@@ -68,7 +68,7 @@ |
||
| 68 | 68 | <script type="text/javascript"> |
| 69 | 69 | <?= |
| 70 | 70 | $gymName = ""; |
| 71 | -if (isset($_GET['name']) && $_GET['name']!="") { |
|
| 71 | +if (isset($_GET['name']) && $_GET['name'] != "") { |
|
| 72 | 72 | $gymName = htmlentities($_GET['name']); |
| 73 | 73 | } |
| 74 | 74 | ?> |
@@ -58,153 +58,153 @@ discard block |
||
| 58 | 58 | // |
| 59 | 59 | ############################ |
| 60 | 60 | |
| 61 | - case 'home_update': |
|
| 62 | - // Right now |
|
| 63 | - // --------- |
|
| 61 | + case 'home_update': |
|
| 62 | + // Right now |
|
| 63 | + // --------- |
|
| 64 | 64 | |
| 65 | - $req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 66 | - $result = $mysqli->query($req); |
|
| 67 | - $data = $result->fetch_object(); |
|
| 65 | + $req = "SELECT COUNT(*) AS total FROM pokemon WHERE disappear_time >= UTC_TIMESTAMP()"; |
|
| 66 | + $result = $mysqli->query($req); |
|
| 67 | + $data = $result->fetch_object(); |
|
| 68 | 68 | |
| 69 | - $values[] = $data->total; |
|
| 69 | + $values[] = $data->total; |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - // Lured stops |
|
| 73 | - // ----------- |
|
| 72 | + // Lured stops |
|
| 73 | + // ----------- |
|
| 74 | 74 | |
| 75 | - $req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 76 | - $result = $mysqli->query($req); |
|
| 77 | - $data = $result->fetch_object(); |
|
| 75 | + $req = "SELECT COUNT(*) AS total FROM pokestop WHERE lure_expiration >= UTC_TIMESTAMP()"; |
|
| 76 | + $result = $mysqli->query($req); |
|
| 77 | + $data = $result->fetch_object(); |
|
| 78 | 78 | |
| 79 | - $values[] = $data->total; |
|
| 79 | + $values[] = $data->total; |
|
| 80 | 80 | |
| 81 | 81 | |
| 82 | 82 | |
| 83 | - // Team battle |
|
| 84 | - // ----------- |
|
| 83 | + // Team battle |
|
| 84 | + // ----------- |
|
| 85 | 85 | |
| 86 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym"; |
|
| 87 | - $result = $mysqli->query($req); |
|
| 88 | - $data = $result->fetch_object(); |
|
| 86 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym"; |
|
| 87 | + $result = $mysqli->query($req); |
|
| 88 | + $data = $result->fetch_object(); |
|
| 89 | 89 | |
| 90 | - $values[] = $data->total; |
|
| 90 | + $values[] = $data->total; |
|
| 91 | 91 | |
| 92 | - // Team |
|
| 93 | - // 1 = bleu |
|
| 94 | - // 2 = rouge |
|
| 95 | - // 3 = jaune |
|
| 92 | + // Team |
|
| 93 | + // 1 = bleu |
|
| 94 | + // 2 = rouge |
|
| 95 | + // 3 = jaune |
|
| 96 | 96 | |
| 97 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '2'"; |
|
| 98 | - $result = $mysqli->query($req); |
|
| 99 | - $data = $result->fetch_object(); |
|
| 97 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '2'"; |
|
| 98 | + $result = $mysqli->query($req); |
|
| 99 | + $data = $result->fetch_object(); |
|
| 100 | 100 | |
| 101 | - // Red |
|
| 102 | - $values[] = $data->total; |
|
| 101 | + // Red |
|
| 102 | + $values[] = $data->total; |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '1'"; |
|
| 106 | - $result = $mysqli->query($req); |
|
| 107 | - $data = $result->fetch_object(); |
|
| 105 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '1'"; |
|
| 106 | + $result = $mysqli->query($req); |
|
| 107 | + $data = $result->fetch_object(); |
|
| 108 | 108 | |
| 109 | - // Blue |
|
| 110 | - $values[] = $data->total; |
|
| 109 | + // Blue |
|
| 110 | + $values[] = $data->total; |
|
| 111 | 111 | |
| 112 | 112 | |
| 113 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '3'"; |
|
| 114 | - $result = $mysqli->query($req); |
|
| 115 | - $data = $result->fetch_object(); |
|
| 113 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '3'"; |
|
| 114 | + $result = $mysqli->query($req); |
|
| 115 | + $data = $result->fetch_object(); |
|
| 116 | 116 | |
| 117 | - // Yellow |
|
| 118 | - $values[] = $data->total; |
|
| 117 | + // Yellow |
|
| 118 | + $values[] = $data->total; |
|
| 119 | 119 | |
| 120 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '0'"; |
|
| 121 | - $result = $mysqli->query($req); |
|
| 122 | - $data = $result->fetch_object(); |
|
| 120 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total FROM gym WHERE team_id = '0'"; |
|
| 121 | + $result = $mysqli->query($req); |
|
| 122 | + $data = $result->fetch_object(); |
|
| 123 | 123 | |
| 124 | - // Neutral |
|
| 125 | - $values[] = $data->total; |
|
| 124 | + // Neutral |
|
| 125 | + $values[] = $data->total; |
|
| 126 | 126 | |
| 127 | - header('Content-Type: application/json'); |
|
| 128 | - echo json_encode($values); |
|
| 127 | + header('Content-Type: application/json'); |
|
| 128 | + echo json_encode($values); |
|
| 129 | 129 | |
| 130 | - break; |
|
| 130 | + break; |
|
| 131 | 131 | |
| 132 | 132 | |
| 133 | - #################################### |
|
| 134 | - // |
|
| 135 | - // Update latests spawn on homepage |
|
| 136 | - // |
|
| 137 | - #################################### |
|
| 133 | + #################################### |
|
| 134 | + // |
|
| 135 | + // Update latests spawn on homepage |
|
| 136 | + // |
|
| 137 | + #################################### |
|
| 138 | 138 | |
| 139 | - case 'spawnlist_update': |
|
| 140 | - // Recent spawn |
|
| 141 | - // ------------ |
|
| 142 | - $total_spawns = array(); |
|
| 143 | - $last_uid_param = ""; |
|
| 144 | - if (isset($_GET['last_uid'])) { |
|
| 145 | - $last_uid_param = $_GET['last_uid']; |
|
| 146 | - } |
|
| 147 | - if ($config->system->recents_filter) { |
|
| 148 | - // get all mythic pokemon ids |
|
| 149 | - $mythic_pokemons = array(); |
|
| 150 | - foreach ($pokemons->pokemon as $id => $pokemon) { |
|
| 151 | - if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
| 152 | - $mythic_pokemons[] = $id; |
|
| 153 | - } |
|
| 139 | + case 'spawnlist_update': |
|
| 140 | + // Recent spawn |
|
| 141 | + // ------------ |
|
| 142 | + $total_spawns = array(); |
|
| 143 | + $last_uid_param = ""; |
|
| 144 | + if (isset($_GET['last_uid'])) { |
|
| 145 | + $last_uid_param = $_GET['last_uid']; |
|
| 154 | 146 | } |
| 147 | + if ($config->system->recents_filter) { |
|
| 148 | + // get all mythic pokemon ids |
|
| 149 | + $mythic_pokemons = array(); |
|
| 150 | + foreach ($pokemons->pokemon as $id => $pokemon) { |
|
| 151 | + if ($pokemon->spawn_rate < $config->system->recents_filter_rarity && $pokemon->rating >= $config->system->recents_filter_rating) { |
|
| 152 | + $mythic_pokemons[] = $id; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - // get last mythic pokemon |
|
| 157 | - $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, |
|
| 156 | + // get last mythic pokemon |
|
| 157 | + $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, |
|
| 158 | 158 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 159 | 159 | FROM pokemon |
| 160 | 160 | WHERE pokemon_id IN (".implode(",", $mythic_pokemons).") |
| 161 | 161 | ORDER BY last_modified DESC |
| 162 | 162 | LIMIT 0,12"; |
| 163 | - } else { |
|
| 164 | - // get last pokemon |
|
| 165 | - $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, |
|
| 163 | + } else { |
|
| 164 | + // get last pokemon |
|
| 165 | + $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_time_real, |
|
| 166 | 166 | latitude, longitude, cp, individual_attack, individual_defense, individual_stamina |
| 167 | 167 | FROM pokemon |
| 168 | 168 | ORDER BY last_modified DESC |
| 169 | 169 | LIMIT 0,12"; |
| 170 | - } |
|
| 171 | - $result = $mysqli->query($req); |
|
| 172 | - while ($data = $result->fetch_object()) { |
|
| 173 | - $new_spawn = array(); |
|
| 174 | - $pokeid = $data->pokemon_id; |
|
| 175 | - $pokeuid = $data->encounter_id; |
|
| 176 | - |
|
| 177 | - if ($last_uid_param != $pokeuid) { |
|
| 178 | - $last_seen = strtotime($data->disappear_time_real); |
|
| 179 | - |
|
| 180 | - $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
| 181 | - $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
| 182 | - $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
| 183 | - |
|
| 184 | - if ($config->system->recents_encounter_details) { |
|
| 185 | - $encdetails = new stdClass(); |
|
| 186 | - $encdetails->cp = $data->cp; |
|
| 187 | - $encdetails->attack = $data->individual_attack; |
|
| 188 | - $encdetails->defense = $data->individual_defense; |
|
| 189 | - $encdetails->stamina = $data->individual_stamina; |
|
| 190 | - if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
| 191 | - $encdetails->available = true; |
|
| 192 | - } else { |
|
| 193 | - $encdetails->available = false; |
|
| 170 | + } |
|
| 171 | + $result = $mysqli->query($req); |
|
| 172 | + while ($data = $result->fetch_object()) { |
|
| 173 | + $new_spawn = array(); |
|
| 174 | + $pokeid = $data->pokemon_id; |
|
| 175 | + $pokeuid = $data->encounter_id; |
|
| 176 | + |
|
| 177 | + if ($last_uid_param != $pokeuid) { |
|
| 178 | + $last_seen = strtotime($data->disappear_time_real); |
|
| 179 | + |
|
| 180 | + $location_link = isset($config->system->location_url) ? $config->system->location_url : 'https://maps.google.com/?q={latitude},{longitude}&ll={latitude},{longitude}&z=16'; |
|
| 181 | + $location_link = str_replace('{latitude}', $data->latitude, $location_link); |
|
| 182 | + $location_link = str_replace('{longitude}', $data->longitude, $location_link); |
|
| 183 | + |
|
| 184 | + if ($config->system->recents_encounter_details) { |
|
| 185 | + $encdetails = new stdClass(); |
|
| 186 | + $encdetails->cp = $data->cp; |
|
| 187 | + $encdetails->attack = $data->individual_attack; |
|
| 188 | + $encdetails->defense = $data->individual_defense; |
|
| 189 | + $encdetails->stamina = $data->individual_stamina; |
|
| 190 | + if (isset($encdetails->cp) && isset($encdetails->attack) && isset($encdetails->defense) && isset($encdetails->stamina)) { |
|
| 191 | + $encdetails->available = true; |
|
| 192 | + } else { |
|
| 193 | + $encdetails->available = false; |
|
| 194 | + } |
|
| 194 | 195 | } |
| 195 | - } |
|
| 196 | 196 | |
| 197 | - $html = ' |
|
| 197 | + $html = ' |
|
| 198 | 198 | <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;"> |
| 199 | 199 | <a href="pokemon/'.$pokeid.'"><img src="'.$pokemons->pokemon->$pokeid->img.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a> |
| 200 | 200 | <a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a> |
| 201 | 201 | <a href="'.$location_link.'" target="_blank"> |
| 202 | 202 | <small class="pokemon-timer">00:00:00</small> |
| 203 | 203 | </a>'; |
| 204 | - if ($config->system->recents_encounter_details) { |
|
| 205 | - if ($encdetails->available) { |
|
| 206 | - if ($config->system->iv_numbers) { |
|
| 207 | - $html .= ' |
|
| 204 | + if ($config->system->recents_encounter_details) { |
|
| 205 | + if ($encdetails->available) { |
|
| 206 | + if ($config->system->iv_numbers) { |
|
| 207 | + $html .= ' |
|
| 208 | 208 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 209 | 209 | <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"> |
| 210 | 210 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span>'.$encdetails->attack.' |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span>'.$encdetails->stamina.' |
| 217 | 217 | </div> |
| 218 | 218 | </div>'; |
| 219 | - } else { |
|
| 220 | - $html .= ' |
|
| 219 | + } else { |
|
| 220 | + $html .= ' |
|
| 221 | 221 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 222 | 222 | <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).'%"> |
| 223 | 223 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$encdetails->attack.'</span> |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$encdetails->stamina.'</span> |
| 230 | 230 | </div> |
| 231 | 231 | </div>'; |
| 232 | - } |
|
| 233 | - $html .= '<small>'.$encdetails->cp.'</small>'; |
|
| 234 | - } else { |
|
| 235 | - if ($config->system->iv_numbers) { |
|
| 236 | - $html .= ' |
|
| 232 | + } |
|
| 233 | + $html .= '<small>'.$encdetails->cp.'</small>'; |
|
| 234 | + } else { |
|
| 235 | + if ($config->system->iv_numbers) { |
|
| 236 | + $html .= ' |
|
| 237 | 237 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 238 | 238 | <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"> |
| 239 | 239 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span>? |
@@ -245,123 +245,123 @@ discard block |
||
| 245 | 245 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span>? |
| 246 | 246 | </div> |
| 247 | 247 | </div>'; |
| 248 | - } else { |
|
| 249 | - $html .= ' |
|
| 248 | + } else { |
|
| 249 | + $html .= ' |
|
| 250 | 250 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto"> |
| 251 | 251 | <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"> |
| 252 | 252 | <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span> |
| 253 | 253 | </div> |
| 254 | 254 | </div>'; |
| 255 | + } |
|
| 256 | + $html .= '<small>???</small>'; |
|
| 255 | 257 | } |
| 256 | - $html .= '<small>???</small>'; |
|
| 257 | 258 | } |
| 258 | - } |
|
| 259 | - $html .= ' |
|
| 259 | + $html .= ' |
|
| 260 | 260 | </div>'; |
| 261 | - $new_spawn['html'] = $html; |
|
| 262 | - $countdown = $last_seen - time(); |
|
| 263 | - $new_spawn['countdown'] = $countdown; |
|
| 264 | - $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 265 | - $total_spawns[] = $new_spawn; |
|
| 266 | - } else { |
|
| 267 | - break; |
|
| 261 | + $new_spawn['html'] = $html; |
|
| 262 | + $countdown = $last_seen - time(); |
|
| 263 | + $new_spawn['countdown'] = $countdown; |
|
| 264 | + $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 265 | + $total_spawns[] = $new_spawn; |
|
| 266 | + } else { |
|
| 267 | + break; |
|
| 268 | + } |
|
| 268 | 269 | } |
| 269 | - } |
|
| 270 | 270 | |
| 271 | - header('Content-Type: application/json'); |
|
| 272 | - echo json_encode($total_spawns); |
|
| 271 | + header('Content-Type: application/json'); |
|
| 272 | + echo json_encode($total_spawns); |
|
| 273 | 273 | |
| 274 | - break; |
|
| 274 | + break; |
|
| 275 | 275 | |
| 276 | 276 | |
| 277 | - #################################### |
|
| 278 | - // |
|
| 279 | - // List Pokestop |
|
| 280 | - // |
|
| 281 | - #################################### |
|
| 277 | + #################################### |
|
| 278 | + // |
|
| 279 | + // List Pokestop |
|
| 280 | + // |
|
| 281 | + #################################### |
|
| 282 | 282 | |
| 283 | - case 'pokestop': |
|
| 284 | - $where = ""; |
|
| 285 | - $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop "; |
|
| 283 | + case 'pokestop': |
|
| 284 | + $where = ""; |
|
| 285 | + $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop "; |
|
| 286 | 286 | |
| 287 | - $result = $mysqli->query($req); |
|
| 287 | + $result = $mysqli->query($req); |
|
| 288 | 288 | |
| 289 | - $pokestops = []; |
|
| 289 | + $pokestops = []; |
|
| 290 | 290 | |
| 291 | - while ($data = $result->fetch_object()) { |
|
| 292 | - if ($data->lure_expiration >= $data->now) { |
|
| 293 | - $icon = 'pokestap_lured.png'; |
|
| 294 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 295 | - $lured = true; |
|
| 296 | - } else { |
|
| 297 | - $icon = 'pokestap.png'; |
|
| 298 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 299 | - $lured = false; |
|
| 300 | - } |
|
| 291 | + while ($data = $result->fetch_object()) { |
|
| 292 | + if ($data->lure_expiration >= $data->now) { |
|
| 293 | + $icon = 'pokestap_lured.png'; |
|
| 294 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 295 | + $lured = true; |
|
| 296 | + } else { |
|
| 297 | + $icon = 'pokestap.png'; |
|
| 298 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 299 | + $lured = false; |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | - $pokestops[] = [ |
|
| 303 | - $text, |
|
| 304 | - $icon, |
|
| 305 | - $data->latitude, |
|
| 306 | - $data->longitude, |
|
| 307 | - $lured |
|
| 308 | - ]; |
|
| 309 | - } |
|
| 302 | + $pokestops[] = [ |
|
| 303 | + $text, |
|
| 304 | + $icon, |
|
| 305 | + $data->latitude, |
|
| 306 | + $data->longitude, |
|
| 307 | + $lured |
|
| 308 | + ]; |
|
| 309 | + } |
|
| 310 | 310 | |
| 311 | - header('Content-Type: application/json'); |
|
| 312 | - echo json_encode($pokestops); |
|
| 311 | + header('Content-Type: application/json'); |
|
| 312 | + echo json_encode($pokestops); |
|
| 313 | 313 | |
| 314 | - break; |
|
| 314 | + break; |
|
| 315 | 315 | |
| 316 | 316 | |
| 317 | - #################################### |
|
| 318 | - // |
|
| 319 | - // Update data for the gym battle |
|
| 320 | - // |
|
| 321 | - #################################### |
|
| 317 | + #################################### |
|
| 318 | + // |
|
| 319 | + // Update data for the gym battle |
|
| 320 | + // |
|
| 321 | + #################################### |
|
| 322 | 322 | |
| 323 | - case 'update_gym': |
|
| 324 | - $teams = new stdClass(); |
|
| 325 | - $teams->mystic = 1; |
|
| 326 | - $teams->valor = 2; |
|
| 327 | - $teams->instinct = 3; |
|
| 323 | + case 'update_gym': |
|
| 324 | + $teams = new stdClass(); |
|
| 325 | + $teams->mystic = 1; |
|
| 326 | + $teams->valor = 2; |
|
| 327 | + $teams->instinct = 3; |
|
| 328 | 328 | |
| 329 | 329 | |
| 330 | - foreach ($teams as $team_name => $team_id) { |
|
| 331 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'"; |
|
| 332 | - $result = $mysqli->query($req); |
|
| 333 | - $data = $result->fetch_object(); |
|
| 330 | + foreach ($teams as $team_name => $team_id) { |
|
| 331 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(total_cp),0) AS average_points FROM gym WHERE team_id = '".$team_id."'"; |
|
| 332 | + $result = $mysqli->query($req); |
|
| 333 | + $data = $result->fetch_object(); |
|
| 334 | 334 | |
| 335 | - $return[] = $data->total; |
|
| 336 | - $return[] = $data->average_points; |
|
| 337 | - } |
|
| 335 | + $return[] = $data->total; |
|
| 336 | + $return[] = $data->average_points; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - header('Content-Type: application/json'); |
|
| 340 | - echo json_encode($return); |
|
| 339 | + header('Content-Type: application/json'); |
|
| 340 | + echo json_encode($return); |
|
| 341 | 341 | |
| 342 | - break; |
|
| 342 | + break; |
|
| 343 | 343 | |
| 344 | 344 | |
| 345 | - #################################### |
|
| 346 | - // |
|
| 347 | - // Get datas for the gym map |
|
| 348 | - // |
|
| 349 | - #################################### |
|
| 345 | + #################################### |
|
| 346 | + // |
|
| 347 | + // Get datas for the gym map |
|
| 348 | + // |
|
| 349 | + #################################### |
|
| 350 | 350 | |
| 351 | 351 | |
| 352 | - case 'gym_map': |
|
| 353 | - $req = "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"; |
|
| 354 | - $result = $mysqli->query($req); |
|
| 352 | + case 'gym_map': |
|
| 353 | + $req = "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"; |
|
| 354 | + $result = $mysqli->query($req); |
|
| 355 | 355 | |
| 356 | - $gyms = []; |
|
| 356 | + $gyms = []; |
|
| 357 | 357 | |
| 358 | - while ($data = $result->fetch_object()) { |
|
| 359 | - // Team |
|
| 360 | - // 1 = bleu |
|
| 361 | - // 2 = rouge |
|
| 362 | - // 3 = jaune |
|
| 358 | + while ($data = $result->fetch_object()) { |
|
| 359 | + // Team |
|
| 360 | + // 1 = bleu |
|
| 361 | + // 2 = rouge |
|
| 362 | + // 3 = jaune |
|
| 363 | 363 | |
| 364 | - switch ($data->team_id) { |
|
| 364 | + switch ($data->team_id) { |
|
| 365 | 365 | case 0: |
| 366 | 366 | $icon = 'map_white.png'; |
| 367 | 367 | $team = 'No Team (yet)'; |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | $team = 'Team Instinct'; |
| 386 | 386 | $color = 'rgba(254, 217, 40, .6)'; |
| 387 | 387 | break; |
| 388 | - } |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | 390 | if ($data->team_id != 0) { |
| 391 | 391 | $icon .= $data->level.".png"; |
@@ -411,50 +411,50 @@ discard block |
||
| 411 | 411 | // |
| 412 | 412 | #################################### |
| 413 | 413 | |
| 414 | - case 'gym_defenders': |
|
| 415 | - $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 416 | - $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 414 | + case 'gym_defenders': |
|
| 415 | + $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 416 | + $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 417 | 417 | (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 |
| 418 | 418 | FROM gymdetails |
| 419 | 419 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
| 420 | 420 | WHERE gym.gym_id='".$gym_id."'"; |
| 421 | - $result = $mysqli->query($req); |
|
| 421 | + $result = $mysqli->query($req); |
|
| 422 | 422 | |
| 423 | - $gymData['gymDetails']['gymInfos'] = false; |
|
| 423 | + $gymData['gymDetails']['gymInfos'] = false; |
|
| 424 | 424 | |
| 425 | - while ($data = $result->fetch_object()) { |
|
| 426 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 427 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 428 | - if ($data->url == null) { |
|
| 429 | - $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 430 | - } else { |
|
| 431 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 425 | + while ($data = $result->fetch_object()) { |
|
| 426 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 427 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 428 | + if ($data->url == null) { |
|
| 429 | + $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 430 | + } else { |
|
| 431 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 432 | + } |
|
| 433 | + $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 434 | + $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 435 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 436 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 437 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 432 | 438 | } |
| 433 | - $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 434 | - $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 435 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 436 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 437 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 438 | - } |
|
| 439 | 439 | |
| 440 | - $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 440 | + $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 441 | 441 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 442 | 442 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
| 443 | 443 | HAVING gymmember.gym_id='".$gym_id."' |
| 444 | 444 | ORDER BY cp DESC"; |
| 445 | - $result = $mysqli->query($req); |
|
| 445 | + $result = $mysqli->query($req); |
|
| 446 | 446 | |
| 447 | - $i = 0; |
|
| 447 | + $i = 0; |
|
| 448 | 448 | |
| 449 | - $gymData['infoWindow'] = ' |
|
| 449 | + $gymData['infoWindow'] = ' |
|
| 450 | 450 | <div class="gym_defenders"> |
| 451 | 451 | '; |
| 452 | - while ($data = $result->fetch_object()) { |
|
| 453 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
| 454 | - if ($data != false) { |
|
| 455 | - $pokemon_id = $data->pokemon_id; |
|
| 456 | - if ($config->system->iv_numbers) { |
|
| 457 | - $gymData['infoWindow'] .= ' |
|
| 452 | + while ($data = $result->fetch_object()) { |
|
| 453 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
| 454 | + if ($data != false) { |
|
| 455 | + $pokemon_id = $data->pokemon_id; |
|
| 456 | + if ($config->system->iv_numbers) { |
|
| 457 | + $gymData['infoWindow'] .= ' |
|
| 458 | 458 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 459 | 459 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 460 | 460 | <img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | </div> |
| 473 | 473 | </div> |
| 474 | 474 | </div>'; |
| 475 | - } else { |
|
| 476 | - $gymData['infoWindow'] .= ' |
|
| 475 | + } else { |
|
| 476 | + $gymData['infoWindow'] .= ' |
|
| 477 | 477 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 478 | 478 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 479 | 479 | <img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
@@ -491,80 +491,80 @@ discard block |
||
| 491 | 491 | </div> |
| 492 | 492 | </div> |
| 493 | 493 | </div>' |
| 494 | - ; } |
|
| 495 | - } else { |
|
| 496 | - $pokemon_id = $gymData['gymDetails']['gymInfos']['guardPokemonId']; |
|
| 497 | - $gymData['infoWindow'] .= ' |
|
| 494 | + ; } |
|
| 495 | + } else { |
|
| 496 | + $pokemon_id = $gymData['gymDetails']['gymInfos']['guardPokemonId']; |
|
| 497 | + $gymData['infoWindow'] .= ' |
|
| 498 | 498 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 499 | 499 | <a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'"> |
| 500 | 500 | <img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
| 501 | 501 | </a> |
| 502 | 502 | <p class="pkmn-name">???</p> |
| 503 | 503 | </div>' |
| 504 | - ; |
|
| 504 | + ; |
|
| 505 | + } |
|
| 506 | + $i++; |
|
| 505 | 507 | } |
| 506 | - $i++; |
|
| 507 | - } |
|
| 508 | 508 | |
| 509 | - // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 510 | - if (!$gymData['gymDetails']['gymInfos']) { |
|
| 511 | - $req = "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 |
|
| 509 | + // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 510 | + if (!$gymData['gymDetails']['gymInfos']) { |
|
| 511 | + $req = "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 |
|
| 512 | 512 | FROM gym WHERE gym_id='".$gym_id."'"; |
| 513 | - $result = $mysqli->query($req); |
|
| 514 | - $data = $result->fetch_object(); |
|
| 515 | - |
|
| 516 | - $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 517 | - $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 518 | - $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 519 | - $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 520 | - $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 521 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 522 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team_id; |
|
| 523 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 524 | - |
|
| 525 | - $pokemon_id = $data->guard_pokemon_id; |
|
| 526 | - $gymData['infoWindow'] .= ' |
|
| 513 | + $result = $mysqli->query($req); |
|
| 514 | + $data = $result->fetch_object(); |
|
| 515 | + |
|
| 516 | + $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 517 | + $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 518 | + $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 519 | + $gymData['gymDetails']['gymInfos']['points'] = $data->total_cp; |
|
| 520 | + $gymData['gymDetails']['gymInfos']['level'] = $data->level; |
|
| 521 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 522 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team_id; |
|
| 523 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 524 | + |
|
| 525 | + $pokemon_id = $data->guard_pokemon_id; |
|
| 526 | + $gymData['infoWindow'] .= ' |
|
| 527 | 527 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 528 | 528 | <a href="pokemon/'.$data->guard_pokemon_id.'"> |
| 529 | 529 | <img src="'.$pokemons->pokemon->$pokemon_id->img.'" height="50" style="display:inline-block" > |
| 530 | 530 | </a> |
| 531 | 531 | <p class="pkmn-name">???</p> |
| 532 | 532 | </div>'; |
| 533 | - } |
|
| 534 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 533 | + } |
|
| 534 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 535 | 535 | |
| 536 | - header('Content-Type: application/json'); |
|
| 537 | - echo json_encode($gymData); |
|
| 536 | + header('Content-Type: application/json'); |
|
| 537 | + echo json_encode($gymData); |
|
| 538 | 538 | |
| 539 | - break; |
|
| 539 | + break; |
|
| 540 | 540 | |
| 541 | 541 | |
| 542 | - case 'trainer': |
|
| 543 | - $name = ""; |
|
| 544 | - $page = "0"; |
|
| 545 | - $where = ""; |
|
| 546 | - $order = ""; |
|
| 547 | - $team = 0; |
|
| 548 | - $ranking = 0; |
|
| 549 | - if (isset($_GET['name'])) { |
|
| 550 | - $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 551 | - $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 552 | - } |
|
| 553 | - if (isset($_GET['team']) && $_GET['team'] != 0) { |
|
| 554 | - $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 555 | - $where .= ($where == "" ? " HAVING" : " AND")." team = ".$team; |
|
| 556 | - } |
|
| 557 | - if (!empty($config->system->trainer_blacklist)) { |
|
| 558 | - $where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')"; |
|
| 559 | - } |
|
| 560 | - if (isset($_GET['page'])) { |
|
| 561 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 562 | - } |
|
| 563 | - if (isset($_GET['ranking'])) { |
|
| 564 | - $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 565 | - } |
|
| 542 | + case 'trainer': |
|
| 543 | + $name = ""; |
|
| 544 | + $page = "0"; |
|
| 545 | + $where = ""; |
|
| 546 | + $order = ""; |
|
| 547 | + $team = 0; |
|
| 548 | + $ranking = 0; |
|
| 549 | + if (isset($_GET['name'])) { |
|
| 550 | + $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 551 | + $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 552 | + } |
|
| 553 | + if (isset($_GET['team']) && $_GET['team'] != 0) { |
|
| 554 | + $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 555 | + $where .= ($where == "" ? " HAVING" : " AND")." team = ".$team; |
|
| 556 | + } |
|
| 557 | + if (!empty($config->system->trainer_blacklist)) { |
|
| 558 | + $where .= ($where == "" ? " HAVING" : " AND")." name NOT IN ('".implode("','", $config->system->trainer_blacklist)."')"; |
|
| 559 | + } |
|
| 560 | + if (isset($_GET['page'])) { |
|
| 561 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 562 | + } |
|
| 563 | + if (isset($_GET['ranking'])) { |
|
| 564 | + $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 565 | + } |
|
| 566 | 566 | |
| 567 | - switch ($ranking) { |
|
| 567 | + switch ($ranking) { |
|
| 568 | 568 | case 1: |
| 569 | 569 | $order = " ORDER BY active DESC, level DESC"; |
| 570 | 570 | break; |
@@ -573,7 +573,7 @@ discard block |
||
| 573 | 573 | break; |
| 574 | 574 | default: |
| 575 | 575 | $order = " ORDER BY level DESC, active DESC"; |
| 576 | - } |
|
| 576 | + } |
|
| 577 | 577 | |
| 578 | 578 | $order .= ", last_seen DESC, name "; |
| 579 | 579 | |
@@ -649,73 +649,73 @@ discard block |
||
| 649 | 649 | break; |
| 650 | 650 | |
| 651 | 651 | |
| 652 | - case 'raids': |
|
| 653 | - $page = "0"; |
|
| 654 | - if (isset($_GET['page'])) { |
|
| 655 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 656 | - } |
|
| 652 | + case 'raids': |
|
| 653 | + $page = "0"; |
|
| 654 | + if (isset($_GET['page'])) { |
|
| 655 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 656 | + } |
|
| 657 | 657 | |
| 658 | - $limit = " LIMIT ".($page * 10).",10"; |
|
| 658 | + $limit = " LIMIT ".($page * 10).",10"; |
|
| 659 | 659 | |
| 660 | - $req = "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 |
|
| 660 | + $req = "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 |
|
| 661 | 661 | JOIN gymdetails ON gymdetails.gym_id = raid.gym_id |
| 662 | 662 | JOIN gym ON gym.gym_id = raid.gym_id |
| 663 | 663 | WHERE raid.end > UTC_TIMESTAMP() |
| 664 | 664 | ORDER BY raid.level DESC, raid.start".$limit; |
| 665 | 665 | |
| 666 | - $result = $mysqli->query($req); |
|
| 667 | - $raids = array(); |
|
| 668 | - while ($data = $result->fetch_object()) { |
|
| 669 | - $data->starttime = date("H:i", strtotime($data->start)); |
|
| 670 | - $data->endtime = date("H:i", strtotime($data->end)); |
|
| 671 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 672 | - if (isset($data->move_1)) { |
|
| 673 | - $move1 = $data->move_1; |
|
| 674 | - $data->quick_move = $move->$move1->name; |
|
| 675 | - } else { |
|
| 676 | - $data->quick_move = "?"; |
|
| 677 | - } |
|
| 678 | - if (isset($data->move_2)) { |
|
| 679 | - $move2 = $data->move_2; |
|
| 680 | - $data->charge_move = $move->$move2->name; |
|
| 681 | - } else { |
|
| 682 | - $data->charge_move = "?"; |
|
| 666 | + $result = $mysqli->query($req); |
|
| 667 | + $raids = array(); |
|
| 668 | + while ($data = $result->fetch_object()) { |
|
| 669 | + $data->starttime = date("H:i", strtotime($data->start)); |
|
| 670 | + $data->endtime = date("H:i", strtotime($data->end)); |
|
| 671 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 672 | + if (isset($data->move_1)) { |
|
| 673 | + $move1 = $data->move_1; |
|
| 674 | + $data->quick_move = $move->$move1->name; |
|
| 675 | + } else { |
|
| 676 | + $data->quick_move = "?"; |
|
| 677 | + } |
|
| 678 | + if (isset($data->move_2)) { |
|
| 679 | + $move2 = $data->move_2; |
|
| 680 | + $data->charge_move = $move->$move2->name; |
|
| 681 | + } else { |
|
| 682 | + $data->charge_move = "?"; |
|
| 683 | + } |
|
| 684 | + $raids[$data->gym_id] = $data; |
|
| 683 | 685 | } |
| 684 | - $raids[$data->gym_id] = $data; |
|
| 685 | - } |
|
| 686 | - $json = array(); |
|
| 687 | - $json['raids'] = $raids; |
|
| 688 | - $locale = array(); |
|
| 689 | - $locale['noraids'] = $locales->RAIDS_NONE; |
|
| 690 | - $json['locale'] = $locale; |
|
| 686 | + $json = array(); |
|
| 687 | + $json['raids'] = $raids; |
|
| 688 | + $locale = array(); |
|
| 689 | + $locale['noraids'] = $locales->RAIDS_NONE; |
|
| 690 | + $json['locale'] = $locale; |
|
| 691 | 691 | |
| 692 | - header('Content-Type: application/json'); |
|
| 693 | - echo json_encode($json); |
|
| 692 | + header('Content-Type: application/json'); |
|
| 693 | + echo json_encode($json); |
|
| 694 | 694 | |
| 695 | - break; |
|
| 695 | + break; |
|
| 696 | 696 | |
| 697 | 697 | |
| 698 | - case 'gyms': |
|
| 699 | - $page = '0'; |
|
| 700 | - $where = ''; |
|
| 701 | - $order = ''; |
|
| 702 | - $ranking = 0; |
|
| 703 | - if (isset($_GET['name']) && $_GET['name'] != '') { |
|
| 704 | - $gym_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 705 | - $where = " WHERE name LIKE '%".$gym_name."%'"; |
|
| 706 | - } |
|
| 707 | - if (isset($_GET['team']) && $_GET['team'] != '') { |
|
| 708 | - $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 709 | - $where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team; |
|
| 710 | - } |
|
| 711 | - if (isset($_GET['page'])) { |
|
| 712 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 713 | - } |
|
| 714 | - if (isset($_GET['ranking'])) { |
|
| 715 | - $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 716 | - } |
|
| 698 | + case 'gyms': |
|
| 699 | + $page = '0'; |
|
| 700 | + $where = ''; |
|
| 701 | + $order = ''; |
|
| 702 | + $ranking = 0; |
|
| 703 | + if (isset($_GET['name']) && $_GET['name'] != '') { |
|
| 704 | + $gym_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 705 | + $where = " WHERE name LIKE '%".$gym_name."%'"; |
|
| 706 | + } |
|
| 707 | + if (isset($_GET['team']) && $_GET['team'] != '') { |
|
| 708 | + $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 709 | + $where .= ($where == "" ? " WHERE" : " AND")." team_id = ".$team; |
|
| 710 | + } |
|
| 711 | + if (isset($_GET['page'])) { |
|
| 712 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 713 | + } |
|
| 714 | + if (isset($_GET['ranking'])) { |
|
| 715 | + $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - switch ($ranking) { |
|
| 718 | + switch ($ranking) { |
|
| 719 | 719 | case 1: |
| 720 | 720 | $order = " ORDER BY name, last_modified DESC"; |
| 721 | 721 | break; |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | break; |
| 725 | 725 | default: |
| 726 | 726 | $order = " ORDER BY last_modified DESC, name"; |
| 727 | - } |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | 729 | $limit = " LIMIT ".($page * 10).",10"; |
| 730 | 730 | |
@@ -766,163 +766,163 @@ discard block |
||
| 766 | 766 | break; |
| 767 | 767 | |
| 768 | 768 | |
| 769 | - case 'gymhistory': |
|
| 770 | - $gym_id = ''; |
|
| 771 | - $page = '0'; |
|
| 772 | - if (isset($_GET['gym_id'])) { |
|
| 773 | - $gym_id = mysqli_real_escape_string($mysqli, $_GET['gym_id']); |
|
| 774 | - $gym_id = str_replace('_', '.', $gym_id); |
|
| 775 | - } |
|
| 776 | - if (isset($_GET['page'])) { |
|
| 777 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 778 | - } |
|
| 769 | + case 'gymhistory': |
|
| 770 | + $gym_id = ''; |
|
| 771 | + $page = '0'; |
|
| 772 | + if (isset($_GET['gym_id'])) { |
|
| 773 | + $gym_id = mysqli_real_escape_string($mysqli, $_GET['gym_id']); |
|
| 774 | + $gym_id = str_replace('_', '.', $gym_id); |
|
| 775 | + } |
|
| 776 | + if (isset($_GET['page'])) { |
|
| 777 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 778 | + } |
|
| 779 | 779 | |
| 780 | - $entries = array(); |
|
| 780 | + $entries = array(); |
|
| 781 | 781 | |
| 782 | - if ($gym_id != '') { |
|
| 783 | - $req = "SELECT gym_id, team_id, total_cp, pokemon_uids, pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '".$time_offset."')) as last_modified |
|
| 782 | + if ($gym_id != '') { |
|
| 783 | + $req = "SELECT gym_id, team_id, total_cp, pokemon_uids, pokemon_count, (CONVERT_TZ(last_modified, '+00:00', '".$time_offset."')) as last_modified |
|
| 784 | 784 | FROM gymhistory |
| 785 | 785 | WHERE gym_id='".$gym_id."' |
| 786 | 786 | ORDER BY last_modified DESC |
| 787 | 787 | LIMIT ".($page * 10).",11"; |
| 788 | 788 | |
| 789 | - $result = $mysqli->query($req); |
|
| 790 | - while ($result && $data = $result->fetch_object()) { |
|
| 791 | - $pkm = array(); |
|
| 792 | - if ($data->total_cp == 0) { $data->pokemon_uids = ''; } |
|
| 793 | - if ($data->pokemon_uids != '') { |
|
| 794 | - $pkm_uids = explode(',', $data->pokemon_uids); |
|
| 795 | - $pkm_req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name |
|
| 789 | + $result = $mysqli->query($req); |
|
| 790 | + while ($result && $data = $result->fetch_object()) { |
|
| 791 | + $pkm = array(); |
|
| 792 | + if ($data->total_cp == 0) { $data->pokemon_uids = ''; } |
|
| 793 | + if ($data->pokemon_uids != '') { |
|
| 794 | + $pkm_uids = explode(',', $data->pokemon_uids); |
|
| 795 | + $pkm_req = "SELECT DISTINCT pokemon_uid, pokemon_id, cp, trainer_name |
|
| 796 | 796 | FROM gympokemon |
| 797 | 797 | WHERE pokemon_uid IN ('".implode("','", $pkm_uids)."') |
| 798 | 798 | ORDER BY FIND_IN_SET(pokemon_uid, '".implode(",", $pkm_uids)."')"; |
| 799 | - $pkm_result = $mysqli->query($pkm_req); |
|
| 800 | - while ($pkm_result && $pkm_data = $pkm_result->fetch_object()) { |
|
| 801 | - $pkm[$pkm_data->pokemon_uid] = $pkm_data; |
|
| 799 | + $pkm_result = $mysqli->query($pkm_req); |
|
| 800 | + while ($pkm_result && $pkm_data = $pkm_result->fetch_object()) { |
|
| 801 | + $pkm[$pkm_data->pokemon_uid] = $pkm_data; |
|
| 802 | + } |
|
| 802 | 803 | } |
| 804 | + $data->pokemon = $pkm; |
|
| 805 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 806 | + $entries[] = $data; |
|
| 803 | 807 | } |
| 804 | - $data->pokemon = $pkm; |
|
| 805 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 806 | - $entries[] = $data; |
|
| 807 | - } |
|
| 808 | - |
|
| 809 | - foreach ($entries as $idx => $entry) { |
|
| 810 | - $entry->total_cp_diff = 0; |
|
| 811 | - $entry->only_cp_changed = true; |
|
| 812 | - if ($idx < count($entries) - 1) { |
|
| 813 | - $next_entry = $entries[$idx+1]; |
|
| 814 | - $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
|
| 815 | - $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
|
| 816 | - $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 817 | - $next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 818 | - $new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon); |
|
| 819 | - $old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon); |
|
| 820 | - foreach ($new_pokemon as $pkm) { |
|
| 821 | - $entry->pokemon[$pkm]->class = 'new'; |
|
| 822 | - } |
|
| 823 | - foreach ($old_pokemon as $pkm) { |
|
| 824 | - $next_entry->pokemon[$pkm]->class = 'old'; |
|
| 825 | - } |
|
| 826 | - if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 827 | - $entry->only_cp_changed = false; |
|
| 808 | + |
|
| 809 | + foreach ($entries as $idx => $entry) { |
|
| 810 | + $entry->total_cp_diff = 0; |
|
| 811 | + $entry->only_cp_changed = true; |
|
| 812 | + if ($idx < count($entries) - 1) { |
|
| 813 | + $next_entry = $entries[$idx+1]; |
|
| 814 | + $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
|
| 815 | + $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
|
| 816 | + $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 817 | + $next_entry_pokemon = preg_split('/,/', $next_entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
|
| 818 | + $new_pokemon = array_diff($entry_pokemon, $next_entry_pokemon); |
|
| 819 | + $old_pokemon = array_diff($next_entry_pokemon, $entry_pokemon); |
|
| 820 | + foreach ($new_pokemon as $pkm) { |
|
| 821 | + $entry->pokemon[$pkm]->class = 'new'; |
|
| 822 | + } |
|
| 823 | + foreach ($old_pokemon as $pkm) { |
|
| 824 | + $next_entry->pokemon[$pkm]->class = 'old'; |
|
| 825 | + } |
|
| 826 | + if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 827 | + $entry->only_cp_changed = false; |
|
| 828 | + } |
|
| 828 | 829 | } |
| 830 | + unset($entry->pokemon_uids); |
|
| 829 | 831 | } |
| 830 | - unset($entry->pokemon_uids); |
|
| 832 | + |
|
| 833 | + if (count($entries) > 10) { array_pop($entries); } |
|
| 831 | 834 | } |
| 832 | 835 | |
| 833 | - if (count($entries) > 10) { array_pop($entries); } |
|
| 834 | - } |
|
| 836 | + $json = array(); |
|
| 837 | + $json['entries'] = $entries; |
|
| 838 | + $locale = array(); |
|
| 839 | + $json['locale'] = $locale; |
|
| 835 | 840 | |
| 836 | - $json = array(); |
|
| 837 | - $json['entries'] = $entries; |
|
| 838 | - $locale = array(); |
|
| 839 | - $json['locale'] = $locale; |
|
| 841 | + header('Content-Type: application/json'); |
|
| 842 | + echo json_encode($json); |
|
| 840 | 843 | |
| 841 | - header('Content-Type: application/json'); |
|
| 842 | - echo json_encode($json); |
|
| 844 | + break; |
|
| 843 | 845 | |
| 844 | - break; |
|
| 845 | 846 | |
| 847 | + case 'pokemon_slider_init': |
|
| 848 | + $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 849 | + $result = $mysqli->query($req); |
|
| 850 | + $bounds = $result->fetch_object(); |
|
| 846 | 851 | |
| 847 | - case 'pokemon_slider_init': |
|
| 848 | - $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 849 | - $result = $mysqli->query($req); |
|
| 850 | - $bounds = $result->fetch_object(); |
|
| 852 | + header('Content-Type: application/json'); |
|
| 853 | + echo json_encode($bounds); |
|
| 851 | 854 | |
| 852 | - header('Content-Type: application/json'); |
|
| 853 | - echo json_encode($bounds); |
|
| 855 | + break; |
|
| 854 | 856 | |
| 855 | - break; |
|
| 856 | 857 | |
| 858 | + case 'pokemon_heatmap_points': |
|
| 859 | + $json = ""; |
|
| 860 | + if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 861 | + $start = date("Y-m-d H:i", (int) $_GET['start']); |
|
| 862 | + $end = date("Y-m-d H:i", (int) $_GET['end']); |
|
| 863 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 864 | + $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 865 | + . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 866 | + $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 867 | + $result = $mysqli->query($req); |
|
| 868 | + $points = array(); |
|
| 869 | + while ($result && $data = $result->fetch_object()) { |
|
| 870 | + $points[] = $data; |
|
| 871 | + } |
|
| 857 | 872 | |
| 858 | - case 'pokemon_heatmap_points': |
|
| 859 | - $json = ""; |
|
| 860 | - if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 861 | - $start = date("Y-m-d H:i", (int) $_GET['start']); |
|
| 862 | - $end = date("Y-m-d H:i", (int) $_GET['end']); |
|
| 863 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 864 | - $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 865 | - . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 866 | - $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 867 | - $result = $mysqli->query($req); |
|
| 868 | - $points = array(); |
|
| 869 | - while ($result && $data = $result->fetch_object()) { |
|
| 870 | - $points[] = $data; |
|
| 873 | + $json = json_encode($points); |
|
| 871 | 874 | } |
| 872 | 875 | |
| 873 | - $json = json_encode($points); |
|
| 874 | - } |
|
| 875 | - |
|
| 876 | - header('Content-Type: application/json'); |
|
| 877 | - echo $json; |
|
| 878 | - break; |
|
| 876 | + header('Content-Type: application/json'); |
|
| 877 | + echo $json; |
|
| 878 | + break; |
|
| 879 | 879 | |
| 880 | 880 | |
| 881 | - case 'maps_localization_coordinates': |
|
| 882 | - $json = ""; |
|
| 883 | - $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 884 | - $result = $mysqli->query($req); |
|
| 885 | - $coordinates = $result->fetch_object(); |
|
| 881 | + case 'maps_localization_coordinates': |
|
| 882 | + $json = ""; |
|
| 883 | + $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 884 | + $result = $mysqli->query($req); |
|
| 885 | + $coordinates = $result->fetch_object(); |
|
| 886 | 886 | |
| 887 | - header('Content-Type: application/json'); |
|
| 888 | - echo json_encode($coordinates); |
|
| 887 | + header('Content-Type: application/json'); |
|
| 888 | + echo json_encode($coordinates); |
|
| 889 | 889 | |
| 890 | - break; |
|
| 890 | + break; |
|
| 891 | 891 | |
| 892 | 892 | |
| 893 | - case 'pokemon_graph_data': |
|
| 894 | - $json = ""; |
|
| 895 | - if (isset($_GET['pokemon_id'])) { |
|
| 896 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 897 | - $req = "SELECT COUNT(*) AS total, |
|
| 893 | + case 'pokemon_graph_data': |
|
| 894 | + $json = ""; |
|
| 895 | + if (isset($_GET['pokemon_id'])) { |
|
| 896 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 897 | + $req = "SELECT COUNT(*) AS total, |
|
| 898 | 898 | HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour |
| 899 | 899 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
| 900 | 900 | GROUP BY disappear_hour |
| 901 | 901 | ORDER BY disappear_hour"; |
| 902 | - $result = $mysqli->query($req); |
|
| 903 | - $array = array_fill(0, 24, 0); |
|
| 904 | - while ($result && $data = $result->fetch_object()) { |
|
| 905 | - $array[$data->disappear_hour] = $data->total; |
|
| 902 | + $result = $mysqli->query($req); |
|
| 903 | + $array = array_fill(0, 24, 0); |
|
| 904 | + while ($result && $data = $result->fetch_object()) { |
|
| 905 | + $array[$data->disappear_hour] = $data->total; |
|
| 906 | + } |
|
| 907 | + // shift array because AM/PM starts at 1AM not 0:00 |
|
| 908 | + $array[] = $array[0]; |
|
| 909 | + array_shift($array); |
|
| 910 | + |
|
| 911 | + $json = json_encode($array); |
|
| 906 | 912 | } |
| 907 | - // shift array because AM/PM starts at 1AM not 0:00 |
|
| 908 | - $array[] = $array[0]; |
|
| 909 | - array_shift($array); |
|
| 910 | 913 | |
| 911 | - $json = json_encode($array); |
|
| 912 | - } |
|
| 914 | + header('Content-Type: application/json'); |
|
| 915 | + echo $json; |
|
| 916 | + break; |
|
| 913 | 917 | |
| 914 | - header('Content-Type: application/json'); |
|
| 915 | - echo $json; |
|
| 916 | - break; |
|
| 917 | 918 | |
| 919 | + case 'postRequest': |
|
| 920 | + break; |
|
| 918 | 921 | |
| 919 | - case 'postRequest': |
|
| 922 | + default: |
|
| 923 | + echo "What do you mean?"; |
|
| 924 | + exit(); |
|
| 920 | 925 | break; |
| 921 | - |
|
| 922 | - default: |
|
| 923 | - echo "What do you mean?"; |
|
| 924 | - exit(); |
|
| 925 | - break; |
|
| 926 | 926 | } |
| 927 | 927 | |
| 928 | 928 | if ($postRequest != "") { |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | FROM gymmember |
| 744 | 744 | LEFT JOIN gympokemon |
| 745 | 745 | ON gymmember.pokemon_uid = gympokemon.pokemon_uid |
| 746 | - WHERE gymmember.gym_id = '". $data->gym_id ."' |
|
| 746 | + WHERE gymmember.gym_id = '". $data->gym_id."' |
|
| 747 | 747 | ORDER BY deployment_time"; |
| 748 | 748 | $pkm_result = $mysqli->query($pkm_req); |
| 749 | 749 | while ($pkm_result && $pkm_data = $pkm_result->fetch_object()) { |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | $entry->total_cp_diff = 0; |
| 811 | 811 | $entry->only_cp_changed = true; |
| 812 | 812 | if ($idx < count($entries) - 1) { |
| 813 | - $next_entry = $entries[$idx+1]; |
|
| 813 | + $next_entry = $entries[$idx + 1]; |
|
| 814 | 814 | $entry->total_cp_diff = $entry->total_cp - $next_entry->total_cp; |
| 815 | 815 | $entry->class = $entry->total_cp_diff > 0 ? 'gain' : ($entry->total_cp_diff < 0 ? 'loss' : ''); |
| 816 | 816 | $entry_pokemon = preg_split('/,/', $entry->pokemon_uids, null, PREG_SPLIT_NO_EMPTY); |
@@ -823,7 +823,7 @@ discard block |
||
| 823 | 823 | foreach ($old_pokemon as $pkm) { |
| 824 | 824 | $next_entry->pokemon[$pkm]->class = 'old'; |
| 825 | 825 | } |
| 826 | - if ($entry->team_id != $next_entry->team_id|| $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 826 | + if ($entry->team_id != $next_entry->team_id || $entry->pokemon_uids != $next_entry->pokemon_uids) { |
|
| 827 | 827 | $entry->only_cp_changed = false; |
| 828 | 828 | } |
| 829 | 829 | } |