This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
raw_data.php
204 lines (182 loc) · 7.8 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
<?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;
$luredonly = !empty($_POST['luredonly']) ? $_POST['luredonly'] : false;
$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;
$exEligible = !empty($_POST['exEligible']) ? $_POST['exEligible'] : 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;
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(400);
die();
}
if ($maxLatLng > 0 && ((($neLat - $swLat) > $maxLatLng) || (($neLng - $swLng) > $maxLatLng))) {
http_response_code(400);
die();
}
if (!validateToken($_POST['token'])) {
http_response_code(400);
die();
}
// init map
if (strtolower($map) === "monocle") {
if (strtolower($fork) === "asner") {
$scanner = new \Scanner\Monocle_Asner();
} elseif (strtolower($fork) === "default") {
$scanner = new \Scanner\Monocle();
} else {
$scanner = new \Scanner\Monocle_Alternate();
}
} elseif (strtolower($map) === "rm") {
if (strtolower($fork) === "sloppy") {
$scanner = new \Scanner\RocketMap_Sloppy();
} else {
$scanner = new \Scanner\RocketMap();
}
}
$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();
$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;
if (!$noPokestops) {
if ($d["lastpokestops"] == "true") {
if ($lastpokestops != "true") {
$d["pokestops"] = $scanner->get_stops($swLat, $swLng, $neLat, $neLng, 0, 0, 0, 0, 0, $luredonly);
} else {
if ($newarea) {
$d["pokestops"] = $scanner->get_stops($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng, $luredonly);
} else {
$d["pokestops"] = $scanner->get_stops($swLat, $swLng, $neLat, $neLng, $timestamp, 0, 0, 0, 0, $luredonly);
}
}
}
}
$debug['3_after_pokestops'] = microtime(true) - $timing['start'];
global $noGyms, $noRaids;
if (!$noGyms || !$noRaids) {
if ($d["lastgyms"] == "true") {
if ($lastgyms != "true") {
$d["gyms"] = $scanner->get_gyms($swLat, $swLng, $neLat, $neLng, $exEligible);
} else {
if ($newarea) {
$d["gyms"] = $scanner->get_gyms($swLat, $swLng, $neLat, $neLng, $exEligible, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng);
} else {
$d["gyms"] = $scanner->get_gyms($swLat, $swLng, $neLat, $neLng, $exEligible, $timestamp);
}
}
}
}
$debug['4_after_gyms'] = 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['5_after_spawnpoints'] = microtime(true) - $timing['start'];
global $noScannedLocations;
if (!$noScannedLocations) {
if ($d["lastslocs"] == "true") {
if ($lastlocs != "true") {
$d["scanned"] = $scanner->get_recent($swLat, $swLng, $neLat, $neLng);
} else {
if ($newarea) {
$d["scanned"] = $scanner->get_recent($swLat, $swLng, $neLat, $neLng, 0, $oSwLat, $oSwLng, $oNeLat, $oNeLng);
} else {
$d["scanned"] = $scanner->get_recent($swLat, $swLng, $neLat, $neLng, $timestamp);
}
}
}
}
$debug['6_after_recent'] = microtime(true) - $timing['start'];
$d['token'] = refreshCsrfToken();
$debug['7_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;