Passed
Push — master ( 47c073...e9d6ce )
by Markus
09:22
created
core/process/data.loader.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 // Include & load the variables
4 4
 // ############################
5 5
 
6
-$variables 	= SYS_PATH.'/core/json/variables.json';
7
-$config 	= json_decode(file_get_contents($variables));
6
+$variables = SYS_PATH.'/core/json/variables.json';
7
+$config = json_decode(file_get_contents($variables));
8 8
 
9 9
 if (!defined('SYS_PATH')) {
10 10
 	echo 'Error: config.php does not exist or failed to load.<br>';
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 #################
39 39
 
40 40
 
41
-$mysqli 	= new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
41
+$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
42 42
 
43 43
 
44 44
 if ($mysqli->connect_error != '') {
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
 // ( for Brusselopole we use CRONTAB but as we're not sure that every had access to it we build this really simple false crontab system
82 82
 // => check filemtime, if > 24h launch an update. )
83 83
 
84
-$pokedex_rarity_filetime	= filemtime($pokedex_rarity_file);
85
-$now				= time();
86
-$diff				= $now - $pokedex_rarity_filetime;
84
+$pokedex_rarity_filetime = filemtime($pokedex_rarity_file);
85
+$now = time();
86
+$diff = $now - $pokedex_rarity_filetime;
87 87
 
88 88
 // Update each 24h
89
-$update_delay		= 86400;
89
+$update_delay = 86400;
90 90
 
91 91
 if ($diff > $update_delay) {
92 92
 	include_once(SYS_PATH.'/core/cron/pokedex.rarity.php');
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			// Current Pokemon datas
117 117
 			// ---------------------
118 118
 
119
-			$pokemon_id 			= mysqli_real_escape_string($mysqli, $_GET['id']);
119
+			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['id']);
120 120
 
121 121
 			if (!is_object($pokemons->pokemon->$pokemon_id)) {
122 122
 				header('Location:/404');
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 
127 127
 			$pokemon			= new stdClass();
128 128
 			$pokemon			= $pokemons->pokemon->$pokemon_id;
129
-			$pokemon->id			= $pokemon_id;
129
+			$pokemon->id = $pokemon_id;
130 130
 
131 131
 
132 132
 			// Some math
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
 
143 143
 			// Total gym protected
144 144
 
145
-			$req 		= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'  ";
146
-			$result 	= $mysqli->query($req);
147
-			$data 		= $result->fetch_object();
145
+			$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'  ";
146
+			$result = $mysqli->query($req);
147
+			$data = $result->fetch_object();
148 148
 
149 149
 			$pokemon->protected_gyms = $data->total;
150 150
 
151 151
 			// Total spawn
152 152
 
153
-			$req 		= "SELECT COUNT(*) as total FROM pokemon WHERE pokemon_id = '".$pokemon_id."'";
154
-			$result 	= $mysqli->query($req);
155
-			$data 		= $result->fetch_object();
153
+			$req = "SELECT COUNT(*) as total FROM pokemon WHERE pokemon_id = '".$pokemon_id."'";
154
+			$result = $mysqli->query($req);
155
+			$data = $result->fetch_object();
156 156
 
157
-			$pokemon->total_spawn 	= $data->total;
157
+			$pokemon->total_spawn = $data->total;
158 158
 			// Spawn rate
159 159
 
160 160
 			if ($pokemon->total_spawn > 0) {
@@ -162,28 +162,28 @@  discard block
 block discarded – undo
162 162
 				$result = $mysqli->query($req);
163 163
 				$data = $result->fetch_object();
164 164
 				// Calc spawns_per_day for last week
165
-				$pokemon->spawns_per_day = round(($data->spawns_last_week/7), 2);
165
+				$pokemon->spawns_per_day = round(($data->spawns_last_week / 7), 2);
166 166
 			} else {
167 167
 				$pokemon->spawns_per_day = 0;
168 168
 			}
169 169
 
170 170
 			// Last seen
171 171
 
172
-			$req 		= "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude
172
+			$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude
173 173
 			FROM pokemon
174 174
 			WHERE pokemon_id = '".$pokemon_id."'
175 175
 			ORDER BY disappear_time DESC
176 176
 			LIMIT 0,1";
177
-			$result 	= $mysqli->query($req);
178
-			$data 		= $result->fetch_object();
177
+			$result = $mysqli->query($req);
178
+			$data = $result->fetch_object();
179 179
 
180 180
 			if (isset($data)) {
181
-				$last_spawn 				= $data;
181
+				$last_spawn = $data;
182 182
 
183
-				$pokemon->last_seen			= strtotime($data->disappear_time_real);
184
-				$pokemon->last_position			= new stdClass();
185
-				$pokemon->last_position->latitude 	= $data->latitude;
186
-				$pokemon->last_position->longitude 	= $data->longitude;
183
+				$pokemon->last_seen = strtotime($data->disappear_time_real);
184
+				$pokemon->last_position = new stdClass();
185
+				$pokemon->last_position->latitude = $data->latitude;
186
+				$pokemon->last_position->longitude = $data->longitude;
187 187
 			}
188 188
 
189 189
 			// Related Pokemons
@@ -271,23 +271,23 @@  discard block
 block discarded – undo
271 271
 			$total = $data->total;
272 272
 
273 273
 			$max 		= $config->system->max_pokemon;
274
-			$pokedex 	= new stdClass();
274
+			$pokedex = new stdClass();
275 275
 
276 276
 			$req 		= "SELECT DISTINCT pokemon_id FROM pokemon";
277
-			$result 	= $mysqli->query($req);
277
+			$result = $mysqli->query($req);
278 278
 			$data_array = array();
279 279
 
280 280
 			while ($data = $result->fetch_object()) {
281 281
 				$data_array[$data->pokemon_id] = 1;
282 282
 			};
283 283
 
284
-			for ($i= 1; $i <= $max; $i++) {
285
-				$pokedex->$i			= new stdClass();
284
+			for ($i = 1; $i <= $max; $i++) {
285
+				$pokedex->$i = new stdClass();
286 286
 				$pokedex->$i->id 		= $i;
287
-				$pokedex->$i->permalink 	= 'pokemon/'.$i;
287
+				$pokedex->$i->permalink = 'pokemon/'.$i;
288 288
 				$pokedex->$i->img		= 'core/pokemons/'.$i.$config->system->pokeimg_suffix;
289
-				$pokedex->$i->name		= $pokemons->pokemon->$i->name;
290
-				$pokedex->$i->spawn 		= isset($data_array[$i])? $data_array[$i] : 0;
289
+				$pokedex->$i->name = $pokemons->pokemon->$i->name;
290
+				$pokedex->$i->spawn = isset($data_array[$i]) ? $data_array[$i] : 0;
291 291
 			}
292 292
 
293 293
 
@@ -298,17 +298,17 @@  discard block
 block discarded – undo
298 298
 		############
299 299
 
300 300
 		case 'pokestops':
301
-			$pokestop 	= new stdClass();
301
+			$pokestop = new stdClass();
302 302
 
303
-			$req 		= "SELECT COUNT(*) as total FROM pokestop";
304
-			$result 	= $mysqli->query($req);
305
-			$data 		= $result->fetch_object();
303
+			$req = "SELECT COUNT(*) as total FROM pokestop";
304
+			$result = $mysqli->query($req);
305
+			$data = $result->fetch_object();
306 306
 
307 307
 			$pokestop->total = $data->total;
308 308
 
309
-			$req 		= "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
310
-			$result 	= $mysqli->query($req);
311
-			$data 		= $result->fetch_object();
309
+			$req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
310
+			$result = $mysqli->query($req);
311
+			$data = $result->fetch_object();
312 312
 
313 313
 			$pokestop->lured = $data->total;
314 314
 
@@ -325,36 +325,36 @@  discard block
 block discarded – undo
325 325
 			// 3 Teams (teamm rocket is neutral)
326 326
 			// 1 Fight
327 327
 
328
-			$teams 				= new stdClass();
328
+			$teams = new stdClass();
329 329
 
330
-			$teams->mystic 			= new stdClass();
331
-			$teams->mystic->guardians 	= new stdClass();
332
-			$teams->mystic->id 		= 1;
330
+			$teams->mystic = new stdClass();
331
+			$teams->mystic->guardians = new stdClass();
332
+			$teams->mystic->id = 1;
333 333
 
334
-			$teams->valor 			= new stdClass();
335
-			$teams->valor->guardians 	= new stdClass();
336
-			$teams->valor->id 		= 2;
334
+			$teams->valor = new stdClass();
335
+			$teams->valor->guardians = new stdClass();
336
+			$teams->valor->id = 2;
337 337
 
338
-			$teams->instinct 		= new stdClass();
339
-			$teams->instinct->guardians 	= new stdClass();
340
-			$teams->instinct->id 		= 3;
338
+			$teams->instinct = new stdClass();
339
+			$teams->instinct->guardians = new stdClass();
340
+			$teams->instinct->id = 3;
341 341
 
342
-			$teams->rocket 			= new stdClass();
343
-			$teams->rocket->guardians 	= new stdClass();
344
-			$teams->rocket->id 		= 0;
342
+			$teams->rocket = new stdClass();
343
+			$teams->rocket->guardians = new stdClass();
344
+			$teams->rocket->id = 0;
345 345
 
346 346
 
347 347
 
348 348
 			foreach ($teams as $team_key => $team_values) {
349 349
 				// Team Guardians
350 350
 
351
-				$req 	= "SELECT COUNT(*) as total, guard_pokemon_id FROM gym WHERE team_id = '".$team_values->id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3 ";
351
+				$req = "SELECT COUNT(*) as total, guard_pokemon_id FROM gym WHERE team_id = '".$team_values->id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3 ";
352 352
 				$result = $mysqli->query($req);
353 353
 
354
-				$i=0;
354
+				$i = 0;
355 355
 
356 356
 				while ($data = $result->fetch_object()) {
357
-					$teams->$team_key->guardians->$i	= $data->guard_pokemon_id;
357
+					$teams->$team_key->guardians->$i = $data->guard_pokemon_id;
358 358
 
359 359
 					$i++;
360 360
 				}
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 				$result = $mysqli->query($req);
367 367
 				$data	= $result->fetch_object();
368 368
 
369
-				$teams->$team_key->gym_owned	= $data->total;
370
-				$teams->$team_key->average	= $data->average_points;
369
+				$teams->$team_key->gym_owned = $data->total;
370
+				$teams->$team_key->average = $data->average_points;
371 371
 			}
372 372
 
373 373
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 		case 'dashboard':
381 381
 			// This case is only used for test purpose.
382 382
 
383
-			$stats_file	= SYS_PATH.'/core/json/gym.stats.json';
383
+			$stats_file = SYS_PATH.'/core/json/gym.stats.json';
384 384
 
385 385
 			if (!is_file($stats_file)) {
386 386
 				echo "Sorry, no Gym stats file was found. <br> Did you enable cron? ";
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 			}
389 389
 
390 390
 
391
-			$stats_file	= SYS_PATH.'/core/json/pokemon.stats.json';
391
+			$stats_file = SYS_PATH.'/core/json/pokemon.stats.json';
392 392
 
393 393
 			if (!is_file($stats_file)) {
394 394
 				echo "Sorry, no Pokémon stats file was found. <br> Did you enabled cron?";
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 			}
397 397
 
398 398
 
399
-			$stats_file	= SYS_PATH.'/core/json/pokestop.stats.json';
399
+			$stats_file = SYS_PATH.'/core/json/pokestop.stats.json';
400 400
 
401 401
 			if (!is_file($stats_file)) {
402 402
 				echo "Sorry, no Pokéstop stats file was found. <br> Did you enabled cron?";
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			}
405 405
 
406 406
 			if ($config->system->captcha_support) {
407
-				$stats_file	= SYS_PATH.'/core/json/captcha.stats.json';
407
+				$stats_file = SYS_PATH.'/core/json/captcha.stats.json';
408 408
 
409 409
 				if (!is_file($stats_file)) {
410 410
 					echo "Sorry, no Captcha stats file were found  <br> Have you enable cron?";
@@ -424,9 +424,9 @@  discard block
 block discarded – undo
424 424
 	// Right now
425 425
 	// ---------
426 426
 
427
-	$req 		= "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
428
-	$result 	= $mysqli->query($req);
429
-	$data 		= $result->fetch_object();
427
+	$req = "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
428
+	$result = $mysqli->query($req);
429
+	$data = $result->fetch_object();
430 430
 
431 431
 
432 432
 	$home->pokemon_now = $data->total;
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 	// Lured stops
436 436
 	// -----------
437 437
 
438
-	$req 		= "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
439
-	$result 	= $mysqli->query($req);
440
-	$data 		= $result->fetch_object();
438
+	$req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
439
+	$result = $mysqli->query($req);
440
+	$data = $result->fetch_object();
441 441
 
442 442
 	$home->pokestop_lured = $data->total;
443 443
 
@@ -445,9 +445,9 @@  discard block
 block discarded – undo
445 445
 	// Gyms
446 446
 	// ----
447 447
 
448
-	$req 		= "SELECT COUNT(DISTINCT(gym_id)) as total FROM gym";
449
-	$result 	= $mysqli->query($req);
450
-	$data 		= $result->fetch_object();
448
+	$req = "SELECT COUNT(DISTINCT(gym_id)) as total FROM gym";
449
+	$result = $mysqli->query($req);
450
+	$data = $result->fetch_object();
451 451
 
452 452
 	$home->gyms = $data->total;
453 453
 
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 
458 458
 	if ($config->system->recents_filter) {
459 459
 		// get all mythic pokemon ids
460
-		$mythic_pokemons  = array();
460
+		$mythic_pokemons = array();
461 461
 		foreach ($pokemons->pokemon as $id => $pokemon) {
462 462
 			if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) {
463 463
 				$mythic_pokemons[] = $id;
464 464
 			}
465 465
 		}
466 466
 		// get all mythic pokemon
467
-		$req 		= "SELECT DISTINCT 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
467
+		$req = "SELECT DISTINCT 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
468 468
 				   WHERE pokemon_id IN (".implode(",", $mythic_pokemons).")
469 469
 				   ORDER BY last_modified DESC LIMIT 0,12";
470 470
 	} else {
471 471
 		// get all pokemon
472
-		$req		= "SELECT DISTINCT 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
472
+		$req = "SELECT DISTINCT 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
473 473
 				   ORDER BY last_modified DESC LIMIT 0,12";
474 474
 	}
475 475
 	$result 	= $mysqli->query($req);
@@ -515,28 +515,28 @@  discard block
 block discarded – undo
515 515
 
516 516
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '1'  ";
517 517
 	$result = $mysqli->query($req);
518
-	$data 	= $result->fetch_object();
518
+	$data = $result->fetch_object();
519 519
 
520
-	$home->teams->mystic 	= $data->total;
520
+	$home->teams->mystic = $data->total;
521 521
 
522 522
 
523 523
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '2'  ";
524 524
 	$result = $mysqli->query($req);
525
-	$data 	= $result->fetch_object();
525
+	$data = $result->fetch_object();
526 526
 
527
-	$home->teams->valor 	= $data->total;
527
+	$home->teams->valor = $data->total;
528 528
 
529 529
 
530 530
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '3'  ";
531 531
 	$result = $mysqli->query($req);
532
-	$data 	= $result->fetch_object();
532
+	$data = $result->fetch_object();
533 533
 
534
-	$home->teams->instinct 	= $data->total;
534
+	$home->teams->instinct = $data->total;
535 535
 
536 536
 
537 537
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '0'  ";
538 538
 	$result = $mysqli->query($req);
539
-	$data 	= $result->fetch_object();
539
+	$data = $result->fetch_object();
540 540
 
541
-	$home->teams->rocket 	= $data->total;
541
+	$home->teams->rocket = $data->total;
542 542
 }
Please login to merge, or discard this patch.