Passed
Push — master ( a87a11...601bb2 )
by Markus
02:09
created
core/process/aru.php 1 patch
Switch Indentation   +367 added lines, -367 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="'.$pokemons->pokemon->$pokeid->img.'" 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,123 +245,123 @@  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
-		$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop ";
283
+		case 'pokestop':
284
+			$where = "";
285
+			$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop ";
286 286
 
287
-		$result = $mysqli->query($req);
287
+			$result = $mysqli->query($req);
288 288
 
289
-		$pokestops = [];
289
+			$pokestops = [];
290 290
 
291
-		while ($data = $result->fetch_object()) {
292
-			if ($data->lure_expiration >= $data->now) {
293
-				$icon = 'pokestap_lured.png';
294
-				$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
295
-				$lured = true;
296
-			} else {
297
-				$icon = 'pokestap.png';
298
-				$text = $locales->POKESTOPS_MAP_REGULAR;
299
-				$lured = false;
291
+			while ($data = $result->fetch_object()) {
292
+				if ($data->lure_expiration >= $data->now) {
293
+					$icon = 'pokestap_lured.png';
294
+					$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
295
+					$lured = true;
296
+				} else {
297
+					$icon = 'pokestap.png';
298
+					$text = $locales->POKESTOPS_MAP_REGULAR;
299
+					$lured = false;
300
+				}
301
+
302
+				$pokestops[] = [
303
+					$text,
304
+					$icon,
305
+					$data->latitude,
306
+					$data->longitude,
307
+					$lured
308
+				];
300 309
 			}
301 310
 
302
-			$pokestops[] = [
303
-				$text,
304
-				$icon,
305
-				$data->latitude,
306
-				$data->longitude,
307
-				$lured
308
-			];
309
-		}
311
+			header('Content-Type: application/json');
312
+			echo json_encode($pokestops);
310 313
 
311
-		header('Content-Type: application/json');
312
-		echo json_encode($pokestops);
314
+			break;
313 315
 
314
-		break;
315 316
 
317
+		####################################
318
+		//
319
+		// Update data for the gym battle
320
+		//
321
+		####################################
316 322
 
317
-	####################################
318
-	//
319
-	// Update data for the gym battle
320
-	//
321
-	####################################
323
+		case 'update_gym':
324
+			$teams = new stdClass();
325
+			$teams->mystic = 1;
326
+			$teams->valor = 2;
327
+			$teams->instinct = 3;
322 328
 
323
-	case 'update_gym':
324
-		$teams = new stdClass();
325
-		$teams->mystic = 1;
326
-		$teams->valor = 2;
327
-		$teams->instinct = 3;
328 329
 
330
+			foreach ($teams as $team_name => $team_id) {
331
+				$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
332
+				$result = $mysqli->query($req);
333
+				$data = $result->fetch_object();
329 334
 
330
-		foreach ($teams as $team_name => $team_id) {
331
-			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
332
-			$result = $mysqli->query($req);
333
-			$data = $result->fetch_object();
335
+				$return[] = $data->total;
336
+				$return[] = $data->average_points;
337
+			}
334 338
 
335
-			$return[] = $data->total;
336
-			$return[] = $data->average_points;
337
-		}
339
+			header('Content-Type: application/json');
340
+			echo json_encode($return);
338 341
 
339
-		header('Content-Type: application/json');
340
-		echo json_encode($return);
342
+			break;
341 343
 
342
-		break;
343 344
 
345
+		####################################
346
+		//
347
+		// Get datas for the gym map
348
+		//
349
+		####################################
344 350
 
345
-	####################################
346
-	//
347
-	// Get datas for the gym map
348
-	//
349
-	####################################
350 351
 
352
+		case 'gym_map':
353
+			$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";
354
+			$result = $mysqli->query($req);
351 355
 
352
-	case 'gym_map':
353
-		$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";
354
-		$result = $mysqli->query($req);
356
+			$gyms = [];
355 357
 
356
-		$gyms = [];
358
+			while ($data = $result->fetch_object()) {
359
+				// Team
360
+				// 1 = bleu
361
+				// 2 = rouge
362
+				// 3 = jaune
357 363
 
358
-		while ($data = $result->fetch_object()) {
359
-			// Team
360
-			// 1 = bleu
361
-			// 2 = rouge
362
-			// 3 = jaune
363
-
364
-			switch ($data->team_id) {
364
+				switch ($data->team_id) {
365 365
 				case 0:
366 366
 					$icon	= 'map_white.png';
367 367
 					$team	= 'No Team (yet)';
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 					$team	= 'Team Instinct';
386 386
 					$color = 'rgba(254, 217, 40, .6)';
387 387
 					break;
388
-			}
388
+				}
389 389
 
390 390
 			if ($data->team_id != 0) {
391 391
 				$icon .= $data->level.".png";
@@ -411,50 +411,50 @@  discard block
 block discarded – undo
411 411
 	//
412 412
 	####################################
413 413
 
414
-	case 'gym_defenders':
415
-		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
416
-		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
414
+		case 'gym_defenders':
415
+			$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
416
+			$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team,
417 417
 					(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
418 418
 					FROM gymdetails
419 419
 					LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id
420 420
 					WHERE gym.gym_id='".$gym_id."'";
421
-		$result = $mysqli->query($req);
421
+			$result = $mysqli->query($req);
422 422
 
423
-		$gymData['gymDetails']['gymInfos'] = false;
423
+			$gymData['gymDetails']['gymInfos'] = false;
424 424
 
425
-		while ($data = $result->fetch_object()) {
426
-			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
427
-			$gymData['gymDetails']['gymInfos']['description'] = $data->description;
428
-			if ($data->url == null) {
429
-				$gymData['gymDetails']['gymInfos']['url'] = '';
430
-			} else {
431
-				$gymData['gymDetails']['gymInfos']['url'] = $data->url;
425
+			while ($data = $result->fetch_object()) {
426
+				$gymData['gymDetails']['gymInfos']['name'] = $data->name;
427
+				$gymData['gymDetails']['gymInfos']['description'] = $data->description;
428
+				if ($data->url == null) {
429
+					$gymData['gymDetails']['gymInfos']['url'] = '';
430
+				} else {
431
+					$gymData['gymDetails']['gymInfos']['url'] = $data->url;
432
+				}
433
+				$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
434
+				$gymData['gymDetails']['gymInfos']['level'] = $data->level;
435
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
436
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team;
437
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
432 438
 			}
433
-			$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
434
-			$gymData['gymDetails']['gymInfos']['level'] = $data->level;
435
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
436
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
437
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
438
-		}
439 439
 
440
-		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
440
+			$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
441 441
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
442 442
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
443 443
 					HAVING gymmember.gym_id='".$gym_id."'
444 444
 					ORDER BY cp DESC";
445
-		$result = $mysqli->query($req);
445
+			$result = $mysqli->query($req);
446 446
 
447
-		$i = 0;
447
+			$i = 0;
448 448
 
449
-		$gymData['infoWindow'] = '
449
+			$gymData['infoWindow'] = '
450 450
 			<div class="gym_defenders">
451 451
 			';
452
-		while ($data = $result->fetch_object()) {
453
-			$gymData['gymDetails']['pokemons'][] = $data;
454
-			if ($data != false) {
455
-				$pokemon_id = $data->pokemon_id;
456
-				if ($config->system->iv_numbers) {
457
-					$gymData['infoWindow'] .= '
452
+			while ($data = $result->fetch_object()) {
453
+				$gymData['gymDetails']['pokemons'][] = $data;
454
+				if ($data != false) {
455
+					$pokemon_id = $data->pokemon_id;
456
+					if ($config->system->iv_numbers) {
457
+						$gymData['infoWindow'] .= '
458 458
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
459 459
 						<a href="pokemon/'.$data->pokemon_id.'">
460 460
 						<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 								</div>
473 473
 							</div>
474 474
 						</div>';
475
-				} else {
476
-					$gymData['infoWindow'] .= '
475
+					} else {
476
+						$gymData['infoWindow'] .= '
477 477
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
478 478
 						<a href="pokemon/'.$data->pokemon_id.'">
479 479
 						<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
@@ -491,80 +491,80 @@  discard block
 block discarded – undo
491 491
 							</div>
492 492
 						</div>
493 493
 					</div>'
494
-						; }
495
-			} else {
496
-				$pokemon_id = $gymData['gymDetails']['gymInfos']['guardPokemonId'];
497
-				$gymData['infoWindow'] .= '
494
+							; }
495
+				} else {
496
+					$pokemon_id = $gymData['gymDetails']['gymInfos']['guardPokemonId'];
497
+					$gymData['infoWindow'] .= '
498 498
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
499 499
 					<a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'">
500 500
 					<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
501 501
 					</a>
502 502
 					<p class="pkmn-name">???</p>
503 503
 				</div>'
504
-				;
504
+					;
505
+				}
506
+				$i++;
505 507
 			}
506
-			$i++;
507
-		}
508 508
 
509
-		// check whether we could retrieve gym infos, otherwise use basic gym info
510
-		if (!$gymData['gymDetails']['gymInfos']) {
511
-			$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
509
+			// check whether we could retrieve gym infos, otherwise use basic gym info
510
+			if (!$gymData['gymDetails']['gymInfos']) {
511
+				$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
512 512
 				FROM gym WHERE gym_id='".$gym_id."'";
513
-			$result = $mysqli->query($req);
514
-			$data = $result->fetch_object();
515
-
516
-			$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
517
-			$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
518
-			$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
519
-			$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
520
-			$gymData['gymDetails']['gymInfos']['level'] = $data->level;
521
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
522
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
523
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
524
-
525
-			$pokemon_id = $data->guard_pokemon_id;
526
-			$gymData['infoWindow'] .= '
513
+				$result = $mysqli->query($req);
514
+				$data = $result->fetch_object();
515
+
516
+				$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
517
+				$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
518
+				$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
519
+				$gymData['gymDetails']['gymInfos']['points'] = $data->total_cp;
520
+				$gymData['gymDetails']['gymInfos']['level'] = $data->level;
521
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
522
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
523
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
524
+
525
+				$pokemon_id = $data->guard_pokemon_id;
526
+				$gymData['infoWindow'] .= '
527 527
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
528 528
 					<a href="pokemon/'.$data->guard_pokemon_id.'">
529 529
 					<img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" >
530 530
 					</a>
531 531
 					<p class="pkmn-name">???</p>
532 532
 				</div>';
533
-		}
534
-		$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
533
+			}
534
+			$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
535 535
 
536
-		header('Content-Type: application/json');
537
-		echo json_encode($gymData);
536
+			header('Content-Type: application/json');
537
+			echo json_encode($gymData);
538 538
 
539
-		break;
539
+			break;
540 540
 
541 541
 
542
-	case 'trainer':
543
-		$name = "";
544
-		$page = "0";
545
-		$where = "";
546
-		$order = "";
547
-		$team = 0;
548
-		$ranking = 0;
549
-		if (isset($_GET['name'])) {
550
-			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
551
-			$where = " HAVING name LIKE '%".$trainer_name."%'";
552
-		}
553
-		if (isset($_GET['team']) && $_GET['team'] != 0) {
554
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
555
-			$where .= ($where == "" ? " HAVING" : " AND")." team = ".$team;
556
-		}
557
-		if (!empty($config->system->trainer_blacklist)) {
558
-			$where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')";
559
-		}
560
-		if (isset($_GET['page'])) {
561
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
562
-		}
563
-		if (isset($_GET['ranking'])) {
564
-			$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
565
-		}
542
+		case 'trainer':
543
+			$name = "";
544
+			$page = "0";
545
+			$where = "";
546
+			$order = "";
547
+			$team = 0;
548
+			$ranking = 0;
549
+			if (isset($_GET['name'])) {
550
+				$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
551
+				$where = " HAVING name LIKE '%".$trainer_name."%'";
552
+			}
553
+			if (isset($_GET['team']) && $_GET['team'] != 0) {
554
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
555
+				$where .= ($where == "" ? " HAVING" : " AND")." team = ".$team;
556
+			}
557
+			if (!empty($config->system->trainer_blacklist)) {
558
+				$where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')";
559
+			}
560
+			if (isset($_GET['page'])) {
561
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
562
+			}
563
+			if (isset($_GET['ranking'])) {
564
+				$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
565
+			}
566 566
 
567
-		switch ($ranking) {
567
+			switch ($ranking) {
568 568
 			case 1:
569 569
 				$order = " ORDER BY active DESC, level DESC";
570 570
 				break;
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 				break;
574 574
 			default:
575 575
 				$order = " ORDER BY level DESC, active DESC";
576
-		}
576
+			}
577 577
 
578 578
 		$order .= ", last_seen DESC, name ";
579 579
 
@@ -649,130 +649,130 @@  discard block
 block discarded – undo
649 649
 		break;
650 650
 
651 651
 
652
-	case 'raids':
653
-		$page = "0";
654
-		if (isset($_GET['page'])) {
655
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
656
-		}
652
+		case 'raids':
653
+			$page = "0";
654
+			if (isset($_GET['page'])) {
655
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
656
+			}
657 657
 
658
-		$limit = " LIMIT ".($page * 10).",10";
658
+			$limit = " LIMIT ".($page * 10).",10";
659 659
 
660
-		$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
660
+			$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 661
 				JOIN gymdetails ON gymdetails.gym_id = raid.gym_id
662 662
 				JOIN gym ON gym.gym_id = raid.gym_id
663 663
 				WHERE raid.end > UTC_TIMESTAMP()
664 664
 				ORDER BY raid.level DESC, raid.start".$limit;
665 665
 
666
-		$result = $mysqli->query($req);
667
-		$raids = array();
668
-		while ($data = $result->fetch_object()) {
669
-			$data->starttime = date("H:i", strtotime($data->start));
670
-			$data->endtime = date("H:i", strtotime($data->end));
671
-			$data->gym_id = str_replace('.', '_', $data->gym_id);
672
-			if (isset($data->move_1)) {
673
-				$move1 = $data->move_1;
674
-				$data->quick_move = $move->$move1->name;
675
-			} else {
676
-				$data->quick_move = "?";
677
-			}
678
-			if (isset($data->move_2)) {
679
-				$move2 = $data->move_2;
680
-				$data->charge_move = $move->$move2->name;
681
-			} else {
682
-				$data->charge_move = "?";
666
+			$result = $mysqli->query($req);
667
+			$raids = array();
668
+			while ($data = $result->fetch_object()) {
669
+				$data->starttime = date("H:i", strtotime($data->start));
670
+				$data->endtime = date("H:i", strtotime($data->end));
671
+				$data->gym_id = str_replace('.', '_', $data->gym_id);
672
+				if (isset($data->move_1)) {
673
+					$move1 = $data->move_1;
674
+					$data->quick_move = $move->$move1->name;
675
+				} else {
676
+					$data->quick_move = "?";
677
+				}
678
+				if (isset($data->move_2)) {
679
+					$move2 = $data->move_2;
680
+					$data->charge_move = $move->$move2->name;
681
+				} else {
682
+					$data->charge_move = "?";
683
+				}
684
+				$raids[$data->gym_id] = $data;
683 685
 			}
684
-			$raids[$data->gym_id] = $data;
685
-		}
686
-		$json = array();
687
-		$json['raids'] = $raids;
688
-		$locale = array();
689
-		$locale['noraids'] = $locales->RAIDS_NONE;
690
-		$json['locale'] = $locale;
686
+			$json = array();
687
+			$json['raids'] = $raids;
688
+			$locale = array();
689
+			$locale['noraids'] = $locales->RAIDS_NONE;
690
+			$json['locale'] = $locale;
691 691
 
692
-		header('Content-Type: application/json');
693
-		echo json_encode($json);
692
+			header('Content-Type: application/json');
693
+			echo json_encode($json);
694 694
 
695
-		break;
695
+			break;
696 696
 
697
-	case 'pokemon_slider_init':
698
-		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
699
-		$result 	= $mysqli->query($req);
700
-		$bounds		= $result->fetch_object();
697
+		case 'pokemon_slider_init':
698
+			$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
699
+			$result 	= $mysqli->query($req);
700
+			$bounds		= $result->fetch_object();
701 701
 
702
-		header('Content-Type: application/json');
703
-		echo json_encode($bounds);
702
+			header('Content-Type: application/json');
703
+			echo json_encode($bounds);
704 704
 
705
-		break;
705
+			break;
706 706
 
707 707
 
708
-	case 'pokemon_heatmap_points':
709
-		$json = "";
710
-		if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
711
-			$start = date("Y-m-d H:i", (int) $_GET['start']);
712
-			$end = date("Y-m-d H:i", (int) $_GET['end']);
713
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
714
-			$where = " WHERE pokemon_id = ".$pokemon_id." "
715
-					. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
716
-			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
717
-			$result = $mysqli->query($req);
718
-			$points = array();
719
-			while ($result && $data = $result->fetch_object()) {
720
-				$points[] = $data;
721
-			}
708
+		case 'pokemon_heatmap_points':
709
+			$json = "";
710
+			if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
711
+				$start = date("Y-m-d H:i", (int) $_GET['start']);
712
+				$end = date("Y-m-d H:i", (int) $_GET['end']);
713
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
714
+				$where = " WHERE pokemon_id = ".$pokemon_id." "
715
+						. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
716
+				$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
717
+				$result = $mysqli->query($req);
718
+				$points = array();
719
+				while ($result && $data = $result->fetch_object()) {
720
+					$points[] = $data;
721
+				}
722 722
 
723
-			$json = json_encode($points);
724
-		}
723
+				$json = json_encode($points);
724
+			}
725 725
 
726
-		header('Content-Type: application/json');
727
-		echo $json;
728
-		break;
726
+			header('Content-Type: application/json');
727
+			echo $json;
728
+			break;
729 729
 
730 730
 
731
-	case 'maps_localization_coordinates':
732
-		$json = "";
733
-		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
734
-		$result = $mysqli->query($req);
735
-		$coordinates = $result->fetch_object();
731
+		case 'maps_localization_coordinates':
732
+			$json = "";
733
+			$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
734
+			$result = $mysqli->query($req);
735
+			$coordinates = $result->fetch_object();
736 736
 
737
-		header('Content-Type: application/json');
738
-		echo json_encode($coordinates);
737
+			header('Content-Type: application/json');
738
+			echo json_encode($coordinates);
739 739
 
740
-		break;
740
+			break;
741 741
 
742 742
 
743
-	case 'pokemon_graph_data':
744
-		$json = "";
745
-		if (isset($_GET['pokemon_id'])) {
746
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
747
-			$req = "SELECT COUNT(*) AS total,
743
+		case 'pokemon_graph_data':
744
+			$json = "";
745
+			if (isset($_GET['pokemon_id'])) {
746
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
747
+				$req = "SELECT COUNT(*) AS total,
748 748
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour
749 749
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered
750 750
 					GROUP BY disappear_hour
751 751
 					ORDER BY disappear_hour";
752
-			$result = $mysqli->query($req);
753
-			$array = array_fill(0, 24, 0);
754
-			while ($result && $data = $result->fetch_object()) {
755
-				$array[$data->disappear_hour] = $data->total;
752
+				$result = $mysqli->query($req);
753
+				$array = array_fill(0, 24, 0);
754
+				while ($result && $data = $result->fetch_object()) {
755
+					$array[$data->disappear_hour] = $data->total;
756
+				}
757
+				// shift array because AM/PM starts at 1AM not 0:00
758
+				$array[] = $array[0];
759
+				array_shift($array);
760
+
761
+				$json = json_encode($array);
756 762
 			}
757
-			// shift array because AM/PM starts at 1AM not 0:00
758
-			$array[] = $array[0];
759
-			array_shift($array);
760 763
 
761
-			$json = json_encode($array);
762
-		}
764
+			header('Content-Type: application/json');
765
+			echo $json;
766
+			break;
763 767
 
764
-		header('Content-Type: application/json');
765
-		echo $json;
766
-		break;
767 768
 
769
+		case 'postRequest':
770
+			break;
768 771
 
769
-	case 'postRequest':
772
+		default:
773
+			echo "What do you mean?";
774
+			exit();
770 775
 		break;
771
-
772
-	default:
773
-		echo "What do you mean?";
774
-		exit();
775
-	break;
776 776
 }
777 777
 
778 778
 if ($postRequest != "") {
Please login to merge, or discard this patch.