Passed
Push — master ( 3432ea...d7936c )
by Markus
06:00
created
core/process/aru.php 1 patch
Switch Indentation   +330 added lines, -330 removed lines patch added patch discarded remove patch
@@ -58,152 +58,152 @@  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, 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, 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
-				$last_location = new stdClass();
181
-				$last_location->latitude = $data->latitude;
182
-				$last_location->longitude = $data->longitude;
183
-
184
-				if ($config->system->recents_show_iv) {
185
-					$iv = new stdClass();
186
-					$iv->attack = $data->individual_attack;
187
-					$iv->defense = $data->individual_defense;
188
-					$iv->stamina = $data->individual_stamina;
189
-					if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) {
190
-						$iv->available = true;
191
-					} else {
192
-						$iv->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
+					$last_location = new stdClass();
181
+					$last_location->latitude = $data->latitude;
182
+					$last_location->longitude = $data->longitude;
183
+
184
+					if ($config->system->recents_show_iv) {
185
+						$iv = new stdClass();
186
+						$iv->attack = $data->individual_attack;
187
+						$iv->defense = $data->individual_defense;
188
+						$iv->stamina = $data->individual_stamina;
189
+						if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) {
190
+							$iv->available = true;
191
+						} else {
192
+							$iv->available = false;
193
+						}
193 194
 					}
194
-				}
195 195
 
196
-				$html = '
196
+					$html = '
197 197
 			    <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;">
198 198
 				<a href="pokemon/'.$pokeid.'"><img src="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a>
199 199
 				<a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a>
200 200
 				<a href="https://maps.google.com/?q='.$last_location->latitude.','.$last_location->longitude.'&ll='.$last_location->latitude.','.$last_location->longitude.'&z=16" target="_blank">
201 201
 				    <small class="pokemon-timer">00:00:00</small>
202 202
 				</a>';
203
-				if ($config->system->recents_show_iv) {
204
-					if ($iv->available) {
205
-						if ($config->system->iv_numbers) {
206
-							$html .= '
203
+					if ($config->system->recents_show_iv) {
204
+						if ($iv->available) {
205
+							if ($config->system->iv_numbers) {
206
+								$html .= '
207 207
 							<div class="progress" style="height: 15px; margin-bottom: 0">
208 208
 								<div title="'.$locales->IV_ATTACK.': '.$iv->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$iv->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px";>
209 209
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .'
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .'
216 216
 								</div>
217 217
 							</div>';
218
-						} else {
219
-							$html .= '
218
+							} else {
219
+								$html .= '
220 220
 							<div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto;">
221 221
 					    		<div title="'.$locales->IV_ATTACK.': '.$iv->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$iv->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->attack) / 3).'%">
222 222
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>
229 229
 					    		</div>
230 230
 							</div>';
231
-						}
232
-					} else {
233
-						if ($config->system->iv_numbers) {
234
-							$html .= '
231
+							}
232
+						} else {
233
+							if ($config->system->iv_numbers) {
234
+								$html .= '
235 235
 							<div class="progress" style="height: 15px; margin-bottom: 0">
236 236
 								<div title="'.$locales->IV_ATTACK.': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$iv->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px";>
237 237
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>
@@ -243,126 +243,126 @@  discard block
 block discarded – undo
243 243
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>
244 244
 								</div>
245 245
 							</div>';
246
-						} else {
247
-						$html .= '
246
+							} else {
247
+							$html .= '
248 248
 					    <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 15px auto;">
249 249
 						    <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">
250 250
 							    <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span>
251 251
 						    </div>
252 252
 					    </div>';
253
+							}
253 254
 						}
254 255
 					}
255
-				}
256
-				$html .= '
256
+					$html .= '
257 257
 			    </div>';
258
-				$new_spawn['html'] = $html;
259
-				$countdown = $last_seen - time();
260
-				$new_spawn['countdown'] = $countdown;
261
-				$new_spawn['pokemon_uid'] = $pokeuid;
262
-				$total_spawns[] = $new_spawn;
263
-			} else {
264
-				break;
258
+					$new_spawn['html'] = $html;
259
+					$countdown = $last_seen - time();
260
+					$new_spawn['countdown'] = $countdown;
261
+					$new_spawn['pokemon_uid'] = $pokeuid;
262
+					$total_spawns[] = $new_spawn;
263
+				} else {
264
+					break;
265
+				}
265 266
 			}
266
-		}
267 267
 
268
-		header('Content-Type: application/json');
269
-		echo json_encode($total_spawns);
268
+			header('Content-Type: application/json');
269
+			echo json_encode($total_spawns);
270 270
 
271
-		break;
271
+			break;
272 272
 
273 273
 
274
-	####################################
275
-	//
276
-	// List Pokestop
277
-	//
278
-	####################################
274
+		####################################
275
+		//
276
+		// List Pokestop
277
+		//
278
+		####################################
279 279
 
280
-	case 'pokestop':
281
-		$where = "";
282
-		if ($config->system->only_lured_pokestops) {
283
-			$where = "WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration";
284
-		}
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 ".$where."";
280
+		case 'pokestop':
281
+			$where = "";
282
+			if ($config->system->only_lured_pokestops) {
283
+				$where = "WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration";
284
+			}
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 ".$where."";
286 286
 
287
-		//show all stops if no lure active
288
-		if (!$mysqli->query($req)->fetch_object()) {
289
-			$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop";
290
-		}
291
-		$result = $mysqli->query($req);
287
+			//show all stops if no lure active
288
+			if (!$mysqli->query($req)->fetch_object()) {
289
+				$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop";
290
+			}
291
+			$result = $mysqli->query($req);
292 292
 
293
-		$pokestops = [];
293
+			$pokestops = [];
294 294
 
295
-		while ($data = $result->fetch_object()) {
296
-			if ($data->lure_expiration >= $data->now) {
297
-				$icon = 'pokestap_lured.png';
298
-				$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
299
-			} else {
300
-				$icon = 'pokestap.png';
301
-				$text = $locales->POKESTOPS_MAP_REGULAR;
295
+			while ($data = $result->fetch_object()) {
296
+				if ($data->lure_expiration >= $data->now) {
297
+					$icon = 'pokestap_lured.png';
298
+					$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
299
+				} else {
300
+					$icon = 'pokestap.png';
301
+					$text = $locales->POKESTOPS_MAP_REGULAR;
302
+				}
303
+
304
+				$pokestops[] = [
305
+					$text,
306
+					$icon,
307
+					$data->latitude,
308
+					$data->longitude
309
+				];
302 310
 			}
303 311
 
304
-			$pokestops[] = [
305
-				$text,
306
-				$icon,
307
-				$data->latitude,
308
-				$data->longitude
309
-			];
310
-		}
312
+			header('Content-Type: application/json');
313
+			echo json_encode($pokestops);
311 314
 
312
-		header('Content-Type: application/json');
313
-		echo json_encode($pokestops);
315
+			break;
314 316
 
315
-		break;
316 317
 
318
+		####################################
319
+		//
320
+		// Update data for the gym battle
321
+		//
322
+		####################################
317 323
 
318
-	####################################
319
-	//
320
-	// Update data for the gym battle
321
-	//
322
-	####################################
323
-
324
-	case 'update_gym':
325
-		$teams			= new stdClass();
326
-		$teams->mystic 		= 1;
327
-		$teams->valor 		= 2;
328
-		$teams->instinct 	= 3;
324
+		case 'update_gym':
325
+			$teams			= new stdClass();
326
+			$teams->mystic 		= 1;
327
+			$teams->valor 		= 2;
328
+			$teams->instinct 	= 3;
329 329
 
330 330
 
331
-		foreach ($teams as $team_name => $team_id) {
332
-			$req	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
333
-			$result	= $mysqli->query($req);
334
-			$data	= $result->fetch_object();
331
+			foreach ($teams as $team_name => $team_id) {
332
+				$req	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
333
+				$result	= $mysqli->query($req);
334
+				$data	= $result->fetch_object();
335 335
 
336
-			$return[] 	= $data->total;
337
-			$return[]	= $data->average_points;
338
-		}
336
+				$return[] 	= $data->total;
337
+				$return[]	= $data->average_points;
338
+			}
339 339
 
340
-		header('Content-Type: application/json');
341
-		echo json_encode($return);
340
+			header('Content-Type: application/json');
341
+			echo json_encode($return);
342 342
 
343
-		break;
343
+			break;
344 344
 
345 345
 
346
-	####################################
347
-	//
348
-	// Get datas for the gym map
349
-	//
350
-	####################################
346
+		####################################
347
+		//
348
+		// Get datas for the gym map
349
+		//
350
+		####################################
351 351
 
352 352
 
353
-	case 'gym_map':
354
-		$req	= "SELECT gym_id, team_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym";
355
-		$result = $mysqli->query($req);
353
+		case 'gym_map':
354
+			$req	= "SELECT gym_id, team_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym";
355
+			$result = $mysqli->query($req);
356 356
 
357
-		$gyms = [];
357
+			$gyms = [];
358 358
 
359
-		while ($data = $result->fetch_object()) {
360
-			// Team
361
-			// 1 = bleu
362
-			// 2 = rouge
363
-			// 3 = jaune
359
+			while ($data = $result->fetch_object()) {
360
+				// Team
361
+				// 1 = bleu
362
+				// 2 = rouge
363
+				// 3 = jaune
364 364
 
365
-			switch ($data->team_id) {
365
+				switch ($data->team_id) {
366 366
 				case 0:
367 367
 					$icon	= 'map_white.png';
368 368
 					$team	= 'No Team (yet)';
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 					$team	= 'Team Instinct';
387 387
 					$color	= 'rgba(254, 217, 40, .6)';
388 388
 					break;
389
-			}
389
+				}
390 390
 
391 391
 			// Set gym level
392 392
 			$gym_level = gym_level($data->gym_points);
@@ -415,50 +415,50 @@  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, gym.gym_points AS points, 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, gym.gym_points AS points, 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
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->points;
438
+				$gymData['gymDetails']['gymInfos']['level'] = 0;
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
+				$gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points);
436 443
 			}
437
-			$gymData['gymDetails']['gymInfos']['points'] = $data->points;
438
-			$gymData['gymDetails']['gymInfos']['level'] = 0;
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
-			$gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points);
443
-		}
444 444
 
445
-		$req 	= "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
445
+			$req 	= "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
446 446
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
447 447
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
448 448
 					HAVING gymmember.gym_id='".$gym_id."'
449 449
 					ORDER BY cp DESC";
450
-		$result = $mysqli->query($req);
450
+			$result = $mysqli->query($req);
451 451
 
452
-		$i = 0;
452
+			$i = 0;
453 453
 
454
-		$gymData['infoWindow'] = '
454
+			$gymData['infoWindow'] = '
455 455
 			<div class="gym_defenders">
456 456
 			';
457
-		while ($data = $result->fetch_object()) {
458
-			$gymData['gymDetails']['pokemons'][] = $data;
459
-			if ($data != false) {
460
-				if ($config->system->iv_numbers) {
461
-					$gymData['infoWindow'] .= '
457
+			while ($data = $result->fetch_object()) {
458
+				$gymData['gymDetails']['pokemons'][] = $data;
459
+				if ($data != false) {
460
+					if ($config->system->iv_numbers) {
461
+						$gymData['infoWindow'] .= '
462 462
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
463 463
 						<a href="pokemon/'.$data->pokemon_id.'">
464 464
 						<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 								</div>
477 477
 							</div>
478 478
 						</div>';
479
-				} else {
480
-					$gymData['infoWindow'] .= '
479
+					} else {
480
+						$gymData['infoWindow'] .= '
481 481
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
482 482
 						<a href="pokemon/'.$data->pokemon_id.'">
483 483
 						<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -495,76 +495,76 @@  discard block
 block discarded – undo
495 495
 							</div>
496 496
 						</div>
497 497
 					</div>'
498
-						; }
499
-			} else {
500
-				$gymData['infoWindow'] .= '
498
+							; }
499
+				} else {
500
+					$gymData['infoWindow'] .= '
501 501
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
502 502
 					<a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'">
503 503
 					<img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
504 504
 					</a>
505 505
 					<p class="pkmn-name">???</p>
506 506
 				</div>'
507
-				;
507
+					;
508
+				}
509
+				$i++;
508 510
 			}
509
-			$i++;
510
-		}
511 511
 
512
-		// check whether we could retrieve gym infos, otherwise use basic gym info
513
-		if (!$gymData['gymDetails']['gymInfos']) {
514
-			$req = "SELECT gym_id, team_id, gym_points, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned
512
+			// check whether we could retrieve gym infos, otherwise use basic gym info
513
+			if (!$gymData['gymDetails']['gymInfos']) {
514
+				$req = "SELECT gym_id, team_id, gym_points, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned
515 515
 				FROM gym WHERE gym_id='".$gym_id."'";
516
-			$result = $mysqli->query($req);
517
-			$data = $result->fetch_object();
518
-
519
-			$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
520
-			$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
521
-			$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
522
-			$gymData['gymDetails']['gymInfos']['points'] = $data->gym_points;
523
-			$gymData['gymDetails']['gymInfos']['level'] = 0;
524
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
525
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
526
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
527
-			$gymData['gymDetails']['gymInfos']['level'] = gym_level($data->gym_points);
528
-
529
-			$gymData['infoWindow'] .= '
516
+				$result = $mysqli->query($req);
517
+				$data = $result->fetch_object();
518
+
519
+				$gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE;
520
+				$gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE;
521
+				$gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png';
522
+				$gymData['gymDetails']['gymInfos']['points'] = $data->gym_points;
523
+				$gymData['gymDetails']['gymInfos']['level'] = 0;
524
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
525
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team_id;
526
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
527
+				$gymData['gymDetails']['gymInfos']['level'] = gym_level($data->gym_points);
528
+
529
+				$gymData['infoWindow'] .= '
530 530
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
531 531
 					<a href="pokemon/'.$data->guard_pokemon_id.'">
532 532
 					<img src="core/pokemons/'.$data->guard_pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
533 533
 					</a>
534 534
 					<p class="pkmn-name">???</p>
535 535
 				</div>';
536
-		}
537
-		$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
536
+			}
537
+			$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
538 538
 
539
-		header('Content-Type: application/json');
540
-		echo json_encode($gymData);
539
+			header('Content-Type: application/json');
540
+			echo json_encode($gymData);
541 541
 
542
-		break;
542
+			break;
543 543
 
544 544
 
545
-	case 'trainer':
546
-		$name = "";
547
-		$page = "0";
548
-		$where = "";
549
-		$order="";
550
-		$team=0;
551
-		$ranking=0;
552
-		if (isset($_GET['name'])) {
553
-			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
554
-			$where = " HAVING name LIKE '%".$trainer_name."%'";
555
-		}
556
-		if (isset($_GET['team']) && $_GET['team']!=0) {
557
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
558
-			$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
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
-		}
545
+		case 'trainer':
546
+			$name = "";
547
+			$page = "0";
548
+			$where = "";
549
+			$order="";
550
+			$team=0;
551
+			$ranking=0;
552
+			if (isset($_GET['name'])) {
553
+				$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
554
+				$where = " HAVING name LIKE '%".$trainer_name."%'";
555
+			}
556
+			if (isset($_GET['team']) && $_GET['team']!=0) {
557
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
558
+				$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
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 ";
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
 		$limit = " LIMIT ".($page*10).",10 ";
579 579
 
@@ -645,85 +645,85 @@  discard block
 block discarded – undo
645 645
 		break;
646 646
 
647 647
 
648
-	case 'pokemon_slider_init':
649
-		$req 		= "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
650
-		$result 	= $mysqli->query($req);
651
-		$bounds		= $result->fetch_object();
648
+		case 'pokemon_slider_init':
649
+			$req 		= "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
650
+			$result 	= $mysqli->query($req);
651
+			$bounds		= $result->fetch_object();
652
+
653
+			header('Content-Type: application/json');
654
+			echo json_encode($bounds);
652 655
 
653
-		header('Content-Type: application/json');
654
-		echo json_encode($bounds);
656
+			break;
655 657
 
656
-		break;
657 658
 
659
+		case 'pokemon_heatmap_points':
660
+			$json="";
661
+			if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
662
+				$start = Date("Y-m-d H:i",(int)$_GET['start']);
663
+				$end = Date("Y-m-d H:i",(int)$_GET['end']);
664
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
665
+				$where = " WHERE pokemon_id = ".$pokemon_id." "
666
+						. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
667
+				$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
668
+				$result 	= $mysqli->query($req);
669
+				$points = array();
670
+				while ($result && $data = $result->fetch_object()) {
671
+					$points[] 	= $data;
672
+				}
658 673
 
659
-	case 'pokemon_heatmap_points':
660
-		$json="";
661
-		if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
662
-			$start = Date("Y-m-d H:i",(int)$_GET['start']);
663
-			$end = Date("Y-m-d H:i",(int)$_GET['end']);
664
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
665
-			$where = " WHERE pokemon_id = ".$pokemon_id." "
666
-					. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
667
-			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
668
-			$result 	= $mysqli->query($req);
669
-			$points = array();
670
-			while ($result && $data = $result->fetch_object()) {
671
-				$points[] 	= $data;
674
+				$json = json_encode($points);
672 675
 			}
673 676
 
674
-			$json = json_encode($points);
675
-		}
676
-
677
-		header('Content-Type: application/json');
678
-		echo $json;
679
-		break;
677
+			header('Content-Type: application/json');
678
+			echo $json;
679
+			break;
680 680
 
681 681
 
682
-	case 'maps_localization_coordinates':
683
-		$json="";
684
-		$req 		 = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
685
-		$result 	 = $mysqli->query($req);
686
-		$coordinates = $result->fetch_object();
682
+		case 'maps_localization_coordinates':
683
+			$json="";
684
+			$req 		 = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
685
+			$result 	 = $mysqli->query($req);
686
+			$coordinates = $result->fetch_object();
687 687
 		
688
-		header('Content-Type: application/json');
689
-		echo json_encode($coordinates);
688
+			header('Content-Type: application/json');
689
+			echo json_encode($coordinates);
690 690
 
691
-		break;
691
+			break;
692 692
 
693 693
 
694
-	case 'pokemon_graph_data':
695
-		$json="";
696
-		if (isset($_GET['pokemon_id'])) {
697
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
698
-			$req = "SELECT COUNT(*) AS total,
694
+		case 'pokemon_graph_data':
695
+			$json="";
696
+			if (isset($_GET['pokemon_id'])) {
697
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
698
+				$req = "SELECT COUNT(*) AS total,
699 699
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour
700 700
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered
701 701
 					GROUP BY disappear_hour
702 702
 					ORDER BY disappear_hour";
703
-			$result	= $mysqli->query($req);
704
-			$array = array_fill(0, 24, 0);
705
-			while ($result && $data = $result->fetch_object()) {
706
-				$array[$data->disappear_hour] = $data->total;
703
+				$result	= $mysqli->query($req);
704
+				$array = array_fill(0, 24, 0);
705
+				while ($result && $data = $result->fetch_object()) {
706
+					$array[$data->disappear_hour] = $data->total;
707
+				}
708
+				// shift array because AM/PM starts at 1AM not 0:00
709
+				$array[] = $array[0];
710
+				array_shift($array);
711
+
712
+				$json = json_encode($array);
707 713
 			}
708
-			// shift array because AM/PM starts at 1AM not 0:00
709
-			$array[] = $array[0];
710
-			array_shift($array);
711 714
 
712
-			$json = json_encode($array);
713
-		}
715
+			header('Content-Type: application/json');
716
+			echo $json;
717
+			break;
714 718
 
715
-		header('Content-Type: application/json');
716
-		echo $json;
717
-		break;
718 719
 
720
+		case 'postRequest':
721
+			break;
719 722
 
720
-	case 'postRequest':
723
+		default:
724
+			echo "What do you mean?";
725
+			exit();
721 726
 		break;
722
-
723
-	default:
724
-		echo "What do you mean?";
725
-		exit();
726
-	break;
727 727
 }
728 728
 
729 729
 if ($postRequest!="") {
Please login to merge, or discard this patch.