@@ -3,8 +3,8 @@ discard block |
||
| 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.'; |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | ################# |
| 32 | 32 | |
| 33 | 33 | |
| 34 | -$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 34 | +$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | if ($mysqli->connect_error != '') { |
@@ -74,12 +74,12 @@ discard block |
||
| 74 | 74 | // ( 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 |
| 75 | 75 | // => check filemtime, if > 24h launch an update. ) |
| 76 | 76 | |
| 77 | -$pokedex_rarity_filetime = filemtime($pokedex_rarity_file); |
|
| 78 | -$now = time(); |
|
| 79 | -$diff = $now - $pokedex_rarity_filetime; |
|
| 77 | +$pokedex_rarity_filetime = filemtime($pokedex_rarity_file); |
|
| 78 | +$now = time(); |
|
| 79 | +$diff = $now - $pokedex_rarity_filetime; |
|
| 80 | 80 | |
| 81 | 81 | // Update each 24h |
| 82 | -$update_delay = 86400; |
|
| 82 | +$update_delay = 86400; |
|
| 83 | 83 | |
| 84 | 84 | if ($diff > $update_delay) { |
| 85 | 85 | include_once(SYS_PATH.'/core/cron/pokedex.rarity.php'); |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | // Current Pokemon datas |
| 110 | 110 | // --------------------- |
| 111 | 111 | |
| 112 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['id']); |
|
| 112 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['id']); |
|
| 113 | 113 | |
| 114 | 114 | if (!is_object($pokemons->pokemon->$pokemon_id)) { |
| 115 | 115 | header('Location:/404'); |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | $pokemon = new stdClass(); |
| 121 | 121 | $pokemon = $pokemons->pokemon->$pokemon_id; |
| 122 | - $pokemon->id = $pokemon_id; |
|
| 122 | + $pokemon->id = $pokemon_id; |
|
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | // Some math |
@@ -135,19 +135,19 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | // Total gym protected |
| 137 | 137 | |
| 138 | - $req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."' "; |
|
| 139 | - $result = $mysqli->query($req); |
|
| 140 | - $data = $result->fetch_object(); |
|
| 138 | + $req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."' "; |
|
| 139 | + $result = $mysqli->query($req); |
|
| 140 | + $data = $result->fetch_object(); |
|
| 141 | 141 | |
| 142 | 142 | $pokemon->protected_gyms = $data->total; |
| 143 | 143 | |
| 144 | 144 | // Total spawn |
| 145 | 145 | |
| 146 | - $req = "SELECT COUNT(*) as total FROM pokemon WHERE pokemon_id = '".$pokemon_id."'"; |
|
| 147 | - $result = $mysqli->query($req); |
|
| 148 | - $data = $result->fetch_object(); |
|
| 146 | + $req = "SELECT COUNT(*) as total FROM pokemon WHERE pokemon_id = '".$pokemon_id."'"; |
|
| 147 | + $result = $mysqli->query($req); |
|
| 148 | + $data = $result->fetch_object(); |
|
| 149 | 149 | |
| 150 | - $pokemon->total_spawn = $data->total; |
|
| 150 | + $pokemon->total_spawn = $data->total; |
|
| 151 | 151 | // Spawn rate |
| 152 | 152 | |
| 153 | 153 | if ($pokemon->total_spawn > 0) { |
@@ -155,28 +155,28 @@ discard block |
||
| 155 | 155 | $result = $mysqli->query($req); |
| 156 | 156 | $data = $result->fetch_object(); |
| 157 | 157 | // Calc spawns_per_day for last week |
| 158 | - $pokemon->spawns_per_day = round(($data->spawns_last_week/7), 2); |
|
| 158 | + $pokemon->spawns_per_day = round(($data->spawns_last_week / 7), 2); |
|
| 159 | 159 | } else { |
| 160 | 160 | $pokemon->spawns_per_day = 0; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // Last seen |
| 164 | 164 | |
| 165 | - $req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude |
|
| 165 | + $req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude |
|
| 166 | 166 | FROM pokemon |
| 167 | 167 | WHERE pokemon_id = '".$pokemon_id."' |
| 168 | 168 | ORDER BY disappear_time DESC |
| 169 | 169 | LIMIT 0,1"; |
| 170 | - $result = $mysqli->query($req); |
|
| 171 | - $data = $result->fetch_object(); |
|
| 170 | + $result = $mysqli->query($req); |
|
| 171 | + $data = $result->fetch_object(); |
|
| 172 | 172 | |
| 173 | 173 | if (isset($data)) { |
| 174 | - $last_spawn = $data; |
|
| 174 | + $last_spawn = $data; |
|
| 175 | 175 | |
| 176 | - $pokemon->last_seen = strtotime($data->disappear_time_real); |
|
| 177 | - $pokemon->last_position = new stdClass(); |
|
| 178 | - $pokemon->last_position->latitude = $data->latitude; |
|
| 179 | - $pokemon->last_position->longitude = $data->longitude; |
|
| 176 | + $pokemon->last_seen = strtotime($data->disappear_time_real); |
|
| 177 | + $pokemon->last_position = new stdClass(); |
|
| 178 | + $pokemon->last_position->latitude = $data->latitude; |
|
| 179 | + $pokemon->last_position->longitude = $data->longitude; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // Related Pokemons |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $toptrainer[] = $data; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - $moves_file = SYS_PATH.'/core/json/moves.json'; |
|
| 251 | + $moves_file = SYS_PATH.'/core/json/moves.json'; |
|
| 252 | 252 | |
| 253 | 253 | $moves = json_decode(file_get_contents($moves_file)); |
| 254 | 254 | |
@@ -276,23 +276,23 @@ discard block |
||
| 276 | 276 | $total = $data->total; |
| 277 | 277 | |
| 278 | 278 | $max = $config->system->max_pokemon; |
| 279 | - $pokedex = new stdClass(); |
|
| 279 | + $pokedex = new stdClass(); |
|
| 280 | 280 | |
| 281 | 281 | $req = "SELECT DISTINCT pokemon_id FROM pokemon"; |
| 282 | - $result = $mysqli->query($req); |
|
| 282 | + $result = $mysqli->query($req); |
|
| 283 | 283 | $data_array = array(); |
| 284 | 284 | |
| 285 | 285 | while ($data = $result->fetch_object()) { |
| 286 | 286 | $data_array[$data->pokemon_id] = 1; |
| 287 | 287 | }; |
| 288 | 288 | |
| 289 | - for ($i= 1; $i <= $max; $i++) { |
|
| 290 | - $pokedex->$i = new stdClass(); |
|
| 289 | + for ($i = 1; $i <= $max; $i++) { |
|
| 290 | + $pokedex->$i = new stdClass(); |
|
| 291 | 291 | $pokedex->$i->id = $i; |
| 292 | - $pokedex->$i->permalink = 'pokemon/'.$i; |
|
| 292 | + $pokedex->$i->permalink = 'pokemon/'.$i; |
|
| 293 | 293 | $pokedex->$i->img = 'core/pokemons/'.$i.$config->system->pokeimg_suffix; |
| 294 | - $pokedex->$i->name = $pokemons->pokemon->$i->name; |
|
| 295 | - $pokedex->$i->spawn = isset($data_array[$i])? $data_array[$i] : 0; |
|
| 294 | + $pokedex->$i->name = $pokemons->pokemon->$i->name; |
|
| 295 | + $pokedex->$i->spawn = isset($data_array[$i]) ? $data_array[$i] : 0; |
|
| 296 | 296 | } |
| 297 | 297 | |
| 298 | 298 | |
@@ -303,17 +303,17 @@ discard block |
||
| 303 | 303 | ############ |
| 304 | 304 | |
| 305 | 305 | case 'pokestops': |
| 306 | - $pokestop = new stdClass(); |
|
| 306 | + $pokestop = new stdClass(); |
|
| 307 | 307 | |
| 308 | - $req = "SELECT COUNT(*) as total FROM pokestop"; |
|
| 309 | - $result = $mysqli->query($req); |
|
| 310 | - $data = $result->fetch_object(); |
|
| 308 | + $req = "SELECT COUNT(*) as total FROM pokestop"; |
|
| 309 | + $result = $mysqli->query($req); |
|
| 310 | + $data = $result->fetch_object(); |
|
| 311 | 311 | |
| 312 | 312 | $pokestop->total = $data->total; |
| 313 | 313 | |
| 314 | - $req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 315 | - $result = $mysqli->query($req); |
|
| 316 | - $data = $result->fetch_object(); |
|
| 314 | + $req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 315 | + $result = $mysqli->query($req); |
|
| 316 | + $data = $result->fetch_object(); |
|
| 317 | 317 | |
| 318 | 318 | $pokestop->lured = $data->total; |
| 319 | 319 | |
@@ -330,36 +330,36 @@ discard block |
||
| 330 | 330 | // 3 Teams (teamm rocket is neutral) |
| 331 | 331 | // 1 Fight |
| 332 | 332 | |
| 333 | - $teams = new stdClass(); |
|
| 333 | + $teams = new stdClass(); |
|
| 334 | 334 | |
| 335 | - $teams->mystic = new stdClass(); |
|
| 336 | - $teams->mystic->guardians = new stdClass(); |
|
| 337 | - $teams->mystic->id = 1; |
|
| 335 | + $teams->mystic = new stdClass(); |
|
| 336 | + $teams->mystic->guardians = new stdClass(); |
|
| 337 | + $teams->mystic->id = 1; |
|
| 338 | 338 | |
| 339 | - $teams->valor = new stdClass(); |
|
| 340 | - $teams->valor->guardians = new stdClass(); |
|
| 341 | - $teams->valor->id = 2; |
|
| 339 | + $teams->valor = new stdClass(); |
|
| 340 | + $teams->valor->guardians = new stdClass(); |
|
| 341 | + $teams->valor->id = 2; |
|
| 342 | 342 | |
| 343 | - $teams->instinct = new stdClass(); |
|
| 344 | - $teams->instinct->guardians = new stdClass(); |
|
| 345 | - $teams->instinct->id = 3; |
|
| 343 | + $teams->instinct = new stdClass(); |
|
| 344 | + $teams->instinct->guardians = new stdClass(); |
|
| 345 | + $teams->instinct->id = 3; |
|
| 346 | 346 | |
| 347 | - $teams->rocket = new stdClass(); |
|
| 348 | - $teams->rocket->guardians = new stdClass(); |
|
| 349 | - $teams->rocket->id = 0; |
|
| 347 | + $teams->rocket = new stdClass(); |
|
| 348 | + $teams->rocket->guardians = new stdClass(); |
|
| 349 | + $teams->rocket->id = 0; |
|
| 350 | 350 | |
| 351 | 351 | |
| 352 | 352 | |
| 353 | 353 | foreach ($teams as $team_key => $team_values) { |
| 354 | 354 | // Team Guardians |
| 355 | 355 | |
| 356 | - $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 "; |
|
| 356 | + $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 "; |
|
| 357 | 357 | $result = $mysqli->query($req); |
| 358 | 358 | |
| 359 | - $i=0; |
|
| 359 | + $i = 0; |
|
| 360 | 360 | |
| 361 | 361 | while ($data = $result->fetch_object()) { |
| 362 | - $teams->$team_key->guardians->$i = $data->guard_pokemon_id; |
|
| 362 | + $teams->$team_key->guardians->$i = $data->guard_pokemon_id; |
|
| 363 | 363 | |
| 364 | 364 | $i++; |
| 365 | 365 | } |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | $result = $mysqli->query($req); |
| 372 | 372 | $data = $result->fetch_object(); |
| 373 | 373 | |
| 374 | - $teams->$team_key->gym_owned = $data->total; |
|
| 375 | - $teams->$team_key->average = $data->average_points; |
|
| 374 | + $teams->$team_key->gym_owned = $data->total; |
|
| 375 | + $teams->$team_key->average = $data->average_points; |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | case 'dashboard': |
| 386 | 386 | // This case is only used for test purpose. |
| 387 | 387 | |
| 388 | - $stats_file = SYS_PATH.'/core/json/gym.stats.json'; |
|
| 388 | + $stats_file = SYS_PATH.'/core/json/gym.stats.json'; |
|
| 389 | 389 | |
| 390 | 390 | if (!is_file($stats_file)) { |
| 391 | 391 | echo "Sorry, no Gym stats file was found. <br> Did you enable cron? "; |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | |
| 396 | - $stats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
|
| 396 | + $stats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
|
| 397 | 397 | |
| 398 | 398 | if (!is_file($stats_file)) { |
| 399 | 399 | echo "Sorry, no Pokémon stats file was found. <br> Did you enabled cron?"; |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
| 404 | - $stats_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
|
| 404 | + $stats_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
|
| 405 | 405 | |
| 406 | 406 | if (!is_file($stats_file)) { |
| 407 | 407 | echo "Sorry, no Pokéstop stats file was found. <br> Did you enabled cron?"; |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | if ($config->system->captcha_support) { |
| 412 | - $stats_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 412 | + $stats_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 413 | 413 | |
| 414 | 414 | if (!is_file($stats_file)) { |
| 415 | 415 | echo "Sorry, no Captcha stats file were found <br> Have you enable cron?"; |
@@ -429,9 +429,9 @@ discard block |
||
| 429 | 429 | // Right now |
| 430 | 430 | // --------- |
| 431 | 431 | |
| 432 | - $req = "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 433 | - $result = $mysqli->query($req); |
|
| 434 | - $data = $result->fetch_object(); |
|
| 432 | + $req = "SELECT COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 433 | + $result = $mysqli->query($req); |
|
| 434 | + $data = $result->fetch_object(); |
|
| 435 | 435 | |
| 436 | 436 | |
| 437 | 437 | $home->pokemon_now = $data->total; |
@@ -440,9 +440,9 @@ discard block |
||
| 440 | 440 | // Lured stops |
| 441 | 441 | // ----------- |
| 442 | 442 | |
| 443 | - $req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 444 | - $result = $mysqli->query($req); |
|
| 445 | - $data = $result->fetch_object(); |
|
| 443 | + $req = "SELECT COUNT(*) as total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 444 | + $result = $mysqli->query($req); |
|
| 445 | + $data = $result->fetch_object(); |
|
| 446 | 446 | |
| 447 | 447 | $home->pokestop_lured = $data->total; |
| 448 | 448 | |
@@ -450,9 +450,9 @@ discard block |
||
| 450 | 450 | // Gyms |
| 451 | 451 | // ---- |
| 452 | 452 | |
| 453 | - $req = "SELECT COUNT(DISTINCT(gym_id)) as total FROM gym"; |
|
| 454 | - $result = $mysqli->query($req); |
|
| 455 | - $data = $result->fetch_object(); |
|
| 453 | + $req = "SELECT COUNT(DISTINCT(gym_id)) as total FROM gym"; |
|
| 454 | + $result = $mysqli->query($req); |
|
| 455 | + $data = $result->fetch_object(); |
|
| 456 | 456 | |
| 457 | 457 | $home->gyms = $data->total; |
| 458 | 458 | |
@@ -462,19 +462,19 @@ discard block |
||
| 462 | 462 | |
| 463 | 463 | if ($config->system->recents_filter) { |
| 464 | 464 | // get all mythic pokemon ids |
| 465 | - $mythic_pokemons = array(); |
|
| 465 | + $mythic_pokemons = array(); |
|
| 466 | 466 | foreach ($pokemons->pokemon as $id => $pokemon) { |
| 467 | 467 | if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
| 468 | 468 | $mythic_pokemons[] = $id; |
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | // get all mythic 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 | WHERE pokemon_id IN (".implode(",", $mythic_pokemons).") |
| 474 | 474 | ORDER BY last_modified DESC LIMIT 0,12"; |
| 475 | 475 | } else { |
| 476 | 476 | // get all pokemon |
| 477 | - $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 |
|
| 477 | + $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 |
|
| 478 | 478 | ORDER BY last_modified DESC LIMIT 0,12"; |
| 479 | 479 | } |
| 480 | 480 | $result = $mysqli->query($req); |
@@ -520,28 +520,28 @@ discard block |
||
| 520 | 520 | |
| 521 | 521 | $req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '1' "; |
| 522 | 522 | $result = $mysqli->query($req); |
| 523 | - $data = $result->fetch_object(); |
|
| 523 | + $data = $result->fetch_object(); |
|
| 524 | 524 | |
| 525 | - $home->teams->mystic = $data->total; |
|
| 525 | + $home->teams->mystic = $data->total; |
|
| 526 | 526 | |
| 527 | 527 | |
| 528 | 528 | $req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '2' "; |
| 529 | 529 | $result = $mysqli->query($req); |
| 530 | - $data = $result->fetch_object(); |
|
| 530 | + $data = $result->fetch_object(); |
|
| 531 | 531 | |
| 532 | - $home->teams->valor = $data->total; |
|
| 532 | + $home->teams->valor = $data->total; |
|
| 533 | 533 | |
| 534 | 534 | |
| 535 | 535 | $req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '3' "; |
| 536 | 536 | $result = $mysqli->query($req); |
| 537 | - $data = $result->fetch_object(); |
|
| 537 | + $data = $result->fetch_object(); |
|
| 538 | 538 | |
| 539 | - $home->teams->instinct = $data->total; |
|
| 539 | + $home->teams->instinct = $data->total; |
|
| 540 | 540 | |
| 541 | 541 | |
| 542 | 542 | $req = "SELECT count( DISTINCT(gym_id) ) as total FROM gym WHERE team_id = '0' "; |
| 543 | 543 | $result = $mysqli->query($req); |
| 544 | - $data = $result->fetch_object(); |
|
| 544 | + $data = $result->fetch_object(); |
|
| 545 | 545 | |
| 546 | - $home->teams->rocket = $data->total; |
|
| 546 | + $home->teams->rocket = $data->total; |
|
| 547 | 547 | } |