@@ -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 | - $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->cp = $data->cp; |
|
| 187 | - $iv->attack = $data->individual_attack; |
|
| 188 | - $iv->defense = $data->individual_defense; |
|
| 189 | - $iv->stamina = $data->individual_stamina; |
|
| 190 | - if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) { |
|
| 191 | - $iv->available = true; |
|
| 192 | - } else { |
|
| 193 | - $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->cp = $data->cp; |
|
| 187 | + $iv->attack = $data->individual_attack; |
|
| 188 | + $iv->defense = $data->individual_defense; |
|
| 189 | + $iv->stamina = $data->individual_stamina; |
|
| 190 | + if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) { |
|
| 191 | + $iv->available = true; |
|
| 192 | + } else { |
|
| 193 | + $iv->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="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" 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="https://maps.google.com/?q='.$last_location->latitude.','.$last_location->longitude.'&ll='.$last_location->latitude.','.$last_location->longitude.'&z=16" target="_blank"> |
| 202 | 202 | <small class="pokemon-timer">00:00:00</small> |
| 203 | 203 | </a>'; |
| 204 | - if ($config->system->recents_show_iv) { |
|
| 205 | - if ($iv->available) { |
|
| 206 | - if ($config->system->iv_numbers) { |
|
| 207 | - $html .= ' |
|
| 204 | + if ($config->system->recents_show_iv) { |
|
| 205 | + if ($iv->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.': '.$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"> |
| 210 | 210 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .' |
@@ -216,8 +216,8 @@ discard block |
||
| 216 | 216 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->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.': '.$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).'%"> |
| 223 | 223 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span> |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span> |
| 230 | 230 | </div> |
| 231 | 231 | </div>'; |
| 232 | - } |
|
| 233 | - $html .= '<small>'.$iv->cp.'</small>'; |
|
| 234 | - } else { |
|
| 235 | - if ($config->system->iv_numbers) { |
|
| 236 | - $html .= ' |
|
| 232 | + } |
|
| 233 | + $html .= '<small>'.$iv->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="'.$iv->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,127 +245,127 @@ 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 | - if ($config->system->only_lured_pokestops) { |
|
| 286 | - $where = "WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration"; |
|
| 287 | - } |
|
| 288 | - $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.""; |
|
| 283 | + case 'pokestop': |
|
| 284 | + $where = ""; |
|
| 285 | + if ($config->system->only_lured_pokestops) { |
|
| 286 | + $where = "WHERE lure_expiration > UTC_TIMESTAMP() ORDER BY lure_expiration"; |
|
| 287 | + } |
|
| 288 | + $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.""; |
|
| 289 | 289 | |
| 290 | - //show all stops if no lure active |
|
| 291 | - if (!$mysqli->query($req)->fetch_object()) { |
|
| 292 | - $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop"; |
|
| 293 | - } |
|
| 294 | - $result = $mysqli->query($req); |
|
| 290 | + //show all stops if no lure active |
|
| 291 | + if (!$mysqli->query($req)->fetch_object()) { |
|
| 292 | + $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() AS now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) AS lure_expiration_real FROM pokestop"; |
|
| 293 | + } |
|
| 294 | + $result = $mysqli->query($req); |
|
| 295 | 295 | |
| 296 | - $pokestops = []; |
|
| 296 | + $pokestops = []; |
|
| 297 | 297 | |
| 298 | - while ($data = $result->fetch_object()) { |
|
| 299 | - if ($data->lure_expiration >= $data->now) { |
|
| 300 | - $icon = 'pokestap_lured.png'; |
|
| 301 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 302 | - } else { |
|
| 303 | - $icon = 'pokestap.png'; |
|
| 304 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 298 | + while ($data = $result->fetch_object()) { |
|
| 299 | + if ($data->lure_expiration >= $data->now) { |
|
| 300 | + $icon = 'pokestap_lured.png'; |
|
| 301 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 302 | + } else { |
|
| 303 | + $icon = 'pokestap.png'; |
|
| 304 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 305 | + } |
|
| 306 | + |
|
| 307 | + $pokestops[] = [ |
|
| 308 | + $text, |
|
| 309 | + $icon, |
|
| 310 | + $data->latitude, |
|
| 311 | + $data->longitude |
|
| 312 | + ]; |
|
| 305 | 313 | } |
| 306 | 314 | |
| 307 | - $pokestops[] = [ |
|
| 308 | - $text, |
|
| 309 | - $icon, |
|
| 310 | - $data->latitude, |
|
| 311 | - $data->longitude |
|
| 312 | - ]; |
|
| 313 | - } |
|
| 315 | + header('Content-Type: application/json'); |
|
| 316 | + echo json_encode($pokestops); |
|
| 314 | 317 | |
| 315 | - header('Content-Type: application/json'); |
|
| 316 | - echo json_encode($pokestops); |
|
| 318 | + break; |
|
| 317 | 319 | |
| 318 | - break; |
|
| 319 | 320 | |
| 321 | + #################################### |
|
| 322 | + // |
|
| 323 | + // Update data for the gym battle |
|
| 324 | + // |
|
| 325 | + #################################### |
|
| 320 | 326 | |
| 321 | - #################################### |
|
| 322 | - // |
|
| 323 | - // Update data for the gym battle |
|
| 324 | - // |
|
| 325 | - #################################### |
|
| 327 | + case 'update_gym': |
|
| 328 | + $teams = new stdClass(); |
|
| 329 | + $teams->mystic = 1; |
|
| 330 | + $teams->valor = 2; |
|
| 331 | + $teams->instinct = 3; |
|
| 326 | 332 | |
| 327 | - case 'update_gym': |
|
| 328 | - $teams = new stdClass(); |
|
| 329 | - $teams->mystic = 1; |
|
| 330 | - $teams->valor = 2; |
|
| 331 | - $teams->instinct = 3; |
|
| 332 | 333 | |
| 334 | + foreach ($teams as $team_name => $team_id) { |
|
| 335 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm JOIN gym ON gm.gym_id=gym.gym_id WHERE team_id = '".$team_id."') AS members FROM gym WHERE team_id = '".$team_id."'"; |
|
| 336 | + $result = $mysqli->query($req); |
|
| 337 | + $data = $result->fetch_object(); |
|
| 333 | 338 | |
| 334 | - foreach ($teams as $team_name => $team_id) { |
|
| 335 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm JOIN gym ON gm.gym_id=gym.gym_id WHERE team_id = '".$team_id."') AS members FROM gym WHERE team_id = '".$team_id."'"; |
|
| 336 | - $result = $mysqli->query($req); |
|
| 337 | - $data = $result->fetch_object(); |
|
| 339 | + $return[] = $data->total; |
|
| 340 | + $return[] = round($data->members / $data->total); |
|
| 341 | + } |
|
| 338 | 342 | |
| 339 | - $return[] = $data->total; |
|
| 340 | - $return[] = round($data->members / $data->total); |
|
| 341 | - } |
|
| 343 | + header('Content-Type: application/json'); |
|
| 344 | + echo json_encode($return); |
|
| 342 | 345 | |
| 343 | - header('Content-Type: application/json'); |
|
| 344 | - echo json_encode($return); |
|
| 346 | + break; |
|
| 345 | 347 | |
| 346 | - break; |
|
| 347 | 348 | |
| 349 | + #################################### |
|
| 350 | + // |
|
| 351 | + // Get datas for the gym map |
|
| 352 | + // |
|
| 353 | + #################################### |
|
| 348 | 354 | |
| 349 | - #################################### |
|
| 350 | - // |
|
| 351 | - // Get datas for the gym map |
|
| 352 | - // |
|
| 353 | - #################################### |
|
| 354 | 355 | |
| 356 | + case 'gym_map': |
|
| 357 | + $req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level FROM gym"; |
|
| 358 | + $result = $mysqli->query($req); |
|
| 355 | 359 | |
| 356 | - case 'gym_map': |
|
| 357 | - $req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level FROM gym"; |
|
| 358 | - $result = $mysqli->query($req); |
|
| 360 | + $gyms = []; |
|
| 359 | 361 | |
| 360 | - $gyms = []; |
|
| 362 | + while ($data = $result->fetch_object()) { |
|
| 363 | + // Team |
|
| 364 | + // 1 = bleu |
|
| 365 | + // 2 = rouge |
|
| 366 | + // 3 = jaune |
|
| 361 | 367 | |
| 362 | - while ($data = $result->fetch_object()) { |
|
| 363 | - // Team |
|
| 364 | - // 1 = bleu |
|
| 365 | - // 2 = rouge |
|
| 366 | - // 3 = jaune |
|
| 367 | - |
|
| 368 | - switch ($data->team_id) { |
|
| 368 | + switch ($data->team_id) { |
|
| 369 | 369 | case 0: |
| 370 | 370 | $icon = 'map_white.png'; |
| 371 | 371 | $team = 'No Team (yet)'; |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | $team = 'Team Instinct'; |
| 390 | 390 | $color = 'rgba(254, 217, 40, .6)'; |
| 391 | 391 | break; |
| 392 | - } |
|
| 392 | + } |
|
| 393 | 393 | |
| 394 | 394 | // Set gym level |
| 395 | 395 | $gym_level = $data->gym_level; |
@@ -418,49 +418,49 @@ discard block |
||
| 418 | 418 | // |
| 419 | 419 | #################################### |
| 420 | 420 | |
| 421 | - case 'gym_defenders': |
|
| 422 | - $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 423 | - $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 421 | + case 'gym_defenders': |
|
| 422 | + $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 423 | + $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 424 | 424 | (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level |
| 425 | 425 | FROM gymdetails |
| 426 | 426 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
| 427 | 427 | WHERE gym.gym_id='".$gym_id."'"; |
| 428 | - $result = $mysqli->query($req); |
|
| 428 | + $result = $mysqli->query($req); |
|
| 429 | 429 | |
| 430 | - $gymData['gymDetails']['gymInfos'] = false; |
|
| 430 | + $gymData['gymDetails']['gymInfos'] = false; |
|
| 431 | 431 | |
| 432 | - while ($data = $result->fetch_object()) { |
|
| 433 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 434 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 435 | - if ($data->url == null) { |
|
| 436 | - $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 437 | - } else { |
|
| 438 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 432 | + while ($data = $result->fetch_object()) { |
|
| 433 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 434 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 435 | + if ($data->url == null) { |
|
| 436 | + $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 437 | + } else { |
|
| 438 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 439 | + } |
|
| 440 | + $gymData['gymDetails']['gymInfos']['level'] = $data->gym_level; |
|
| 441 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 442 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 443 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 444 | + $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points); |
|
| 439 | 445 | } |
| 440 | - $gymData['gymDetails']['gymInfos']['level'] = $data->gym_level; |
|
| 441 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 442 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 443 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 444 | - $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points); |
|
| 445 | - } |
|
| 446 | 446 | |
| 447 | - $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 447 | + $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 448 | 448 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 449 | 449 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
| 450 | 450 | HAVING gymmember.gym_id='".$gym_id."' |
| 451 | 451 | ORDER BY cp DESC"; |
| 452 | - $result = $mysqli->query($req); |
|
| 452 | + $result = $mysqli->query($req); |
|
| 453 | 453 | |
| 454 | - $i = 0; |
|
| 454 | + $i = 0; |
|
| 455 | 455 | |
| 456 | - $gymData['infoWindow'] = ' |
|
| 456 | + $gymData['infoWindow'] = ' |
|
| 457 | 457 | <div class="gym_defenders"> |
| 458 | 458 | '; |
| 459 | - while ($data = $result->fetch_object()) { |
|
| 460 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
| 461 | - if ($data != false) { |
|
| 462 | - if ($config->system->iv_numbers) { |
|
| 463 | - $gymData['infoWindow'] .= ' |
|
| 459 | + while ($data = $result->fetch_object()) { |
|
| 460 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
| 461 | + if ($data != false) { |
|
| 462 | + if ($config->system->iv_numbers) { |
|
| 463 | + $gymData['infoWindow'] .= ' |
|
| 464 | 464 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 465 | 465 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 466 | 466 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -478,8 +478,8 @@ discard block |
||
| 478 | 478 | </div> |
| 479 | 479 | </div> |
| 480 | 480 | </div>'; |
| 481 | - } else { |
|
| 482 | - $gymData['infoWindow'] .= ' |
|
| 481 | + } else { |
|
| 482 | + $gymData['infoWindow'] .= ' |
|
| 483 | 483 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 484 | 484 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 485 | 485 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -497,74 +497,74 @@ discard block |
||
| 497 | 497 | </div> |
| 498 | 498 | </div> |
| 499 | 499 | </div>' |
| 500 | - ; } |
|
| 501 | - } else { |
|
| 502 | - $gymData['infoWindow'] .= ' |
|
| 500 | + ; } |
|
| 501 | + } else { |
|
| 502 | + $gymData['infoWindow'] .= ' |
|
| 503 | 503 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 504 | 504 | <a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'"> |
| 505 | 505 | <img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 506 | 506 | </a> |
| 507 | 507 | <p class="pkmn-name">???</p> |
| 508 | 508 | </div>' |
| 509 | - ; |
|
| 509 | + ; |
|
| 510 | + } |
|
| 511 | + $i++; |
|
| 510 | 512 | } |
| 511 | - $i++; |
|
| 512 | - } |
|
| 513 | 513 | |
| 514 | - // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 515 | - if (!$gymData['gymDetails']['gymInfos']) { |
|
| 516 | - $req = "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level |
|
| 514 | + // check whether we could retrieve gym infos, otherwise use basic gym info |
|
| 515 | + if (!$gymData['gymDetails']['gymInfos']) { |
|
| 516 | + $req = "SELECT gym_id, team_id, guard_pokemon_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level |
|
| 517 | 517 | FROM gym WHERE gym_id='".$gym_id."'"; |
| 518 | - $result = $mysqli->query($req); |
|
| 519 | - $data = $result->fetch_object(); |
|
| 518 | + $result = $mysqli->query($req); |
|
| 519 | + $data = $result->fetch_object(); |
|
| 520 | 520 | |
| 521 | - $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 522 | - $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 523 | - $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 524 | - $gymData['gymDetails']['gymInfos']['level'] = $data->gym_level; |
|
| 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; |
|
| 521 | + $gymData['gymDetails']['gymInfos']['name'] = $locales->NOT_AVAILABLE; |
|
| 522 | + $gymData['gymDetails']['gymInfos']['description'] = $locales->NOT_AVAILABLE; |
|
| 523 | + $gymData['gymDetails']['gymInfos']['url'] = 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Solid_grey.svg/200px-Solid_grey.svg.png'; |
|
| 524 | + $gymData['gymDetails']['gymInfos']['level'] = $data->gym_level; |
|
| 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 | 528 | |
| 529 | - $gymData['infoWindow'] .= ' |
|
| 529 | + $gymData['infoWindow'] .= ' |
|
| 530 | 530 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 531 | 531 | <a href="pokemon/'.$data->guard_pokemon_id.'"> |
| 532 | 532 | <img src="core/pokemons/'.$data->guard_pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 533 | 533 | </a> |
| 534 | 534 | <p class="pkmn-name">???</p> |
| 535 | 535 | </div>'; |
| 536 | - } |
|
| 537 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 536 | + } |
|
| 537 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 538 | 538 | |
| 539 | - header('Content-Type: application/json'); |
|
| 540 | - echo json_encode($gymData); |
|
| 539 | + header('Content-Type: application/json'); |
|
| 540 | + echo json_encode($gymData); |
|
| 541 | 541 | |
| 542 | - break; |
|
| 542 | + break; |
|
| 543 | 543 | |
| 544 | 544 | |
| 545 | - case 'trainer': |
|
| 546 | - $name = ""; |
|
| 547 | - $page = "0"; |
|
| 548 | - $where = ""; |
|
| 549 | - $order=""; |
|
| 550 | - $team=0; |
|
| 551 | - $ranking=0; |
|
| 552 | - if (isset($_GET['name'])) { |
|
| 553 | - $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 554 | - $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 555 | - } |
|
| 556 | - if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 557 | - $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 558 | - $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 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 | - } |
|
| 545 | + case 'trainer': |
|
| 546 | + $name = ""; |
|
| 547 | + $page = "0"; |
|
| 548 | + $where = ""; |
|
| 549 | + $order=""; |
|
| 550 | + $team=0; |
|
| 551 | + $ranking=0; |
|
| 552 | + if (isset($_GET['name'])) { |
|
| 553 | + $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 554 | + $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 555 | + } |
|
| 556 | + if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 557 | + $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 558 | + $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 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 "; |
| 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 | $limit = " LIMIT ".($page*10).",10 "; |
| 579 | 579 | |
@@ -645,129 +645,129 @@ discard block |
||
| 645 | 645 | break; |
| 646 | 646 | |
| 647 | 647 | |
| 648 | - case 'raids': |
|
| 649 | - $page = "0"; |
|
| 650 | - if (isset($_GET['page'])) { |
|
| 651 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 652 | - } |
|
| 648 | + case 'raids': |
|
| 649 | + $page = "0"; |
|
| 650 | + if (isset($_GET['page'])) { |
|
| 651 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | - $limit = " LIMIT ".($page*10).",10"; |
|
| 654 | + $limit = " LIMIT ".($page*10).",10"; |
|
| 655 | 655 | |
| 656 | - $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 |
|
| 656 | + $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 |
|
| 657 | 657 | JOIN gymdetails ON gymdetails.gym_id = raid.gym_id |
| 658 | 658 | JOIN gym ON gym.gym_id = raid.gym_id |
| 659 | 659 | WHERE raid.end > UTC_TIMESTAMP() |
| 660 | 660 | ORDER BY raid.level DESC, raid.start".$limit; |
| 661 | 661 | |
| 662 | - $result = $mysqli->query($req); |
|
| 663 | - $raids = array(); |
|
| 664 | - while ($data = $result->fetch_object()) { |
|
| 665 | - $data->starttime = date("H:i", strtotime($data->start)); |
|
| 666 | - $data->endtime = date("H:i", strtotime($data->end)); |
|
| 667 | - $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 668 | - if (isset($data->move_1)) { |
|
| 669 | - $move1 = $data->move_1; |
|
| 670 | - $data->quick_move = $move->$move1->name; |
|
| 671 | - } else { |
|
| 672 | - $data->quick_move = "?"; |
|
| 673 | - } |
|
| 674 | - if (isset($data->move_2)) { |
|
| 675 | - $move2 = $data->move_2; |
|
| 676 | - $data->charge_move = $move->$move2->name; |
|
| 677 | - } else { |
|
| 678 | - $data->charge_move = "?"; |
|
| 662 | + $result = $mysqli->query($req); |
|
| 663 | + $raids = array(); |
|
| 664 | + while ($data = $result->fetch_object()) { |
|
| 665 | + $data->starttime = date("H:i", strtotime($data->start)); |
|
| 666 | + $data->endtime = date("H:i", strtotime($data->end)); |
|
| 667 | + $data->gym_id = str_replace('.', '_', $data->gym_id); |
|
| 668 | + if (isset($data->move_1)) { |
|
| 669 | + $move1 = $data->move_1; |
|
| 670 | + $data->quick_move = $move->$move1->name; |
|
| 671 | + } else { |
|
| 672 | + $data->quick_move = "?"; |
|
| 673 | + } |
|
| 674 | + if (isset($data->move_2)) { |
|
| 675 | + $move2 = $data->move_2; |
|
| 676 | + $data->charge_move = $move->$move2->name; |
|
| 677 | + } else { |
|
| 678 | + $data->charge_move = "?"; |
|
| 679 | + } |
|
| 680 | + $raids[$data->gym_id] = $data; |
|
| 679 | 681 | } |
| 680 | - $raids[$data->gym_id] = $data; |
|
| 681 | - } |
|
| 682 | - $json = array(); |
|
| 683 | - $json['raids'] = $raids; |
|
| 684 | - $locale = array(); |
|
| 685 | - $json['locale'] = $locale; |
|
| 682 | + $json = array(); |
|
| 683 | + $json['raids'] = $raids; |
|
| 684 | + $locale = array(); |
|
| 685 | + $json['locale'] = $locale; |
|
| 686 | 686 | |
| 687 | - header('Content-Type: application/json'); |
|
| 688 | - echo json_encode($json); |
|
| 687 | + header('Content-Type: application/json'); |
|
| 688 | + echo json_encode($json); |
|
| 689 | 689 | |
| 690 | - break; |
|
| 690 | + break; |
|
| 691 | 691 | |
| 692 | - case 'pokemon_slider_init': |
|
| 693 | - $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 694 | - $result = $mysqli->query($req); |
|
| 695 | - $bounds = $result->fetch_object(); |
|
| 692 | + case 'pokemon_slider_init': |
|
| 693 | + $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 694 | + $result = $mysqli->query($req); |
|
| 695 | + $bounds = $result->fetch_object(); |
|
| 696 | 696 | |
| 697 | - header('Content-Type: application/json'); |
|
| 698 | - echo json_encode($bounds); |
|
| 697 | + header('Content-Type: application/json'); |
|
| 698 | + echo json_encode($bounds); |
|
| 699 | 699 | |
| 700 | - break; |
|
| 700 | + break; |
|
| 701 | 701 | |
| 702 | 702 | |
| 703 | - case 'pokemon_heatmap_points': |
|
| 704 | - $json=""; |
|
| 705 | - if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 706 | - $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 707 | - $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 708 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 709 | - $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 710 | - . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 711 | - $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 712 | - $result = $mysqli->query($req); |
|
| 713 | - $points = array(); |
|
| 714 | - while ($result && $data = $result->fetch_object()) { |
|
| 715 | - $points[] = $data; |
|
| 716 | - } |
|
| 703 | + case 'pokemon_heatmap_points': |
|
| 704 | + $json=""; |
|
| 705 | + if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 706 | + $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 707 | + $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 708 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 709 | + $where = " WHERE pokemon_id = ".$pokemon_id." " |
|
| 710 | + . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 711 | + $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 712 | + $result = $mysqli->query($req); |
|
| 713 | + $points = array(); |
|
| 714 | + while ($result && $data = $result->fetch_object()) { |
|
| 715 | + $points[] = $data; |
|
| 716 | + } |
|
| 717 | 717 | |
| 718 | - $json = json_encode($points); |
|
| 719 | - } |
|
| 718 | + $json = json_encode($points); |
|
| 719 | + } |
|
| 720 | 720 | |
| 721 | - header('Content-Type: application/json'); |
|
| 722 | - echo $json; |
|
| 723 | - break; |
|
| 721 | + header('Content-Type: application/json'); |
|
| 722 | + echo $json; |
|
| 723 | + break; |
|
| 724 | 724 | |
| 725 | 725 | |
| 726 | - case 'maps_localization_coordinates': |
|
| 727 | - $json=""; |
|
| 728 | - $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 729 | - $result = $mysqli->query($req); |
|
| 730 | - $coordinates = $result->fetch_object(); |
|
| 726 | + case 'maps_localization_coordinates': |
|
| 727 | + $json=""; |
|
| 728 | + $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 729 | + $result = $mysqli->query($req); |
|
| 730 | + $coordinates = $result->fetch_object(); |
|
| 731 | 731 | |
| 732 | - header('Content-Type: application/json'); |
|
| 733 | - echo json_encode($coordinates); |
|
| 732 | + header('Content-Type: application/json'); |
|
| 733 | + echo json_encode($coordinates); |
|
| 734 | 734 | |
| 735 | - break; |
|
| 735 | + break; |
|
| 736 | 736 | |
| 737 | 737 | |
| 738 | - case 'pokemon_graph_data': |
|
| 739 | - $json=""; |
|
| 740 | - if (isset($_GET['pokemon_id'])) { |
|
| 741 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 742 | - $req = "SELECT COUNT(*) AS total, |
|
| 738 | + case 'pokemon_graph_data': |
|
| 739 | + $json=""; |
|
| 740 | + if (isset($_GET['pokemon_id'])) { |
|
| 741 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 742 | + $req = "SELECT COUNT(*) AS total, |
|
| 743 | 743 | HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) AS disappear_hour |
| 744 | 744 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
| 745 | 745 | GROUP BY disappear_hour |
| 746 | 746 | ORDER BY disappear_hour"; |
| 747 | - $result = $mysqli->query($req); |
|
| 748 | - $array = array_fill(0, 24, 0); |
|
| 749 | - while ($result && $data = $result->fetch_object()) { |
|
| 750 | - $array[$data->disappear_hour] = $data->total; |
|
| 747 | + $result = $mysqli->query($req); |
|
| 748 | + $array = array_fill(0, 24, 0); |
|
| 749 | + while ($result && $data = $result->fetch_object()) { |
|
| 750 | + $array[$data->disappear_hour] = $data->total; |
|
| 751 | + } |
|
| 752 | + // shift array because AM/PM starts at 1AM not 0:00 |
|
| 753 | + $array[] = $array[0]; |
|
| 754 | + array_shift($array); |
|
| 755 | + |
|
| 756 | + $json = json_encode($array); |
|
| 751 | 757 | } |
| 752 | - // shift array because AM/PM starts at 1AM not 0:00 |
|
| 753 | - $array[] = $array[0]; |
|
| 754 | - array_shift($array); |
|
| 755 | 758 | |
| 756 | - $json = json_encode($array); |
|
| 757 | - } |
|
| 759 | + header('Content-Type: application/json'); |
|
| 760 | + echo $json; |
|
| 761 | + break; |
|
| 758 | 762 | |
| 759 | - header('Content-Type: application/json'); |
|
| 760 | - echo $json; |
|
| 761 | - break; |
|
| 762 | 763 | |
| 764 | + case 'postRequest': |
|
| 765 | + break; |
|
| 763 | 766 | |
| 764 | - case 'postRequest': |
|
| 767 | + default: |
|
| 768 | + echo "What do you mean?"; |
|
| 769 | + exit(); |
|
| 765 | 770 | break; |
| 766 | - |
|
| 767 | - default: |
|
| 768 | - echo "What do you mean?"; |
|
| 769 | - exit(); |
|
| 770 | - break; |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | if ($postRequest!="") { |
@@ -17,8 +17,8 @@ discard block |
||
| 17 | 17 | // Include & load the variables |
| 18 | 18 | // ############################ |
| 19 | 19 | |
| 20 | -$variables = SYS_PATH.'/core/json/variables.json'; |
|
| 21 | -$config = json_decode(file_get_contents($variables)); |
|
| 20 | +$variables = SYS_PATH.'/core/json/variables.json'; |
|
| 21 | +$config = json_decode(file_get_contents($variables)); |
|
| 22 | 22 | |
| 23 | 23 | // Manage Time Interval |
| 24 | 24 | // ##################### |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | include_once(SYS_PATH.'/functions.php'); |
| 38 | 38 | |
| 39 | 39 | # MySQL |
| 40 | -$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 40 | +$mysqli = new mysqli(SYS_DB_HOST, SYS_DB_USER, SYS_DB_PSWD, SYS_DB_NAME, SYS_DB_PORT); |
|
| 41 | 41 | if ($mysqli->connect_error != '') { |
| 42 | 42 | exit('Error MySQL Connect'); |
| 43 | 43 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $postRequest = ""; |
| 50 | 50 | if (isset($_POST['type'])) { |
| 51 | 51 | $postRequest = $_POST['type']; |
| 52 | - $request= "postRequest"; |
|
| 52 | + $request = "postRequest"; |
|
| 53 | 53 | } |
| 54 | 54 | switch ($request) { |
| 55 | 55 | ############################ |
@@ -62,64 +62,64 @@ discard block |
||
| 62 | 62 | // Right now |
| 63 | 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 | 72 | // Lured stops |
| 73 | 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 | 83 | // Team battle |
| 84 | 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 | 92 | // Team |
| 93 | 93 | // 1 = bleu |
| 94 | 94 | // 2 = rouge |
| 95 | 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 | 101 | // Red |
| 102 | 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 | 109 | // Blue |
| 110 | 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 | 117 | // Yellow |
| 118 | 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 | 124 | // Neutral |
| 125 | 125 | $values[] = $data->total; |
@@ -207,13 +207,13 @@ discard block |
||
| 207 | 207 | $html .= ' |
| 208 | 208 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 209 | 209 | <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"> |
| 210 | - <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .' |
|
| 210 | + <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack.' |
|
| 211 | 211 | </div> |
| 212 | 212 | <div title="'.$locales->IV_DEFENSE.': '.$iv->defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$iv->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
| 213 | - <span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense .' |
|
| 213 | + <span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense.' |
|
| 214 | 214 | </div> |
| 215 | 215 | <div title="'.$locales->IV_STAMINA.': '.$iv->stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$iv->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 16px"> |
| 216 | - <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .' |
|
| 216 | + <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina.' |
|
| 217 | 217 | </div> |
| 218 | 218 | </div>'; |
| 219 | 219 | } else { |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | <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).'%"> |
| 223 | 223 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span> |
| 224 | 224 | </div> |
| 225 | - <div title="'.$locales->IV_DEFENSE.': '.$iv->defense .'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$iv->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->defense) / 3).'%"> |
|
| 225 | + <div title="'.$locales->IV_DEFENSE.': '.$iv->defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$iv->defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->defense) / 3).'%"> |
|
| 226 | 226 | <span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span> |
| 227 | 227 | </div> |
| 228 | - <div title="'.$locales->IV_STAMINA.': '.$iv->stamina .'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$iv->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->stamina) / 3).'%"> |
|
| 228 | + <div title="'.$locales->IV_STAMINA.': '.$iv->stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$iv->stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(((100 / 15) * $iv->stamina) / 3).'%"> |
|
| 229 | 229 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span> |
| 230 | 230 | </div> |
| 231 | 231 | </div>'; |
@@ -325,19 +325,19 @@ discard block |
||
| 325 | 325 | #################################### |
| 326 | 326 | |
| 327 | 327 | case 'update_gym': |
| 328 | - $teams = new stdClass(); |
|
| 329 | - $teams->mystic = 1; |
|
| 330 | - $teams->valor = 2; |
|
| 331 | - $teams->instinct = 3; |
|
| 328 | + $teams = new stdClass(); |
|
| 329 | + $teams->mystic = 1; |
|
| 330 | + $teams->valor = 2; |
|
| 331 | + $teams->instinct = 3; |
|
| 332 | 332 | |
| 333 | 333 | |
| 334 | 334 | foreach ($teams as $team_name => $team_id) { |
| 335 | - $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm JOIN gym ON gm.gym_id=gym.gym_id WHERE team_id = '".$team_id."') AS members FROM gym WHERE team_id = '".$team_id."'"; |
|
| 336 | - $result = $mysqli->query($req); |
|
| 337 | - $data = $result->fetch_object(); |
|
| 335 | + $req = "SELECT COUNT(DISTINCT(gym_id)) AS total, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm JOIN gym ON gm.gym_id=gym.gym_id WHERE team_id = '".$team_id."') AS members FROM gym WHERE team_id = '".$team_id."'"; |
|
| 336 | + $result = $mysqli->query($req); |
|
| 337 | + $data = $result->fetch_object(); |
|
| 338 | 338 | |
| 339 | - $return[] = $data->total; |
|
| 340 | - $return[] = round($data->members / $data->total); |
|
| 339 | + $return[] = $data->total; |
|
| 340 | + $return[] = round($data->members / $data->total); |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | header('Content-Type: application/json'); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | |
| 356 | 356 | case 'gym_map': |
| 357 | - $req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level FROM gym"; |
|
| 357 | + $req = "SELECT gym_id, team_id, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level FROM gym"; |
|
| 358 | 358 | $result = $mysqli->query($req); |
| 359 | 359 | |
| 360 | 360 | $gyms = []; |
@@ -369,25 +369,25 @@ discard block |
||
| 369 | 369 | case 0: |
| 370 | 370 | $icon = 'map_white.png'; |
| 371 | 371 | $team = 'No Team (yet)'; |
| 372 | - $color = 'rgba(0, 0, 0, .6)'; |
|
| 372 | + $color = 'rgba(0, 0, 0, .6)'; |
|
| 373 | 373 | break; |
| 374 | 374 | |
| 375 | 375 | case 1: |
| 376 | 376 | $icon = 'map_blue_'; |
| 377 | 377 | $team = 'Team Mystic'; |
| 378 | - $color = 'rgba(74, 138, 202, .6)'; |
|
| 378 | + $color = 'rgba(74, 138, 202, .6)'; |
|
| 379 | 379 | break; |
| 380 | 380 | |
| 381 | 381 | case 2: |
| 382 | 382 | $icon = 'map_red_'; |
| 383 | 383 | $team = 'Team Valor'; |
| 384 | - $color = 'rgba(240, 68, 58, .6)'; |
|
| 384 | + $color = 'rgba(240, 68, 58, .6)'; |
|
| 385 | 385 | break; |
| 386 | 386 | |
| 387 | 387 | case 3: |
| 388 | 388 | $icon = 'map_yellow_'; |
| 389 | 389 | $team = 'Team Instinct'; |
| 390 | - $color = 'rgba(254, 217, 40, .6)'; |
|
| 390 | + $color = 'rgba(254, 217, 40, .6)'; |
|
| 391 | 391 | break; |
| 392 | 392 | } |
| 393 | 393 | |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | case 'gym_defenders': |
| 422 | 422 | $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
| 423 | - $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 423 | + $req = "SELECT gymdetails.name AS name, gymdetails.description AS description, gymdetails.url AS url, gym.team_id AS team, |
|
| 424 | 424 | (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) AS last_scanned, gym.guard_pokemon_id AS guard_pokemon_id, (SELECT COUNT(DISTINCT pokemon_uid) FROM gymmember AS gm WHERE gm.gym_id = gym.gym_id) AS gym_level |
| 425 | 425 | FROM gymdetails |
| 426 | 426 | LEFT JOIN gym ON gym.gym_id = gymdetails.gym_id |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | $gymData['gymDetails']['gymInfos']['level'] = gym_level($data->points); |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | - $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 447 | + $req = "SELECT DISTINCT gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) AS cp, gymmember.gym_id |
|
| 448 | 448 | FROM gympokemon INNER JOIN gymmember ON gympokemon.pokemon_uid=gymmember.pokemon_uid |
| 449 | 449 | GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id |
| 450 | 450 | HAVING gymmember.gym_id='".$gym_id."' |
@@ -471,10 +471,10 @@ discard block |
||
| 471 | 471 | <span class="sr-only">'.$locales->IV_ATTACK.' : '.$data->iv_attack.'</span>'.$data->iv_attack.' |
| 472 | 472 | </div> |
| 473 | 473 | <div title="'.$locales->IV_DEFENSE.': '.$data->iv_defense.'" class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="'.$data->iv_defense.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 13px; font-size: 11px"> |
| 474 | - <span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'. $data->iv_defense .' |
|
| 474 | + <span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'.$data->iv_defense.' |
|
| 475 | 475 | </div> |
| 476 | 476 | <div title="'.$locales->IV_STAMINA.': '.$data->iv_stamina.'" class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$data->iv_stamina.'" aria-valuemin="0" aria-valuemax="45" style="width: '.(100 / 3).'%; line-height: 13px; font-size: 11px"> |
| 477 | - <span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'. $data->iv_stamina .' |
|
| 477 | + <span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'.$data->iv_stamina.' |
|
| 478 | 478 | </div> |
| 479 | 479 | </div> |
| 480 | 480 | </div>'; |
@@ -546,16 +546,16 @@ discard block |
||
| 546 | 546 | $name = ""; |
| 547 | 547 | $page = "0"; |
| 548 | 548 | $where = ""; |
| 549 | - $order=""; |
|
| 550 | - $team=0; |
|
| 551 | - $ranking=0; |
|
| 549 | + $order = ""; |
|
| 550 | + $team = 0; |
|
| 551 | + $ranking = 0; |
|
| 552 | 552 | if (isset($_GET['name'])) { |
| 553 | 553 | $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
| 554 | 554 | $where = " HAVING name LIKE '%".$trainer_name."%'"; |
| 555 | 555 | } |
| 556 | - if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 556 | + if (isset($_GET['team']) && $_GET['team'] != 0) { |
|
| 557 | 557 | $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
| 558 | - $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 558 | + $where .= ($where == "" ? " HAVING" : "AND ")." team = ".$team; |
|
| 559 | 559 | } |
| 560 | 560 | if (isset($_GET['page'])) { |
| 561 | 561 | $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
@@ -566,16 +566,16 @@ discard block |
||
| 566 | 566 | |
| 567 | 567 | switch ($ranking) { |
| 568 | 568 | case 1: |
| 569 | - $order=" ORDER BY active DESC "; |
|
| 569 | + $order = " ORDER BY active DESC "; |
|
| 570 | 570 | break; |
| 571 | 571 | case 2: |
| 572 | - $order=" ORDER BY maxCp DESC "; |
|
| 572 | + $order = " ORDER BY maxCp DESC "; |
|
| 573 | 573 | break; |
| 574 | 574 | default: |
| 575 | - $order=" ORDER BY level DESC, active DESC "; |
|
| 575 | + $order = " ORDER BY level DESC, active DESC "; |
|
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - $limit = " LIMIT ".($page*10).",10 "; |
|
| 578 | + $limit = " LIMIT ".($page * 10).",10 "; |
|
| 579 | 579 | |
| 580 | 580 | |
| 581 | 581 | $req = "SELECT trainer.*, COUNT(actives_pokemons.trainer_name) AS active, max(actives_pokemons.cp) AS maxCp |
@@ -596,7 +596,7 @@ discard block |
||
| 596 | 596 | $reqRanking = "SELECT COUNT(1) AS rank FROM trainer WHERE trainer.level >= ".$trainer->level; |
| 597 | 597 | $resultRanking = $mysqli->query($reqRanking); |
| 598 | 598 | while ($data = $resultRanking->fetch_object()) { |
| 599 | - $trainer->rank = $data->rank ; |
|
| 599 | + $trainer->rank = $data->rank; |
|
| 600 | 600 | } |
| 601 | 601 | $req = "(SELECT DISTINCT gympokemon.pokemon_id, gympokemon.pokemon_uid, gympokemon.cp, DATEDIFF(UTC_TIMESTAMP(), gympokemon.last_seen) AS last_scanned, gympokemon.trainer_name, gympokemon.iv_defense, gympokemon.iv_stamina, gympokemon.iv_attack, filtered_gymmember.gym_id, '1' AS active |
| 602 | 602 | FROM gympokemon INNER JOIN |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | $resultPkms = $mysqli->query($req); |
| 609 | 609 | $trainer->pokemons = array(); |
| 610 | - $active_gyms=0; |
|
| 610 | + $active_gyms = 0; |
|
| 611 | 611 | $pkmCount = 0; |
| 612 | 612 | while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
| 613 | 613 | $active_gyms++; |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
| 652 | 652 | } |
| 653 | 653 | |
| 654 | - $limit = " LIMIT ".($page*10).",10"; |
|
| 654 | + $limit = " LIMIT ".($page * 10).",10"; |
|
| 655 | 655 | |
| 656 | 656 | $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 |
| 657 | 657 | JOIN gymdetails ON gymdetails.gym_id = raid.gym_id |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | break; |
| 691 | 691 | |
| 692 | 692 | case 'pokemon_slider_init': |
| 693 | - $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 693 | + $req = "SELECT MIN(disappear_time) AS min, MAX(disappear_time) AS max FROM pokemon"; |
|
| 694 | 694 | $result = $mysqli->query($req); |
| 695 | 695 | $bounds = $result->fetch_object(); |
| 696 | 696 | |
@@ -701,18 +701,18 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | |
| 703 | 703 | case 'pokemon_heatmap_points': |
| 704 | - $json=""; |
|
| 705 | - if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 706 | - $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 707 | - $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 704 | + $json = ""; |
|
| 705 | + if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 706 | + $start = Date("Y-m-d H:i", (int) $_GET['start']); |
|
| 707 | + $end = Date("Y-m-d H:i", (int) $_GET['end']); |
|
| 708 | 708 | $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
| 709 | 709 | $where = " WHERE pokemon_id = ".$pokemon_id." " |
| 710 | 710 | . "AND disappear_time BETWEEN '".$start."' AND '".$end."'"; |
| 711 | 711 | $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
| 712 | - $result = $mysqli->query($req); |
|
| 712 | + $result = $mysqli->query($req); |
|
| 713 | 713 | $points = array(); |
| 714 | 714 | while ($result && $data = $result->fetch_object()) { |
| 715 | - $points[] = $data; |
|
| 715 | + $points[] = $data; |
|
| 716 | 716 | } |
| 717 | 717 | |
| 718 | 718 | $json = json_encode($points); |
@@ -724,9 +724,9 @@ discard block |
||
| 724 | 724 | |
| 725 | 725 | |
| 726 | 726 | case 'maps_localization_coordinates': |
| 727 | - $json=""; |
|
| 728 | - $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 729 | - $result = $mysqli->query($req); |
|
| 727 | + $json = ""; |
|
| 728 | + $req = "SELECT MAX(latitude) AS max_latitude, MIN(latitude) AS min_latitude, MAX(longitude) AS max_longitude, MIN(longitude) as min_longitude FROM spawnpoint"; |
|
| 729 | + $result = $mysqli->query($req); |
|
| 730 | 730 | $coordinates = $result->fetch_object(); |
| 731 | 731 | |
| 732 | 732 | header('Content-Type: application/json'); |
@@ -736,7 +736,7 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | |
| 738 | 738 | case 'pokemon_graph_data': |
| 739 | - $json=""; |
|
| 739 | + $json = ""; |
|
| 740 | 740 | if (isset($_GET['pokemon_id'])) { |
| 741 | 741 | $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
| 742 | 742 | $req = "SELECT COUNT(*) AS total, |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) AS pokemonFiltered |
| 745 | 745 | GROUP BY disappear_hour |
| 746 | 746 | ORDER BY disappear_hour"; |
| 747 | - $result = $mysqli->query($req); |
|
| 747 | + $result = $mysqli->query($req); |
|
| 748 | 748 | $array = array_fill(0, 24, 0); |
| 749 | 749 | while ($result && $data = $result->fetch_object()) { |
| 750 | 750 | $array[$data->disappear_hour] = $data->total; |
@@ -770,30 +770,30 @@ discard block |
||
| 770 | 770 | break; |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | -if ($postRequest!="") { |
|
| 773 | +if ($postRequest != "") { |
|
| 774 | 774 | switch ($postRequest) { |
| 775 | 775 | case 'pokemon_live': |
| 776 | - $json=""; |
|
| 777 | - if (isset( $_POST['pokemon_id'])) { |
|
| 776 | + $json = ""; |
|
| 777 | + if (isset($_POST['pokemon_id'])) { |
|
| 778 | 778 | $pokemon_id = mysqli_real_escape_string($mysqli, $_POST['pokemon_id']); |
| 779 | - $inmap_pkms_filter=""; |
|
| 779 | + $inmap_pkms_filter = ""; |
|
| 780 | 780 | $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon_id = ".$pokemon_id; |
| 781 | 781 | |
| 782 | 782 | $reqTestIv = "SELECT MAX(individual_attack) AS iv FROM pokemon ".$where; |
| 783 | - $resultTestIv = $mysqli->query($reqTestIv); |
|
| 783 | + $resultTestIv = $mysqli->query($reqTestIv); |
|
| 784 | 784 | $testIv = $resultTestIv->fetch_object(); |
| 785 | - if (isset( $_POST['inmap_pokemons'])&&( $_POST['inmap_pokemons']!="")) { |
|
| 785 | + if (isset($_POST['inmap_pokemons']) && ($_POST['inmap_pokemons'] != "")) { |
|
| 786 | 786 | foreach ($_POST['inmap_pokemons'] as $inmap) { |
| 787 | 787 | $inmap_pkms_filter .= "'".$inmap."',"; |
| 788 | 788 | } |
| 789 | 789 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
| 790 | 790 | $where .= " AND encounter_id NOT IN (".$inmap_pkms_filter.") "; |
| 791 | 791 | } |
| 792 | - if ($testIv->iv!=null && isset( $_POST['ivMin'])&&( $_POST['ivMin']!="")) { |
|
| 792 | + if ($testIv->iv != null && isset($_POST['ivMin']) && ($_POST['ivMin'] != "")) { |
|
| 793 | 793 | $ivMin = mysqli_real_escape_string($mysqli, $_POST['ivMin']); |
| 794 | 794 | $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") "; |
| 795 | 795 | } |
| 796 | - if ($testIv->iv!=null && isset( $_POST['ivMax'])&&( $_POST['ivMax']!="")) { |
|
| 796 | + if ($testIv->iv != null && isset($_POST['ivMax']) && ($_POST['ivMax'] != "")) { |
|
| 797 | 797 | $ivMax = mysqli_real_escape_string($mysqli, $_POST['ivMax']); |
| 798 | 798 | $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(".$ivMax.") "; |
| 799 | 799 | } |
@@ -807,12 +807,12 @@ discard block |
||
| 807 | 807 | $json = array(); |
| 808 | 808 | $json['points'] = array(); |
| 809 | 809 | $locale = array(); |
| 810 | - $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 810 | + $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 811 | 811 | $locale["ivDefense"] = $locales->IV_DEFENSE; |
| 812 | - $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 812 | + $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 813 | 813 | $json['locale'] = $locale; |
| 814 | 814 | while ($result && $data = $result->fetch_object()) { |
| 815 | - $pokeid=$data->pokemon_id; |
|
| 815 | + $pokeid = $data->pokemon_id; |
|
| 816 | 816 | $data->name = $pokemons->pokemon->$pokeid->name; |
| 817 | 817 | if (isset($data->move_1)) { |
| 818 | 818 | $move1 = $data->move_1; |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | } else { |
| 827 | 827 | $data->charge_move = "?"; |
| 828 | 828 | } |
| 829 | - $json['points'][] = $data; |
|
| 829 | + $json['points'][] = $data; |
|
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | $json = json_encode($json); |