Passed
Push — master ( f11ac2...8e3507 )
by Markus
02:37
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 (!isset($config->system)) {
10 10
 	echo 'Error: Could not load core/json/variables.json.<br>';
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 #################
34 34
 
35 35
 
36
-$mysqli 	= new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
36
+$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT);
37 37
 
38 38
 
39 39
 if ($mysqli->connect_error != '') {
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 // ( 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
77 77
 // => check filemtime, if > 24h launch an update. )
78 78
 
79
-$pokedex_rarity_filetime	= filemtime($pokedex_rarity_file);
80
-$now				= time();
81
-$diff				= $now - $pokedex_rarity_filetime;
79
+$pokedex_rarity_filetime = filemtime($pokedex_rarity_file);
80
+$now = time();
81
+$diff = $now - $pokedex_rarity_filetime;
82 82
 
83 83
 // Update each 24h
84
-$update_delay		= 86400;
84
+$update_delay = 86400;
85 85
 
86 86
 if ($diff > $update_delay) {
87 87
 	include_once(SYS_PATH.'/core/cron/pokedex.rarity.php');
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 			// Current Pokemon datas
112 112
 			// ---------------------
113 113
 
114
-			$pokemon_id 			= mysqli_real_escape_string($mysqli, $_GET['id']);
114
+			$pokemon_id = mysqli_real_escape_string($mysqli, $_GET['id']);
115 115
 
116 116
 			if (!is_object($pokemons->pokemon->$pokemon_id)) {
117 117
 				header('Location:/404');
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 			$pokemon			= new stdClass();
123 123
 			$pokemon			= $pokemons->pokemon->$pokemon_id;
124
-			$pokemon->id			= $pokemon_id;
124
+			$pokemon->id = $pokemon_id;
125 125
 
126 126
 
127 127
 			// Some math
@@ -137,19 +137,19 @@  discard block
 block discarded – undo
137 137
 
138 138
 			// Total gym protected
139 139
 
140
-			$req 		= "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'  ";
141
-			$result 	= $mysqli->query($req);
142
-			$data 		= $result->fetch_object();
140
+			$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'  ";
141
+			$result = $mysqli->query($req);
142
+			$data = $result->fetch_object();
143 143
 
144 144
 			$pokemon->protected_gyms = $data->total;
145 145
 
146 146
 			// Total spawn
147 147
 
148
-			$req 		= "SELECT COUNT(*) as total FROM pokemon WHERE pokemon_id = '".$pokemon_id."'";
149
-			$result 	= $mysqli->query($req);
150
-			$data 		= $result->fetch_object();
148
+			$req = "SELECT COUNT(*) as total FROM pokemon WHERE pokemon_id = '".$pokemon_id."'";
149
+			$result = $mysqli->query($req);
150
+			$data = $result->fetch_object();
151 151
 
152
-			$pokemon->total_spawn 	= $data->total;
152
+			$pokemon->total_spawn = $data->total;
153 153
 			// Spawn rate
154 154
 
155 155
 			if ($pokemon->total_spawn > 0) {
@@ -157,28 +157,28 @@  discard block
 block discarded – undo
157 157
 				$result = $mysqli->query($req);
158 158
 				$data = $result->fetch_object();
159 159
 				// Calc spawns_per_day for last week
160
-				$pokemon->spawns_per_day = round(($data->spawns_last_week/7), 2);
160
+				$pokemon->spawns_per_day = round(($data->spawns_last_week / 7), 2);
161 161
 			} else {
162 162
 				$pokemon->spawns_per_day = 0;
163 163
 			}
164 164
 
165 165
 			// Last seen
166 166
 
167
-			$req 		= "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude
167
+			$req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude
168 168
 			FROM pokemon
169 169
 			WHERE pokemon_id = '".$pokemon_id."'
170 170
 			ORDER BY disappear_time DESC
171 171
 			LIMIT 0,1";
172
-			$result 	= $mysqli->query($req);
173
-			$data 		= $result->fetch_object();
172
+			$result = $mysqli->query($req);
173
+			$data = $result->fetch_object();
174 174
 
175 175
 			if (isset($data)) {
176
-				$last_spawn 				= $data;
176
+				$last_spawn = $data;
177 177
 
178
-				$pokemon->last_seen			= strtotime($data->disappear_time_real);
179
-				$pokemon->last_position			= new stdClass();
180
-				$pokemon->last_position->latitude 	= $data->latitude;
181
-				$pokemon->last_position->longitude 	= $data->longitude;
178
+				$pokemon->last_seen = strtotime($data->disappear_time_real);
179
+				$pokemon->last_position = new stdClass();
180
+				$pokemon->last_position->latitude = $data->latitude;
181
+				$pokemon->last_position->longitude = $data->longitude;
182 182
 			}
183 183
 
184 184
 			// Related Pokemons
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
 			$total = $data->total;
221 221
 
222 222
 			$max 		= $config->system->max_pokemon;
223
-			$pokedex 	= new stdClass();
223
+			$pokedex = new stdClass();
224 224
 
225 225
 			$req 		= "SELECT DISTINCT pokemon_id FROM pokemon";
226
-			$result 	= $mysqli->query($req);
226
+			$result = $mysqli->query($req);
227 227
 			$data_array = array();
228 228
 
229 229
 			while ($data = $result->fetch_object()) {
230 230
 				$data_array[$data->pokemon_id] = 1;
231 231
 			};
232 232
 
233
-			for ($i= 1; $i <= $max; $i++) {
234
-				$pokedex->$i			= new stdClass();
233
+			for ($i = 1; $i <= $max; $i++) {
234
+				$pokedex->$i = new stdClass();
235 235
 				$pokedex->$i->id 		= $i;
236
-				$pokedex->$i->permalink 	= 'pokemon/'.$i;
236
+				$pokedex->$i->permalink = 'pokemon/'.$i;
237 237
 				$pokedex->$i->img		= 'core/pokemons/'.$i.$config->system->pokeimg_suffix;
238
-				$pokedex->$i->name		= $pokemons->pokemon->$i->name;
239
-				$pokedex->$i->spawn 		= isset($data_array[$i])? $data_array[$i] : 0;
238
+				$pokedex->$i->name = $pokemons->pokemon->$i->name;
239
+				$pokedex->$i->spawn = isset($data_array[$i]) ? $data_array[$i] : 0;
240 240
 			}
241 241
 
242 242
 
@@ -247,17 +247,17 @@  discard block
 block discarded – undo
247 247
 		############
248 248
 
249 249
 		case 'pokestops':
250
-			$pokestop 	= new stdClass();
250
+			$pokestop = new stdClass();
251 251
 
252
-			$req 		= "SELECT COUNT(*) as total FROM pokestop";
253
-			$result 	= $mysqli->query($req);
254
-			$data 		= $result->fetch_object();
252
+			$req = "SELECT COUNT(*) as total FROM pokestop";
253
+			$result = $mysqli->query($req);
254
+			$data = $result->fetch_object();
255 255
 
256 256
 			$pokestop->total = $data->total;
257 257
 
258
-			$req 		= "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
259
-			$result 	= $mysqli->query($req);
260
-			$data 		= $result->fetch_object();
258
+			$req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
259
+			$result = $mysqli->query($req);
260
+			$data = $result->fetch_object();
261 261
 
262 262
 			$pokestop->lured = $data->total;
263 263
 
@@ -274,36 +274,36 @@  discard block
 block discarded – undo
274 274
 			// 3 Teams (teamm rocket is neutral)
275 275
 			// 1 Fight
276 276
 
277
-			$teams 				= new stdClass();
277
+			$teams = new stdClass();
278 278
 
279
-			$teams->mystic 			= new stdClass();
280
-			$teams->mystic->guardians 	= new stdClass();
281
-			$teams->mystic->id 		= 1;
279
+			$teams->mystic = new stdClass();
280
+			$teams->mystic->guardians = new stdClass();
281
+			$teams->mystic->id = 1;
282 282
 
283
-			$teams->valor 			= new stdClass();
284
-			$teams->valor->guardians 	= new stdClass();
285
-			$teams->valor->id 		= 2;
283
+			$teams->valor = new stdClass();
284
+			$teams->valor->guardians = new stdClass();
285
+			$teams->valor->id = 2;
286 286
 
287
-			$teams->instinct 		= new stdClass();
288
-			$teams->instinct->guardians 	= new stdClass();
289
-			$teams->instinct->id 		= 3;
287
+			$teams->instinct = new stdClass();
288
+			$teams->instinct->guardians = new stdClass();
289
+			$teams->instinct->id = 3;
290 290
 
291
-			$teams->rocket 			= new stdClass();
292
-			$teams->rocket->guardians 	= new stdClass();
293
-			$teams->rocket->id 		= 0;
291
+			$teams->rocket = new stdClass();
292
+			$teams->rocket->guardians = new stdClass();
293
+			$teams->rocket->id = 0;
294 294
 
295 295
 
296 296
 
297 297
 			foreach ($teams as $team_key => $team_values) {
298 298
 				// Team Guardians
299 299
 
300
-				$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 ";
300
+				$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 ";
301 301
 				$result = $mysqli->query($req);
302 302
 
303
-				$i=0;
303
+				$i = 0;
304 304
 
305 305
 				while ($data = $result->fetch_object()) {
306
-					$teams->$team_key->guardians->$i	= $data->guard_pokemon_id;
306
+					$teams->$team_key->guardians->$i = $data->guard_pokemon_id;
307 307
 
308 308
 					$i++;
309 309
 				}
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
 				$result = $mysqli->query($req);
316 316
 				$data	= $result->fetch_object();
317 317
 
318
-				$teams->$team_key->gym_owned	= $data->total;
319
-				$teams->$team_key->average	= $data->average_points;
318
+				$teams->$team_key->gym_owned = $data->total;
319
+				$teams->$team_key->average = $data->average_points;
320 320
 			}
321 321
 
322 322
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		case 'dashboard':
330 330
 			// This case is only used for test purpose.
331 331
 
332
-			$stats_file	= SYS_PATH.'/core/json/gym.stats.json';
332
+			$stats_file = SYS_PATH.'/core/json/gym.stats.json';
333 333
 
334 334
 			if (!is_file($stats_file)) {
335 335
 				echo "Sorry, no Gym stats file was found. <br> Did you enable cron? ";
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 			}
338 338
 
339 339
 
340
-			$stats_file	= SYS_PATH.'/core/json/pokemon.stats.json';
340
+			$stats_file = SYS_PATH.'/core/json/pokemon.stats.json';
341 341
 
342 342
 			if (!is_file($stats_file)) {
343 343
 				echo "Sorry, no Pokémon stats file was found. <br> Did you enabled cron?";
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 			}
346 346
 
347 347
 
348
-			$stats_file	= SYS_PATH.'/core/json/pokestop.stats.json';
348
+			$stats_file = SYS_PATH.'/core/json/pokestop.stats.json';
349 349
 
350 350
 			if (!is_file($stats_file)) {
351 351
 				echo "Sorry, no Pokéstop stats file was found. <br> Did you enabled cron?";
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			}
354 354
 
355 355
 			if ($config->system->captcha_support) {
356
-				$stats_file	= SYS_PATH.'/core/json/captcha.stats.json';
356
+				$stats_file = SYS_PATH.'/core/json/captcha.stats.json';
357 357
 
358 358
 				if (!is_file($stats_file)) {
359 359
 					echo "Sorry, no Captcha stats file were found  <br> Have you enable cron?";
@@ -373,9 +373,9 @@  discard block
 block discarded – undo
373 373
 	// Right now
374 374
 	// ---------
375 375
 
376
-	$req 		= "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
377
-	$result 	= $mysqli->query($req);
378
-	$data 		= $result->fetch_object();
376
+	$req = "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()";
377
+	$result = $mysqli->query($req);
378
+	$data = $result->fetch_object();
379 379
 
380 380
 
381 381
 	$home->pokemon_now = $data->total;
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 	// Lured stops
385 385
 	// -----------
386 386
 
387
-	$req 		= "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
388
-	$result 	= $mysqli->query($req);
389
-	$data 		= $result->fetch_object();
387
+	$req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()";
388
+	$result = $mysqli->query($req);
389
+	$data = $result->fetch_object();
390 390
 
391 391
 	$home->pokestop_lured = $data->total;
392 392
 
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
 	// Gyms
395 395
 	// ----
396 396
 
397
-	$req 		= "SELECT COUNT(DISTINCT(gym_id)) as total FROM gym";
398
-	$result 	= $mysqli->query($req);
399
-	$data 		= $result->fetch_object();
397
+	$req = "SELECT COUNT(DISTINCT(gym_id)) as total FROM gym";
398
+	$result = $mysqli->query($req);
399
+	$data = $result->fetch_object();
400 400
 
401 401
 	$home->gyms = $data->total;
402 402
 
@@ -406,19 +406,19 @@  discard block
 block discarded – undo
406 406
 
407 407
 	if ($config->system->recents_filter) {
408 408
 		// get all mythic pokemon ids
409
-		$mythic_pokemons  = array();
409
+		$mythic_pokemons = array();
410 410
 		foreach ($pokemons->pokemon as $id => $pokemon) {
411 411
 			if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) {
412 412
 				$mythic_pokemons[] = $id;
413 413
 			}
414 414
 		}
415 415
 		// get all mythic pokemon
416
-		$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
416
+		$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
417 417
 				   WHERE pokemon_id IN (".implode(",", $mythic_pokemons).")
418 418
 				   ORDER BY last_modified DESC LIMIT 0,12";
419 419
 	} else {
420 420
 		// get all pokemon
421
-		$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
421
+		$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
422 422
 				   ORDER BY last_modified DESC LIMIT 0,12";
423 423
 	}
424 424
 	$result 	= $mysqli->query($req);
@@ -464,28 +464,28 @@  discard block
 block discarded – undo
464 464
 
465 465
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '1'  ";
466 466
 	$result = $mysqli->query($req);
467
-	$data 	= $result->fetch_object();
467
+	$data = $result->fetch_object();
468 468
 
469
-	$home->teams->mystic 	= $data->total;
469
+	$home->teams->mystic = $data->total;
470 470
 
471 471
 
472 472
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '2'  ";
473 473
 	$result = $mysqli->query($req);
474
-	$data 	= $result->fetch_object();
474
+	$data = $result->fetch_object();
475 475
 
476
-	$home->teams->valor 	= $data->total;
476
+	$home->teams->valor = $data->total;
477 477
 
478 478
 
479 479
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '3'  ";
480 480
 	$result = $mysqli->query($req);
481
-	$data 	= $result->fetch_object();
481
+	$data = $result->fetch_object();
482 482
 
483
-	$home->teams->instinct 	= $data->total;
483
+	$home->teams->instinct = $data->total;
484 484
 
485 485
 
486 486
 	$req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '0'  ";
487 487
 	$result = $mysqli->query($req);
488
-	$data 	= $result->fetch_object();
488
+	$data = $result->fetch_object();
489 489
 
490
-	$home->teams->rocket 	= $data->total;
490
+	$home->teams->rocket = $data->total;
491 491
 }
Please login to merge, or discard this patch.