@@ -48,7 +48,7 @@ |
||
| 48 | 48 | $pokedatas = json_decode(file_get_contents($pokemonstats_file), true); |
| 49 | 49 | } |
| 50 | 50 | if (is_file($pokedex_raids_file)) { |
| 51 | - $raiddatas = json_decode(file_get_contents($pokedex_raids_file), true); |
|
| 51 | + $raiddatas = json_decode(file_get_contents($pokedex_raids_file), true); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | include_once(SYS_PATH.'/functions.php'); |
| 13 | 13 | |
| 14 | 14 | // Load timezone |
| 15 | -include_once(SYS_PATH. '/core/process/timezone.loader.php'); |
|
| 15 | +include_once(SYS_PATH.'/core/process/timezone.loader.php'); |
|
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | // Load variables.json |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $pokedatas = json_decode(file_get_contents($pokemonstats_file), true); |
| 54 | 54 | } |
| 55 | 55 | if (is_file($pokedex_raids_file)) { |
| 56 | - $raiddatas = json_decode(file_get_contents($pokedex_raids_file), true); |
|
| 56 | + $raiddatas = json_decode(file_get_contents($pokedex_raids_file), true); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -211,14 +211,14 @@ |
||
| 211 | 211 | $pokemon->spawn_count = $pokemon_counts->$pokeid; |
| 212 | 212 | |
| 213 | 213 | // Add raid data to array |
| 214 | - $raid_data = $raid_counts->$pokeid; |
|
| 215 | - if (isset($raid_data->end_time)) { |
|
| 216 | - $pokemon->last_raid_seen = strtotime($raid_data->end_time); |
|
| 217 | - $pokemon->last_raid_position = new stdClass(); |
|
| 218 | - $pokemon->last_raid_position->latitude = $raid_data->latitude; |
|
| 219 | - $pokemon->last_raid_position->longitude = $raid_data->longitude; |
|
| 220 | - } |
|
| 221 | - $pokemon->raid_count = $raid_data->count; |
|
| 214 | + $raid_data = $raid_counts->$pokeid; |
|
| 215 | + if (isset($raid_data->end_time)) { |
|
| 216 | + $pokemon->last_raid_seen = strtotime($raid_data->end_time); |
|
| 217 | + $pokemon->last_raid_position = new stdClass(); |
|
| 218 | + $pokemon->last_raid_position->latitude = $raid_data->latitude; |
|
| 219 | + $pokemon->last_raid_position->longitude = $raid_data->longitude; |
|
| 220 | + } |
|
| 221 | + $pokemon->raid_count = $raid_data->count; |
|
| 222 | 222 | |
| 223 | 223 | // Calculate and add rarities to array |
| 224 | 224 | $spawn_rate = $pokemons_rarity->$pokeid->rate; |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | JOIN gym g |
| 20 | 20 | JOIN (SELECT count(*) as count |
| 21 | 21 | FROM raid |
| 22 | - " . $where . " |
|
| 22 | + " . $where." |
|
| 23 | 23 | ) x |
| 24 | 24 | ON r.gym_id = g.gym_id |
| 25 | - " . $where . " |
|
| 25 | + " . $where." |
|
| 26 | 26 | ORDER BY start DESC |
| 27 | 27 | LIMIT 0,1"; |
| 28 | 28 | $result = $mysqli->query($req); |
@@ -6,15 +6,15 @@ discard block |
||
| 6 | 6 | $newraiddatas = $raiddatas; |
| 7 | 7 | |
| 8 | 8 | for ($pid = 1; $pid <= $maxpid; $pid++) { |
| 9 | - // Get count since update |
|
| 10 | - if (isset($raiddatas[$pid]['last_update'])) { |
|
| 11 | - $last_update = $raiddatas[$pid]['last_update']; |
|
| 12 | - } else { |
|
| 13 | - $last_update = 0; |
|
| 14 | - } |
|
| 9 | + // Get count since update |
|
| 10 | + if (isset($raiddatas[$pid]['last_update'])) { |
|
| 11 | + $last_update = $raiddatas[$pid]['last_update']; |
|
| 12 | + } else { |
|
| 13 | + $last_update = 0; |
|
| 14 | + } |
|
| 15 | 15 | |
| 16 | - $where = "WHERE pokemon_id = '".$pid."' && UNIX_TIMESTAMP(start) > '".$last_update."'"; |
|
| 17 | - $req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".$time_offset."')) AS end_time_real, latitude, longitude, count |
|
| 16 | + $where = "WHERE pokemon_id = '".$pid."' && UNIX_TIMESTAMP(start) > '".$last_update."'"; |
|
| 17 | + $req = "SELECT UNIX_TIMESTAMP(start) as start_timestamp, end, (CONVERT_TZ(end, '+00:00', '".$time_offset."')) AS end_time_real, latitude, longitude, count |
|
| 18 | 18 | FROM raid r |
| 19 | 19 | JOIN gym g |
| 20 | 20 | JOIN (SELECT count(*) as count |
@@ -25,29 +25,29 @@ discard block |
||
| 25 | 25 | " . $where . " |
| 26 | 26 | ORDER BY start DESC |
| 27 | 27 | LIMIT 0,1"; |
| 28 | - $result = $mysqli->query($req); |
|
| 29 | - $data = $result->fetch_object(); |
|
| 28 | + $result = $mysqli->query($req); |
|
| 29 | + $data = $result->fetch_object(); |
|
| 30 | 30 | |
| 31 | - if (isset($data)) { |
|
| 32 | - $count = $data->count; |
|
| 33 | - } else { |
|
| 34 | - $count = 0; |
|
| 35 | - } |
|
| 31 | + if (isset($data)) { |
|
| 32 | + $count = $data->count; |
|
| 33 | + } else { |
|
| 34 | + $count = 0; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - if ($count != 0) { |
|
| 38 | - echo $count; |
|
| 39 | - $newraiddatas[$pid]['count'] += $count; |
|
| 40 | - $newraiddatas[$pid]['last_update'] = $data->start_timestamp; |
|
| 41 | - $newraiddatas[$pid]['end_time'] = $data->end_time_real; |
|
| 42 | - $newraiddatas[$pid]['latitude'] = $data->latitude; |
|
| 43 | - $newraiddatas[$pid]['longitude'] = $data->longitude; |
|
| 44 | - } elseif (is_null($newraiddatas[$pid]['count'])) { |
|
| 45 | - $newraiddatas[$pid]['count'] = 0; |
|
| 46 | - $newraiddatas[$pid]['last_update'] = 0; |
|
| 47 | - $newraiddatas[$pid]['end_time'] = null; |
|
| 48 | - $newraiddatas[$pid]['latitude'] = null; |
|
| 49 | - $newraiddatas[$pid]['longitude'] = null; |
|
| 50 | - } |
|
| 37 | + if ($count != 0) { |
|
| 38 | + echo $count; |
|
| 39 | + $newraiddatas[$pid]['count'] += $count; |
|
| 40 | + $newraiddatas[$pid]['last_update'] = $data->start_timestamp; |
|
| 41 | + $newraiddatas[$pid]['end_time'] = $data->end_time_real; |
|
| 42 | + $newraiddatas[$pid]['latitude'] = $data->latitude; |
|
| 43 | + $newraiddatas[$pid]['longitude'] = $data->longitude; |
|
| 44 | + } elseif (is_null($newraiddatas[$pid]['count'])) { |
|
| 45 | + $newraiddatas[$pid]['count'] = 0; |
|
| 46 | + $newraiddatas[$pid]['last_update'] = 0; |
|
| 47 | + $newraiddatas[$pid]['end_time'] = null; |
|
| 48 | + $newraiddatas[$pid]['latitude'] = null; |
|
| 49 | + $newraiddatas[$pid]['longitude'] = null; |
|
| 50 | + } |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // Write to file |
@@ -263,14 +263,14 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | <?php |
| 265 | 265 | $tree = array($pokemon->tree); |
| 266 | - $depth = get_depth($tree); |
|
| 267 | - ?> |
|
| 266 | + $depth = get_depth($tree); |
|
| 267 | + ?> |
|
| 268 | 268 | |
| 269 | 269 | <h3 class="col-md-12 text-center sub-title"><strong><?= $locales->POKEMON_EVOLUTIONS ?></strong></h3> |
| 270 | 270 | <div class="col-md-12 flex-container results"> |
| 271 | 271 | |
| 272 | 272 | <?php |
| 273 | - $skip = false; |
|
| 273 | + $skip = false; |
|
| 274 | 274 | for ($i = 0; $i < $depth; $i++) { |
| 275 | 275 | $i_id = intval(($i+1)/2); |
| 276 | 276 | $data = get_tree_at_depth($tree, $i_id, $config->system->max_pokemon); |
@@ -302,9 +302,9 @@ discard block |
||
| 302 | 302 | $itemName = 'ITEM_' . $obj->item; |
| 303 | 303 | echo '<br>+ ' . $locales->$itemName; |
| 304 | 304 | } elseif (!is_null($obj->info)) { |
| 305 | - $infoName = 'INFO_' . $obj->info; |
|
| 306 | - echo '<br>(' . $locales->$infoName . ')'; |
|
| 307 | - } |
|
| 305 | + $infoName = 'INFO_' . $obj->info; |
|
| 306 | + echo '<br>(' . $locales->$infoName . ')'; |
|
| 307 | + } |
|
| 308 | 308 | else { |
| 309 | 309 | echo '<br> </br>'; |
| 310 | 310 | } |
@@ -317,11 +317,11 @@ discard block |
||
| 317 | 317 | ?> |
| 318 | 318 | </div> |
| 319 | 319 | <?php |
| 320 | - } elseif ($skip) { |
|
| 321 | - $skip = false; |
|
| 322 | - } else { |
|
| 323 | - $skip = true; |
|
| 324 | - } |
|
| 320 | + } elseif ($skip) { |
|
| 321 | + $skip = false; |
|
| 322 | + } else { |
|
| 323 | + $skip = true; |
|
| 324 | + } |
|
| 325 | 325 | } |
| 326 | 326 | ?> |
| 327 | 327 | </div> |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | <?php |
| 273 | 273 | $skip = false; |
| 274 | 274 | for ($i = 0; $i < $depth; $i++) { |
| 275 | - $i_id = intval(($i+1)/2); |
|
| 275 | + $i_id = intval(($i + 1) / 2); |
|
| 276 | 276 | $data = get_tree_at_depth($tree, $i_id, $config->system->max_pokemon); |
| 277 | 277 | ?> |
| 278 | 278 | |
@@ -282,9 +282,9 @@ discard block |
||
| 282 | 282 | <?php foreach ($data as $obj) { |
| 283 | 283 | $obj_id = $obj->id; |
| 284 | 284 | $tree_pokemon = $pokemons->pokemon->$obj_id; |
| 285 | - $link = "/pokemon/" . $obj_id; |
|
| 285 | + $link = "/pokemon/".$obj_id; |
|
| 286 | 286 | |
| 287 | - if ($i%2 == 0) { ?> |
|
| 287 | + if ($i % 2 == 0) { ?> |
|
| 288 | 288 | |
| 289 | 289 | <div> |
| 290 | 290 | <a href="<?= $link ?>"><img src="<?= $tree_pokemon->img ?>" alt="<?= $tree_pokemon->name ?>" class="img"></a> |
@@ -297,13 +297,13 @@ discard block |
||
| 297 | 297 | <img src="core/img/arrow<?=$obj->array_sufix?>.png" alt="Arrow" class="img"> |
| 298 | 298 | <p class="pkmn-name"> |
| 299 | 299 | <?php |
| 300 | - echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 300 | + echo $obj->candies.' '.$locales->POKEMON_CANDIES; |
|
| 301 | 301 | if (!is_null($obj->item)) { |
| 302 | - $itemName = 'ITEM_' . $obj->item; |
|
| 303 | - echo '<br>+ ' . $locales->$itemName; |
|
| 302 | + $itemName = 'ITEM_'.$obj->item; |
|
| 303 | + echo '<br>+ '.$locales->$itemName; |
|
| 304 | 304 | } elseif (!is_null($obj->info)) { |
| 305 | - $infoName = 'INFO_' . $obj->info; |
|
| 306 | - echo '<br>(' . $locales->$infoName . ')'; |
|
| 305 | + $infoName = 'INFO_'.$obj->info; |
|
| 306 | + echo '<br>('.$locales->$infoName.')'; |
|
| 307 | 307 | } |
| 308 | 308 | else { |
| 309 | 309 | echo '<br> </br>'; |
@@ -304,8 +304,7 @@ |
||
| 304 | 304 | } elseif (!is_null($obj->info)) { |
| 305 | 305 | $infoName = 'INFO_' . $obj->info; |
| 306 | 306 | echo '<br>(' . $locales->$infoName . ')'; |
| 307 | - } |
|
| 308 | - else { |
|
| 307 | + } else { |
|
| 309 | 308 | echo '<br> </br>'; |
| 310 | 309 | } |
| 311 | 310 | ?> |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) { |
| 184 | 184 | if ($depth == $currentDepth) { // Found depth |
| 185 | - return tree_remove_bellow($trees, $max_pokemon); |
|
| 185 | + return tree_remove_bellow($trees, $max_pokemon); |
|
| 186 | 186 | } else { // Go deeper |
| 187 | 187 | $arr = array(); |
| 188 | 188 | foreach ($trees as $temp) { // Go into all trees |
@@ -191,35 +191,35 @@ discard block |
||
| 191 | 191 | $count = count($results); |
| 192 | 192 | $i = 0; |
| 193 | 193 | if (!is_null($results)) { |
| 194 | - foreach ($results as $res) { // Check if above, equal or bellow center |
|
| 195 | - if ($count != 1 && $depth - $currentDepth == 1) { |
|
| 196 | - $num = $i / ($count - 1); |
|
| 197 | - if ($num < 0.5) { |
|
| 198 | - $res->array_sufix = "_up"; |
|
| 199 | - } elseif ($num > 0.5) { |
|
| 200 | - $res->array_sufix = "_down"; |
|
| 201 | - } |
|
| 202 | - } |
|
| 203 | - $arr[] = $res; |
|
| 204 | - $i++; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - echo "<br>"; |
|
| 194 | + foreach ($results as $res) { // Check if above, equal or bellow center |
|
| 195 | + if ($count != 1 && $depth - $currentDepth == 1) { |
|
| 196 | + $num = $i / ($count - 1); |
|
| 197 | + if ($num < 0.5) { |
|
| 198 | + $res->array_sufix = "_up"; |
|
| 199 | + } elseif ($num > 0.5) { |
|
| 200 | + $res->array_sufix = "_down"; |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | + $arr[] = $res; |
|
| 204 | + $i++; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + echo "<br>"; |
|
| 208 | 208 | } |
| 209 | - return $arr; |
|
| 209 | + return $arr; |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | function tree_remove_bellow($tree, $max_pokemon) |
| 214 | 214 | { |
| 215 | - if (is_null($tree)) { |
|
| 216 | - return null; |
|
| 217 | - } |
|
| 218 | - $arr = array(); |
|
| 219 | - foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 220 | - if ($item->id <= $max_pokemon) { |
|
| 221 | - $arr[] = $item; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - return $arr; |
|
| 215 | + if (is_null($tree)) { |
|
| 216 | + return null; |
|
| 217 | + } |
|
| 218 | + $arr = array(); |
|
| 219 | + foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 220 | + if ($item->id <= $max_pokemon) { |
|
| 221 | + $arr[] = $item; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + return $arr; |
|
| 225 | 225 | } |
| 226 | 226 | \ No newline at end of file |
@@ -171,7 +171,8 @@ discard block |
||
| 171 | 171 | return $gym_level; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | -function get_depth($arr) { |
|
| 174 | +function get_depth($arr) |
|
| 175 | +{ |
|
| 175 | 176 | $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); |
| 176 | 177 | $depth = 0; |
| 177 | 178 | foreach ($it as $v) { |
@@ -180,18 +181,23 @@ discard block |
||
| 180 | 181 | return $depth; |
| 181 | 182 | } |
| 182 | 183 | |
| 183 | -function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) { |
|
| 184 | - if ($depth == $currentDepth) { // Found depth |
|
| 184 | +function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) |
|
| 185 | +{ |
|
| 186 | + if ($depth == $currentDepth) { |
|
| 187 | +// Found depth |
|
| 185 | 188 | return tree_remove_bellow($trees, $max_pokemon); |
| 186 | - } else { // Go deeper |
|
| 189 | + } else { |
|
| 190 | +// Go deeper |
|
| 187 | 191 | $arr = array(); |
| 188 | - foreach ($trees as $temp) { // Go into all trees |
|
| 192 | + foreach ($trees as $temp) { |
|
| 193 | +// Go into all trees |
|
| 189 | 194 | $tree = $temp->evolutions; |
| 190 | 195 | $results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon); |
| 191 | 196 | $count = count($results); |
| 192 | 197 | $i = 0; |
| 193 | 198 | if (!is_null($results)) { |
| 194 | - foreach ($results as $res) { // Check if above, equal or bellow center |
|
| 199 | + foreach ($results as $res) { |
|
| 200 | +// Check if above, equal or bellow center |
|
| 195 | 201 | if ($count != 1 && $depth - $currentDepth == 1) { |
| 196 | 202 | $num = $i / ($count - 1); |
| 197 | 203 | if ($num < 0.5) { |
@@ -216,7 +222,8 @@ discard block |
||
| 216 | 222 | return null; |
| 217 | 223 | } |
| 218 | 224 | $arr = array(); |
| 219 | - foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 225 | + foreach ($tree as $item) { |
|
| 226 | +// Check if above, equal or bellow center |
|
| 220 | 227 | if ($item->id <= $max_pokemon) { |
| 221 | 228 | $arr[] = $item; |
| 222 | 229 | } |