Passed
Pull Request — master (#192)
by PoUpA
02:32
created
core/process/aru.php 1 patch
Spacing   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 $pos = !empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], getenv('HTTP_HOST'));
8 8
 
9
-if ($pos===false) {
9
+if ($pos === false) {
10 10
 	http_response_code(401);
11 11
 	die('Restricted access');
12 12
 }
@@ -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,19 +37,19 @@  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
 }
44 44
 $mysqli->set_charset('utf8');
45 45
 $request = "";
46
-if (isset($_GET['type'])){
47
-$request 	= $_GET['type'];
46
+if (isset($_GET['type'])) {
47
+$request = $_GET['type'];
48 48
 }
49 49
 $postRequest = "";
50
-if (isset($_POST['type'])){
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;
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
 			}
160 160
 
161 161
 			// get last mythic pokemon
162
-			$req		= "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon
162
+			$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon
163 163
                         WHERE pokemon_id IN (".implode(",", $mythic_pokemons).")
164 164
                         ORDER BY last_modified DESC LIMIT 0,12";
165 165
 		} else {
166 166
 			// get last pokemon
167
-			$req		= "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12";
167
+			$req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12";
168 168
 		}
169 169
 		$result = $mysqli->query($req);
170 170
 		while ($data = $result->fetch_object()) {
@@ -203,27 +203,27 @@  discard block
 block discarded – undo
203 203
 						if ($config->system->iv_numbers) {
204 204
 							$html .= '
205 205
 							<div class="progress" style="height: 15px; margin-bottom: 0">
206
-								<div title="Attack IV: '. $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";>
207
-									<span class="sr-only">Attack IV: '. $iv->attack .'</span>'. $iv->attack .'
206
+								<div title="Attack IV: '. $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";>
207
+									<span class="sr-only">Attack IV: '. $iv->attack.'</span>'.$iv->attack.'
208 208
 								</div>
209
-								<div title="Defense IV: '. $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";>
210
-									<span class="sr-only">Defense IV: '. $iv->defense .'</span>'. $iv->defense .'
209
+								<div title="Defense IV: '. $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";>
210
+									<span class="sr-only">Defense IV: '. $iv->defense.'</span>'.$iv->defense.'
211 211
 								</div>
212
-								<div title="Stamina IV: '. $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";>
213
-									<span class="sr-only">Stamina IV: '. $iv->stamina .'</span>'. $iv->stamina .'
212
+								<div title="Stamina IV: '. $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";>
213
+									<span class="sr-only">Stamina IV: '. $iv->stamina.'</span>'.$iv->stamina.'
214 214
 								</div>
215 215
 							</div>';
216 216
 						} else {
217 217
 							$html .= '
218 218
 							<div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto;">
219
-					    		<div title="Attack IV: '. $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 .'%">
220
-									<span class="sr-only">Attack IV: '. $iv->attack .'</span>
219
+					    		<div title="Attack IV: '. $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.'%">
220
+									<span class="sr-only">Attack IV: '. $iv->attack.'</span>
221 221
 					    		</div>
222
-					    		<div title="Defense IV: '. $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 .'%">
223
-									<span class="sr-only">Defense IV: '. $iv->defense .'</span>
222
+					    		<div title="Defense IV: '. $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.'%">
223
+									<span class="sr-only">Defense IV: '. $iv->defense.'</span>
224 224
 					    		</div>
225
-					    		<div title="Stamina IV: '. $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 .'%">
226
-									<span class="sr-only">Stamina IV: '. $iv->stamina .'</span>
225
+					    		<div title="Stamina IV: '. $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.'%">
226
+									<span class="sr-only">Stamina IV: '. $iv->stamina.'</span>
227 227
 					    		</div>
228 228
 							</div>';
229 229
 						}
@@ -231,13 +231,13 @@  discard block
 block discarded – undo
231 231
 						if ($config->system->iv_numbers) {
232 232
 							$html .= '
233 233
 							<div class="progress" style="height: 15px; margin-bottom: 0">
234
-								<div title="Attack IV: 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";>
234
+								<div title="Attack IV: 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";>
235 235
 									<span class="sr-only">Attack IV: not available</span>?
236 236
 								</div>
237
-								<div title="Defense IV: not available" 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";>
237
+								<div title="Defense IV: not available" 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";>
238 238
 									<span class="sr-only">Defense IV: not available</span>?
239 239
 								</div>
240
-								<div title="Stamina IV: not available" 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";>
240
+								<div title="Stamina IV: not available" 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";>
241 241
 									<span class="sr-only">Stamina IV: not available</span>?
242 242
 								</div>
243 243
 							</div>';
@@ -275,15 +275,15 @@  discard block
 block discarded – undo
275 275
 	####################################
276 276
 
277 277
 	case 'pokestop':
278
-		$req 		= "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() as now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) as lure_expiration_real FROM pokestop";
279
-		$result 	= $mysqli->query($req);
278
+		$req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() as now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) as lure_expiration_real FROM pokestop";
279
+		$result = $mysqli->query($req);
280 280
 
281
-		$i=0;
281
+		$i = 0;
282 282
 
283 283
 		while ($data = $result->fetch_object()) {
284 284
 			if ($data->lure_expiration >= $data->now) {
285 285
 				$icon = 'pokestap_lured.png';
286
-				$text = 'Lured expire @ '.date('H:i:s', strtotime($data->lure_expiration_real)) ;
286
+				$text = 'Lured expire @ '.date('H:i:s', strtotime($data->lure_expiration_real));
287 287
 			} else {
288 288
 				$icon = 'pokestap.png';
289 289
 				$text = 'Normal stop';
@@ -316,19 +316,19 @@  discard block
 block discarded – undo
316 316
 	####################################
317 317
 
318 318
 	case 'update_gym':
319
-		$teams			= new stdClass();
320
-		$teams->mystic 		= 1;
321
-		$teams->valor 		= 2;
322
-		$teams->instinct 	= 3;
319
+		$teams = new stdClass();
320
+		$teams->mystic = 1;
321
+		$teams->valor = 2;
322
+		$teams->instinct = 3;
323 323
 
324 324
 
325 325
 		foreach ($teams as $team_name => $team_id) {
326
-			$req	= "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."'  ";
327
-			$result	= $mysqli->query($req);
328
-			$data	= $result->fetch_object();
326
+			$req = "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."'  ";
327
+			$result = $mysqli->query($req);
328
+			$data = $result->fetch_object();
329 329
 
330
-			$return[] 	= $data->total;
331
-			$return[]	= $data->average_points;
330
+			$return[] = $data->total;
331
+			$return[] = $data->average_points;
332 332
 		}
333 333
 
334 334
 		$json = json_encode($return);
@@ -347,11 +347,11 @@  discard block
 block discarded – undo
347 347
 
348 348
 
349 349
 	case 'gym_map':
350
-		$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";
351
-		$result 	= $mysqli->query($req);
350
+		$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";
351
+		$result = $mysqli->query($req);
352 352
 
353 353
 
354
-		$i=0;
354
+		$i = 0;
355 355
 
356 356
 		while ($data = $result->fetch_object()) {
357 357
 			// Team
@@ -363,50 +363,50 @@  discard block
 block discarded – undo
363 363
 				case 0:
364 364
 					$icon	= 'map_white.png';
365 365
 					$team	= 'No Team (yet)';
366
-					$color	= 'rgba(0, 0, 0, .6)';
366
+					$color = 'rgba(0, 0, 0, .6)';
367 367
 					break;
368 368
 
369 369
 				case 1:
370 370
 					$icon	= 'map_blue_';
371 371
 					$team	= 'Team Mystic';
372
-					$color	= 'rgba(74, 138, 202, .6)';
372
+					$color = 'rgba(74, 138, 202, .6)';
373 373
 					break;
374 374
 
375 375
 				case 2:
376 376
 					$icon	= 'map_red_';
377 377
 					$team	= 'Team Valor';
378
-					$color	= 'rgba(240, 68, 58, .6)';
378
+					$color = 'rgba(240, 68, 58, .6)';
379 379
 					break;
380 380
 
381 381
 				case 3:
382 382
 					$icon	= 'map_yellow_';
383 383
 					$team	= 'Team Instinct';
384
-					$color	= 'rgba(254, 217, 40, .6)';
384
+					$color = 'rgba(254, 217, 40, .6)';
385 385
 					break;
386 386
 			}
387 387
 
388 388
 			// Set gym level
389
-			$data->gym_level=0;
389
+			$data->gym_level = 0;
390 390
 			if ($data->gym_points < 2000) {
391
-				$data->gym_level=1;
391
+				$data->gym_level = 1;
392 392
 			} elseif ($data->gym_points < 4000) {
393
-				$data->gym_level=2;
393
+				$data->gym_level = 2;
394 394
 			} elseif ($data->gym_points < 8000) {
395
-				$data->gym_level=3;
395
+				$data->gym_level = 3;
396 396
 			} elseif ($data->gym_points < 12000) {
397
-				$data->gym_level=4;
397
+				$data->gym_level = 4;
398 398
 			} elseif ($data->gym_points < 16000) {
399
-				$data->gym_level=5;
399
+				$data->gym_level = 5;
400 400
 			} elseif ($data->gym_points < 20000) {
401
-				$data->gym_level=6;
401
+				$data->gym_level = 6;
402 402
 			} elseif ($data->gym_points < 30000) {
403
-				$data->gym_level=7;
403
+				$data->gym_level = 7;
404 404
 			} elseif ($data->gym_points < 40000) {
405
-				$data->gym_level=8;
405
+				$data->gym_level = 8;
406 406
 			} elseif ($data->gym_points < 50000) {
407
-				$data->gym_level=9;
407
+				$data->gym_level = 9;
408 408
 			} else {
409
-				$data->gym_level=10;
409
+				$data->gym_level = 10;
410 410
 			}
411 411
 
412 412
 			## I know, I revert commit 6e8d2e7 from @kiralydavid but the way it was done broke the page.
@@ -457,8 +457,8 @@  discard block
 block discarded – undo
457 457
 
458 458
 	case 'gym_defenders':
459 459
 		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
460
-		$req 		= "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) as last_scanned, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'";
461
-		$result 	= $mysqli->query($req);
460
+		$req = "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) as last_scanned, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'";
461
+		$result = $mysqli->query($req);
462 462
 		$gymData['gymDetails']['gymInfos'] = false;
463 463
 		while ($data = $result->fetch_object()) {
464 464
 			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
@@ -474,35 +474,35 @@  discard block
 block discarded – undo
474 474
 			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
475 475
 			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
476 476
 			if ($data->points < 2000) {
477
-				$gymData['gymDetails']['gymInfos']['level']=1;
477
+				$gymData['gymDetails']['gymInfos']['level'] = 1;
478 478
 			} elseif ($data->points < 4000) {
479
-				$gymData['gymDetails']['gymInfos']['level']=2;
479
+				$gymData['gymDetails']['gymInfos']['level'] = 2;
480 480
 			} elseif ($data->points < 8000) {
481
-				$gymData['gymDetails']['gymInfos']['level']=3;
481
+				$gymData['gymDetails']['gymInfos']['level'] = 3;
482 482
 			} elseif ($data->points < 12000) {
483
-				$gymData['gymDetails']['gymInfos']['level']=4;
483
+				$gymData['gymDetails']['gymInfos']['level'] = 4;
484 484
 			} elseif ($data->points < 16000) {
485
-				$gymData['gymDetails']['gymInfos']['level']=5;
485
+				$gymData['gymDetails']['gymInfos']['level'] = 5;
486 486
 			} elseif ($data->points < 20000) {
487
-				$gymData['gymDetails']['gymInfos']['level']=6;
487
+				$gymData['gymDetails']['gymInfos']['level'] = 6;
488 488
 			} elseif ($data->points < 30000) {
489
-				$gymData['gymDetails']['gymInfos']['level']=7;
489
+				$gymData['gymDetails']['gymInfos']['level'] = 7;
490 490
 			} elseif ($data->points < 40000) {
491
-				$gymData['gymDetails']['gymInfos']['level']=8;
491
+				$gymData['gymDetails']['gymInfos']['level'] = 8;
492 492
 			} elseif ($data->points < 50000) {
493
-				$gymData['gymDetails']['gymInfos']['level']=9;
493
+				$gymData['gymDetails']['gymInfos']['level'] = 9;
494 494
 			} else {
495
-				$gymData['gymDetails']['gymInfos']['level']=10;
495
+				$gymData['gymDetails']['gymInfos']['level'] = 10;
496 496
 			}
497 497
 		}
498 498
 		//print_r($gymData);
499
-		$req 		= "SELECT DISTINCT gympokemon.pokemon_uid, "
499
+		$req = "SELECT DISTINCT gympokemon.pokemon_uid, "
500 500
 				. "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id "
501 501
 				. "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid "
502 502
 				. "GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id"
503 503
 				. " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC";
504
-		$result 	= $mysqli->query($req);
505
-		$i=0;
504
+		$result = $mysqli->query($req);
505
+		$i = 0;
506 506
 
507 507
 
508 508
 
@@ -520,14 +520,14 @@  discard block
 block discarded – undo
520 520
 						</a>
521 521
 						<p class="pkmn-name">'.$data->cp.'</p>
522 522
 						<div class="progress" style="height: 12px; margin-bottom: 0">
523
-							<div title="Attack IV: '. $data->iv_attack .'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'. $data->iv_attack .'" aria-valuemin="0" aria-valuemax="45" style="width: '. (100/3)  .'%; line-height: 13px; font-size: 11px">
524
-								<span class="sr-only">Angriff IV : '. $data->iv_attack .'</span>'.$data->iv_attack.'
523
+							<div title="Attack IV: '. $data->iv_attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$data->iv_attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 13px; font-size: 11px">
524
+								<span class="sr-only">Angriff IV : '. $data->iv_attack.'</span>'.$data->iv_attack.'
525 525
 								</div>
526
-								<div title="Defense IV: '. $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">
527
-									<span class="sr-only">Verteidigung IV : '. $data->iv_defense .'</span>'. $data->iv_defense .'
526
+								<div title="Defense IV: '. $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">
527
+									<span class="sr-only">Verteidigung IV : '. $data->iv_defense.'</span>'.$data->iv_defense.'
528 528
 								</div>
529
-								<div title="Stamina IV: '. $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">
530
-									<span class="sr-only">KP IV : '. $data->iv_stamina .'</span>'. $data->iv_stamina .'
529
+								<div title="Stamina IV: '. $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">
530
+									<span class="sr-only">KP IV : '. $data->iv_stamina.'</span>'.$data->iv_stamina.'
531 531
 								</div>
532 532
 							</div>
533 533
 						</div>';
@@ -540,13 +540,13 @@  discard block
 block discarded – undo
540 540
 						</a>
541 541
 						<p class="pkmn-name">'.$data->cp.'</p>
542 542
 						<div class="progress" style="height: 4px; width: 40px; margin-bottom: 10px; margin-top: 2px; margin-left: auto; margin-right: auto">
543
-							<div title="Attack IV: '.$data->iv_attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$data->iv_attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100/15)*$data->iv_attack)/3).'%">
543
+							<div title="Attack IV: '.$data->iv_attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$data->iv_attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $data->iv_attack) / 3).'%">
544 544
 								<span class="sr-only">Attack IV: '.$data->iv_attack.'</span>
545 545
 							</div>
546
-							<div title="Defense IV: '.$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/15)*$data->iv_defense)/3).'%">
546
+							<div title="Defense IV: '.$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 / 15) * $data->iv_defense) / 3).'%">
547 547
 								<span class="sr-only">Defense IV: '.$data->iv_defense.'</span>
548 548
 							</div>
549
-							<div title="Stamina IV: '.$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/15)*$data->iv_stamina)/3).'%">
549
+							<div title="Stamina IV: '.$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 / 15) * $data->iv_stamina) / 3).'%">
550 550
 								<span class="sr-only">Stamina IV: '.$data->iv_stamina.'</span>
551 551
 							</div>
552 552
 						</div>
@@ -576,16 +576,16 @@  discard block
 block discarded – undo
576 576
 		$name = "";
577 577
 		$page = "0";
578 578
 		$where = "";
579
-		$order="";
580
-		$team=0;
581
-		$ranking=0;
579
+		$order = "";
580
+		$team = 0;
581
+		$ranking = 0;
582 582
 		if (isset($_GET['name'])) {
583 583
 			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
584 584
 			$where = " HAVING name LIKE '%".$trainer_name."%'";
585 585
 		}
586
-		if (isset($_GET['team']) && $_GET['team']!=0) {
586
+		if (isset($_GET['team']) && $_GET['team'] != 0) {
587 587
 			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
588
-			$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
588
+			$where .= ($where == "" ? " HAVING" : "AND ")." team = ".$team;
589 589
 		}
590 590
 		if (isset($_GET['page'])) {
591 591
 			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
@@ -596,16 +596,16 @@  discard block
 block discarded – undo
596 596
 
597 597
 		switch ($ranking) {
598 598
 			case 1:
599
-				$order=" ORDER BY active DESC ";
599
+				$order = " ORDER BY active DESC ";
600 600
 				break;
601 601
 			case 2:
602
-				$order=" ORDER BY maxCp DESC ";
602
+				$order = " ORDER BY maxCp DESC ";
603 603
 				break;
604 604
 			default:
605
-				$order=" ORDER BY level DESC, active DESC ";
605
+				$order = " ORDER BY level DESC, active DESC ";
606 606
 		}
607 607
 
608
-		$limit = " LIMIT ".($page*10).",10 ";
608
+		$limit = " LIMIT ".($page * 10).",10 ";
609 609
 
610 610
 
611 611
 		$req = "SELECT trainer.*, count(actives_pokemons.trainer_name) as active, max(actives_pokemons.cp) as maxCp ".
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 			$reqRanking = "SELECT count(1) as rank FROM trainer where trainer.level >= ".$trainer->level;
625 625
 			$resultRanking = $mysqli->query($reqRanking);
626 626
 			while ($data = $resultRanking->fetch_object()) {
627
-				$trainer->rank = $data->rank ;
627
+				$trainer->rank = $data->rank;
628 628
 			}
629 629
 			$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 ".
630 630
 				"FROM gympokemon INNER JOIN ".
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 
635 635
 			$resultPkms = $mysqli->query($req);
636 636
 			$trainer->pokemons = array();
637
-			$active_gyms=0;
637
+			$active_gyms = 0;
638 638
 			$pkmCount = 0;
639 639
 			while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) {
640 640
 				$active_gyms++;
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 		break;
662 662
 
663 663
 	case 'pokemon_slider_init':
664
-		$req 		= "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon";
664
+		$req = "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon";
665 665
 		$result 	= $mysqli->query($req);
666
-		$data 		= $result->fetch_object();
666
+		$data = $result->fetch_object();
667 667
 		$bounds 	= $data;
668 668
 
669 669
 		header('Content-Type: application/json');
@@ -673,18 +673,18 @@  discard block
 block discarded – undo
673 673
 		break;
674 674
 
675 675
 	case 'pokemon_heatmap_points':
676
-		$json="";
677
-		if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
678
-			$start = Date("Y-m-d H:i",(int)$_GET['start']);
679
-			$end = Date("Y-m-d H:i",(int)$_GET['end']);
676
+		$json = "";
677
+		if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
678
+			$start = Date("Y-m-d H:i", (int) $_GET['start']);
679
+			$end = Date("Y-m-d H:i", (int) $_GET['end']);
680 680
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
681 681
 			$where = " WHERE pokemon.pokemon_id = ".$pokemon_id." "
682 682
 					. "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'";
683 683
 			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
684
-			$result 	= $mysqli->query($req);
684
+			$result = $mysqli->query($req);
685 685
 			$points = array();
686 686
 			while ($result && $data = $result->fetch_object()) {
687
-				$points[] 	= $data;
687
+				$points[] = $data;
688 688
 			}
689 689
 
690 690
 			$json = json_encode($points);
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 		break;
698 698
 
699 699
 	case 'pokedex':
700
-		$json="";
700
+		$json = "";
701 701
 		if (isset($_GET['pokemon_id'])) {
702 702
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
703 703
 			$where = " WHERE pokemon.pokemon_id = ".$pokemon_id;
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 		break;
722 722
 
723 723
 	case 'pokemon_graph_data':
724
-		$json="";
724
+		$json = "";
725 725
 		if (isset($_GET['pokemon_id'])) {
726 726
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
727 727
 			$where = " WHERE pokemonFiltered.pokemon_id = ".$pokemon_id;
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 			FROM (SELECT * FROM pokemon WHERE pokemon_id = '".$pokemon_id."' LIMIT 10000) as pokemonFiltered
731 731
 			GROUP BY disappear_hour
732 732
 			ORDER BY disappear_hour";
733
-			$result 	= $mysqli->query($req);
733
+			$result = $mysqli->query($req);
734 734
 			$array = array();
735 735
 			while ($result && $data = $result->fetch_object()) {
736 736
 				$array[] = $data->total;
@@ -755,30 +755,30 @@  discard block
 block discarded – undo
755 755
 
756 756
 	break;
757 757
 }
758
-if ($postRequest!=""){
758
+if ($postRequest != "") {
759 759
 	switch ($postRequest) {
760 760
 		case 'pokemon_live':
761
-			$json="";
762
-			if (isset( $_POST['pokemon_id'])) {
761
+			$json = "";
762
+			if (isset($_POST['pokemon_id'])) {
763 763
 				$pokemon_id = mysqli_real_escape_string($mysqli, $_POST['pokemon_id']);
764
-				$inmap_pkms_filter="";
764
+				$inmap_pkms_filter = "";
765 765
 				$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon.pokemon_id = ".$pokemon_id;
766 766
 
767 767
 				$reqTestIv = "SELECT MAX(individual_attack) as iv FROM pokemon ".$where;
768
-				$resultTestIv 	= $mysqli->query($reqTestIv);
768
+				$resultTestIv = $mysqli->query($reqTestIv);
769 769
 				$testIv = $resultTestIv->fetch_object();
770
-				if (isset( $_POST['inmap_pokemons'])&&( $_POST['inmap_pokemons']!="")) {
770
+				if (isset($_POST['inmap_pokemons']) && ($_POST['inmap_pokemons'] != "")) {
771 771
 					foreach ($_POST['inmap_pokemons'] as $inmap) {
772 772
 						$inmap_pkms_filter .= "'".$inmap."',";
773 773
 					}
774 774
 					$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
775 775
 					$where .= " AND pokemon.encounter_id NOT IN (".$inmap_pkms_filter.") ";
776 776
 				}
777
-				if ($testIv->iv!=null && isset( $_POST['ivMin'])&&( $_POST['ivMin']!="")) {
777
+				if ($testIv->iv != null && isset($_POST['ivMin']) && ($_POST['ivMin'] != "")) {
778 778
 					$ivMin = mysqli_real_escape_string($mysqli, $_POST['ivMin']);
779 779
 					$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") ";
780 780
 				}
781
-				if ($testIv->iv!=null && isset( $_POST['ivMax'])&&( $_POST['ivMax']!="")) {
781
+				if ($testIv->iv != null && isset($_POST['ivMax']) && ($_POST['ivMax'] != "")) {
782 782
 					$ivMax = mysqli_real_escape_string($mysqli, $_POST['ivMax']);
783 783
 					$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(".$ivMax.") ";
784 784
 				}
@@ -786,12 +786,12 @@  discard block
 block discarded – undo
786 786
 						. " (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, "
787 787
 						. " individual_attack, individual_defense, individual_stamina "
788 788
 						. "FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 5000";
789
-				$result 	= $mysqli->query($req);
789
+				$result = $mysqli->query($req);
790 790
 				$points = array();
791 791
 				while ($result && $data = $result->fetch_object()) {
792
-					$pokeid=$data->pokemon_id;
792
+					$pokeid = $data->pokemon_id;
793 793
 					$data->name = $pokemons->pokemon->$pokeid->name;
794
-					$points[] 	= $data;
794
+					$points[] = $data;
795 795
 				}
796 796
 
797 797
 				$json = json_encode($points);
Please login to merge, or discard this patch.