Failed Conditions
Pull Request — master (#248)
by
unknown
08:43
created
core/process/aru.php 1 patch
Spacing   +120 added lines, -120 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 46
 if (isset($_GET['type'])) {
47
-$request 	= $_GET['type'];
47
+$request = $_GET['type'];
48 48
 }
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;
@@ -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()) {
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 							$html .= '
205 205
 							<div class="progress" style="height: 15px; margin-bottom: 0">
206 206
 								<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";>
207
-									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .'
207
+									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack.'
208 208
 								</div>
209 209
 								<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";>
210
-									<span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense .'
210
+									<span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense.'
211 211
 								</div>
212 212
 								<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";>
213
-									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .'
213
+									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina.'
214 214
 								</div>
215 215
 							</div>';
216 216
 						} else {
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 					    		<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).'%">
220 220
 									<span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>
221 221
 					    		</div>
222
-					    		<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).'%">
222
+					    		<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).'%">
223 223
 									<span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>
224 224
 					    		</div>
225
-					    		<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).'%">
225
+					    		<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).'%">
226 226
 									<span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>
227 227
 					    		</div>
228 228
 							</div>';
@@ -280,9 +280,9 @@  discard block
 block discarded – undo
280 280
 		} else {
281 281
 			$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()";
282 282
 		}
283
-		$result 	= $mysqli->query($req);
283
+		$result = $mysqli->query($req);
284 284
 
285
-		$i=0;
285
+		$i = 0;
286 286
 
287 287
 		while ($data = $result->fetch_object()) {
288 288
 			if ($data->lure_expiration >= $data->now) {
@@ -320,19 +320,19 @@  discard block
 block discarded – undo
320 320
 	####################################
321 321
 
322 322
 	case 'update_gym':
323
-		$teams			= new stdClass();
324
-		$teams->mystic 		= 1;
325
-		$teams->valor 		= 2;
326
-		$teams->instinct 	= 3;
323
+		$teams = new stdClass();
324
+		$teams->mystic = 1;
325
+		$teams->valor = 2;
326
+		$teams->instinct = 3;
327 327
 
328 328
 
329 329
 		foreach ($teams as $team_name => $team_id) {
330
-			$req	= "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."'  ";
331
-			$result	= $mysqli->query($req);
332
-			$data	= $result->fetch_object();
330
+			$req = "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."'  ";
331
+			$result = $mysqli->query($req);
332
+			$data = $result->fetch_object();
333 333
 
334
-			$return[] 	= $data->total;
335
-			$return[]	= $data->average_points;
334
+			$return[] = $data->total;
335
+			$return[] = $data->average_points;
336 336
 		}
337 337
 
338 338
 		$json = json_encode($return);
@@ -351,11 +351,11 @@  discard block
 block discarded – undo
351 351
 
352 352
 
353 353
 	case 'gym_map':
354
-		$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";
355
-		$result 	= $mysqli->query($req);
354
+		$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";
355
+		$result = $mysqli->query($req);
356 356
 
357 357
 
358
-		$i=0;
358
+		$i = 0;
359 359
 
360 360
 		while ($data = $result->fetch_object()) {
361 361
 			// Team
@@ -367,50 +367,50 @@  discard block
 block discarded – undo
367 367
 				case 0:
368 368
 					$icon	= 'map_white.png';
369 369
 					$team	= 'No Team (yet)';
370
-					$color	= 'rgba(0, 0, 0, .6)';
370
+					$color = 'rgba(0, 0, 0, .6)';
371 371
 					break;
372 372
 
373 373
 				case 1:
374 374
 					$icon	= 'map_blue_';
375 375
 					$team	= 'Team Mystic';
376
-					$color	= 'rgba(74, 138, 202, .6)';
376
+					$color = 'rgba(74, 138, 202, .6)';
377 377
 					break;
378 378
 
379 379
 				case 2:
380 380
 					$icon	= 'map_red_';
381 381
 					$team	= 'Team Valor';
382
-					$color	= 'rgba(240, 68, 58, .6)';
382
+					$color = 'rgba(240, 68, 58, .6)';
383 383
 					break;
384 384
 
385 385
 				case 3:
386 386
 					$icon	= 'map_yellow_';
387 387
 					$team	= 'Team Instinct';
388
-					$color	= 'rgba(254, 217, 40, .6)';
388
+					$color = 'rgba(254, 217, 40, .6)';
389 389
 					break;
390 390
 			}
391 391
 
392 392
 			// Set gym level
393
-			$data->gym_level=0;
393
+			$data->gym_level = 0;
394 394
 			if ($data->gym_points < 2000) {
395
-				$data->gym_level=1;
395
+				$data->gym_level = 1;
396 396
 			} elseif ($data->gym_points < 4000) {
397
-				$data->gym_level=2;
397
+				$data->gym_level = 2;
398 398
 			} elseif ($data->gym_points < 8000) {
399
-				$data->gym_level=3;
399
+				$data->gym_level = 3;
400 400
 			} elseif ($data->gym_points < 12000) {
401
-				$data->gym_level=4;
401
+				$data->gym_level = 4;
402 402
 			} elseif ($data->gym_points < 16000) {
403
-				$data->gym_level=5;
403
+				$data->gym_level = 5;
404 404
 			} elseif ($data->gym_points < 20000) {
405
-				$data->gym_level=6;
405
+				$data->gym_level = 6;
406 406
 			} elseif ($data->gym_points < 30000) {
407
-				$data->gym_level=7;
407
+				$data->gym_level = 7;
408 408
 			} elseif ($data->gym_points < 40000) {
409
-				$data->gym_level=8;
409
+				$data->gym_level = 8;
410 410
 			} elseif ($data->gym_points < 50000) {
411
-				$data->gym_level=9;
411
+				$data->gym_level = 9;
412 412
 			} else {
413
-				$data->gym_level=10;
413
+				$data->gym_level = 10;
414 414
 			}
415 415
 
416 416
 			## I know, I revert commit 6e8d2e7 from @kiralydavid but the way it was done broke the page.
@@ -461,8 +461,8 @@  discard block
 block discarded – undo
461 461
 
462 462
 	case 'gym_defenders':
463 463
 		$gym_id = $mysqli->real_escape_string($_GET['gym_id']);
464
-		$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."'";
465
-		$result 	= $mysqli->query($req);
464
+		$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."'";
465
+		$result = $mysqli->query($req);
466 466
 		$gymData['gymDetails']['gymInfos'] = false;
467 467
 		while ($data = $result->fetch_object()) {
468 468
 			$gymData['gymDetails']['gymInfos']['name'] = $data->name;
@@ -478,35 +478,35 @@  discard block
 block discarded – undo
478 478
 			$gymData['gymDetails']['gymInfos']['team'] = $data->team;
479 479
 			$gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id;
480 480
 			if ($data->points < 2000) {
481
-				$gymData['gymDetails']['gymInfos']['level']=1;
481
+				$gymData['gymDetails']['gymInfos']['level'] = 1;
482 482
 			} elseif ($data->points < 4000) {
483
-				$gymData['gymDetails']['gymInfos']['level']=2;
483
+				$gymData['gymDetails']['gymInfos']['level'] = 2;
484 484
 			} elseif ($data->points < 8000) {
485
-				$gymData['gymDetails']['gymInfos']['level']=3;
485
+				$gymData['gymDetails']['gymInfos']['level'] = 3;
486 486
 			} elseif ($data->points < 12000) {
487
-				$gymData['gymDetails']['gymInfos']['level']=4;
487
+				$gymData['gymDetails']['gymInfos']['level'] = 4;
488 488
 			} elseif ($data->points < 16000) {
489
-				$gymData['gymDetails']['gymInfos']['level']=5;
489
+				$gymData['gymDetails']['gymInfos']['level'] = 5;
490 490
 			} elseif ($data->points < 20000) {
491
-				$gymData['gymDetails']['gymInfos']['level']=6;
491
+				$gymData['gymDetails']['gymInfos']['level'] = 6;
492 492
 			} elseif ($data->points < 30000) {
493
-				$gymData['gymDetails']['gymInfos']['level']=7;
493
+				$gymData['gymDetails']['gymInfos']['level'] = 7;
494 494
 			} elseif ($data->points < 40000) {
495
-				$gymData['gymDetails']['gymInfos']['level']=8;
495
+				$gymData['gymDetails']['gymInfos']['level'] = 8;
496 496
 			} elseif ($data->points < 50000) {
497
-				$gymData['gymDetails']['gymInfos']['level']=9;
497
+				$gymData['gymDetails']['gymInfos']['level'] = 9;
498 498
 			} else {
499
-				$gymData['gymDetails']['gymInfos']['level']=10;
499
+				$gymData['gymDetails']['gymInfos']['level'] = 10;
500 500
 			}
501 501
 		}
502 502
 		//print_r($gymData);
503
-		$req 		= "SELECT DISTINCT gympokemon.pokemon_uid, "
503
+		$req = "SELECT DISTINCT gympokemon.pokemon_uid, "
504 504
 				. "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id "
505 505
 				. "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid "
506 506
 				. "GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id"
507 507
 				. " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC";
508
-		$result 	= $mysqli->query($req);
509
-		$i=0;
508
+		$result = $mysqli->query($req);
509
+		$i = 0;
510 510
 
511 511
 
512 512
 
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
 								<span class="sr-only">'.$locales->IV_ATTACK.' : '.$data->iv_attack.'</span>'.$data->iv_attack.'
529 529
 								</div>
530 530
 								<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">
531
-									<span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'. $data->iv_defense .'
531
+									<span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'.$data->iv_defense.'
532 532
 								</div>
533 533
 								<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">
534
-									<span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'. $data->iv_stamina .'
534
+									<span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'.$data->iv_stamina.'
535 535
 								</div>
536 536
 							</div>
537 537
 						</div>';
@@ -579,16 +579,16 @@  discard block
 block discarded – undo
579 579
 		$name = "";
580 580
 		$page = "0";
581 581
 		$where = "";
582
-		$order="";
583
-		$team=0;
584
-		$ranking=0;
582
+		$order = "";
583
+		$team = 0;
584
+		$ranking = 0;
585 585
 		if (isset($_GET['name'])) {
586 586
 			$trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']);
587 587
 			$where = " HAVING name LIKE '%".$trainer_name."%'";
588 588
 		}
589
-		if (isset($_GET['team']) && $_GET['team']!=0) {
589
+		if (isset($_GET['team']) && $_GET['team'] != 0) {
590 590
 			$team = mysqli_real_escape_string($mysqli, $_GET['team']);
591
-			$where .= ($where==""?" HAVING":"AND ")." team = ".$team;
591
+			$where .= ($where == "" ? " HAVING" : "AND ")." team = ".$team;
592 592
 		}
593 593
 		if (isset($_GET['page'])) {
594 594
 			$page = mysqli_real_escape_string($mysqli, $_GET['page']);
@@ -599,16 +599,16 @@  discard block
 block discarded – undo
599 599
 
600 600
 		switch ($ranking) {
601 601
 			case 1:
602
-				$order=" ORDER BY active DESC ";
602
+				$order = " ORDER BY active DESC ";
603 603
 				break;
604 604
 			case 2:
605
-				$order=" ORDER BY maxCp DESC ";
605
+				$order = " ORDER BY maxCp DESC ";
606 606
 				break;
607 607
 			default:
608
-				$order=" ORDER BY level DESC, active DESC ";
608
+				$order = " ORDER BY level DESC, active DESC ";
609 609
 		}
610 610
 
611
-		$limit = " LIMIT ".($page*10).",10 ";
611
+		$limit = " LIMIT ".($page * 10).",10 ";
612 612
 
613 613
 
614 614
 		$req = "SELECT trainer.*, count(actives_pokemons.trainer_name) as active, max(actives_pokemons.cp) as maxCp ".
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 			$reqRanking = "SELECT count(1) as rank FROM trainer where trainer.level >= ".$trainer->level;
628 628
 			$resultRanking = $mysqli->query($reqRanking);
629 629
 			while ($data = $resultRanking->fetch_object()) {
630
-				$trainer->rank = $data->rank ;
630
+				$trainer->rank = $data->rank;
631 631
 			}
632 632
 			$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, TRUNCATE(gympokemon.cp_multiplier,6) as cp_multiplier, gympokemon.num_upgrades, filtered_gymmember.gym_id, '1' as active ".
633 633
 				"FROM gympokemon INNER JOIN ".
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 
638 638
 			$resultPkms = $mysqli->query($req);
639 639
 			$trainer->pokemons = array();
640
-			$active_gyms=0;
640
+			$active_gyms = 0;
641 641
 			$pkmCount = 0;
642 642
 			while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) {
643 643
 				$active_gyms++;
@@ -674,9 +674,9 @@  discard block
 block discarded – undo
674 674
 		break;
675 675
 
676 676
 	case 'pokemon_slider_init':
677
-		$req 		= "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon";
677
+		$req = "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon";
678 678
 		$result 	= $mysqli->query($req);
679
-		$data 		= $result->fetch_object();
679
+		$data = $result->fetch_object();
680 680
 		$bounds 	= $data;
681 681
 
682 682
 		header('Content-Type: application/json');
@@ -686,18 +686,18 @@  discard block
 block discarded – undo
686 686
 		break;
687 687
 
688 688
 	case 'pokemon_heatmap_points':
689
-		$json="";
690
-		if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) {
691
-			$start = Date("Y-m-d H:i",(int)$_GET['start']);
692
-			$end = Date("Y-m-d H:i",(int)$_GET['end']);
689
+		$json = "";
690
+		if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) {
691
+			$start = Date("Y-m-d H:i", (int) $_GET['start']);
692
+			$end = Date("Y-m-d H:i", (int) $_GET['end']);
693 693
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
694 694
 			$where = " WHERE pokemon.pokemon_id = ".$pokemon_id." "
695 695
 					. "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'";
696 696
 			$req 		= "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000";
697
-			$result 	= $mysqli->query($req);
697
+			$result = $mysqli->query($req);
698 698
 			$points = array();
699 699
 			while ($result && $data = $result->fetch_object()) {
700
-				$points[] 	= $data;
700
+				$points[] = $data;
701 701
 			}
702 702
 
703 703
 			$json = json_encode($points);
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 		break;
711 711
 
712 712
 	case 'pokedex':
713
-		$json="";
713
+		$json = "";
714 714
 		if (isset($_GET['pokemon_id'])) {
715 715
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
716 716
 			$where = " WHERE pokemon.pokemon_id = ".$pokemon_id;
@@ -731,15 +731,15 @@  discard block
 block discarded – undo
731 731
 		break;
732 732
 
733 733
 	case 'pokemon_graph_data':
734
-		$json="";
734
+		$json = "";
735 735
 		if (isset($_GET['pokemon_id'])) {
736 736
 			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']);
737
-			$req 		= "SELECT COUNT(*) as total, "
737
+			$req = "SELECT COUNT(*) as total, "
738 738
 					. "HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_hour
739 739
 			FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' LIMIT 10000) as pokemonFiltered
740 740
 			GROUP BY disappear_hour
741 741
 			ORDER BY disappear_hour";
742
-			$result 	= $mysqli->query($req);
742
+			$result = $mysqli->query($req);
743 743
 			$array = array_fill(0, 24, 0);
744 744
 			while ($result && $data = $result->fetch_object()) {
745 745
 				$array[$data->disappear_hour] = $data->total;
@@ -766,30 +766,30 @@  discard block
 block discarded – undo
766 766
 
767 767
 	break;
768 768
 }
769
-if ($postRequest!="") {
769
+if ($postRequest != "") {
770 770
 	switch ($postRequest) {
771 771
 		case 'pokemon_live':
772
-			$json="";
773
-			if (isset( $_POST['pokemon_id'])) {
772
+			$json = "";
773
+			if (isset($_POST['pokemon_id'])) {
774 774
 				$pokemon_id = mysqli_real_escape_string($mysqli, $_POST['pokemon_id']);
775
-				$inmap_pkms_filter="";
775
+				$inmap_pkms_filter = "";
776 776
 				$where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon.pokemon_id = ".$pokemon_id;
777 777
 
778 778
 				$reqTestIv = "SELECT MAX(individual_attack) as iv FROM pokemon ".$where;
779
-				$resultTestIv 	= $mysqli->query($reqTestIv);
779
+				$resultTestIv = $mysqli->query($reqTestIv);
780 780
 				$testIv = $resultTestIv->fetch_object();
781
-				if (isset( $_POST['inmap_pokemons'])&&( $_POST['inmap_pokemons']!="")) {
781
+				if (isset($_POST['inmap_pokemons']) && ($_POST['inmap_pokemons'] != "")) {
782 782
 					foreach ($_POST['inmap_pokemons'] as $inmap) {
783 783
 						$inmap_pkms_filter .= "'".$inmap."',";
784 784
 					}
785 785
 					$inmap_pkms_filter = rtrim($inmap_pkms_filter, ",");
786 786
 					$where .= " AND pokemon.encounter_id NOT IN (".$inmap_pkms_filter.") ";
787 787
 				}
788
-				if ($testIv->iv!=null && isset( $_POST['ivMin'])&&( $_POST['ivMin']!="")) {
788
+				if ($testIv->iv != null && isset($_POST['ivMin']) && ($_POST['ivMin'] != "")) {
789 789
 					$ivMin = mysqli_real_escape_string($mysqli, $_POST['ivMin']);
790 790
 					$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") ";
791 791
 				}
792
-				if ($testIv->iv!=null && isset( $_POST['ivMax'])&&( $_POST['ivMax']!="")) {
792
+				if ($testIv->iv != null && isset($_POST['ivMax']) && ($_POST['ivMax'] != "")) {
793 793
 					$ivMax = mysqli_real_escape_string($mysqli, $_POST['ivMax']);
794 794
 					$where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(".$ivMax.") ";
795 795
 				}
@@ -797,19 +797,19 @@  discard block
 block discarded – undo
797 797
 						. " (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, "
798 798
 						. " individual_attack, individual_defense, individual_stamina, move_1, move_2 "
799 799
 						. "FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 5000";
800
-				$result 	= $mysqli->query($req);
800
+				$result = $mysqli->query($req);
801 801
 				$json = array();
802 802
 				$json['points'] = array();
803 803
 				$locale = array();
804
-				$locale["ivAttack"] =  $locales->IV_ATTACK;
804
+				$locale["ivAttack"] = $locales->IV_ATTACK;
805 805
 				$locale["ivDefense"] = $locales->IV_DEFENSE;
806
-				$locale["ivStamina"] =  $locales->IV_STAMINA;
806
+				$locale["ivStamina"] = $locales->IV_STAMINA;
807 807
 				$json['locale'] = $locale;
808 808
 				while ($result && $data = $result->fetch_object()) {
809
-					$pokeid=$data->pokemon_id;
809
+					$pokeid = $data->pokemon_id;
810 810
 					$data->name = $pokemons->pokemon->$pokeid->name;
811
-					$move1=$data->move_1;
812
-					$move2=$data->move_2;
811
+					$move1 = $data->move_1;
812
+					$move2 = $data->move_2;
813 813
 					$data->quick_move = $move->$move1->name;
814 814
 					$data->charge_move = $move->$move2->name;
815 815
 					$json['points'][] 	= $data;
Please login to merge, or discard this patch.