@@ -58,152 +58,152 @@ 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, 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, 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 | - $last_location = new stdClass(); |
|
| 181 | - $last_location->latitude = $data->latitude; |
|
| 182 | - $last_location->longitude = $data->longitude; |
|
| 183 | - |
|
| 184 | - if ($config->system->recents_show_iv) { |
|
| 185 | - $iv = new stdClass(); |
|
| 186 | - $iv->attack = $data->individual_attack; |
|
| 187 | - $iv->defense = $data->individual_defense; |
|
| 188 | - $iv->stamina = $data->individual_stamina; |
|
| 189 | - if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) { |
|
| 190 | - $iv->available = true; |
|
| 191 | - } else { |
|
| 192 | - $iv->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 | + $last_location = new stdClass(); |
|
| 181 | + $last_location->latitude = $data->latitude; |
|
| 182 | + $last_location->longitude = $data->longitude; |
|
| 183 | + |
|
| 184 | + if ($config->system->recents_show_iv) { |
|
| 185 | + $iv = new stdClass(); |
|
| 186 | + $iv->attack = $data->individual_attack; |
|
| 187 | + $iv->defense = $data->individual_defense; |
|
| 188 | + $iv->stamina = $data->individual_stamina; |
|
| 189 | + if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) { |
|
| 190 | + $iv->available = true; |
|
| 191 | + } else { |
|
| 192 | + $iv->available = false; |
|
| 193 | + } |
|
| 193 | 194 | } |
| 194 | - } |
|
| 195 | 195 | |
| 196 | - $html = ' |
|
| 196 | + $html = ' |
|
| 197 | 197 | <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;"> |
| 198 | 198 | <a href="pokemon/'.$pokeid.'"><img src="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a> |
| 199 | 199 | <a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a> |
| 200 | 200 | <a href="https://maps.google.com/?q='.$last_location->latitude.','.$last_location->longitude.'&ll='.$last_location->latitude.','.$last_location->longitude.'&z=16" target="_blank"> |
| 201 | 201 | <small class="pokemon-timer">00:00:00</small> |
| 202 | 202 | </a>'; |
| 203 | - if ($config->system->recents_show_iv) { |
|
| 204 | - if ($iv->available) { |
|
| 205 | - if ($config->system->iv_numbers) { |
|
| 206 | - $html .= ' |
|
| 203 | + if ($config->system->recents_show_iv) { |
|
| 204 | + if ($iv->available) { |
|
| 205 | + if ($config->system->iv_numbers) { |
|
| 206 | + $html .= ' |
|
| 207 | 207 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 208 | 208 | <div title="'.$locales->IV_ATTACK.': '.$iv->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$iv->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px";> |
| 209 | 209 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .' |
@@ -215,8 +215,8 @@ discard block |
||
| 215 | 215 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .' |
| 216 | 216 | </div> |
| 217 | 217 | </div>'; |
| 218 | - } else { |
|
| 219 | - $html .= ' |
|
| 218 | + } else { |
|
| 219 | + $html .= ' |
|
| 220 | 220 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto;"> |
| 221 | 221 | <div title="'.$locales->IV_ATTACK.': '.$iv->attack.'" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$iv->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->attack) / 3).'%"> |
| 222 | 222 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span> |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span> |
| 229 | 229 | </div> |
| 230 | 230 | </div>'; |
| 231 | - } |
|
| 232 | - } else { |
|
| 233 | - if ($config->system->iv_numbers) { |
|
| 234 | - $html .= ' |
|
| 231 | + } |
|
| 232 | + } else { |
|
| 233 | + if ($config->system->iv_numbers) { |
|
| 234 | + $html .= ' |
|
| 235 | 235 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 236 | 236 | <div title="'.$locales->IV_ATTACK.': not available" class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="'.$iv->attack.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px";> |
| 237 | 237 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span> |
@@ -243,127 +243,127 @@ discard block |
||
| 243 | 243 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span> |
| 244 | 244 | </div> |
| 245 | 245 | </div>'; |
| 246 | - } else { |
|
| 247 | - $html .= ' |
|
| 246 | + } else { |
|
| 247 | + $html .= ' |
|
| 248 | 248 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 15px auto;"> |
| 249 | 249 | <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"> |
| 250 | 250 | <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span> |
| 251 | 251 | </div> |
| 252 | 252 | </div>'; |
| 253 | + } |
|
| 253 | 254 | } |
| 254 | 255 | } |
| 255 | - } |
|
| 256 | - $html .= ' |
|
| 256 | + $html .= ' |
|
| 257 | 257 | </div>'; |
| 258 | - $new_spawn['html'] = $html; |
|
| 259 | - $countdown = $last_seen - time(); |
|
| 260 | - $new_spawn['countdown'] = $countdown; |
|
| 261 | - $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 262 | - $total_spawns[] = $new_spawn; |
|
| 263 | - } else { |
|
| 264 | - break; |
|
| 258 | + $new_spawn['html'] = $html; |
|
| 259 | + $countdown = $last_seen - time(); |
|
| 260 | + $new_spawn['countdown'] = $countdown; |
|
| 261 | + $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 262 | + $total_spawns[] = $new_spawn; |
|
| 263 | + } else { |
|
| 264 | + break; |
|
| 265 | + } |
|
| 265 | 266 | } |
| 266 | - } |
|
| 267 | 267 | |
| 268 | - header('Content-Type: application/json'); |
|
| 269 | - echo json_encode($total_spawns); |
|
| 268 | + header('Content-Type: application/json'); |
|
| 269 | + echo json_encode($total_spawns); |
|
| 270 | 270 | |
| 271 | - break; |
|
| 271 | + break; |
|
| 272 | 272 | |
| 273 | 273 | |
| 274 | - #################################### |
|
| 275 | - // |
|
| 276 | - // List Pokestop |
|
| 277 | - // |
|
| 278 | - #################################### |
|
| 274 | + #################################### |
|
| 275 | + // |
|
| 276 | + // List Pokestop |
|
| 277 | + // |
|
| 278 | + #################################### |
|
| 279 | 279 | |
| 280 | - case 'pokestop': |
|
| 281 | - if ($config->system->only_lured_pokestops) { |
|
| 282 | - $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration"; |
|
| 280 | + case 'pokestop': |
|
| 281 | + if ($config->system->only_lured_pokestops) { |
|
| 282 | + $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration"; |
|
| 283 | + |
|
| 284 | + //show all stops if no lure active |
|
| 285 | + if (!$mysqli->query($req)->fetch_object()) { |
|
| 286 | + $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop"; |
|
| 287 | + } |
|
| 283 | 288 | |
| 284 | - //show all stops if no lure active |
|
| 285 | - if (!$mysqli->query($req)->fetch_object()) { |
|
| 289 | + } else { |
|
| 286 | 290 | $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop"; |
| 287 | 291 | } |
| 288 | - |
|
| 289 | - } else { |
|
| 290 | - $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop"; |
|
| 291 | - } |
|
| 292 | - $result = $mysqli->query($req); |
|
| 292 | + $result = $mysqli->query($req); |
|
| 293 | 293 | |
| 294 | - $pokestops = []; |
|
| 294 | + $pokestops = []; |
|
| 295 | 295 | |
| 296 | - while ($data = $result->fetch_object()) { |
|
| 297 | - if ($data->lure_expiration >= $data->now) { |
|
| 298 | - $icon = 'pokestap_lured.png'; |
|
| 299 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 300 | - } else { |
|
| 301 | - $icon = 'pokestap.png'; |
|
| 302 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 303 | - } |
|
| 296 | + while ($data = $result->fetch_object()) { |
|
| 297 | + if ($data->lure_expiration >= $data->now) { |
|
| 298 | + $icon = 'pokestap_lured.png'; |
|
| 299 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 300 | + } else { |
|
| 301 | + $icon = 'pokestap.png'; |
|
| 302 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - $pokestops[] = [ |
|
| 306 | - $text, |
|
| 307 | - $icon, |
|
| 308 | - $data->latitude, |
|
| 309 | - $data->longitude |
|
| 310 | - ]; |
|
| 311 | - } |
|
| 305 | + $pokestops[] = [ |
|
| 306 | + $text, |
|
| 307 | + $icon, |
|
| 308 | + $data->latitude, |
|
| 309 | + $data->longitude |
|
| 310 | + ]; |
|
| 311 | + } |
|
| 312 | 312 | |
| 313 | - header('Content-Type: application/json'); |
|
| 314 | - echo json_encode($pokestops); |
|
| 313 | + header('Content-Type: application/json'); |
|
| 314 | + echo json_encode($pokestops); |
|
| 315 | 315 | |
| 316 | - break; |
|
| 316 | + break; |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | - #################################### |
|
| 320 | - // |
|
| 321 | - // Update data for the gym battle |
|
| 322 | - // |
|
| 323 | - #################################### |
|
| 319 | + #################################### |
|
| 320 | + // |
|
| 321 | + // Update data for the gym battle |
|
| 322 | + // |
|
| 323 | + #################################### |
|
| 324 | 324 | |
| 325 | - case 'update_gym': |
|
| 326 | - $teams = new stdClass(); |
|
| 327 | - $teams->mystic = 1; |
|
| 328 | - $teams->valor = 2; |
|
| 329 | - $teams->instinct = 3; |
|
| 325 | + case 'update_gym': |
|
| 326 | + $teams = new stdClass(); |
|
| 327 | + $teams->mystic = 1; |
|
| 328 | + $teams->valor = 2; |
|
| 329 | + $teams->instinct = 3; |
|
| 330 | 330 | |
| 331 | 331 | |
| 332 | - foreach ($teams as $team_name => $team_id) { |
|
| 333 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'"; |
|
| 334 | - $result = $mysqli->query($req); |
|
| 335 | - $data = $result->fetch_object(); |
|
| 332 | + foreach ($teams as $team_name => $team_id) { |
|
| 333 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, ROUND(AVG(gym_points),0) AS average_points FROM gym WHERE team_id = '".$team_id."'"; |
|
| 334 | + $result = $mysqli->query($req); |
|
| 335 | + $data = $result->fetch_object(); |
|
| 336 | 336 | |
| 337 | - $return[] = $data->total; |
|
| 338 | - $return[] = $data->average_points; |
|
| 339 | - } |
|
| 337 | + $return[] = $data->total; |
|
| 338 | + $return[] = $data->average_points; |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | - header('Content-Type: application/json'); |
|
| 342 | - echo json_encode($return); |
|
| 341 | + header('Content-Type: application/json'); |
|
| 342 | + echo json_encode($return); |
|
| 343 | 343 | |
| 344 | - break; |
|
| 344 | + break; |
|
| 345 | 345 | |
| 346 | 346 | |
| 347 | - #################################### |
|
| 348 | - // |
|
| 349 | - // Get datas for the gym map |
|
| 350 | - // |
|
| 351 | - #################################### |
|
| 347 | + #################################### |
|
| 348 | + // |
|
| 349 | + // Get datas for the gym map |
|
| 350 | + // |
|
| 351 | + #################################### |
|
| 352 | 352 | |
| 353 | 353 | |
| 354 | - case 'gym_map': |
|
| 355 | - $req = "SELECT gym_id, team_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym"; |
|
| 356 | - $result = $mysqli->query($req); |
|
| 354 | + case 'gym_map': |
|
| 355 | + $req = "SELECT gym_id, team_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned FROM gym"; |
|
| 356 | + $result = $mysqli->query($req); |
|
| 357 | 357 | |
| 358 | - $gyms = []; |
|
| 358 | + $gyms = []; |
|
| 359 | 359 | |
| 360 | - while ($data = $result->fetch_object()) { |
|
| 361 | - // Team |
|
| 362 | - // 1 = bleu |
|
| 363 | - // 2 = rouge |
|
| 364 | - // 3 = jaune |
|
| 360 | + while ($data = $result->fetch_object()) { |
|
| 361 | + // Team |
|
| 362 | + // 1 = bleu |
|
| 363 | + // 2 = rouge |
|
| 364 | + // 3 = jaune |
|
| 365 | 365 | |
| 366 | - switch ($data->team_id) { |
|
| 366 | + switch ($data->team_id) { |
|
| 367 | 367 | case 0: |
| 368 | 368 | $icon = 'map_white.png'; |
| 369 | 369 | $team = 'No Team (yet)'; |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $team = 'Team Instinct'; |
| 388 | 388 | $color = 'rgba(254, 217, 40, .6)'; |
| 389 | 389 | break; |
| 390 | - } |
|
| 390 | + } |
|
| 391 | 391 | |
| 392 | 392 | // Set gym level |
| 393 | 393 | $gym_level = gym_level($data->gym_points); |
@@ -416,50 +416,50 @@ discard block |
||
| 416 | 416 | // |
| 417 | 417 | #################################### |
| 418 | 418 | |
| 419 | - case 'gym_defenders': |
|
| 420 | - $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 421 | - $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gym.gym_points AS points, gymdetails.url AS url, gym.team_id AS team, |
|
| 419 | + case 'gym_defenders': |
|
| 420 | + $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 421 | + $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gym.gym_points AS points, gymdetails.url AS url, gym.team_id AS team, |
|
| 422 | 422 | (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id |
| 423 | 423 | FROM gymdetails |
| 424 | 424 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
| 425 | 425 | WHERE gym.gym_id='".$gym_id."'"; |
| 426 | - $result = $mysqli->query($req); |
|
| 426 | + $result = $mysqli->query($req); |
|
| 427 | 427 | |
| 428 | - $gymData['gymDetails']['gymInfos'] = false; |
|
| 428 | + $gymData['gymDetails']['gymInfos'] = false; |
|
| 429 | 429 | |
| 430 | - while ($data = $result->fetch_object()) { |
|
| 431 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 432 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 433 | - if ($data->url == null) { |
|
| 434 | - $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 435 | - } else { |
|
| 436 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 430 | + while ($data = $result->fetch_object()) { |
|
| 431 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 432 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 433 | + if ($data->url == null) { |
|
| 434 | + $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 435 | + } else { |
|
| 436 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 437 | + } |
|
| 438 | + $gymData['gymDetails']['gymInfos']['points'] = $data->points; |
|
| 439 | + $gymData['gymDetails']['gymInfos']['level'] = 0; |
|
| 440 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 441 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 442 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 443 | + $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points); |
|
| 437 | 444 | } |
| 438 | - $gymData['gymDetails']['gymInfos']['points'] = $data->points; |
|
| 439 | - $gymData['gymDetails']['gymInfos']['level'] = 0; |
|
| 440 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 441 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 442 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 443 | - $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points); |
|
| 444 | - } |
|
| 445 | 445 | |
| 446 | - $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 446 | + $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 447 | 447 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 448 | 448 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
| 449 | 449 | HAVING gymmember.gym_id='".$gym_id."' |
| 450 | 450 | ORDER BY cp DESC"; |
| 451 | - $result = $mysqli->query($req); |
|
| 451 | + $result = $mysqli->query($req); |
|
| 452 | 452 | |
| 453 | - $i = 0; |
|
| 453 | + $i = 0; |
|
| 454 | 454 | |
| 455 | - $gymData['infoWindow'] = ' |
|
| 455 | + $gymData['infoWindow'] = ' |
|
| 456 | 456 | <div class="gym_defenders"> |
| 457 | 457 | '; |
| 458 | - while ($data = $result->fetch_object()) { |
|
| 459 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
| 460 | - if ($data != false) { |
|
| 461 | - if ($config->system->iv_numbers) { |
|
| 462 | - $gymData['infoWindow'] .= ' |
|
| 458 | + while ($data = $result->fetch_object()) { |
|
| 459 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
| 460 | + if ($data != false) { |
|
| 461 | + if ($config->system->iv_numbers) { |
|
| 462 | + $gymData['infoWindow'] .= ' |
|
| 463 | 463 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 464 | 464 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 465 | 465 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -477,8 +477,8 @@ discard block |
||
| 477 | 477 | </div> |
| 478 | 478 | </div> |
| 479 | 479 | </div>'; |
| 480 | - } else { |
|
| 481 | - $gymData['infoWindow'] .= ' |
|
| 480 | + } else { |
|
| 481 | + $gymData['infoWindow'] .= ' |
|
| 482 | 482 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 483 | 483 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 484 | 484 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -496,76 +496,76 @@ discard block |
||
| 496 | 496 | </div> |
| 497 | 497 | </div> |
| 498 | 498 | </div>' |
| 499 | - ; } |
|
| 500 | - } else { |
|
| 501 | - $gymData['infoWindow'] .= ' |
|
| 499 | + ; } |
|
| 500 | + } else { |
|
| 501 | + $gymData['infoWindow'] .= ' |
|
| 502 | 502 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 503 | 503 | <a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'"> |
| 504 | 504 | <img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 505 | 505 | </a> |
| 506 | 506 | <p class="pkmn-name">???</p> |
| 507 | 507 | </div>' |
| 508 | - ; |
|
| 508 | + ; |
|
| 509 | + } |
|
| 510 | + $i++; |
|
| 509 | 511 | } |
| 510 | - $i++; |
|
| 511 | - } |
|
| 512 | 512 | |
| 513 | - // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 514 | - if (!$gymData['gymDetails']['gymInfos']) { |
|
| 515 | - $req = "SELECT gym_id, team_id, gym_points, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned |
|
| 513 | + // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 514 | + if (!$gymData['gymDetails']['gymInfos']) { |
|
| 515 | + $req = "SELECT gym_id, team_id, gym_points, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned |
|
| 516 | 516 | FROM gym WHERE gym_id='".$gym_id."'"; |
| 517 | - $result = $mysqli->query($req); |
|
| 518 | - $data = $result->fetch_object(); |
|
| 519 | - |
|
| 520 | - $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 521 | - $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 522 | - $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 523 | - $gymData['gymDetails']['gymInfos']['points'] = $data->gym_points; |
|
| 524 | - $gymData['gymDetails']['gymInfos']['level'] = 0; |
|
| 525 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 526 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team_id; |
|
| 527 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 528 | - $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->gym_points); |
|
| 529 | - |
|
| 530 | - $gymData['infoWindow'] .= ' |
|
| 517 | + $result = $mysqli->query($req); |
|
| 518 | + $data = $result->fetch_object(); |
|
| 519 | + |
|
| 520 | + $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 521 | + $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 522 | + $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 523 | + $gymData['gymDetails']['gymInfos']['points'] = $data->gym_points; |
|
| 524 | + $gymData['gymDetails']['gymInfos']['level'] = 0; |
|
| 525 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 526 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team_id; |
|
| 527 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 528 | + $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->gym_points); |
|
| 529 | + |
|
| 530 | + $gymData['infoWindow'] .= ' |
|
| 531 | 531 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 532 | 532 | <a href="pokemon/'.$data->guard_pokemon_id.'"> |
| 533 | 533 | <img src="core/pokemons/'.$data->guard_pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 534 | 534 | </a> |
| 535 | 535 | <p class="pkmn-name">???</p> |
| 536 | 536 | </div>'; |
| 537 | - } |
|
| 538 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 537 | + } |
|
| 538 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 539 | 539 | |
| 540 | - header('Content-Type: application/json'); |
|
| 541 | - echo json_encode($gymData); |
|
| 540 | + header('Content-Type: application/json'); |
|
| 541 | + echo json_encode($gymData); |
|
| 542 | 542 | |
| 543 | - break; |
|
| 543 | + break; |
|
| 544 | 544 | |
| 545 | 545 | |
| 546 | - case 'trainer': |
|
| 547 | - $name = ""; |
|
| 548 | - $page = "0"; |
|
| 549 | - $where = ""; |
|
| 550 | - $order=""; |
|
| 551 | - $team=0; |
|
| 552 | - $ranking=0; |
|
| 553 | - if (isset($_GET['name'])) { |
|
| 554 | - $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 555 | - $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 556 | - } |
|
| 557 | - if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 558 | - $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 559 | - $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 560 | - } |
|
| 561 | - if (isset($_GET['page'])) { |
|
| 562 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 563 | - } |
|
| 564 | - if (isset($_GET['ranking'])) { |
|
| 565 | - $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 566 | - } |
|
| 546 | + case 'trainer': |
|
| 547 | + $name = ""; |
|
| 548 | + $page = "0"; |
|
| 549 | + $where = ""; |
|
| 550 | + $order=""; |
|
| 551 | + $team=0; |
|
| 552 | + $ranking=0; |
|
| 553 | + if (isset($_GET['name'])) { |
|
| 554 | + $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 555 | + $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 556 | + } |
|
| 557 | + if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 558 | + $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 559 | + $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 560 | + } |
|
| 561 | + if (isset($_GET['page'])) { |
|
| 562 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 563 | + } |
|
| 564 | + if (isset($_GET['ranking'])) { |
|
| 565 | + $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 566 | + } |
|
| 567 | 567 | |
| 568 | - switch ($ranking) { |
|
| 568 | + switch ($ranking) { |
|
| 569 | 569 | case 1: |
| 570 | 570 | $order=" ORDER BY active DESC "; |
| 571 | 571 | break; |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | break; |
| 575 | 575 | default: |
| 576 | 576 | $order=" ORDER BY level DESC, active DESC "; |
| 577 | - } |
|
| 577 | + } |
|
| 578 | 578 | |
| 579 | 579 | $limit = " LIMIT ".($page*10).",10 "; |
| 580 | 580 | |
@@ -646,85 +646,85 @@ discard block |
||
| 646 | 646 | break; |
| 647 | 647 | |
| 648 | 648 | |
| 649 | - case 'pokemon_slider_init': |
|
| 650 | - $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 651 | - $result = $mysqli->query($req); |
|
| 652 | - $bounds = $result->fetch_object(); |
|
| 649 | + case 'pokemon_slider_init': |
|
| 650 | + $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 651 | + $result = $mysqli->query($req); |
|
| 652 | + $bounds = $result->fetch_object(); |
|
| 653 | + |
|
| 654 | + header('Content-Type: application/json'); |
|
| 655 | + echo json_encode($bounds); |
|
| 653 | 656 | |
| 654 | - header('Content-Type: application/json'); |
|
| 655 | - echo json_encode($bounds); |
|
| 657 | + break; |
|
| 656 | 658 | |
| 657 | - break; |
|
| 658 | 659 | |
| 660 | + case 'pokemon_heatmap_points': |
|
| 661 | + $json=""; |
|
| 662 | + if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 663 | + $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 664 | + $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 665 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 666 | + $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 667 | + . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 668 | + $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 669 | + $result = $mysqli->query($req); |
|
| 670 | + $points = array(); |
|
| 671 | + while ($result && $data = $result->fetch_object()) { |
|
| 672 | + $points[] = $data; |
|
| 673 | + } |
|
| 659 | 674 | |
| 660 | - case 'pokemon_heatmap_points': |
|
| 661 | - $json=""; |
|
| 662 | - if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 663 | - $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 664 | - $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 665 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 666 | - $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 667 | - . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 668 | - $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 669 | - $result = $mysqli->query($req); |
|
| 670 | - $points = array(); |
|
| 671 | - while ($result && $data = $result->fetch_object()) { |
|
| 672 | - $points[] = $data; |
|
| 675 | + $json = json_encode($points); |
|
| 673 | 676 | } |
| 674 | 677 | |
| 675 | - $json = json_encode($points); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - header('Content-Type: application/json'); |
|
| 679 | - echo $json; |
|
| 680 | - break; |
|
| 678 | + header('Content-Type: application/json'); |
|
| 679 | + echo $json; |
|
| 680 | + break; |
|
| 681 | 681 | |
| 682 | 682 | |
| 683 | - case 'maps_localization_coordinates': |
|
| 684 | - $json=""; |
|
| 685 | - $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 686 | - $result = $mysqli->query($req); |
|
| 687 | - $coordinates = $result->fetch_object(); |
|
| 683 | + case 'maps_localization_coordinates': |
|
| 684 | + $json=""; |
|
| 685 | + $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 686 | + $result = $mysqli->query($req); |
|
| 687 | + $coordinates = $result->fetch_object(); |
|
| 688 | 688 | |
| 689 | - header('Content-Type: application/json'); |
|
| 690 | - echo json_encode($coordinates); |
|
| 689 | + header('Content-Type: application/json'); |
|
| 690 | + echo json_encode($coordinates); |
|
| 691 | 691 | |
| 692 | - break; |
|
| 692 | + break; |
|
| 693 | 693 | |
| 694 | 694 | |
| 695 | - case 'pokemon_graph_data': |
|
| 696 | - $json=""; |
|
| 697 | - if (isset($_GET['pokemon_id'])) { |
|
| 698 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 699 | - $req = "SELECT COUNT(*) AS total, |
|
| 695 | + case 'pokemon_graph_data': |
|
| 696 | + $json=""; |
|
| 697 | + if (isset($_GET['pokemon_id'])) { |
|
| 698 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 699 | + $req = "SELECT COUNT(*) AS total, |
|
| 700 | 700 | HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour |
| 701 | 701 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
| 702 | 702 | GROUP BY disappear_hour |
| 703 | 703 | ORDER BY disappear_hour"; |
| 704 | - $result = $mysqli->query($req); |
|
| 705 | - $array = array_fill(0, 24, 0); |
|
| 706 | - while ($result && $data = $result->fetch_object()) { |
|
| 707 | - $array[$data->disappear_hour] = $data->total; |
|
| 704 | + $result = $mysqli->query($req); |
|
| 705 | + $array = array_fill(0, 24, 0); |
|
| 706 | + while ($result && $data = $result->fetch_object()) { |
|
| 707 | + $array[$data->disappear_hour] = $data->total; |
|
| 708 | + } |
|
| 709 | + // shift array because AM/PM starts at 1AM not 0:00 |
|
| 710 | + $array[] = $array[0]; |
|
| 711 | + array_shift($array); |
|
| 712 | + |
|
| 713 | + $json = json_encode($array); |
|
| 708 | 714 | } |
| 709 | - // shift array because AM/PM starts at 1AM not 0:00 |
|
| 710 | - $array[] = $array[0]; |
|
| 711 | - array_shift($array); |
|
| 712 | 715 | |
| 713 | - $json = json_encode($array); |
|
| 714 | - } |
|
| 716 | + header('Content-Type: application/json'); |
|
| 717 | + echo $json; |
|
| 718 | + break; |
|
| 715 | 719 | |
| 716 | - header('Content-Type: application/json'); |
|
| 717 | - echo $json; |
|
| 718 | - break; |
|
| 719 | 720 | |
| 721 | + case 'postRequest': |
|
| 722 | + break; |
|
| 720 | 723 | |
| 721 | - case 'postRequest': |
|
| 724 | + default: |
|
| 725 | + echo "What do you mean?"; |
|
| 726 | + exit(); |
|
| 722 | 727 | break; |
| 723 | - |
|
| 724 | - default: |
|
| 725 | - echo "What do you mean?"; |
|
| 726 | - exit(); |
|
| 727 | - break; |
|
| 728 | 728 | } |
| 729 | 729 | |
| 730 | 730 | if ($postRequest!="") { |