-
Notifications
You must be signed in to change notification settings - Fork 0
/
raw_data.php
365 lines (329 loc) · 16.1 KB
/
raw_data.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?php
$timing['start'] = microtime(true);
include('config/config.php');
global $map, $fork;
// set content type
header('Content-Type: application/json');
$now = new DateTime();
$now->sub(new DateInterval('PT20S'));
$d = array();
$d["timestamp"] = $now->getTimestamp();
$swLat = !empty($_POST['swLat']) ? $_POST['swLat'] : 0;
$neLng = !empty($_POST['neLng']) ? $_POST['neLng'] : 0;
$swLng = !empty($_POST['swLng']) ? $_POST['swLng'] : 0;
$neLat = !empty($_POST['neLat']) ? $_POST['neLat'] : 0;
$oSwLat = !empty($_POST['oSwLat']) ? $_POST['oSwLat'] : 0;
$oSwLng = !empty($_POST['oSwLng']) ? $_POST['oSwLng'] : 0;
$oNeLat = !empty($_POST['oNeLat']) ? $_POST['oNeLat'] : 0;
$oNeLng = !empty($_POST['oNeLng']) ? $_POST['oNeLng'] : 0;
$lures = !empty($_POST['lures']) ? $_POST['lures'] : false;
$rocket = !empty($_POST['rocket']) ? $_POST['rocket'] : false;
$raids = !empty($_POST['raids']) ? $_POST['raids'] : false;
$quests = !empty($_POST['quests']) ? $_POST['quests'] : false;
$dustamount = isset($_POST['dustamount']) ? $_POST['dustamount'] : false;
$nestavg = isset($_POST['nestavg']) ? $_POST['nestavg'] : false;
$reloaddustamount = !empty($_POST['reloaddustamount']) ? $_POST['reloaddustamount'] : false;
$newportals = !empty($_POST['newportals']) ? $_POST['newportals'] : 0;
$minIv = isset($_POST['minIV']) ? floatval($_POST['minIV']) : false;
$prevMinIv = !empty($_POST['prevMinIV']) ? $_POST['prevMinIV'] : false;
$minLevel = isset($_POST['minLevel']) ? intval($_POST['minLevel']) : false;
$prevMinLevel = !empty($_POST['prevMinLevel']) ? $_POST['prevMinLevel'] : false;
$exMinIv = !empty($_POST['exMinIV']) ? $_POST['exMinIV'] : '';
$bigKarp = !empty($_POST['bigKarp']) ? $_POST['bigKarp'] : false;
$tinyRat = !empty($_POST['tinyRat']) ? $_POST['tinyRat'] : false;
$lastpokemon = !empty($_POST['lastpokemon']) ? $_POST['lastpokemon'] : false;
$lastgyms = !empty($_POST['lastgyms']) ? $_POST['lastgyms'] : false;
$lastpokestops = !empty($_POST['lastpokestops']) ? $_POST['lastpokestops'] : false;
$lastlocs = !empty($_POST['lastslocs']) ? $_POST['lastslocs'] : false;
$lastspawns = !empty($_POST['lastspawns']) ? $_POST['lastspawns'] : false;
$lastnests = !empty($_POST['lastnests']) ? $_POST['lastnests'] : false;
$lastcommunities = !empty($_POST['lastcommunities']) ? $_POST['lastcommunities'] : false;
$lastportals = !empty($_POST['lastportals']) ? $_POST['lastportals'] : false;
$lastpois = !empty($_POST['lastpois']) ? $_POST['lastpois'] : false;
$exEligible = !empty($_POST['exEligible']) ? $_POST['exEligible'] : false;
$d["lastscanlocations"] = !empty($_POST['scanlocations']) ? $_POST['scanlocations'] : false;
$d["lastpokestops"] = !empty($_POST['pokestops']) ? $_POST['pokestops'] : false;
$d["lastgyms"] = !empty($_POST['gyms']) ? $_POST['gyms'] : false;
$d["lastslocs"] = !empty($_POST['scanned']) ? $_POST['scanned'] : false;
$d["lastspawns"] = !empty($_POST['spawnpoints']) ? $_POST['spawnpoints'] : false;
$d["lastpokemon"] = !empty($_POST['pokemon']) ? $_POST['pokemon'] : false;
$d["lastnests"] = !empty($_POST['nests']) ? $_POST['nests'] : false;
$d["lastcommunities"] = !empty($_POST['communities']) ? $_POST['communities'] : false;
$d["lastportals"] = !empty($_POST['portals']) ? $_POST['portals'] : false;
$d["lastpois"] = !empty($_POST['pois']) ? $_POST['pois'] : false;
if ($minIv < $prevMinIv || $minLevel < $prevMinLevel) {
$lastpokemon = false;
}
$enc_id = !empty($_POST['encId']) ? $_POST['encId'] : null;
$timestamp = !empty($_POST['timestamp']) ? $_POST['timestamp'] : 0;
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if (empty($swLat) || empty($swLng) || empty($neLat) || empty($neLng) || preg_match("/curl|libcurl/", $useragent)) {
http_response_code(403);
die();
}
if ($maxLatLng > 0 && ((($neLat - $swLat) > $maxLatLng) || (($neLng - $swLng) > $maxLatLng))) {
http_response_code(413);
die();
}
$validity = validateToken($_POST['token']);
if (!empty($validity)) {
switch ($validity) {
case 'invalid':
http_response_code(401);
break;
case 'no-id':
http_response_code(404);
break;
}
}
$debug['0_after_auth'] = microtime(true) - $timing['start'];
// init map
if (strtolower($map) === "rdm") {
if (strtolower($fork) === "default" || strtolower($fork) === "beta") {
$scanner = new \Scanner\RDM();
}
} elseif (strtolower($map) === "rocketmap") {
if (strtolower($fork) === "mad") {
$scanner = new \Scanner\RocketMap_MAD();
}
}
$manual = new \Manual\Manual();
$newarea = false;
if (($oSwLng < $swLng) && ($oSwLat < $swLat) && ($oNeLat > $neLat) && ($oNeLng > $neLng)) {
$newarea = false;
} elseif (($oSwLat != $swLat) && ($oSwLng != $swLng) && ($oNeLat != $neLat) && ($oNeLng != $neLng)) {
$newarea = true;
} else {
$newarea = false;
}
$d["oSwLat"] = $swLat;
$d["oSwLng"] = $swLng;
$d["oNeLat"] = $neLat;
$d["oNeLng"] = $neLng;
$ids = array();
$eids = array();
$reids = array();
$qpeids = array();
$qpreids = array();
$qieids = array();
$qireids = array();
$qeeids = array();
$qereids = array();
$geids = array();
$greids = array();
$rbeids = array();
$rbreids = array();
$reeids = array();
$rereids = array();
$debug['1_before_functions'] = microtime(true) - $timing['start'];
global $noPokemon;
if (!$noPokemon) {
if ($d["lastpokemon"] == "true") {
$eids = !empty($_POST['eids']) ? explode(",", $_POST['eids']) : array();
if ($lastpokemon != 'true') {
$d["pokemons"] = $scanner->get_active($eids, $minIv, $minLevel, $exMinIv, $bigKarp, $tinyRat, $swLat, $swLng, $neLat, $neLng, 0, 0, 0, 0, 0, $enc_id);
} else {
if ($newarea) {
$d["pokemons"] = $scanner->get_active($eids, $minIv, $minLevel, $exMinIv, $bigKarp, $tinyRat, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $enc_id);
} else {
$d["pokemons"] = $scanner->get_active($eids, $minIv, $minLevel, $exMinIv, $bigKarp, $tinyRat, $swLat, $swLng, $neLat, $neLng, $timestamp, 0, 0, 0, 0, $enc_id);
}
}
$d["preMinIV"] = $minIv;
$d["preMinLevel"] = $minLevel;
if (!empty($_POST['reids'])) {
$reids = !empty($_POST['reids']) ? array_unique(explode(",", $_POST['reids'])) : array();
$reidsDiff = array_diff($reids, $eids);
if (count($reidsDiff)) {
$d["pokemons"] = array_merge($d["pokemons"], $scanner->get_active_by_id($reidsDiff, $minIv, $minLevel, $exMinIv, $bigKarp, $tinyRat, $swLat, $swLng, $neLat, $neLng));
}
$d["reids"] = $reids;
}
}
}
$debug['2_after_pokemon'] = microtime(true) - $timing['start'];
global $noPokestops, $map, $fork;
if (!$noPokestops) {
if ($d["lastpokestops"] == "true") {
$qpeids = !empty($_POST['qpeids']) ? explode(",", $_POST['qpeids']) : array();
$qieids = !empty($_POST['qieids']) ? explode(",", $_POST['qieids']) : array();
$qeeids = !empty($_POST['qeeids']) ? explode(",", $_POST['qeeids']) : array();
$geids = !empty($_POST['geids']) ? explode(",", $_POST['geids']) : array();
if ($lastpokestops != "true") {
$d["pokestops"] = $scanner->get_stops($geids, $qpeids, $qeeids, $qieids, $swLat, $swLng, $neLat, $neLng, 0, 0, 0, 0, 0, $lures, $rocket, $quests, $dustamount);
} else {
if ($newarea) {
$d["pokestops"] = $scanner->get_stops($geids, $qpeids, $qeeids, $qieids, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $lures, $rocket, $quests, $dustamount);
} else {
$d["pokestops"] = $scanner->get_stops($geids, $qpeids, $qeeids, $qieids, $swLat, $swLng, $neLat, $neLng, $timestamp, 0, 0, 0, 0, $lures, $rocket, $quests, $dustamount);
}
}
if ((strtolower($map) === "rdm") || (strtolower($map) === "rocketmap" && strtolower($fork) === "mad")) {
if ($reloaddustamount == "true") {
$d["pokestops"] = array_merge($d["pokestops"], $scanner->get_stops_quest($greids, $qpreids, $qereids, $qireids, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $lures, $rocket, $quests, $dustamount, $reloaddustamount));
}
if (!empty($_POST['qpreids'])) {
$qpreids = !empty($_POST['qpreids']) ? array_unique(explode(",", $_POST['qpreids'])) : array();
$qpreidsDiff = array_diff($qpreids, $qpeids);
if (count($qpreidsDiff)) {
$d["pokestops"] = array_merge($d["pokestops"], $scanner->get_stops_quest($greids, $qpreids, $qereids, $qireids, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $lures, $rocket, $quests, $dustamount, $reloaddustamount));
}
$d["qpreids"] = $qpreids;
}
if (!empty($_POST['qereids'])) {
$qereids = !empty($_POST['qereids']) ? array_unique(explode(",", $_POST['qereids'])) : array();
$qereidsDiff = array_diff($qereids, $qeeids);
if (count($qereidsDiff)) {
$d["pokestops"] = array_merge($d["pokestops"], $scanner->get_stops_quest($greids, $qpreids, $qereids, $qireids, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $lures, $rocket, $quests, $dustamount, $reloaddustamount));
}
$d["qereids"] = $qereids;
}
if (!empty($_POST['qireids'])) {
$qireids = !empty($_POST['qireids']) ? array_unique(explode(",", $_POST['qireids'])) : array();
$qireidsDiff = array_diff($qireids, $qieids);
if (count($qireidsDiff)) {
$d["pokestops"] = array_merge($d["pokestops"], $scanner->get_stops_quest($greids, $qpreids, $qereids, $qireids, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $lures, $rocket, $quests, $dustamount, $reloaddustamount));
}
$d["qireids"] = $qireids;
}
if (!empty($_POST['greids'])) {
$greids = !empty($_POST['greids']) ? array_unique(explode(",", $_POST['greids'])) : array();
$greidsDiff = array_diff($greids, $geids);
if (count($greidsDiff)) {
$d["pokestops"] = array_merge($d["pokestops"], $scanner->get_stops_quest($greids, $qpreids, $qereids, $qireids, $swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $lures, $rocket, $quests, $dustamount, $reloaddustamount));
}
$d["greids"] = $greids;
}
}
}
}
$debug['3_after_pokestops'] = microtime(true) - $timing['start'];
global $noGyms, $noRaids;
if (!$noGyms || !$noRaids) {
if ($d["lastgyms"] == "true" || $raids == "true") {
$gyms = $d["lastgyms"];
$rbeids = !empty($_POST['rbeids']) ? explode(",", $_POST['rbeids']) : array();
$reeids = !empty($_POST['reeids']) ? explode(",", $_POST['reeids']) : array();
if ($lastgyms != "true") {
$d["gyms"] = $scanner->get_gyms($rbeids, $reeids, $swLat, $swLng, $neLat, $neLng, $exEligible, 0, 0, 0, 0, 0, $raids, $gyms);
} else {
if ($newarea) {
$d["gyms"] = $scanner->get_gyms($rbeids, $reeids, $swLat, $swLng, $neLat, $neLng, $exEligible, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $raids, $gyms);
} else {
$d["gyms"] = $scanner->get_gyms($rbeids, $reeids, $swLat, $swLng, $neLat, $neLng, $exEligible, $timestamp, 0, 0, 0, 0, $raids, $gyms);
}
}
if (!empty($_POST['rbreids'])) {
$rbreids = !empty($_POST['rbreids']) ? array_unique(explode(",", $_POST['rbreids'])) : array();
$rbreidsDiff = array_diff($rbreids, $rbeids);
if (count($rbreidsDiff)) {
$d["gyms"] = array_merge($d["gyms"], $scanner->get_gyms($rbeids, $reeids, $swLat, $swLng, $neLat, $neLng, $exEligible, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $raids, $gyms));
}
$d["rbreids"] = $rbreids;
}
if (!empty($_POST['rereids'])) {
$rereids = !empty($_POST['rereids']) ? array_unique(explode(",", $_POST['rereids'])) : array();
$rereidsDiff = array_diff($rereids, $reeids);
if (count($rereidsDiff)) {
$d["gyms"] = array_merge($d["gyms"], $scanner->get_gyms($rbeids, $reeids, $swLat, $swLng, $neLat, $neLng, $exEligible, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $raids, $gyms));
}
$d["rereids"] = $rereids;
}
}
}
$debug['4_after_gyms'] = microtime(true) - $timing['start'];
global $noNests;
if (!$noNests) {
if ($d["lastnests"] == "true") {
if ($lastnests != "true") {
$d["nests"] = $manual->get_nests($swLat, $swLng, $neLat, $neLng, 0, 0, 0, 0, 0, $nestavg);
} else {
if ($newarea) {
$d["nests"] = $manual->get_nests($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $nestavg);
} else {
$d["nests"] = $manual->get_nests($swLat, $swLng, $neLat, $neLng, time(), 0, 0, 0, 0, $nestavg);
}
}
}
}
$debug['5_after_nest'] = microtime(true) - $timing['start'];
global $noCommunity;
if (!$noCommunity) {
if ($d["lastcommunities"] == "true") {
if ($lastcommunities != "true") {
$d["communities"] = $manual->get_communities($swLat, $swLng, $neLat, $neLng);
} else {
if ($newarea) {
$d["communities"] = $manual->get_communities($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng);
} else {
$d["communities"] = $manual->get_communities($swLat, $swLng, $neLat, $neLng, time());
}
}
}
}
$debug['6_after_community'] = microtime(true) - $timing['start'];
global $noPortals;
if (!$noPortals) {
if ($d["lastportals"] == "true") {
if ($lastportals != "true") {
$d["portals"] = $manual->get_portals($swLat, $swLng, $neLat, $neLng, 0, 0, 0, 0, 0, $newportals);
} else {
if ($newarea) {
$d["portals"] = $manual->get_portals($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $newportals);
} else {
$d["portals"] = $manual->get_portals($swLat, $swLng, $neLat, $neLng, time(), 0, 0, 0, 0, $newportals);
}
}
}
}
$debug['7_after_portals'] = microtime(true) - $timing['start'];
global $noPoi;
if (!$noPoi) {
if ($d["lastpois"] == "true") {
if ($lastpois != "true") {
$d["pois"] = $manual->get_poi($swLat, $swLng, $neLat, $neLng, 0, 0, 0, 0, 0);
} else {
if ($newarea) {
$d["pois"] = $manual->get_poi($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng);
} else {
$d["pois"] = $manual->get_poi($swLat, $swLng, $neLat, $neLng, time(), 0, 0, 0, 0);
}
}
}
}
$debug['8_after_poi'] = microtime(true) - $timing['start'];
global $noSpawnPoints;
if (!$noSpawnPoints) {
if ($d["lastspawns"] == "true") {
if ($lastspawns != "true") {
$d["spawnpoints"] = $scanner->get_spawnpoints($swLat, $swLng, $neLat, $neLng);
} else {
if ($newarea) {
$d["spawnpoints"] = $scanner->get_spawnpoints($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng);
} else {
$d["spawnpoints"] = $scanner->get_spawnpoints($swLat, $swLng, $neLat, $neLng, $timestamp);
}
}
}
}
$debug['9_after_spawnpoints'] = microtime(true) - $timing['start'];
global $noLiveScanLocation;
if (!$noLiveScanLocation) {
if ($d["lastscanlocations"] == "true") {
if ($newarea) {
$d["scanlocations"] = $scanner->get_scanlocation($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng);
} else {
$d["scanlocations"] = $scanner->get_scanlocation($swLat, $swLng, $neLat, $neLng, $timestamp);
}
}
}
$debug['10_after_devices'] = microtime(true) - $timing['start'];
$d['token'] = refreshCsrfToken();
$debug['11_end'] = microtime(true) - $timing['start'];
if ($enableDebug == true) {
foreach ($debug as $k => $v) {
header("X-Debug-Time-" . $k . ": " . $v);
}
}
$jaysson = json_encode($d);
echo $jaysson;