@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $tree = $temp->evolutions; |
| 190 | 190 | $resultsTemp = get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1); |
| 191 | 191 | if (is_null($resultsTemp)) { // Woops |
| 192 | - return null; |
|
| 192 | + return null; |
|
| 193 | 193 | } |
| 194 | 194 | $results = $arr = array(); |
| 195 | 195 | foreach ($resultsTemp as $res) { // Remove all above max_pokemon |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | if (is_null($results)) { // Not in current gen |
| 201 | - return null; |
|
| 201 | + return null; |
|
| 202 | 202 | } |
| 203 | 203 | $count = count($results); |
| 204 | 204 | $i = 0; |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | $i = 0; |
| 205 | 205 | foreach ($results as $res) { // Check if above, equal or bellow center |
| 206 | 206 | if ($count != 1) { |
| 207 | - $num = $i / ($count-1); |
|
| 207 | + $num = $i / ($count - 1); |
|
| 208 | 208 | if ($num < 0.5) { |
| 209 | 209 | $res->array_sufix = "_up"; |
| 210 | 210 | } elseif ($num > 0.5) { |
@@ -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,29 +181,37 @@ 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 $trees; |
| 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 | $resultsTemp = get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1); |
| 191 | - if (is_null($resultsTemp)) { // Woops |
|
| 196 | + if (is_null($resultsTemp)) { |
|
| 197 | +// Woops |
|
| 192 | 198 | return null; |
| 193 | 199 | } |
| 194 | 200 | $results = $arr = array(); |
| 195 | - foreach ($resultsTemp as $res) { // Remove all above max_pokemon |
|
| 201 | + foreach ($resultsTemp as $res) { |
|
| 202 | +// Remove all above max_pokemon |
|
| 196 | 203 | if ($res->id <= $max_pokemon) { |
| 197 | 204 | $results[] = $res; |
| 198 | 205 | } |
| 199 | 206 | } |
| 200 | - if (is_null($results)) { // Not in current gen |
|
| 207 | + if (is_null($results)) { |
|
| 208 | +// Not in current gen |
|
| 201 | 209 | return null; |
| 202 | 210 | } |
| 203 | 211 | $count = count($results); |
| 204 | 212 | $i = 0; |
| 205 | - foreach ($results as $res) { // Check if above, equal or bellow center |
|
| 213 | + foreach ($results as $res) { |
|
| 214 | +// Check if above, equal or bellow center |
|
| 206 | 215 | if ($count != 1) { |
| 207 | 216 | $num = $i / ($count-1); |
| 208 | 217 | if ($num < 0.5) { |
@@ -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; |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | <?php |
| 265 | 265 | $tree = array($pokemon->tree); |
| 266 | - $depth = (get_depth($tree)+1)/2; |
|
| 266 | + $depth = (get_depth($tree) + 1) / 2; |
|
| 267 | 267 | ?> |
| 268 | 268 | |
| 269 | 269 | <h3 class="col-md-12 text-center sub-title"><strong><?= $locales->POKEMON_EVOLUTIONS ?></strong></h3> |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | |
| 272 | 272 | <?php |
| 273 | 273 | for ($i = 0; $i < $depth * 2 - 1; $i++) { |
| 274 | - $i_id = intval(($i+1)/2); |
|
| 274 | + $i_id = intval(($i + 1) / 2); |
|
| 275 | 275 | $data = get_tree_at_depth($tree, $i_id, $config->system->max_pokemon); |
| 276 | 276 | ?> |
| 277 | 277 | |
@@ -281,9 +281,9 @@ discard block |
||
| 281 | 281 | <?php foreach ($data as $obj) { |
| 282 | 282 | $obj_id = $obj->id; |
| 283 | 283 | $tree_pokemon = $pokemons->pokemon->$obj_id; |
| 284 | - $link = "/pokemon/" . $obj_id; |
|
| 284 | + $link = "/pokemon/".$obj_id; |
|
| 285 | 285 | |
| 286 | - if ($i%2 == 0) { ?> |
|
| 286 | + if ($i % 2 == 0) { ?> |
|
| 287 | 287 | |
| 288 | 288 | <div> |
| 289 | 289 | <a href="<?= $link ?>"><img src="<?= $tree_pokemon->img ?>" alt="<?= $tree_pokemon->name ?>" class="img"></a> |
@@ -296,10 +296,10 @@ discard block |
||
| 296 | 296 | <img src="core/img/arrow<?=$obj->array_sufix?>.png" alt="Arrow" class="img"> |
| 297 | 297 | <p class="pkmn-name"> |
| 298 | 298 | <?php |
| 299 | - echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 299 | + echo $obj->candies.' '.$locales->POKEMON_CANDIES; |
|
| 300 | 300 | if (!is_null($obj->item)) { |
| 301 | - $itemName = 'ITEM_' . $obj->item; |
|
| 302 | - echo '<br>+ ' . $locales->$itemName; |
|
| 301 | + $itemName = 'ITEM_'.$obj->item; |
|
| 302 | + echo '<br>+ '.$locales->$itemName; |
|
| 303 | 303 | } else { |
| 304 | 304 | echo '<br> </br>'; |
| 305 | 305 | } |
@@ -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,30 +25,30 @@ 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 | - $gym_id = $data->gym_id; |
|
| 40 | - $newraiddatas[$pid]['count'] += $count; |
|
| 41 | - $newraiddatas[$pid]['last_update'] = $data->start_timestamp; |
|
| 42 | - $newraiddatas[$pid]['end_time'] = $data->end_time_real; |
|
| 43 | - $newraiddatas[$pid]['latitude'] = $data->latitude; |
|
| 44 | - $newraiddatas[$pid]['longitude'] = $data->longitude; |
|
| 45 | - } elseif (is_null($newraiddatas[$pid]['count'])) { |
|
| 46 | - $newraiddatas[$pid]['count'] = 0; |
|
| 47 | - $newraiddatas[$pid]['last_update'] = 0; |
|
| 48 | - $newraiddatas[$pid]['end_time'] = null; |
|
| 49 | - $newraiddatas[$pid]['latitude'] = null; |
|
| 50 | - $newraiddatas[$pid]['longitude'] = null; |
|
| 51 | - } |
|
| 37 | + if ($count != 0) { |
|
| 38 | + echo $count; |
|
| 39 | + $gym_id = $data->gym_id; |
|
| 40 | + $newraiddatas[$pid]['count'] += $count; |
|
| 41 | + $newraiddatas[$pid]['last_update'] = $data->start_timestamp; |
|
| 42 | + $newraiddatas[$pid]['end_time'] = $data->end_time_real; |
|
| 43 | + $newraiddatas[$pid]['latitude'] = $data->latitude; |
|
| 44 | + $newraiddatas[$pid]['longitude'] = $data->longitude; |
|
| 45 | + } elseif (is_null($newraiddatas[$pid]['count'])) { |
|
| 46 | + $newraiddatas[$pid]['count'] = 0; |
|
| 47 | + $newraiddatas[$pid]['last_update'] = 0; |
|
| 48 | + $newraiddatas[$pid]['end_time'] = null; |
|
| 49 | + $newraiddatas[$pid]['latitude'] = null; |
|
| 50 | + $newraiddatas[$pid]['longitude'] = null; |
|
| 51 | + } |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Write to file |
@@ -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); |