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