-
Notifications
You must be signed in to change notification settings - Fork 0
/
apar_main.php
230 lines (203 loc) · 7.56 KB
/
apar_main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
// 方块盒子Auth接入工具 ArkPowered-Auth-Requester
// Release v1.0.1
// 23w03a
// Update Release 00003 on 2023/1/24
// 您的accessID_v3信息
$enable_apar = true; //这个设置暂时没啥用
$List = array(
"accessID_v3" => false,
"userName" => false,
"userVerifyToken" => false
);
// 您的accessID_v3信息
class Basic_Function
{
protected function f_get($url)
{
$get_array = file_get_contents($url);
$out_array = json_decode($get_array, true);
return $out_array;
}
}
class apar_Checker extends Basic_Function
{
public function check_Setting()
{
global $List;
if ($List["accessID_v3"] == false || $List["userName"] == false || $List["userVerifyToken"] == false) {
echo "您需要到程序顶部设置您的ID和自己的账户信息";
} else {
$basic = new Basic_Function();
$auth_status = $basic->f_get("https://auth.arkpowered.cn/api/checkAPARSetting?accessid={$List['accessID_v3']}&username={$List['userName']}&userVerifyToken={$List['userVerifyToken']}");
if ($auth_status) {
if ($auth_status["success"] == true) {
} else {
echo "您的APAR配置不正确!";
}
} else {
echo "目前APAR无法连接到验证服务器,您可以在设置项中暂时取消使用APAR";
}
}
}
}
class apar_Main extends Basic_Function
{
// goto 验证页面
public function goto_authorize()
{
global $List;
$basic = new Basic_Function();
$auth_status = $basic->f_get("https://auth.arkpowered.cn");
$manifest = $basic->f_get("https://api.arkpowered.cn/api/manifest.json");
if ($auth_status) {
if ($auth_status["Status"] == "OK") {
if ($manifest) {
$output = array(
"Status" => "OK"
);
header("location: //id.arkpowered.cn/api/public/cauth/v3/authorize?accessid={$List['accessID_v3']}");
} else {
$output = array(
"Status" => "Offline",
"msg" => "ID Server Down"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Temporary Maintenance"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Down"
);
}
return $output;
}
// 请求用户信息
public function require_userdata($name, $token)
{
global $List;
$basic = new Basic_Function();
$auth_status = $basic->f_get("https://auth.arkpowered.cn");
$manifest = $basic->f_get("https://api.arkpowered.cn/api/manifest.json");
if ($auth_status) {
if ($auth_status["Status"] == "OK") {
$re_data = $basic->f_get($manifest["protocol"] . "://" . $manifest["apiaddress"]["cauth3"]["get-userdata"] . "?accessid={$List['accessID_v3']}&username={$name}&accesstoken={$token}");
if ($re_data) {
$output = array(
"Status" => "OK",
"info" => $re_data
);
} else {
$output = array(
"Status" => "Offline",
"msg" => "ID Server Down"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Temporary Maintenance"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Down"
);
}
return $output;
}
public function require_recyclingAccessToken($name, $token)
{
global $List;
$basic = new Basic_Function();
$auth_status = $basic->f_get("https://auth.arkpowered.cn");
$manifest = $basic->f_get("https://api.arkpowered.cn/api/manifest.json");
if ($auth_status) {
if ($auth_status["Status"] == "OK") {
$re_data = $basic->f_get($manifest["protocol"] . "://" . $manifest["apiaddress"]["cauth3"]["recycling-accesstoken"] . "?accessid={$List['accessID_v3']}&username={$name}&accesstoken={$token}");
if ($re_data) {
$output = array(
"Status" => "OK"
);
} else {
$output = array(
"Status" => "Offline",
"msg" => "ID Server Down"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Temporary Maintenance"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Down"
);
}
return $output;
}
// 这个接口能不用就不用,因为CA3的get-userdata疑似正在替代他
public function verify_userInformation($name, $token)
{
$basic = new Basic_Function();
$auth_status = $basic->f_get("https://auth.arkpowered.cn");
$manifest = $basic->f_get("https://api.arkpowered.cn/api/manifest.json");
if ($auth_status) {
if ($auth_status["Status"] == "OK") {
$re_data = $basic->f_get($manifest["protocol"] . "://" . $manifest["apiaddress"]["verify-user"] . "?username={$name}&token={$token}");
if ($re_data) {
$output = array(
"Status" => "OK",
"info" => $re_data
);
} else {
$output = array(
"Status" => "Offline",
"msg" => "ID Server Down"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Temporary Maintenance"
);
}
} else {
$output = array(
"Status" => "Offline",
"msg" => "Auth Server Down"
);
}
return $output;
}
// 返回一个非json信息,如果信息正确返回userVerifyToken(注意保护用户隐私),如果错误返回NO(纯String,建议使用Basic->f_get返回)
public function getUserStatus_noJson($name, $token)
{
$basic = new Basic_Function();
$auth_status = $basic->f_get("https://auth.arkpowered.cn");
if ($auth_status) {
if ($auth_status["Status"] == "OK") {
$return = $basic->f_get("https://auth.arkpowered.cn/api/account/arkpowered?method=login&username={$name}&token={$token}");
if ($return != "NO") {
$output = $return;
} else {
$output = "NO";
}
} else {
$output = "NO";
}
} else {
$output = "NO";
}
return $output;
}
}