@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
| 26 | 26 | |
| 27 | 27 | // Pokemon Test |
| 28 | - $result = $mysqli->query(req_tester_pokemon()); |
|
| 28 | + $result = $mysqli->query(req_tester_pokemon()); |
|
| 29 | 29 | |
| 30 | 30 | if (!is_object($result)) { |
| 31 | 31 | $lock_msg .= "Error: No Pokémon database found<br>"; |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // Gym Test |
| 42 | - $result = $mysqli->query(req_tester_gym()); |
|
| 42 | + $result = $mysqli->query(req_tester_gym()); |
|
| 43 | 43 | |
| 44 | 44 | if (!is_object($result)) { |
| 45 | 45 | $lock_msg .= "Error: No Gym database found<br>"; |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | // Pokéstop Test |
| 57 | - $result = $mysqli->query(req_tester_pokestop()); |
|
| 57 | + $result = $mysqli->query(req_tester_pokestop()); |
|
| 58 | 58 | |
| 59 | 59 | if (!is_object($result)) { |
| 60 | 60 | $lock_msg .= "Error: No Pokestop database found<br>"; |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | $total_pokemon = 0; |
| 7 | 7 | $pokedex_counts = new stdClass(); |
| 8 | 8 | for ($pid = 1; $pid <= $maxpid; $pid++) { |
| 9 | - $result = $mysqli->query(req_pokemon_total_count($pid)); |
|
| 9 | + $result = $mysqli->query(req_pokemon_total_count($pid)); |
|
| 10 | 10 | $data = $result->fetch_object(); |
| 11 | 11 | |
| 12 | 12 | $pokedex_counts->$pid = (int) $data->pokemon_spawns; |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | $nests['c'] = $data->total_pokemon; |
| 15 | 15 | $nests['lat'] = $data->latitude; |
| 16 | 16 | $nests['lng'] = $data->longitude; |
| 17 | - $starttime = $data->latest_seen - $data->duration; |
|
| 17 | + $starttime = $data->latest_seen - $data->duration; |
|
| 18 | 18 | if ($starttime < 0) { |
| 19 | 19 | $starttime = 3600 + $starttime; |
| 20 | 20 | } |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | if ($config_secret->captcha_key == "") { |
| 20 | 20 | $captcha['timestamp'] = $timestamp; |
| 21 | 21 | // get amount of accounts requiring a captcha |
| 22 | - $result = $mysqli->query(req_captcha_count()); |
|
| 22 | + $result = $mysqli->query(req_captcha_count()); |
|
| 23 | 23 | $data = $result->fetch_object(); |
| 24 | 24 | $captcha['captcha_accs'] = $data->total; |
| 25 | 25 | // Add the datas in file |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | $trainer_lvl = []; |
| 30 | 30 | # For all 3 teams |
| 31 | 31 | for ($teamid = 1; $teamid <= 3; $teamid++) { |
| 32 | - if ($result = $mysqli->query(req_trainer_levels_for_team($teamid))) { |
|
| 32 | + if ($result = $mysqli->query(req_trainer_levels_for_team($teamid))) { |
|
| 33 | 33 | # build level=>count array |
| 34 | 34 | $data = []; |
| 35 | 35 | while ($row = $result->fetch_assoc()) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | function req_maps_localization_coordinates() |
| 12 | 12 | { |
| 13 | - return "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) AS min_longitude FROM spawnpoint"; |
|
| 13 | + return "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) AS min_longitude FROM spawnpoint"; |
|
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | |
@@ -19,19 +19,19 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | function req_pokemon_count() |
| 21 | 21 | { |
| 22 | - return "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 22 | + return "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | function req_pokemon_count_id() |
| 26 | 26 | { |
| 27 | - return "SELECT pokemon_id FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 27 | + return "SELECT pokemon_id FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | function req_mystic_pokemon($mythic_pokemon) |
| 32 | 32 | { |
| 33 | - global $time_offset; |
|
| 34 | - return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 33 | + global $time_offset; |
|
| 34 | + return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 35 | 35 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 36 | 36 | FROM pokemon |
| 37 | 37 | WHERE pokemon_id IN (" . implode(",", $mythic_pokemon) . ") |
@@ -41,8 +41,8 @@ discard block |
||
| 41 | 41 | |
| 42 | 42 | function req_all_pokemon() |
| 43 | 43 | { |
| 44 | - global $time_offset; |
|
| 45 | - return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 44 | + global $time_offset; |
|
| 45 | + return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 46 | 46 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 47 | 47 | FROM pokemon |
| 48 | 48 | ORDER BY last_modified DESC |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | function req_pokemon_total_count($pokemon_id) |
| 57 | 57 | { |
| 58 | - return "SELECT COUNT(*) AS pokemon_spawns FROM pokemon WHERE pokemon_id = '" . $pokemon_id . "'"; |
|
| 58 | + return "SELECT COUNT(*) AS pokemon_spawns FROM pokemon WHERE pokemon_id = '" . $pokemon_id . "'"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | function req_pokemon_total_gym_protected($pokemon_id) |
| 62 | 62 | { |
| 63 | - return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '" . $pokemon_id . "'"; |
|
| 63 | + return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '" . $pokemon_id . "'"; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function req_pokemon_last_seen($pokemon_id) |
| 67 | 67 | { |
| 68 | - global $time_offset; |
|
| 69 | - return "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, latitude, longitude |
|
| 68 | + global $time_offset; |
|
| 69 | + return "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, latitude, longitude |
|
| 70 | 70 | FROM pokemon |
| 71 | 71 | WHERE pokemon_id = '" . $pokemon_id . "' |
| 72 | 72 | ORDER BY disappear_time DESC |
@@ -75,8 +75,8 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | function req_pokemon_get_top_50($pokemon_id, $top_order_by, $top_direction) |
| 77 | 77 | { |
| 78 | - global $time_offset; |
|
| 79 | - return "SELECT (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS distime, pokemon_id, disappear_time, latitude, longitude, |
|
| 78 | + global $time_offset; |
|
| 79 | + return "SELECT (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS distime, pokemon_id, disappear_time, latitude, longitude, |
|
| 80 | 80 | cp, individual_attack, individual_defense, individual_stamina, |
| 81 | 81 | ROUND(SUM(100*(individual_attack+individual_defense+individual_stamina)/45),1) AS IV, move_1, move_2, form |
| 82 | 82 | FROM pokemon |
@@ -88,12 +88,12 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | function req_pokemon_get_top_trainers($pokemon_id, $best_order_by, $best_direction) |
| 90 | 90 | { |
| 91 | - global $config; |
|
| 92 | - $trainer_blacklist = ""; |
|
| 93 | - if (!empty($config->system->trainer_blacklist)) { |
|
| 94 | - $trainer_blacklist = " AND trainer_name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 95 | - } |
|
| 96 | - return "SELECT trainer_name, ROUND(SUM(100*(iv_attack+iv_defense+iv_stamina)/45),1) AS IV, move_1, move_2, cp, |
|
| 91 | + global $config; |
|
| 92 | + $trainer_blacklist = ""; |
|
| 93 | + if (!empty($config->system->trainer_blacklist)) { |
|
| 94 | + $trainer_blacklist = " AND trainer_name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 95 | + } |
|
| 96 | + return "SELECT trainer_name, ROUND(SUM(100*(iv_attack+iv_defense+iv_stamina)/45),1) AS IV, move_1, move_2, cp, |
|
| 97 | 97 | DATE_FORMAT(last_seen, '%Y-%m-%d') AS lasttime, last_seen |
| 98 | 98 | FROM gympokemon |
| 99 | 99 | WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . " |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | function req_pokemon_slider_init() |
| 106 | 106 | { |
| 107 | - return "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 107 | + return "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | function req_pokemon_headmap_points($pokemon_id, $start, $end) |
| 111 | 111 | { |
| 112 | - $where = " WHERE pokemon_id = " . $pokemon_id . " " |
|
| 113 | - . "AND disappear_time BETWEEN '" . $start . "' AND '" . $end . "'"; |
|
| 114 | - return "SELECT latitude, longitude FROM pokemon" . $where . " ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 112 | + $where = " WHERE pokemon_id = " . $pokemon_id . " " |
|
| 113 | + . "AND disappear_time BETWEEN '" . $start . "' AND '" . $end . "'"; |
|
| 114 | + return "SELECT latitude, longitude FROM pokemon" . $where . " ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function req_pokemon_graph_data($pokemon_id) |
| 118 | 118 | { |
| 119 | - global $time_offset; |
|
| 120 | - return "SELECT COUNT(*) AS total, |
|
| 119 | + global $time_offset; |
|
| 120 | + return "SELECT COUNT(*) AS total, |
|
| 121 | 121 | HOUR(CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_hour |
| 122 | 122 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '" . $pokemon_id . "' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
| 123 | 123 | GROUP BY disappear_hour |
@@ -126,31 +126,31 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | function req_pokemon_live_data_test($pokemon_id) |
| 128 | 128 | { |
| 129 | - $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 130 | - return "SELECT MAX(individual_attack) AS iv FROM pokemon " . $where; |
|
| 129 | + $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 130 | + return "SELECT MAX(individual_attack) AS iv FROM pokemon " . $where; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | function req_pokemon_live_data($pokemon_id, $testIv, $post) |
| 134 | 134 | { |
| 135 | - global $mysqli, $time_offset; |
|
| 136 | - $inmap_pkms_filter = ""; |
|
| 137 | - $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 138 | - if (isset($post['inmap_pokemons']) && ($post['inmap_pokemons'] != "")) { |
|
| 139 | - foreach ($post['inmap_pokemons'] as $inmap) { |
|
| 140 | - $inmap_pkms_filter .= "'" . $inmap . "',"; |
|
| 141 | - } |
|
| 142 | - $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
|
| 143 | - $where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") "; |
|
| 144 | - } |
|
| 145 | - if ($testIv->iv != null && isset($post['ivMin']) && ($post['ivMin'] != "")) { |
|
| 146 | - $ivMin = mysqli_real_escape_string($mysqli, $post['ivMin']); |
|
| 147 | - $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (" . $ivMin . ") "; |
|
| 148 | - } |
|
| 149 | - if ($testIv->iv != null && isset($post['ivMax']) && ($post['ivMax'] != "")) { |
|
| 150 | - $ivMax = mysqli_real_escape_string($mysqli, $post['ivMax']); |
|
| 151 | - $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(" . $ivMax . ") "; |
|
| 152 | - } |
|
| 153 | - return "SELECT pokemon_id, encounter_id, latitude, longitude, disappear_time, |
|
| 135 | + global $mysqli, $time_offset; |
|
| 136 | + $inmap_pkms_filter = ""; |
|
| 137 | + $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 138 | + if (isset($post['inmap_pokemons']) && ($post['inmap_pokemons'] != "")) { |
|
| 139 | + foreach ($post['inmap_pokemons'] as $inmap) { |
|
| 140 | + $inmap_pkms_filter .= "'" . $inmap . "',"; |
|
| 141 | + } |
|
| 142 | + $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
|
| 143 | + $where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") "; |
|
| 144 | + } |
|
| 145 | + if ($testIv->iv != null && isset($post['ivMin']) && ($post['ivMin'] != "")) { |
|
| 146 | + $ivMin = mysqli_real_escape_string($mysqli, $post['ivMin']); |
|
| 147 | + $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (" . $ivMin . ") "; |
|
| 148 | + } |
|
| 149 | + if ($testIv->iv != null && isset($post['ivMax']) && ($post['ivMax'] != "")) { |
|
| 150 | + $ivMax = mysqli_real_escape_string($mysqli, $post['ivMax']); |
|
| 151 | + $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(" . $ivMax . ") "; |
|
| 152 | + } |
|
| 153 | + return "SELECT pokemon_id, encounter_id, latitude, longitude, disappear_time, |
|
| 154 | 154 | (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
| 155 | 155 | individual_attack, individual_defense, individual_stamina, move_1, move_2 |
| 156 | 156 | FROM pokemon " . $where . " |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | function req_pokemon_count_24h() |
| 162 | 162 | { |
| 163 | - return "SELECT pokemon_id, COUNT(*) AS spawns_last_day |
|
| 163 | + return "SELECT pokemon_id, COUNT(*) AS spawns_last_day |
|
| 164 | 164 | FROM pokemon |
| 165 | 165 | WHERE disappear_time >= (SELECT MAX(disappear_time) FROM pokemon) - INTERVAL 1 DAY |
| 166 | 166 | GROUP BY pokemon_id |
@@ -173,18 +173,18 @@ discard block |
||
| 173 | 173 | |
| 174 | 174 | function req_pokestop_count() |
| 175 | 175 | { |
| 176 | - return "SELECT COUNT(*) AS total FROM pokestop"; |
|
| 176 | + return "SELECT COUNT(*) AS total FROM pokestop"; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | function req_pokestop_lure_count() |
| 180 | 180 | { |
| 181 | - return "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 181 | + return "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | function req_pokestop_data() |
| 185 | 185 | { |
| 186 | - global $time_offset; |
|
| 187 | - return "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '" . $time_offset . "')) AS lure_expiration_real FROM pokestop "; |
|
| 186 | + global $time_offset; |
|
| 187 | + return "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '" . $time_offset . "')) AS lure_expiration_real FROM pokestop "; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Gyms |
@@ -192,41 +192,41 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | function req_gym_count() |
| 194 | 194 | { |
| 195 | - return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym"; |
|
| 195 | + return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym"; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | function req_gym_count_for_team($team_id) |
| 199 | 199 | { |
| 200 | - return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '$team_id'"; |
|
| 200 | + return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '$team_id'"; |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | function req_gym_guards_for_team($team_id) |
| 204 | 204 | { |
| 205 | - return "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"; |
|
| 205 | + return "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"; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | function req_gym_count_cp_for_team($team_id) |
| 209 | 209 | { |
| 210 | - return "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '$team_id'"; |
|
| 210 | + return "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '$team_id'"; |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | function req_gym_data() |
| 214 | 214 | { |
| 215 | - global $time_offset; |
|
| 216 | - return "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '" . $time_offset . "')) AS last_scanned, (6 - slots_available) AS level FROM gym"; |
|
| 215 | + global $time_offset; |
|
| 216 | + return "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '" . $time_offset . "')) AS last_scanned, (6 - slots_available) AS level FROM gym"; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | function req_gym_data_simple($gym_id) |
| 220 | 220 | { |
| 221 | - global $time_offset; |
|
| 222 | - return "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '" . $time_offset . "')) AS last_scanned, total_cp, (6 - slots_available) AS level |
|
| 221 | + global $time_offset; |
|
| 222 | + return "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '" . $time_offset . "')) AS last_scanned, total_cp, (6 - slots_available) AS level |
|
| 223 | 223 | FROM gym WHERE gym_id='" . $gym_id . "'"; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | function req_gym_defender_for($gym_id) |
| 227 | 227 | { |
| 228 | - global $time_offset; |
|
| 229 | - return "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 228 | + global $time_offset; |
|
| 229 | + return "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 230 | 230 | (CONVERT_TZ(gym.last_scanned, '+00:00', '" . $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 |
| 231 | 231 | FROM gymdetails |
| 232 | 232 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | function req_gym_defender_stats_for($gym_id) |
| 237 | 237 | { |
| 238 | - return "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 238 | + return "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 239 | 239 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 240 | 240 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
| 241 | 241 | HAVING gymmember.gym_id='" . $gym_id . "' |
@@ -247,38 +247,38 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | function req_trainers($get) |
| 249 | 249 | { |
| 250 | - global $config, $mysqli; |
|
| 251 | - if (isset($get['name'])) { |
|
| 252 | - $trainer_name = mysqli_real_escape_string($mysqli, $get['name']); |
|
| 253 | - $where = " HAVING name LIKE '%" . $trainer_name . "%'"; |
|
| 254 | - } |
|
| 255 | - if (isset($get['team']) && $get['team'] != 0) { |
|
| 256 | - $team = mysqli_real_escape_string($mysqli, $get['team']); |
|
| 257 | - $where .= ($where == "" ? " HAVING" : " AND") . " team = " . $team; |
|
| 258 | - } |
|
| 259 | - if (!empty($config->system->trainer_blacklist)) { |
|
| 260 | - $where .= ($where == "" ? " HAVING" : " AND") . " name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 261 | - } |
|
| 262 | - if (isset($get['page'])) { |
|
| 263 | - $page = mysqli_real_escape_string($mysqli, $get['page']); |
|
| 264 | - } |
|
| 265 | - if (isset($get['ranking'])) { |
|
| 266 | - $ranking = mysqli_real_escape_string($mysqli, $get['ranking']); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - switch ($ranking) { |
|
| 270 | - case 1: |
|
| 271 | - $order = " ORDER BY active DESC, level DESC"; |
|
| 272 | - break; |
|
| 273 | - case 2: |
|
| 274 | - $order = " ORDER BY maxCp DESC, level DESC"; |
|
| 275 | - break; |
|
| 276 | - default: |
|
| 277 | - $order = " ORDER BY level DESC, active DESC"; |
|
| 278 | - } |
|
| 279 | - $order .= ", last_seen DESC, name "; |
|
| 280 | - $limit = " LIMIT " . ($page * 10) . ",10 "; |
|
| 281 | - return "SELECT trainer.*, COUNT(actives_pokemons.trainer_name) AS active, max(actives_pokemons.cp) AS maxCp |
|
| 250 | + global $config, $mysqli; |
|
| 251 | + if (isset($get['name'])) { |
|
| 252 | + $trainer_name = mysqli_real_escape_string($mysqli, $get['name']); |
|
| 253 | + $where = " HAVING name LIKE '%" . $trainer_name . "%'"; |
|
| 254 | + } |
|
| 255 | + if (isset($get['team']) && $get['team'] != 0) { |
|
| 256 | + $team = mysqli_real_escape_string($mysqli, $get['team']); |
|
| 257 | + $where .= ($where == "" ? " HAVING" : " AND") . " team = " . $team; |
|
| 258 | + } |
|
| 259 | + if (!empty($config->system->trainer_blacklist)) { |
|
| 260 | + $where .= ($where == "" ? " HAVING" : " AND") . " name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 261 | + } |
|
| 262 | + if (isset($get['page'])) { |
|
| 263 | + $page = mysqli_real_escape_string($mysqli, $get['page']); |
|
| 264 | + } |
|
| 265 | + if (isset($get['ranking'])) { |
|
| 266 | + $ranking = mysqli_real_escape_string($mysqli, $get['ranking']); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + switch ($ranking) { |
|
| 270 | + case 1: |
|
| 271 | + $order = " ORDER BY active DESC, level DESC"; |
|
| 272 | + break; |
|
| 273 | + case 2: |
|
| 274 | + $order = " ORDER BY maxCp DESC, level DESC"; |
|
| 275 | + break; |
|
| 276 | + default: |
|
| 277 | + $order = " ORDER BY level DESC, active DESC"; |
|
| 278 | + } |
|
| 279 | + $order .= ", last_seen DESC, name "; |
|
| 280 | + $limit = " LIMIT " . ($page * 10) . ",10 "; |
|
| 281 | + return "SELECT trainer.*, COUNT(actives_pokemons.trainer_name) AS active, max(actives_pokemons.cp) AS maxCp |
|
| 282 | 282 | FROM trainer |
| 283 | 283 | LEFT JOIN (SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.trainer_name, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned |
| 284 | 284 | FROM gympokemon |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | |
| 290 | 290 | function req_trainer_active_pokemon($name) |
| 291 | 291 | { |
| 292 | - global $time_offset; |
|
| 293 | - return "(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', '" . $time_offset . "') as deployment_time, '1' AS active |
|
| 292 | + global $time_offset; |
|
| 293 | + return "(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', '" . $time_offset . "') as deployment_time, '1' AS active |
|
| 294 | 294 | FROM gympokemon INNER JOIN |
| 295 | 295 | (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 |
| 296 | 296 | ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | function req_trainer_inactive_pokemon($name) |
| 302 | 302 | { |
| 303 | - global $time_offset; |
|
| 304 | - return "(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', '" . $time_offset . "') as deployment_time, '0' AS active |
|
| 303 | + global $time_offset; |
|
| 304 | + return "(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', '" . $time_offset . "') as deployment_time, '0' AS active |
|
| 305 | 305 | FROM gympokemon LEFT JOIN |
| 306 | 306 | (SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember |
| 307 | 307 | ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid |
@@ -311,23 +311,23 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | function req_trainer_ranking($trainer) |
| 313 | 313 | { |
| 314 | - global $config; |
|
| 315 | - $reqRanking = "SELECT COUNT(1) AS rank FROM trainer WHERE level = " . $trainer->level; |
|
| 316 | - if (!empty($config->system->trainer_blacklist)) { |
|
| 317 | - $reqRanking .= " AND name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 318 | - } |
|
| 319 | - return $reqRanking; |
|
| 314 | + global $config; |
|
| 315 | + $reqRanking = "SELECT COUNT(1) AS rank FROM trainer WHERE level = " . $trainer->level; |
|
| 316 | + if (!empty($config->system->trainer_blacklist)) { |
|
| 317 | + $reqRanking .= " AND name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 318 | + } |
|
| 319 | + return $reqRanking; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | function req_trainer_levels_for_team($teamid) |
| 323 | 323 | { |
| 324 | - global $config; |
|
| 325 | - $reqLevels = "SELECT level, count(level) AS count FROM trainer WHERE team = '" . $teamid . "'"; |
|
| 326 | - if (!empty($config->system->trainer_blacklist)) { |
|
| 327 | - $reqLevels .= " AND name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 328 | - } |
|
| 329 | - $reqLevels .= " GROUP BY level"; |
|
| 330 | - return $reqLevels; |
|
| 324 | + global $config; |
|
| 325 | + $reqLevels = "SELECT level, count(level) AS count FROM trainer WHERE team = '" . $teamid . "'"; |
|
| 326 | + if (!empty($config->system->trainer_blacklist)) { |
|
| 327 | + $reqLevels .= " AND name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 328 | + } |
|
| 329 | + $reqLevels .= " GROUP BY level"; |
|
| 330 | + return $reqLevels; |
|
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | // Raids |
@@ -335,9 +335,9 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | function req_raids_data($page) |
| 337 | 337 | { |
| 338 | - global $time_offset; |
|
| 339 | - $limit = " LIMIT " . ($page * 10) . ",10"; |
|
| 340 | - return "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '" . $time_offset . "') AS spawn, CONVERT_TZ(raid.start, '+00:00', '" . $time_offset . "') AS start, CONVERT_TZ(raid.end, '+00:00', '" . $time_offset . "') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '" . $time_offset . "') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid |
|
| 338 | + global $time_offset; |
|
| 339 | + $limit = " LIMIT " . ($page * 10) . ",10"; |
|
| 340 | + return "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '" . $time_offset . "') AS spawn, CONVERT_TZ(raid.start, '+00:00', '" . $time_offset . "') AS start, CONVERT_TZ(raid.end, '+00:00', '" . $time_offset . "') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '" . $time_offset . "') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid |
|
| 341 | 341 | JOIN gymdetails ON gymdetails.gym_id = raid.gym_id |
| 342 | 342 | JOIN gym ON gym.gym_id = raid.gym_id |
| 343 | 343 | WHERE raid.end > UTC_TIMESTAMP() |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | |
| 350 | 350 | function req_captcha_count() |
| 351 | 351 | { |
| 352 | - return "SELECT SUM(accounts_captcha) AS total FROM mainworker"; |
|
| 352 | + return "SELECT SUM(accounts_captcha) AS total FROM mainworker"; |
|
| 353 | 353 | |
| 354 | 354 | } |
| 355 | 355 | |
@@ -358,17 +358,17 @@ discard block |
||
| 358 | 358 | |
| 359 | 359 | function req_tester_pokemon() |
| 360 | 360 | { |
| 361 | - return "SELECT COUNT(*) AS total FROM pokemon"; |
|
| 361 | + return "SELECT COUNT(*) AS total FROM pokemon"; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | function req_tester_gym() |
| 365 | 365 | { |
| 366 | - return "SELECT COUNT(*) AS total FROM gym"; |
|
| 366 | + return "SELECT COUNT(*) AS total FROM gym"; |
|
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | function req_tester_pokestop() |
| 370 | 370 | { |
| 371 | - return "SELECT COUNT(*) AS total FROM pokestop"; |
|
| 371 | + return "SELECT COUNT(*) AS total FROM pokestop"; |
|
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 374 | // Nests |
@@ -376,12 +376,12 @@ discard block |
||
| 376 | 376 | |
| 377 | 377 | function req_map_data() |
| 378 | 378 | { |
| 379 | - global $config; |
|
| 380 | - $pokemon_exclude_sql = ""; |
|
| 381 | - if (!empty($config->system->nest_exclude_pokemon)) { |
|
| 382 | - $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", $config->system->nest_exclude_pokemon) . ")"; |
|
| 383 | - } |
|
| 384 | - return "SELECT p.pokemon_id, max(p.latitude) AS latitude, max(p.longitude) AS longitude, count(p.pokemon_id) AS total_pokemon, s.latest_seen, (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900 AS duration |
|
| 379 | + global $config; |
|
| 380 | + $pokemon_exclude_sql = ""; |
|
| 381 | + if (!empty($config->system->nest_exclude_pokemon)) { |
|
| 382 | + $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", $config->system->nest_exclude_pokemon) . ")"; |
|
| 383 | + } |
|
| 384 | + return "SELECT p.pokemon_id, max(p.latitude) AS latitude, max(p.longitude) AS longitude, count(p.pokemon_id) AS total_pokemon, s.latest_seen, (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900 AS duration |
|
| 385 | 385 | FROM pokemon p |
| 386 | 386 | INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id) |
| 387 | 387 | WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL 24 HOUR |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | function req_mystic_pokemon($mythic_pokemon) |
| 32 | 32 | { |
| 33 | 33 | global $time_offset; |
| 34 | - return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 34 | + return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, |
|
| 35 | 35 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 36 | 36 | FROM pokemon |
| 37 | - WHERE pokemon_id IN (" . implode(",", $mythic_pokemon) . ") |
|
| 37 | + WHERE pokemon_id IN (" . implode(",", $mythic_pokemon).") |
|
| 38 | 38 | ORDER BY last_modified DESC |
| 39 | 39 | LIMIT 0,12"; |
| 40 | 40 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | function req_all_pokemon() |
| 43 | 43 | { |
| 44 | 44 | global $time_offset; |
| 45 | - return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 45 | + return "SELECT DISTINCT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, |
|
| 46 | 46 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 47 | 47 | FROM pokemon |
| 48 | 48 | ORDER BY last_modified DESC |
@@ -55,20 +55,20 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | function req_pokemon_total_count($pokemon_id) |
| 57 | 57 | { |
| 58 | - return "SELECT COUNT(*) AS pokemon_spawns FROM pokemon WHERE pokemon_id = '" . $pokemon_id . "'"; |
|
| 58 | + return "SELECT COUNT(*) AS pokemon_spawns FROM pokemon WHERE pokemon_id = '".$pokemon_id."'"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | function req_pokemon_total_gym_protected($pokemon_id) |
| 62 | 62 | { |
| 63 | - return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '" . $pokemon_id . "'"; |
|
| 63 | + return "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE guard_pokemon_id = '".$pokemon_id."'"; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | function req_pokemon_last_seen($pokemon_id) |
| 67 | 67 | { |
| 68 | 68 | global $time_offset; |
| 69 | - return "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, latitude, longitude |
|
| 69 | + return "SELECT disappear_time, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, latitude, longitude |
|
| 70 | 70 | FROM pokemon |
| 71 | - WHERE pokemon_id = '" . $pokemon_id . "' |
|
| 71 | + WHERE pokemon_id = '" . $pokemon_id."' |
|
| 72 | 72 | ORDER BY disappear_time DESC |
| 73 | 73 | LIMIT 0,1"; |
| 74 | 74 | } |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | function req_pokemon_get_top_50($pokemon_id, $top_order_by, $top_direction) |
| 77 | 77 | { |
| 78 | 78 | global $time_offset; |
| 79 | - return "SELECT (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS distime, pokemon_id, disappear_time, latitude, longitude, |
|
| 79 | + return "SELECT (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS distime, pokemon_id, disappear_time, latitude, longitude, |
|
| 80 | 80 | cp, individual_attack, individual_defense, individual_stamina, |
| 81 | 81 | ROUND(SUM(100*(individual_attack+individual_defense+individual_stamina)/45),1) AS IV, move_1, move_2, form |
| 82 | 82 | FROM pokemon |
| 83 | - WHERE pokemon_id = '" . $pokemon_id . "' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
| 83 | + WHERE pokemon_id = '" . $pokemon_id."' AND move_1 IS NOT NULL AND move_1 <> '0' |
|
| 84 | 84 | GROUP BY encounter_id |
| 85 | 85 | ORDER BY $top_order_by $top_direction, disappear_time DESC |
| 86 | 86 | LIMIT 0,50"; |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | global $config; |
| 92 | 92 | $trainer_blacklist = ""; |
| 93 | 93 | if (!empty($config->system->trainer_blacklist)) { |
| 94 | - $trainer_blacklist = " AND trainer_name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 94 | + $trainer_blacklist = " AND trainer_name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')"; |
|
| 95 | 95 | } |
| 96 | 96 | return "SELECT trainer_name, ROUND(SUM(100*(iv_attack+iv_defense+iv_stamina)/45),1) AS IV, move_1, move_2, cp, |
| 97 | 97 | DATE_FORMAT(last_seen, '%Y-%m-%d') AS lasttime, last_seen |
| 98 | 98 | FROM gympokemon |
| 99 | - WHERE pokemon_id = '" . $pokemon_id . "'" . $trainer_blacklist . " |
|
| 99 | + WHERE pokemon_id = '" . $pokemon_id."'".$trainer_blacklist." |
|
| 100 | 100 | GROUP BY pokemon_uid |
| 101 | 101 | ORDER BY $best_order_by $best_direction, trainer_name ASC |
| 102 | 102 | LIMIT 0,50"; |
@@ -109,51 +109,51 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | function req_pokemon_headmap_points($pokemon_id, $start, $end) |
| 111 | 111 | { |
| 112 | - $where = " WHERE pokemon_id = " . $pokemon_id . " " |
|
| 113 | - . "AND disappear_time BETWEEN '" . $start . "' AND '" . $end . "'"; |
|
| 114 | - return "SELECT latitude, longitude FROM pokemon" . $where . " ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 112 | + $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 113 | + . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 114 | + return "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function req_pokemon_graph_data($pokemon_id) |
| 118 | 118 | { |
| 119 | 119 | global $time_offset; |
| 120 | 120 | return "SELECT COUNT(*) AS total, |
| 121 | - HOUR(CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_hour |
|
| 122 | - FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '" . $pokemon_id . "' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
|
| 121 | + HOUR(CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset."')) AS disappear_hour |
|
| 122 | + FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '" . $pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
|
| 123 | 123 | GROUP BY disappear_hour |
| 124 | 124 | ORDER BY disappear_hour"; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | function req_pokemon_live_data_test($pokemon_id) |
| 128 | 128 | { |
| 129 | - $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 130 | - return "SELECT MAX(individual_attack) AS iv FROM pokemon " . $where; |
|
| 129 | + $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id; |
|
| 130 | + return "SELECT MAX(individual_attack) AS iv FROM pokemon ".$where; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | function req_pokemon_live_data($pokemon_id, $testIv, $post) |
| 134 | 134 | { |
| 135 | 135 | global $mysqli, $time_offset; |
| 136 | 136 | $inmap_pkms_filter = ""; |
| 137 | - $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = " . $pokemon_id; |
|
| 137 | + $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id; |
|
| 138 | 138 | if (isset($post['inmap_pokemons']) && ($post['inmap_pokemons'] != "")) { |
| 139 | 139 | foreach ($post['inmap_pokemons'] as $inmap) { |
| 140 | - $inmap_pkms_filter .= "'" . $inmap . "',"; |
|
| 140 | + $inmap_pkms_filter .= "'".$inmap."',"; |
|
| 141 | 141 | } |
| 142 | 142 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
| 143 | - $where .= " AND encounter_id NOT IN (" . $inmap_pkms_filter . ") "; |
|
| 143 | + $where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") "; |
|
| 144 | 144 | } |
| 145 | 145 | if ($testIv->iv != null && isset($post['ivMin']) && ($post['ivMin'] != "")) { |
| 146 | 146 | $ivMin = mysqli_real_escape_string($mysqli, $post['ivMin']); |
| 147 | - $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (" . $ivMin . ") "; |
|
| 147 | + $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") "; |
|
| 148 | 148 | } |
| 149 | 149 | if ($testIv->iv != null && isset($post['ivMax']) && ($post['ivMax'] != "")) { |
| 150 | 150 | $ivMax = mysqli_real_escape_string($mysqli, $post['ivMax']); |
| 151 | - $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(" . $ivMax . ") "; |
|
| 151 | + $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(".$ivMax.") "; |
|
| 152 | 152 | } |
| 153 | 153 | return "SELECT pokemon_id, encounter_id, latitude, longitude, disappear_time, |
| 154 | - (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset . "')) AS disappear_time_real, |
|
| 154 | + (CONVERT_TZ(disappear_time, '+00:00', '" . $time_offset."')) AS disappear_time_real, |
|
| 155 | 155 | individual_attack, individual_defense, individual_stamina, move_1, move_2 |
| 156 | - FROM pokemon " . $where . " |
|
| 156 | + FROM pokemon " . $where." |
|
| 157 | 157 | ORDER BY disappear_time DESC |
| 158 | 158 | LIMIT 5000"; |
| 159 | 159 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | function req_pokestop_data() |
| 185 | 185 | { |
| 186 | 186 | global $time_offset; |
| 187 | - return "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '" . $time_offset . "')) AS lure_expiration_real FROM pokestop "; |
|
| 187 | + return "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop "; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | // Gyms |
@@ -213,24 +213,24 @@ discard block |
||
| 213 | 213 | function req_gym_data() |
| 214 | 214 | { |
| 215 | 215 | global $time_offset; |
| 216 | - return "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '" . $time_offset . "')) AS last_scanned, (6 - slots_available) AS level FROM gym"; |
|
| 216 | + return "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (6 - slots_available) AS level FROM gym"; |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | function req_gym_data_simple($gym_id) |
| 220 | 220 | { |
| 221 | 221 | global $time_offset; |
| 222 | - return "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '" . $time_offset . "')) AS last_scanned, total_cp, (6 - slots_available) AS level |
|
| 223 | - FROM gym WHERE gym_id='" . $gym_id . "'"; |
|
| 222 | + return "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, total_cp, (6 - slots_available) AS level |
|
| 223 | + FROM gym WHERE gym_id='" . $gym_id."'"; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | function req_gym_defender_for($gym_id) |
| 227 | 227 | { |
| 228 | 228 | global $time_offset; |
| 229 | 229 | return "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
| 230 | - (CONVERT_TZ(gym.last_scanned, '+00:00', '" . $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 |
|
| 230 | + (CONVERT_TZ(gym.last_scanned, '+00:00', '" . $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 |
|
| 231 | 231 | FROM gymdetails |
| 232 | 232 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
| 233 | - WHERE gym.gym_id='" . $gym_id . "'"; |
|
| 233 | + WHERE gym.gym_id='" . $gym_id."'"; |
|
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | function req_gym_defender_stats_for($gym_id) |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | return "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
| 239 | 239 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 240 | 240 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
| 241 | - HAVING gymmember.gym_id='" . $gym_id . "' |
|
| 241 | + HAVING gymmember.gym_id='" . $gym_id."' |
|
| 242 | 242 | ORDER BY cp DESC"; |
| 243 | 243 | } |
| 244 | 244 | |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | global $config, $mysqli; |
| 251 | 251 | if (isset($get['name'])) { |
| 252 | 252 | $trainer_name = mysqli_real_escape_string($mysqli, $get['name']); |
| 253 | - $where = " HAVING name LIKE '%" . $trainer_name . "%'"; |
|
| 253 | + $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 254 | 254 | } |
| 255 | 255 | if (isset($get['team']) && $get['team'] != 0) { |
| 256 | 256 | $team = mysqli_real_escape_string($mysqli, $get['team']); |
| 257 | - $where .= ($where == "" ? " HAVING" : " AND") . " team = " . $team; |
|
| 257 | + $where .= ($where == "" ? " HAVING" : " AND")." team = ".$team; |
|
| 258 | 258 | } |
| 259 | 259 | if (!empty($config->system->trainer_blacklist)) { |
| 260 | - $where .= ($where == "" ? " HAVING" : " AND") . " name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 260 | + $where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')"; |
|
| 261 | 261 | } |
| 262 | 262 | if (isset($get['page'])) { |
| 263 | 263 | $page = mysqli_real_escape_string($mysqli, $get['page']); |
@@ -277,44 +277,44 @@ discard block |
||
| 277 | 277 | $order = " ORDER BY level DESC, active DESC"; |
| 278 | 278 | } |
| 279 | 279 | $order .= ", last_seen DESC, name "; |
| 280 | - $limit = " LIMIT " . ($page * 10) . ",10 "; |
|
| 280 | + $limit = " LIMIT ".($page * 10).",10 "; |
|
| 281 | 281 | return "SELECT trainer.*, COUNT(actives_pokemons.trainer_name) AS active, max(actives_pokemons.cp) AS maxCp |
| 282 | 282 | FROM trainer |
| 283 | 283 | LEFT JOIN (SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.trainer_name, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned |
| 284 | 284 | FROM gympokemon |
| 285 | 285 | 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 |
| 286 | 286 | ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid) AS actives_pokemons ON actives_pokemons.trainer_name = trainer.name |
| 287 | - GROUP BY trainer.name " . $where . $order . $limit; |
|
| 287 | + GROUP BY trainer.name " . $where.$order.$limit; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | function req_trainer_active_pokemon($name) |
| 291 | 291 | { |
| 292 | 292 | global $time_offset; |
| 293 | - return "(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', '" . $time_offset . "') as deployment_time, '1' AS active |
|
| 293 | + return "(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', '".$time_offset."') as deployment_time, '1' AS active |
|
| 294 | 294 | FROM gympokemon INNER JOIN |
| 295 | 295 | (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 |
| 296 | 296 | ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid |
| 297 | - WHERE gympokemon.trainer_name='" . $name . "' |
|
| 297 | + WHERE gympokemon.trainer_name='" . $name."' |
|
| 298 | 298 | ORDER BY gympokemon.cp DESC)"; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | function req_trainer_inactive_pokemon($name) |
| 302 | 302 | { |
| 303 | 303 | global $time_offset; |
| 304 | - return "(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', '" . $time_offset . "') as deployment_time, '0' AS active |
|
| 304 | + return "(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', '".$time_offset."') as deployment_time, '0' AS active |
|
| 305 | 305 | FROM gympokemon LEFT JOIN |
| 306 | 306 | (SELECT * FROM gymmember HAVING gymmember.gym_id <> '') AS filtered_gymmember |
| 307 | 307 | ON gympokemon.pokemon_uid = filtered_gymmember.pokemon_uid |
| 308 | - WHERE filtered_gymmember.pokemon_uid IS NULL AND gympokemon.trainer_name='" . $name . "' |
|
| 308 | + WHERE filtered_gymmember.pokemon_uid IS NULL AND gympokemon.trainer_name='" . $name."' |
|
| 309 | 309 | ORDER BY gympokemon.cp DESC)"; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | function req_trainer_ranking($trainer) |
| 313 | 313 | { |
| 314 | 314 | global $config; |
| 315 | - $reqRanking = "SELECT COUNT(1) AS rank FROM trainer WHERE level = " . $trainer->level; |
|
| 315 | + $reqRanking = "SELECT COUNT(1) AS rank FROM trainer WHERE level = ".$trainer->level; |
|
| 316 | 316 | if (!empty($config->system->trainer_blacklist)) { |
| 317 | - $reqRanking .= " AND name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 317 | + $reqRanking .= " AND name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')"; |
|
| 318 | 318 | } |
| 319 | 319 | return $reqRanking; |
| 320 | 320 | } |
@@ -322,9 +322,9 @@ discard block |
||
| 322 | 322 | function req_trainer_levels_for_team($teamid) |
| 323 | 323 | { |
| 324 | 324 | global $config; |
| 325 | - $reqLevels = "SELECT level, count(level) AS count FROM trainer WHERE team = '" . $teamid . "'"; |
|
| 325 | + $reqLevels = "SELECT level, count(level) AS count FROM trainer WHERE team = '".$teamid."'"; |
|
| 326 | 326 | if (!empty($config->system->trainer_blacklist)) { |
| 327 | - $reqLevels .= " AND name NOT IN ('" . implode("','", $config->system->trainer_blacklist) . "')"; |
|
| 327 | + $reqLevels .= " AND name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')"; |
|
| 328 | 328 | } |
| 329 | 329 | $reqLevels .= " GROUP BY level"; |
| 330 | 330 | return $reqLevels; |
@@ -336,8 +336,8 @@ discard block |
||
| 336 | 336 | function req_raids_data($page) |
| 337 | 337 | { |
| 338 | 338 | global $time_offset; |
| 339 | - $limit = " LIMIT " . ($page * 10) . ",10"; |
|
| 340 | - return "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '" . $time_offset . "') AS spawn, CONVERT_TZ(raid.start, '+00:00', '" . $time_offset . "') AS start, CONVERT_TZ(raid.end, '+00:00', '" . $time_offset . "') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '" . $time_offset . "') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid |
|
| 339 | + $limit = " LIMIT ".($page * 10).",10"; |
|
| 340 | + return "SELECT raid.gym_id, raid.level, raid.pokemon_id, raid.cp, raid.move_1, raid.move_2, CONVERT_TZ(raid.spawn, '+00:00', '".$time_offset."') AS spawn, CONVERT_TZ(raid.start, '+00:00', '".$time_offset."') AS start, CONVERT_TZ(raid.end, '+00:00', '".$time_offset."') AS end, CONVERT_TZ(raid.last_scanned, '+00:00', '".$time_offset."') AS last_scanned, gymdetails.name, gym.latitude, gym.longitude FROM raid |
|
| 341 | 341 | JOIN gymdetails ON gymdetails.gym_id = raid.gym_id |
| 342 | 342 | JOIN gym ON gym.gym_id = raid.gym_id |
| 343 | 343 | WHERE raid.end > UTC_TIMESTAMP() |
@@ -379,13 +379,13 @@ discard block |
||
| 379 | 379 | global $config; |
| 380 | 380 | $pokemon_exclude_sql = ""; |
| 381 | 381 | if (!empty($config->system->nest_exclude_pokemon)) { |
| 382 | - $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (" . implode(",", $config->system->nest_exclude_pokemon) . ")"; |
|
| 382 | + $pokemon_exclude_sql = "AND p.pokemon_id NOT IN (".implode(",", $config->system->nest_exclude_pokemon).")"; |
|
| 383 | 383 | } |
| 384 | 384 | return "SELECT p.pokemon_id, max(p.latitude) AS latitude, max(p.longitude) AS longitude, count(p.pokemon_id) AS total_pokemon, s.latest_seen, (LENGTH(s.kind) - LENGTH( REPLACE ( kind, \"s\", \"\") )) * 900 AS duration |
| 385 | 385 | FROM pokemon p |
| 386 | 386 | INNER JOIN spawnpoint s ON (p.spawnpoint_id = s.id) |
| 387 | 387 | WHERE p.disappear_time > UTC_TIMESTAMP() - INTERVAL 24 HOUR |
| 388 | - " . $pokemon_exclude_sql . " |
|
| 388 | + " . $pokemon_exclude_sql." |
|
| 389 | 389 | GROUP BY p.spawnpoint_id, p.pokemon_id |
| 390 | 390 | HAVING COUNT(p.pokemon_id) >= 6 |
| 391 | 391 | ORDER BY p.pokemon_id"; |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | // Right now |
| 68 | 68 | // --------- |
| 69 | 69 | |
| 70 | - $result = $mysqli->query(req_pokemon_count()); |
|
| 70 | + $result = $mysqli->query(req_pokemon_count()); |
|
| 71 | 71 | $data = $result->fetch_object(); |
| 72 | 72 | |
| 73 | 73 | $values[] = $data->total; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | // Lured stops |
| 77 | 77 | // ----------- |
| 78 | 78 | |
| 79 | - $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 79 | + $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 80 | 80 | $data = $result->fetch_object(); |
| 81 | 81 | |
| 82 | 82 | $values[] = $data->total; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | // Team battle |
| 87 | 87 | // ----------- |
| 88 | 88 | |
| 89 | - $result = $mysqli->query(req_gym_count()); |
|
| 89 | + $result = $mysqli->query(req_gym_count()); |
|
| 90 | 90 | $data = $result->fetch_object(); |
| 91 | 91 | |
| 92 | 92 | $values[] = $data->total; |
@@ -96,27 +96,27 @@ discard block |
||
| 96 | 96 | // 2 = rouge |
| 97 | 97 | // 3 = jaune |
| 98 | 98 | |
| 99 | - $result = $mysqli->query(req_gym_count_for_team(2)); |
|
| 99 | + $result = $mysqli->query(req_gym_count_for_team(2)); |
|
| 100 | 100 | $data = $result->fetch_object(); |
| 101 | 101 | |
| 102 | 102 | // Red |
| 103 | 103 | $values[] = $data->total; |
| 104 | 104 | |
| 105 | 105 | |
| 106 | - $result = $mysqli->query(req_gym_count_for_team(1)); |
|
| 106 | + $result = $mysqli->query(req_gym_count_for_team(1)); |
|
| 107 | 107 | $data = $result->fetch_object(); |
| 108 | 108 | |
| 109 | 109 | // Blue |
| 110 | 110 | $values[] = $data->total; |
| 111 | 111 | |
| 112 | 112 | |
| 113 | - $result = $mysqli->query(req_gym_count_for_team(3)); |
|
| 113 | + $result = $mysqli->query(req_gym_count_for_team(3)); |
|
| 114 | 114 | $data = $result->fetch_object(); |
| 115 | 115 | |
| 116 | 116 | // Yellow |
| 117 | 117 | $values[] = $data->total; |
| 118 | 118 | |
| 119 | - $result = $mysqli->query(req_gym_count_for_team(0)); |
|
| 119 | + $result = $mysqli->query(req_gym_count_for_team(0)); |
|
| 120 | 120 | $data = $result->fetch_object(); |
| 121 | 121 | |
| 122 | 122 | // Neutral |
@@ -152,12 +152,12 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // get last mythic pokemon |
| 155 | - $req_poke = req_mystic_pokemon($mythic_pokemons); |
|
| 156 | - } else { |
|
| 155 | + $req_poke = req_mystic_pokemon($mythic_pokemons); |
|
| 156 | + } else { |
|
| 157 | 157 | // get last pokemon |
| 158 | - $req_poke = req_all_pokemon(); |
|
| 159 | - } |
|
| 160 | - $result = $mysqli->query($req_poke); |
|
| 158 | + $req_poke = req_all_pokemon(); |
|
| 159 | + } |
|
| 160 | + $result = $mysqli->query($req_poke); |
|
| 161 | 161 | while ($data = $result->fetch_object()) { |
| 162 | 162 | $new_spawn = array(); |
| 163 | 163 | $pokeid = $data->pokemon_id; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | #################################### |
| 271 | 271 | |
| 272 | 272 | case 'pokestop': |
| 273 | - $result = $mysqli->query(req_pokestop_data()); |
|
| 273 | + $result = $mysqli->query(req_pokestop_data()); |
|
| 274 | 274 | |
| 275 | 275 | $pokestops = []; |
| 276 | 276 | |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | |
| 316 | 316 | foreach ($teams as $team_name => $team_id) { |
| 317 | - $result = $mysqli->query(req_gym_count_cp_for_team($team_id)); |
|
| 317 | + $result = $mysqli->query(req_gym_count_cp_for_team($team_id)); |
|
| 318 | 318 | $data = $result->fetch_object(); |
| 319 | 319 | |
| 320 | 320 | $return[] = $data->total; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | |
| 336 | 336 | |
| 337 | 337 | case 'gym_map': |
| 338 | - $result = $mysqli->query(req_gym_data()); |
|
| 338 | + $result = $mysqli->query(req_gym_data()); |
|
| 339 | 339 | |
| 340 | 340 | $gyms = []; |
| 341 | 341 | |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | case 'gym_defenders': |
| 399 | 399 | $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
| 400 | - $result = $mysqli->query(req_gym_defender_for($gym_id)); |
|
| 400 | + $result = $mysqli->query(req_gym_defender_for($gym_id)); |
|
| 401 | 401 | |
| 402 | 402 | $gymData['gymDetails']['gymInfos'] = false; |
| 403 | 403 | |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - $result = $mysqli->query(req_gym_defender_stats_for($gym_id)); |
|
| 419 | + $result = $mysqli->query(req_gym_defender_stats_for($gym_id)); |
|
| 420 | 420 | |
| 421 | 421 | $i = 0; |
| 422 | 422 | |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | // check whether we could retrieve gym infos, otherwise use basic gym info |
| 482 | 482 | if (!$gymData['gymDetails']['gymInfos']) { |
| 483 | 483 | |
| 484 | - $result = $mysqli->query(req_gym_data_simple($gym_id)); |
|
| 484 | + $result = $mysqli->query(req_gym_data_simple($gym_id)); |
|
| 485 | 485 | $data = $result->fetch_object(); |
| 486 | 486 | |
| 487 | 487 | $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
@@ -517,19 +517,19 @@ discard block |
||
| 517 | 517 | $team = 0; |
| 518 | 518 | $ranking = 0; |
| 519 | 519 | |
| 520 | - $result = $mysqli->query(req_trainers($_GET)); |
|
| 520 | + $result = $mysqli->query(req_trainers($_GET)); |
|
| 521 | 521 | $trainers = array(); |
| 522 | 522 | while ($data = $result->fetch_object()) { |
| 523 | 523 | $data->last_seen = date("Y-m-d", strtotime($data->last_seen)); |
| 524 | 524 | $trainers[$data->name] = $data; |
| 525 | 525 | } |
| 526 | 526 | foreach ($trainers as $trainer) { |
| 527 | - $resultRanking = $mysqli->query(req_trainer_ranking($trainer)); |
|
| 527 | + $resultRanking = $mysqli->query(req_trainer_ranking($trainer)); |
|
| 528 | 528 | while ($data = $resultRanking->fetch_object()) { |
| 529 | 529 | $trainer->rank = $data->rank; |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - $resultPkms = $mysqli->query(req_trainer_active_pokemon($trainer->name)); |
|
| 532 | + $resultPkms = $mysqli->query(req_trainer_active_pokemon($trainer->name)); |
|
| 533 | 533 | $trainer->pokemons = array(); |
| 534 | 534 | $active_gyms = 0; |
| 535 | 535 | $pkmCount = 0; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | } |
| 540 | 540 | $trainer->gyms = $active_gyms; |
| 541 | 541 | |
| 542 | - $resultPkms = $mysqli->query(req_trainer_inactive_pokemon($trainer->name)); |
|
| 542 | + $resultPkms = $mysqli->query(req_trainer_inactive_pokemon($trainer->name)); |
|
| 543 | 543 | while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
| 544 | 544 | $trainer->pokemons[$pkmCount++] = $dataPkm; |
| 545 | 545 | } |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | - $result = $mysqli->query(req_raids_data($page)); |
|
| 570 | + $result = $mysqli->query(req_raids_data($page)); |
|
| 571 | 571 | $raids = array(); |
| 572 | 572 | while ($data = $result->fetch_object()) { |
| 573 | 573 | $data->starttime = date("H:i", strtotime($data->start)); |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | break; |
| 600 | 600 | |
| 601 | 601 | case 'pokemon_slider_init': |
| 602 | - $result = $mysqli->query(req_pokemon_slider_init()); |
|
| 602 | + $result = $mysqli->query(req_pokemon_slider_init()); |
|
| 603 | 603 | $bounds = $result->fetch_object(); |
| 604 | 604 | |
| 605 | 605 | header('Content-Type: application/json'); |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | $start = date("Y-m-d H:i", (int) $_GET['start']); |
| 615 | 615 | $end = date("Y-m-d H:i", (int) $_GET['end']); |
| 616 | 616 | $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
| 617 | - $result = $mysqli->query(req_pokemon_headmap_points($pokemon_id, $start, $end)); |
|
| 617 | + $result = $mysqli->query(req_pokemon_headmap_points($pokemon_id, $start, $end)); |
|
| 618 | 618 | $points = array(); |
| 619 | 619 | while ($result && $data = $result->fetch_object()) { |
| 620 | 620 | $points[] = $data; |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | |
| 631 | 631 | case 'maps_localization_coordinates': |
| 632 | 632 | $json = ""; |
| 633 | - $result = $mysqli->query(req_maps_localization_coordinates()); |
|
| 633 | + $result = $mysqli->query(req_maps_localization_coordinates()); |
|
| 634 | 634 | $coordinates = $result->fetch_object(); |
| 635 | 635 | |
| 636 | 636 | header('Content-Type: application/json'); |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | $json = ""; |
| 644 | 644 | if (isset($_GET['pokemon_id'])) { |
| 645 | 645 | $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
| 646 | - $result = $mysqli->query(req_pokemon_graph_data($pokemon_id)); |
|
| 646 | + $result = $mysqli->query(req_pokemon_graph_data($pokemon_id)); |
|
| 647 | 647 | $array = array_fill(0, 24, 0); |
| 648 | 648 | while ($result && $data = $result->fetch_object()) { |
| 649 | 649 | $array[$data->disappear_hour] = $data->total; |
@@ -674,9 +674,9 @@ discard block |
||
| 674 | 674 | case 'pokemon_live': |
| 675 | 675 | $json = ""; |
| 676 | 676 | if (isset($_POST['pokemon_id'])) { |
| 677 | - $resultTestIv = $mysqli->query(req_pokemon_liva_data_test($pokemon_id)); |
|
| 677 | + $resultTestIv = $mysqli->query(req_pokemon_liva_data_test($pokemon_id)); |
|
| 678 | 678 | $testIv = $resultTestIv->fetch_object(); |
| 679 | - $result = $mysqli->query(req_pokemon_live_data($pokemon_id, $testIv, $_POST)); |
|
| 679 | + $result = $mysqli->query(req_pokemon_live_data($pokemon_id, $testIv, $_POST)); |
|
| 680 | 680 | $json = array(); |
| 681 | 681 | $json['points'] = array(); |
| 682 | 682 | $locale = array(); |
@@ -63,137 +63,137 @@ discard block |
||
| 63 | 63 | // |
| 64 | 64 | ############################ |
| 65 | 65 | |
| 66 | - case 'home_update': |
|
| 67 | - // Right now |
|
| 68 | - // --------- |
|
| 66 | + case 'home_update': |
|
| 67 | + // Right now |
|
| 68 | + // --------- |
|
| 69 | 69 | |
| 70 | - $result = $mysqli->query(req_pokemon_count()); |
|
| 71 | - $data = $result->fetch_object(); |
|
| 70 | + $result = $mysqli->query(req_pokemon_count()); |
|
| 71 | + $data = $result->fetch_object(); |
|
| 72 | 72 | |
| 73 | - $values[] = $data->total; |
|
| 73 | + $values[] = $data->total; |
|
| 74 | 74 | |
| 75 | 75 | |
| 76 | - // Lured stops |
|
| 77 | - // ----------- |
|
| 76 | + // Lured stops |
|
| 77 | + // ----------- |
|
| 78 | 78 | |
| 79 | - $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 80 | - $data = $result->fetch_object(); |
|
| 79 | + $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 80 | + $data = $result->fetch_object(); |
|
| 81 | 81 | |
| 82 | - $values[] = $data->total; |
|
| 82 | + $values[] = $data->total; |
|
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | |
| 86 | - // Team battle |
|
| 87 | - // ----------- |
|
| 86 | + // Team battle |
|
| 87 | + // ----------- |
|
| 88 | 88 | |
| 89 | - $result = $mysqli->query(req_gym_count()); |
|
| 90 | - $data = $result->fetch_object(); |
|
| 89 | + $result = $mysqli->query(req_gym_count()); |
|
| 90 | + $data = $result->fetch_object(); |
|
| 91 | 91 | |
| 92 | - $values[] = $data->total; |
|
| 92 | + $values[] = $data->total; |
|
| 93 | 93 | |
| 94 | - // Team |
|
| 95 | - // 1 = bleu |
|
| 96 | - // 2 = rouge |
|
| 97 | - // 3 = jaune |
|
| 94 | + // Team |
|
| 95 | + // 1 = bleu |
|
| 96 | + // 2 = rouge |
|
| 97 | + // 3 = jaune |
|
| 98 | 98 | |
| 99 | - $result = $mysqli->query(req_gym_count_for_team(2)); |
|
| 100 | - $data = $result->fetch_object(); |
|
| 99 | + $result = $mysqli->query(req_gym_count_for_team(2)); |
|
| 100 | + $data = $result->fetch_object(); |
|
| 101 | 101 | |
| 102 | - // Red |
|
| 103 | - $values[] = $data->total; |
|
| 102 | + // Red |
|
| 103 | + $values[] = $data->total; |
|
| 104 | 104 | |
| 105 | 105 | |
| 106 | - $result = $mysqli->query(req_gym_count_for_team(1)); |
|
| 107 | - $data = $result->fetch_object(); |
|
| 106 | + $result = $mysqli->query(req_gym_count_for_team(1)); |
|
| 107 | + $data = $result->fetch_object(); |
|
| 108 | 108 | |
| 109 | - // Blue |
|
| 110 | - $values[] = $data->total; |
|
| 109 | + // Blue |
|
| 110 | + $values[] = $data->total; |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | - $result = $mysqli->query(req_gym_count_for_team(3)); |
|
| 114 | - $data = $result->fetch_object(); |
|
| 113 | + $result = $mysqli->query(req_gym_count_for_team(3)); |
|
| 114 | + $data = $result->fetch_object(); |
|
| 115 | 115 | |
| 116 | - // Yellow |
|
| 117 | - $values[] = $data->total; |
|
| 116 | + // Yellow |
|
| 117 | + $values[] = $data->total; |
|
| 118 | 118 | |
| 119 | - $result = $mysqli->query(req_gym_count_for_team(0)); |
|
| 120 | - $data = $result->fetch_object(); |
|
| 119 | + $result = $mysqli->query(req_gym_count_for_team(0)); |
|
| 120 | + $data = $result->fetch_object(); |
|
| 121 | 121 | |
| 122 | - // Neutral |
|
| 123 | - $values[] = $data->total; |
|
| 122 | + // Neutral |
|
| 123 | + $values[] = $data->total; |
|
| 124 | 124 | |
| 125 | - header('Content-Type: application/json'); |
|
| 126 | - echo json_encode($values); |
|
| 125 | + header('Content-Type: application/json'); |
|
| 126 | + echo json_encode($values); |
|
| 127 | 127 | |
| 128 | - break; |
|
| 128 | + break; |
|
| 129 | 129 | |
| 130 | 130 | |
| 131 | - #################################### |
|
| 132 | - // |
|
| 133 | - // Update latests spawn on homepage |
|
| 134 | - // |
|
| 135 | - #################################### |
|
| 131 | + #################################### |
|
| 132 | + // |
|
| 133 | + // Update latests spawn on homepage |
|
| 134 | + // |
|
| 135 | + #################################### |
|
| 136 | 136 | |
| 137 | - case 'spawnlist_update': |
|
| 138 | - // Recent spawn |
|
| 139 | - // ------------ |
|
| 140 | - $total_spawns = array(); |
|
| 141 | - $last_uid_param = ""; |
|
| 142 | - if (isset($_GET['last_uid'])) { |
|
| 143 | - $last_uid_param = $_GET['last_uid']; |
|
| 144 | - } |
|
| 145 | - if ($config->system->recents_filter) { |
|
| 146 | - // get all mythic pokemon ids |
|
| 147 | - $mythic_pokemons = array(); |
|
| 148 | - foreach ($pokemons->pokemon as $id => $pokemon) { |
|
| 149 | - if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
| 150 | - $mythic_pokemons[] = $id; |
|
| 151 | - } |
|
| 137 | + case 'spawnlist_update': |
|
| 138 | + // Recent spawn |
|
| 139 | + // ------------ |
|
| 140 | + $total_spawns = array(); |
|
| 141 | + $last_uid_param = ""; |
|
| 142 | + if (isset($_GET['last_uid'])) { |
|
| 143 | + $last_uid_param = $_GET['last_uid']; |
|
| 152 | 144 | } |
| 153 | - |
|
| 154 | - // get last mythic pokemon |
|
| 155 | - $req_poke = req_mystic_pokemon($mythic_pokemons); |
|
| 156 | - } else { |
|
| 157 | - // get last pokemon |
|
| 158 | - $req_poke = req_all_pokemon(); |
|
| 159 | - } |
|
| 160 | - $result = $mysqli->query($req_poke); |
|
| 161 | - while ($data = $result->fetch_object()) { |
|
| 162 | - $new_spawn = array(); |
|
| 163 | - $pokeid = $data->pokemon_id; |
|
| 164 | - $pokeuid = $data->encounter_id; |
|
| 165 | - |
|
| 166 | - if ($last_uid_param != $pokeuid) { |
|
| 167 | - $last_seen = strtotime($data->disappear_time_real); |
|
| 168 | - |
|
| 169 | - $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
| 170 | - $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
| 171 | - $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
| 172 | - |
|
| 173 | - if ($config->system->recents_encounter_details) { |
|
| 174 | - $encdetails = new stdClass(); |
|
| 175 | - $encdetails->cp = $data->cp; |
|
| 176 | - $encdetails->attack = $data->individual_attack; |
|
| 177 | - $encdetails->defense = $data->individual_defense; |
|
| 178 | - $encdetails->stamina = $data->individual_stamina; |
|
| 179 | - if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
| 180 | - $encdetails->available = true; |
|
| 181 | - } else { |
|
| 182 | - $encdetails->available = false; |
|
| 145 | + if ($config->system->recents_filter) { |
|
| 146 | + // get all mythic pokemon ids |
|
| 147 | + $mythic_pokemons = array(); |
|
| 148 | + foreach ($pokemons->pokemon as $id => $pokemon) { |
|
| 149 | + if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
| 150 | + $mythic_pokemons[] = $id; |
|
| 183 | 151 | } |
| 184 | 152 | } |
| 185 | 153 | |
| 186 | - $html = ' |
|
| 154 | + // get last mythic pokemon |
|
| 155 | + $req_poke = req_mystic_pokemon($mythic_pokemons); |
|
| 156 | + } else { |
|
| 157 | + // get last pokemon |
|
| 158 | + $req_poke = req_all_pokemon(); |
|
| 159 | + } |
|
| 160 | + $result = $mysqli->query($req_poke); |
|
| 161 | + while ($data = $result->fetch_object()) { |
|
| 162 | + $new_spawn = array(); |
|
| 163 | + $pokeid = $data->pokemon_id; |
|
| 164 | + $pokeuid = $data->encounter_id; |
|
| 165 | + |
|
| 166 | + if ($last_uid_param != $pokeuid) { |
|
| 167 | + $last_seen = strtotime($data->disappear_time_real); |
|
| 168 | + |
|
| 169 | + $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
| 170 | + $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
| 171 | + $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
| 172 | + |
|
| 173 | + if ($config->system->recents_encounter_details) { |
|
| 174 | + $encdetails = new stdClass(); |
|
| 175 | + $encdetails->cp = $data->cp; |
|
| 176 | + $encdetails->attack = $data->individual_attack; |
|
| 177 | + $encdetails->defense = $data->individual_defense; |
|
| 178 | + $encdetails->stamina = $data->individual_stamina; |
|
| 179 | + if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
| 180 | + $encdetails->available = true; |
|
| 181 | + } else { |
|
| 182 | + $encdetails->available = false; |
|
| 183 | + } |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + $html = ' |
|
| 187 | 187 | <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;"> |
| 188 | 188 | <a href="pokemon/'.$pokeid.'"><img src="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a> |
| 189 | 189 | <a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a> |
| 190 | 190 | <a href="'.$location_link.'" target="_blank"> |
| 191 | 191 | <small class="pokemon-timer">00:00:00</small> |
| 192 | 192 | </a>'; |
| 193 | - if ($config->system->recents_encounter_details) { |
|
| 194 | - if ($encdetails->available) { |
|
| 195 | - if ($config->system->iv_numbers) { |
|
| 196 | - $html .= ' |
|
| 193 | + if ($config->system->recents_encounter_details) { |
|
| 194 | + if ($encdetails->available) { |
|
| 195 | + if ($config->system->iv_numbers) { |
|
| 196 | + $html .= ' |
|
| 197 | 197 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 198 | 198 | <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"> |
| 199 | 199 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>'.$encdetails->attack.' |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>'.$encdetails->stamina.' |
| 206 | 206 | </div> |
| 207 | 207 | </div>'; |
| 208 | - } else { |
|
| 209 | - $html .= ' |
|
| 208 | + } else { |
|
| 209 | + $html .= ' |
|
| 210 | 210 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 211 | 211 | <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).'%"> |
| 212 | 212 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span> |
@@ -218,11 +218,11 @@ discard block |
||
| 218 | 218 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span> |
| 219 | 219 | </div> |
| 220 | 220 | </div>'; |
| 221 | - } |
|
| 222 | - $html .= '<small>'.$encdetails->cp.'</small>'; |
|
| 223 | - } else { |
|
| 224 | - if ($config->system->iv_numbers) { |
|
| 225 | - $html .= ' |
|
| 221 | + } |
|
| 222 | + $html .= '<small>'.$encdetails->cp.'</small>'; |
|
| 223 | + } else { |
|
| 224 | + if ($config->system->iv_numbers) { |
|
| 225 | + $html .= ' |
|
| 226 | 226 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 227 | 227 | <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"> |
| 228 | 228 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>? |
@@ -234,118 +234,118 @@ discard block |
||
| 234 | 234 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>? |
| 235 | 235 | </div> |
| 236 | 236 | </div>'; |
| 237 | - } else { |
|
| 238 | - $html .= ' |
|
| 237 | + } else { |
|
| 238 | + $html .= ' |
|
| 239 | 239 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 240 | 240 | <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"> |
| 241 | 241 | <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span> |
| 242 | 242 | </div> |
| 243 | 243 | </div>'; |
| 244 | + } |
|
| 245 | + $html .= '<small>???</small>'; |
|
| 244 | 246 | } |
| 245 | - $html .= '<small>???</small>'; |
|
| 246 | 247 | } |
| 247 | - } |
|
| 248 | - $html .= ' |
|
| 248 | + $html .= ' |
|
| 249 | 249 | </div>'; |
| 250 | - $new_spawn['html'] = $html; |
|
| 251 | - $countdown = $last_seen - time(); |
|
| 252 | - $new_spawn['countdown'] = $countdown; |
|
| 253 | - $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 254 | - $total_spawns[] = $new_spawn; |
|
| 255 | - } else { |
|
| 256 | - break; |
|
| 250 | + $new_spawn['html'] = $html; |
|
| 251 | + $countdown = $last_seen - time(); |
|
| 252 | + $new_spawn['countdown'] = $countdown; |
|
| 253 | + $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 254 | + $total_spawns[] = $new_spawn; |
|
| 255 | + } else { |
|
| 256 | + break; |
|
| 257 | + } |
|
| 257 | 258 | } |
| 258 | - } |
|
| 259 | 259 | |
| 260 | - header('Content-Type: application/json'); |
|
| 261 | - echo json_encode($total_spawns); |
|
| 260 | + header('Content-Type: application/json'); |
|
| 261 | + echo json_encode($total_spawns); |
|
| 262 | 262 | |
| 263 | - break; |
|
| 263 | + break; |
|
| 264 | 264 | |
| 265 | 265 | |
| 266 | - #################################### |
|
| 267 | - // |
|
| 268 | - // List Pokestop |
|
| 269 | - // |
|
| 270 | - #################################### |
|
| 266 | + #################################### |
|
| 267 | + // |
|
| 268 | + // List Pokestop |
|
| 269 | + // |
|
| 270 | + #################################### |
|
| 271 | 271 | |
| 272 | - case 'pokestop': |
|
| 273 | - $result = $mysqli->query(req_pokestop_data()); |
|
| 272 | + case 'pokestop': |
|
| 273 | + $result = $mysqli->query(req_pokestop_data()); |
|
| 274 | 274 | |
| 275 | - $pokestops = []; |
|
| 275 | + $pokestops = []; |
|
| 276 | 276 | |
| 277 | - while ($data = $result->fetch_object()) { |
|
| 278 | - if ($data->lure_expiration >= $data->now) { |
|
| 279 | - $icon = 'pokestap_lured.png'; |
|
| 280 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 281 | - $lured = true; |
|
| 282 | - } else { |
|
| 283 | - $icon = 'pokestap.png'; |
|
| 284 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 285 | - $lured = false; |
|
| 286 | - } |
|
| 277 | + while ($data = $result->fetch_object()) { |
|
| 278 | + if ($data->lure_expiration >= $data->now) { |
|
| 279 | + $icon = 'pokestap_lured.png'; |
|
| 280 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 281 | + $lured = true; |
|
| 282 | + } else { |
|
| 283 | + $icon = 'pokestap.png'; |
|
| 284 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 285 | + $lured = false; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - $pokestops[] = [ |
|
| 289 | - $text, |
|
| 290 | - $icon, |
|
| 291 | - $data->latitude, |
|
| 292 | - $data->longitude, |
|
| 293 | - $lured |
|
| 294 | - ]; |
|
| 295 | - } |
|
| 288 | + $pokestops[] = [ |
|
| 289 | + $text, |
|
| 290 | + $icon, |
|
| 291 | + $data->latitude, |
|
| 292 | + $data->longitude, |
|
| 293 | + $lured |
|
| 294 | + ]; |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - header('Content-Type: application/json'); |
|
| 298 | - echo json_encode($pokestops); |
|
| 297 | + header('Content-Type: application/json'); |
|
| 298 | + echo json_encode($pokestops); |
|
| 299 | 299 | |
| 300 | - break; |
|
| 300 | + break; |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | - #################################### |
|
| 304 | - // |
|
| 305 | - // Update data for the gym battle |
|
| 306 | - // |
|
| 307 | - #################################### |
|
| 303 | + #################################### |
|
| 304 | + // |
|
| 305 | + // Update data for the gym battle |
|
| 306 | + // |
|
| 307 | + #################################### |
|
| 308 | 308 | |
| 309 | - case 'update_gym': |
|
| 310 | - $teams = new stdClass(); |
|
| 311 | - $teams->mystic = 1; |
|
| 312 | - $teams->valor = 2; |
|
| 313 | - $teams->instinct = 3; |
|
| 309 | + case 'update_gym': |
|
| 310 | + $teams = new stdClass(); |
|
| 311 | + $teams->mystic = 1; |
|
| 312 | + $teams->valor = 2; |
|
| 313 | + $teams->instinct = 3; |
|
| 314 | 314 | |
| 315 | 315 | |
| 316 | - foreach ($teams as $team_name => $team_id) { |
|
| 317 | - $result = $mysqli->query(req_gym_count_cp_for_team($team_id)); |
|
| 318 | - $data = $result->fetch_object(); |
|
| 316 | + foreach ($teams as $team_name => $team_id) { |
|
| 317 | + $result = $mysqli->query(req_gym_count_cp_for_team($team_id)); |
|
| 318 | + $data = $result->fetch_object(); |
|
| 319 | 319 | |
| 320 | - $return[] = $data->total; |
|
| 321 | - $return[] = $data->average_points; |
|
| 322 | - } |
|
| 320 | + $return[] = $data->total; |
|
| 321 | + $return[] = $data->average_points; |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - header('Content-Type: application/json'); |
|
| 325 | - echo json_encode($return); |
|
| 324 | + header('Content-Type: application/json'); |
|
| 325 | + echo json_encode($return); |
|
| 326 | 326 | |
| 327 | - break; |
|
| 327 | + break; |
|
| 328 | 328 | |
| 329 | 329 | |
| 330 | - #################################### |
|
| 331 | - // |
|
| 332 | - // Get datas for the gym map |
|
| 333 | - // |
|
| 334 | - #################################### |
|
| 330 | + #################################### |
|
| 331 | + // |
|
| 332 | + // Get datas for the gym map |
|
| 333 | + // |
|
| 334 | + #################################### |
|
| 335 | 335 | |
| 336 | 336 | |
| 337 | - case 'gym_map': |
|
| 338 | - $result = $mysqli->query(req_gym_data()); |
|
| 337 | + case 'gym_map': |
|
| 338 | + $result = $mysqli->query(req_gym_data()); |
|
| 339 | 339 | |
| 340 | - $gyms = []; |
|
| 340 | + $gyms = []; |
|
| 341 | 341 | |
| 342 | - while ($data = $result->fetch_object()) { |
|
| 343 | - // Team |
|
| 344 | - // 1 = bleu |
|
| 345 | - // 2 = rouge |
|
| 346 | - // 3 = jaune |
|
| 342 | + while ($data = $result->fetch_object()) { |
|
| 343 | + // Team |
|
| 344 | + // 1 = bleu |
|
| 345 | + // 2 = rouge |
|
| 346 | + // 3 = jaune |
|
| 347 | 347 | |
| 348 | - switch ($data->team_id) { |
|
| 348 | + switch ($data->team_id) { |
|
| 349 | 349 | case 0: |
| 350 | 350 | $icon = 'map_white.png'; |
| 351 | 351 | $team = 'No Team (yet)'; |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | $team = 'Team Instinct'; |
| 370 | 370 | $color = 'rgba(254, 217, 40, .6)'; |
| 371 | 371 | break; |
| 372 | - } |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | 374 | if ($data->team_id != 0) { |
| 375 | 375 | $icon .= $data->level.".png"; |
@@ -395,39 +395,39 @@ discard block |
||
| 395 | 395 | // |
| 396 | 396 | #################################### |
| 397 | 397 | |
| 398 | - case 'gym_defenders': |
|
| 399 | - $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 400 | - $result = $mysqli->query(req_gym_defender_for($gym_id)); |
|
| 398 | + case 'gym_defenders': |
|
| 399 | + $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 400 | + $result = $mysqli->query(req_gym_defender_for($gym_id)); |
|
| 401 | 401 | |
| 402 | - $gymData['gymDetails']['gymInfos'] = false; |
|
| 402 | + $gymData['gymDetails']['gymInfos'] = false; |
|
| 403 | 403 | |
| 404 | - while ($data = $result->fetch_object()) { |
|
| 405 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 406 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 407 | - if ($data->url == null) { |
|
| 408 | - $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 409 | - } else { |
|
| 410 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 404 | + while ($data = $result->fetch_object()) { |
|
| 405 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 406 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 407 | + if ($data->url == null) { |
|
| 408 | + $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 409 | + } else { |
|
| 410 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 411 | + } |
|
| 412 | + $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 413 | + $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 414 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 415 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 416 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 411 | 417 | } |
| 412 | - $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 413 | - $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 414 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 415 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 416 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 417 | - } |
|
| 418 | 418 | |
| 419 | - $result = $mysqli->query(req_gym_defender_stats_for($gym_id)); |
|
| 419 | + $result = $mysqli->query(req_gym_defender_stats_for($gym_id)); |
|
| 420 | 420 | |
| 421 | - $i = 0; |
|
| 421 | + $i = 0; |
|
| 422 | 422 | |
| 423 | - $gymData['infoWindow'] = ' |
|
| 423 | + $gymData['infoWindow'] = ' |
|
| 424 | 424 | <div class="gym_defenders"> |
| 425 | 425 | '; |
| 426 | - while ($data = $result->fetch_object()) { |
|
| 427 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
| 428 | - if ($data != false) { |
|
| 429 | - if ($config->system->iv_numbers) { |
|
| 430 | - $gymData['infoWindow'] .= ' |
|
| 426 | + while ($data = $result->fetch_object()) { |
|
| 427 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
| 428 | + if ($data != false) { |
|
| 429 | + if ($config->system->iv_numbers) { |
|
| 430 | + $gymData['infoWindow'] .= ' |
|
| 431 | 431 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 432 | 432 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 433 | 433 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -445,8 +445,8 @@ discard block |
||
| 445 | 445 | </div> |
| 446 | 446 | </div> |
| 447 | 447 | </div>'; |
| 448 | - } else { |
|
| 449 | - $gymData['infoWindow'] .= ' |
|
| 448 | + } else { |
|
| 449 | + $gymData['infoWindow'] .= ' |
|
| 450 | 450 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 451 | 451 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 452 | 452 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -464,209 +464,209 @@ discard block |
||
| 464 | 464 | </div> |
| 465 | 465 | </div> |
| 466 | 466 | </div>' |
| 467 | - ; } |
|
| 468 | - } else { |
|
| 469 | - $gymData['infoWindow'] .= ' |
|
| 467 | + ; } |
|
| 468 | + } else { |
|
| 469 | + $gymData['infoWindow'] .= ' |
|
| 470 | 470 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 471 | 471 | <a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'"> |
| 472 | 472 | <img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 473 | 473 | </a> |
| 474 | 474 | <p class="pkmn-name">???</p> |
| 475 | 475 | </div>' |
| 476 | - ; |
|
| 476 | + ; |
|
| 477 | + } |
|
| 478 | + $i++; |
|
| 477 | 479 | } |
| 478 | - $i++; |
|
| 479 | - } |
|
| 480 | 480 | |
| 481 | - // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 482 | - if (!$gymData['gymDetails']['gymInfos']) { |
|
| 481 | + // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 482 | + if (!$gymData['gymDetails']['gymInfos']) { |
|
| 483 | 483 | |
| 484 | - $result = $mysqli->query(req_gym_data_simple($gym_id)); |
|
| 485 | - $data = $result->fetch_object(); |
|
| 484 | + $result = $mysqli->query(req_gym_data_simple($gym_id)); |
|
| 485 | + $data = $result->fetch_object(); |
|
| 486 | 486 | |
| 487 | - $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 488 | - $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 489 | - $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 490 | - $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 491 | - $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 492 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 493 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team_id; |
|
| 494 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 487 | + $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 488 | + $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 489 | + $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 490 | + $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 491 | + $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 492 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 493 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team_id; |
|
| 494 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 495 | 495 | |
| 496 | - $gymData['infoWindow'] .= ' |
|
| 496 | + $gymData['infoWindow'] .= ' |
|
| 497 | 497 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 498 | 498 | <a href="pokemon/'.$data->guard_pokemon_id.'"> |
| 499 | 499 | <img src="core/pokemons/'.$data->guard_pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 500 | 500 | </a> |
| 501 | 501 | <p class="pkmn-name">???</p> |
| 502 | 502 | </div>'; |
| 503 | - } |
|
| 504 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 503 | + } |
|
| 504 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 505 | 505 | |
| 506 | - header('Content-Type: application/json'); |
|
| 507 | - echo json_encode($gymData); |
|
| 506 | + header('Content-Type: application/json'); |
|
| 507 | + echo json_encode($gymData); |
|
| 508 | 508 | |
| 509 | - break; |
|
| 509 | + break; |
|
| 510 | 510 | |
| 511 | 511 | |
| 512 | - case 'trainer': |
|
| 513 | - $name = ""; |
|
| 514 | - $page = "0"; |
|
| 515 | - $where = ""; |
|
| 516 | - $order = ""; |
|
| 517 | - $team = 0; |
|
| 518 | - $ranking = 0; |
|
| 512 | + case 'trainer': |
|
| 513 | + $name = ""; |
|
| 514 | + $page = "0"; |
|
| 515 | + $where = ""; |
|
| 516 | + $order = ""; |
|
| 517 | + $team = 0; |
|
| 518 | + $ranking = 0; |
|
| 519 | 519 | |
| 520 | - $result = $mysqli->query(req_trainers($_GET)); |
|
| 521 | - $trainers = array(); |
|
| 522 | - while ($data = $result->fetch_object()) { |
|
| 523 | - $data->last_seen = date("Y-m-d", strtotime($data->last_seen)); |
|
| 524 | - $trainers[$data->name] = $data; |
|
| 525 | - } |
|
| 526 | - foreach ($trainers as $trainer) { |
|
| 527 | - $resultRanking = $mysqli->query(req_trainer_ranking($trainer)); |
|
| 528 | - while ($data = $resultRanking->fetch_object()) { |
|
| 529 | - $trainer->rank = $data->rank; |
|
| 520 | + $result = $mysqli->query(req_trainers($_GET)); |
|
| 521 | + $trainers = array(); |
|
| 522 | + while ($data = $result->fetch_object()) { |
|
| 523 | + $data->last_seen = date("Y-m-d", strtotime($data->last_seen)); |
|
| 524 | + $trainers[$data->name] = $data; |
|
| 530 | 525 | } |
| 526 | + foreach ($trainers as $trainer) { |
|
| 527 | + $resultRanking = $mysqli->query(req_trainer_ranking($trainer)); |
|
| 528 | + while ($data = $resultRanking->fetch_object()) { |
|
| 529 | + $trainer->rank = $data->rank; |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | - $resultPkms = $mysqli->query(req_trainer_active_pokemon($trainer->name)); |
|
| 533 | - $trainer->pokemons = array(); |
|
| 534 | - $active_gyms = 0; |
|
| 535 | - $pkmCount = 0; |
|
| 536 | - while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
|
| 537 | - $active_gyms++; |
|
| 538 | - $trainer->pokemons[$pkmCount++] = $dataPkm; |
|
| 539 | - } |
|
| 540 | - $trainer->gyms = $active_gyms; |
|
| 532 | + $resultPkms = $mysqli->query(req_trainer_active_pokemon($trainer->name)); |
|
| 533 | + $trainer->pokemons = array(); |
|
| 534 | + $active_gyms = 0; |
|
| 535 | + $pkmCount = 0; |
|
| 536 | + while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
|
| 537 | + $active_gyms++; |
|
| 538 | + $trainer->pokemons[$pkmCount++] = $dataPkm; |
|
| 539 | + } |
|
| 540 | + $trainer->gyms = $active_gyms; |
|
| 541 | 541 | |
| 542 | - $resultPkms = $mysqli->query(req_trainer_inactive_pokemon($trainer->name)); |
|
| 543 | - while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
|
| 544 | - $trainer->pokemons[$pkmCount++] = $dataPkm; |
|
| 542 | + $resultPkms = $mysqli->query(req_trainer_inactive_pokemon($trainer->name)); |
|
| 543 | + while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
|
| 544 | + $trainer->pokemons[$pkmCount++] = $dataPkm; |
|
| 545 | + } |
|
| 545 | 546 | } |
| 546 | - } |
|
| 547 | - $json = array(); |
|
| 548 | - $json['trainers'] = $trainers; |
|
| 549 | - $locale = array(); |
|
| 550 | - $locale["today"] = $locales->TODAY; |
|
| 551 | - $locale["day"] = $locales->DAY; |
|
| 552 | - $locale["days"] = $locales->DAYS; |
|
| 553 | - $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 554 | - $locale["ivDefense"] = $locales->IV_DEFENSE; |
|
| 555 | - $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 556 | - $json['locale'] = $locale; |
|
| 557 | - |
|
| 558 | - header('Content-Type: application/json'); |
|
| 559 | - echo json_encode($json); |
|
| 547 | + $json = array(); |
|
| 548 | + $json['trainers'] = $trainers; |
|
| 549 | + $locale = array(); |
|
| 550 | + $locale["today"] = $locales->TODAY; |
|
| 551 | + $locale["day"] = $locales->DAY; |
|
| 552 | + $locale["days"] = $locales->DAYS; |
|
| 553 | + $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 554 | + $locale["ivDefense"] = $locales->IV_DEFENSE; |
|
| 555 | + $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 556 | + $json['locale'] = $locale; |
|
| 560 | 557 | |
| 561 | - break; |
|
| 558 | + header('Content-Type: application/json'); |
|
| 559 | + echo json_encode($json); |
|
| 562 | 560 | |
| 561 | + break; |
|
| 563 | 562 | |
| 564 | - case 'raids': |
|
| 565 | - $page = "0"; |
|
| 566 | - if (isset($_GET['page'])) { |
|
| 567 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 568 | - } |
|
| 569 | 563 | |
| 570 | - $result = $mysqli->query(req_raids_data($page)); |
|
| 571 | - $raids = array(); |
|
| 572 | - while ($data = $result->fetch_object()) { |
|
| 573 | - $data->starttime = date("H:i", strtotime($data->start)); |
|
| 574 | - $data->endtime = date("H:i", strtotime($data->end)); |
|
| 575 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 576 | - if (isset($data->move_1)) { |
|
| 577 | - $move1 = $data->move_1; |
|
| 578 | - $data->quick_move = $move->$move1->name; |
|
| 579 | - } else { |
|
| 580 | - $data->quick_move = "?"; |
|
| 564 | + case 'raids': |
|
| 565 | + $page = "0"; |
|
| 566 | + if (isset($_GET['page'])) { |
|
| 567 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 581 | 568 | } |
| 582 | - if (isset($data->move_2)) { |
|
| 583 | - $move2 = $data->move_2; |
|
| 584 | - $data->charge_move = $move->$move2->name; |
|
| 585 | - } else { |
|
| 586 | - $data->charge_move = "?"; |
|
| 569 | + |
|
| 570 | + $result = $mysqli->query(req_raids_data($page)); |
|
| 571 | + $raids = array(); |
|
| 572 | + while ($data = $result->fetch_object()) { |
|
| 573 | + $data->starttime = date("H:i", strtotime($data->start)); |
|
| 574 | + $data->endtime = date("H:i", strtotime($data->end)); |
|
| 575 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 576 | + if (isset($data->move_1)) { |
|
| 577 | + $move1 = $data->move_1; |
|
| 578 | + $data->quick_move = $move->$move1->name; |
|
| 579 | + } else { |
|
| 580 | + $data->quick_move = "?"; |
|
| 581 | + } |
|
| 582 | + if (isset($data->move_2)) { |
|
| 583 | + $move2 = $data->move_2; |
|
| 584 | + $data->charge_move = $move->$move2->name; |
|
| 585 | + } else { |
|
| 586 | + $data->charge_move = "?"; |
|
| 587 | + } |
|
| 588 | + $raids[$data->gym_id] = $data; |
|
| 587 | 589 | } |
| 588 | - $raids[$data->gym_id] = $data; |
|
| 589 | - } |
|
| 590 | - $json = array(); |
|
| 591 | - $json['raids'] = $raids; |
|
| 592 | - $locale = array(); |
|
| 593 | - $locale['noraids'] = $locales->RAIDS_NONE; |
|
| 594 | - $json['locale'] = $locale; |
|
| 590 | + $json = array(); |
|
| 591 | + $json['raids'] = $raids; |
|
| 592 | + $locale = array(); |
|
| 593 | + $locale['noraids'] = $locales->RAIDS_NONE; |
|
| 594 | + $json['locale'] = $locale; |
|
| 595 | 595 | |
| 596 | - header('Content-Type: application/json'); |
|
| 597 | - echo json_encode($json); |
|
| 596 | + header('Content-Type: application/json'); |
|
| 597 | + echo json_encode($json); |
|
| 598 | 598 | |
| 599 | - break; |
|
| 599 | + break; |
|
| 600 | 600 | |
| 601 | - case 'pokemon_slider_init': |
|
| 602 | - $result = $mysqli->query(req_pokemon_slider_init()); |
|
| 603 | - $bounds = $result->fetch_object(); |
|
| 601 | + case 'pokemon_slider_init': |
|
| 602 | + $result = $mysqli->query(req_pokemon_slider_init()); |
|
| 603 | + $bounds = $result->fetch_object(); |
|
| 604 | 604 | |
| 605 | - header('Content-Type: application/json'); |
|
| 606 | - echo json_encode($bounds); |
|
| 605 | + header('Content-Type: application/json'); |
|
| 606 | + echo json_encode($bounds); |
|
| 607 | 607 | |
| 608 | - break; |
|
| 608 | + break; |
|
| 609 | 609 | |
| 610 | 610 | |
| 611 | - case 'pokemon_heatmap_points': |
|
| 612 | - $json = ""; |
|
| 613 | - if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 614 | - $start = date("Y-m-d H:i", (int) $_GET['start']); |
|
| 615 | - $end = date("Y-m-d H:i", (int) $_GET['end']); |
|
| 616 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 617 | - $result = $mysqli->query(req_pokemon_headmap_points($pokemon_id, $start, $end)); |
|
| 618 | - $points = array(); |
|
| 619 | - while ($result && $data = $result->fetch_object()) { |
|
| 620 | - $points[] = $data; |
|
| 611 | + case 'pokemon_heatmap_points': |
|
| 612 | + $json = ""; |
|
| 613 | + if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 614 | + $start = date("Y-m-d H:i", (int) $_GET['start']); |
|
| 615 | + $end = date("Y-m-d H:i", (int) $_GET['end']); |
|
| 616 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 617 | + $result = $mysqli->query(req_pokemon_headmap_points($pokemon_id, $start, $end)); |
|
| 618 | + $points = array(); |
|
| 619 | + while ($result && $data = $result->fetch_object()) { |
|
| 620 | + $points[] = $data; |
|
| 621 | + } |
|
| 622 | + |
|
| 623 | + $json = json_encode($points); |
|
| 621 | 624 | } |
| 622 | 625 | |
| 623 | - $json = json_encode($points); |
|
| 624 | - } |
|
| 626 | + header('Content-Type: application/json'); |
|
| 627 | + echo $json; |
|
| 628 | + break; |
|
| 625 | 629 | |
| 626 | - header('Content-Type: application/json'); |
|
| 627 | - echo $json; |
|
| 628 | - break; |
|
| 629 | 630 | |
| 631 | + case 'maps_localization_coordinates': |
|
| 632 | + $json = ""; |
|
| 633 | + $result = $mysqli->query(req_maps_localization_coordinates()); |
|
| 634 | + $coordinates = $result->fetch_object(); |
|
| 630 | 635 | |
| 631 | - case 'maps_localization_coordinates': |
|
| 632 | - $json = ""; |
|
| 633 | - $result = $mysqli->query(req_maps_localization_coordinates()); |
|
| 634 | - $coordinates = $result->fetch_object(); |
|
| 636 | + header('Content-Type: application/json'); |
|
| 637 | + echo json_encode($coordinates); |
|
| 635 | 638 | |
| 636 | - header('Content-Type: application/json'); |
|
| 637 | - echo json_encode($coordinates); |
|
| 639 | + break; |
|
| 638 | 640 | |
| 639 | - break; |
|
| 640 | 641 | |
| 642 | + case 'pokemon_graph_data': |
|
| 643 | + $json = ""; |
|
| 644 | + if (isset($_GET['pokemon_id'])) { |
|
| 645 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 646 | + $result = $mysqli->query(req_pokemon_graph_data($pokemon_id)); |
|
| 647 | + $array = array_fill(0, 24, 0); |
|
| 648 | + while ($result && $data = $result->fetch_object()) { |
|
| 649 | + $array[$data->disappear_hour] = $data->total; |
|
| 650 | + } |
|
| 651 | + // shift array because AM/PM starts at 1AM not 0:00 |
|
| 652 | + $array[] = $array[0]; |
|
| 653 | + array_shift($array); |
|
| 641 | 654 | |
| 642 | - case 'pokemon_graph_data': |
|
| 643 | - $json = ""; |
|
| 644 | - if (isset($_GET['pokemon_id'])) { |
|
| 645 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 646 | - $result = $mysqli->query(req_pokemon_graph_data($pokemon_id)); |
|
| 647 | - $array = array_fill(0, 24, 0); |
|
| 648 | - while ($result && $data = $result->fetch_object()) { |
|
| 649 | - $array[$data->disappear_hour] = $data->total; |
|
| 655 | + $json = json_encode($array); |
|
| 650 | 656 | } |
| 651 | - // shift array because AM/PM starts at 1AM not 0:00 |
|
| 652 | - $array[] = $array[0]; |
|
| 653 | - array_shift($array); |
|
| 654 | 657 | |
| 655 | - $json = json_encode($array); |
|
| 656 | - } |
|
| 658 | + header('Content-Type: application/json'); |
|
| 659 | + echo $json; |
|
| 660 | + break; |
|
| 657 | 661 | |
| 658 | - header('Content-Type: application/json'); |
|
| 659 | - echo $json; |
|
| 660 | - break; |
|
| 661 | 662 | |
| 663 | + case 'postRequest': |
|
| 664 | + break; |
|
| 662 | 665 | |
| 663 | - case 'postRequest': |
|
| 666 | + default: |
|
| 667 | + echo "What do you mean?"; |
|
| 668 | + exit(); |
|
| 664 | 669 | break; |
| 665 | - |
|
| 666 | - default: |
|
| 667 | - echo "What do you mean?"; |
|
| 668 | - exit(); |
|
| 669 | - break; |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | if ($postRequest != "") { |
@@ -600,7 +600,7 @@ |
||
| 600 | 600 | |
| 601 | 601 | case 'pokemon_slider_init': |
| 602 | 602 | $result = $mysqli->query(req_pokemon_slider_init()); |
| 603 | - $bounds = $result->fetch_object(); |
|
| 603 | + $bounds = $result->fetch_object(); |
|
| 604 | 604 | |
| 605 | 605 | header('Content-Type: application/json'); |
| 606 | 606 | echo json_encode($bounds); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$variables = realpath(dirname(__FILE__)) . '/../json/variables.json'; |
|
| 3 | +$variables = realpath(dirname(__FILE__)).'/../json/variables.json'; |
|
| 4 | 4 | $config = json_decode(file_get_contents($variables)); |
| 5 | 5 | |
| 6 | -include_once('quarrys/' . ($config->system->db_type ?: 'rocketmap') . '.php'); |
|
| 7 | 6 | \ No newline at end of file |
| 7 | +include_once('quarrys/'.($config->system->db_type ?: 'rocketmap').'.php'); |
|
| 8 | 8 | \ No newline at end of file |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // Total gym protected |
| 129 | 129 | |
| 130 | - $result = $mysqli->query(req_pokemon_total_gym_protected($pokemon_id)); |
|
| 130 | + $result = $mysqli->query(req_pokemon_total_gym_protected($pokemon_id)); |
|
| 131 | 131 | $data = $result->fetch_object(); |
| 132 | 132 | |
| 133 | 133 | $pokemon->protected_gyms = $data->total; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | // Last seen |
| 144 | 144 | |
| 145 | 145 | |
| 146 | - $result = $mysqli->query(req_pokemon_last_seen($pokemon_id)); |
|
| 146 | + $result = $mysqli->query(req_pokemon_last_seen($pokemon_id)); |
|
| 147 | 147 | $data = $result->fetch_object(); |
| 148 | 148 | |
| 149 | 149 | if (isset($data)) { |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | $top_direction = isset($_GET['direction']) ? 'ASC' : 'DESC'; |
| 188 | 188 | $top_direction = !isset($_GET['order']) && !isset($_GET['direction']) ? 'DESC' : $top_direction; |
| 189 | 189 | |
| 190 | - $result = $mysqli->query(req_pokemon_get_top_50($pokemon_id, $top_order_by, $top_direction)); |
|
| 190 | + $result = $mysqli->query(req_pokemon_get_top_50($pokemon_id, $top_order_by, $top_direction)); |
|
| 191 | 191 | $top = array(); |
| 192 | 192 | while ($data = $result->fetch_object()) { |
| 193 | 193 | $top[] = $data; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | $best_direction = isset($_GET['direction']) ? 'ASC' : 'DESC'; |
| 204 | 204 | $best_direction = !isset($_GET['order']) && !isset($_GET['direction']) ? 'DESC' : $best_direction; |
| 205 | 205 | |
| 206 | - $result = $mysqli->query(req_pokemon_get_top_trainers($pokemon_id, $best_order_by, $best_direction)); |
|
| 206 | + $result = $mysqli->query(req_pokemon_get_top_trainers($pokemon_id, $best_order_by, $best_direction)); |
|
| 207 | 207 | $toptrainer = array(); |
| 208 | 208 | while ($data = $result->fetch_object()) { |
| 209 | 209 | $toptrainer[] = $data; |
@@ -241,12 +241,12 @@ discard block |
||
| 241 | 241 | case 'pokestops': |
| 242 | 242 | $pokestop = new stdClass(); |
| 243 | 243 | |
| 244 | - $result = $mysqli->query(req_pokestop_count()); |
|
| 244 | + $result = $mysqli->query(req_pokestop_count()); |
|
| 245 | 245 | $data = $result->fetch_object(); |
| 246 | 246 | |
| 247 | 247 | $pokestop->total = $data->total; |
| 248 | 248 | |
| 249 | - $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 249 | + $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 250 | 250 | $data = $result->fetch_object(); |
| 251 | 251 | |
| 252 | 252 | $pokestop->lured = $data->total; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | foreach ($teams as $team_key => $team_values) { |
| 288 | 288 | // Team Guardians |
| 289 | 289 | |
| 290 | - $result = $mysqli->query(req_gym_guards_for_team($team_values->id)); |
|
| 290 | + $result = $mysqli->query(req_gym_guards_for_team($team_values->id)); |
|
| 291 | 291 | |
| 292 | 292 | $i = 0; |
| 293 | 293 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | // Gym owned and average points |
| 302 | 302 | |
| 303 | - $result = $mysqli->query(req_gym_count_cp_for_team($team_values->id)); |
|
| 303 | + $result = $mysqli->query(req_gym_count_cp_for_team($team_values->id)); |
|
| 304 | 304 | $data = $result->fetch_object(); |
| 305 | 305 | |
| 306 | 306 | $teams->$team_key->gym_owned = $data->total; |
@@ -361,7 +361,7 @@ discard block |
||
| 361 | 361 | // Right now |
| 362 | 362 | // --------- |
| 363 | 363 | |
| 364 | - $result = $mysqli->query(req_pokemon_count()); |
|
| 364 | + $result = $mysqli->query(req_pokemon_count()); |
|
| 365 | 365 | $data = $result->fetch_object(); |
| 366 | 366 | |
| 367 | 367 | |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | // Lured stops |
| 372 | 372 | // ----------- |
| 373 | 373 | |
| 374 | - $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 374 | + $result = $mysqli->query(req_pokestop_lure_count()); |
|
| 375 | 375 | $data = $result->fetch_object(); |
| 376 | 376 | |
| 377 | 377 | $home->pokestop_lured = $data->total; |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | // Gyms |
| 381 | 381 | // ---- |
| 382 | 382 | |
| 383 | - $result = $mysqli->query(req_gym_count()); |
|
| 383 | + $result = $mysqli->query(req_gym_count()); |
|
| 384 | 384 | $data = $result->fetch_object(); |
| 385 | 385 | |
| 386 | 386 | $home->gyms = $data->total; |
@@ -398,12 +398,12 @@ discard block |
||
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | // get all mythic pokemon |
| 401 | - $req_poke = req_mystic_pokemon($mythic_pokemons); |
|
| 401 | + $req_poke = req_mystic_pokemon($mythic_pokemons); |
|
| 402 | 402 | } else { |
| 403 | 403 | // get all pokemon |
| 404 | - $req_poke = req_all_pokemon(); |
|
| 405 | - } |
|
| 406 | - $result = $mysqli->query($req_poke); |
|
| 404 | + $req_poke = req_all_pokemon(); |
|
| 405 | + } |
|
| 406 | + $result = $mysqli->query($req_poke); |
|
| 407 | 407 | $recents = array(); |
| 408 | 408 | |
| 409 | 409 | if ($result->num_rows > 0) { |
@@ -446,25 +446,25 @@ discard block |
||
| 446 | 446 | // 2 = rouge |
| 447 | 447 | // 3 = jaune |
| 448 | 448 | |
| 449 | - $result = $mysqli->query(req_gym_count_for_team(1)); |
|
| 449 | + $result = $mysqli->query(req_gym_count_for_team(1)); |
|
| 450 | 450 | $data = $result->fetch_object(); |
| 451 | 451 | |
| 452 | 452 | $home->teams->mystic = $data->total; |
| 453 | 453 | |
| 454 | 454 | |
| 455 | - $result = $mysqli->query(req_gym_count_for_team(2)); |
|
| 455 | + $result = $mysqli->query(req_gym_count_for_team(2)); |
|
| 456 | 456 | $data = $result->fetch_object(); |
| 457 | 457 | |
| 458 | 458 | $home->teams->valor = $data->total; |
| 459 | 459 | |
| 460 | 460 | |
| 461 | - $result = $mysqli->query(req_gym_count_for_team(3)); |
|
| 461 | + $result = $mysqli->query(req_gym_count_for_team(3)); |
|
| 462 | 462 | $data = $result->fetch_object(); |
| 463 | 463 | |
| 464 | 464 | $home->teams->instinct = $data->total; |
| 465 | 465 | |
| 466 | 466 | |
| 467 | - $result = $mysqli->query(req_gym_count_for_team(0)); |
|
| 467 | + $result = $mysqli->query(req_gym_count_for_team(0)); |
|
| 468 | 468 | $data = $result->fetch_object(); |
| 469 | 469 | |
| 470 | 470 | $home->teams->rocket = $data->total; |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | // Gym owned and average points |
| 302 | 302 | |
| 303 | 303 | $result = $mysqli->query(req_gym_count_cp_for_team($team_values->id)); |
| 304 | - $data = $result->fetch_object(); |
|
| 304 | + $data = $result->fetch_object(); |
|
| 305 | 305 | |
| 306 | 306 | $teams->$team_key->gym_owned = $data->total; |
| 307 | 307 | $teams->$team_key->average = $data->average_points; |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | $req_poke = req_all_pokemon(); |
| 405 | 405 | } |
| 406 | 406 | $result = $mysqli->query($req_poke); |
| 407 | - $recents = array(); |
|
| 407 | + $recents = array(); |
|
| 408 | 408 | |
| 409 | 409 | if ($result->num_rows > 0) { |
| 410 | 410 | while ($data = $result->fetch_object()) { |