@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | // Load Query Manager |
| 41 | 41 | // ################### |
| 42 | 42 | |
| 43 | -include_once __DIR__ . '/queries/QueryManager.php'; |
|
| 43 | +include_once __DIR__.'/queries/QueryManager.php'; |
|
| 44 | 44 | $manager = QueryManager::current(); |
| 45 | 45 | |
| 46 | 46 | $request = ""; |
@@ -161,10 +161,10 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | $html = ' |
| 164 | - <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="' . $pokeid . '" data-pokeuid="' . $pokeuid . '" style="display: none;"> |
|
| 165 | - <a href="pokemon/' . $pokeid . '"><img src="' . $pokemons->pokemon->$pokeid->img . '" alt="' . $pokemons->pokemon->$pokeid->name . '" class="img-responsive"></a> |
|
| 166 | - <a href="pokemon/' . $pokeid . '"><p class="pkmn-name">' . $pokemons->pokemon->$pokeid->name . '</p></a> |
|
| 167 | - <a href="' . $location_link . '" target="_blank"> |
|
| 164 | + <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="' . $pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;"> |
|
| 165 | + <a href="pokemon/' . $pokeid.'"><img src="'.$pokemons->pokemon->$pokeid->img.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a> |
|
| 166 | + <a href="pokemon/' . $pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a> |
|
| 167 | + <a href="' . $location_link.'" target="_blank"> |
|
| 168 | 168 | <small class="pokemon-timer">00:00:00</small> |
| 169 | 169 | </a>'; |
| 170 | 170 | if ($config->system->recents_encounter_details) { |
@@ -172,50 +172,50 @@ discard block |
||
| 172 | 172 | if ($config->system->iv_numbers) { |
| 173 | 173 | $html .= ' |
| 174 | 174 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 175 | - <div title="' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="' . $encdetails->attack . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
|
| 176 | - <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '</span>' . $encdetails->attack . ' |
|
| 175 | + <div title="' . $locales->IV_ATTACK.': '.$encdetails->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
|
| 176 | + <span class="sr-only">' . $locales->IV_ATTACK.': '.$encdetails->attack.'</span>'.$encdetails->attack.' |
|
| 177 | 177 | </div> |
| 178 | - <div title="' . $locales->IV_DEFENSE . ': ' . $encdetails->defense . '" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="' . $encdetails->defense . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
|
| 179 | - <span class="sr-only">' . $locales->IV_DEFENSE . ': ' . $encdetails->defense . '</span>' . $encdetails->defense . ' |
|
| 178 | + <div title="' . $locales->IV_DEFENSE.': '.$encdetails->defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$encdetails->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
|
| 179 | + <span class="sr-only">' . $locales->IV_DEFENSE.': '.$encdetails->defense.'</span>'.$encdetails->defense.' |
|
| 180 | 180 | </div> |
| 181 | - <div title="' . $locales->IV_STAMINA . ': ' . $encdetails->stamina . '" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' . $encdetails->stamina . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
|
| 182 | - <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $encdetails->stamina . '</span>' . $encdetails->stamina . ' |
|
| 181 | + <div title="' . $locales->IV_STAMINA.': '.$encdetails->stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$encdetails->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
|
| 182 | + <span class="sr-only">' . $locales->IV_STAMINA.': '.$encdetails->stamina.'</span>'.$encdetails->stamina.' |
|
| 183 | 183 | </div> |
| 184 | 184 | </div>'; |
| 185 | 185 | } else { |
| 186 | 186 | $html .= ' |
| 187 | 187 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 188 | - <div title="' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="' . $encdetails->attack . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (((100 / 15) * $encdetails->attack) / 3) . '%"> |
|
| 189 | - <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '</span> |
|
| 188 | + <div title="' . $locales->IV_ATTACK.': '.$encdetails->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $encdetails->attack) / 3).'%"> |
|
| 189 | + <span class="sr-only">' . $locales->IV_ATTACK.': '.$encdetails->attack.'</span> |
|
| 190 | 190 | </div> |
| 191 | - <div title="' . $locales->IV_DEFENSE . ': ' . $encdetails->defense . '" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="' . $encdetails->defense . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (((100 / 15) * $encdetails->defense) / 3) . '%"> |
|
| 192 | - <span class="sr-only">' . $locales->IV_DEFENSE . ': ' . $encdetails->defense . '</span> |
|
| 191 | + <div title="' . $locales->IV_DEFENSE.': '.$encdetails->defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$encdetails->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $encdetails->defense) / 3).'%"> |
|
| 192 | + <span class="sr-only">' . $locales->IV_DEFENSE.': '.$encdetails->defense.'</span> |
|
| 193 | 193 | </div> |
| 194 | - <div title="' . $locales->IV_STAMINA . ': ' . $encdetails->stamina . '" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' . $encdetails->stamina . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (((100 / 15) * $encdetails->stamina) / 3) . '%"> |
|
| 195 | - <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $encdetails->stamina . '</span> |
|
| 194 | + <div title="' . $locales->IV_STAMINA.': '.$encdetails->stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$encdetails->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $encdetails->stamina) / 3).'%"> |
|
| 195 | + <span class="sr-only">' . $locales->IV_STAMINA.': '.$encdetails->stamina.'</span> |
|
| 196 | 196 | </div> |
| 197 | 197 | </div>'; |
| 198 | 198 | } |
| 199 | - $html .= '<small>' . $encdetails->cp . '</small>'; |
|
| 199 | + $html .= '<small>'.$encdetails->cp.'</small>'; |
|
| 200 | 200 | } else { |
| 201 | 201 | if ($config->system->iv_numbers) { |
| 202 | 202 | $html .= ' |
| 203 | 203 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 204 | - <div title="' . $locales->IV_ATTACK . ': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="' . $encdetails->attack . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
|
| 205 | - <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $locales->NOT_AVAILABLE . '</span>? |
|
| 204 | + <div title="' . $locales->IV_ATTACK.': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$encdetails->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
|
| 205 | + <span class="sr-only">' . $locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>? |
|
| 206 | 206 | </div> |
| 207 | - <div title="' . $locales->IV_DEFENSE . ': not available" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="' . $encdetails->defense . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
|
| 208 | - <span class="sr-only">' . $locales->IV_DEFENSE . ': ' . $locales->NOT_AVAILABLE . '</span>? |
|
| 207 | + <div title="' . $locales->IV_DEFENSE.': not available" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$encdetails->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
|
| 208 | + <span class="sr-only">' . $locales->IV_DEFENSE.': '.$locales->NOT_AVAILABLE.'</span>? |
|
| 209 | 209 | </div> |
| 210 | - <div title="' . $locales->IV_STAMINA . ': not available" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="' . $encdetails->stamina . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
|
| 211 | - <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $locales->NOT_AVAILABLE . '</span>? |
|
| 210 | + <div title="' . $locales->IV_STAMINA.': not available" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$encdetails->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
|
| 211 | + <span class="sr-only">' . $locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>? |
|
| 212 | 212 | </div> |
| 213 | 213 | </div>'; |
| 214 | 214 | } else { |
| 215 | 215 | $html .= ' |
| 216 | 216 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 217 | 217 | <div title="IV not available" class="progress-bar" role="progressbar" style="width: 100%; background-color: rgb(210,210,210)" aria-valuenow="1" aria-valuemin="0" aria-valuemax="1"> |
| 218 | - <span class="sr-only">IV ' . $locales->NOT_AVAILABLE . '</span> |
|
| 218 | + <span class="sr-only">IV ' . $locales->NOT_AVAILABLE.'</span> |
|
| 219 | 219 | </div> |
| 220 | 220 | </div>'; |
| 221 | 221 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | foreach ($teams as $team_name => $team_id) { |
| 293 | 293 | |
| 294 | - $data = $manager->getOwnedAndPoints($team_id); |
|
| 294 | + $data = $manager->getOwnedAndPoints($team_id); |
|
| 295 | 295 | |
| 296 | 296 | $return[] = $data->total; |
| 297 | 297 | $return[] = $data->average_points; |
@@ -414,38 +414,38 @@ discard block |
||
| 414 | 414 | if ($config->system->iv_numbers) { |
| 415 | 415 | $gymData['infoWindow'] .= ' |
| 416 | 416 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 417 | - <a href="pokemon/' . $data->pokemon_id . '"> |
|
| 418 | - <img src="' . $pokemons->pokemon->$pokemon_id->img . '" height="50" style="display:inline-block" > |
|
| 417 | + <a href="pokemon/' . $data->pokemon_id.'"> |
|
| 418 | + <img src="' . $pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
|
| 419 | 419 | </a> |
| 420 | - <p class="pkmn-name">' . $data->cp . '</p> |
|
| 420 | + <p class="pkmn-name">' . $data->cp.'</p> |
|
| 421 | 421 | <div class="progress" style="height: 12px; margin-bottom: 0"> |
| 422 | - <div title="' . $locales->IV_ATTACK . ': ' . $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"> |
|
| 423 | - <span class="sr-only">' . $locales->IV_ATTACK . ' : ' . $data->iv_attack . '</span>' . $data->iv_attack . ' |
|
| 422 | + <div title="' . $locales->IV_ATTACK.': '.$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"> |
|
| 423 | + <span class="sr-only">' . $locales->IV_ATTACK.' : '.$data->iv_attack.'</span>'.$data->iv_attack.' |
|
| 424 | 424 | </div> |
| 425 | - <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"> |
|
| 426 | - <span class="sr-only">' . $locales->IV_DEFENSE . ' : ' . $data->iv_defense . '</span>' . $data->iv_defense . ' |
|
| 425 | + <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"> |
|
| 426 | + <span class="sr-only">' . $locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'.$data->iv_defense.' |
|
| 427 | 427 | </div> |
| 428 | - <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"> |
|
| 429 | - <span class="sr-only">' . $locales->IV_STAMINA . ' : ' . $data->iv_stamina . '</span>' . $data->iv_stamina . ' |
|
| 428 | + <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"> |
|
| 429 | + <span class="sr-only">' . $locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'.$data->iv_stamina.' |
|
| 430 | 430 | </div> |
| 431 | 431 | </div> |
| 432 | 432 | </div>'; |
| 433 | 433 | } else { |
| 434 | 434 | $gymData['infoWindow'] .= ' |
| 435 | 435 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 436 | - <a href="pokemon/' . $data->pokemon_id . '"> |
|
| 437 | - <img src="' . $pokemons->pokemon->$pokemon_id->img . '" height="50" style="display:inline-block" > |
|
| 436 | + <a href="pokemon/' . $data->pokemon_id.'"> |
|
| 437 | + <img src="' . $pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
|
| 438 | 438 | </a> |
| 439 | - <p class="pkmn-name">' . $data->cp . '</p> |
|
| 439 | + <p class="pkmn-name">' . $data->cp.'</p> |
|
| 440 | 440 | <div class="progress" style="height: 4px; width: 40px; margin-bottom: 10px; margin-top: 2px; margin-left: auto; margin-right: auto"> |
| 441 | - <div title="' . $locales->IV_ATTACK . ': ' . $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) . '%"> |
|
| 442 | - <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $data->iv_attack . '</span> |
|
| 441 | + <div title="' . $locales->IV_ATTACK.': '.$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).'%"> |
|
| 442 | + <span class="sr-only">' . $locales->IV_ATTACK.': '.$data->iv_attack.'</span> |
|
| 443 | 443 | </div> |
| 444 | - <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 / 15) * $data->iv_defense) / 3) . '%"> |
|
| 445 | - <span class="sr-only">' . $locales->IV_DEFENSE . ': ' . $data->iv_defense . '</span> |
|
| 444 | + <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 / 15) * $data->iv_defense) / 3).'%"> |
|
| 445 | + <span class="sr-only">' . $locales->IV_DEFENSE.': '.$data->iv_defense.'</span> |
|
| 446 | 446 | </div> |
| 447 | - <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 / 15) * $data->iv_stamina) / 3) . '%"> |
|
| 448 | - <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $data->iv_stamina . '</span> |
|
| 447 | + <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 / 15) * $data->iv_stamina) / 3).'%"> |
|
| 448 | + <span class="sr-only">' . $locales->IV_STAMINA.': '.$data->iv_stamina.'</span> |
|
| 449 | 449 | </div> |
| 450 | 450 | </div> |
| 451 | 451 | </div>'; |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | } else { |
| 524 | 524 | $data->charge_move = "?"; |
| 525 | 525 | } |
| 526 | - $raids[10*$page + $i] = $data; |
|
| 526 | + $raids[10 * $page + $i] = $data; |
|
| 527 | 527 | $i++; |
| 528 | 528 | } |
| 529 | 529 | $json = array(); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | $entry->total_cp_diff = 0; |
| 612 | 612 | $entry->only_cp_changed = true; |
| 613 | 613 | if ($idx < count($entries) - 1) { |
| 614 | - $next_entry = $entries[$idx+1]; |
|
| 614 | + $next_entry = $entries[$idx + 1]; |
|
| 615 | 615 | $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
| 616 | 616 | $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
| 617 | 617 | $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
@@ -624,7 +624,7 @@ discard block |
||
| 624 | 624 | foreach ($old_pokemon as $pkm) { |
| 625 | 625 | $next_entry->pokemon[$pkm]->class = 'old'; |
| 626 | 626 | } |
| 627 | - if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 627 | + if ($entry->team_id != $next_entry->team_id || $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 628 | 628 | $entry->only_cp_changed = false; |
| 629 | 629 | } |
| 630 | 630 | } |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | |
| 647 | 647 | |
| 648 | 648 | case 'pokemon_slider_init': |
| 649 | - $bounds = $manager->getPokemonSliderMinMax(); |
|
| 649 | + $bounds = $manager->getPokemonSliderMinMax(); |
|
| 650 | 650 | |
| 651 | 651 | header('Content-Type: application/json'); |
| 652 | 652 | echo json_encode($bounds); |
@@ -59,118 +59,118 @@ discard block |
||
| 59 | 59 | // |
| 60 | 60 | ############################ |
| 61 | 61 | |
| 62 | - case 'home_update': |
|
| 63 | - $values = []; |
|
| 64 | - // Right now |
|
| 65 | - // --------- |
|
| 66 | - $data = $manager->getTotalPokemon(); |
|
| 67 | - $values[] = $data->total; |
|
| 62 | + case 'home_update': |
|
| 63 | + $values = []; |
|
| 64 | + // Right now |
|
| 65 | + // --------- |
|
| 66 | + $data = $manager->getTotalPokemon(); |
|
| 67 | + $values[] = $data->total; |
|
| 68 | 68 | |
| 69 | - // Lured stops |
|
| 70 | - // ----------- |
|
| 71 | - $data = $manager->getTotalLures(); |
|
| 72 | - $values[] = $data->total; |
|
| 69 | + // Lured stops |
|
| 70 | + // ----------- |
|
| 71 | + $data = $manager->getTotalLures(); |
|
| 72 | + $values[] = $data->total; |
|
| 73 | 73 | |
| 74 | - // Active Raids |
|
| 75 | - // ----------- |
|
| 76 | - $data = $manager->getTotalRaids(); |
|
| 77 | - $values[] = $data->total; |
|
| 74 | + // Active Raids |
|
| 75 | + // ----------- |
|
| 76 | + $data = $manager->getTotalRaids(); |
|
| 77 | + $values[] = $data->total; |
|
| 78 | 78 | |
| 79 | - // Team battle |
|
| 80 | - // ----------- |
|
| 81 | - $data = $manager->getTotalGyms(); |
|
| 82 | - $values[] = $data->total; |
|
| 79 | + // Team battle |
|
| 80 | + // ----------- |
|
| 81 | + $data = $manager->getTotalGyms(); |
|
| 82 | + $values[] = $data->total; |
|
| 83 | 83 | |
| 84 | - // Red |
|
| 85 | - $data = $manager->getTotalGymsForTeam(2); |
|
| 86 | - $values[] = $data->total; |
|
| 84 | + // Red |
|
| 85 | + $data = $manager->getTotalGymsForTeam(2); |
|
| 86 | + $values[] = $data->total; |
|
| 87 | 87 | |
| 88 | - // Blue |
|
| 89 | - $data = $manager->getTotalGymsForTeam(1); |
|
| 90 | - $values[] = $data->total; |
|
| 88 | + // Blue |
|
| 89 | + $data = $manager->getTotalGymsForTeam(1); |
|
| 90 | + $values[] = $data->total; |
|
| 91 | 91 | |
| 92 | - // Yellow |
|
| 93 | - $data = $manager->getTotalGymsForTeam(3); |
|
| 94 | - $values[] = $data->total; |
|
| 92 | + // Yellow |
|
| 93 | + $data = $manager->getTotalGymsForTeam(3); |
|
| 94 | + $values[] = $data->total; |
|
| 95 | 95 | |
| 96 | - // Neutral |
|
| 97 | - $data = $manager->getTotalGymsForTeam(0); |
|
| 98 | - $values[] = $data->total; |
|
| 96 | + // Neutral |
|
| 97 | + $data = $manager->getTotalGymsForTeam(0); |
|
| 98 | + $values[] = $data->total; |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | - header('Content-Type: application/json'); |
|
| 102 | - echo json_encode($values); |
|
| 101 | + header('Content-Type: application/json'); |
|
| 102 | + echo json_encode($values); |
|
| 103 | 103 | |
| 104 | - break; |
|
| 104 | + break; |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | - #################################### |
|
| 108 | - // |
|
| 109 | - // Update latests spawn on homepage |
|
| 110 | - // |
|
| 111 | - #################################### |
|
| 107 | + #################################### |
|
| 108 | + // |
|
| 109 | + // Update latests spawn on homepage |
|
| 110 | + // |
|
| 111 | + #################################### |
|
| 112 | 112 | |
| 113 | - case 'spawnlist_update': |
|
| 114 | - // Recent spawn |
|
| 115 | - // ------------ |
|
| 116 | - $total_spawns = array(); |
|
| 117 | - $last_uid_param = ""; |
|
| 118 | - if (isset($_GET['last_uid'])) { |
|
| 119 | - $last_uid_param = $_GET['last_uid']; |
|
| 120 | - } |
|
| 121 | - if ($config->system->recents_filter) { |
|
| 122 | - // get all mythic pokemon ids |
|
| 123 | - $mythic_pokemons = array(); |
|
| 124 | - foreach ($pokemons->pokemon as $id => $pokemon) { |
|
| 125 | - if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
| 126 | - $mythic_pokemons[] = $id; |
|
| 127 | - } |
|
| 113 | + case 'spawnlist_update': |
|
| 114 | + // Recent spawn |
|
| 115 | + // ------------ |
|
| 116 | + $total_spawns = array(); |
|
| 117 | + $last_uid_param = ""; |
|
| 118 | + if (isset($_GET['last_uid'])) { |
|
| 119 | + $last_uid_param = $_GET['last_uid']; |
|
| 128 | 120 | } |
| 121 | + if ($config->system->recents_filter) { |
|
| 122 | + // get all mythic pokemon ids |
|
| 123 | + $mythic_pokemons = array(); |
|
| 124 | + foreach ($pokemons->pokemon as $id => $pokemon) { |
|
| 125 | + if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
| 126 | + $mythic_pokemons[] = $id; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - // get last mythic pokemon |
|
| 131 | - $result = $manager->getRecentMythic($mythic_pokemons); |
|
| 132 | - } else { |
|
| 133 | - // get last pokemon |
|
| 134 | - $result = $manager->getRecentAll(); |
|
| 135 | - } |
|
| 130 | + // get last mythic pokemon |
|
| 131 | + $result = $manager->getRecentMythic($mythic_pokemons); |
|
| 132 | + } else { |
|
| 133 | + // get last pokemon |
|
| 134 | + $result = $manager->getRecentAll(); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - if (count($result) > 0) { |
|
| 138 | - foreach ($result as $data) { |
|
| 139 | - $new_spawn = array(); |
|
| 140 | - $pokeid = $data->pokemon_id; |
|
| 141 | - $pokeuid = $data->encounter_id; |
|
| 142 | - |
|
| 143 | - if ($last_uid_param != $pokeuid) { |
|
| 144 | - $last_seen = strtotime($data->disappear_time_real); |
|
| 145 | - |
|
| 146 | - $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
| 147 | - $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
| 148 | - $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
| 149 | - |
|
| 150 | - if ($config->system->recents_encounter_details) { |
|
| 151 | - $encdetails = new stdClass(); |
|
| 152 | - $encdetails->cp = $data->cp; |
|
| 153 | - $encdetails->attack = $data->individual_attack; |
|
| 154 | - $encdetails->defense = $data->individual_defense; |
|
| 155 | - $encdetails->stamina = $data->individual_stamina; |
|
| 156 | - if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
| 157 | - $encdetails->available = true; |
|
| 158 | - } else { |
|
| 159 | - $encdetails->available = false; |
|
| 137 | + if (count($result) > 0) { |
|
| 138 | + foreach ($result as $data) { |
|
| 139 | + $new_spawn = array(); |
|
| 140 | + $pokeid = $data->pokemon_id; |
|
| 141 | + $pokeuid = $data->encounter_id; |
|
| 142 | + |
|
| 143 | + if ($last_uid_param != $pokeuid) { |
|
| 144 | + $last_seen = strtotime($data->disappear_time_real); |
|
| 145 | + |
|
| 146 | + $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
| 147 | + $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
| 148 | + $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
| 149 | + |
|
| 150 | + if ($config->system->recents_encounter_details) { |
|
| 151 | + $encdetails = new stdClass(); |
|
| 152 | + $encdetails->cp = $data->cp; |
|
| 153 | + $encdetails->attack = $data->individual_attack; |
|
| 154 | + $encdetails->defense = $data->individual_defense; |
|
| 155 | + $encdetails->stamina = $data->individual_stamina; |
|
| 156 | + if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
| 157 | + $encdetails->available = true; |
|
| 158 | + } else { |
|
| 159 | + $encdetails->available = false; |
|
| 160 | + } |
|
| 160 | 161 | } |
| 161 | - } |
|
| 162 | 162 | |
| 163 | - $html = ' |
|
| 163 | + $html = ' |
|
| 164 | 164 | <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="' . $pokeid . '" data-pokeuid="' . $pokeuid . '" style="display: none;"> |
| 165 | 165 | <a href="pokemon/' . $pokeid . '"><img src="' . $pokemons->pokemon->$pokeid->img . '" alt="' . $pokemons->pokemon->$pokeid->name . '" class="img-responsive"></a> |
| 166 | 166 | <a href="pokemon/' . $pokeid . '"><p class="pkmn-name">' . $pokemons->pokemon->$pokeid->name . '</p></a> |
| 167 | 167 | <a href="' . $location_link . '" target="_blank"> |
| 168 | 168 | <small class="pokemon-timer">00:00:00</small> |
| 169 | 169 | </a>'; |
| 170 | - if ($config->system->recents_encounter_details) { |
|
| 171 | - if ($encdetails->available) { |
|
| 172 | - if ($config->system->iv_numbers) { |
|
| 173 | - $html .= ' |
|
| 170 | + if ($config->system->recents_encounter_details) { |
|
| 171 | + if ($encdetails->available) { |
|
| 172 | + if ($config->system->iv_numbers) { |
|
| 173 | + $html .= ' |
|
| 174 | 174 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 175 | 175 | <div title="' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="' . $encdetails->attack . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
| 176 | 176 | <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '</span>' . $encdetails->attack . ' |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $encdetails->stamina . '</span>' . $encdetails->stamina . ' |
| 183 | 183 | </div> |
| 184 | 184 | </div>'; |
| 185 | - } else { |
|
| 186 | - $html .= ' |
|
| 185 | + } else { |
|
| 186 | + $html .= ' |
|
| 187 | 187 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 188 | 188 | <div title="' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="' . $encdetails->attack . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (((100 / 15) * $encdetails->attack) / 3) . '%"> |
| 189 | 189 | <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $encdetails->attack . '</span> |
@@ -195,11 +195,11 @@ discard block |
||
| 195 | 195 | <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $encdetails->stamina . '</span> |
| 196 | 196 | </div> |
| 197 | 197 | </div>'; |
| 198 | - } |
|
| 199 | - $html .= '<small>' . $encdetails->cp . '</small>'; |
|
| 200 | - } else { |
|
| 201 | - if ($config->system->iv_numbers) { |
|
| 202 | - $html .= ' |
|
| 198 | + } |
|
| 199 | + $html .= '<small>' . $encdetails->cp . '</small>'; |
|
| 200 | + } else { |
|
| 201 | + if ($config->system->iv_numbers) { |
|
| 202 | + $html .= ' |
|
| 203 | 203 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 204 | 204 | <div title="' . $locales->IV_ATTACK . ': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="' . $encdetails->attack . '" aria-valuemin="0" aria-valuemax="45" style="width: ' . (100 / 3) . '%; line-height: 16px"> |
| 205 | 205 | <span class="sr-only">' . $locales->IV_ATTACK . ': ' . $locales->NOT_AVAILABLE . '</span>? |
@@ -211,116 +211,116 @@ discard block |
||
| 211 | 211 | <span class="sr-only">' . $locales->IV_STAMINA . ': ' . $locales->NOT_AVAILABLE . '</span>? |
| 212 | 212 | </div> |
| 213 | 213 | </div>'; |
| 214 | - } else { |
|
| 215 | - $html .= ' |
|
| 214 | + } else { |
|
| 215 | + $html .= ' |
|
| 216 | 216 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 217 | 217 | <div title="IV not available" class="progress-bar" role="progressbar" style="width: 100%; background-color: rgb(210,210,210)" aria-valuenow="1" aria-valuemin="0" aria-valuemax="1"> |
| 218 | 218 | <span class="sr-only">IV ' . $locales->NOT_AVAILABLE . '</span> |
| 219 | 219 | </div> |
| 220 | 220 | </div>'; |
| 221 | + } |
|
| 222 | + $html .= '<small>???</small>'; |
|
| 221 | 223 | } |
| 222 | - $html .= '<small>???</small>'; |
|
| 223 | 224 | } |
| 224 | - } |
|
| 225 | - $html .= ' |
|
| 225 | + $html .= ' |
|
| 226 | 226 | </div>'; |
| 227 | - $new_spawn['html'] = $html; |
|
| 228 | - $countdown = $last_seen - time(); |
|
| 229 | - $new_spawn['countdown'] = $countdown; |
|
| 230 | - $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 231 | - $total_spawns[] = $new_spawn; |
|
| 232 | - } else { |
|
| 233 | - break; |
|
| 227 | + $new_spawn['html'] = $html; |
|
| 228 | + $countdown = $last_seen - time(); |
|
| 229 | + $new_spawn['countdown'] = $countdown; |
|
| 230 | + $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 231 | + $total_spawns[] = $new_spawn; |
|
| 232 | + } else { |
|
| 233 | + break; |
|
| 234 | + } |
|
| 234 | 235 | } |
| 235 | 236 | } |
| 236 | - } |
|
| 237 | 237 | |
| 238 | - header('Content-Type: application/json'); |
|
| 239 | - echo json_encode($total_spawns); |
|
| 238 | + header('Content-Type: application/json'); |
|
| 239 | + echo json_encode($total_spawns); |
|
| 240 | 240 | |
| 241 | - break; |
|
| 241 | + break; |
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | - #################################### |
|
| 245 | - // |
|
| 246 | - // List Pokestop |
|
| 247 | - // |
|
| 248 | - #################################### |
|
| 244 | + #################################### |
|
| 245 | + // |
|
| 246 | + // List Pokestop |
|
| 247 | + // |
|
| 248 | + #################################### |
|
| 249 | 249 | |
| 250 | - case 'pokestop': |
|
| 251 | - $datas = $manager->getAllPokestops(); |
|
| 250 | + case 'pokestop': |
|
| 251 | + $datas = $manager->getAllPokestops(); |
|
| 252 | 252 | |
| 253 | - $pokestops = []; |
|
| 254 | - foreach ($datas as $data) { |
|
| 255 | - if ($data->lure_expiration >= $data->now) { |
|
| 256 | - $icon = 'pokestap_lured.png'; |
|
| 257 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 258 | - $lured = true; |
|
| 259 | - } else { |
|
| 260 | - $icon = 'pokestap.png'; |
|
| 261 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 262 | - $lured = false; |
|
| 263 | - } |
|
| 253 | + $pokestops = []; |
|
| 254 | + foreach ($datas as $data) { |
|
| 255 | + if ($data->lure_expiration >= $data->now) { |
|
| 256 | + $icon = 'pokestap_lured.png'; |
|
| 257 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 258 | + $lured = true; |
|
| 259 | + } else { |
|
| 260 | + $icon = 'pokestap.png'; |
|
| 261 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 262 | + $lured = false; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - $pokestops[] = [ |
|
| 266 | - $text, |
|
| 267 | - $icon, |
|
| 268 | - $data->latitude, |
|
| 269 | - $data->longitude, |
|
| 270 | - $lured |
|
| 271 | - ]; |
|
| 272 | - } |
|
| 265 | + $pokestops[] = [ |
|
| 266 | + $text, |
|
| 267 | + $icon, |
|
| 268 | + $data->latitude, |
|
| 269 | + $data->longitude, |
|
| 270 | + $lured |
|
| 271 | + ]; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - header('Content-Type: application/json'); |
|
| 275 | - echo json_encode($pokestops); |
|
| 274 | + header('Content-Type: application/json'); |
|
| 275 | + echo json_encode($pokestops); |
|
| 276 | 276 | |
| 277 | - break; |
|
| 277 | + break; |
|
| 278 | 278 | |
| 279 | 279 | |
| 280 | - #################################### |
|
| 281 | - // |
|
| 282 | - // Update data for the gym battle |
|
| 283 | - // |
|
| 284 | - #################################### |
|
| 280 | + #################################### |
|
| 281 | + // |
|
| 282 | + // Update data for the gym battle |
|
| 283 | + // |
|
| 284 | + #################################### |
|
| 285 | 285 | |
| 286 | - case 'update_gym': |
|
| 287 | - $teams = new stdClass(); |
|
| 288 | - $teams->mystic = 1; |
|
| 289 | - $teams->valor = 2; |
|
| 290 | - $teams->instinct = 3; |
|
| 286 | + case 'update_gym': |
|
| 287 | + $teams = new stdClass(); |
|
| 288 | + $teams->mystic = 1; |
|
| 289 | + $teams->valor = 2; |
|
| 290 | + $teams->instinct = 3; |
|
| 291 | 291 | |
| 292 | - foreach ($teams as $team_name => $team_id) { |
|
| 292 | + foreach ($teams as $team_name => $team_id) { |
|
| 293 | 293 | |
| 294 | - $data = $manager->getOwnedAndPoints($team_id); |
|
| 294 | + $data = $manager->getOwnedAndPoints($team_id); |
|
| 295 | 295 | |
| 296 | - $return[] = $data->total; |
|
| 297 | - $return[] = $data->average_points; |
|
| 298 | - } |
|
| 296 | + $return[] = $data->total; |
|
| 297 | + $return[] = $data->average_points; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - header('Content-Type: application/json'); |
|
| 301 | - echo json_encode($return); |
|
| 300 | + header('Content-Type: application/json'); |
|
| 301 | + echo json_encode($return); |
|
| 302 | 302 | |
| 303 | - break; |
|
| 303 | + break; |
|
| 304 | 304 | |
| 305 | 305 | |
| 306 | - #################################### |
|
| 307 | - // |
|
| 308 | - // Get datas for the gym map |
|
| 309 | - // |
|
| 310 | - #################################### |
|
| 306 | + #################################### |
|
| 307 | + // |
|
| 308 | + // Get datas for the gym map |
|
| 309 | + // |
|
| 310 | + #################################### |
|
| 311 | 311 | |
| 312 | 312 | |
| 313 | - case 'gym_map': |
|
| 314 | - $datas = $manager->getAllGyms(); |
|
| 313 | + case 'gym_map': |
|
| 314 | + $datas = $manager->getAllGyms(); |
|
| 315 | 315 | |
| 316 | - $gyms = []; |
|
| 317 | - foreach ($datas as $data) { |
|
| 318 | - // Team |
|
| 319 | - // 1 = bleu |
|
| 320 | - // 2 = rouge |
|
| 321 | - // 3 = jaune |
|
| 316 | + $gyms = []; |
|
| 317 | + foreach ($datas as $data) { |
|
| 318 | + // Team |
|
| 319 | + // 1 = bleu |
|
| 320 | + // 2 = rouge |
|
| 321 | + // 3 = jaune |
|
| 322 | 322 | |
| 323 | - switch ($data->team_id) { |
|
| 323 | + switch ($data->team_id) { |
|
| 324 | 324 | case 0: |
| 325 | 325 | $icon = 'map_white.png'; |
| 326 | 326 | $team = 'No Team (yet)'; |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | $team = 'Team Instinct'; |
| 345 | 345 | $color = 'rgba(254, 217, 40, .6)'; |
| 346 | 346 | break; |
| 347 | - } |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | 349 | if ($data->team_id != 0) { |
| 350 | 350 | $icon .= $data->level.".png"; |
@@ -370,49 +370,49 @@ discard block |
||
| 370 | 370 | // |
| 371 | 371 | #################################### |
| 372 | 372 | |
| 373 | - case 'gym_defenders': |
|
| 374 | - $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
| 373 | + case 'gym_defenders': |
|
| 374 | + $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
| 375 | 375 | |
| 376 | - $data = $manager->getGymData($gym_id); |
|
| 377 | - $gymData['gymDetails']['gymInfos'] = false; |
|
| 376 | + $data = $manager->getGymData($gym_id); |
|
| 377 | + $gymData['gymDetails']['gymInfos'] = false; |
|
| 378 | 378 | |
| 379 | - if (!is_null($data)) { |
|
| 380 | - if ($data->name == null) { |
|
| 381 | - $gymData['gymDetails']['gymInfos']['name'] = "?"; |
|
| 382 | - } else { |
|
| 383 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 384 | - } |
|
| 385 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 386 | - if ($data->url == null) { |
|
| 387 | - $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 388 | - } else { |
|
| 389 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 390 | - } |
|
| 391 | - if ($data->url == null) { |
|
| 392 | - $gymData['gymDetails']['gymInfos']['points'] = "?"; |
|
| 393 | - } else { |
|
| 394 | - $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 395 | - } |
|
| 396 | - $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 397 | - if ($data->last_scanned == null) { |
|
| 398 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = "?"; |
|
| 399 | - } else { |
|
| 400 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 401 | - } |
|
| 402 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 403 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 379 | + if (!is_null($data)) { |
|
| 380 | + if ($data->name == null) { |
|
| 381 | + $gymData['gymDetails']['gymInfos']['name'] = "?"; |
|
| 382 | + } else { |
|
| 383 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 384 | + } |
|
| 385 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 386 | + if ($data->url == null) { |
|
| 387 | + $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 388 | + } else { |
|
| 389 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 390 | + } |
|
| 391 | + if ($data->url == null) { |
|
| 392 | + $gymData['gymDetails']['gymInfos']['points'] = "?"; |
|
| 393 | + } else { |
|
| 394 | + $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 395 | + } |
|
| 396 | + $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 397 | + if ($data->last_scanned == null) { |
|
| 398 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = "?"; |
|
| 399 | + } else { |
|
| 400 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 401 | + } |
|
| 402 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 403 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 404 | 404 | |
| 405 | - // Skip Query if team is none |
|
| 406 | - if ($data->team > 0) { |
|
| 407 | - $datas = $manager->getGymDefenders($gym_id); |
|
| 408 | - $gymData['infoWindow'] = ' |
|
| 405 | + // Skip Query if team is none |
|
| 406 | + if ($data->team > 0) { |
|
| 407 | + $datas = $manager->getGymDefenders($gym_id); |
|
| 408 | + $gymData['infoWindow'] = ' |
|
| 409 | 409 | <div class="gym_defenders"> |
| 410 | 410 | '; |
| 411 | - foreach ($datas as $data) { |
|
| 412 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
| 413 | - $pokemon_id = $data->pokemon_id; |
|
| 414 | - if ($config->system->iv_numbers) { |
|
| 415 | - $gymData['infoWindow'] .= ' |
|
| 411 | + foreach ($datas as $data) { |
|
| 412 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
| 413 | + $pokemon_id = $data->pokemon_id; |
|
| 414 | + if ($config->system->iv_numbers) { |
|
| 415 | + $gymData['infoWindow'] .= ' |
|
| 416 | 416 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 417 | 417 | <a href="pokemon/' . $data->pokemon_id . '"> |
| 418 | 418 | <img src="' . $pokemons->pokemon->$pokemon_id->img . '" height="50" style="display:inline-block" > |
@@ -430,8 +430,8 @@ discard block |
||
| 430 | 430 | </div> |
| 431 | 431 | </div> |
| 432 | 432 | </div>'; |
| 433 | - } else { |
|
| 434 | - $gymData['infoWindow'] .= ' |
|
| 433 | + } else { |
|
| 434 | + $gymData['infoWindow'] .= ' |
|
| 435 | 435 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 436 | 436 | <a href="pokemon/' . $data->pokemon_id . '"> |
| 437 | 437 | <img src="' . $pokemons->pokemon->$pokemon_id->img . '" height="50" style="display:inline-block" > |
@@ -449,254 +449,254 @@ discard block |
||
| 449 | 449 | </div> |
| 450 | 450 | </div> |
| 451 | 451 | </div>'; |
| 452 | + } |
|
| 452 | 453 | } |
| 453 | 454 | } |
| 455 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 454 | 456 | } |
| 455 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 456 | - } |
|
| 457 | 457 | |
| 458 | 458 | |
| 459 | - header('Content-Type: application/json'); |
|
| 460 | - echo json_encode($gymData); |
|
| 459 | + header('Content-Type: application/json'); |
|
| 460 | + echo json_encode($gymData); |
|
| 461 | 461 | |
| 462 | - break; |
|
| 462 | + break; |
|
| 463 | 463 | |
| 464 | 464 | |
| 465 | - case 'trainer': |
|
| 466 | - $name = ""; |
|
| 467 | - $page = "0"; |
|
| 468 | - $team = 0; |
|
| 469 | - $ranking = 0; |
|
| 470 | - if (isset($_GET['name'])) { |
|
| 471 | - $trainer_name = $manager->getEcapedString($_GET['name']); |
|
| 472 | - } |
|
| 473 | - if (isset($_GET['team'])) { |
|
| 474 | - $team = $manager->getEcapedString($_GET['team']); |
|
| 475 | - } |
|
| 476 | - if (isset($_GET['page'])) { |
|
| 477 | - $page = $manager->getEcapedString($_GET['page']); |
|
| 478 | - } |
|
| 479 | - if (isset($_GET['ranking'])) { |
|
| 480 | - $ranking = $manager->getEcapedString($_GET['ranking']); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $trainers = $manager->getTrainers($trainer_name, $team, $page, $ranking); |
|
| 484 | - $json = array(); |
|
| 485 | - $json['trainers'] = $trainers; |
|
| 486 | - $locale = array(); |
|
| 487 | - $locale["today"] = $locales->TODAY; |
|
| 488 | - $locale["day"] = $locales->DAY; |
|
| 489 | - $locale["days"] = $locales->DAYS; |
|
| 490 | - $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 491 | - $locale["ivDefense"] = $locales->IV_DEFENSE; |
|
| 492 | - $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 493 | - $json['locale'] = $locale; |
|
| 465 | + case 'trainer': |
|
| 466 | + $name = ""; |
|
| 467 | + $page = "0"; |
|
| 468 | + $team = 0; |
|
| 469 | + $ranking = 0; |
|
| 470 | + if (isset($_GET['name'])) { |
|
| 471 | + $trainer_name = $manager->getEcapedString($_GET['name']); |
|
| 472 | + } |
|
| 473 | + if (isset($_GET['team'])) { |
|
| 474 | + $team = $manager->getEcapedString($_GET['team']); |
|
| 475 | + } |
|
| 476 | + if (isset($_GET['page'])) { |
|
| 477 | + $page = $manager->getEcapedString($_GET['page']); |
|
| 478 | + } |
|
| 479 | + if (isset($_GET['ranking'])) { |
|
| 480 | + $ranking = $manager->getEcapedString($_GET['ranking']); |
|
| 481 | + } |
|
| 494 | 482 | |
| 495 | - header('Content-Type: application/json'); |
|
| 496 | - echo json_encode($json); |
|
| 483 | + $trainers = $manager->getTrainers($trainer_name, $team, $page, $ranking); |
|
| 484 | + $json = array(); |
|
| 485 | + $json['trainers'] = $trainers; |
|
| 486 | + $locale = array(); |
|
| 487 | + $locale["today"] = $locales->TODAY; |
|
| 488 | + $locale["day"] = $locales->DAY; |
|
| 489 | + $locale["days"] = $locales->DAYS; |
|
| 490 | + $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 491 | + $locale["ivDefense"] = $locales->IV_DEFENSE; |
|
| 492 | + $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 493 | + $json['locale'] = $locale; |
|
| 497 | 494 | |
| 498 | - break; |
|
| 495 | + header('Content-Type: application/json'); |
|
| 496 | + echo json_encode($json); |
|
| 499 | 497 | |
| 498 | + break; |
|
| 500 | 499 | |
| 501 | - case 'raids': |
|
| 502 | - $page = "0"; |
|
| 503 | - if (isset($_GET['page'])) { |
|
| 504 | - $page = $manager->getEcapedString($_GET['page']); |
|
| 505 | - } |
|
| 506 | 500 | |
| 507 | - $datas = $manager->getAllRaids($page); |
|
| 508 | - $i = 1; |
|
| 509 | - $raids = array(); |
|
| 510 | - foreach ($datas as $data) { |
|
| 511 | - $data->starttime = date("H:i", strtotime($data->start)); |
|
| 512 | - $data->endtime = date("H:i", strtotime($data->end)); |
|
| 513 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 514 | - if (isset($data->move_1)) { |
|
| 515 | - $move1 = $data->move_1; |
|
| 516 | - $data->quick_move = $move->$move1->name; |
|
| 517 | - } else { |
|
| 518 | - $data->quick_move = "?"; |
|
| 501 | + case 'raids': |
|
| 502 | + $page = "0"; |
|
| 503 | + if (isset($_GET['page'])) { |
|
| 504 | + $page = $manager->getEcapedString($_GET['page']); |
|
| 519 | 505 | } |
| 520 | - if (isset($data->move_2)) { |
|
| 521 | - $move2 = $data->move_2; |
|
| 522 | - $data->charge_move = $move->$move2->name; |
|
| 523 | - } else { |
|
| 524 | - $data->charge_move = "?"; |
|
| 506 | + |
|
| 507 | + $datas = $manager->getAllRaids($page); |
|
| 508 | + $i = 1; |
|
| 509 | + $raids = array(); |
|
| 510 | + foreach ($datas as $data) { |
|
| 511 | + $data->starttime = date("H:i", strtotime($data->start)); |
|
| 512 | + $data->endtime = date("H:i", strtotime($data->end)); |
|
| 513 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 514 | + if (isset($data->move_1)) { |
|
| 515 | + $move1 = $data->move_1; |
|
| 516 | + $data->quick_move = $move->$move1->name; |
|
| 517 | + } else { |
|
| 518 | + $data->quick_move = "?"; |
|
| 519 | + } |
|
| 520 | + if (isset($data->move_2)) { |
|
| 521 | + $move2 = $data->move_2; |
|
| 522 | + $data->charge_move = $move->$move2->name; |
|
| 523 | + } else { |
|
| 524 | + $data->charge_move = "?"; |
|
| 525 | + } |
|
| 526 | + $raids[10*$page + $i] = $data; |
|
| 527 | + $i++; |
|
| 525 | 528 | } |
| 526 | - $raids[10*$page + $i] = $data; |
|
| 527 | - $i++; |
|
| 528 | - } |
|
| 529 | - $json = array(); |
|
| 530 | - $json['raids'] = $raids; |
|
| 531 | - $locale = array(); |
|
| 532 | - $locale['noraids'] = $locales->RAIDS_NONE; |
|
| 533 | - $json['locale'] = $locale; |
|
| 529 | + $json = array(); |
|
| 530 | + $json['raids'] = $raids; |
|
| 531 | + $locale = array(); |
|
| 532 | + $locale['noraids'] = $locales->RAIDS_NONE; |
|
| 533 | + $json['locale'] = $locale; |
|
| 534 | 534 | |
| 535 | - header('Content-Type: application/json'); |
|
| 536 | - echo json_encode($json); |
|
| 535 | + header('Content-Type: application/json'); |
|
| 536 | + echo json_encode($json); |
|
| 537 | 537 | |
| 538 | - break; |
|
| 538 | + break; |
|
| 539 | 539 | |
| 540 | 540 | |
| 541 | - case 'gyms': |
|
| 542 | - $page = '0'; |
|
| 543 | - $ranking = 0; |
|
| 544 | - $gym_name = ''; |
|
| 545 | - $team = ''; |
|
| 546 | - if (isset($_GET['name']) && $_GET['name'] != '') { |
|
| 547 | - $gym_name = $manager->getEcapedString($_GET['name']); |
|
| 548 | - } |
|
| 549 | - if (isset($_GET['team']) && $_GET['team'] != '') { |
|
| 550 | - $team = $manager->getEcapedString($_GET['team']); |
|
| 551 | - } |
|
| 552 | - if (isset($_GET['page'])) { |
|
| 553 | - $page = $manager->getEcapedString($_GET['page']); |
|
| 554 | - } |
|
| 555 | - if (isset($_GET['ranking'])) { |
|
| 556 | - $ranking = $manager->getEcapedString($_GET['ranking']); |
|
| 557 | - } |
|
| 541 | + case 'gyms': |
|
| 542 | + $page = '0'; |
|
| 543 | + $ranking = 0; |
|
| 544 | + $gym_name = ''; |
|
| 545 | + $team = ''; |
|
| 546 | + if (isset($_GET['name']) && $_GET['name'] != '') { |
|
| 547 | + $gym_name = $manager->getEcapedString($_GET['name']); |
|
| 548 | + } |
|
| 549 | + if (isset($_GET['team']) && $_GET['team'] != '') { |
|
| 550 | + $team = $manager->getEcapedString($_GET['team']); |
|
| 551 | + } |
|
| 552 | + if (isset($_GET['page'])) { |
|
| 553 | + $page = $manager->getEcapedString($_GET['page']); |
|
| 554 | + } |
|
| 555 | + if (isset($_GET['ranking'])) { |
|
| 556 | + $ranking = $manager->getEcapedString($_GET['ranking']); |
|
| 557 | + } |
|
| 558 | 558 | |
| 559 | 559 | |
| 560 | - $datas = $manager->getGymHistories($gym_name, $team, $page, $ranking); |
|
| 561 | - $gyms = array(); |
|
| 562 | - foreach ($datas as $data) { |
|
| 563 | - $pkm = array(); |
|
| 564 | - if ($data->total_cp > 0) { |
|
| 565 | - $pkm = $manager->getGymHistoriesPokemon($data->gym_id); |
|
| 560 | + $datas = $manager->getGymHistories($gym_name, $team, $page, $ranking); |
|
| 561 | + $gyms = array(); |
|
| 562 | + foreach ($datas as $data) { |
|
| 563 | + $pkm = array(); |
|
| 564 | + if ($data->total_cp > 0) { |
|
| 565 | + $pkm = $manager->getGymHistoriesPokemon($data->gym_id); |
|
| 566 | + } |
|
| 567 | + $data->pokemon = $pkm; |
|
| 568 | + unset($data->pokemon_uids); |
|
| 569 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 570 | + $gyms[] = $data; |
|
| 566 | 571 | } |
| 567 | - $data->pokemon = $pkm; |
|
| 568 | - unset($data->pokemon_uids); |
|
| 569 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 570 | - $gyms[] = $data; |
|
| 571 | - } |
|
| 572 | - $json = array(); |
|
| 573 | - $json['gyms'] = $gyms; |
|
| 574 | - $locale = array(); |
|
| 575 | - $json['locale'] = $locale; |
|
| 572 | + $json = array(); |
|
| 573 | + $json['gyms'] = $gyms; |
|
| 574 | + $locale = array(); |
|
| 575 | + $json['locale'] = $locale; |
|
| 576 | 576 | |
| 577 | - header('Content-Type: application/json'); |
|
| 578 | - echo json_encode($json); |
|
| 577 | + header('Content-Type: application/json'); |
|
| 578 | + echo json_encode($json); |
|
| 579 | 579 | |
| 580 | - break; |
|
| 580 | + break; |
|
| 581 | 581 | |
| 582 | 582 | |
| 583 | 583 | |
| 584 | - case 'gymhistory': |
|
| 585 | - $gym_id = ''; |
|
| 586 | - $page = '0'; |
|
| 587 | - if (isset($_GET['gym_id'])) { |
|
| 588 | - $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
| 589 | - $gym_id = str_replace('_', '.', $gym_id); |
|
| 590 | - } |
|
| 591 | - if (isset($_GET['page'])) { |
|
| 592 | - $page = $manager->getEcapedString($_GET['page']); |
|
| 593 | - } |
|
| 584 | + case 'gymhistory': |
|
| 585 | + $gym_id = ''; |
|
| 586 | + $page = '0'; |
|
| 587 | + if (isset($_GET['gym_id'])) { |
|
| 588 | + $gym_id = $manager->getEcapedString($_GET['gym_id']); |
|
| 589 | + $gym_id = str_replace('_', '.', $gym_id); |
|
| 590 | + } |
|
| 591 | + if (isset($_GET['page'])) { |
|
| 592 | + $page = $manager->getEcapedString($_GET['page']); |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | - $entries = array(); |
|
| 595 | + $entries = array(); |
|
| 596 | 596 | |
| 597 | - $last_page = true; |
|
| 598 | - if ($gym_id != '') { |
|
| 599 | - $datas = $manager->getHistoryForGym($page, $gym_id); |
|
| 600 | - foreach ($datas['data'] as $data) { |
|
| 601 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 602 | - $entries[] = $data; |
|
| 603 | - } |
|
| 604 | - $last_page = $datas['last_page']; |
|
| 605 | - |
|
| 606 | - foreach ($entries as $idx => $entry) { |
|
| 607 | - $entry->total_cp_diff = 0; |
|
| 608 | - $entry->only_cp_changed = true; |
|
| 609 | - if ($idx < count($entries) - 1) { |
|
| 610 | - $next_entry = $entries[$idx+1]; |
|
| 611 | - $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
|
| 612 | - $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
|
| 613 | - $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 614 | - $next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 615 | - $new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon); |
|
| 616 | - $old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon); |
|
| 617 | - foreach ($new_pokemon as $pkm) { |
|
| 618 | - $entry->pokemon[$pkm]->class = 'new'; |
|
| 619 | - } |
|
| 620 | - foreach ($old_pokemon as $pkm) { |
|
| 621 | - $next_entry->pokemon[$pkm]->class = 'old'; |
|
| 622 | - } |
|
| 623 | - if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 624 | - $entry->only_cp_changed = false; |
|
| 597 | + $last_page = true; |
|
| 598 | + if ($gym_id != '') { |
|
| 599 | + $datas = $manager->getHistoryForGym($page, $gym_id); |
|
| 600 | + foreach ($datas['data'] as $data) { |
|
| 601 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 602 | + $entries[] = $data; |
|
| 603 | + } |
|
| 604 | + $last_page = $datas['last_page']; |
|
| 605 | + |
|
| 606 | + foreach ($entries as $idx => $entry) { |
|
| 607 | + $entry->total_cp_diff = 0; |
|
| 608 | + $entry->only_cp_changed = true; |
|
| 609 | + if ($idx < count($entries) - 1) { |
|
| 610 | + $next_entry = $entries[$idx+1]; |
|
| 611 | + $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
|
| 612 | + $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
|
| 613 | + $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 614 | + $next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 615 | + $new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon); |
|
| 616 | + $old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon); |
|
| 617 | + foreach ($new_pokemon as $pkm) { |
|
| 618 | + $entry->pokemon[$pkm]->class = 'new'; |
|
| 619 | + } |
|
| 620 | + foreach ($old_pokemon as $pkm) { |
|
| 621 | + $next_entry->pokemon[$pkm]->class = 'old'; |
|
| 622 | + } |
|
| 623 | + if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 624 | + $entry->only_cp_changed = false; |
|
| 625 | + } |
|
| 625 | 626 | } |
| 627 | + unset($entry->pokemon_uids); |
|
| 626 | 628 | } |
| 627 | - unset($entry->pokemon_uids); |
|
| 629 | + |
|
| 630 | + if (count($entries) > 10) { array_pop($entries); } |
|
| 628 | 631 | } |
| 629 | 632 | |
| 630 | - if (count($entries) > 10) { array_pop($entries); } |
|
| 631 | - } |
|
| 633 | + $json = array(); |
|
| 634 | + $json['entries'] = $entries; |
|
| 635 | + $locale = array(); |
|
| 636 | + $json['locale'] = $locale; |
|
| 637 | + $json['last_page'] = $last_page; |
|
| 632 | 638 | |
| 633 | - $json = array(); |
|
| 634 | - $json['entries'] = $entries; |
|
| 635 | - $locale = array(); |
|
| 636 | - $json['locale'] = $locale; |
|
| 637 | - $json['last_page'] = $last_page; |
|
| 639 | + header('Content-Type: application/json'); |
|
| 640 | + echo json_encode($json); |
|
| 638 | 641 | |
| 639 | - header('Content-Type: application/json'); |
|
| 640 | - echo json_encode($json); |
|
| 642 | + break; |
|
| 641 | 643 | |
| 642 | - break; |
|
| 643 | 644 | |
| 645 | + case 'pokemon_slider_init': |
|
| 646 | + $bounds = $manager->getPokemonSliderMinMax(); |
|
| 644 | 647 | |
| 645 | - case 'pokemon_slider_init': |
|
| 646 | - $bounds = $manager->getPokemonSliderMinMax(); |
|
| 648 | + header('Content-Type: application/json'); |
|
| 649 | + echo json_encode($bounds); |
|
| 647 | 650 | |
| 648 | - header('Content-Type: application/json'); |
|
| 649 | - echo json_encode($bounds); |
|
| 651 | + break; |
|
| 650 | 652 | |
| 651 | - break; |
|
| 652 | 653 | |
| 654 | + case 'pokemon_heatmap_points': |
|
| 655 | + $json = ""; |
|
| 656 | + if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 657 | + $start = date("Y-m-d H:i", (int) $_GET['start']); |
|
| 658 | + $end = date("Y-m-d H:i", (int) $_GET['end']); |
|
| 659 | + $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
| 660 | + $points = $manager->getPokemonHeatmap($pokemon_id, $start, $end); |
|
| 653 | 661 | |
| 654 | - case 'pokemon_heatmap_points': |
|
| 655 | - $json = ""; |
|
| 656 | - if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 657 | - $start = date("Y-m-d H:i", (int) $_GET['start']); |
|
| 658 | - $end = date("Y-m-d H:i", (int) $_GET['end']); |
|
| 659 | - $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
| 660 | - $points = $manager->getPokemonHeatmap($pokemon_id, $start, $end); |
|
| 662 | + $json = json_encode($points); |
|
| 663 | + } |
|
| 661 | 664 | |
| 662 | - $json = json_encode($points); |
|
| 663 | - } |
|
| 665 | + header('Content-Type: application/json'); |
|
| 666 | + echo $json; |
|
| 667 | + break; |
|
| 664 | 668 | |
| 665 | - header('Content-Type: application/json'); |
|
| 666 | - echo $json; |
|
| 667 | - break; |
|
| 668 | 669 | |
| 670 | + case 'maps_localization_coordinates': |
|
| 671 | + $coordinates = $manager->getMapsCoords(); |
|
| 669 | 672 | |
| 670 | - case 'maps_localization_coordinates': |
|
| 671 | - $coordinates = $manager->getMapsCoords(); |
|
| 673 | + header('Content-Type: application/json'); |
|
| 674 | + echo json_encode($coordinates); |
|
| 672 | 675 | |
| 673 | - header('Content-Type: application/json'); |
|
| 674 | - echo json_encode($coordinates); |
|
| 676 | + break; |
|
| 675 | 677 | |
| 676 | - break; |
|
| 677 | 678 | |
| 679 | + case 'pokemon_graph_data': |
|
| 680 | + $json = ""; |
|
| 681 | + if (isset($_GET['pokemon_id'])) { |
|
| 682 | + $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
| 683 | + $array = $manager->getPokemonGraph($pokemon_id); |
|
| 678 | 684 | |
| 679 | - case 'pokemon_graph_data': |
|
| 680 | - $json = ""; |
|
| 681 | - if (isset($_GET['pokemon_id'])) { |
|
| 682 | - $pokemon_id = $manager->getEcapedString($_GET['pokemon_id']); |
|
| 683 | - $array = $manager->getPokemonGraph($pokemon_id); |
|
| 685 | + $json = json_encode($array); |
|
| 686 | + } |
|
| 684 | 687 | |
| 685 | - $json = json_encode($array); |
|
| 686 | - } |
|
| 688 | + header('Content-Type: application/json'); |
|
| 689 | + echo $json; |
|
| 690 | + break; |
|
| 687 | 691 | |
| 688 | - header('Content-Type: application/json'); |
|
| 689 | - echo $json; |
|
| 690 | - break; |
|
| 691 | 692 | |
| 693 | + case 'postRequest': |
|
| 694 | + break; |
|
| 692 | 695 | |
| 693 | - case 'postRequest': |
|
| 696 | + default: |
|
| 697 | + echo "What do you mean?"; |
|
| 698 | + exit(); |
|
| 694 | 699 | break; |
| 695 | - |
|
| 696 | - default: |
|
| 697 | - echo "What do you mean?"; |
|
| 698 | - exit(); |
|
| 699 | - break; |
|
| 700 | 700 | } |
| 701 | 701 | |
| 702 | 702 | if ($postRequest != "") { |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | <script type="text/javascript"> |
| 69 | 69 | <?= |
| 70 | 70 | $gymName = ""; |
| 71 | -if (isset($_GET['name']) && $_GET['name']!="") { |
|
| 71 | +if (isset($_GET['name']) && $_GET['name'] != "") { |
|
| 72 | 72 | $gymName = html_entity_decode($_GET['name']); |
| 73 | 73 | } |
| 74 | 74 | ?> |
@@ -540,9 +540,9 @@ |
||
| 540 | 540 | $trainers = array(); |
| 541 | 541 | while ($data = $result->fetch_object()) { |
| 542 | 542 | $data->last_seen = date("Y-m-d", strtotime($data->last_seen)); |
| 543 | - if (is_null($data->active)) { |
|
| 544 | - $data->active = 0; |
|
| 545 | - } |
|
| 543 | + if (is_null($data->active)) { |
|
| 544 | + $data->active = 0; |
|
| 545 | + } |
|
| 546 | 546 | $trainers[$data->name] = $data; |
| 547 | 547 | |
| 548 | 548 | $pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name)); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina, |
| 168 | 168 | ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form |
| 169 | 169 | FROM sightings |
| 170 | - WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
| 170 | + WHERE pokemon_id = '" . $pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
| 171 | 171 | ORDER BY $top_order_by $top_direction, expire_timestamp DESC |
| 172 | 172 | LIMIT 0,50"; |
| 173 | 173 | |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) { |
| 183 | 183 | $trainer_blacklist = ""; |
| 184 | 184 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 185 | - $trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')"; |
|
| 185 | + $trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | $req = "SELECT owner_name as trainer_name, ROUND((100*((atk_iv)+(def_iv)+(sta_iv))/45),1) AS IV, move_1, move_2, cp as cp, |
| 189 | 189 | FROM_UNIXTIME(last_modified) AS lasttime, last_modified as last_seen |
| 190 | 190 | FROM gym_defenders |
| 191 | - WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . " |
|
| 191 | + WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist." |
|
| 192 | 192 | ORDER BY $best_order_by $best_direction, owner_name ASC |
| 193 | 193 | LIMIT 0,50"; |
| 194 | 194 | |
@@ -230,9 +230,9 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) { |
| 232 | 232 | $inmap_pkms_filter = ""; |
| 233 | - $where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 233 | + $where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = ".$pokemon_id; |
|
| 234 | 234 | |
| 235 | - $reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where; |
|
| 235 | + $reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings ".$where; |
|
| 236 | 236 | $resultTestIv = $this->mysqli->query($reqTestIv); |
| 237 | 237 | $testIv = $resultTestIv->fetch_object(); |
| 238 | 238 | if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) { |
@@ -240,20 +240,20 @@ discard block |
||
| 240 | 240 | $inmap_pkms_filter .= "'".$inmap."',"; |
| 241 | 241 | } |
| 242 | 242 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
| 243 | - $where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") "; |
|
| 243 | + $where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") "; |
|
| 244 | 244 | } |
| 245 | 245 | if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) { |
| 246 | - $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") "; |
|
| 246 | + $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (".$ivMin.") "; |
|
| 247 | 247 | } |
| 248 | 248 | if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) { |
| 249 | - $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") "; |
|
| 249 | + $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (".$ivMax.") "; |
|
| 250 | 250 | } |
| 251 | 251 | $req = "SELECT pokemon_id, lat AS latitude, lon AS longitude, |
| 252 | 252 | FROM_UNIXTIME(expire_timestamp) AS disappear_time, |
| 253 | 253 | FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, |
| 254 | 254 | atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina, |
| 255 | 255 | move_1, move_2 |
| 256 | - FROM sightings " . $where . " |
|
| 256 | + FROM sightings " . $where." |
|
| 257 | 257 | LIMIT 5000"; |
| 258 | 258 | $result = $this->mysqli->query($req); |
| 259 | 259 | $spawns = array(); |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points |
| 344 | 344 | FROM forts f |
| 345 | 345 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
| 346 | - WHERE fs.team = '" . $team_id . "'"; |
|
| 346 | + WHERE fs.team = '" . $team_id."'"; |
|
| 347 | 347 | $result = $this->mysqli->query($req); |
| 348 | 348 | $data = $result->fetch_object(); |
| 349 | 349 | return $data; |
@@ -449,7 +449,7 @@ discard block |
||
| 449 | 449 | { |
| 450 | 450 | $req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name |
| 451 | 451 | FROM gym_defenders |
| 452 | - WHERE fort_id = '". $gym_id ."' |
|
| 452 | + WHERE fort_id = '". $gym_id."' |
|
| 453 | 453 | ORDER BY deployment_time"; |
| 454 | 454 | $result = $this->mysqli->query($req); |
| 455 | 455 | $pokemons = array(); |
@@ -469,9 +469,9 @@ discard block |
||
| 469 | 469 | $req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, FROM_UNIXTIME(fs.last_modified) as last_modified, last_modified as last_modified_real |
| 470 | 470 | FROM fort_sightings fs |
| 471 | 471 | LEFT JOIN forts f ON f.id = fs.fort_id |
| 472 | - WHERE f.id = '". $gym_id ."' |
|
| 472 | + WHERE f.id = '". $gym_id."' |
|
| 473 | 473 | ORDER BY fs.last_modified DESC |
| 474 | - LIMIT ".($page * $pageSize).",".($pageSize+1); |
|
| 474 | + LIMIT ".($page * $pageSize).",".($pageSize + 1); |
|
| 475 | 475 | $result = $this->mysqli->query($req); |
| 476 | 476 | $history = array(); |
| 477 | 477 | $count = 0; |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name |
| 504 | 504 | FROM gym_history_defenders ghd |
| 505 | 505 | JOIN gym_defenders gd ON ghd.defender_id = gd.external_id |
| 506 | - WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."' |
|
| 506 | + WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."' |
|
| 507 | 507 | ORDER BY gd.deployment_time"; |
| 508 | 508 | $result = $this->mysqli->query($req); |
| 509 | 509 | $pokemons = array(); |
@@ -551,8 +551,8 @@ discard block |
||
| 551 | 551 | WHERE fort_id IS NOT NULL |
| 552 | 552 | GROUP BY owner_name |
| 553 | 553 | ) active ON active.owner_name = gd.owner_name |
| 554 | - WHERE gd.owner_level IS NOT NULL " . $where . " |
|
| 555 | - GROUP BY gd.owner_name" . $order . $limit; |
|
| 554 | + WHERE gd.owner_level IS NOT NULL " . $where." |
|
| 555 | + GROUP BY gd.owner_name" . $order.$limit; |
|
| 556 | 556 | $result = $this->mysqli->query($req); |
| 557 | 557 | $trainers = array(); |
| 558 | 558 | while ($data = $result->fetch_object()) { |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | $trainers[$data->name] = $data; |
| 564 | 564 | |
| 565 | - $pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name)); |
|
| 565 | + $pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name)); |
|
| 566 | 566 | |
| 567 | 567 | $trainers[$data->name]->gyms = $data->active; |
| 568 | 568 | $trainers[$data->name]->pokemons = $pokemon; |
@@ -678,13 +678,13 @@ discard block |
||
| 678 | 678 | public function getNestData() { |
| 679 | 679 | $pokemon_exclude_sql = ""; |
| 680 | 680 | if (!empty(self::$config->system->nest_exclude_pokemon)) { |
| 681 | - $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")"; |
|
| 681 | + $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")"; |
|
| 682 | 682 | } |
| 683 | 683 | $req = "SELECT p.pokemon_id, MAX(p.lat) AS latitude, MAX(p.lon) AS longitude, count(p.pokemon_id) AS total_pokemon, MAX(s.updated) as latest_seen, coalesce(CASE WHEN MAX(duration) = 0 THEN NULL ELSE MAX(duration) END ,30)*60 as duration |
| 684 | 684 | FROM sightings p |
| 685 | 685 | INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id) |
| 686 | 686 | WHERE p.expire_timestamp > UNIX_TIMESTAMP() - 86400 |
| 687 | - " . $pokemon_exclude_sql . " |
|
| 687 | + " . $pokemon_exclude_sql." |
|
| 688 | 688 | GROUP BY p.spawn_id, p.pokemon_id |
| 689 | 689 | HAVING COUNT(p.pokemon_id) >= 6 |
| 690 | 690 | ORDER BY p.pokemon_id"; |
@@ -1,12 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql { |
|
| 3 | +class QueryManagerMysqlMonocleAlternate extends QueryManagerMysql |
|
| 4 | +{ |
|
| 4 | 5 | |
| 5 | - public function __construct() { |
|
| 6 | + public function __construct() |
|
| 7 | + { |
|
| 6 | 8 | parent::__construct(); |
| 7 | 9 | } |
| 8 | 10 | |
| 9 | - public function __destruct() { |
|
| 11 | + public function __destruct() |
|
| 12 | + { |
|
| 10 | 13 | parent::__destruct(); |
| 11 | 14 | } |
| 12 | 15 | |
@@ -14,7 +17,8 @@ discard block |
||
| 14 | 17 | // Tester |
| 15 | 18 | /////////// |
| 16 | 19 | |
| 17 | - function testTotalPokemon() { |
|
| 20 | + function testTotalPokemon() |
|
| 21 | + { |
|
| 18 | 22 | $req = "SELECT COUNT(*) as total FROM sightings"; |
| 19 | 23 | $result = $this->mysqli->query($req); |
| 20 | 24 | if (!is_object($result)) { |
@@ -30,7 +34,8 @@ discard block |
||
| 30 | 34 | return 0; |
| 31 | 35 | } |
| 32 | 36 | |
| 33 | - function testTotalGyms() { |
|
| 37 | + function testTotalGyms() |
|
| 38 | + { |
|
| 34 | 39 | $req = "SELECT COUNT(*) as total FROM forts"; |
| 35 | 40 | $result = $this->mysqli->query($req); |
| 36 | 41 | if (!is_object($result)) { |
@@ -46,7 +51,8 @@ discard block |
||
| 46 | 51 | return 0; |
| 47 | 52 | } |
| 48 | 53 | |
| 49 | - function testTotalPokestops() { |
|
| 54 | + function testTotalPokestops() |
|
| 55 | + { |
|
| 50 | 56 | $req = "SELECT COUNT(*) as total FROM pokestops"; |
| 51 | 57 | $result = $this->mysqli->query($req); |
| 52 | 58 | if (!is_object($result)) { |
@@ -67,26 +73,30 @@ discard block |
||
| 67 | 73 | // Homepage |
| 68 | 74 | ///////////// |
| 69 | 75 | |
| 70 | - function getTotalPokemon() { |
|
| 76 | + function getTotalPokemon() |
|
| 77 | + { |
|
| 71 | 78 | $req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP()"; |
| 72 | 79 | $result = $this->mysqli->query($req); |
| 73 | 80 | $data = $result->fetch_object(); |
| 74 | 81 | return $data; |
| 75 | 82 | } |
| 76 | 83 | |
| 77 | - function getTotalLures() { |
|
| 84 | + function getTotalLures() |
|
| 85 | + { |
|
| 78 | 86 | $data = (object) array("total" => 0); |
| 79 | 87 | return $data; |
| 80 | 88 | } |
| 81 | 89 | |
| 82 | - function getTotalGyms() { |
|
| 90 | + function getTotalGyms() |
|
| 91 | + { |
|
| 83 | 92 | $req = "SELECT COUNT(*) AS total FROM forts"; |
| 84 | 93 | $result = $this->mysqli->query($req); |
| 85 | 94 | $data = $result->fetch_object(); |
| 86 | 95 | return $data; |
| 87 | 96 | } |
| 88 | 97 | |
| 89 | - function getTotalRaids() { |
|
| 98 | + function getTotalRaids() |
|
| 99 | + { |
|
| 90 | 100 | $req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= UNIX_TIMESTAMP() AND time_end >= UNIX_TIMESTAMP()"; |
| 91 | 101 | $result = $this->mysqli->query($req); |
| 92 | 102 | $data = $result->fetch_object(); |
@@ -94,7 +104,8 @@ discard block |
||
| 94 | 104 | } |
| 95 | 105 | |
| 96 | 106 | |
| 97 | - function getTotalGymsForTeam($team_id) { |
|
| 107 | + function getTotalGymsForTeam($team_id) |
|
| 108 | + { |
|
| 98 | 109 | $req = "SELECT COUNT(*) AS total |
| 99 | 110 | FROM forts f |
| 100 | 111 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -104,7 +115,8 @@ discard block |
||
| 104 | 115 | return $data; |
| 105 | 116 | } |
| 106 | 117 | |
| 107 | - function getRecentAll() { |
|
| 118 | + function getRecentAll() |
|
| 119 | + { |
|
| 108 | 120 | $req = "SELECT DISTINCT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, |
| 109 | 121 | lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina |
| 110 | 122 | FROM sightings |
@@ -120,7 +132,8 @@ discard block |
||
| 120 | 132 | return $data; |
| 121 | 133 | } |
| 122 | 134 | |
| 123 | - function getRecentMythic($mythic_pokemon) { |
|
| 135 | + function getRecentMythic($mythic_pokemon) |
|
| 136 | + { |
|
| 124 | 137 | $req = "SELECT pokemon_id, encounter_id, FROM_UNIXTIME(expire_timestamp) AS disappear_time, FROM_UNIXTIME(updated) AS last_modified, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, |
| 125 | 138 | lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina |
| 126 | 139 | FROM sightings |
@@ -141,7 +154,8 @@ discard block |
||
| 141 | 154 | // Single Pokemon |
| 142 | 155 | /////////////////// |
| 143 | 156 | |
| 144 | - function getGymsProtectedByPokemon($pokemon_id) { |
|
| 157 | + function getGymsProtectedByPokemon($pokemon_id) |
|
| 158 | + { |
|
| 145 | 159 | $req = "SELECT COUNT(f.id) AS total |
| 146 | 160 | FROM forts f |
| 147 | 161 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -151,7 +165,8 @@ discard block |
||
| 151 | 165 | return $data; |
| 152 | 166 | } |
| 153 | 167 | |
| 154 | - function getPokemonLastSeen($pokemon_id) { |
|
| 168 | + function getPokemonLastSeen($pokemon_id) |
|
| 169 | + { |
|
| 155 | 170 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS expire_timestamp, FROM_UNIXTIME(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude |
| 156 | 171 | FROM sightings |
| 157 | 172 | WHERE pokemon_id = '".$pokemon_id."' |
@@ -162,7 +177,8 @@ discard block |
||
| 162 | 177 | return $data; |
| 163 | 178 | } |
| 164 | 179 | |
| 165 | - function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) { |
|
| 180 | + function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) |
|
| 181 | + { |
|
| 166 | 182 | $req = "SELECT FROM_UNIXTIME(expire_timestamp) AS distime, pokemon_id as pokemon_id, FROM_UNIXTIME(expire_timestamp) as disappear_time, lat as latitude, lon as longitude, |
| 167 | 183 | cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina, |
| 168 | 184 | ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS IV, move_1 as move_1, move_2, form |
@@ -179,7 +195,8 @@ discard block |
||
| 179 | 195 | return $top; |
| 180 | 196 | } |
| 181 | 197 | |
| 182 | - function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) { |
|
| 198 | + function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) |
|
| 199 | + { |
|
| 183 | 200 | $trainer_blacklist = ""; |
| 184 | 201 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 185 | 202 | $trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')"; |
@@ -200,7 +217,8 @@ discard block |
||
| 200 | 217 | return $toptrainer; |
| 201 | 218 | } |
| 202 | 219 | |
| 203 | - public function getPokemonHeatmap($pokemon_id, $start, $end) { |
|
| 220 | + public function getPokemonHeatmap($pokemon_id, $start, $end) |
|
| 221 | + { |
|
| 204 | 222 | $where = " WHERE pokemon_id = ".$pokemon_id." " |
| 205 | 223 | . "AND FROM_UNIXTIME(expire_timestamp) BETWEEN '".$start."' AND '".$end."'"; |
| 206 | 224 | $req = "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000"; |
@@ -212,7 +230,8 @@ discard block |
||
| 212 | 230 | return $points; |
| 213 | 231 | } |
| 214 | 232 | |
| 215 | - public function getPokemonGraph($pokemon_id) { |
|
| 233 | + public function getPokemonGraph($pokemon_id) |
|
| 234 | + { |
|
| 216 | 235 | $req = "SELECT COUNT(*) AS total, HOUR(disappear_time) AS disappear_hour |
| 217 | 236 | FROM (SELECT FROM_UNIXTIME(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered |
| 218 | 237 | GROUP BY disappear_hour |
@@ -228,7 +247,8 @@ discard block |
||
| 228 | 247 | return $array; |
| 229 | 248 | } |
| 230 | 249 | |
| 231 | - public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) { |
|
| 250 | + public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) |
|
| 251 | + { |
|
| 232 | 252 | $inmap_pkms_filter = ""; |
| 233 | 253 | $where = " WHERE expire_timestamp >= UNIX_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
| 234 | 254 | |
@@ -263,21 +283,24 @@ discard block |
||
| 263 | 283 | return $spawns; |
| 264 | 284 | } |
| 265 | 285 | |
| 266 | - public function getPokemonSliderMinMax() { |
|
| 286 | + public function getPokemonSliderMinMax() |
|
| 287 | + { |
|
| 267 | 288 | $req = "SELECT FROM_UNIXTIME(MIN(expire_timestamp)) AS min, FROM_UNIXTIME(MAX(expire_timestamp)) AS max FROM sightings"; |
| 268 | 289 | $result = $this->mysqli->query($req); |
| 269 | 290 | $data = $result->fetch_object(); |
| 270 | 291 | return $data; |
| 271 | 292 | } |
| 272 | 293 | |
| 273 | - public function getMapsCoords() { |
|
| 294 | + public function getMapsCoords() |
|
| 295 | + { |
|
| 274 | 296 | $req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints"; |
| 275 | 297 | $result = $this->mysqli->query($req); |
| 276 | 298 | $data = $result->fetch_object(); |
| 277 | 299 | return $data; |
| 278 | 300 | } |
| 279 | 301 | |
| 280 | - public function getPokemonCount($pokemon_id) { |
|
| 302 | + public function getPokemonCount($pokemon_id) |
|
| 303 | + { |
|
| 281 | 304 | $req = "SELECT count, last_seen, latitude, longitude |
| 282 | 305 | FROM pokemon_stats |
| 283 | 306 | WHERE pid = ".$pokemon_id; |
@@ -286,7 +309,8 @@ discard block |
||
| 286 | 309 | return $data; |
| 287 | 310 | } |
| 288 | 311 | |
| 289 | - public function getRaidCount($pokemon_id) { |
|
| 312 | + public function getRaidCount($pokemon_id) |
|
| 313 | + { |
|
| 290 | 314 | $req = "SELECT count, last_seen, latitude, longitude |
| 291 | 315 | FROM raid_stats |
| 292 | 316 | WHERE pid = ".$pokemon_id; |
@@ -302,14 +326,16 @@ discard block |
||
| 302 | 326 | ////////////// |
| 303 | 327 | |
| 304 | 328 | |
| 305 | - function getTotalPokestops() { |
|
| 329 | + function getTotalPokestops() |
|
| 330 | + { |
|
| 306 | 331 | $req = "SELECT COUNT(*) as total FROM pokestops"; |
| 307 | 332 | $result = $this->mysqli->query($req); |
| 308 | 333 | $data = $result->fetch_object(); |
| 309 | 334 | return $data; |
| 310 | 335 | } |
| 311 | 336 | |
| 312 | - public function getAllPokestops() { |
|
| 337 | + public function getAllPokestops() |
|
| 338 | + { |
|
| 313 | 339 | $req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, UNIX_TIMESTAMP() AS now, null AS lure_expiration_real FROM pokestops"; |
| 314 | 340 | $result = $this->mysqli->query($req); |
| 315 | 341 | $pokestops = array(); |
@@ -324,7 +350,8 @@ discard block |
||
| 324 | 350 | // Gyms |
| 325 | 351 | ///////// |
| 326 | 352 | |
| 327 | - function getTeamGuardians($team_id) { |
|
| 353 | + function getTeamGuardians($team_id) |
|
| 354 | + { |
|
| 328 | 355 | $req = "SELECT COUNT(*) AS total, guard_pokemon_id |
| 329 | 356 | FROM forts f |
| 330 | 357 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -339,7 +366,8 @@ discard block |
||
| 339 | 366 | return $datas; |
| 340 | 367 | } |
| 341 | 368 | |
| 342 | - function getOwnedAndPoints($team_id) { |
|
| 369 | + function getOwnedAndPoints($team_id) |
|
| 370 | + { |
|
| 343 | 371 | $req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp)) AS average_points |
| 344 | 372 | FROM forts f |
| 345 | 373 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -349,7 +377,8 @@ discard block |
||
| 349 | 377 | return $data; |
| 350 | 378 | } |
| 351 | 379 | |
| 352 | - function getAllGyms() { |
|
| 380 | + function getAllGyms() |
|
| 381 | + { |
|
| 353 | 382 | $req = "SELECT f.id as gym_id, team as team_id, f.lat as latitude, f.lon as longitude, updated as last_scanned, (6 - fs.slots_available) AS level |
| 354 | 383 | FROM forts f |
| 355 | 384 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id));"; |
@@ -361,7 +390,8 @@ discard block |
||
| 361 | 390 | return $gyms; |
| 362 | 391 | } |
| 363 | 392 | |
| 364 | - public function getGymData($gym_id) { |
|
| 393 | + public function getGymData($gym_id) |
|
| 394 | + { |
|
| 365 | 395 | $req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, FROM_UNIXTIME(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp |
| 366 | 396 | FROM forts f |
| 367 | 397 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -371,7 +401,8 @@ discard block |
||
| 371 | 401 | return $data; |
| 372 | 402 | } |
| 373 | 403 | |
| 374 | - public function getGymDefenders($gym_id) { |
|
| 404 | + public function getGymDefenders($gym_id) |
|
| 405 | + { |
|
| 375 | 406 | $req = "SELECT external_id as pokemon_uid, pokemon_id, atk_iv as iv_attack, def_iv as iv_defense, sta_iv as iv_stamina, cp, fort_id as gym_id |
| 376 | 407 | FROM gym_defenders |
| 377 | 408 | WHERE fort_id='".$gym_id."' |
@@ -389,7 +420,8 @@ discard block |
||
| 389 | 420 | // Raids |
| 390 | 421 | /////////// |
| 391 | 422 | |
| 392 | - public function getAllRaids($page) { |
|
| 423 | + public function getAllRaids($page) |
|
| 424 | + { |
|
| 393 | 425 | $limit = " LIMIT ".($page * 10).",10"; |
| 394 | 426 | $req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, FROM_UNIXTIME(r.time_spawn) AS spawn, FROM_UNIXTIME(r.time_battle) AS start, FROM_UNIXTIME(r.time_end) AS end, FROM_UNIXTIME(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude |
| 395 | 427 | FROM forts f |
@@ -519,7 +551,8 @@ discard block |
||
| 519 | 551 | // Trainers |
| 520 | 552 | ////////////// |
| 521 | 553 | |
| 522 | - public function getTrainers($trainer_name, $team, $page, $rankingNumber) { |
|
| 554 | + public function getTrainers($trainer_name, $team, $page, $rankingNumber) |
|
| 555 | + { |
|
| 523 | 556 | $ranking = $this->getTrainerLevelRanking(); |
| 524 | 557 | $where = ""; |
| 525 | 558 | if (!empty(self::$config->system->trainer_blacklist)) { |
@@ -571,7 +604,8 @@ discard block |
||
| 571 | 604 | return $trainers; |
| 572 | 605 | } |
| 573 | 606 | |
| 574 | - public function getTrainerLevelRanking() { |
|
| 607 | + public function getTrainerLevelRanking() |
|
| 608 | + { |
|
| 575 | 609 | $exclue = ""; |
| 576 | 610 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 577 | 611 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -592,7 +626,8 @@ discard block |
||
| 592 | 626 | return $levelData; |
| 593 | 627 | } |
| 594 | 628 | |
| 595 | - public function getActivePokemon($trainer_name) { |
|
| 629 | + public function getActivePokemon($trainer_name) |
|
| 630 | + { |
|
| 596 | 631 | $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, FROM_UNIXTIME(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned |
| 597 | 632 | FROM gym_defenders |
| 598 | 633 | WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL |
@@ -605,7 +640,8 @@ discard block |
||
| 605 | 640 | return $pokemon; |
| 606 | 641 | } |
| 607 | 642 | |
| 608 | - public function getInactivePokemon($trainer_name) { |
|
| 643 | + public function getInactivePokemon($trainer_name) |
|
| 644 | + { |
|
| 609 | 645 | $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, NULL AS deployment_time, '0' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned |
| 610 | 646 | FROM gym_defenders |
| 611 | 647 | WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL |
@@ -618,7 +654,8 @@ discard block |
||
| 618 | 654 | return $pokemon; |
| 619 | 655 | } |
| 620 | 656 | |
| 621 | - public function getTrainerLevelCount($team_id) { |
|
| 657 | + public function getTrainerLevelCount($team_id) |
|
| 658 | + { |
|
| 622 | 659 | $exclue = ""; |
| 623 | 660 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 624 | 661 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -644,7 +681,8 @@ discard block |
||
| 644 | 681 | // Cron |
| 645 | 682 | ///////// |
| 646 | 683 | |
| 647 | - public function getPokemonCountsActive() { |
|
| 684 | + public function getPokemonCountsActive() |
|
| 685 | + { |
|
| 648 | 686 | $req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= UNIX_TIMESTAMP() GROUP BY pokemon_id"; |
| 649 | 687 | $result = $this->mysqli->query($req); |
| 650 | 688 | $counts = array(); |
@@ -654,7 +692,8 @@ discard block |
||
| 654 | 692 | return $counts; |
| 655 | 693 | } |
| 656 | 694 | |
| 657 | - public function getPokemonCountsLastDay() { |
|
| 695 | + public function getPokemonCountsLastDay() |
|
| 696 | + { |
|
| 658 | 697 | $req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day |
| 659 | 698 | FROM sightings |
| 660 | 699 | WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings) |
@@ -668,14 +707,16 @@ discard block |
||
| 668 | 707 | return $counts; |
| 669 | 708 | } |
| 670 | 709 | |
| 671 | - public function getCaptchaCount() { |
|
| 710 | + public function getCaptchaCount() |
|
| 711 | + { |
|
| 672 | 712 | $req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL"; |
| 673 | 713 | $result = $this->mysqli->query($req); |
| 674 | 714 | $data = $result->fetch_object(); |
| 675 | 715 | return $data; |
| 676 | 716 | } |
| 677 | 717 | |
| 678 | - public function getNestData() { |
|
| 718 | + public function getNestData() |
|
| 719 | + { |
|
| 679 | 720 | $pokemon_exclude_sql = ""; |
| 680 | 721 | if (!empty(self::$config->system->nest_exclude_pokemon)) { |
| 681 | 722 | $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")"; |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | // Load Query Manager |
| 30 | 30 | // ################### |
| 31 | 31 | |
| 32 | -include_once __DIR__ . '/../process/queries/QueryManager.php'; |
|
| 32 | +include_once __DIR__.'/../process/queries/QueryManager.php'; |
|
| 33 | 33 | $manager = QueryManager::current(); |
| 34 | 34 | |
| 35 | 35 | |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina, |
| 174 | 174 | ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form |
| 175 | 175 | FROM sightings |
| 176 | - WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
| 176 | + WHERE pokemon_id = '" . $pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
| 177 | 177 | ORDER BY $top_order_by $top_direction, expire_timestamp DESC |
| 178 | 178 | LIMIT 50 OFFSET 0"; |
| 179 | 179 | $result = pg_query($this->db, $req); |
@@ -187,13 +187,13 @@ discard block |
||
| 187 | 187 | function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) { |
| 188 | 188 | $trainer_blacklist = ""; |
| 189 | 189 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 190 | - $trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')"; |
|
| 190 | + $trainer_blacklist = " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | $req = "SELECT owner_name as trainer_name, ROUND((100.0*((atk_iv)+(def_iv)+(sta_iv))/45),1) AS \"IV\", move_1, move_2, cp as cp, |
| 194 | 194 | TO_TIMESTAMP(last_modified) AS lasttime, last_modified as last_seen |
| 195 | 195 | FROM gym_defenders |
| 196 | - WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . " |
|
| 196 | + WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist." |
|
| 197 | 197 | ORDER BY $best_order_by $best_direction, owner_name ASC |
| 198 | 198 | LIMIT 50 OFFSET 0"; |
| 199 | 199 | |
@@ -235,9 +235,9 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) { |
| 237 | 237 | $inmap_pkms_filter = ""; |
| 238 | - $where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id; |
|
| 238 | + $where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = ".$pokemon_id; |
|
| 239 | 239 | |
| 240 | - $reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings " . $where; |
|
| 240 | + $reqTestIv = "SELECT MAX(atk_iv) AS iv FROM sightings ".$where; |
|
| 241 | 241 | $resultTestIv = pg_query($this->db, $reqTestIv); |
| 242 | 242 | $testIv = pg_fetch_object($resultTestIv); |
| 243 | 243 | if (!is_null($inmap_pokemons) && ($inmap_pokemons != "")) { |
@@ -245,20 +245,20 @@ discard block |
||
| 245 | 245 | $inmap_pkms_filter .= "'".$inmap."',"; |
| 246 | 246 | } |
| 247 | 247 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
| 248 | - $where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") "; |
|
| 248 | + $where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") "; |
|
| 249 | 249 | } |
| 250 | 250 | if ($testIv->iv != null && !is_null($ivMin) && ($ivMin != "")) { |
| 251 | - $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (" . $ivMin . ") "; |
|
| 251 | + $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) >= (".$ivMin.") "; |
|
| 252 | 252 | } |
| 253 | 253 | if ($testIv->iv != null && !is_null($ivMax) && ($ivMax != "")) { |
| 254 | - $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (" . $ivMax . ") "; |
|
| 254 | + $where .= " AND ((100/45)*(atk_iv + def_iv + sta_iv)) <= (".$ivMax.") "; |
|
| 255 | 255 | } |
| 256 | 256 | $req = "SELECT pokemon_id, lat AS latitude, lon AS longitude, |
| 257 | 257 | TO_TIMESTAMP(expire_timestamp) AS disappear_time, |
| 258 | 258 | TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, |
| 259 | 259 | atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina, |
| 260 | 260 | move_1, move_2 |
| 261 | - FROM sightings " . $where . " |
|
| 261 | + FROM sightings " . $where." |
|
| 262 | 262 | LIMIT 5000"; |
| 263 | 263 | $result = pg_query($this->db, $req); |
| 264 | 264 | $spawns = array(); |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | $req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points |
| 348 | 348 | FROM forts f |
| 349 | 349 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
| 350 | - WHERE fs.team = '" . $team_id . "'"; |
|
| 350 | + WHERE fs.team = '" . $team_id."'"; |
|
| 351 | 351 | $result = pg_query($this->db, $req); |
| 352 | 352 | $data = pg_fetch_object($result); |
| 353 | 353 | return $data; |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | { |
| 435 | 435 | $req = "SELECT external_id AS pokemon_uid, pokemon_id, cp_now as cp, owner_name AS trainer_name |
| 436 | 436 | FROM gym_defenders |
| 437 | - WHERE fort_id = '". $gym_id ."' |
|
| 437 | + WHERE fort_id = '". $gym_id."' |
|
| 438 | 438 | ORDER BY deployment_time"; |
| 439 | 439 | $result = $this->mysqli->query($req); |
| 440 | 440 | $pokemons = array(); |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | $req = "SELECT f.id as gym_id, fs.team as team_id, total_cp, TO_TIMESTAMP(fs.last_modified) as last_modified, last_modified as last_modified_real |
| 455 | 455 | FROM fort_sightings fs |
| 456 | 456 | LEFT JOIN forts f ON f.id = fs.fort_id |
| 457 | - WHERE f.id = '". $gym_id ."' |
|
| 457 | + WHERE f.id = '". $gym_id."' |
|
| 458 | 458 | ORDER BY fs.last_modified DESC |
| 459 | - LIMIT ".($pageSize+1)." OFFSET ".($page * $pageSize); |
|
| 459 | + LIMIT ".($pageSize + 1)." OFFSET ".($page * $pageSize); |
|
| 460 | 460 | $result = $this->mysqli->query($req); |
| 461 | 461 | $history = array(); |
| 462 | 462 | $count = 0; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $req = "SELECT ghd.defender_id, gd.pokemon_id, ghd.cp, gd.owner_name as trainer_name |
| 489 | 489 | FROM gym_history_defenders ghd |
| 490 | 490 | JOIN gym_defenders gd ON ghd.defender_id = gd.external_id |
| 491 | - WHERE ghd.fort_id = '". $gym_id ."' AND date = '".$last_modified."' |
|
| 491 | + WHERE ghd.fort_id = '". $gym_id."' AND date = '".$last_modified."' |
|
| 492 | 492 | ORDER BY gd.deployment_time"; |
| 493 | 493 | $result = $this->mysqli->query($req); |
| 494 | 494 | $pokemons = array(); |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | /////////// |
| 504 | 504 | |
| 505 | 505 | public function getAllRaids($page) { |
| 506 | - $limit = " LIMIT 10 OFFSET ". ($page * 10); |
|
| 506 | + $limit = " LIMIT 10 OFFSET ".($page * 10); |
|
| 507 | 507 | $req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude |
| 508 | 508 | FROM forts f |
| 509 | 509 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -555,8 +555,8 @@ discard block |
||
| 555 | 555 | WHERE fort_id IS NOT NULL |
| 556 | 556 | GROUP BY owner_name |
| 557 | 557 | ) active ON active.owner_name = gd.owner_name |
| 558 | - WHERE level IS NOT NULL " . $where . " |
|
| 559 | - GROUP BY gd.owner_name" . $order . $limit; |
|
| 558 | + WHERE level IS NOT NULL " . $where." |
|
| 559 | + GROUP BY gd.owner_name" . $order.$limit; |
|
| 560 | 560 | $result = $this->mysqli->query($req); |
| 561 | 561 | $trainers = array(); |
| 562 | 562 | while ($data = $result->fetch_object()) { |
@@ -566,7 +566,7 @@ discard block |
||
| 566 | 566 | } |
| 567 | 567 | $trainers[$data->name] = $data; |
| 568 | 568 | |
| 569 | - $pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name)); |
|
| 569 | + $pokemon = array_merge($this->getActivePokemon($data->name), $this->getInactivePokemon($data->name)); |
|
| 570 | 570 | |
| 571 | 571 | $trainers[$data->name]->gyms = $data->active; |
| 572 | 572 | $trainers[$data->name]->pokemons = $pokemon; |
@@ -683,13 +683,13 @@ discard block |
||
| 683 | 683 | public function getNestData() { |
| 684 | 684 | $pokemon_exclude_sql = ""; |
| 685 | 685 | if (!empty(self::$config->system->nest_exclude_pokemon)) { |
| 686 | - $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")"; |
|
| 686 | + $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")"; |
|
| 687 | 687 | } |
| 688 | 688 | $req = "SELECT p.spawn_id, p.pokemon_id, MAX(p.lat) AS latitude, MAX(p.lon) AS longitude, count(p.pokemon_id) AS total_pokemon, MAX(s.updated) as latest_seen, coalesce(CASE WHEN MAX(duration) = 0 THEN NULL ELSE MAX(duration) END ,30)*60 as duration |
| 689 | 689 | FROM sightings p |
| 690 | 690 | INNER JOIN spawnpoints s ON (p.spawn_id = s.spawn_id) |
| 691 | 691 | WHERE p.expire_timestamp > EXTRACT(EPOCH FROM NOW()) - 86400 |
| 692 | - " . $pokemon_exclude_sql . " |
|
| 692 | + " . $pokemon_exclude_sql." |
|
| 693 | 693 | GROUP BY p.spawn_id, p.pokemon_id |
| 694 | 694 | HAVING COUNT(p.pokemon_id) >= 6 |
| 695 | 695 | ORDER BY p.pokemon_id"; |
@@ -6,13 +6,16 @@ discard block |
||
| 6 | 6 | * Time: 02:26 |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql { |
|
| 9 | +class QueryManagerPostgresqlMonocleAlternate extends QueryManagerPostgresql |
|
| 10 | +{ |
|
| 10 | 11 | |
| 11 | - public function __construct() { |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 12 | 14 | parent::__construct(); |
| 13 | 15 | } |
| 14 | 16 | |
| 15 | - public function __destruct() { |
|
| 17 | + public function __destruct() |
|
| 18 | + { |
|
| 16 | 19 | parent::__destruct(); |
| 17 | 20 | } |
| 18 | 21 | |
@@ -20,7 +23,8 @@ discard block |
||
| 20 | 23 | // Tester |
| 21 | 24 | /////////// |
| 22 | 25 | |
| 23 | - function testTotalPokemon() { |
|
| 26 | + function testTotalPokemon() |
|
| 27 | + { |
|
| 24 | 28 | $req = "SELECT COUNT(*) as total FROM sightings"; |
| 25 | 29 | $result = pg_query($this->db, $req); |
| 26 | 30 | if ($result === false) { |
@@ -36,7 +40,8 @@ discard block |
||
| 36 | 40 | return 0; |
| 37 | 41 | } |
| 38 | 42 | |
| 39 | - function testTotalGyms() { |
|
| 43 | + function testTotalGyms() |
|
| 44 | + { |
|
| 40 | 45 | $req = "SELECT COUNT(*) as total FROM forts"; |
| 41 | 46 | $result = pg_query($this->db, $req); |
| 42 | 47 | if ($result === false) { |
@@ -52,7 +57,8 @@ discard block |
||
| 52 | 57 | return 0; |
| 53 | 58 | } |
| 54 | 59 | |
| 55 | - function testTotalPokestops() { |
|
| 60 | + function testTotalPokestops() |
|
| 61 | + { |
|
| 56 | 62 | $req = "SELECT COUNT(*) as total FROM pokestops"; |
| 57 | 63 | $result = pg_query($this->db, $req); |
| 58 | 64 | if ($result === false) { |
@@ -73,26 +79,30 @@ discard block |
||
| 73 | 79 | // Homepage |
| 74 | 80 | ///////////// |
| 75 | 81 | |
| 76 | - function getTotalPokemon() { |
|
| 82 | + function getTotalPokemon() |
|
| 83 | + { |
|
| 77 | 84 | $req = "SELECT COUNT(*) AS total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW())"; |
| 78 | 85 | $result = pg_query($this->db, $req); |
| 79 | 86 | $data = pg_fetch_object($result); |
| 80 | 87 | return $data; |
| 81 | 88 | } |
| 82 | 89 | |
| 83 | - function getTotalLures() { |
|
| 90 | + function getTotalLures() |
|
| 91 | + { |
|
| 84 | 92 | $data = (object) array("total" => 0); |
| 85 | 93 | return $data; |
| 86 | 94 | } |
| 87 | 95 | |
| 88 | - function getTotalGyms() { |
|
| 96 | + function getTotalGyms() |
|
| 97 | + { |
|
| 89 | 98 | $req = "SELECT COUNT(*) AS total FROM forts"; |
| 90 | 99 | $result = pg_query($this->db, $req); |
| 91 | 100 | $data = pg_fetch_object($result); |
| 92 | 101 | return $data; |
| 93 | 102 | } |
| 94 | 103 | |
| 95 | - function getTotalRaids() { |
|
| 104 | + function getTotalRaids() |
|
| 105 | + { |
|
| 96 | 106 | $req = "SELECT COUNT(*) AS total FROM raids WHERE time_battle <= EXTRACT(EPOCH FROM NOW()) AND time_end >= EXTRACT(EPOCH FROM NOW())"; |
| 97 | 107 | $result = pg_query($this->db, $req); |
| 98 | 108 | $data = pg_fetch_object($result); |
@@ -100,7 +110,8 @@ discard block |
||
| 100 | 110 | } |
| 101 | 111 | |
| 102 | 112 | |
| 103 | - function getTotalGymsForTeam($team_id) { |
|
| 113 | + function getTotalGymsForTeam($team_id) |
|
| 114 | + { |
|
| 104 | 115 | $req = "SELECT COUNT(*) AS total |
| 105 | 116 | FROM forts f |
| 106 | 117 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -110,7 +121,8 @@ discard block |
||
| 110 | 121 | return $data; |
| 111 | 122 | } |
| 112 | 123 | |
| 113 | - function getRecentAll() { |
|
| 124 | + function getRecentAll() |
|
| 125 | + { |
|
| 114 | 126 | $req = "SELECT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, |
| 115 | 127 | lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina |
| 116 | 128 | FROM sightings |
@@ -126,7 +138,8 @@ discard block |
||
| 126 | 138 | return $data; |
| 127 | 139 | } |
| 128 | 140 | |
| 129 | - function getRecentMythic($mythic_pokemon) { |
|
| 141 | + function getRecentMythic($mythic_pokemon) |
|
| 142 | + { |
|
| 130 | 143 | $req = "SELECT pokemon_id, encounter_id, TO_TIMESTAMP(expire_timestamp) AS disappear_time, TO_TIMESTAMP(updated) AS last_modified, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, |
| 131 | 144 | lat AS latitude, lon AS longitude, cp, atk_iv AS individual_attack, def_iv AS individual_defense, sta_iv AS individual_stamina |
| 132 | 145 | FROM sightings |
@@ -147,7 +160,8 @@ discard block |
||
| 147 | 160 | // Single Pokemon |
| 148 | 161 | /////////////////// |
| 149 | 162 | |
| 150 | - function getGymsProtectedByPokemon($pokemon_id) { |
|
| 163 | + function getGymsProtectedByPokemon($pokemon_id) |
|
| 164 | + { |
|
| 151 | 165 | $req = "SELECT COUNT(f.id) AS total |
| 152 | 166 | FROM forts f |
| 153 | 167 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -157,7 +171,8 @@ discard block |
||
| 157 | 171 | return $data; |
| 158 | 172 | } |
| 159 | 173 | |
| 160 | - function getPokemonLastSeen($pokemon_id) { |
|
| 174 | + function getPokemonLastSeen($pokemon_id) |
|
| 175 | + { |
|
| 161 | 176 | $req = "SELECT TO_TIMESTAMP(expire_timestamp) AS expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS disappear_time_real, lat AS latitude, lon AS longitude |
| 162 | 177 | FROM sightings |
| 163 | 178 | WHERE pokemon_id = '".$pokemon_id."' |
@@ -168,7 +183,8 @@ discard block |
||
| 168 | 183 | return $data; |
| 169 | 184 | } |
| 170 | 185 | |
| 171 | - function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) { |
|
| 186 | + function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) |
|
| 187 | + { |
|
| 172 | 188 | $req = "SELECT expire_timestamp, TO_TIMESTAMP(expire_timestamp) AS distime, pokemon_id as pokemon_id, TO_TIMESTAMP(expire_timestamp) as disappear_time, lat as latitude, lon as longitude, |
| 173 | 189 | cp, atk_iv as individual_attack, def_iv as individual_defense, sta_iv as individual_stamina, |
| 174 | 190 | ROUND(100*(atk_iv+def_iv+sta_iv)/45,1) AS \"IV\", move_1 as move_1, move_2, form |
@@ -184,7 +200,8 @@ discard block |
||
| 184 | 200 | return $top; |
| 185 | 201 | } |
| 186 | 202 | |
| 187 | - function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) { |
|
| 203 | + function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) |
|
| 204 | + { |
|
| 188 | 205 | $trainer_blacklist = ""; |
| 189 | 206 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 190 | 207 | $trainer_blacklist = " AND owner_name NOT IN ('" . implode("','", self::$config->system->trainer_blacklist) . "')"; |
@@ -205,7 +222,8 @@ discard block |
||
| 205 | 222 | return $toptrainer; |
| 206 | 223 | } |
| 207 | 224 | |
| 208 | - public function getPokemonHeatmap($pokemon_id, $start, $end) { |
|
| 225 | + public function getPokemonHeatmap($pokemon_id, $start, $end) |
|
| 226 | + { |
|
| 209 | 227 | $where = " WHERE pokemon_id = ".$pokemon_id." " |
| 210 | 228 | . "AND TO_TIMESTAMP(expire_timestamp) BETWEEN '".$start."' AND '".$end."'"; |
| 211 | 229 | $req = "SELECT lat AS latitude, lon AS longitude FROM sightings".$where." LIMIT 100000"; |
@@ -217,7 +235,8 @@ discard block |
||
| 217 | 235 | return $points; |
| 218 | 236 | } |
| 219 | 237 | |
| 220 | - public function getPokemonGraph($pokemon_id) { |
|
| 238 | + public function getPokemonGraph($pokemon_id) |
|
| 239 | + { |
|
| 221 | 240 | $req = "SELECT COUNT(*) AS total, EXTRACT(HOUR FROM disappear_time) AS disappear_hour |
| 222 | 241 | FROM (SELECT TO_TIMESTAMP(expire_timestamp) as disappear_time FROM sightings WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered |
| 223 | 242 | GROUP BY disappear_hour |
@@ -233,7 +252,8 @@ discard block |
||
| 233 | 252 | return $array; |
| 234 | 253 | } |
| 235 | 254 | |
| 236 | - public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) { |
|
| 255 | + public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) |
|
| 256 | + { |
|
| 237 | 257 | $inmap_pkms_filter = ""; |
| 238 | 258 | $where = " WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) AND pokemon_id = " . $pokemon_id; |
| 239 | 259 | |
@@ -268,21 +288,24 @@ discard block |
||
| 268 | 288 | return $spawns; |
| 269 | 289 | } |
| 270 | 290 | |
| 271 | - public function getPokemonSliderMinMax() { |
|
| 291 | + public function getPokemonSliderMinMax() |
|
| 292 | + { |
|
| 272 | 293 | $req = "SELECT TO_TIMESTAMP(MIN(expire_timestamp)) AS min, TO_TIMESTAMP(MAX(expire_timestamp)) AS max FROM sightings"; |
| 273 | 294 | $result = pg_query($this->db, $req); |
| 274 | 295 | $data = pg_fetch_object($result); |
| 275 | 296 | return $data; |
| 276 | 297 | } |
| 277 | 298 | |
| 278 | - public function getMapsCoords() { |
|
| 299 | + public function getMapsCoords() |
|
| 300 | + { |
|
| 279 | 301 | $req = "SELECT MAX(lat) AS max_latitude, MIN(lat) AS min_latitude, MAX(lon) AS max_longitude, MIN(lon) as min_longitude FROM spawnpoints"; |
| 280 | 302 | $result = pg_query($this->db, $req); |
| 281 | 303 | $data = pg_fetch_object($result); |
| 282 | 304 | return $data; |
| 283 | 305 | } |
| 284 | 306 | |
| 285 | - public function getPokemonCount($pokemon_id) { |
|
| 307 | + public function getPokemonCount($pokemon_id) |
|
| 308 | + { |
|
| 286 | 309 | $req = "SELECT count, last_seen, latitude, longitude |
| 287 | 310 | FROM pokemon_stats |
| 288 | 311 | WHERE pid = ".$pokemon_id; |
@@ -291,7 +314,8 @@ discard block |
||
| 291 | 314 | return $data; |
| 292 | 315 | } |
| 293 | 316 | |
| 294 | - public function getRaidCount($pokemon_id) { |
|
| 317 | + public function getRaidCount($pokemon_id) |
|
| 318 | + { |
|
| 295 | 319 | $req = "SELECT count, last_seen, latitude, longitude |
| 296 | 320 | FROM raid_stats |
| 297 | 321 | WHERE pid = ".$pokemon_id; |
@@ -306,14 +330,16 @@ discard block |
||
| 306 | 330 | ////////////// |
| 307 | 331 | |
| 308 | 332 | |
| 309 | - function getTotalPokestops() { |
|
| 333 | + function getTotalPokestops() |
|
| 334 | + { |
|
| 310 | 335 | $req = "SELECT COUNT(*) as total FROM pokestops"; |
| 311 | 336 | $result = pg_query($this->db, $req); |
| 312 | 337 | $data = pg_fetch_object($result); |
| 313 | 338 | return $data; |
| 314 | 339 | } |
| 315 | 340 | |
| 316 | - public function getAllPokestops() { |
|
| 341 | + public function getAllPokestops() |
|
| 342 | + { |
|
| 317 | 343 | $req = "SELECT lat as latitude, lon as longitude, null AS lure_expiration, EXTRACT(EPOCH FROM NOW()) AS now, null AS lure_expiration_real FROM pokestops"; |
| 318 | 344 | $result = pg_query($this->db, $req); |
| 319 | 345 | $pokestops = array(); |
@@ -328,7 +354,8 @@ discard block |
||
| 328 | 354 | // Gyms |
| 329 | 355 | ///////// |
| 330 | 356 | |
| 331 | - function getTeamGuardians($team_id) { |
|
| 357 | + function getTeamGuardians($team_id) |
|
| 358 | + { |
|
| 332 | 359 | $req = "SELECT COUNT(*) AS total, guard_pokemon_id |
| 333 | 360 | FROM forts f |
| 334 | 361 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -343,7 +370,8 @@ discard block |
||
| 343 | 370 | return $datas; |
| 344 | 371 | } |
| 345 | 372 | |
| 346 | - function getOwnedAndPoints($team_id) { |
|
| 373 | + function getOwnedAndPoints($team_id) |
|
| 374 | + { |
|
| 347 | 375 | $req = "SELECT COUNT(f.id) AS total, ROUND(AVG(fs.total_cp))AS average_points |
| 348 | 376 | FROM forts f |
| 349 | 377 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -353,7 +381,8 @@ discard block |
||
| 353 | 381 | return $data; |
| 354 | 382 | } |
| 355 | 383 | |
| 356 | - function getAllGyms() { |
|
| 384 | + function getAllGyms() |
|
| 385 | + { |
|
| 357 | 386 | $req = "SELECT f.id as gym_id, team as team_id, f.lat as latitude, f.lon as longitude, updated as last_scanned, (6 - fs.slots_available) AS level |
| 358 | 387 | FROM forts f |
| 359 | 388 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id))"; |
@@ -365,7 +394,8 @@ discard block |
||
| 365 | 394 | return $gyms; |
| 366 | 395 | } |
| 367 | 396 | |
| 368 | - public function getGymData($gym_id) { |
|
| 397 | + public function getGymData($gym_id) |
|
| 398 | + { |
|
| 369 | 399 | $req = "SELECT f.name AS name, null AS description, f.url AS url, fs.team AS team, TO_TIMESTAMP(fs.updated) AS last_scanned, fs.guard_pokemon_id AS guard_pokemon_id, (6 - fs.slots_available) AS level, fs.total_cp |
| 370 | 400 | FROM forts f |
| 371 | 401 | LEFT JOIN fort_sightings fs ON (fs.fort_id = f.id AND fs.last_modified = (SELECT MAX(last_modified) FROM fort_sightings fs2 WHERE fs2.fort_id=f.id)) |
@@ -376,7 +406,8 @@ discard block |
||
| 376 | 406 | return $data; |
| 377 | 407 | } |
| 378 | 408 | |
| 379 | - public function getGymDefenders($gym_id) { |
|
| 409 | + public function getGymDefenders($gym_id) |
|
| 410 | + { |
|
| 380 | 411 | $req = "SELECT external_id as pokemon_uid, pokemon_id, atk_iv as iv_attack, def_iv as iv_defense, sta_iv as iv_stamina, cp, fort_id as gym_id |
| 381 | 412 | FROM gym_defenders |
| 382 | 413 | WHERE fort_id='".$gym_id."' |
@@ -502,7 +533,8 @@ discard block |
||
| 502 | 533 | // Raids |
| 503 | 534 | /////////// |
| 504 | 535 | |
| 505 | - public function getAllRaids($page) { |
|
| 536 | + public function getAllRaids($page) |
|
| 537 | + { |
|
| 506 | 538 | $limit = " LIMIT 10 OFFSET ". ($page * 10); |
| 507 | 539 | $req = "SELECT r.fort_id AS gym_id, r.level AS level, r.pokemon_id AS pokemon_id, r.cp AS cp, r.move_1 AS move_1, r.move_2 AS move_2, TO_TIMESTAMP(r.time_spawn) AS spawn, TO_TIMESTAMP(r.time_battle) AS start, TO_TIMESTAMP(r.time_end) AS end, TO_TIMESTAMP(fs.updated) AS last_scanned, f.name, f.lat AS latitude, f.lon as longitude |
| 508 | 540 | FROM forts f |
@@ -523,7 +555,8 @@ discard block |
||
| 523 | 555 | // Trainers |
| 524 | 556 | ////////////// |
| 525 | 557 | |
| 526 | - public function getTrainers($trainer_name, $team, $page, $rankingNumber) { |
|
| 558 | + public function getTrainers($trainer_name, $team, $page, $rankingNumber) |
|
| 559 | + { |
|
| 527 | 560 | $ranking = $this->getTrainerLevelRanking(); |
| 528 | 561 | $where = ""; |
| 529 | 562 | if (!empty(self::$config->system->trainer_blacklist)) { |
@@ -575,7 +608,8 @@ discard block |
||
| 575 | 608 | return $trainers; |
| 576 | 609 | } |
| 577 | 610 | |
| 578 | - public function getTrainerLevelRanking() { |
|
| 611 | + public function getTrainerLevelRanking() |
|
| 612 | + { |
|
| 579 | 613 | $exclue = ""; |
| 580 | 614 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 581 | 615 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -596,7 +630,8 @@ discard block |
||
| 596 | 630 | return $levelData; |
| 597 | 631 | } |
| 598 | 632 | |
| 599 | - public function getActivePokemon($trainer_name) { |
|
| 633 | + public function getActivePokemon($trainer_name) |
|
| 634 | + { |
|
| 600 | 635 | $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, TO_TIMESTAMP(deployment_time) AS deployment_time, '1' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned |
| 601 | 636 | FROM gym_defenders |
| 602 | 637 | WHERE owner_name = '".$trainer_name."' AND fort_id IS NOT NULL |
@@ -609,7 +644,8 @@ discard block |
||
| 609 | 644 | return $pokemon; |
| 610 | 645 | } |
| 611 | 646 | |
| 612 | - public function getInactivePokemon($trainer_name) { |
|
| 647 | + public function getInactivePokemon($trainer_name) |
|
| 648 | + { |
|
| 613 | 649 | $req = "SELECT pokemon_id, cp, atk_iv AS iv_attack, sta_iv AS iv_stamina, def_iv AS iv_defense, NULL AS deployment_time, '0' AS active, fort_id as gym_id, FLOOR((UNIX_TIMESTAMP() - created) / 86400) AS last_scanned |
| 614 | 650 | FROM gym_defenders |
| 615 | 651 | WHERE owner_name = '".$trainer_name."' AND fort_id IS NULL |
@@ -622,7 +658,8 @@ discard block |
||
| 622 | 658 | return $pokemon; |
| 623 | 659 | } |
| 624 | 660 | |
| 625 | - public function getTrainerLevelCount($team_id) { |
|
| 661 | + public function getTrainerLevelCount($team_id) |
|
| 662 | + { |
|
| 626 | 663 | $exclue = ""; |
| 627 | 664 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 628 | 665 | $exclue .= " AND owner_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -648,7 +685,8 @@ discard block |
||
| 648 | 685 | // Cron |
| 649 | 686 | ///////// |
| 650 | 687 | |
| 651 | - public function getPokemonCountsActive() { |
|
| 688 | + public function getPokemonCountsActive() |
|
| 689 | + { |
|
| 652 | 690 | $req = "SELECT pokemon_id, COUNT(*) as total FROM sightings WHERE expire_timestamp >= EXTRACT(EPOCH FROM NOW()) GROUP BY pokemon_id"; |
| 653 | 691 | $result = pg_query($this->db, $req); |
| 654 | 692 | $counts = array(); |
@@ -658,7 +696,8 @@ discard block |
||
| 658 | 696 | return $counts; |
| 659 | 697 | } |
| 660 | 698 | |
| 661 | - public function getPokemonCountsLastDay() { |
|
| 699 | + public function getPokemonCountsLastDay() |
|
| 700 | + { |
|
| 662 | 701 | $req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day |
| 663 | 702 | FROM sightings |
| 664 | 703 | WHERE expire_timestamp >= (SELECT MAX(expire_timestamp) - 86400 FROM sightings) |
@@ -673,14 +712,16 @@ discard block |
||
| 673 | 712 | } |
| 674 | 713 | |
| 675 | 714 | |
| 676 | - public function getCaptchaCount() { |
|
| 715 | + public function getCaptchaCount() |
|
| 716 | + { |
|
| 677 | 717 | $req = " SELECT COUNT(*) as total FROM accounts WHERE captchaed IS NOT NULL AND reason IS NULL"; |
| 678 | 718 | $result = pg_query($this->db, $req); |
| 679 | 719 | $data = pg_fetch_object($result); |
| 680 | 720 | return $data; |
| 681 | 721 | } |
| 682 | 722 | |
| 683 | - public function getNestData() { |
|
| 723 | + public function getNestData() |
|
| 724 | + { |
|
| 684 | 725 | $pokemon_exclude_sql = ""; |
| 685 | 726 | if (!empty(self::$config->system->nest_exclude_pokemon)) { |
| 686 | 727 | $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", self::$config->system->nest_exclude_pokemon) . ")"; |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | ///////// |
| 319 | 319 | |
| 320 | 320 | function getTeamGuardians($team_id) { |
| 321 | - $req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id ."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3"; |
|
| 321 | + $req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3"; |
|
| 322 | 322 | $result = $this->mysqli->query($req); |
| 323 | 323 | $datas = array(); |
| 324 | 324 | while ($data = $result->fetch_object()) { |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | |
| 397 | 397 | $limit = " LIMIT ".($page * 10).",10"; |
| 398 | 398 | |
| 399 | - $req = "SELECT gymdetails.gym_id, name, team_id, total_cp, (6 - slots_available) as pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '" . self::$time_offset . "')) as last_modified |
|
| 399 | + $req = "SELECT gymdetails.gym_id, name, team_id, total_cp, (6 - slots_available) as pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '".self::$time_offset."')) as last_modified |
|
| 400 | 400 | FROM gymdetails |
| 401 | 401 | LEFT JOIN gym |
| 402 | 402 | ON gymdetails.gym_id = gym.gym_id |
@@ -415,7 +415,7 @@ discard block |
||
| 415 | 415 | FROM gymmember |
| 416 | 416 | LEFT JOIN gympokemon |
| 417 | 417 | ON gymmember.pokemon_uid = gympokemon.pokemon_uid |
| 418 | - WHERE gymmember.gym_id = '". $gym_id ."' |
|
| 418 | + WHERE gymmember.gym_id = '". $gym_id."' |
|
| 419 | 419 | ORDER BY deployment_time"; |
| 420 | 420 | $result = $this->mysqli->query($req); |
| 421 | 421 | $pokemons = array(); |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | FROM gymhistory |
| 436 | 436 | WHERE gym_id='".$gym_id."' |
| 437 | 437 | ORDER BY last_modified DESC |
| 438 | - LIMIT ".($page * $pageSize).",".($pageSize+1); |
|
| 438 | + LIMIT ".($page * $pageSize).",".($pageSize + 1); |
|
| 439 | 439 | $result = $this->mysqli->query($req); |
| 440 | 440 | $history = array(); |
| 441 | 441 | $count = 0; |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | FROM gympokemon |
| 576 | 576 | INNER JOIN (SELECT gymmember.pokemon_uid, gymmember.gym_id FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember |
| 577 | 577 | ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid) AS actives_pokemons ON actives_pokemons.trainer_name = trainer.name |
| 578 | - GROUP BY trainer.name " . $where . $order . $limit; |
|
| 578 | + GROUP BY trainer.name " . $where.$order.$limit; |
|
| 579 | 579 | |
| 580 | 580 | $result = $this->mysqli->query($req); |
| 581 | 581 | $trainers = array(); |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | return $data; |
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - private function getTrainerActivePokemon($trainer_name){ |
|
| 599 | + private function getTrainerActivePokemon($trainer_name) { |
|
| 600 | 600 | $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, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '1' AS active |
| 601 | 601 | FROM gympokemon INNER JOIN |
| 602 | 602 | (SELECT gymmember.pokemon_uid, gymmember.gym_id, gymmember.deployment_time FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.deployment_time, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | return $pokemons; |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - private function getTrainerInactivePokemon($trainer_name){ |
|
| 614 | + private function getTrainerInactivePokemon($trainer_name) { |
|
| 615 | 615 | $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, null AS gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '0' AS active |
| 616 | 616 | FROM gympokemon LEFT JOIN |
| 617 | 617 | (SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember |
@@ -671,7 +671,7 @@ discard block |
||
| 671 | 671 | FROM pokemon p |
| 672 | 672 | INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id) |
| 673 | 673 | WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL 24 HOUR |
| 674 | - " . $pokemon_exclude_sql . " |
|
| 674 | + " . $pokemon_exclude_sql." |
|
| 675 | 675 | GROUP BY p.spawnpoint_id, p.pokemon_id |
| 676 | 676 | HAVING COUNT(p.pokemon_id) >= 6 |
| 677 | 677 | ORDER BY p.pokemon_id"; |
@@ -1,12 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -final class QueryManagerMysqlRocketmap extends QueryManagerMysql { |
|
| 3 | +final class QueryManagerMysqlRocketmap extends QueryManagerMysql |
|
| 4 | +{ |
|
| 4 | 5 | |
| 5 | - public function __construct() { |
|
| 6 | + public function __construct() |
|
| 7 | + { |
|
| 6 | 8 | parent::__construct(); |
| 7 | 9 | } |
| 8 | 10 | |
| 9 | - public function __destruct() { |
|
| 11 | + public function __destruct() |
|
| 12 | + { |
|
| 10 | 13 | parent::__destruct(); |
| 11 | 14 | } |
| 12 | 15 | |
@@ -14,7 +17,8 @@ discard block |
||
| 14 | 17 | // Tester |
| 15 | 18 | /////////// |
| 16 | 19 | |
| 17 | - function testTotalPokemon() { |
|
| 20 | + function testTotalPokemon() |
|
| 21 | + { |
|
| 18 | 22 | $req = "SELECT COUNT(*) as total FROM pokemon"; |
| 19 | 23 | $result = $this->mysqli->query($req); |
| 20 | 24 | if (!is_object($result)) { |
@@ -30,7 +34,8 @@ discard block |
||
| 30 | 34 | return 0; |
| 31 | 35 | } |
| 32 | 36 | |
| 33 | - function testTotalGyms() { |
|
| 37 | + function testTotalGyms() |
|
| 38 | + { |
|
| 34 | 39 | $req = "SELECT COUNT(*) as total FROM gym"; |
| 35 | 40 | $result = $this->mysqli->query($req); |
| 36 | 41 | if (!is_object($result)) { |
@@ -46,7 +51,8 @@ discard block |
||
| 46 | 51 | return 0; |
| 47 | 52 | } |
| 48 | 53 | |
| 49 | - function testTotalPokestops() { |
|
| 54 | + function testTotalPokestops() |
|
| 55 | + { |
|
| 50 | 56 | $req = "SELECT COUNT(*) as total FROM pokestop"; |
| 51 | 57 | $result = $this->mysqli->query($req); |
| 52 | 58 | if (!is_object($result)) { |
@@ -67,42 +73,48 @@ discard block |
||
| 67 | 73 | // Homepage |
| 68 | 74 | ///////////// |
| 69 | 75 | |
| 70 | - function getTotalPokemon() { |
|
| 76 | + function getTotalPokemon() |
|
| 77 | + { |
|
| 71 | 78 | $req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
| 72 | 79 | $result = $this->mysqli->query($req); |
| 73 | 80 | $data = $result->fetch_object(); |
| 74 | 81 | return $data; |
| 75 | 82 | } |
| 76 | 83 | |
| 77 | - function getTotalLures() { |
|
| 84 | + function getTotalLures() |
|
| 85 | + { |
|
| 78 | 86 | $req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
| 79 | 87 | $result = $this->mysqli->query($req); |
| 80 | 88 | $data = $result->fetch_object(); |
| 81 | 89 | return $data; |
| 82 | 90 | } |
| 83 | 91 | |
| 84 | - function getTotalGyms() { |
|
| 92 | + function getTotalGyms() |
|
| 93 | + { |
|
| 85 | 94 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym"; |
| 86 | 95 | $result = $this->mysqli->query($req); |
| 87 | 96 | $data = $result->fetch_object(); |
| 88 | 97 | return $data; |
| 89 | 98 | } |
| 90 | 99 | |
| 91 | - function getTotalRaids() { |
|
| 100 | + function getTotalRaids() |
|
| 101 | + { |
|
| 92 | 102 | $req = "SELECT COUNT(*) AS total FROM raid WHERE start <= UTC_TIMESTAMP AND end >= UTC_TIMESTAMP()"; |
| 93 | 103 | $result = $this->mysqli->query($req); |
| 94 | 104 | $data = $result->fetch_object(); |
| 95 | 105 | return $data; |
| 96 | 106 | } |
| 97 | 107 | |
| 98 | - function getTotalGymsForTeam($team_id) { |
|
| 108 | + function getTotalGymsForTeam($team_id) |
|
| 109 | + { |
|
| 99 | 110 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '".$team_id."'"; |
| 100 | 111 | $result = $this->mysqli->query($req); |
| 101 | 112 | $data = $result->fetch_object(); |
| 102 | 113 | return $data; |
| 103 | 114 | } |
| 104 | 115 | |
| 105 | - function getRecentAll() { |
|
| 116 | + function getRecentAll() |
|
| 117 | + { |
|
| 106 | 118 | $req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, |
| 107 | 119 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 108 | 120 | FROM pokemon |
@@ -118,7 +130,8 @@ discard block |
||
| 118 | 130 | return $data; |
| 119 | 131 | } |
| 120 | 132 | |
| 121 | - function getRecentMythic($mythic_pokemons) { |
|
| 133 | + function getRecentMythic($mythic_pokemons) |
|
| 134 | + { |
|
| 122 | 135 | $req = "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, |
| 123 | 136 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 124 | 137 | FROM pokemon |
@@ -139,14 +152,16 @@ discard block |
||
| 139 | 152 | // Single Pokemon |
| 140 | 153 | /////////////////// |
| 141 | 154 | |
| 142 | - function getGymsProtectedByPokemon($pokemon_id) { |
|
| 155 | + function getGymsProtectedByPokemon($pokemon_id) |
|
| 156 | + { |
|
| 143 | 157 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'"; |
| 144 | 158 | $result = $this->mysqli->query($req); |
| 145 | 159 | $data = $result->fetch_object(); |
| 146 | 160 | return $data; |
| 147 | 161 | } |
| 148 | 162 | |
| 149 | - function getPokemonLastSeen($pokemon_id) { |
|
| 163 | + function getPokemonLastSeen($pokemon_id) |
|
| 164 | + { |
|
| 150 | 165 | $req = "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_time_real, latitude, longitude |
| 151 | 166 | FROM pokemon |
| 152 | 167 | WHERE pokemon_id = '".$pokemon_id."' |
@@ -157,7 +172,8 @@ discard block |
||
| 157 | 172 | return $data; |
| 158 | 173 | } |
| 159 | 174 | |
| 160 | - function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) { |
|
| 175 | + function getTop50Pokemon($pokemon_id, $top_order_by, $top_direction) |
|
| 176 | + { |
|
| 161 | 177 | $req = "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude, |
| 162 | 178 | cp, individual_attack, individual_defense, individual_stamina, |
| 163 | 179 | ROUND(100*(individual_attack+individual_defense+individual_stamina)/45,1) AS IV, move_1, move_2, form |
@@ -174,7 +190,8 @@ discard block |
||
| 174 | 190 | return $top; |
| 175 | 191 | } |
| 176 | 192 | |
| 177 | - function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) { |
|
| 193 | + function getTop50Trainers($pokemon_id, $best_order_by, $best_direction) |
|
| 194 | + { |
|
| 178 | 195 | $trainer_blacklist = ""; |
| 179 | 196 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 180 | 197 | $trainer_blacklist = " AND trainer_name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -195,7 +212,8 @@ discard block |
||
| 195 | 212 | return $toptrainer; |
| 196 | 213 | } |
| 197 | 214 | |
| 198 | - public function getPokemonHeatmap($pokemon_id, $start, $end) { |
|
| 215 | + public function getPokemonHeatmap($pokemon_id, $start, $end) |
|
| 216 | + { |
|
| 199 | 217 | $where = " WHERE pokemon_id = ".$pokemon_id." " |
| 200 | 218 | . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
| 201 | 219 | $req = "SELECT latitude, longitude FROM pokemon".$where." LIMIT 10000"; |
@@ -207,7 +225,8 @@ discard block |
||
| 207 | 225 | return $points; |
| 208 | 226 | } |
| 209 | 227 | |
| 210 | - public function getPokemonGraph($pokemon_id) { |
|
| 228 | + public function getPokemonGraph($pokemon_id) |
|
| 229 | + { |
|
| 211 | 230 | $req = "SELECT COUNT(*) AS total, |
| 212 | 231 | HOUR(CONVERT_TZ(disappear_time, '+00:00', '".self::$time_offset."')) AS disappear_hour |
| 213 | 232 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' LIMIT 100000) AS pokemonFiltered |
@@ -224,7 +243,8 @@ discard block |
||
| 224 | 243 | return $array; |
| 225 | 244 | } |
| 226 | 245 | |
| 227 | - public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) { |
|
| 246 | + public function getPokemonLive($pokemon_id, $ivMin, $ivMax, $inmap_pokemons) |
|
| 247 | + { |
|
| 228 | 248 | $inmap_pkms_filter = ""; |
| 229 | 249 | $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id; |
| 230 | 250 | |
@@ -257,21 +277,24 @@ discard block |
||
| 257 | 277 | return $spawns; |
| 258 | 278 | } |
| 259 | 279 | |
| 260 | - public function getPokemonSliderMinMax() { |
|
| 280 | + public function getPokemonSliderMinMax() |
|
| 281 | + { |
|
| 261 | 282 | $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
| 262 | 283 | $result = $this->mysqli->query($req); |
| 263 | 284 | $data = $result->fetch_object(); |
| 264 | 285 | return $data; |
| 265 | 286 | } |
| 266 | 287 | |
| 267 | - public function getMapsCoords() { |
|
| 288 | + public function getMapsCoords() |
|
| 289 | + { |
|
| 268 | 290 | $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
| 269 | 291 | $result = $this->mysqli->query($req); |
| 270 | 292 | $data = $result->fetch_object(); |
| 271 | 293 | return $data; |
| 272 | 294 | } |
| 273 | 295 | |
| 274 | - public function getPokemonCount($pokemon_id) { |
|
| 296 | + public function getPokemonCount($pokemon_id) |
|
| 297 | + { |
|
| 275 | 298 | $req = "SELECT count, last_seen, latitude, longitude |
| 276 | 299 | FROM pokemon_stats |
| 277 | 300 | WHERE pid = ".$pokemon_id; |
@@ -280,7 +303,8 @@ discard block |
||
| 280 | 303 | return $data; |
| 281 | 304 | } |
| 282 | 305 | |
| 283 | - public function getRaidCount($pokemon_id) { |
|
| 306 | + public function getRaidCount($pokemon_id) |
|
| 307 | + { |
|
| 284 | 308 | $req = "SELECT count, last_seen, latitude, longitude |
| 285 | 309 | FROM raid_stats |
| 286 | 310 | WHERE pid = ".$pokemon_id; |
@@ -295,14 +319,16 @@ discard block |
||
| 295 | 319 | // Pokestops |
| 296 | 320 | ////////////// |
| 297 | 321 | |
| 298 | - function getTotalPokestops() { |
|
| 322 | + function getTotalPokestops() |
|
| 323 | + { |
|
| 299 | 324 | $req = "SELECT COUNT(*) as total FROM pokestop"; |
| 300 | 325 | $result = $this->mysqli->query($req); |
| 301 | 326 | $data = $result->fetch_object(); |
| 302 | 327 | return $data; |
| 303 | 328 | } |
| 304 | 329 | |
| 305 | - public function getAllPokestops() { |
|
| 330 | + public function getAllPokestops() |
|
| 331 | + { |
|
| 306 | 332 | $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".self::$time_offset."')) AS lure_expiration_real FROM pokestop"; |
| 307 | 333 | $result = $this->mysqli->query($req); |
| 308 | 334 | $pokestops = array(); |
@@ -317,7 +343,8 @@ discard block |
||
| 317 | 343 | // Gyms |
| 318 | 344 | ///////// |
| 319 | 345 | |
| 320 | - function getTeamGuardians($team_id) { |
|
| 346 | + function getTeamGuardians($team_id) |
|
| 347 | + { |
|
| 321 | 348 | $req = "SELECT COUNT(*) AS total, guard_pokemon_id FROM gym WHERE team_id = '".$team_id ."' GROUP BY guard_pokemon_id ORDER BY total DESC LIMIT 0,3"; |
| 322 | 349 | $result = $this->mysqli->query($req); |
| 323 | 350 | $datas = array(); |
@@ -327,14 +354,16 @@ discard block |
||
| 327 | 354 | return $datas; |
| 328 | 355 | } |
| 329 | 356 | |
| 330 | - function getOwnedAndPoints($team_id) { |
|
| 357 | + function getOwnedAndPoints($team_id) |
|
| 358 | + { |
|
| 331 | 359 | $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'"; |
| 332 | 360 | $result = $this->mysqli->query($req); |
| 333 | 361 | $data = $result->fetch_object(); |
| 334 | 362 | return $data; |
| 335 | 363 | } |
| 336 | 364 | |
| 337 | - function getAllGyms() { |
|
| 365 | + function getAllGyms() |
|
| 366 | + { |
|
| 338 | 367 | $req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".self::$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym"; |
| 339 | 368 | $result = $this->mysqli->query($req); |
| 340 | 369 | $gyms = array(); |
@@ -344,7 +373,8 @@ discard block |
||
| 344 | 373 | return $gyms; |
| 345 | 374 | } |
| 346 | 375 | |
| 347 | - public function getGymData($gym_id) { |
|
| 376 | + public function getGymData($gym_id) |
|
| 377 | + { |
|
| 348 | 378 | $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
| 349 | 379 | (CONVERT_TZ(gym.last_scanned, '+00:00', '".self::$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, gym.total_cp AS total_cp, (6 - gym.slots_available) AS level |
| 350 | 380 | FROM gymdetails |
@@ -355,7 +385,8 @@ discard block |
||
| 355 | 385 | return $data; |
| 356 | 386 | } |
| 357 | 387 | |
| 358 | - public function getGymDefenders($gym_id) { |
|
| 388 | + public function getGymDefenders($gym_id) |
|
| 389 | + { |
|
| 359 | 390 | $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
| 360 | 391 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 361 | 392 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
@@ -375,7 +406,8 @@ discard block |
||
| 375 | 406 | // Gym History |
| 376 | 407 | //////////////// |
| 377 | 408 | |
| 378 | - public function getGymHistories($gym_name, $team, $page, $ranking) { |
|
| 409 | + public function getGymHistories($gym_name, $team, $page, $ranking) |
|
| 410 | + { |
|
| 379 | 411 | $where = ''; |
| 380 | 412 | if (isset($gym_name) && $gym_name != '') { |
| 381 | 413 | $where = " WHERE name LIKE '%".$gym_name."%'"; |
@@ -410,7 +442,8 @@ discard block |
||
| 410 | 442 | return $gym_history; |
| 411 | 443 | } |
| 412 | 444 | |
| 413 | - public function getGymHistoriesPokemon($gym_id) { |
|
| 445 | + public function getGymHistoriesPokemon($gym_id) |
|
| 446 | + { |
|
| 414 | 447 | $req = "SELECT DISTINCT gymmember.pokemon_uid, pokemon_id, cp, trainer_name |
| 415 | 448 | FROM gymmember |
| 416 | 449 | LEFT JOIN gympokemon |
@@ -425,7 +458,8 @@ discard block |
||
| 425 | 458 | return $pokemons; |
| 426 | 459 | } |
| 427 | 460 | |
| 428 | - public function getHistoryForGym($page, $gym_id) { |
|
| 461 | + public function getHistoryForGym($page, $gym_id) |
|
| 462 | + { |
|
| 429 | 463 | if (isset(self::$config->system->gymhistory_hide_cp_changes) && self::$config->system->gymhistory_hide_cp_changes === true) { |
| 430 | 464 | $pageSize = 25; |
| 431 | 465 | } else { |
@@ -461,7 +495,8 @@ discard block |
||
| 461 | 495 | return array("last_page" => $last_page, "data" => $history); |
| 462 | 496 | } |
| 463 | 497 | |
| 464 | - private function getHistoryForGymPokemon($pkm_uids) { |
|
| 498 | + private function getHistoryForGymPokemon($pkm_uids) |
|
| 499 | + { |
|
| 465 | 500 | $req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name |
| 466 | 501 | FROM gympokemon |
| 467 | 502 | WHERE pokemon_uid IN ('".implode("','", $pkm_uids)."') |
@@ -479,7 +514,8 @@ discard block |
||
| 479 | 514 | // Raids |
| 480 | 515 | /////////// |
| 481 | 516 | |
| 482 | - public function getAllRaids($page) { |
|
| 517 | + public function getAllRaids($page) |
|
| 518 | + { |
|
| 483 | 519 | $limit = " LIMIT ".($page * 10).",10"; |
| 484 | 520 | $req = "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".self::$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".self::$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".self::$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".self::$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid |
| 485 | 521 | JOIN gymdetails ON gymdetails.gym_id = raid.gym_id |
@@ -499,7 +535,8 @@ discard block |
||
| 499 | 535 | // Trainers |
| 500 | 536 | ////////////// |
| 501 | 537 | |
| 502 | - public function getTrainers($trainer_name, $team, $page, $ranking) { |
|
| 538 | + public function getTrainers($trainer_name, $team, $page, $ranking) |
|
| 539 | + { |
|
| 503 | 540 | $trainers = $this->getTrainerData($trainer_name, $team, $page, $ranking); |
| 504 | 541 | foreach ($trainers as $trainer) { |
| 505 | 542 | |
@@ -524,7 +561,8 @@ discard block |
||
| 524 | 561 | return $trainers; |
| 525 | 562 | } |
| 526 | 563 | |
| 527 | - public function getTrainerLevelCount($team_id) { |
|
| 564 | + public function getTrainerLevelCount($team_id) |
|
| 565 | + { |
|
| 528 | 566 | $req = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$team_id."'"; |
| 529 | 567 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 530 | 568 | $req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -545,7 +583,8 @@ discard block |
||
| 545 | 583 | return $levelData; |
| 546 | 584 | } |
| 547 | 585 | |
| 548 | - private function getTrainerData($trainer_name, $team, $page, $ranking) { |
|
| 586 | + private function getTrainerData($trainer_name, $team, $page, $ranking) |
|
| 587 | + { |
|
| 549 | 588 | $where = ""; |
| 550 | 589 | |
| 551 | 590 | if (!empty(self::$config->system->trainer_blacklist)) { |
@@ -586,7 +625,8 @@ discard block |
||
| 586 | 625 | return $trainers; |
| 587 | 626 | } |
| 588 | 627 | |
| 589 | - private function getTrainerLevelRating($level) { |
|
| 628 | + private function getTrainerLevelRating($level) |
|
| 629 | + { |
|
| 590 | 630 | $req = "SELECT COUNT(1) AS rank FROM trainer WHERE level = ".$level; |
| 591 | 631 | if (!empty(self::$config->system->trainer_blacklist)) { |
| 592 | 632 | $req .= " AND name NOT IN ('".implode("','", self::$config->system->trainer_blacklist)."')"; |
@@ -596,7 +636,8 @@ discard block |
||
| 596 | 636 | return $data; |
| 597 | 637 | } |
| 598 | 638 | |
| 599 | - private function getTrainerActivePokemon($trainer_name){ |
|
| 639 | + private function getTrainerActivePokemon($trainer_name) |
|
| 640 | + { |
|
| 600 | 641 | $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, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '1' AS active |
| 601 | 642 | FROM gympokemon INNER JOIN |
| 602 | 643 | (SELECT gymmember.pokemon_uid, gymmember.gym_id, gymmember.deployment_time FROM gymmember GROUP BY gymmember.pokemon_uid, gymmember.deployment_time, gymmember.gym_id HAVING gymmember.gym_id <> '') AS filtered_gymmember |
@@ -611,7 +652,8 @@ discard block |
||
| 611 | 652 | return $pokemons; |
| 612 | 653 | } |
| 613 | 654 | |
| 614 | - private function getTrainerInactivePokemon($trainer_name){ |
|
| 655 | + private function getTrainerInactivePokemon($trainer_name) |
|
| 656 | + { |
|
| 615 | 657 | $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, null AS gym_id, CONVERT_TZ(filtered_gymmember.deployment_time, '+00:00', '".self::$time_offset."') as deployment_time, '0' AS active |
| 616 | 658 | FROM gympokemon LEFT JOIN |
| 617 | 659 | (SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember |
@@ -631,7 +673,8 @@ discard block |
||
| 631 | 673 | // Cron |
| 632 | 674 | ///////// |
| 633 | 675 | |
| 634 | - public function getPokemonCountsActive() { |
|
| 676 | + public function getPokemonCountsActive() |
|
| 677 | + { |
|
| 635 | 678 | $req = "SELECT pokemon_id, COUNT(*) as total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP() GROUP BY pokemon_id"; |
| 636 | 679 | $result = $this->mysqli->query($req); |
| 637 | 680 | $counts = array(); |
@@ -641,7 +684,8 @@ discard block |
||
| 641 | 684 | return $counts; |
| 642 | 685 | } |
| 643 | 686 | |
| 644 | - public function getPokemonCountsLastDay() { |
|
| 687 | + public function getPokemonCountsLastDay() |
|
| 688 | + { |
|
| 645 | 689 | $req = "SELECT pokemon_id, COUNT(*) AS spawns_last_day |
| 646 | 690 | FROM pokemon |
| 647 | 691 | WHERE disappear_time >= (SELECT MAX(disappear_time) FROM pokemon) - INTERVAL 1 DAY |
@@ -655,14 +699,16 @@ discard block |
||
| 655 | 699 | return $counts; |
| 656 | 700 | } |
| 657 | 701 | |
| 658 | - public function getCaptchaCount() { |
|
| 702 | + public function getCaptchaCount() |
|
| 703 | + { |
|
| 659 | 704 | $req = "SELECT SUM(accounts_captcha) AS total FROM mainworker"; |
| 660 | 705 | $result = $this->mysqli->query($req); |
| 661 | 706 | $data = $result->fetch_object(); |
| 662 | 707 | return $data; |
| 663 | 708 | } |
| 664 | 709 | |
| 665 | - public function getNestData() { |
|
| 710 | + public function getNestData() |
|
| 711 | + { |
|
| 666 | 712 | $pokemon_exclude_sql = ""; |
| 667 | 713 | if (!empty(self::$config->system->nest_exclude_pokemon)) { |
| 668 | 714 | $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", self::$config->system->nest_exclude_pokemon).")"; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | // Load Query Manager |
| 4 | 4 | // ################### |
| 5 | 5 | |
| 6 | -include_once __DIR__ . '/queries/QueryManager.php'; |
|
| 6 | +include_once __DIR__.'/queries/QueryManager.php'; |
|
| 7 | 7 | $manager = QueryManager::current(); |
| 8 | 8 | |
| 9 | 9 | /** |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | * @return array Sorted list of "accept" options |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -$sortAccept = function ($header) { |
|
| 29 | +$sortAccept = function($header) { |
|
| 30 | 30 | $matches = array(); |
| 31 | 31 | foreach (explode(',', $header) as $option) { |
| 32 | 32 | $option = array_map('trim', explode(';', $option)); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return string|NULL a matched option, or NULL if no match |
| 61 | 61 | */ |
| 62 | -$matchAccept = function ($header, $supported) use ($sortAccept) { |
|
| 62 | +$matchAccept = function($header, $supported) use ($sortAccept) { |
|
| 63 | 63 | $matches = $sortAccept($header); |
| 64 | 64 | foreach ($matches as $key => $q) { |
| 65 | 65 | if (isset($supported[$key])) { |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * |
| 91 | 91 | * @return string The negotiated language result or the supplied default. |
| 92 | 92 | */ |
| 93 | -$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) { |
|
| 93 | +$negotiateLanguage = function($supported, $default = 'en-US') use ($matchAccept) { |
|
| 94 | 94 | $supp = array(); |
| 95 | 95 | foreach ($supported as $lang => $isSupported) { |
| 96 | 96 | if ($isSupported) { |
@@ -26,7 +26,8 @@ discard block |
||
| 26 | 26 | * @return array Sorted list of "accept" options |
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | -$sortAccept = function ($header) { |
|
| 29 | +$sortAccept = function ($header) |
|
| 30 | +{ |
|
| 30 | 31 | $matches = array(); |
| 31 | 32 | foreach (explode(',', $header) as $option) { |
| 32 | 33 | $option = array_map('trim', explode(';', $option)); |
@@ -59,7 +60,8 @@ discard block |
||
| 59 | 60 | * |
| 60 | 61 | * @return string|NULL a matched option, or NULL if no match |
| 61 | 62 | */ |
| 62 | -$matchAccept = function ($header, $supported) use ($sortAccept) { |
|
| 63 | +$matchAccept = function ($header, $supported) use ($sortAccept) |
|
| 64 | +{ |
|
| 63 | 65 | $matches = $sortAccept($header); |
| 64 | 66 | foreach ($matches as $key => $q) { |
| 65 | 67 | if (isset($supported[$key])) { |
@@ -90,7 +92,8 @@ discard block |
||
| 90 | 92 | * |
| 91 | 93 | * @return string The negotiated language result or the supplied default. |
| 92 | 94 | */ |
| 93 | -$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) { |
|
| 95 | +$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) |
|
| 96 | +{ |
|
| 94 | 97 | $supp = array(); |
| 95 | 98 | foreach ($supported as $lang => $isSupported) { |
| 96 | 99 | if ($isSupported) { |