Passed
Pull Request — master (#250)
by Markus
05:02
created
core/process/aru.php 2 patches
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,121 +243,121 @@  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
-
268
-		header('Content-Type: application/json');
269
-		echo json_encode($total_spawns);
270
-
271
-		break;
272 267
 
268
+			header('Content-Type: application/json');
269
+			echo json_encode($total_spawns);
273 270
 
274
-	####################################
275
-	//
276
-	// List Pokestop
277
-	//
278
-	####################################
271
+			break;
279 272
 
280
-	case 'pokestop':
281
-		if (!($config->system->only_lured_pokestops)) {
282
-			$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
-		} else {
284
-			$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 lure_expiration > UTC_TIMESTAMP()";
285
-		}
286
-		$result = $mysqli->query($req);
287 273
 
288
-		$pokestops = [];
274
+		####################################
275
+		//
276
+		// List Pokestop
277
+		//
278
+		####################################
289 279
 
290
-		while ($data = $result->fetch_object()) {
291
-			if ($data->lure_expiration >= $data->now) {
292
-				$icon = 'pokestap_lured.png';
293
-				$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
280
+		case 'pokestop':
281
+			if (!($config->system->only_lured_pokestops)) {
282
+				$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop";
294 283
 			} else {
295
-				$icon = 'pokestap.png';
296
-				$text = $locales->POKESTOPS_MAP_REGULAR;
284
+				$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 lure_expiration > UTC_TIMESTAMP()";
297 285
 			}
286
+			$result = $mysqli->query($req);
298 287
 
299
-			$pokestops[] = [
300
-				$text,
301
-				$icon,
302
-				$data->latitude,
303
-				$data->longitude
304
-			];
305
-		}
288
+			$pokestops = [];
306 289
 
307
-		header('Content-Type: application/json');
308
-		echo json_encode($pokestops);
290
+			while ($data = $result->fetch_object()) {
291
+				if ($data->lure_expiration >= $data->now) {
292
+					$icon = 'pokestap_lured.png';
293
+					$text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real)));
294
+				} else {
295
+					$icon = 'pokestap.png';
296
+					$text = $locales->POKESTOPS_MAP_REGULAR;
297
+				}
309 298
 
310
-		break;
299
+				$pokestops[] = [
300
+					$text,
301
+					$icon,
302
+					$data->latitude,
303
+					$data->longitude
304
+				];
305
+			}
311 306
 
307
+			header('Content-Type: application/json');
308
+			echo json_encode($pokestops);
312 309
 
313
-	####################################
314
-	//
315
-	// Update data for the gym battle
316
-	//
317
-	####################################
310
+			break;
318 311
 
319
-	case 'update_gym':
320
-		$teams			= new stdClass();
321
-		$teams->mystic 		= 1;
322
-		$teams->valor 		= 2;
323
-		$teams->instinct 	= 3;
324 312
 
313
+		####################################
314
+		//
315
+		// Update data for the gym battle
316
+		//
317
+		####################################
325 318
 
326
-		foreach ($teams as $team_name => $team_id) {
327
-			$req	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
328
-			$result	= $mysqli->query($req);
329
-			$data	= $result->fetch_object();
319
+		case 'update_gym':
320
+			$teams			= new stdClass();
321
+			$teams->mystic 		= 1;
322
+			$teams->valor 		= 2;
323
+			$teams->instinct 	= 3;
330 324
 
331
-			$return[] 	= $data->total;
332
-			$return[]	= $data->average_points;
333
-		}
334 325
 
335
-		header('Content-Type: application/json');
336
-		echo json_encode($return);
326
+			foreach ($teams as $team_name => $team_id) {
327
+				$req	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
328
+				$result	= $mysqli->query($req);
329
+				$data	= $result->fetch_object();
337 330
 
338
-		break;
331
+				$return[] 	= $data->total;
332
+				$return[]	= $data->average_points;
333
+			}
339 334
 
335
+			header('Content-Type: application/json');
336
+			echo json_encode($return);
340 337
 
341
-	####################################
342
-	//
343
-	// Get datas for the gym map
344
-	//
345
-	####################################
338
+			break;
346 339
 
347 340
 
348
-	case 'gym_map':
349
-		$req	= "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym";
350
-		$result = $mysqli->query($req);
341
+		####################################
342
+		//
343
+		// Get datas for the gym map
344
+		//
345
+		####################################
351 346
 
352
-		$gyms = [];
353 347
 
354
-		while ($data = $result->fetch_object()) {
355
-			// Team
356
-			// 1 = bleu
357
-			// 2 = rouge
358
-			// 3 = jaune
348
+		case 'gym_map':
349
+			$req	= "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym";
350
+			$result = $mysqli->query($req);
359 351
 
360
-			switch ($data->team_id) {
352
+			$gyms = [];
353
+
354
+			while ($data = $result->fetch_object()) {
355
+				// Team
356
+				// 1 = bleu
357
+				// 2 = rouge
358
+				// 3 = jaune
359
+
360
+				switch ($data->team_id) {
361 361
 				case 0:
362 362
 					$icon	= 'map_white.png';
363 363
 					$team	= 'No Team (yet)';
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 					$team	= 'Team Instinct';
382 382
 					$color	= 'rgba(254, 217, 40, .6)';
383 383
 					break;
384
-			}
384
+				}
385 385
 
386 386
 			// Set gym level
387 387
 			$data->gym_level=0;
@@ -446,69 +446,69 @@  discard block
 block discarded – undo
446 446
 	//
447 447
 	####################################
448 448
 
449
-	case 'gym_defenders':
450
-		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
451
-		$req	= "SELECT gymdetails.name AS name, gymdetails.description AS description, gym.gym_points AS points, gymdetails.url AS url, gym.team_id AS team,
449
+		case 'gym_defenders':
450
+			$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
451
+			$req	= "SELECT gymdetails.name AS name, gymdetails.description AS description, gym.gym_points AS points, gymdetails.url AS url, gym.team_id AS team,
452 452
 					(CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id
453 453
 					FROM gymdetails
454 454
 					LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id
455 455
 					WHERE gym.gym_id='".$gym_id."'";
456
-		$result = $mysqli->query($req);
457
-		$gymData['gymDetails']['gymInfos'] = false;
456
+			$result = $mysqli->query($req);
457
+			$gymData['gymDetails']['gymInfos'] = false;
458 458
 		
459
-		while ($data = $result->fetch_object()) {
460
-			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
461
-			$gymData['gymDetails']['gymInfos']['description'] = $data->description;
462
-			if ($data->url == null) {
463
-				$gymData['gymDetails']['gymInfos']['url'] = '';
464
-			} else {
465
-				$gymData['gymDetails']['gymInfos']['url'] = $data->url;
466
-			}
467
-			$gymData['gymDetails']['gymInfos']['points'] = $data->points;
468
-			$gymData['gymDetails']['gymInfos']['level'] = 0;
469
-			$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
470
-			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
471
-			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
472
-			if ($data->points < 2000) {
473
-				$gymData['gymDetails']['gymInfos']['level']=1;
474
-			} elseif ($data->points < 4000) {
475
-				$gymData['gymDetails']['gymInfos']['level']=2;
476
-			} elseif ($data->points < 8000) {
477
-				$gymData['gymDetails']['gymInfos']['level']=3;
478
-			} elseif ($data->points < 12000) {
479
-				$gymData['gymDetails']['gymInfos']['level']=4;
480
-			} elseif ($data->points < 16000) {
481
-				$gymData['gymDetails']['gymInfos']['level']=5;
482
-			} elseif ($data->points < 20000) {
483
-				$gymData['gymDetails']['gymInfos']['level']=6;
484
-			} elseif ($data->points < 30000) {
485
-				$gymData['gymDetails']['gymInfos']['level']=7;
486
-			} elseif ($data->points < 40000) {
487
-				$gymData['gymDetails']['gymInfos']['level']=8;
488
-			} elseif ($data->points < 50000) {
489
-				$gymData['gymDetails']['gymInfos']['level']=9;
490
-			} else {
491
-				$gymData['gymDetails']['gymInfos']['level']=10;
459
+			while ($data = $result->fetch_object()) {
460
+				$gymData['gymDetails']['gymInfos']['name'] = $data->name;
461
+				$gymData['gymDetails']['gymInfos']['description'] = $data->description;
462
+				if ($data->url == null) {
463
+					$gymData['gymDetails']['gymInfos']['url'] = '';
464
+				} else {
465
+					$gymData['gymDetails']['gymInfos']['url'] = $data->url;
466
+				}
467
+				$gymData['gymDetails']['gymInfos']['points'] = $data->points;
468
+				$gymData['gymDetails']['gymInfos']['level'] = 0;
469
+				$gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned;
470
+				$gymData['gymDetails']['gymInfos']['team'] = $data->team;
471
+				$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
472
+				if ($data->points < 2000) {
473
+					$gymData['gymDetails']['gymInfos']['level']=1;
474
+				} elseif ($data->points < 4000) {
475
+					$gymData['gymDetails']['gymInfos']['level']=2;
476
+				} elseif ($data->points < 8000) {
477
+					$gymData['gymDetails']['gymInfos']['level']=3;
478
+				} elseif ($data->points < 12000) {
479
+					$gymData['gymDetails']['gymInfos']['level']=4;
480
+				} elseif ($data->points < 16000) {
481
+					$gymData['gymDetails']['gymInfos']['level']=5;
482
+				} elseif ($data->points < 20000) {
483
+					$gymData['gymDetails']['gymInfos']['level']=6;
484
+				} elseif ($data->points < 30000) {
485
+					$gymData['gymDetails']['gymInfos']['level']=7;
486
+				} elseif ($data->points < 40000) {
487
+					$gymData['gymDetails']['gymInfos']['level']=8;
488
+				} elseif ($data->points < 50000) {
489
+					$gymData['gymDetails']['gymInfos']['level']=9;
490
+				} else {
491
+					$gymData['gymDetails']['gymInfos']['level']=10;
492
+				}
492 493
 			}
493
-		}
494
-		//print_r($gymData);
495
-		$req 	= "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
494
+			//print_r($gymData);
495
+			$req 	= "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
496 496
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
497 497
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
498 498
 					HAVING gymmember.gym_id='".$gym_id."'
499 499
 					ORDER BY cp DESC";
500
-		$result = $mysqli->query($req);
500
+			$result = $mysqli->query($req);
501 501
 		
502
-		$i = 0;
502
+			$i = 0;
503 503
 		
504
-		$gymData['infoWindow'] = '
504
+			$gymData['infoWindow'] = '
505 505
 			<div class="gym_defenders">
506 506
 			';
507
-		while ($data = $result->fetch_object()) {
508
-			$gymData['gymDetails']['pokemons'][] = $data;
509
-			if ($data != false) {
510
-				if ($config->system->iv_numbers) {
511
-					$gymData['infoWindow'] .= '
507
+			while ($data = $result->fetch_object()) {
508
+				$gymData['gymDetails']['pokemons'][] = $data;
509
+				if ($data != false) {
510
+					if ($config->system->iv_numbers) {
511
+						$gymData['infoWindow'] .= '
512 512
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
513 513
 						<a href="pokemon/'.$data->pokemon_id.'">
514 514
 						<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 								</div>
527 527
 							</div>
528 528
 						</div>';
529
-				} else {
530
-					$gymData['infoWindow'] .= '
529
+					} else {
530
+						$gymData['infoWindow'] .= '
531 531
 					<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
532 532
 						<a href="pokemon/'.$data->pokemon_id.'">
533 533
 						<img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
@@ -545,50 +545,50 @@  discard block
 block discarded – undo
545 545
 							</div>
546 546
 						</div>
547 547
 					</div>'
548
-						; }
549
-			} else {
550
-				$gymData['infoWindow'] .= '
548
+							; }
549
+				} else {
550
+					$gymData['infoWindow'] .= '
551 551
 				<div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px">
552 552
 					<a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'">
553 553
 					<img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" >
554 554
 					</a>
555 555
 					<p class="pkmn-name">???</p>
556 556
 				</div>'
557
-				;
557
+					;
558
+				}
559
+				$i++;
558 560
 			}
559
-			$i++;
560
-		}
561
-		$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
561
+			$gymData['infoWindow'] = $gymData['infoWindow'].'</div>';
562 562
 
563
-		header('Content-Type: application/json');
564
-		echo json_encode($gymData);
563
+			header('Content-Type: application/json');
564
+			echo json_encode($gymData);
565 565
 
566
-		break;
566
+			break;
567 567
 
568 568
 
569
-	case 'trainer':
570
-		$name = "";
571
-		$page = "0";
572
-		$where = "";
573
-		$order="";
574
-		$team=0;
575
-		$ranking=0;
576
-		if (isset($_GET['name'])) {
577
-			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
578
-			$where = " HAVING name LIKE '%".$trainer_name."%'";
579
-		}
580
-		if (isset($_GET['team']) && $_GET['team']!=0) {
581
-			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
582
-			$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
583
-		}
584
-		if (isset($_GET['page'])) {
585
-			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
586
-		}
587
-		if (isset($_GET['ranking'])) {
588
-			$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
589
-		}
569
+		case 'trainer':
570
+			$name = "";
571
+			$page = "0";
572
+			$where = "";
573
+			$order="";
574
+			$team=0;
575
+			$ranking=0;
576
+			if (isset($_GET['name'])) {
577
+				$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
578
+				$where = " HAVING name LIKE '%".$trainer_name."%'";
579
+			}
580
+			if (isset($_GET['team']) && $_GET['team']!=0) {
581
+				$team = mysqli_real_escape_string($mysqli, $_GET['team']);
582
+				$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
583
+			}
584
+			if (isset($_GET['page'])) {
585
+				$page = mysqli_real_escape_string($mysqli, $_GET['page']);
586
+			}
587
+			if (isset($_GET['ranking'])) {
588
+				$ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']);
589
+			}
590 590
 
591
-		switch ($ranking) {
591
+			switch ($ranking) {
592 592
 			case 1:
593 593
 				$order=" ORDER BY active DESC ";
594 594
 				break;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 				break;
598 598
 			default:
599 599
 				$order=" ORDER BY level DESC, active DESC ";
600
-		}
600
+			}
601 601
 
602 602
 		$limit = " LIMIT ".($page*10).",10 ";
603 603
 
@@ -669,86 +669,86 @@  discard block
 block discarded – undo
669 669
 		break;
670 670
 
671 671
 
672
-	case 'pokemon_slider_init':
673
-		$req 		= "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
674
-		$result 	= $mysqli->query($req);
675
-		$bounds		= $result->fetch_object();
672
+		case 'pokemon_slider_init':
673
+			$req 		= "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
674
+			$result 	= $mysqli->query($req);
675
+			$bounds		= $result->fetch_object();
676 676
 
677
-		header('Content-Type: application/json');
678
-		echo json_encode($bounds);
677
+			header('Content-Type: application/json');
678
+			echo json_encode($bounds);
679 679
 
680
-		break;
680
+			break;
681 681
 
682 682
 
683
-	case 'pokemon_heatmap_points':
684
-		$json="";
685
-		if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
686
-			$start = Date("Y-m-d H:i",(int)$_GET['start']);
687
-			$end = Date("Y-m-d H:i",(int)$_GET['end']);
688
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
689
-			$where = " WHERE pokemon_id = ".$pokemon_id." "
690
-					. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
691
-			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
692
-			$result 	= $mysqli->query($req);
693
-			$points = array();
694
-			while ($result && $data = $result->fetch_object()) {
695
-				$points[] 	= $data;
696
-			}
683
+		case 'pokemon_heatmap_points':
684
+			$json="";
685
+			if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
686
+				$start = Date("Y-m-d H:i",(int)$_GET['start']);
687
+				$end = Date("Y-m-d H:i",(int)$_GET['end']);
688
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
689
+				$where = " WHERE pokemon_id = ".$pokemon_id." "
690
+						. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
691
+				$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
692
+				$result 	= $mysqli->query($req);
693
+				$points = array();
694
+				while ($result && $data = $result->fetch_object()) {
695
+					$points[] 	= $data;
696
+				}
697 697
 
698
-			$json = json_encode($points);
699
-		}
698
+				$json = json_encode($points);
699
+			}
700 700
 
701
-		header('Content-Type: application/json');
702
-		echo $json;
703
-		break;
701
+			header('Content-Type: application/json');
702
+			echo $json;
703
+			break;
704 704
 
705 705
 
706
-	case 'maps_localization_coordinates':
707
-		$json="";
708
-		$req 		 = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
709
-		$result 	 = $mysqli->query($req);
710
-		$data 		 = $result->fetch_object();
711
-		$coordinates = $data;
706
+		case 'maps_localization_coordinates':
707
+			$json="";
708
+			$req 		 = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
709
+			$result 	 = $mysqli->query($req);
710
+			$data 		 = $result->fetch_object();
711
+			$coordinates = $data;
712 712
 		
713
-		header('Content-Type: application/json');
714
-		echo json_encode($coordinates);
713
+			header('Content-Type: application/json');
714
+			echo json_encode($coordinates);
715 715
 
716
-		break;
716
+			break;
717 717
 
718 718
 
719
-	case 'pokemon_graph_data':
720
-		$json="";
721
-		if (isset($_GET['pokemon_id'])) {
722
-			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
723
-			$req = "SELECT COUNT(*) AS total,
719
+		case 'pokemon_graph_data':
720
+			$json="";
721
+			if (isset($_GET['pokemon_id'])) {
722
+				$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
723
+				$req = "SELECT COUNT(*) AS total,
724 724
 					HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour
725 725
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered
726 726
 					GROUP BY disappear_hour
727 727
 					ORDER BY disappear_hour";
728
-			$result	= $mysqli->query($req);
729
-			$array = array_fill(0, 24, 0);
730
-			while ($result && $data = $result->fetch_object()) {
731
-				$array[$data->disappear_hour] = $data->total;
728
+				$result	= $mysqli->query($req);
729
+				$array = array_fill(0, 24, 0);
730
+				while ($result && $data = $result->fetch_object()) {
731
+					$array[$data->disappear_hour] = $data->total;
732
+				}
733
+				// shift array because AM/PM starts at 1AM not 0:00
734
+				$array[] = $array[0];
735
+				array_shift($array);
736
+
737
+				$json = json_encode($array);
732 738
 			}
733
-			// shift array because AM/PM starts at 1AM not 0:00
734
-			$array[] = $array[0];
735
-			array_shift($array);
736 739
 
737
-			$json = json_encode($array);
738
-		}
740
+			header('Content-Type: application/json');
741
+			echo $json;
742
+			break;
739 743
 
740
-		header('Content-Type: application/json');
741
-		echo $json;
742
-		break;
743 744
 
745
+		case 'postRequest':
746
+			break;
744 747
 
745
-	case 'postRequest':
748
+		default:
749
+			echo "What do you mean?";
750
+			exit();
746 751
 		break;
747
-
748
-	default:
749
-		echo "What do you mean?";
750
-		exit();
751
-	break;
752 752
 }
753 753
 
754 754
 if ($postRequest!="") {
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 // Include & load the variables
20 20
 // ############################
21 21
 
22
-$variables 	= SYS_PATH.'/core/json/variables.json';
23
-$config 	= json_decode(file_get_contents($variables));
22
+$variables = SYS_PATH.'/core/json/variables.json';
23
+$config = json_decode(file_get_contents($variables));
24 24
 
25 25
 
26 26
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 # MySQL
40
-$mysqli 	= new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
40
+$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
41 41
 if ($mysqli->connect_error != '') {
42 42
 	exit('Error MySQL Connect');
43 43
 }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 $postRequest = "";
50 50
 if (isset($_POST['type'])) {
51 51
 	$postRequest = $_POST['type'];
52
-	$request= "postRequest";
52
+	$request = "postRequest";
53 53
 }
54 54
 switch ($request) {
55 55
 	############################
@@ -62,64 +62,64 @@  discard block
 block discarded – undo
62 62
 		// Right now
63 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 72
 		// Lured stops
73 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 83
 		// Team battle
84 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 92
 		// Team
93 93
 		// 1 = bleu
94 94
 		// 2 = rouge
95 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 101
 		// Red
102 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 109
 		// Blue
110 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 117
 		// Yellow
118 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 124
 		// Neutral
125 125
 		$values[] = $data->total;
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 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
-									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .'
209
+									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack.'
210 210
 								</div>
211 211
 								<div title="'.$locales->IV_DEFENSE.': '.$iv->defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$iv->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px";>
212
-									<span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense .'
212
+									<span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense.'
213 213
 								</div>
214 214
 								<div title="'.$locales->IV_STAMINA.': '.$iv->stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$iv->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px";>
215
-									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .'
215
+									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina.'
216 216
 								</div>
217 217
 							</div>';
218 218
 						} else {
@@ -221,10 +221,10 @@  discard block
 block discarded – undo
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>
223 223
 					    		</div>
224
-					    		<div title="'.$locales->IV_DEFENSE.': '.$iv->defense .'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$iv->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->defense) / 3).'%">
224
+					    		<div title="'.$locales->IV_DEFENSE.': '.$iv->defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$iv->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->defense) / 3).'%">
225 225
 									<span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>
226 226
 					    		</div>
227
-					    		<div title="'.$locales->IV_STAMINA.': '.$iv->stamina .'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$iv->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->stamina) / 3).'%">
227
+					    		<div title="'.$locales->IV_STAMINA.': '.$iv->stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$iv->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->stamina) / 3).'%">
228 228
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>
229 229
 					    		</div>
230 230
 							</div>';
@@ -317,19 +317,19 @@  discard block
 block discarded – undo
317 317
 	####################################
318 318
 
319 319
 	case 'update_gym':
320
-		$teams			= new stdClass();
321
-		$teams->mystic 		= 1;
322
-		$teams->valor 		= 2;
323
-		$teams->instinct 	= 3;
320
+		$teams = new stdClass();
321
+		$teams->mystic = 1;
322
+		$teams->valor = 2;
323
+		$teams->instinct = 3;
324 324
 
325 325
 
326 326
 		foreach ($teams as $team_name => $team_id) {
327
-			$req	= "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
328
-			$result	= $mysqli->query($req);
329
-			$data	= $result->fetch_object();
327
+			$req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'";
328
+			$result = $mysqli->query($req);
329
+			$data = $result->fetch_object();
330 330
 
331
-			$return[] 	= $data->total;
332
-			$return[]	= $data->average_points;
331
+			$return[] = $data->total;
332
+			$return[] = $data->average_points;
333 333
 		}
334 334
 
335 335
 		header('Content-Type: application/json');
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 
347 347
 
348 348
 	case 'gym_map':
349
-		$req	= "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym";
349
+		$req = "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym";
350 350
 		$result = $mysqli->query($req);
351 351
 
352 352
 		$gyms = [];
@@ -361,50 +361,50 @@  discard block
 block discarded – undo
361 361
 				case 0:
362 362
 					$icon	= 'map_white.png';
363 363
 					$team	= 'No Team (yet)';
364
-					$color	= 'rgba(0, 0, 0, .6)';
364
+					$color = 'rgba(0, 0, 0, .6)';
365 365
 					break;
366 366
 
367 367
 				case 1:
368 368
 					$icon	= 'map_blue_';
369 369
 					$team	= 'Team Mystic';
370
-					$color	= 'rgba(74, 138, 202, .6)';
370
+					$color = 'rgba(74, 138, 202, .6)';
371 371
 					break;
372 372
 
373 373
 				case 2:
374 374
 					$icon	= 'map_red_';
375 375
 					$team	= 'Team Valor';
376
-					$color	= 'rgba(240, 68, 58, .6)';
376
+					$color = 'rgba(240, 68, 58, .6)';
377 377
 					break;
378 378
 
379 379
 				case 3:
380 380
 					$icon	= 'map_yellow_';
381 381
 					$team	= 'Team Instinct';
382
-					$color	= 'rgba(254, 217, 40, .6)';
382
+					$color = 'rgba(254, 217, 40, .6)';
383 383
 					break;
384 384
 			}
385 385
 
386 386
 			// Set gym level
387
-			$data->gym_level=0;
387
+			$data->gym_level = 0;
388 388
 			if ($data->gym_points < 2000) {
389
-				$data->gym_level=1;
389
+				$data->gym_level = 1;
390 390
 			} elseif ($data->gym_points < 4000) {
391
-				$data->gym_level=2;
391
+				$data->gym_level = 2;
392 392
 			} elseif ($data->gym_points < 8000) {
393
-				$data->gym_level=3;
393
+				$data->gym_level = 3;
394 394
 			} elseif ($data->gym_points < 12000) {
395
-				$data->gym_level=4;
395
+				$data->gym_level = 4;
396 396
 			} elseif ($data->gym_points < 16000) {
397
-				$data->gym_level=5;
397
+				$data->gym_level = 5;
398 398
 			} elseif ($data->gym_points < 20000) {
399
-				$data->gym_level=6;
399
+				$data->gym_level = 6;
400 400
 			} elseif ($data->gym_points < 30000) {
401
-				$data->gym_level=7;
401
+				$data->gym_level = 7;
402 402
 			} elseif ($data->gym_points < 40000) {
403
-				$data->gym_level=8;
403
+				$data->gym_level = 8;
404 404
 			} elseif ($data->gym_points < 50000) {
405
-				$data->gym_level=9;
405
+				$data->gym_level = 9;
406 406
 			} else {
407
-				$data->gym_level=10;
407
+				$data->gym_level = 10;
408 408
 			}
409 409
 
410 410
 			## I know, I revert commit 6e8d2e7 from @kiralydavid but the way it was done broke the page.
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 
449 449
 	case 'gym_defenders':
450 450
 		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
451
-		$req	= "SELECT gymdetails.name AS name, gymdetails.description AS description, gym.gym_points AS points, gymdetails.url AS url, gym.team_id AS team,
451
+		$req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gym.gym_points AS points, gymdetails.url AS url, gym.team_id AS team,
452 452
 					(CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id
453 453
 					FROM gymdetails
454 454
 					LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id
@@ -470,29 +470,29 @@  discard block
 block discarded – undo
470 470
 			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
471 471
 			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
472 472
 			if ($data->points < 2000) {
473
-				$gymData['gymDetails']['gymInfos']['level']=1;
473
+				$gymData['gymDetails']['gymInfos']['level'] = 1;
474 474
 			} elseif ($data->points < 4000) {
475
-				$gymData['gymDetails']['gymInfos']['level']=2;
475
+				$gymData['gymDetails']['gymInfos']['level'] = 2;
476 476
 			} elseif ($data->points < 8000) {
477
-				$gymData['gymDetails']['gymInfos']['level']=3;
477
+				$gymData['gymDetails']['gymInfos']['level'] = 3;
478 478
 			} elseif ($data->points < 12000) {
479
-				$gymData['gymDetails']['gymInfos']['level']=4;
479
+				$gymData['gymDetails']['gymInfos']['level'] = 4;
480 480
 			} elseif ($data->points < 16000) {
481
-				$gymData['gymDetails']['gymInfos']['level']=5;
481
+				$gymData['gymDetails']['gymInfos']['level'] = 5;
482 482
 			} elseif ($data->points < 20000) {
483
-				$gymData['gymDetails']['gymInfos']['level']=6;
483
+				$gymData['gymDetails']['gymInfos']['level'] = 6;
484 484
 			} elseif ($data->points < 30000) {
485
-				$gymData['gymDetails']['gymInfos']['level']=7;
485
+				$gymData['gymDetails']['gymInfos']['level'] = 7;
486 486
 			} elseif ($data->points < 40000) {
487
-				$gymData['gymDetails']['gymInfos']['level']=8;
487
+				$gymData['gymDetails']['gymInfos']['level'] = 8;
488 488
 			} elseif ($data->points < 50000) {
489
-				$gymData['gymDetails']['gymInfos']['level']=9;
489
+				$gymData['gymDetails']['gymInfos']['level'] = 9;
490 490
 			} else {
491
-				$gymData['gymDetails']['gymInfos']['level']=10;
491
+				$gymData['gymDetails']['gymInfos']['level'] = 10;
492 492
 			}
493 493
 		}
494 494
 		//print_r($gymData);
495
-		$req 	= "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
495
+		$req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id
496 496
 					FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid
497 497
 					GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id
498 498
 					HAVING gymmember.gym_id='".$gym_id."'
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 								<span class="sr-only">'.$locales->IV_ATTACK.' : '.$data->iv_attack.'</span>'.$data->iv_attack.'
520 520
 								</div>
521 521
 								<div title="'.$locales->IV_DEFENSE.': '.$data->iv_defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$data->iv_defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 13px; font-size: 11px">
522
-									<span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'. $data->iv_defense .'
522
+									<span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'.$data->iv_defense.'
523 523
 								</div>
524 524
 								<div title="'.$locales->IV_STAMINA.': '.$data->iv_stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$data->iv_stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 13px; font-size: 11px">
525
-									<span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'. $data->iv_stamina .'
525
+									<span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'.$data->iv_stamina.'
526 526
 								</div>
527 527
 							</div>
528 528
 						</div>';
@@ -570,16 +570,16 @@  discard block
 block discarded – undo
570 570
 		$name = "";
571 571
 		$page = "0";
572 572
 		$where = "";
573
-		$order="";
574
-		$team=0;
575
-		$ranking=0;
573
+		$order = "";
574
+		$team = 0;
575
+		$ranking = 0;
576 576
 		if (isset($_GET['name'])) {
577 577
 			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
578 578
 			$where = " HAVING name LIKE '%".$trainer_name."%'";
579 579
 		}
580
-		if (isset($_GET['team']) && $_GET['team']!=0) {
580
+		if (isset($_GET['team']) && $_GET['team'] != 0) {
581 581
 			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
582
-			$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
582
+			$where .= ($where == "" ? " HAVING" : "AND ")." team = ".$team;
583 583
 		}
584 584
 		if (isset($_GET['page'])) {
585 585
 			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
@@ -590,16 +590,16 @@  discard block
 block discarded – undo
590 590
 
591 591
 		switch ($ranking) {
592 592
 			case 1:
593
-				$order=" ORDER BY active DESC ";
593
+				$order = " ORDER BY active DESC ";
594 594
 				break;
595 595
 			case 2:
596
-				$order=" ORDER BY maxCp DESC ";
596
+				$order = " ORDER BY maxCp DESC ";
597 597
 				break;
598 598
 			default:
599
-				$order=" ORDER BY level DESC, active DESC ";
599
+				$order = " ORDER BY level DESC, active DESC ";
600 600
 		}
601 601
 
602
-		$limit = " LIMIT ".($page*10).",10 ";
602
+		$limit = " LIMIT ".($page * 10).",10 ";
603 603
 
604 604
 
605 605
 		$req = "SELECT trainer.*, COUNT(actives_pokemons.trainer_name) AS active, max(actives_pokemons.cp) AS maxCp
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 			$reqRanking = "SELECT COUNT(1) AS rank FROM trainer WHERE trainer.level >= ".$trainer->level;
621 621
 			$resultRanking = $mysqli->query($reqRanking);
622 622
 			while ($data = $resultRanking->fetch_object()) {
623
-				$trainer->rank = $data->rank ;
623
+				$trainer->rank = $data->rank;
624 624
 			}
625 625
 			$req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, filtered_gymmember.gym_id, '1' AS active
626 626
 					FROM gympokemon INNER JOIN
@@ -631,7 +631,7 @@  discard block
 block discarded – undo
631 631
 
632 632
 			$resultPkms = $mysqli->query($req);
633 633
 			$trainer->pokemons = array();
634
-			$active_gyms=0;
634
+			$active_gyms = 0;
635 635
 			$pkmCount = 0;
636 636
 			while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) {
637 637
 				$active_gyms++;
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
 
672 672
 	case 'pokemon_slider_init':
673
-		$req 		= "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
673
+		$req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon";
674 674
 		$result 	= $mysqli->query($req);
675 675
 		$bounds		= $result->fetch_object();
676 676
 
@@ -681,18 +681,18 @@  discard block
 block discarded – undo
681 681
 
682 682
 
683 683
 	case 'pokemon_heatmap_points':
684
-		$json="";
685
-		if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
686
-			$start = Date("Y-m-d H:i",(int)$_GET['start']);
687
-			$end = Date("Y-m-d H:i",(int)$_GET['end']);
684
+		$json = "";
685
+		if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
686
+			$start = Date("Y-m-d H:i", (int) $_GET['start']);
687
+			$end = Date("Y-m-d H:i", (int) $_GET['end']);
688 688
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
689 689
 			$where = " WHERE pokemon_id = ".$pokemon_id." "
690 690
 					. "AND disappear_time BETWEEN '".$start."' AND '".$end."'";
691 691
 			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
692
-			$result 	= $mysqli->query($req);
692
+			$result = $mysqli->query($req);
693 693
 			$points = array();
694 694
 			while ($result && $data = $result->fetch_object()) {
695
-				$points[] 	= $data;
695
+				$points[] = $data;
696 696
 			}
697 697
 
698 698
 			$json = json_encode($points);
@@ -704,10 +704,10 @@  discard block
 block discarded – undo
704 704
 
705 705
 
706 706
 	case 'maps_localization_coordinates':
707
-		$json="";
708
-		$req 		 = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
709
-		$result 	 = $mysqli->query($req);
710
-		$data 		 = $result->fetch_object();
707
+		$json = "";
708
+		$req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint";
709
+		$result = $mysqli->query($req);
710
+		$data = $result->fetch_object();
711 711
 		$coordinates = $data;
712 712
 		
713 713
 		header('Content-Type: application/json');
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
 
719 719
 	case 'pokemon_graph_data':
720
-		$json="";
720
+		$json = "";
721 721
 		if (isset($_GET['pokemon_id'])) {
722 722
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
723 723
 			$req = "SELECT COUNT(*) AS total,
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 					FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered
726 726
 					GROUP BY disappear_hour
727 727
 					ORDER BY disappear_hour";
728
-			$result	= $mysqli->query($req);
728
+			$result = $mysqli->query($req);
729 729
 			$array = array_fill(0, 24, 0);
730 730
 			while ($result && $data = $result->fetch_object()) {
731 731
 				$array[$data->disappear_hour] = $data->total;
@@ -751,30 +751,30 @@  discard block
 block discarded – undo
751 751
 	break;
752 752
 }
753 753
 
754
-if ($postRequest!="") {
754
+if ($postRequest != "") {
755 755
 	switch ($postRequest) {
756 756
 		case 'pokemon_live':
757
-			$json="";
758
-			if (isset( $_POST['pokemon_id'])) {
757
+			$json = "";
758
+			if (isset($_POST['pokemon_id'])) {
759 759
 				$pokemon_id = mysqli_real_escape_string($mysqli, $_POST['pokemon_id']);
760
-				$inmap_pkms_filter="";
760
+				$inmap_pkms_filter = "";
761 761
 				$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id;
762 762
 
763 763
 				$reqTestIv = "SELECT MAX(individual_attack) AS iv FROM pokemon ".$where;
764
-				$resultTestIv 	= $mysqli->query($reqTestIv);
764
+				$resultTestIv = $mysqli->query($reqTestIv);
765 765
 				$testIv = $resultTestIv->fetch_object();
766
-				if (isset( $_POST['inmap_pokemons'])&&( $_POST['inmap_pokemons']!="")) {
766
+				if (isset($_POST['inmap_pokemons']) && ($_POST['inmap_pokemons'] != "")) {
767 767
 					foreach ($_POST['inmap_pokemons'] as $inmap) {
768 768
 						$inmap_pkms_filter .= "'".$inmap."',";
769 769
 					}
770 770
 					$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
771 771
 					$where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") ";
772 772
 				}
773
-				if ($testIv->iv!=null && isset( $_POST['ivMin'])&&( $_POST['ivMin']!="")) {
773
+				if ($testIv->iv != null && isset($_POST['ivMin']) && ($_POST['ivMin'] != "")) {
774 774
 					$ivMin = mysqli_real_escape_string($mysqli, $_POST['ivMin']);
775 775
 					$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") ";
776 776
 				}
777
-				if ($testIv->iv!=null && isset( $_POST['ivMax'])&&( $_POST['ivMax']!="")) {
777
+				if ($testIv->iv != null && isset($_POST['ivMax']) && ($_POST['ivMax'] != "")) {
778 778
 					$ivMax = mysqli_real_escape_string($mysqli, $_POST['ivMax']);
779 779
 					$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(".$ivMax.") ";
780 780
 				}
@@ -788,12 +788,12 @@  discard block
 block discarded – undo
788 788
 				$json = array();
789 789
 				$json['points'] = array();
790 790
 				$locale = array();
791
-				$locale["ivAttack"] =  $locales->IV_ATTACK;
791
+				$locale["ivAttack"] = $locales->IV_ATTACK;
792 792
 				$locale["ivDefense"] = $locales->IV_DEFENSE;
793
-				$locale["ivStamina"] =  $locales->IV_STAMINA;
793
+				$locale["ivStamina"] = $locales->IV_STAMINA;
794 794
 				$json['locale'] = $locale;
795 795
 				while ($result && $data = $result->fetch_object()) {
796
-					$pokeid=$data->pokemon_id;
796
+					$pokeid = $data->pokemon_id;
797 797
 					$data->name = $pokemons->pokemon->$pokeid->name;
798 798
 					if (isset($data->move_1)) {
799 799
 						$move1 = $data->move_1;
@@ -807,7 +807,7 @@  discard block
 block discarded – undo
807 807
 					} else {
808 808
 						$data->charge_move = "?";
809 809
 					}
810
-					$json['points'][] 	= $data;
810
+					$json['points'][] = $data;
811 811
 				}
812 812
 
813 813
 				$json = json_encode($json);
Please login to merge, or discard this patch.