@@ -58,145 +58,145 @@ 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, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon |
|
| 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, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon |
|
| 158 | 158 | WHERE pokemon_id IN (".implode(",", $mythic_pokemons).") |
| 159 | 159 | ORDER BY last_modified DESC LIMIT 0,12"; |
| 160 | - } else { |
|
| 161 | - // get last pokemon |
|
| 162 | - $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12"; |
|
| 163 | - } |
|
| 164 | - $result = $mysqli->query($req); |
|
| 165 | - while ($data = $result->fetch_object()) { |
|
| 166 | - $new_spawn = array(); |
|
| 167 | - $pokeid = $data->pokemon_id; |
|
| 168 | - $pokeuid = $data->encounter_id; |
|
| 169 | - |
|
| 170 | - if ($last_uid_param != $pokeuid) { |
|
| 171 | - $last_seen = strtotime($data->disappear_time_real); |
|
| 172 | - |
|
| 173 | - $last_location = new stdClass(); |
|
| 174 | - $last_location->latitude = $data->latitude; |
|
| 175 | - $last_location->longitude = $data->longitude; |
|
| 176 | - |
|
| 177 | - if ($config->system->recents_show_iv) { |
|
| 178 | - $iv = new stdClass(); |
|
| 179 | - $iv->attack = $data->individual_attack; |
|
| 180 | - $iv->defense = $data->individual_defense; |
|
| 181 | - $iv->stamina = $data->individual_stamina; |
|
| 182 | - if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) { |
|
| 183 | - $iv->available = true; |
|
| 184 | - } else { |
|
| 185 | - $iv->available = false; |
|
| 160 | + } else { |
|
| 161 | + // get last pokemon |
|
| 162 | + $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12"; |
|
| 163 | + } |
|
| 164 | + $result = $mysqli->query($req); |
|
| 165 | + while ($data = $result->fetch_object()) { |
|
| 166 | + $new_spawn = array(); |
|
| 167 | + $pokeid = $data->pokemon_id; |
|
| 168 | + $pokeuid = $data->encounter_id; |
|
| 169 | + |
|
| 170 | + if ($last_uid_param != $pokeuid) { |
|
| 171 | + $last_seen = strtotime($data->disappear_time_real); |
|
| 172 | + |
|
| 173 | + $last_location = new stdClass(); |
|
| 174 | + $last_location->latitude = $data->latitude; |
|
| 175 | + $last_location->longitude = $data->longitude; |
|
| 176 | + |
|
| 177 | + if ($config->system->recents_show_iv) { |
|
| 178 | + $iv = new stdClass(); |
|
| 179 | + $iv->attack = $data->individual_attack; |
|
| 180 | + $iv->defense = $data->individual_defense; |
|
| 181 | + $iv->stamina = $data->individual_stamina; |
|
| 182 | + if (isset($iv->attack) && isset($iv->defense) && isset($iv->stamina)) { |
|
| 183 | + $iv->available = true; |
|
| 184 | + } else { |
|
| 185 | + $iv->available = false; |
|
| 186 | + } |
|
| 186 | 187 | } |
| 187 | - } |
|
| 188 | 188 | |
| 189 | - $html = ' |
|
| 189 | + $html = ' |
|
| 190 | 190 | <div class="col-md-1 col-xs-4 pokemon-single" data-pokeid="'.$pokeid.'" data-pokeuid="'.$pokeuid.'" style="display: none;"> |
| 191 | 191 | <a href="pokemon/'.$pokeid.'"><img src="core/pokemons/'.$pokeid.$config->system->pokeimg_suffix.'" alt="'.$pokemons->pokemon->$pokeid->name.'" class="img-responsive"></a> |
| 192 | 192 | <a href="pokemon/'.$pokeid.'"><p class="pkmn-name">'.$pokemons->pokemon->$pokeid->name.'</p></a> |
| 193 | 193 | <a href="https://maps.google.com/?q='.$last_location->latitude.','.$last_location->longitude.'&ll='.$last_location->latitude.','.$last_location->longitude.'&z=16" target="_blank"> |
| 194 | 194 | <small class="pokemon-timer">00:00:00</small> |
| 195 | 195 | </a>'; |
| 196 | - if ($config->system->recents_show_iv) { |
|
| 197 | - if ($iv->available) { |
|
| 198 | - if ($config->system->iv_numbers) { |
|
| 199 | - $html .= ' |
|
| 196 | + if ($config->system->recents_show_iv) { |
|
| 197 | + if ($iv->available) { |
|
| 198 | + if ($config->system->iv_numbers) { |
|
| 199 | + $html .= ' |
|
| 200 | 200 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 201 | 201 | <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";> |
| 202 | 202 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .' |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .' |
| 209 | 209 | </div> |
| 210 | 210 | </div>'; |
| 211 | - } else { |
|
| 212 | - $html .= ' |
|
| 211 | + } else { |
|
| 212 | + $html .= ' |
|
| 213 | 213 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 0 auto;"> |
| 214 | 214 | <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).'%"> |
| 215 | 215 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span> |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span> |
| 222 | 222 | </div> |
| 223 | 223 | </div>'; |
| 224 | - } |
|
| 225 | - } else { |
|
| 226 | - if ($config->system->iv_numbers) { |
|
| 227 | - $html .= ' |
|
| 224 | + } |
|
| 225 | + } else { |
|
| 226 | + if ($config->system->iv_numbers) { |
|
| 227 | + $html .= ' |
|
| 228 | 228 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 229 | 229 | <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";> |
| 230 | 230 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$locales->NOT_AVAILABLE.'</span> |
@@ -236,121 +236,121 @@ discard block |
||
| 236 | 236 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$locales->NOT_AVAILABLE.'</span> |
| 237 | 237 | </div> |
| 238 | 238 | </div>'; |
| 239 | - } else { |
|
| 240 | - $html .= ' |
|
| 239 | + } else { |
|
| 240 | + $html .= ' |
|
| 241 | 241 | <div class="progress" style="height: 6px; width: 80%; margin: 5px auto 15px auto;"> |
| 242 | 242 | <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"> |
| 243 | 243 | <span class="sr-only">IV '.$locales->NOT_AVAILABLE.'</span> |
| 244 | 244 | </div> |
| 245 | 245 | </div>'; |
| 246 | + } |
|
| 246 | 247 | } |
| 247 | 248 | } |
| 248 | - } |
|
| 249 | - $html .= ' |
|
| 249 | + $html .= ' |
|
| 250 | 250 | </div>'; |
| 251 | - $new_spawn['html'] = $html; |
|
| 252 | - $countdown = $last_seen - time(); |
|
| 253 | - $new_spawn['countdown'] = $countdown; |
|
| 254 | - $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 255 | - $total_spawns[] = $new_spawn; |
|
| 256 | - } else { |
|
| 257 | - break; |
|
| 251 | + $new_spawn['html'] = $html; |
|
| 252 | + $countdown = $last_seen - time(); |
|
| 253 | + $new_spawn['countdown'] = $countdown; |
|
| 254 | + $new_spawn['pokemon_uid'] = $pokeuid; |
|
| 255 | + $total_spawns[] = $new_spawn; |
|
| 256 | + } else { |
|
| 257 | + break; |
|
| 258 | + } |
|
| 258 | 259 | } |
| 259 | - } |
|
| 260 | - |
|
| 261 | - header('Content-Type: application/json'); |
|
| 262 | - echo json_encode($total_spawns); |
|
| 263 | - |
|
| 264 | - break; |
|
| 265 | 260 | |
| 261 | + header('Content-Type: application/json'); |
|
| 262 | + echo json_encode($total_spawns); |
|
| 266 | 263 | |
| 267 | - #################################### |
|
| 268 | - // |
|
| 269 | - // List Pokestop |
|
| 270 | - // |
|
| 271 | - #################################### |
|
| 264 | + break; |
|
| 272 | 265 | |
| 273 | - case 'pokestop': |
|
| 274 | - if (!($config->system->only_lured_pokestops)) { |
|
| 275 | - $req = "SELECT latitude, longitude, lure_expiration, UTC_TIMESTAMP() as now, (CONVERT_TZ(lure_expiration, '+00:00', '".$time_offset."')) as lure_expiration_real FROM pokestop"; |
|
| 276 | - } else { |
|
| 277 | - $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()"; |
|
| 278 | - } |
|
| 279 | - $result = $mysqli->query($req); |
|
| 280 | 266 | |
| 281 | - $pokestops = []; |
|
| 267 | + #################################### |
|
| 268 | + // |
|
| 269 | + // List Pokestop |
|
| 270 | + // |
|
| 271 | + #################################### |
|
| 282 | 272 | |
| 283 | - while ($data = $result->fetch_object()) { |
|
| 284 | - if ($data->lure_expiration >= $data->now) { |
|
| 285 | - $icon = 'pokestap_lured.png'; |
|
| 286 | - $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 273 | + case 'pokestop': |
|
| 274 | + if (!($config->system->only_lured_pokestops)) { |
|
| 275 | + $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 | 276 | } else { |
| 288 | - $icon = 'pokestap.png'; |
|
| 289 | - $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 277 | + $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()"; |
|
| 290 | 278 | } |
| 279 | + $result = $mysqli->query($req); |
|
| 291 | 280 | |
| 292 | - $pokestops[] = [ |
|
| 293 | - $text, |
|
| 294 | - $icon, |
|
| 295 | - $data->latitude, |
|
| 296 | - $data->longitude |
|
| 297 | - ]; |
|
| 298 | - } |
|
| 281 | + $pokestops = []; |
|
| 299 | 282 | |
| 300 | - header('Content-Type: application/json'); |
|
| 301 | - echo json_encode($pokestops); |
|
| 283 | + while ($data = $result->fetch_object()) { |
|
| 284 | + if ($data->lure_expiration >= $data->now) { |
|
| 285 | + $icon = 'pokestap_lured.png'; |
|
| 286 | + $text = sprintf($locales->POKESTOPS_MAP_LURED, date('H:i:s', strtotime($data->lure_expiration_real))); |
|
| 287 | + } else { |
|
| 288 | + $icon = 'pokestap.png'; |
|
| 289 | + $text = $locales->POKESTOPS_MAP_REGULAR; |
|
| 290 | + } |
|
| 302 | 291 | |
| 303 | - break; |
|
| 292 | + $pokestops[] = [ |
|
| 293 | + $text, |
|
| 294 | + $icon, |
|
| 295 | + $data->latitude, |
|
| 296 | + $data->longitude |
|
| 297 | + ]; |
|
| 298 | + } |
|
| 304 | 299 | |
| 300 | + header('Content-Type: application/json'); |
|
| 301 | + echo json_encode($pokestops); |
|
| 305 | 302 | |
| 306 | - #################################### |
|
| 307 | - // |
|
| 308 | - // Update data for the gym battle |
|
| 309 | - // |
|
| 310 | - #################################### |
|
| 303 | + break; |
|
| 311 | 304 | |
| 312 | - case 'update_gym': |
|
| 313 | - $teams = new stdClass(); |
|
| 314 | - $teams->mystic = 1; |
|
| 315 | - $teams->valor = 2; |
|
| 316 | - $teams->instinct = 3; |
|
| 317 | 305 | |
| 306 | + #################################### |
|
| 307 | + // |
|
| 308 | + // Update data for the gym battle |
|
| 309 | + // |
|
| 310 | + #################################### |
|
| 318 | 311 | |
| 319 | - foreach ($teams as $team_name => $team_id) { |
|
| 320 | - $req = "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."' "; |
|
| 321 | - $result = $mysqli->query($req); |
|
| 322 | - $data = $result->fetch_object(); |
|
| 312 | + case 'update_gym': |
|
| 313 | + $teams = new stdClass(); |
|
| 314 | + $teams->mystic = 1; |
|
| 315 | + $teams->valor = 2; |
|
| 316 | + $teams->instinct = 3; |
|
| 323 | 317 | |
| 324 | - $return[] = $data->total; |
|
| 325 | - $return[] = $data->average_points; |
|
| 326 | - } |
|
| 327 | 318 | |
| 328 | - header('Content-Type: application/json'); |
|
| 329 | - echo json_encode($return); |
|
| 319 | + foreach ($teams as $team_name => $team_id) { |
|
| 320 | + $req = "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."' "; |
|
| 321 | + $result = $mysqli->query($req); |
|
| 322 | + $data = $result->fetch_object(); |
|
| 330 | 323 | |
| 331 | - break; |
|
| 324 | + $return[] = $data->total; |
|
| 325 | + $return[] = $data->average_points; |
|
| 326 | + } |
|
| 332 | 327 | |
| 328 | + header('Content-Type: application/json'); |
|
| 329 | + echo json_encode($return); |
|
| 333 | 330 | |
| 334 | - #################################### |
|
| 335 | - // |
|
| 336 | - // Get datas for the gym map |
|
| 337 | - // |
|
| 338 | - #################################### |
|
| 331 | + break; |
|
| 339 | 332 | |
| 340 | 333 | |
| 341 | - case 'gym_map': |
|
| 342 | - $req = "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) as last_scanned FROM gym"; |
|
| 343 | - $result = $mysqli->query($req); |
|
| 334 | + #################################### |
|
| 335 | + // |
|
| 336 | + // Get datas for the gym map |
|
| 337 | + // |
|
| 338 | + #################################### |
|
| 344 | 339 | |
| 345 | - $gyms = []; |
|
| 346 | 340 | |
| 347 | - while ($data = $result->fetch_object()) { |
|
| 348 | - // Team |
|
| 349 | - // 1 = bleu |
|
| 350 | - // 2 = rouge |
|
| 351 | - // 3 = jaune |
|
| 341 | + case 'gym_map': |
|
| 342 | + $req = "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) as last_scanned FROM gym"; |
|
| 343 | + $result = $mysqli->query($req); |
|
| 344 | + |
|
| 345 | + $gyms = []; |
|
| 346 | + |
|
| 347 | + while ($data = $result->fetch_object()) { |
|
| 348 | + // Team |
|
| 349 | + // 1 = bleu |
|
| 350 | + // 2 = rouge |
|
| 351 | + // 3 = jaune |
|
| 352 | 352 | |
| 353 | - switch ($data->team_id) { |
|
| 353 | + switch ($data->team_id) { |
|
| 354 | 354 | case 0: |
| 355 | 355 | $icon = 'map_white.png'; |
| 356 | 356 | $team = 'No Team (yet)'; |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $team = 'Team Instinct'; |
| 375 | 375 | $color = 'rgba(254, 217, 40, .6)'; |
| 376 | 376 | break; |
| 377 | - } |
|
| 377 | + } |
|
| 378 | 378 | |
| 379 | 379 | // Set gym level |
| 380 | 380 | $data->gym_level=0; |
@@ -439,65 +439,65 @@ discard block |
||
| 439 | 439 | // |
| 440 | 440 | #################################### |
| 441 | 441 | |
| 442 | - case 'gym_defenders': |
|
| 443 | - $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 444 | - $req = "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) as last_scanned, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'"; |
|
| 445 | - $result = $mysqli->query($req); |
|
| 446 | - $gymData['gymDetails']['gymInfos'] = false; |
|
| 447 | - while ($data = $result->fetch_object()) { |
|
| 448 | - $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 449 | - $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 450 | - if ($data->url == null) { |
|
| 451 | - $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 452 | - } else { |
|
| 453 | - $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 454 | - } |
|
| 455 | - $gymData['gymDetails']['gymInfos']['points'] = $data->points; |
|
| 456 | - $gymData['gymDetails']['gymInfos']['level'] = 0; |
|
| 457 | - $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 458 | - $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 459 | - $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 460 | - if ($data->points < 2000) { |
|
| 461 | - $gymData['gymDetails']['gymInfos']['level']=1; |
|
| 462 | - } elseif ($data->points < 4000) { |
|
| 463 | - $gymData['gymDetails']['gymInfos']['level']=2; |
|
| 464 | - } elseif ($data->points < 8000) { |
|
| 465 | - $gymData['gymDetails']['gymInfos']['level']=3; |
|
| 466 | - } elseif ($data->points < 12000) { |
|
| 467 | - $gymData['gymDetails']['gymInfos']['level']=4; |
|
| 468 | - } elseif ($data->points < 16000) { |
|
| 469 | - $gymData['gymDetails']['gymInfos']['level']=5; |
|
| 470 | - } elseif ($data->points < 20000) { |
|
| 471 | - $gymData['gymDetails']['gymInfos']['level']=6; |
|
| 472 | - } elseif ($data->points < 30000) { |
|
| 473 | - $gymData['gymDetails']['gymInfos']['level']=7; |
|
| 474 | - } elseif ($data->points < 40000) { |
|
| 475 | - $gymData['gymDetails']['gymInfos']['level']=8; |
|
| 476 | - } elseif ($data->points < 50000) { |
|
| 477 | - $gymData['gymDetails']['gymInfos']['level']=9; |
|
| 478 | - } else { |
|
| 479 | - $gymData['gymDetails']['gymInfos']['level']=10; |
|
| 442 | + case 'gym_defenders': |
|
| 443 | + $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
|
| 444 | + $req = "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) as last_scanned, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'"; |
|
| 445 | + $result = $mysqli->query($req); |
|
| 446 | + $gymData['gymDetails']['gymInfos'] = false; |
|
| 447 | + while ($data = $result->fetch_object()) { |
|
| 448 | + $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
|
| 449 | + $gymData['gymDetails']['gymInfos']['description'] = $data->description; |
|
| 450 | + if ($data->url == null) { |
|
| 451 | + $gymData['gymDetails']['gymInfos']['url'] = ''; |
|
| 452 | + } else { |
|
| 453 | + $gymData['gymDetails']['gymInfos']['url'] = $data->url; |
|
| 454 | + } |
|
| 455 | + $gymData['gymDetails']['gymInfos']['points'] = $data->points; |
|
| 456 | + $gymData['gymDetails']['gymInfos']['level'] = 0; |
|
| 457 | + $gymData['gymDetails']['gymInfos']['last_scanned'] = $data->last_scanned; |
|
| 458 | + $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
|
| 459 | + $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
|
| 460 | + if ($data->points < 2000) { |
|
| 461 | + $gymData['gymDetails']['gymInfos']['level']=1; |
|
| 462 | + } elseif ($data->points < 4000) { |
|
| 463 | + $gymData['gymDetails']['gymInfos']['level']=2; |
|
| 464 | + } elseif ($data->points < 8000) { |
|
| 465 | + $gymData['gymDetails']['gymInfos']['level']=3; |
|
| 466 | + } elseif ($data->points < 12000) { |
|
| 467 | + $gymData['gymDetails']['gymInfos']['level']=4; |
|
| 468 | + } elseif ($data->points < 16000) { |
|
| 469 | + $gymData['gymDetails']['gymInfos']['level']=5; |
|
| 470 | + } elseif ($data->points < 20000) { |
|
| 471 | + $gymData['gymDetails']['gymInfos']['level']=6; |
|
| 472 | + } elseif ($data->points < 30000) { |
|
| 473 | + $gymData['gymDetails']['gymInfos']['level']=7; |
|
| 474 | + } elseif ($data->points < 40000) { |
|
| 475 | + $gymData['gymDetails']['gymInfos']['level']=8; |
|
| 476 | + } elseif ($data->points < 50000) { |
|
| 477 | + $gymData['gymDetails']['gymInfos']['level']=9; |
|
| 478 | + } else { |
|
| 479 | + $gymData['gymDetails']['gymInfos']['level']=10; |
|
| 480 | + } |
|
| 480 | 481 | } |
| 481 | - } |
|
| 482 | - //print_r($gymData); |
|
| 483 | - $req = "SELECT DISTINCT gympokemon.pokemon_uid, " |
|
| 484 | - . "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id " |
|
| 485 | - . "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid " |
|
| 486 | - . "GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id" |
|
| 487 | - . " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC"; |
|
| 488 | - $result = $mysqli->query($req); |
|
| 489 | - $i=0; |
|
| 482 | + //print_r($gymData); |
|
| 483 | + $req = "SELECT DISTINCT gympokemon.pokemon_uid, " |
|
| 484 | + . "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id " |
|
| 485 | + . "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid " |
|
| 486 | + . "GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id" |
|
| 487 | + . " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC"; |
|
| 488 | + $result = $mysqli->query($req); |
|
| 489 | + $i=0; |
|
| 490 | 490 | |
| 491 | 491 | |
| 492 | 492 | |
| 493 | - $gymData['infoWindow'] = ' |
|
| 493 | + $gymData['infoWindow'] = ' |
|
| 494 | 494 | <div class="gym_defenders"> |
| 495 | 495 | '; |
| 496 | - while ($data = $result->fetch_object()) { |
|
| 497 | - $gymData['gymDetails']['pokemons'][] = $data; |
|
| 498 | - if ($data != false) { |
|
| 499 | - if ($config->system->iv_numbers) { |
|
| 500 | - $gymData['infoWindow'] .= ' |
|
| 496 | + while ($data = $result->fetch_object()) { |
|
| 497 | + $gymData['gymDetails']['pokemons'][] = $data; |
|
| 498 | + if ($data != false) { |
|
| 499 | + if ($config->system->iv_numbers) { |
|
| 500 | + $gymData['infoWindow'] .= ' |
|
| 501 | 501 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 502 | 502 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 503 | 503 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -515,8 +515,8 @@ discard block |
||
| 515 | 515 | </div> |
| 516 | 516 | </div> |
| 517 | 517 | </div>'; |
| 518 | - } else { |
|
| 519 | - $gymData['infoWindow'] .= ' |
|
| 518 | + } else { |
|
| 519 | + $gymData['infoWindow'] .= ' |
|
| 520 | 520 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 521 | 521 | <a href="pokemon/'.$data->pokemon_id.'"> |
| 522 | 522 | <img src="core/pokemons/'.$data->pokemon_id.$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
@@ -534,50 +534,50 @@ discard block |
||
| 534 | 534 | </div> |
| 535 | 535 | </div> |
| 536 | 536 | </div>' |
| 537 | - ; } |
|
| 538 | - } else { |
|
| 539 | - $gymData['infoWindow'] .= ' |
|
| 537 | + ; } |
|
| 538 | + } else { |
|
| 539 | + $gymData['infoWindow'] .= ' |
|
| 540 | 540 | <div style="text-align: center; width: 50px; display: inline-block; margin-right: 3px"> |
| 541 | 541 | <a href="pokemon/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].'"> |
| 542 | 542 | <img src="core/pokemons/'.$gymData['gymDetails']['gymInfos']['guardPokemonId'].$config->system->pokeimg_suffix.'" height="50" style="display:inline-block" > |
| 543 | 543 | </a> |
| 544 | 544 | <p class="pkmn-name">???</p> |
| 545 | 545 | </div>' |
| 546 | - ; |
|
| 546 | + ; |
|
| 547 | + } |
|
| 548 | + $i++; |
|
| 547 | 549 | } |
| 548 | - $i++; |
|
| 549 | - } |
|
| 550 | - $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 550 | + $gymData['infoWindow'] = $gymData['infoWindow'].'</div>'; |
|
| 551 | 551 | |
| 552 | - header('Content-Type: application/json'); |
|
| 553 | - echo json_encode($gymData); |
|
| 552 | + header('Content-Type: application/json'); |
|
| 553 | + echo json_encode($gymData); |
|
| 554 | 554 | |
| 555 | - break; |
|
| 555 | + break; |
|
| 556 | 556 | |
| 557 | 557 | |
| 558 | - case 'trainer': |
|
| 559 | - $name = ""; |
|
| 560 | - $page = "0"; |
|
| 561 | - $where = ""; |
|
| 562 | - $order=""; |
|
| 563 | - $team=0; |
|
| 564 | - $ranking=0; |
|
| 565 | - if (isset($_GET['name'])) { |
|
| 566 | - $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 567 | - $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 568 | - } |
|
| 569 | - if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 570 | - $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 571 | - $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 572 | - } |
|
| 573 | - if (isset($_GET['page'])) { |
|
| 574 | - $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 575 | - } |
|
| 576 | - if (isset($_GET['ranking'])) { |
|
| 577 | - $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 578 | - } |
|
| 558 | + case 'trainer': |
|
| 559 | + $name = ""; |
|
| 560 | + $page = "0"; |
|
| 561 | + $where = ""; |
|
| 562 | + $order=""; |
|
| 563 | + $team=0; |
|
| 564 | + $ranking=0; |
|
| 565 | + if (isset($_GET['name'])) { |
|
| 566 | + $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
|
| 567 | + $where = " HAVING name LIKE '%".$trainer_name."%'"; |
|
| 568 | + } |
|
| 569 | + if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 570 | + $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
|
| 571 | + $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 572 | + } |
|
| 573 | + if (isset($_GET['page'])) { |
|
| 574 | + $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
|
| 575 | + } |
|
| 576 | + if (isset($_GET['ranking'])) { |
|
| 577 | + $ranking = mysqli_real_escape_string($mysqli, $_GET['ranking']); |
|
| 578 | + } |
|
| 579 | 579 | |
| 580 | - switch ($ranking) { |
|
| 580 | + switch ($ranking) { |
|
| 581 | 581 | case 1: |
| 582 | 582 | $order=" ORDER BY active DESC "; |
| 583 | 583 | break; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | break; |
| 587 | 587 | default: |
| 588 | 588 | $order=" ORDER BY level DESC, active DESC "; |
| 589 | - } |
|
| 589 | + } |
|
| 590 | 590 | |
| 591 | 591 | $limit = " LIMIT ".($page*10).",10 "; |
| 592 | 592 | |
@@ -654,75 +654,75 @@ discard block |
||
| 654 | 654 | break; |
| 655 | 655 | |
| 656 | 656 | |
| 657 | - case 'pokemon_slider_init': |
|
| 658 | - $req = "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon"; |
|
| 659 | - $result = $mysqli->query($req); |
|
| 660 | - $bounds = $result->fetch_object(); |
|
| 657 | + case 'pokemon_slider_init': |
|
| 658 | + $req = "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon"; |
|
| 659 | + $result = $mysqli->query($req); |
|
| 660 | + $bounds = $result->fetch_object(); |
|
| 661 | 661 | |
| 662 | - header('Content-Type: application/json'); |
|
| 663 | - echo json_encode($bounds); |
|
| 662 | + header('Content-Type: application/json'); |
|
| 663 | + echo json_encode($bounds); |
|
| 664 | 664 | |
| 665 | - break; |
|
| 665 | + break; |
|
| 666 | 666 | |
| 667 | 667 | |
| 668 | - case 'pokemon_heatmap_points': |
|
| 669 | - $json=""; |
|
| 670 | - if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 671 | - $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 672 | - $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 673 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 674 | - $where = " WHERE pokemon.pokemon_id = ".$pokemon_id." " |
|
| 675 | - . "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 676 | - $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 677 | - $result = $mysqli->query($req); |
|
| 678 | - $points = array(); |
|
| 679 | - while ($result && $data = $result->fetch_object()) { |
|
| 680 | - $points[] = $data; |
|
| 681 | - } |
|
| 668 | + case 'pokemon_heatmap_points': |
|
| 669 | + $json=""; |
|
| 670 | + if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 671 | + $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 672 | + $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 673 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 674 | + $where = " WHERE pokemon.pokemon_id = ".$pokemon_id." " |
|
| 675 | + . "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'"; |
|
| 676 | + $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
|
| 677 | + $result = $mysqli->query($req); |
|
| 678 | + $points = array(); |
|
| 679 | + while ($result && $data = $result->fetch_object()) { |
|
| 680 | + $points[] = $data; |
|
| 681 | + } |
|
| 682 | 682 | |
| 683 | - $json = json_encode($points); |
|
| 684 | - } |
|
| 683 | + $json = json_encode($points); |
|
| 684 | + } |
|
| 685 | 685 | |
| 686 | - header('Content-Type: application/json'); |
|
| 687 | - echo $json; |
|
| 686 | + header('Content-Type: application/json'); |
|
| 687 | + echo $json; |
|
| 688 | 688 | |
| 689 | - break; |
|
| 689 | + break; |
|
| 690 | 690 | |
| 691 | 691 | |
| 692 | - case 'pokemon_graph_data': |
|
| 693 | - $json=""; |
|
| 694 | - if (isset($_GET['pokemon_id'])) { |
|
| 695 | - $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 696 | - $req = "SELECT COUNT(*) as total, " |
|
| 697 | - . "HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_hour |
|
| 692 | + case 'pokemon_graph_data': |
|
| 693 | + $json=""; |
|
| 694 | + if (isset($_GET['pokemon_id'])) { |
|
| 695 | + $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
|
| 696 | + $req = "SELECT COUNT(*) as total, " |
|
| 697 | + . "HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_hour |
|
| 698 | 698 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) as pokemonFiltered |
| 699 | 699 | GROUP BY disappear_hour |
| 700 | 700 | ORDER BY disappear_hour"; |
| 701 | - $result = $mysqli->query($req); |
|
| 702 | - $array = array_fill(0, 24, 0); |
|
| 703 | - while ($result && $data = $result->fetch_object()) { |
|
| 704 | - $array[$data->disappear_hour] = $data->total; |
|
| 701 | + $result = $mysqli->query($req); |
|
| 702 | + $array = array_fill(0, 24, 0); |
|
| 703 | + while ($result && $data = $result->fetch_object()) { |
|
| 704 | + $array[$data->disappear_hour] = $data->total; |
|
| 705 | + } |
|
| 706 | + // shift array because AM/PM starts at 1AM not 0:00 |
|
| 707 | + $array[] = $array[0]; |
|
| 708 | + array_shift($array); |
|
| 709 | + |
|
| 710 | + $json = json_encode($array); |
|
| 705 | 711 | } |
| 706 | - // shift array because AM/PM starts at 1AM not 0:00 |
|
| 707 | - $array[] = $array[0]; |
|
| 708 | - array_shift($array); |
|
| 709 | 712 | |
| 710 | - $json = json_encode($array); |
|
| 711 | - } |
|
| 713 | + header('Content-Type: application/json'); |
|
| 714 | + echo $json; |
|
| 712 | 715 | |
| 713 | - header('Content-Type: application/json'); |
|
| 714 | - echo $json; |
|
| 716 | + break; |
|
| 715 | 717 | |
| 716 | - break; |
|
| 717 | 718 | |
| 719 | + case 'postRequest': |
|
| 720 | + break; |
|
| 718 | 721 | |
| 719 | - case 'postRequest': |
|
| 722 | + default: |
|
| 723 | + echo "What do you mean?"; |
|
| 724 | + exit(); |
|
| 720 | 725 | break; |
| 721 | - |
|
| 722 | - default: |
|
| 723 | - echo "What do you mean?"; |
|
| 724 | - exit(); |
|
| 725 | - break; |
|
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | if ($postRequest!="") { |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | // Include & load the variables |
| 20 | 20 | // ############################ |
| 21 | 21 | |
| 22 | -$variables = SYS_PATH.'/core/json/variables.json'; |
|
| 23 | -$config = json_decode(file_get_contents($variables)); |
|
| 22 | +$variables = SYS_PATH.'/core/json/variables.json'; |
|
| 23 | +$config = json_decode(file_get_contents($variables)); |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | |
| 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; |
@@ -154,12 +154,12 @@ discard block |
||
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 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, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon |
|
| 157 | + $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon |
|
| 158 | 158 | WHERE pokemon_id IN (".implode(",", $mythic_pokemons).") |
| 159 | 159 | ORDER BY last_modified DESC LIMIT 0,12"; |
| 160 | 160 | } else { |
| 161 | 161 | // get last pokemon |
| 162 | - $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12"; |
|
| 162 | + $req = "SELECT pokemon_id, encounter_id, disappear_time, last_modified, (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, latitude, longitude, individual_attack, individual_defense, individual_stamina FROM pokemon ORDER BY last_modified DESC LIMIT 0,12"; |
|
| 163 | 163 | } |
| 164 | 164 | $result = $mysqli->query($req); |
| 165 | 165 | while ($data = $result->fetch_object()) { |
@@ -199,13 +199,13 @@ discard block |
||
| 199 | 199 | $html .= ' |
| 200 | 200 | <div class="progress" style="height: 15px; margin-bottom: 0"> |
| 201 | 201 | <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";> |
| 202 | - <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack .' |
|
| 202 | + <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span>'.$iv->attack.' |
|
| 203 | 203 | </div> |
| 204 | 204 | <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";> |
| 205 | - <span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense .' |
|
| 205 | + <span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span>'.$iv->defense.' |
|
| 206 | 206 | </div> |
| 207 | 207 | <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";> |
| 208 | - <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina .' |
|
| 208 | + <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span>'.$iv->stamina.' |
|
| 209 | 209 | </div> |
| 210 | 210 | </div>'; |
| 211 | 211 | } else { |
@@ -214,10 +214,10 @@ discard block |
||
| 214 | 214 | <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).'%"> |
| 215 | 215 | <span class="sr-only">'.$locales->IV_ATTACK.': '.$iv->attack.'</span> |
| 216 | 216 | </div> |
| 217 | - <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).'%"> |
|
| 217 | + <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).'%"> |
|
| 218 | 218 | <span class="sr-only">'.$locales->IV_DEFENSE.': '.$iv->defense.'</span> |
| 219 | 219 | </div> |
| 220 | - <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).'%"> |
|
| 220 | + <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).'%"> |
|
| 221 | 221 | <span class="sr-only">'.$locales->IV_STAMINA.': '.$iv->stamina.'</span> |
| 222 | 222 | </div> |
| 223 | 223 | </div>'; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | } else { |
| 277 | 277 | $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()"; |
| 278 | 278 | } |
| 279 | - $result = $mysqli->query($req); |
|
| 279 | + $result = $mysqli->query($req); |
|
| 280 | 280 | |
| 281 | 281 | $pokestops = []; |
| 282 | 282 | |
@@ -310,19 +310,19 @@ discard block |
||
| 310 | 310 | #################################### |
| 311 | 311 | |
| 312 | 312 | case 'update_gym': |
| 313 | - $teams = new stdClass(); |
|
| 314 | - $teams->mystic = 1; |
|
| 315 | - $teams->valor = 2; |
|
| 316 | - $teams->instinct = 3; |
|
| 313 | + $teams = new stdClass(); |
|
| 314 | + $teams->mystic = 1; |
|
| 315 | + $teams->valor = 2; |
|
| 316 | + $teams->instinct = 3; |
|
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | foreach ($teams as $team_name => $team_id) { |
| 320 | - $req = "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."' "; |
|
| 321 | - $result = $mysqli->query($req); |
|
| 322 | - $data = $result->fetch_object(); |
|
| 320 | + $req = "SELECT COUNT(DISTINCT(gym_id)) as total, ROUND(AVG(gym_points),0) as average_points FROM gym WHERE team_id = '".$team_id."' "; |
|
| 321 | + $result = $mysqli->query($req); |
|
| 322 | + $data = $result->fetch_object(); |
|
| 323 | 323 | |
| 324 | - $return[] = $data->total; |
|
| 325 | - $return[] = $data->average_points; |
|
| 324 | + $return[] = $data->total; |
|
| 325 | + $return[] = $data->average_points; |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | header('Content-Type: application/json'); |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | |
| 341 | 341 | case 'gym_map': |
| 342 | - $req = "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) as last_scanned FROM gym"; |
|
| 343 | - $result = $mysqli->query($req); |
|
| 342 | + $req = "SELECT gym_id, team_id, guard_pokemon_id, gym_points, latitude, longitude, (CONVERT_TZ(last_scanned, '+00:00', '".$time_offset."')) as last_scanned FROM gym"; |
|
| 343 | + $result = $mysqli->query($req); |
|
| 344 | 344 | |
| 345 | 345 | $gyms = []; |
| 346 | 346 | |
@@ -354,50 +354,50 @@ discard block |
||
| 354 | 354 | case 0: |
| 355 | 355 | $icon = 'map_white.png'; |
| 356 | 356 | $team = 'No Team (yet)'; |
| 357 | - $color = 'rgba(0, 0, 0, .6)'; |
|
| 357 | + $color = 'rgba(0, 0, 0, .6)'; |
|
| 358 | 358 | break; |
| 359 | 359 | |
| 360 | 360 | case 1: |
| 361 | 361 | $icon = 'map_blue_'; |
| 362 | 362 | $team = 'Team Mystic'; |
| 363 | - $color = 'rgba(74, 138, 202, .6)'; |
|
| 363 | + $color = 'rgba(74, 138, 202, .6)'; |
|
| 364 | 364 | break; |
| 365 | 365 | |
| 366 | 366 | case 2: |
| 367 | 367 | $icon = 'map_red_'; |
| 368 | 368 | $team = 'Team Valor'; |
| 369 | - $color = 'rgba(240, 68, 58, .6)'; |
|
| 369 | + $color = 'rgba(240, 68, 58, .6)'; |
|
| 370 | 370 | break; |
| 371 | 371 | |
| 372 | 372 | case 3: |
| 373 | 373 | $icon = 'map_yellow_'; |
| 374 | 374 | $team = 'Team Instinct'; |
| 375 | - $color = 'rgba(254, 217, 40, .6)'; |
|
| 375 | + $color = 'rgba(254, 217, 40, .6)'; |
|
| 376 | 376 | break; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | // Set gym level |
| 380 | - $data->gym_level=0; |
|
| 380 | + $data->gym_level = 0; |
|
| 381 | 381 | if ($data->gym_points < 2000) { |
| 382 | - $data->gym_level=1; |
|
| 382 | + $data->gym_level = 1; |
|
| 383 | 383 | } elseif ($data->gym_points < 4000) { |
| 384 | - $data->gym_level=2; |
|
| 384 | + $data->gym_level = 2; |
|
| 385 | 385 | } elseif ($data->gym_points < 8000) { |
| 386 | - $data->gym_level=3; |
|
| 386 | + $data->gym_level = 3; |
|
| 387 | 387 | } elseif ($data->gym_points < 12000) { |
| 388 | - $data->gym_level=4; |
|
| 388 | + $data->gym_level = 4; |
|
| 389 | 389 | } elseif ($data->gym_points < 16000) { |
| 390 | - $data->gym_level=5; |
|
| 390 | + $data->gym_level = 5; |
|
| 391 | 391 | } elseif ($data->gym_points < 20000) { |
| 392 | - $data->gym_level=6; |
|
| 392 | + $data->gym_level = 6; |
|
| 393 | 393 | } elseif ($data->gym_points < 30000) { |
| 394 | - $data->gym_level=7; |
|
| 394 | + $data->gym_level = 7; |
|
| 395 | 395 | } elseif ($data->gym_points < 40000) { |
| 396 | - $data->gym_level=8; |
|
| 396 | + $data->gym_level = 8; |
|
| 397 | 397 | } elseif ($data->gym_points < 50000) { |
| 398 | - $data->gym_level=9; |
|
| 398 | + $data->gym_level = 9; |
|
| 399 | 399 | } else { |
| 400 | - $data->gym_level=10; |
|
| 400 | + $data->gym_level = 10; |
|
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | ## I know, I revert commit 6e8d2e7 from @kiralydavid but the way it was done broke the page. |
@@ -441,8 +441,8 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | case 'gym_defenders': |
| 443 | 443 | $gym_id = $mysqli->real_escape_string($_GET['gym_id']); |
| 444 | - $req = "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) as last_scanned, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'"; |
|
| 445 | - $result = $mysqli->query($req); |
|
| 444 | + $req = "SELECT gymdetails.name as name, gymdetails.description as description, gym.gym_points as points, gymdetails.url as url, gym.team_id as team, (CONVERT_TZ(gym.last_scanned, '+00:00', '".$time_offset."')) as last_scanned, gym.guard_pokemon_id as guard_pokemon_id FROM gymdetails LEFT JOIN gym on gym.gym_id = gymdetails.gym_id WHERE gym.gym_id='".$gym_id."'"; |
|
| 445 | + $result = $mysqli->query($req); |
|
| 446 | 446 | $gymData['gymDetails']['gymInfos'] = false; |
| 447 | 447 | while ($data = $result->fetch_object()) { |
| 448 | 448 | $gymData['gymDetails']['gymInfos']['name'] = $data->name; |
@@ -458,35 +458,35 @@ discard block |
||
| 458 | 458 | $gymData['gymDetails']['gymInfos']['team'] = $data->team; |
| 459 | 459 | $gymData['gymDetails']['gymInfos']['guardPokemonId'] = $data->guard_pokemon_id; |
| 460 | 460 | if ($data->points < 2000) { |
| 461 | - $gymData['gymDetails']['gymInfos']['level']=1; |
|
| 461 | + $gymData['gymDetails']['gymInfos']['level'] = 1; |
|
| 462 | 462 | } elseif ($data->points < 4000) { |
| 463 | - $gymData['gymDetails']['gymInfos']['level']=2; |
|
| 463 | + $gymData['gymDetails']['gymInfos']['level'] = 2; |
|
| 464 | 464 | } elseif ($data->points < 8000) { |
| 465 | - $gymData['gymDetails']['gymInfos']['level']=3; |
|
| 465 | + $gymData['gymDetails']['gymInfos']['level'] = 3; |
|
| 466 | 466 | } elseif ($data->points < 12000) { |
| 467 | - $gymData['gymDetails']['gymInfos']['level']=4; |
|
| 467 | + $gymData['gymDetails']['gymInfos']['level'] = 4; |
|
| 468 | 468 | } elseif ($data->points < 16000) { |
| 469 | - $gymData['gymDetails']['gymInfos']['level']=5; |
|
| 469 | + $gymData['gymDetails']['gymInfos']['level'] = 5; |
|
| 470 | 470 | } elseif ($data->points < 20000) { |
| 471 | - $gymData['gymDetails']['gymInfos']['level']=6; |
|
| 471 | + $gymData['gymDetails']['gymInfos']['level'] = 6; |
|
| 472 | 472 | } elseif ($data->points < 30000) { |
| 473 | - $gymData['gymDetails']['gymInfos']['level']=7; |
|
| 473 | + $gymData['gymDetails']['gymInfos']['level'] = 7; |
|
| 474 | 474 | } elseif ($data->points < 40000) { |
| 475 | - $gymData['gymDetails']['gymInfos']['level']=8; |
|
| 475 | + $gymData['gymDetails']['gymInfos']['level'] = 8; |
|
| 476 | 476 | } elseif ($data->points < 50000) { |
| 477 | - $gymData['gymDetails']['gymInfos']['level']=9; |
|
| 477 | + $gymData['gymDetails']['gymInfos']['level'] = 9; |
|
| 478 | 478 | } else { |
| 479 | - $gymData['gymDetails']['gymInfos']['level']=10; |
|
| 479 | + $gymData['gymDetails']['gymInfos']['level'] = 10; |
|
| 480 | 480 | } |
| 481 | 481 | } |
| 482 | 482 | //print_r($gymData); |
| 483 | - $req = "SELECT DISTINCT gympokemon.pokemon_uid, " |
|
| 483 | + $req = "SELECT DISTINCT gympokemon.pokemon_uid, " |
|
| 484 | 484 | . "pokemon_id, iv_attack, iv_defense, iv_stamina, MAX(cp) as cp, gymmember.gym_id " |
| 485 | 485 | . "FROM gympokemon inner join gymmember on gympokemon.pokemon_uid=gymmember.pokemon_uid " |
| 486 | 486 | . "GROUP BY gympokemon.pokemon_uid, pokemon_id, iv_attack, iv_defense, iv_stamina, gym_id" |
| 487 | 487 | . " HAVING gymmember.gym_id='".$gym_id."' ORDER BY cp DESC"; |
| 488 | - $result = $mysqli->query($req); |
|
| 489 | - $i=0; |
|
| 488 | + $result = $mysqli->query($req); |
|
| 489 | + $i = 0; |
|
| 490 | 490 | |
| 491 | 491 | |
| 492 | 492 | |
@@ -508,10 +508,10 @@ discard block |
||
| 508 | 508 | <span class="sr-only">'.$locales->IV_ATTACK.' : '.$data->iv_attack.'</span>'.$data->iv_attack.' |
| 509 | 509 | </div> |
| 510 | 510 | <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"> |
| 511 | - <span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'. $data->iv_defense .' |
|
| 511 | + <span class="sr-only">'.$locales->IV_DEFENSE.' : '.$data->iv_defense.'</span>'.$data->iv_defense.' |
|
| 512 | 512 | </div> |
| 513 | 513 | <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"> |
| 514 | - <span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'. $data->iv_stamina .' |
|
| 514 | + <span class="sr-only">'.$locales->IV_STAMINA.' : '.$data->iv_stamina.'</span>'.$data->iv_stamina.' |
|
| 515 | 515 | </div> |
| 516 | 516 | </div> |
| 517 | 517 | </div>'; |
@@ -559,16 +559,16 @@ discard block |
||
| 559 | 559 | $name = ""; |
| 560 | 560 | $page = "0"; |
| 561 | 561 | $where = ""; |
| 562 | - $order=""; |
|
| 563 | - $team=0; |
|
| 564 | - $ranking=0; |
|
| 562 | + $order = ""; |
|
| 563 | + $team = 0; |
|
| 564 | + $ranking = 0; |
|
| 565 | 565 | if (isset($_GET['name'])) { |
| 566 | 566 | $trainer_name = mysqli_real_escape_string($mysqli, $_GET['name']); |
| 567 | 567 | $where = " HAVING name LIKE '%".$trainer_name."%'"; |
| 568 | 568 | } |
| 569 | - if (isset($_GET['team']) && $_GET['team']!=0) { |
|
| 569 | + if (isset($_GET['team']) && $_GET['team'] != 0) { |
|
| 570 | 570 | $team = mysqli_real_escape_string($mysqli, $_GET['team']); |
| 571 | - $where .= ($where==""?" HAVING":"AND ")." team = ".$team; |
|
| 571 | + $where .= ($where == "" ? " HAVING" : "AND ")." team = ".$team; |
|
| 572 | 572 | } |
| 573 | 573 | if (isset($_GET['page'])) { |
| 574 | 574 | $page = mysqli_real_escape_string($mysqli, $_GET['page']); |
@@ -579,16 +579,16 @@ discard block |
||
| 579 | 579 | |
| 580 | 580 | switch ($ranking) { |
| 581 | 581 | case 1: |
| 582 | - $order=" ORDER BY active DESC "; |
|
| 582 | + $order = " ORDER BY active DESC "; |
|
| 583 | 583 | break; |
| 584 | 584 | case 2: |
| 585 | - $order=" ORDER BY maxCp DESC "; |
|
| 585 | + $order = " ORDER BY maxCp DESC "; |
|
| 586 | 586 | break; |
| 587 | 587 | default: |
| 588 | - $order=" ORDER BY level DESC, active DESC "; |
|
| 588 | + $order = " ORDER BY level DESC, active DESC "; |
|
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $limit = " LIMIT ".($page*10).",10 "; |
|
| 591 | + $limit = " LIMIT ".($page * 10).",10 "; |
|
| 592 | 592 | |
| 593 | 593 | |
| 594 | 594 | $req = "SELECT trainer.*, count(actives_pokemons.trainer_name) as active, max(actives_pokemons.cp) as maxCp ". |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | $reqRanking = "SELECT count(1) as rank FROM trainer where trainer.level >= ".$trainer->level; |
| 608 | 608 | $resultRanking = $mysqli->query($reqRanking); |
| 609 | 609 | while ($data = $resultRanking->fetch_object()) { |
| 610 | - $trainer->rank = $data->rank ; |
|
| 610 | + $trainer->rank = $data->rank; |
|
| 611 | 611 | } |
| 612 | 612 | $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 ". |
| 613 | 613 | "FROM gympokemon INNER JOIN ". |
@@ -617,7 +617,7 @@ discard block |
||
| 617 | 617 | |
| 618 | 618 | $resultPkms = $mysqli->query($req); |
| 619 | 619 | $trainer->pokemons = array(); |
| 620 | - $active_gyms=0; |
|
| 620 | + $active_gyms = 0; |
|
| 621 | 621 | $pkmCount = 0; |
| 622 | 622 | while ($resultPkms && $dataPkm = $resultPkms->fetch_object()) { |
| 623 | 623 | $active_gyms++; |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | |
| 656 | 656 | |
| 657 | 657 | case 'pokemon_slider_init': |
| 658 | - $req = "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon"; |
|
| 658 | + $req = "SELECT MIN(pokemon.disappear_time) as min, MAX(pokemon.disappear_time) as max from pokemon"; |
|
| 659 | 659 | $result = $mysqli->query($req); |
| 660 | 660 | $bounds = $result->fetch_object(); |
| 661 | 661 | |
@@ -666,18 +666,18 @@ discard block |
||
| 666 | 666 | |
| 667 | 667 | |
| 668 | 668 | case 'pokemon_heatmap_points': |
| 669 | - $json=""; |
|
| 670 | - if (isset($_GET['start'])&&isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 671 | - $start = Date("Y-m-d H:i",(int)$_GET['start']); |
|
| 672 | - $end = Date("Y-m-d H:i",(int)$_GET['end']); |
|
| 669 | + $json = ""; |
|
| 670 | + if (isset($_GET['start']) && isset($_GET['end']) && isset($_GET['pokemon_id'])) { |
|
| 671 | + $start = Date("Y-m-d H:i", (int) $_GET['start']); |
|
| 672 | + $end = Date("Y-m-d H:i", (int) $_GET['end']); |
|
| 673 | 673 | $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
| 674 | 674 | $where = " WHERE pokemon.pokemon_id = ".$pokemon_id." " |
| 675 | 675 | . "AND pokemon.disappear_time BETWEEN '".$start."' AND '".$end."'"; |
| 676 | 676 | $req = "SELECT latitude, longitude FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 10000"; |
| 677 | - $result = $mysqli->query($req); |
|
| 677 | + $result = $mysqli->query($req); |
|
| 678 | 678 | $points = array(); |
| 679 | 679 | while ($result && $data = $result->fetch_object()) { |
| 680 | - $points[] = $data; |
|
| 680 | + $points[] = $data; |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | $json = json_encode($points); |
@@ -690,15 +690,15 @@ discard block |
||
| 690 | 690 | |
| 691 | 691 | |
| 692 | 692 | case 'pokemon_graph_data': |
| 693 | - $json=""; |
|
| 693 | + $json = ""; |
|
| 694 | 694 | if (isset($_GET['pokemon_id'])) { |
| 695 | 695 | $pokemon_id = mysqli_real_escape_string($mysqli, $_GET['pokemon_id']); |
| 696 | - $req = "SELECT COUNT(*) as total, " |
|
| 696 | + $req = "SELECT COUNT(*) as total, " |
|
| 697 | 697 | . "HOUR(CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_hour |
| 698 | 698 | FROM (SELECT disappear_time FROM pokemon WHERE pokemon_id = '".$pokemon_id."' ORDER BY disappear_time LIMIT 10000) as pokemonFiltered |
| 699 | 699 | GROUP BY disappear_hour |
| 700 | 700 | ORDER BY disappear_hour"; |
| 701 | - $result = $mysqli->query($req); |
|
| 701 | + $result = $mysqli->query($req); |
|
| 702 | 702 | $array = array_fill(0, 24, 0); |
| 703 | 703 | while ($result && $data = $result->fetch_object()) { |
| 704 | 704 | $array[$data->disappear_hour] = $data->total; |
@@ -725,30 +725,30 @@ discard block |
||
| 725 | 725 | break; |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | -if ($postRequest!="") { |
|
| 728 | +if ($postRequest != "") { |
|
| 729 | 729 | switch ($postRequest) { |
| 730 | 730 | case 'pokemon_live': |
| 731 | - $json=""; |
|
| 732 | - if (isset( $_POST['pokemon_id'])) { |
|
| 731 | + $json = ""; |
|
| 732 | + if (isset($_POST['pokemon_id'])) { |
|
| 733 | 733 | $pokemon_id = mysqli_real_escape_string($mysqli, $_POST['pokemon_id']); |
| 734 | - $inmap_pkms_filter=""; |
|
| 734 | + $inmap_pkms_filter = ""; |
|
| 735 | 735 | $where = " WHERE disappear_time >= UTC_TIMESTAMP() AND pokemon.pokemon_id = ".$pokemon_id; |
| 736 | 736 | |
| 737 | 737 | $reqTestIv = "SELECT MAX(individual_attack) as iv FROM pokemon ".$where; |
| 738 | - $resultTestIv = $mysqli->query($reqTestIv); |
|
| 738 | + $resultTestIv = $mysqli->query($reqTestIv); |
|
| 739 | 739 | $testIv = $resultTestIv->fetch_object(); |
| 740 | - if (isset( $_POST['inmap_pokemons'])&&( $_POST['inmap_pokemons']!="")) { |
|
| 740 | + if (isset($_POST['inmap_pokemons']) && ($_POST['inmap_pokemons'] != "")) { |
|
| 741 | 741 | foreach ($_POST['inmap_pokemons'] as $inmap) { |
| 742 | 742 | $inmap_pkms_filter .= "'".$inmap."',"; |
| 743 | 743 | } |
| 744 | 744 | $inmap_pkms_filter = rtrim($inmap_pkms_filter, ","); |
| 745 | 745 | $where .= " AND pokemon.encounter_id NOT IN (".$inmap_pkms_filter.") "; |
| 746 | 746 | } |
| 747 | - if ($testIv->iv!=null && isset( $_POST['ivMin'])&&( $_POST['ivMin']!="")) { |
|
| 747 | + if ($testIv->iv != null && isset($_POST['ivMin']) && ($_POST['ivMin'] != "")) { |
|
| 748 | 748 | $ivMin = mysqli_real_escape_string($mysqli, $_POST['ivMin']); |
| 749 | 749 | $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) >= (".$ivMin.") "; |
| 750 | 750 | } |
| 751 | - if ($testIv->iv!=null && isset( $_POST['ivMax'])&&( $_POST['ivMax']!="")) { |
|
| 751 | + if ($testIv->iv != null && isset($_POST['ivMax']) && ($_POST['ivMax'] != "")) { |
|
| 752 | 752 | $ivMax = mysqli_real_escape_string($mysqli, $_POST['ivMax']); |
| 753 | 753 | $where .= " AND ((100/45)*(individual_attack+individual_defense+individual_stamina)) <=(".$ivMax.") "; |
| 754 | 754 | } |
@@ -756,16 +756,16 @@ discard block |
||
| 756 | 756 | . " (CONVERT_TZ(disappear_time, '+00:00', '".$time_offset."')) as disappear_time_real, " |
| 757 | 757 | . " individual_attack, individual_defense, individual_stamina, move_1, move_2 " |
| 758 | 758 | . "FROM pokemon".$where." ORDER BY disappear_time DESC LIMIT 5000"; |
| 759 | - $result = $mysqli->query($req); |
|
| 759 | + $result = $mysqli->query($req); |
|
| 760 | 760 | $json = array(); |
| 761 | 761 | $json['points'] = array(); |
| 762 | 762 | $locale = array(); |
| 763 | - $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 763 | + $locale["ivAttack"] = $locales->IV_ATTACK; |
|
| 764 | 764 | $locale["ivDefense"] = $locales->IV_DEFENSE; |
| 765 | - $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 765 | + $locale["ivStamina"] = $locales->IV_STAMINA; |
|
| 766 | 766 | $json['locale'] = $locale; |
| 767 | 767 | while ($result && $data = $result->fetch_object()) { |
| 768 | - $pokeid=$data->pokemon_id; |
|
| 768 | + $pokeid = $data->pokemon_id; |
|
| 769 | 769 | $data->name = $pokemons->pokemon->$pokeid->name; |
| 770 | 770 | if (isset($data->move_1)) { |
| 771 | 771 | $move1 = $data->move_1; |
@@ -779,7 +779,7 @@ discard block |
||
| 779 | 779 | } else { |
| 780 | 780 | $data->charge_move = "?"; |
| 781 | 781 | } |
| 782 | - $json['points'][] = $data; |
|
| 782 | + $json['points'][] = $data; |
|
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | $json = json_encode($json); |