Passed
Push — master ( 667ab2...89e095 )
by Markus
02:15
created
core/process/aru.php 1 patch
Switch Indentation   +366 added lines, -366 removed lines patch added patch discarded remove patch
@@ -58,153 +58,153 @@  discard block
 block discarded – undo
58 58
 	//
59 59
 	############################
60 60
 
61
-	case 'home_update':
62
-		// Right now
63
-		// ---------
61
+		case 'home_update':
62
+			// Right now
63
+			// ---------
64 64
 
65
-		$req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
66
-		$result = $mysqli->query($req);
67
-		$data = $result->fetch_object();
65
+			$req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
66
+			$result = $mysqli->query($req);
67
+			$data = $result->fetch_object();
68 68
 
69
-		$values[] = $data->total;
69
+			$values[] = $data->total;
70 70
 
71 71
 
72
-		// Lured stops
73
-		// -----------
72
+			// Lured stops
73
+			// -----------
74 74
 
75
-		$req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
76
-		$result = $mysqli->query($req);
77
-		$data = $result->fetch_object();
75
+			$req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
76
+			$result = $mysqli->query($req);
77
+			$data = $result->fetch_object();
78 78
 
79
-		$values[] = $data->total;
79
+			$values[] = $data->total;
80 80
 
81 81
 
82 82
 
83
-		// Team battle
84
-		// -----------
83
+			// Team battle
84
+			// -----------
85 85
 
86
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
87
-		$result = $mysqli->query($req);
88
-		$data = $result->fetch_object();
86
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym";
87
+			$result = $mysqli->query($req);
88
+			$data = $result->fetch_object();
89 89
 
90
-		$values[] = $data->total;
90
+			$values[] = $data->total;
91 91
 
92
-		// Team
93
-		// 1 = bleu
94
-		// 2 = rouge
95
-		// 3 = jaune
92
+			// Team
93
+			// 1 = bleu
94
+			// 2 = rouge
95
+			// 3 = jaune
96 96
 
97
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '2'";
98
-		$result = $mysqli->query($req);
99
-		$data = $result->fetch_object();
97
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '2'";
98
+			$result = $mysqli->query($req);
99
+			$data = $result->fetch_object();
100 100
 
101
-		// Red
102
-		$values[] = $data->total;
101
+			// Red
102
+			$values[] = $data->total;
103 103
 
104 104
 
105
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '1'";
106
-		$result = $mysqli->query($req);
107
-		$data = $result->fetch_object();
105
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '1'";
106
+			$result = $mysqli->query($req);
107
+			$data = $result->fetch_object();
108 108
 
109
-		// Blue
110
-		$values[] = $data->total;
109
+			// Blue
110
+			$values[] = $data->total;
111 111
 
112 112
 
113
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '3'";
114
-		$result = $mysqli->query($req);
115
-		$data = $result->fetch_object();
113
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '3'";
114
+			$result = $mysqli->query($req);
115
+			$data = $result->fetch_object();
116 116
 
117
-		// Yellow
118
-		$values[] = $data->total;
117
+			// Yellow
118
+			$values[] = $data->total;
119 119
 
120
-		$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '0'";
121
-		$result = $mysqli->query($req);
122
-		$data = $result->fetch_object();
120
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '0'";
121
+			$result = $mysqli->query($req);
122
+			$data = $result->fetch_object();
123 123
 
124
-		// Neutral
125
-		$values[] = $data->total;
124
+			// Neutral
125
+			$values[] = $data->total;
126 126
 
127
-		header('Content-Type: application/json');
128
-		echo json_encode($values);
127
+			header('Content-Type: application/json');
128
+			echo json_encode($values);
129 129
 
130
-		break;
130
+			break;
131 131
 
132 132
 
133
-	####################################
134
-	//
135
-	// Update latests spawn on homepage
136
-	//
137
-	####################################
133
+		####################################
134
+		//
135
+		// Update latests spawn on homepage
136
+		//
137
+		####################################
138 138
 
139
-	case 'spawnlist_update':
140
-		// Recent spawn
141
-		// ------------
142
-		$total_spawns = array();
143
-		$last_uid_param = "";
144
-		if (isset($_GET['last_uid'])) {
145
-			$last_uid_param = $_GET['last_uid'];
146
-		}
147
-		if ($config->system->recents_filter) {
148
-			// get all mythic pokemon ids
149
-			$mythic_pokemons = array();
150
-			foreach ($pokemons->pokemon as $id => $pokemon) {
151
-				if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) {
152
-					$mythic_pokemons[] = $id;
153
-				}
139
+		case 'spawnlist_update':
140
+			// Recent spawn
141
+			// ------------
142
+			$total_spawns = array();
143
+			$last_uid_param = "";
144
+			if (isset($_GET['last_uid'])) {
145
+				$last_uid_param = $_GET['last_uid'];
154 146
 			}
147
+			if ($config->system->recents_filter) {
148
+				// get all mythic pokemon ids
149
+				$mythic_pokemons = array();
150
+				foreach ($pokemons->pokemon as $id => $pokemon) {
151
+					if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) {
152
+						$mythic_pokemons[] = $id;
153
+					}
154
+				}
155 155
 
156
-			// get last mythic pokemon
157
-			$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
156
+				// get last mythic pokemon
157
+				$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
158 158
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
159 159
 					FROM pokemon
160 160
 					WHERE pokemon_id IN (".implode(",", $mythic_pokemons).")
161 161
 					ORDER BY last_modified DESC
162 162
 					LIMIT 0,12";
163
-		} else {
164
-			// get last pokemon
165
-			$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
163
+			} else {
164
+				// get last pokemon
165
+				$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real,
166 166
 					latitude, longitude, cp, individual_attack, individual_defense, individual_stamina
167 167
 					FROM pokemon
168 168
 					ORDER BY last_modified DESC
169 169
 					LIMIT 0,12";
170
-		}
171
-		$result = $mysqli->query($req);
172
-		while ($data = $result->fetch_object()) {
173
-			$new_spawn = array();
174
-			$pokeid = $data->pokemon_id;
175
-			$pokeuid = $data->encounter_id;
176
-
177
-			if ($last_uid_param != $pokeuid) {
178
-				$last_seen = strtotime($data->disappear_time_real);
179
-
180
-				$location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16';
181
-				$location_link = str_replace('{latitude}', $data->latitude, $location_link);
182
-				$location_link = str_replace('{longitude}', $data->longitude, $location_link);
183
-
184
-				if ($config->system->recents_encounter_details) {
185
-					$encdetails = new stdClass();
186
-					$encdetails->cp = $data->cp;
187
-					$encdetails->attack = $data->individual_attack;
188
-					$encdetails->defense = $data->individual_defense;
189
-					$encdetails->stamina = $data->individual_stamina;
190
-					if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) {
191
-						$encdetails->available = true;
192
-					} else {
193
-						$encdetails->available = false;
170
+			}
171
+			$result = $mysqli->query($req);
172
+			while ($data = $result->fetch_object()) {
173
+				$new_spawn = array();
174
+				$pokeid = $data->pokemon_id;
175
+				$pokeuid = $data->encounter_id;
176
+
177
+				if ($last_uid_param != $pokeuid) {
178
+					$last_seen = strtotime($data->disappear_time_real);
179
+
180
+					$location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16';
181
+					$location_link = str_replace('{latitude}', $data->latitude, $location_link);
182
+					$location_link = str_replace('{longitude}', $data->longitude, $location_link);
183
+
184
+					if ($config->system->recents_encounter_details) {
185
+						$encdetails = new stdClass();
186
+						$encdetails->cp = $data->cp;
187
+						$encdetails->attack = $data->individual_attack;
188
+						$encdetails->defense = $data->individual_defense;
189
+						$encdetails->stamina = $data->individual_stamina;
190
+						if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) {
191
+							$encdetails->available = true;
192
+						} else {
193
+							$encdetails->available = false;
194
+						}
194 195
 					}
195
-				}
196 196
 
197
-				$html = '
197
+					$html = '
198 198
 			    <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;">
199 199
 				<a href="pokemon/'.$pokeid.'"><img src="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a>
200 200
 				<a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a>
201 201
 				<a href="'.$location_link.'" target="_blank">
202 202
 					<small class="pokemon-timer">00:00:00</small>
203 203
 				</a>';
204
-				if ($config->system->recents_encounter_details) {
205
-					if ($encdetails->available) {
206
-						if ($config->system->iv_numbers) {
207
-							$html .= '
204
+					if ($config->system->recents_encounter_details) {
205
+						if ($encdetails->available) {
206
+							if ($config->system->iv_numbers) {
207
+								$html .= '
208 208
 							<div class="progress" style="height: 15px; margin-bottom: 0">
209 209
 								<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">
210 210
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>'.$encdetails->attack.'
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>'.$encdetails->stamina.'
217 217
 								</div>
218 218
 							</div>';
219
-						} else {
220
-							$html .= '
219
+							} else {
220
+								$html .= '
221 221
 							<div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto">
222 222
 							<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).'%">
223 223
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>
230 230
 							</div>
231 231
 							</div>';
232
-						}
233
-						$html .= '<small>'.$encdetails->cp.'</small>';
234
-					} else {
235
-						if ($config->system->iv_numbers) {
236
-							$html .= '
232
+							}
233
+							$html .= '<small>'.$encdetails->cp.'</small>';
234
+						} else {
235
+							if ($config->system->iv_numbers) {
236
+								$html .= '
237 237
 							<div class="progress" style="height: 15px; margin-bottom: 0">
238 238
 								<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">
239 239
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>?
@@ -245,127 +245,127 @@  discard block
 block discarded – undo
245 245
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>?
246 246
 								</div>
247 247
 							</div>';
248
-						} else {
249
-						$html .= '
248
+							} else {
249
+							$html .= '
250 250
 					    <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto">
251 251
 						    <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">
252 252
 							    <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span>
253 253
 						    </div>
254 254
 					    </div>';
255
+							}
256
+							$html .= '<small>???</small>';
255 257
 						}
256
-						$html .= '<small>???</small>';
257 258
 					}
258
-				}
259
-				$html .= '
259
+					$html .= '
260 260
 			    </div>';
261
-				$new_spawn['html'] = $html;
262
-				$countdown = $last_seen - time();
263
-				$new_spawn['countdown'] = $countdown;
264
-				$new_spawn['pokemon_uid'] = $pokeuid;
265
-				$total_spawns[] = $new_spawn;
266
-			} else {
267
-				break;
261
+					$new_spawn['html'] = $html;
262
+					$countdown = $last_seen - time();
263
+					$new_spawn['countdown'] = $countdown;
264
+					$new_spawn['pokemon_uid'] = $pokeuid;
265
+					$total_spawns[] = $new_spawn;
266
+				} else {
267
+					break;
268
+				}
268 269
 			}
269
-		}
270 270
 
271
-		header('Content-Type: application/json');
272
-		echo json_encode($total_spawns);
271
+			header('Content-Type: application/json');
272
+			echo json_encode($total_spawns);
273 273
 
274
-		break;
274
+			break;
275 275
 
276 276
 
277
-	####################################
278
-	//
279
-	// List Pokestop
280
-	//
281
-	####################################
277
+		####################################
278
+		//
279
+		// List Pokestop
280
+		//
281
+		####################################
282 282
 
283
-	case 'pokestop':
284
-		$where = "";
285
-		if ($config->system->only_lured_pokestops) {
286
-			$where = "WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration";
287
-		}
288
-		$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop ".$where."";
283
+		case 'pokestop':
284
+			$where = "";
285
+			if ($config->system->only_lured_pokestops) {
286
+				$where = "WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration";
287
+			}
288
+			$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop ".$where."";
289 289
 
290
-		//show all stops if no lure active
291
-		if (!$mysqli->query($req)->fetch_object()) {
292
-			$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop";
293
-		}
294
-		$result = $mysqli->query($req);
290
+			//show all stops if no lure active
291
+			if (!$mysqli->query($req)->fetch_object()) {
292
+				$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop";
293
+			}
294
+			$result = $mysqli->query($req);
295 295
 
296
-		$pokestops = [];
296
+			$pokestops = [];
297 297
 
298
-		while ($data = $result->fetch_object()) {
299
-			if ($data->lure_expiration >= $data->now) {
300
-				$icon = 'pokestap_lured.png';
301
-				$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
302
-			} else {
303
-				$icon = 'pokestap.png';
304
-				$text = $locales->POKESTOPS_MAP_REGULAR;
298
+			while ($data = $result->fetch_object()) {
299
+				if ($data->lure_expiration >= $data->now) {
300
+					$icon = 'pokestap_lured.png';
301
+					$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
302
+				} else {
303
+					$icon = 'pokestap.png';
304
+					$text = $locales->POKESTOPS_MAP_REGULAR;
305
+				}
306
+
307
+				$pokestops[] = [
308
+					$text,
309
+					$icon,
310
+					$data->latitude,
311
+					$data->longitude
312
+				];
305 313
 			}
306 314
 
307
-			$pokestops[] = [
308
-				$text,
309
-				$icon,
310
-				$data->latitude,
311
-				$data->longitude
312
-			];
313
-		}
315
+			header('Content-Type: application/json');
316
+			echo json_encode($pokestops);
314 317
 
315
-		header('Content-Type: application/json');
316
-		echo json_encode($pokestops);
318
+			break;
317 319
 
318
-		break;
319 320
 
321
+		####################################
322
+		//
323
+		// Update data for the gym battle
324
+		//
325
+		####################################
320 326
 
321
-	####################################
322
-	//
323
-	// Update data for the gym battle
324
-	//
325
-	####################################
327
+		case 'update_gym':
328
+			$teams = new stdClass();
329
+			$teams->mystic = 1;
330
+			$teams->valor = 2;
331
+			$teams->instinct = 3;
326 332
 
327
-	case 'update_gym':
328
-		$teams = new stdClass();
329
-		$teams->mystic = 1;
330
-		$teams->valor = 2;
331
-		$teams->instinct = 3;
332 333
 
334
+			foreach ($teams as $team_name => $team_id) {
335
+				$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
336
+				$result = $mysqli->query($req);
337
+				$data = $result->fetch_object();
333 338
 
334
-		foreach ($teams as $team_name => $team_id) {
335
-			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
336
-			$result = $mysqli->query($req);
337
-			$data = $result->fetch_object();
339
+				$return[] = $data->total;
340
+				$return[] = $data->average_points;
341
+			}
338 342
 
339
-			$return[] = $data->total;
340
-			$return[] = $data->average_points;
341
-		}
343
+			header('Content-Type: application/json');
344
+			echo json_encode($return);
342 345
 
343
-		header('Content-Type: application/json');
344
-		echo json_encode($return);
346
+			break;
345 347
 
346
-		break;
347 348
 
349
+		####################################
350
+		//
351
+		// Get datas for the gym map
352
+		//
353
+		####################################
348 354
 
349
-	####################################
350
-	//
351
-	// Get datas for the gym map
352
-	//
353
-	####################################
354 355
 
356
+		case 'gym_map':
357
+			$req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym";
358
+			$result = $mysqli->query($req);
355 359
 
356
-	case 'gym_map':
357
-		$req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym";
358
-		$result = $mysqli->query($req);
360
+			$gyms = [];
359 361
 
360
-		$gyms = [];
362
+			while ($data = $result->fetch_object()) {
363
+				// Team
364
+				// 1 = bleu
365
+				// 2 = rouge
366
+				// 3 = jaune
361 367
 
362
-		while ($data = $result->fetch_object()) {
363
-			// Team
364
-			// 1 = bleu
365
-			// 2 = rouge
366
-			// 3 = jaune
367
-
368
-			switch ($data->team_id) {
368
+				switch ($data->team_id) {
369 369
 				case 0:
370 370
 					$icon	= 'map_white.png';
371 371
 					$team	= 'No Team (yet)';
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 					$team	= 'Team Instinct';
390 390
 					$color = 'rgba(254, 217, 40, .6)';
391 391
 					break;
392
-			}
392
+				}
393 393
 
394 394
 			if ($data->team_id != 0) {
395 395
 				$icon .= $data->level.".png";
@@ -415,49 +415,49 @@  discard block
 block discarded – undo
415 415
 	//
416 416
 	####################################
417 417
 
418
-	case 'gym_defenders':
419
-		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
420
-		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
418
+		case 'gym_defenders':
419
+			$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
420
+			$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
421 421
 					(CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, gym.total_cp AS total_cp, (6 - gym.slots_available) AS level
422 422
 					FROM gymdetails
423 423
 					LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id
424 424
 					WHERE gym.gym_id='".$gym_id."'";
425
-		$result = $mysqli->query($req);
425
+			$result = $mysqli->query($req);
426 426
 
427
-		$gymData['gymDetails']['gymInfos'] = false;
427
+			$gymData['gymDetails']['gymInfos'] = false;
428 428
 
429
-		while ($data = $result->fetch_object()) {
430
-			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
431
-			$gymData['gymDetails']['gymInfos']['description'] = $data->description;
432
-			if ($data->url == null) {
433
-				$gymData['gymDetails']['gymInfos']['url'] = '';
434
-			} else {
435
-				$gymData['gymDetails']['gymInfos']['url'] = $data->url;
429
+			while ($data = $result->fetch_object()) {
430
+				$gymData['gymDetails']['gymInfos']['name'] = $data->name;
431
+				$gymData['gymDetails']['gymInfos']['description'] = $data->description;
432
+				if ($data->url == null) {
433
+					$gymData['gymDetails']['gymInfos']['url'] = '';
434
+				} else {
435
+					$gymData['gymDetails']['gymInfos']['url'] = $data->url;
436
+				}
437
+				$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
438
+				$gymData['gymDetails']['gymInfos']['level'] = $data->level;
439
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
440
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team;
441
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
436 442
 			}
437
-			$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
438
-			$gymData['gymDetails']['gymInfos']['level'] = $data->level;
439
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
440
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
441
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
442
-		}
443 443
 
444
-		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
444
+			$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
445 445
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
446 446
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
447 447
 					HAVING gymmember.gym_id='".$gym_id."'
448 448
 					ORDER BY cp DESC";
449
-		$result = $mysqli->query($req);
449
+			$result = $mysqli->query($req);
450 450
 
451
-		$i = 0;
451
+			$i = 0;
452 452
 
453
-		$gymData['infoWindow'] = '
453
+			$gymData['infoWindow'] = '
454 454
 			<div class="gym_defenders">
455 455
 			';
456
-		while ($data = $result->fetch_object()) {
457
-			$gymData['gymDetails']['pokemons'][] = $data;
458
-			if ($data != false) {
459
-				if ($config->system->iv_numbers) {
460
-					$gymData['infoWindow'] .= '
456
+			while ($data = $result->fetch_object()) {
457
+				$gymData['gymDetails']['pokemons'][] = $data;
458
+				if ($data != false) {
459
+					if ($config->system->iv_numbers) {
460
+						$gymData['infoWindow'] .= '
461 461
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
462 462
 						<a href="pokemon/'.$data->pokemon_id.'">
463 463
 						<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 								</div>
476 476
 							</div>
477 477
 						</div>';
478
-				} else {
479
-					$gymData['infoWindow'] .= '
478
+					} else {
479
+						$gymData['infoWindow'] .= '
480 480
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
481 481
 						<a href="pokemon/'.$data->pokemon_id.'">
482 482
 						<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -494,78 +494,78 @@  discard block
 block discarded – undo
494 494
 							</div>
495 495
 						</div>
496 496
 					</div>'
497
-						; }
498
-			} else {
499
-				$gymData['infoWindow'] .= '
497
+							; }
498
+				} else {
499
+					$gymData['infoWindow'] .= '
500 500
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
501 501
 					<a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'">
502 502
 					<img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
503 503
 					</a>
504 504
 					<p class="pkmn-name">???</p>
505 505
 				</div>'
506
-				;
506
+					;
507
+				}
508
+				$i++;
507 509
 			}
508
-			$i++;
509
-		}
510 510
 
511
-		// check whether we could retrieve gym infos, otherwise use basic gym info
512
-		if (!$gymData['gymDetails']['gymInfos']) {
513
-			$req = "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, total_cp, (6 - slots_available) AS level
511
+			// check whether we could retrieve gym infos, otherwise use basic gym info
512
+			if (!$gymData['gymDetails']['gymInfos']) {
513
+				$req = "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, total_cp, (6 - slots_available) AS level
514 514
 				FROM gym WHERE gym_id='".$gym_id."'";
515
-			$result = $mysqli->query($req);
516
-			$data = $result->fetch_object();
515
+				$result = $mysqli->query($req);
516
+				$data = $result->fetch_object();
517 517
 
518
-			$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
519
-			$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
520
-			$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
521
-			$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
522
-			$gymData['gymDetails']['gymInfos']['level'] = $data->level;
523
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
524
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
525
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
518
+				$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
519
+				$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
520
+				$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
521
+				$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
522
+				$gymData['gymDetails']['gymInfos']['level'] = $data->level;
523
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
524
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
525
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
526 526
 
527
-			$gymData['infoWindow'] .= '
527
+				$gymData['infoWindow'] .= '
528 528
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
529 529
 					<a href="pokemon/'.$data->guard_pokemon_id.'">
530 530
 					<img src="core/pokemons/'.$data->guard_pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
531 531
 					</a>
532 532
 					<p class="pkmn-name">???</p>
533 533
 				</div>';
534
-		}
535
-		$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
534
+			}
535
+			$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
536 536
 
537
-		header('Content-Type: application/json');
538
-		echo json_encode($gymData);
537
+			header('Content-Type: application/json');
538
+			echo json_encode($gymData);
539 539
 
540
-		break;
540
+			break;
541 541
 
542 542
 
543
-	case 'trainer':
544
-		$name = "";
545
-		$page = "0";
546
-		$where = "";
547
-		$order = "";
548
-		$team = 0;
549
-		$ranking = 0;
550
-		if (isset($_GET['name'])) {
551
-			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
552
-			$where = " HAVING name LIKE '%".$trainer_name."%'";
553
-		}
554
-		if (isset($_GET['team']) && $_GET['team'] != 0) {
555
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
556
-			$where .= ($where == "" ? " HAVING" : " AND")." team = ".$team;
557
-		}
558
-		if (!empty($config->system->trainer_blacklist)) {
559
-			$where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')";
560
-		}
561
-		if (isset($_GET['page'])) {
562
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
563
-		}
564
-		if (isset($_GET['ranking'])) {
565
-			$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
566
-		}
543
+		case 'trainer':
544
+			$name = "";
545
+			$page = "0";
546
+			$where = "";
547
+			$order = "";
548
+			$team = 0;
549
+			$ranking = 0;
550
+			if (isset($_GET['name'])) {
551
+				$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
552
+				$where = " HAVING name LIKE '%".$trainer_name."%'";
553
+			}
554
+			if (isset($_GET['team']) && $_GET['team'] != 0) {
555
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
556
+				$where .= ($where == "" ? " HAVING" : " AND")." team = ".$team;
557
+			}
558
+			if (!empty($config->system->trainer_blacklist)) {
559
+				$where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')";
560
+			}
561
+			if (isset($_GET['page'])) {
562
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
563
+			}
564
+			if (isset($_GET['ranking'])) {
565
+				$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
566
+			}
567 567
 
568
-		switch ($ranking) {
568
+			switch ($ranking) {
569 569
 			case 1:
570 570
 				$order = " ORDER BY active DESC, level DESC";
571 571
 				break;
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 				break;
575 575
 			default:
576 576
 				$order = " ORDER BY level DESC, active DESC";
577
-		}
577
+			}
578 578
 
579 579
 		$order .= ", last_seen DESC, name ";
580 580
 
@@ -650,130 +650,130 @@  discard block
 block discarded – undo
650 650
 		break;
651 651
 
652 652
 
653
-	case 'raids':
654
-		$page = "0";
655
-		if (isset($_GET['page'])) {
656
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
657
-		}
653
+		case 'raids':
654
+			$page = "0";
655
+			if (isset($_GET['page'])) {
656
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
657
+			}
658 658
 
659
-		$limit = " LIMIT ".($page * 10).",10";
659
+			$limit = " LIMIT ".($page * 10).",10";
660 660
 
661
-		$req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid
661
+			$req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid
662 662
 				JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
663 663
 				JOIN gym ON gym.gym_id = raid.gym_id
664 664
 				WHERE raid.end > UTC_TIMESTAMP()
665 665
 				ORDER BY raid.level DESC, raid.start".$limit;
666 666
 
667
-		$result = $mysqli->query($req);
668
-		$raids = array();
669
-		while ($data = $result->fetch_object()) {
670
-			$data->starttime = date("H:i", strtotime($data->start));
671
-			$data->endtime = date("H:i", strtotime($data->end));
672
-			$data->gym_id = str_replace('.', '_', $data->gym_id);
673
-			if (isset($data->move_1)) {
674
-				$move1 = $data->move_1;
675
-				$data->quick_move = $move->$move1->name;
676
-			} else {
677
-				$data->quick_move = "?";
678
-			}
679
-			if (isset($data->move_2)) {
680
-				$move2 = $data->move_2;
681
-				$data->charge_move = $move->$move2->name;
682
-			} else {
683
-				$data->charge_move = "?";
667
+			$result = $mysqli->query($req);
668
+			$raids = array();
669
+			while ($data = $result->fetch_object()) {
670
+				$data->starttime = date("H:i", strtotime($data->start));
671
+				$data->endtime = date("H:i", strtotime($data->end));
672
+				$data->gym_id = str_replace('.', '_', $data->gym_id);
673
+				if (isset($data->move_1)) {
674
+					$move1 = $data->move_1;
675
+					$data->quick_move = $move->$move1->name;
676
+				} else {
677
+					$data->quick_move = "?";
678
+				}
679
+				if (isset($data->move_2)) {
680
+					$move2 = $data->move_2;
681
+					$data->charge_move = $move->$move2->name;
682
+				} else {
683
+					$data->charge_move = "?";
684
+				}
685
+				$raids[$data->gym_id] = $data;
684 686
 			}
685
-			$raids[$data->gym_id] = $data;
686
-		}
687
-		$json = array();
688
-		$json['raids'] = $raids;
689
-		$locale = array();
690
-		$locale['noraids'] = $locales->RAIDS_NONE;
691
-		$json['locale'] = $locale;
687
+			$json = array();
688
+			$json['raids'] = $raids;
689
+			$locale = array();
690
+			$locale['noraids'] = $locales->RAIDS_NONE;
691
+			$json['locale'] = $locale;
692 692
 
693
-		header('Content-Type: application/json');
694
-		echo json_encode($json);
693
+			header('Content-Type: application/json');
694
+			echo json_encode($json);
695 695
 
696
-		break;
696
+			break;
697 697
 
698
-	case 'pokemon_slider_init':
699
-		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
700
-		$result 	= $mysqli->query($req);
701
-		$bounds		= $result->fetch_object();
698
+		case 'pokemon_slider_init':
699
+			$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
700
+			$result 	= $mysqli->query($req);
701
+			$bounds		= $result->fetch_object();
702 702
 
703
-		header('Content-Type: application/json');
704
-		echo json_encode($bounds);
703
+			header('Content-Type: application/json');
704
+			echo json_encode($bounds);
705 705
 
706
-		break;
706
+			break;
707 707
 
708 708
 
709
-	case 'pokemon_heatmap_points':
710
-		$json = "";
711
-		if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
712
-			$start = date("Y-m-d H:i", (int) $_GET['start']);
713
-			$end = date("Y-m-d H:i", (int) $_GET['end']);
714
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
715
-			$where = " WHERE pokemon_id = ".$pokemon_id." "
716
-					. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
717
-			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
718
-			$result = $mysqli->query($req);
719
-			$points = array();
720
-			while ($result && $data = $result->fetch_object()) {
721
-				$points[] = $data;
722
-			}
709
+		case 'pokemon_heatmap_points':
710
+			$json = "";
711
+			if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
712
+				$start = date("Y-m-d H:i", (int) $_GET['start']);
713
+				$end = date("Y-m-d H:i", (int) $_GET['end']);
714
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
715
+				$where = " WHERE pokemon_id = ".$pokemon_id." "
716
+						. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
717
+				$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
718
+				$result = $mysqli->query($req);
719
+				$points = array();
720
+				while ($result && $data = $result->fetch_object()) {
721
+					$points[] = $data;
722
+				}
723 723
 
724
-			$json = json_encode($points);
725
-		}
724
+				$json = json_encode($points);
725
+			}
726 726
 
727
-		header('Content-Type: application/json');
728
-		echo $json;
729
-		break;
727
+			header('Content-Type: application/json');
728
+			echo $json;
729
+			break;
730 730
 
731 731
 
732
-	case 'maps_localization_coordinates':
733
-		$json = "";
734
-		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
735
-		$result = $mysqli->query($req);
736
-		$coordinates = $result->fetch_object();
732
+		case 'maps_localization_coordinates':
733
+			$json = "";
734
+			$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
735
+			$result = $mysqli->query($req);
736
+			$coordinates = $result->fetch_object();
737 737
 
738
-		header('Content-Type: application/json');
739
-		echo json_encode($coordinates);
738
+			header('Content-Type: application/json');
739
+			echo json_encode($coordinates);
740 740
 
741
-		break;
741
+			break;
742 742
 
743 743
 
744
-	case 'pokemon_graph_data':
745
-		$json = "";
746
-		if (isset($_GET['pokemon_id'])) {
747
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
748
-			$req = "SELECT COUNT(*) AS total,
744
+		case 'pokemon_graph_data':
745
+			$json = "";
746
+			if (isset($_GET['pokemon_id'])) {
747
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
748
+				$req = "SELECT COUNT(*) AS total,
749 749
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour
750 750
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered
751 751
 					GROUP BY disappear_hour
752 752
 					ORDER BY disappear_hour";
753
-			$result = $mysqli->query($req);
754
-			$array = array_fill(0, 24, 0);
755
-			while ($result && $data = $result->fetch_object()) {
756
-				$array[$data->disappear_hour] = $data->total;
753
+				$result = $mysqli->query($req);
754
+				$array = array_fill(0, 24, 0);
755
+				while ($result && $data = $result->fetch_object()) {
756
+					$array[$data->disappear_hour] = $data->total;
757
+				}
758
+				// shift array because AM/PM starts at 1AM not 0:00
759
+				$array[] = $array[0];
760
+				array_shift($array);
761
+
762
+				$json = json_encode($array);
757 763
 			}
758
-			// shift array because AM/PM starts at 1AM not 0:00
759
-			$array[] = $array[0];
760
-			array_shift($array);
761 764
 
762
-			$json = json_encode($array);
763
-		}
765
+			header('Content-Type: application/json');
766
+			echo $json;
767
+			break;
764 768
 
765
-		header('Content-Type: application/json');
766
-		echo $json;
767
-		break;
768 769
 
770
+		case 'postRequest':
771
+			break;
769 772
 
770
-	case 'postRequest':
773
+		default:
774
+			echo "What do you mean?";
775
+			exit();
771 776
 		break;
772
-
773
-	default:
774
-		echo "What do you mean?";
775
-		exit();
776
-	break;
777 777
 }
778 778
 
779 779
 if ($postRequest != "") {
Please login to merge, or discard this patch.