@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | <?php |
48 | 48 | } else { |
49 | 49 | switch ($_GET['page']) { |
50 | - case 'pokemon': |
|
51 | - ?> |
|
50 | + case 'pokemon': |
|
51 | + ?> |
|
52 | 52 | |
53 | 53 | <title><?= $config->infos->site_name; ?> | <?= $locales->FIND; ?> <?= $pokemon->name; ?> <?= sprintf($locales->INCITY, $config->infos->city); ?></title> |
54 | 54 | |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | <?php |
74 | - break; |
|
74 | + break; |
|
75 | 75 | |
76 | - case 'pokestops': |
|
77 | - ?> |
|
76 | + case 'pokestops': |
|
77 | + ?> |
|
78 | 78 | |
79 | 79 | |
80 | 80 | <title><?= $config->infos->site_name; ?> | <?= sprintf($locales->POKESTOPS_METATITLE, $config->infos->city); ?></title> |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | |
98 | 98 | |
99 | 99 | <?php |
100 | - break; |
|
100 | + break; |
|
101 | 101 | |
102 | - case 'gym': |
|
103 | - ?> |
|
102 | + case 'gym': |
|
103 | + ?> |
|
104 | 104 | |
105 | 105 | <title><?= $config->infos->site_name; ?> | <?= $locales->GYMS_METATITLE; ?></title> |
106 | 106 | |
@@ -122,10 +122,10 @@ discard block |
||
122 | 122 | <meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" /> |
123 | 123 | |
124 | 124 | <?php |
125 | - break; |
|
125 | + break; |
|
126 | 126 | |
127 | - case 'trainer': |
|
128 | - ?> |
|
127 | + case 'trainer': |
|
128 | + ?> |
|
129 | 129 | |
130 | 130 | <title><?= $config->infos->site_name; ?> | <?= $locales->TRAINERS_METATITLE; ?></title> |
131 | 131 | |
@@ -146,10 +146,10 @@ discard block |
||
146 | 146 | <meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" /> |
147 | 147 | |
148 | 148 | <?php |
149 | - break; |
|
149 | + break; |
|
150 | 150 | |
151 | - case 'dashboard': |
|
152 | - ?> |
|
151 | + case 'dashboard': |
|
152 | + ?> |
|
153 | 153 | |
154 | 154 | <title><?= $config->infos->site_name; ?> | <?= $locales->NAV_DASHBOARD; ?></title> |
155 | 155 | |
@@ -171,10 +171,10 @@ discard block |
||
171 | 171 | |
172 | 172 | |
173 | 173 | <?php |
174 | - break; |
|
174 | + break; |
|
175 | 175 | |
176 | - case 'pokedex': |
|
177 | - ?> |
|
176 | + case 'pokedex': |
|
177 | + ?> |
|
178 | 178 | |
179 | 179 | <title><?= $config->infos->site_name; ?> | <?= $locales->POKEDEX_METATITLE; ?></title> |
180 | 180 | |
@@ -195,10 +195,10 @@ discard block |
||
195 | 195 | <meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" /> |
196 | 196 | |
197 | 197 | <?php |
198 | - break; |
|
198 | + break; |
|
199 | 199 | |
200 | - case 'nests': |
|
201 | - ?> |
|
200 | + case 'nests': |
|
201 | + ?> |
|
202 | 202 | |
203 | 203 | <title><?= $config->infos->site_name; ?> | <?= $locales->NAV_NESTS; ?></title> |
204 | 204 | |
@@ -219,10 +219,10 @@ discard block |
||
219 | 219 | <meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" /> |
220 | 220 | |
221 | 221 | <?php |
222 | - break; |
|
222 | + break; |
|
223 | 223 | |
224 | - case 'raids': |
|
225 | - ?> |
|
224 | + case 'raids': |
|
225 | + ?> |
|
226 | 226 | |
227 | 227 | <title><?= $config->infos->site_name; ?> | <?= $locales->NAV_RAIDS; ?></title> |
228 | 228 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | <meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" /> |
244 | 244 | |
245 | 245 | <?php |
246 | - break; |
|
246 | + break; |
|
247 | 247 | |
248 | - case 'gymhistory': |
|
249 | - ?> |
|
248 | + case 'gymhistory': |
|
249 | + ?> |
|
250 | 250 | |
251 | 251 | <title><?= $config->infos->site_name; ?> | Gym History</title> |
252 | 252 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | <meta name="twitter:image" content="<?= HOST_URL; ?>core/img/logo.jpg" /> |
268 | 268 | |
269 | 269 | <?php |
270 | - break; |
|
270 | + break; |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 |
@@ -56,116 +56,116 @@ discard block |
||
56 | 56 | // |
57 | 57 | //########################### |
58 | 58 | |
59 | - case 'home_update': |
|
60 | - $values = []; |
|
61 | - // Right now |
|
62 | - // --------- |
|
63 | - $data = $manager->getTotalPokemon(); |
|
64 | - $values[] = $data->total; |
|
65 | - |
|
66 | - // Lured stops |
|
67 | - // ----------- |
|
68 | - $data = $manager->getTotalLures(); |
|
69 | - $values[] = $data->total; |
|
70 | - |
|
71 | - // Active Raids |
|
72 | - // ----------- |
|
73 | - $data = $manager->getTotalRaids(); |
|
74 | - $values[] = $data->total; |
|
75 | - |
|
76 | - // Team battle |
|
77 | - // ----------- |
|
78 | - $data = $manager->getTotalGyms(); |
|
79 | - $values[] = $data->total; |
|
80 | - |
|
81 | - // Red |
|
82 | - $data = $manager->getTotalGymsForTeam(2); |
|
83 | - $values[] = $data->total; |
|
84 | - |
|
85 | - // Blue |
|
86 | - $data = $manager->getTotalGymsForTeam(1); |
|
87 | - $values[] = $data->total; |
|
88 | - |
|
89 | - // Yellow |
|
90 | - $data = $manager->getTotalGymsForTeam(3); |
|
91 | - $values[] = $data->total; |
|
92 | - |
|
93 | - // Neutral |
|
94 | - $data = $manager->getTotalGymsForTeam(0); |
|
95 | - $values[] = $data->total; |
|
96 | - |
|
97 | - header('Content-Type: application/json'); |
|
98 | - echo json_encode($values); |
|
99 | - |
|
100 | - break; |
|
101 | - |
|
102 | - //################################### |
|
103 | - // |
|
104 | - // Update latests spawn on homepage |
|
105 | - // |
|
106 | - //################################### |
|
107 | - |
|
108 | - case 'spawnlist_update': |
|
109 | - // Recent spawn |
|
110 | - // ------------ |
|
111 | - $total_spawns = array(); |
|
112 | - $last_uid_param = ''; |
|
113 | - if (isset($_GET['last_uid'])) { |
|
114 | - $last_uid_param = $_GET['last_uid']; |
|
115 | - } |
|
116 | - if ($config->system->recents_filter) { |
|
117 | - // get all mythic pokemon ids |
|
118 | - $mythic_pokemons = array(); |
|
119 | - foreach ($pokemons->pokemon as $id => $pokemon) { |
|
120 | - if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
121 | - $mythic_pokemons[] = $id; |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - // get last mythic pokemon |
|
126 | - $result = $manager->getRecentMythic($mythic_pokemons); |
|
127 | - } else { |
|
128 | - // get last pokemon |
|
129 | - $result = $manager->getRecentAll(); |
|
130 | - } |
|
131 | - |
|
132 | - if (count($result) > 0) { |
|
133 | - foreach ($result as $data) { |
|
134 | - $new_spawn = array(); |
|
135 | - $pokeid = $data->pokemon_id; |
|
136 | - $pokeuid = $data->encounter_id; |
|
137 | - |
|
138 | - if ($last_uid_param != $pokeuid) { |
|
139 | - $last_seen = strtotime($data->disappear_time_real); |
|
140 | - |
|
141 | - $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
142 | - $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
143 | - $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
144 | - |
|
145 | - if ($config->system->recents_encounter_details) { |
|
146 | - $encdetails = new stdClass(); |
|
147 | - $encdetails->cp = $data->cp; |
|
148 | - $encdetails->attack = $data->individual_attack; |
|
149 | - $encdetails->defense = $data->individual_defense; |
|
150 | - $encdetails->stamina = $data->individual_stamina; |
|
151 | - if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
152 | - $encdetails->available = true; |
|
153 | - } else { |
|
154 | - $encdetails->available = false; |
|
155 | - } |
|
156 | - } |
|
157 | - |
|
158 | - $html = ' |
|
59 | + case 'home_update': |
|
60 | + $values = []; |
|
61 | + // Right now |
|
62 | + // --------- |
|
63 | + $data = $manager->getTotalPokemon(); |
|
64 | + $values[] = $data->total; |
|
65 | + |
|
66 | + // Lured stops |
|
67 | + // ----------- |
|
68 | + $data = $manager->getTotalLures(); |
|
69 | + $values[] = $data->total; |
|
70 | + |
|
71 | + // Active Raids |
|
72 | + // ----------- |
|
73 | + $data = $manager->getTotalRaids(); |
|
74 | + $values[] = $data->total; |
|
75 | + |
|
76 | + // Team battle |
|
77 | + // ----------- |
|
78 | + $data = $manager->getTotalGyms(); |
|
79 | + $values[] = $data->total; |
|
80 | + |
|
81 | + // Red |
|
82 | + $data = $manager->getTotalGymsForTeam(2); |
|
83 | + $values[] = $data->total; |
|
84 | + |
|
85 | + // Blue |
|
86 | + $data = $manager->getTotalGymsForTeam(1); |
|
87 | + $values[] = $data->total; |
|
88 | + |
|
89 | + // Yellow |
|
90 | + $data = $manager->getTotalGymsForTeam(3); |
|
91 | + $values[] = $data->total; |
|
92 | + |
|
93 | + // Neutral |
|
94 | + $data = $manager->getTotalGymsForTeam(0); |
|
95 | + $values[] = $data->total; |
|
96 | + |
|
97 | + header('Content-Type: application/json'); |
|
98 | + echo json_encode($values); |
|
99 | + |
|
100 | + break; |
|
101 | + |
|
102 | + //################################### |
|
103 | + // |
|
104 | + // Update latests spawn on homepage |
|
105 | + // |
|
106 | + //################################### |
|
107 | + |
|
108 | + case 'spawnlist_update': |
|
109 | + // Recent spawn |
|
110 | + // ------------ |
|
111 | + $total_spawns = array(); |
|
112 | + $last_uid_param = ''; |
|
113 | + if (isset($_GET['last_uid'])) { |
|
114 | + $last_uid_param = $_GET['last_uid']; |
|
115 | + } |
|
116 | + if ($config->system->recents_filter) { |
|
117 | + // get all mythic pokemon ids |
|
118 | + $mythic_pokemons = array(); |
|
119 | + foreach ($pokemons->pokemon as $id => $pokemon) { |
|
120 | + if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
121 | + $mythic_pokemons[] = $id; |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + // get last mythic pokemon |
|
126 | + $result = $manager->getRecentMythic($mythic_pokemons); |
|
127 | + } else { |
|
128 | + // get last pokemon |
|
129 | + $result = $manager->getRecentAll(); |
|
130 | + } |
|
131 | + |
|
132 | + if (count($result) > 0) { |
|
133 | + foreach ($result as $data) { |
|
134 | + $new_spawn = array(); |
|
135 | + $pokeid = $data->pokemon_id; |
|
136 | + $pokeuid = $data->encounter_id; |
|
137 | + |
|
138 | + if ($last_uid_param != $pokeuid) { |
|
139 | + $last_seen = strtotime($data->disappear_time_real); |
|
140 | + |
|
141 | + $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
142 | + $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
143 | + $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
144 | + |
|
145 | + if ($config->system->recents_encounter_details) { |
|
146 | + $encdetails = new stdClass(); |
|
147 | + $encdetails->cp = $data->cp; |
|
148 | + $encdetails->attack = $data->individual_attack; |
|
149 | + $encdetails->defense = $data->individual_defense; |
|
150 | + $encdetails->stamina = $data->individual_stamina; |
|
151 | + if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
152 | + $encdetails->available = true; |
|
153 | + } else { |
|
154 | + $encdetails->available = false; |
|
155 | + } |
|
156 | + } |
|
157 | + |
|
158 | + $html = ' |
|
159 | 159 | <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;"> |
160 | 160 | <a href="pokemon/'.$pokeid.'"><img src="'.$pokemons->pokemon->$pokeid->img.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a> |
161 | 161 | <a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a> |
162 | 162 | <a href="'.$location_link.'" target="_blank"> |
163 | 163 | <small class="pokemon-timer">00:00:00</small> |
164 | 164 | </a>'; |
165 | - if ($config->system->recents_encounter_details) { |
|
166 | - if ($encdetails->available) { |
|
167 | - if ($config->system->iv_numbers) { |
|
168 | - $html .= ' |
|
165 | + if ($config->system->recents_encounter_details) { |
|
166 | + if ($encdetails->available) { |
|
167 | + if ($config->system->iv_numbers) { |
|
168 | + $html .= ' |
|
169 | 169 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
170 | 170 | <div title="'.$locales->IV_ATTACK.': '.$encdetails->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
171 | 171 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>'.$encdetails->attack.' |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>'.$encdetails->stamina.' |
178 | 178 | </div> |
179 | 179 | </div>'; |
180 | - } else { |
|
181 | - $html .= ' |
|
180 | + } else { |
|
181 | + $html .= ' |
|
182 | 182 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
183 | 183 | <div title="'.$locales->IV_ATTACK.': '.$encdetails->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $encdetails->attack) / 3).'%"> |
184 | 184 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span> |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span> |
191 | 191 | </div> |
192 | 192 | </div>'; |
193 | - } |
|
194 | - $html .= '<small>'.$encdetails->cp.'</small>'; |
|
195 | - } else { |
|
196 | - if ($config->system->iv_numbers) { |
|
197 | - $html .= ' |
|
193 | + } |
|
194 | + $html .= '<small>'.$encdetails->cp.'</small>'; |
|
195 | + } else { |
|
196 | + if ($config->system->iv_numbers) { |
|
197 | + $html .= ' |
|
198 | 198 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
199 | 199 | <div title="'.$locales->IV_ATTACK.': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
200 | 200 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>? |
@@ -206,111 +206,111 @@ discard block |
||
206 | 206 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>? |
207 | 207 | </div> |
208 | 208 | </div>'; |
209 | - } else { |
|
210 | - $html .= ' |
|
209 | + } else { |
|
210 | + $html .= ' |
|
211 | 211 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
212 | 212 | <div title="IV not available" class="progress-bar" role="progressbar" style="width: 100%; background-color: rgb(210,210,210)" aria-valuenow="1" aria-valuemin="0" aria-valuemax="1"> |
213 | 213 | <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span> |
214 | 214 | </div> |
215 | 215 | </div>'; |
216 | - } |
|
217 | - $html .= '<small>???</small>'; |
|
218 | - } |
|
219 | - } |
|
220 | - $html .= ' |
|
216 | + } |
|
217 | + $html .= '<small>???</small>'; |
|
218 | + } |
|
219 | + } |
|
220 | + $html .= ' |
|
221 | 221 | </div>'; |
222 | - $new_spawn['html'] = $html; |
|
223 | - $countdown = $last_seen - time(); |
|
224 | - $new_spawn['countdown'] = $countdown; |
|
225 | - $new_spawn['pokemon_uid'] = $pokeuid; |
|
226 | - $total_spawns[] = $new_spawn; |
|
227 | - } else { |
|
228 | - break; |
|
229 | - } |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - header('Content-Type: application/json'); |
|
234 | - echo json_encode($total_spawns); |
|
235 | - |
|
236 | - break; |
|
237 | - |
|
238 | - //################################### |
|
239 | - // |
|
240 | - // List Pokestop |
|
241 | - // |
|
242 | - //################################### |
|
243 | - |
|
244 | - case 'pokestop': |
|
245 | - $datas = $manager->getAllPokestops(); |
|
246 | - |
|
247 | - $pokestops = []; |
|
248 | - foreach ($datas as $data) { |
|
249 | - if ($data->lure_expiration >= $data->now) { |
|
250 | - $icon = 'pokestap_lured.png'; |
|
251 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
252 | - $lured = true; |
|
253 | - } else { |
|
254 | - $icon = 'pokestap.png'; |
|
255 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
256 | - $lured = false; |
|
257 | - } |
|
258 | - |
|
259 | - $pokestops[] = [ |
|
260 | - $text, |
|
261 | - $icon, |
|
262 | - $data->latitude, |
|
263 | - $data->longitude, |
|
264 | - $lured, |
|
265 | - ]; |
|
266 | - } |
|
267 | - |
|
268 | - header('Content-Type: application/json'); |
|
269 | - echo json_encode($pokestops); |
|
270 | - |
|
271 | - break; |
|
272 | - |
|
273 | - //################################### |
|
274 | - // |
|
275 | - // Update data for the gym battle |
|
276 | - // |
|
277 | - //################################### |
|
278 | - |
|
279 | - case 'update_gym': |
|
280 | - $teams = new stdClass(); |
|
281 | - $teams->mystic = 1; |
|
282 | - $teams->valor = 2; |
|
283 | - $teams->instinct = 3; |
|
284 | - |
|
285 | - foreach ($teams as $team_name => $team_id) { |
|
286 | - $data = $manager->getOwnedAndPoints($team_id); |
|
287 | - |
|
288 | - $return[] = $data->total; |
|
289 | - $return[] = $data->average_points; |
|
290 | - } |
|
291 | - |
|
292 | - header('Content-Type: application/json'); |
|
293 | - echo json_encode($return); |
|
294 | - |
|
295 | - break; |
|
296 | - |
|
297 | - //################################### |
|
298 | - // |
|
299 | - // Get datas for the gym map |
|
300 | - // |
|
301 | - //################################### |
|
302 | - |
|
303 | - case 'gym_map': |
|
304 | - $datas = $manager->getAllGyms(); |
|
305 | - |
|
306 | - $gyms = []; |
|
307 | - foreach ($datas as $data) { |
|
308 | - // Team |
|
309 | - // 1 = bleu |
|
310 | - // 2 = rouge |
|
311 | - // 3 = jaune |
|
312 | - |
|
313 | - switch ($data->team_id) { |
|
222 | + $new_spawn['html'] = $html; |
|
223 | + $countdown = $last_seen - time(); |
|
224 | + $new_spawn['countdown'] = $countdown; |
|
225 | + $new_spawn['pokemon_uid'] = $pokeuid; |
|
226 | + $total_spawns[] = $new_spawn; |
|
227 | + } else { |
|
228 | + break; |
|
229 | + } |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + header('Content-Type: application/json'); |
|
234 | + echo json_encode($total_spawns); |
|
235 | + |
|
236 | + break; |
|
237 | + |
|
238 | + //################################### |
|
239 | + // |
|
240 | + // List Pokestop |
|
241 | + // |
|
242 | + //################################### |
|
243 | + |
|
244 | + case 'pokestop': |
|
245 | + $datas = $manager->getAllPokestops(); |
|
246 | + |
|
247 | + $pokestops = []; |
|
248 | + foreach ($datas as $data) { |
|
249 | + if ($data->lure_expiration >= $data->now) { |
|
250 | + $icon = 'pokestap_lured.png'; |
|
251 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
252 | + $lured = true; |
|
253 | + } else { |
|
254 | + $icon = 'pokestap.png'; |
|
255 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
256 | + $lured = false; |
|
257 | + } |
|
258 | + |
|
259 | + $pokestops[] = [ |
|
260 | + $text, |
|
261 | + $icon, |
|
262 | + $data->latitude, |
|
263 | + $data->longitude, |
|
264 | + $lured, |
|
265 | + ]; |
|
266 | + } |
|
267 | + |
|
268 | + header('Content-Type: application/json'); |
|
269 | + echo json_encode($pokestops); |
|
270 | + |
|
271 | + break; |
|
272 | + |
|
273 | + //################################### |
|
274 | + // |
|
275 | + // Update data for the gym battle |
|
276 | + // |
|
277 | + //################################### |
|
278 | + |
|
279 | + case 'update_gym': |
|
280 | + $teams = new stdClass(); |
|
281 | + $teams->mystic = 1; |
|
282 | + $teams->valor = 2; |
|
283 | + $teams->instinct = 3; |
|
284 | + |
|
285 | + foreach ($teams as $team_name => $team_id) { |
|
286 | + $data = $manager->getOwnedAndPoints($team_id); |
|
287 | + |
|
288 | + $return[] = $data->total; |
|
289 | + $return[] = $data->average_points; |
|
290 | + } |
|
291 | + |
|
292 | + header('Content-Type: application/json'); |
|
293 | + echo json_encode($return); |
|
294 | + |
|
295 | + break; |
|
296 | + |
|
297 | + //################################### |
|
298 | + // |
|
299 | + // Get datas for the gym map |
|
300 | + // |
|
301 | + //################################### |
|
302 | + |
|
303 | + case 'gym_map': |
|
304 | + $datas = $manager->getAllGyms(); |
|
305 | + |
|
306 | + $gyms = []; |
|
307 | + foreach ($datas as $data) { |
|
308 | + // Team |
|
309 | + // 1 = bleu |
|
310 | + // 2 = rouge |
|
311 | + // 3 = jaune |
|
312 | + |
|
313 | + switch ($data->team_id) { |
|
314 | 314 | case 0: |
315 | 315 | $icon = 'map_white.png'; |
316 | 316 | $team = 'No Team (yet)'; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | $team = 'Team Instinct'; |
335 | 335 | $color = 'rgba(254, 217, 40, .6)'; |
336 | 336 | break; |
337 | - } |
|
337 | + } |
|
338 | 338 | |
339 | 339 | if (0 != $data->team_id) { |
340 | 340 | $icon .= $data->level.'.png'; |
@@ -359,49 +359,49 @@ discard block |
||
359 | 359 | // |
360 | 360 | //################################### |
361 | 361 | |
362 | - case 'gym_defenders': |
|
363 | - $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
364 | - |
|
365 | - $data = $manager->getGymData($gym_id); |
|
366 | - $gymData['gymDetails']['gymInfos'] = false; |
|
367 | - |
|
368 | - if (!is_null($data)) { |
|
369 | - if (null == $data->name) { |
|
370 | - $gymData['gymDetails']['gymInfos']['name'] = '?'; |
|
371 | - } else { |
|
372 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
373 | - } |
|
374 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
375 | - if (null == $data->url) { |
|
376 | - $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
377 | - } else { |
|
378 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
379 | - } |
|
380 | - if (null == $data->total_cp) { |
|
381 | - $gymData['gymDetails']['gymInfos']['points'] = '?'; |
|
382 | - } else { |
|
383 | - $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
384 | - } |
|
385 | - $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
386 | - if (null == $data->last_scanned) { |
|
387 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = '?'; |
|
388 | - } else { |
|
389 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
390 | - } |
|
391 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
392 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
393 | - |
|
394 | - // Skip Query if team is none |
|
395 | - if ($data->team > 0) { |
|
396 | - $datas = $manager->getGymDefenders($gym_id); |
|
397 | - $gymData['infoWindow'] = ' |
|
362 | + case 'gym_defenders': |
|
363 | + $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
364 | + |
|
365 | + $data = $manager->getGymData($gym_id); |
|
366 | + $gymData['gymDetails']['gymInfos'] = false; |
|
367 | + |
|
368 | + if (!is_null($data)) { |
|
369 | + if (null == $data->name) { |
|
370 | + $gymData['gymDetails']['gymInfos']['name'] = '?'; |
|
371 | + } else { |
|
372 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
373 | + } |
|
374 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
375 | + if (null == $data->url) { |
|
376 | + $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
377 | + } else { |
|
378 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
379 | + } |
|
380 | + if (null == $data->total_cp) { |
|
381 | + $gymData['gymDetails']['gymInfos']['points'] = '?'; |
|
382 | + } else { |
|
383 | + $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
384 | + } |
|
385 | + $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
386 | + if (null == $data->last_scanned) { |
|
387 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = '?'; |
|
388 | + } else { |
|
389 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
390 | + } |
|
391 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
392 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
393 | + |
|
394 | + // Skip Query if team is none |
|
395 | + if ($data->team > 0) { |
|
396 | + $datas = $manager->getGymDefenders($gym_id); |
|
397 | + $gymData['infoWindow'] = ' |
|
398 | 398 | <div class="gym_defenders"> |
399 | 399 | '; |
400 | - foreach ($datas as $data) { |
|
401 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
402 | - $pokemon_id = $data->pokemon_id; |
|
403 | - if ($config->system->iv_numbers) { |
|
404 | - $gymData['infoWindow'] .= ' |
|
400 | + foreach ($datas as $data) { |
|
401 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
402 | + $pokemon_id = $data->pokemon_id; |
|
403 | + if ($config->system->iv_numbers) { |
|
404 | + $gymData['infoWindow'] .= ' |
|
405 | 405 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
406 | 406 | <a href="pokemon/'.$data->pokemon_id.'"> |
407 | 407 | <img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
@@ -419,8 +419,8 @@ discard block |
||
419 | 419 | </div> |
420 | 420 | </div> |
421 | 421 | </div>'; |
422 | - } else { |
|
423 | - $gymData['infoWindow'] .= ' |
|
422 | + } else { |
|
423 | + $gymData['infoWindow'] .= ' |
|
424 | 424 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
425 | 425 | <a href="pokemon/'.$data->pokemon_id.'"> |
426 | 426 | <img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
@@ -438,244 +438,244 @@ discard block |
||
438 | 438 | </div> |
439 | 439 | </div> |
440 | 440 | </div>'; |
441 | - } |
|
442 | - } |
|
443 | - } |
|
444 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
445 | - } |
|
446 | - |
|
447 | - header('Content-Type: application/json'); |
|
448 | - echo json_encode($gymData); |
|
449 | - |
|
450 | - break; |
|
451 | - |
|
452 | - case 'trainer': |
|
453 | - $name = ''; |
|
454 | - $page = '0'; |
|
455 | - $team = 0; |
|
456 | - $ranking = 0; |
|
457 | - if (isset($_GET['name'])) { |
|
458 | - $trainer_name = $manager->getEcapedString($_GET['name']); |
|
459 | - } |
|
460 | - if (isset($_GET['team'])) { |
|
461 | - $team = $manager->getEcapedString($_GET['team']); |
|
462 | - } |
|
463 | - if (isset($_GET['page'])) { |
|
464 | - $page = $manager->getEcapedString($_GET['page']); |
|
465 | - } |
|
466 | - if (isset($_GET['ranking'])) { |
|
467 | - $ranking = $manager->getEcapedString($_GET['ranking']); |
|
468 | - } |
|
469 | - |
|
470 | - $trainers = $manager->getTrainers($trainer_name, $team, $page, $ranking); |
|
471 | - $json = array(); |
|
472 | - $json['trainers'] = $trainers; |
|
473 | - $locale = array(); |
|
474 | - $locale['today'] = $locales->TODAY; |
|
475 | - $locale['day'] = $locales->DAY; |
|
476 | - $locale['days'] = $locales->DAYS; |
|
477 | - $locale['ivAttack'] = $locales->IV_ATTACK; |
|
478 | - $locale['ivDefense'] = $locales->IV_DEFENSE; |
|
479 | - $locale['ivStamina'] = $locales->IV_STAMINA; |
|
480 | - $json['locale'] = $locale; |
|
481 | - |
|
482 | - header('Content-Type: application/json'); |
|
483 | - echo json_encode($json); |
|
484 | - |
|
485 | - break; |
|
486 | - |
|
487 | - case 'raids': |
|
488 | - $page = '0'; |
|
489 | - if (isset($_GET['page'])) { |
|
490 | - $page = $manager->getEcapedString($_GET['page']); |
|
491 | - } |
|
492 | - |
|
493 | - $datas = $manager->getAllRaids($page); |
|
494 | - $i = 1; |
|
495 | - $raids = array(); |
|
496 | - foreach ($datas as $data) { |
|
497 | - $data->starttime = date('H:i', strtotime($data->start)); |
|
498 | - $data->endtime = date('H:i', strtotime($data->end)); |
|
499 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
500 | - if (isset($data->move_1)) { |
|
501 | - $move1 = $data->move_1; |
|
502 | - $data->quick_move = $move->$move1->name; |
|
503 | - } else { |
|
504 | - $data->quick_move = '?'; |
|
505 | - } |
|
506 | - if (isset($data->move_2)) { |
|
507 | - $move2 = $data->move_2; |
|
508 | - $data->charge_move = $move->$move2->name; |
|
509 | - } else { |
|
510 | - $data->charge_move = '?'; |
|
511 | - } |
|
512 | - $raids[10 * $page + $i] = $data; |
|
513 | - ++$i; |
|
514 | - } |
|
515 | - $json = array(); |
|
516 | - $json['raids'] = $raids; |
|
517 | - $locale = array(); |
|
518 | - $locale['noraids'] = $locales->RAIDS_NONE; |
|
519 | - $json['locale'] = $locale; |
|
520 | - |
|
521 | - header('Content-Type: application/json'); |
|
522 | - echo json_encode($json); |
|
523 | - |
|
524 | - break; |
|
525 | - |
|
526 | - case 'gyms': |
|
527 | - $page = '0'; |
|
528 | - $ranking = 0; |
|
529 | - $gym_name = ''; |
|
530 | - $team = ''; |
|
531 | - if (isset($_GET['name']) && '' != $_GET['name']) { |
|
532 | - $gym_name = $manager->getEcapedString($_GET['name']); |
|
533 | - } |
|
534 | - if (isset($_GET['team']) && '' != $_GET['team']) { |
|
535 | - $team = $manager->getEcapedString($_GET['team']); |
|
536 | - } |
|
537 | - if (isset($_GET['page'])) { |
|
538 | - $page = $manager->getEcapedString($_GET['page']); |
|
539 | - } |
|
540 | - if (isset($_GET['ranking'])) { |
|
541 | - $ranking = $manager->getEcapedString($_GET['ranking']); |
|
542 | - } |
|
543 | - |
|
544 | - $datas = $manager->getGymHistories($gym_name, $team, $page, $ranking); |
|
545 | - $gyms = array(); |
|
546 | - foreach ($datas as $data) { |
|
547 | - $pkm = array(); |
|
548 | - if ($data->total_cp > 0) { |
|
549 | - $pkm = $manager->getGymHistoriesPokemon($data->gym_id); |
|
550 | - } |
|
551 | - $data->pokemon = $pkm; |
|
552 | - unset($data->pokemon_uids); |
|
553 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
554 | - $gyms[] = $data; |
|
555 | - } |
|
556 | - $json = array(); |
|
557 | - $json['gyms'] = $gyms; |
|
558 | - $locale = array(); |
|
559 | - $json['locale'] = $locale; |
|
560 | - |
|
561 | - header('Content-Type: application/json'); |
|
562 | - echo json_encode($json); |
|
563 | - |
|
564 | - break; |
|
565 | - |
|
566 | - case 'gymhistory': |
|
567 | - $gym_id = ''; |
|
568 | - $page = '0'; |
|
569 | - if (isset($_GET['gym_id'])) { |
|
570 | - $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
571 | - $gym_id = str_replace('_', '.', $gym_id); |
|
572 | - } |
|
573 | - if (isset($_GET['page'])) { |
|
574 | - $page = $manager->getEcapedString($_GET['page']); |
|
575 | - } |
|
576 | - |
|
577 | - $entries = array(); |
|
578 | - |
|
579 | - $last_page = true; |
|
580 | - if ('' != $gym_id) { |
|
581 | - $datas = $manager->getHistoryForGym($page, $gym_id); |
|
582 | - foreach ($datas['data'] as $data) { |
|
583 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
584 | - $entries[] = $data; |
|
585 | - } |
|
586 | - $last_page = $datas['last_page']; |
|
587 | - |
|
588 | - foreach ($entries as $idx => $entry) { |
|
589 | - $entry->total_cp_diff = 0; |
|
590 | - $entry->only_cp_changed = true; |
|
591 | - if ($idx < count($entries) - 1) { |
|
592 | - $next_entry = $entries[$idx + 1]; |
|
593 | - $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
|
594 | - $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
|
595 | - $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
596 | - $next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
597 | - $new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon); |
|
598 | - $old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon); |
|
599 | - foreach ($new_pokemon as $pkm) { |
|
600 | - $entry->pokemon[$pkm]->class = 'new'; |
|
601 | - } |
|
602 | - foreach ($old_pokemon as $pkm) { |
|
603 | - $next_entry->pokemon[$pkm]->class = 'old'; |
|
604 | - } |
|
605 | - if ($entry->team_id != $next_entry->team_id || $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
606 | - $entry->only_cp_changed = false; |
|
607 | - } |
|
608 | - } |
|
609 | - unset($entry->pokemon_uids); |
|
610 | - } |
|
611 | - |
|
612 | - if (count($entries) > 10) { |
|
613 | - array_pop($entries); |
|
614 | - } |
|
615 | - } |
|
616 | - |
|
617 | - $json = array(); |
|
618 | - $json['entries'] = $entries; |
|
619 | - $locale = array(); |
|
620 | - $json['locale'] = $locale; |
|
621 | - $json['last_page'] = $last_page; |
|
622 | - |
|
623 | - header('Content-Type: application/json'); |
|
624 | - echo json_encode($json); |
|
625 | - |
|
626 | - break; |
|
627 | - |
|
628 | - case 'pokemon_slider_init': |
|
629 | - $bounds = $manager->getPokemonSliderMinMax(); |
|
630 | - |
|
631 | - header('Content-Type: application/json'); |
|
632 | - echo json_encode($bounds); |
|
633 | - |
|
634 | - break; |
|
635 | - |
|
636 | - case 'pokemon_heatmap_points': |
|
637 | - $json = ''; |
|
638 | - if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
639 | - $start = date('Y-m-d H:i', (int) $_GET['start']); |
|
640 | - $end = date('Y-m-d H:i', (int) $_GET['end']); |
|
641 | - $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
642 | - $points = $manager->getPokemonHeatmap($pokemon_id, $start, $end); |
|
643 | - |
|
644 | - $json = json_encode($points); |
|
645 | - } |
|
646 | - |
|
647 | - header('Content-Type: application/json'); |
|
648 | - echo $json; |
|
649 | - break; |
|
650 | - |
|
651 | - case 'maps_localization_coordinates': |
|
652 | - $coordinates = $manager->getMapsCoords(); |
|
653 | - |
|
654 | - header('Content-Type: application/json'); |
|
655 | - echo json_encode($coordinates); |
|
656 | - |
|
657 | - break; |
|
658 | - |
|
659 | - case 'pokemon_graph_data': |
|
660 | - $json = ''; |
|
661 | - if (isset($_GET['pokemon_id'])) { |
|
662 | - $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
663 | - $array = $manager->getPokemonGraph($pokemon_id); |
|
664 | - |
|
665 | - $json = json_encode($array); |
|
666 | - } |
|
667 | - |
|
668 | - header('Content-Type: application/json'); |
|
669 | - echo $json; |
|
670 | - break; |
|
671 | - |
|
672 | - case 'postRequest': |
|
673 | - break; |
|
674 | - |
|
675 | - default: |
|
676 | - echo 'What do you mean?'; |
|
677 | - exit(); |
|
678 | - break; |
|
441 | + } |
|
442 | + } |
|
443 | + } |
|
444 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
445 | + } |
|
446 | + |
|
447 | + header('Content-Type: application/json'); |
|
448 | + echo json_encode($gymData); |
|
449 | + |
|
450 | + break; |
|
451 | + |
|
452 | + case 'trainer': |
|
453 | + $name = ''; |
|
454 | + $page = '0'; |
|
455 | + $team = 0; |
|
456 | + $ranking = 0; |
|
457 | + if (isset($_GET['name'])) { |
|
458 | + $trainer_name = $manager->getEcapedString($_GET['name']); |
|
459 | + } |
|
460 | + if (isset($_GET['team'])) { |
|
461 | + $team = $manager->getEcapedString($_GET['team']); |
|
462 | + } |
|
463 | + if (isset($_GET['page'])) { |
|
464 | + $page = $manager->getEcapedString($_GET['page']); |
|
465 | + } |
|
466 | + if (isset($_GET['ranking'])) { |
|
467 | + $ranking = $manager->getEcapedString($_GET['ranking']); |
|
468 | + } |
|
469 | + |
|
470 | + $trainers = $manager->getTrainers($trainer_name, $team, $page, $ranking); |
|
471 | + $json = array(); |
|
472 | + $json['trainers'] = $trainers; |
|
473 | + $locale = array(); |
|
474 | + $locale['today'] = $locales->TODAY; |
|
475 | + $locale['day'] = $locales->DAY; |
|
476 | + $locale['days'] = $locales->DAYS; |
|
477 | + $locale['ivAttack'] = $locales->IV_ATTACK; |
|
478 | + $locale['ivDefense'] = $locales->IV_DEFENSE; |
|
479 | + $locale['ivStamina'] = $locales->IV_STAMINA; |
|
480 | + $json['locale'] = $locale; |
|
481 | + |
|
482 | + header('Content-Type: application/json'); |
|
483 | + echo json_encode($json); |
|
484 | + |
|
485 | + break; |
|
486 | + |
|
487 | + case 'raids': |
|
488 | + $page = '0'; |
|
489 | + if (isset($_GET['page'])) { |
|
490 | + $page = $manager->getEcapedString($_GET['page']); |
|
491 | + } |
|
492 | + |
|
493 | + $datas = $manager->getAllRaids($page); |
|
494 | + $i = 1; |
|
495 | + $raids = array(); |
|
496 | + foreach ($datas as $data) { |
|
497 | + $data->starttime = date('H:i', strtotime($data->start)); |
|
498 | + $data->endtime = date('H:i', strtotime($data->end)); |
|
499 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
500 | + if (isset($data->move_1)) { |
|
501 | + $move1 = $data->move_1; |
|
502 | + $data->quick_move = $move->$move1->name; |
|
503 | + } else { |
|
504 | + $data->quick_move = '?'; |
|
505 | + } |
|
506 | + if (isset($data->move_2)) { |
|
507 | + $move2 = $data->move_2; |
|
508 | + $data->charge_move = $move->$move2->name; |
|
509 | + } else { |
|
510 | + $data->charge_move = '?'; |
|
511 | + } |
|
512 | + $raids[10 * $page + $i] = $data; |
|
513 | + ++$i; |
|
514 | + } |
|
515 | + $json = array(); |
|
516 | + $json['raids'] = $raids; |
|
517 | + $locale = array(); |
|
518 | + $locale['noraids'] = $locales->RAIDS_NONE; |
|
519 | + $json['locale'] = $locale; |
|
520 | + |
|
521 | + header('Content-Type: application/json'); |
|
522 | + echo json_encode($json); |
|
523 | + |
|
524 | + break; |
|
525 | + |
|
526 | + case 'gyms': |
|
527 | + $page = '0'; |
|
528 | + $ranking = 0; |
|
529 | + $gym_name = ''; |
|
530 | + $team = ''; |
|
531 | + if (isset($_GET['name']) && '' != $_GET['name']) { |
|
532 | + $gym_name = $manager->getEcapedString($_GET['name']); |
|
533 | + } |
|
534 | + if (isset($_GET['team']) && '' != $_GET['team']) { |
|
535 | + $team = $manager->getEcapedString($_GET['team']); |
|
536 | + } |
|
537 | + if (isset($_GET['page'])) { |
|
538 | + $page = $manager->getEcapedString($_GET['page']); |
|
539 | + } |
|
540 | + if (isset($_GET['ranking'])) { |
|
541 | + $ranking = $manager->getEcapedString($_GET['ranking']); |
|
542 | + } |
|
543 | + |
|
544 | + $datas = $manager->getGymHistories($gym_name, $team, $page, $ranking); |
|
545 | + $gyms = array(); |
|
546 | + foreach ($datas as $data) { |
|
547 | + $pkm = array(); |
|
548 | + if ($data->total_cp > 0) { |
|
549 | + $pkm = $manager->getGymHistoriesPokemon($data->gym_id); |
|
550 | + } |
|
551 | + $data->pokemon = $pkm; |
|
552 | + unset($data->pokemon_uids); |
|
553 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
554 | + $gyms[] = $data; |
|
555 | + } |
|
556 | + $json = array(); |
|
557 | + $json['gyms'] = $gyms; |
|
558 | + $locale = array(); |
|
559 | + $json['locale'] = $locale; |
|
560 | + |
|
561 | + header('Content-Type: application/json'); |
|
562 | + echo json_encode($json); |
|
563 | + |
|
564 | + break; |
|
565 | + |
|
566 | + case 'gymhistory': |
|
567 | + $gym_id = ''; |
|
568 | + $page = '0'; |
|
569 | + if (isset($_GET['gym_id'])) { |
|
570 | + $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
571 | + $gym_id = str_replace('_', '.', $gym_id); |
|
572 | + } |
|
573 | + if (isset($_GET['page'])) { |
|
574 | + $page = $manager->getEcapedString($_GET['page']); |
|
575 | + } |
|
576 | + |
|
577 | + $entries = array(); |
|
578 | + |
|
579 | + $last_page = true; |
|
580 | + if ('' != $gym_id) { |
|
581 | + $datas = $manager->getHistoryForGym($page, $gym_id); |
|
582 | + foreach ($datas['data'] as $data) { |
|
583 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
584 | + $entries[] = $data; |
|
585 | + } |
|
586 | + $last_page = $datas['last_page']; |
|
587 | + |
|
588 | + foreach ($entries as $idx => $entry) { |
|
589 | + $entry->total_cp_diff = 0; |
|
590 | + $entry->only_cp_changed = true; |
|
591 | + if ($idx < count($entries) - 1) { |
|
592 | + $next_entry = $entries[$idx + 1]; |
|
593 | + $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
|
594 | + $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
|
595 | + $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
596 | + $next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
597 | + $new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon); |
|
598 | + $old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon); |
|
599 | + foreach ($new_pokemon as $pkm) { |
|
600 | + $entry->pokemon[$pkm]->class = 'new'; |
|
601 | + } |
|
602 | + foreach ($old_pokemon as $pkm) { |
|
603 | + $next_entry->pokemon[$pkm]->class = 'old'; |
|
604 | + } |
|
605 | + if ($entry->team_id != $next_entry->team_id || $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
606 | + $entry->only_cp_changed = false; |
|
607 | + } |
|
608 | + } |
|
609 | + unset($entry->pokemon_uids); |
|
610 | + } |
|
611 | + |
|
612 | + if (count($entries) > 10) { |
|
613 | + array_pop($entries); |
|
614 | + } |
|
615 | + } |
|
616 | + |
|
617 | + $json = array(); |
|
618 | + $json['entries'] = $entries; |
|
619 | + $locale = array(); |
|
620 | + $json['locale'] = $locale; |
|
621 | + $json['last_page'] = $last_page; |
|
622 | + |
|
623 | + header('Content-Type: application/json'); |
|
624 | + echo json_encode($json); |
|
625 | + |
|
626 | + break; |
|
627 | + |
|
628 | + case 'pokemon_slider_init': |
|
629 | + $bounds = $manager->getPokemonSliderMinMax(); |
|
630 | + |
|
631 | + header('Content-Type: application/json'); |
|
632 | + echo json_encode($bounds); |
|
633 | + |
|
634 | + break; |
|
635 | + |
|
636 | + case 'pokemon_heatmap_points': |
|
637 | + $json = ''; |
|
638 | + if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
639 | + $start = date('Y-m-d H:i', (int) $_GET['start']); |
|
640 | + $end = date('Y-m-d H:i', (int) $_GET['end']); |
|
641 | + $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
642 | + $points = $manager->getPokemonHeatmap($pokemon_id, $start, $end); |
|
643 | + |
|
644 | + $json = json_encode($points); |
|
645 | + } |
|
646 | + |
|
647 | + header('Content-Type: application/json'); |
|
648 | + echo $json; |
|
649 | + break; |
|
650 | + |
|
651 | + case 'maps_localization_coordinates': |
|
652 | + $coordinates = $manager->getMapsCoords(); |
|
653 | + |
|
654 | + header('Content-Type: application/json'); |
|
655 | + echo json_encode($coordinates); |
|
656 | + |
|
657 | + break; |
|
658 | + |
|
659 | + case 'pokemon_graph_data': |
|
660 | + $json = ''; |
|
661 | + if (isset($_GET['pokemon_id'])) { |
|
662 | + $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
663 | + $array = $manager->getPokemonGraph($pokemon_id); |
|
664 | + |
|
665 | + $json = json_encode($array); |
|
666 | + } |
|
667 | + |
|
668 | + header('Content-Type: application/json'); |
|
669 | + echo $json; |
|
670 | + break; |
|
671 | + |
|
672 | + case 'postRequest': |
|
673 | + break; |
|
674 | + |
|
675 | + default: |
|
676 | + echo 'What do you mean?'; |
|
677 | + exit(); |
|
678 | + break; |
|
679 | 679 | } |
680 | 680 | |
681 | 681 | if ('' != $postRequest) { |