@@ -19,8 +19,8 @@ |
||
| 19 | 19 | |
| 20 | 20 | $rarityarray = array(); |
| 21 | 21 | foreach ($counts as $poke_id => $total) { |
| 22 | - $rarity = $pokemons->pokemon->$poke_id->rarity; |
|
| 23 | - isset($rarityarray[$rarity]) ? $rarityarray[$rarity] += $total : $rarityarray[$rarity] = $total; |
|
| 22 | + $rarity = $pokemons->pokemon->$poke_id->rarity; |
|
| 23 | + isset($rarityarray[$rarity]) ? $rarityarray[$rarity] += $total : $rarityarray[$rarity] = $total; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // Set amount of Pokemon for each rarity to 0 if there weren't any at that time |
@@ -8,73 +8,73 @@ |
||
| 8 | 8 | |
| 9 | 9 | $captcha_file = SYS_PATH.'/core/json/captcha.stats.json'; |
| 10 | 10 | if (is_file($captcha_file)) { |
| 11 | - $capdatas = json_decode(file_get_contents($captcha_file), true); |
|
| 12 | - // Trim json stats files to last 7 days of data |
|
| 13 | - $capdatas = trim_stats_json($capdatas, $timestamp_lastweek); |
|
| 11 | + $capdatas = json_decode(file_get_contents($captcha_file), true); |
|
| 12 | + // Trim json stats files to last 7 days of data |
|
| 13 | + $capdatas = trim_stats_json($capdatas, $timestamp_lastweek); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | $variables_secret = SYS_PATH.'/core/json/variables.secret.json'; |
| 17 | 17 | $config_secret = json_decode(file_get_contents($variables_secret)); |
| 18 | 18 | |
| 19 | 19 | if ('' == $config_secret->captcha_key) { |
| 20 | - $captcha['timestamp'] = $timestamp; |
|
| 21 | - // get amount of accounts requiring a captcha |
|
| 22 | - $data = $manager->getCaptchaCount(); |
|
| 23 | - $captcha['captcha_accs'] = $data->total; |
|
| 24 | - // Add the datas in file |
|
| 25 | - $capdatas[] = $captcha; |
|
| 20 | + $captcha['timestamp'] = $timestamp; |
|
| 21 | + // get amount of accounts requiring a captcha |
|
| 22 | + $data = $manager->getCaptchaCount(); |
|
| 23 | + $captcha['captcha_accs'] = $data->total; |
|
| 24 | + // Add the datas in file |
|
| 25 | + $capdatas[] = $captcha; |
|
| 26 | 26 | } else { |
| 27 | - if (!empty($capdatas)) { |
|
| 28 | - $lastCaptcha = array_pop($capdatas); |
|
| 29 | - } else { |
|
| 30 | - $lastCaptcha['timestamp'] = strtotime('-7 days', strtotime(date('Y-m-d'))); |
|
| 31 | - } |
|
| 32 | - $lastCaptchaDate = date('Y-m-d', $lastCaptcha['timestamp']); |
|
| 33 | - $startTime = strtotime($lastCaptchaDate); |
|
| 34 | - $endTime = strtotime(date('Y-m-d')) + date('Z'); |
|
| 35 | - $timeDiff = abs($endTime - $startTime); |
|
| 36 | - $numberDays = intval($timeDiff / 86400); // 86400 seconds in one day |
|
| 37 | - if ($numberDays > 7) { |
|
| 38 | - $numberDays = 7; |
|
| 39 | - } |
|
| 40 | - while ($numberDays >= 0) { |
|
| 41 | - $day = $endTime - ($numberDays * 86400); |
|
| 42 | - $captchaUrl = |
|
| 43 | - 'http://2captcha.com/res.php?key='. |
|
| 44 | - $config_secret->captcha_key.'&action=getstats&date='.date('Y-m-d', $day); |
|
| 27 | + if (!empty($capdatas)) { |
|
| 28 | + $lastCaptcha = array_pop($capdatas); |
|
| 29 | + } else { |
|
| 30 | + $lastCaptcha['timestamp'] = strtotime('-7 days', strtotime(date('Y-m-d'))); |
|
| 31 | + } |
|
| 32 | + $lastCaptchaDate = date('Y-m-d', $lastCaptcha['timestamp']); |
|
| 33 | + $startTime = strtotime($lastCaptchaDate); |
|
| 34 | + $endTime = strtotime(date('Y-m-d')) + date('Z'); |
|
| 35 | + $timeDiff = abs($endTime - $startTime); |
|
| 36 | + $numberDays = intval($timeDiff / 86400); // 86400 seconds in one day |
|
| 37 | + if ($numberDays > 7) { |
|
| 38 | + $numberDays = 7; |
|
| 39 | + } |
|
| 40 | + while ($numberDays >= 0) { |
|
| 41 | + $day = $endTime - ($numberDays * 86400); |
|
| 42 | + $captchaUrl = |
|
| 43 | + 'http://2captcha.com/res.php?key='. |
|
| 44 | + $config_secret->captcha_key.'&action=getstats&date='.date('Y-m-d', $day); |
|
| 45 | 45 | |
| 46 | - $ch = curl_init(); |
|
| 47 | - curl_setopt($ch, CURLOPT_URL, $captchaUrl); |
|
| 48 | - curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); |
|
| 49 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 50 | - $fileContents = curl_exec($ch); |
|
| 51 | - if (curl_errno($ch)) { |
|
| 52 | - echo curl_error($ch); |
|
| 53 | - echo "\n<br />"; |
|
| 54 | - $fileContents = ''; |
|
| 55 | - } else { |
|
| 56 | - curl_close($ch); |
|
| 57 | - } |
|
| 46 | + $ch = curl_init(); |
|
| 47 | + curl_setopt($ch, CURLOPT_URL, $captchaUrl); |
|
| 48 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); |
|
| 49 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
| 50 | + $fileContents = curl_exec($ch); |
|
| 51 | + if (curl_errno($ch)) { |
|
| 52 | + echo curl_error($ch); |
|
| 53 | + echo "\n<br />"; |
|
| 54 | + $fileContents = ''; |
|
| 55 | + } else { |
|
| 56 | + curl_close($ch); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - if (!is_string($fileContents) || !strlen($fileContents)) { |
|
| 60 | - echo 'Failed to get contents.'; |
|
| 61 | - $fileContents = ''; |
|
| 62 | - } |
|
| 63 | - $capXml = simplexml_load_string($fileContents); |
|
| 59 | + if (!is_string($fileContents) || !strlen($fileContents)) { |
|
| 60 | + echo 'Failed to get contents.'; |
|
| 61 | + $fileContents = ''; |
|
| 62 | + } |
|
| 63 | + $capXml = simplexml_load_string($fileContents); |
|
| 64 | 64 | |
| 65 | - foreach ($capXml as $key => $value) { |
|
| 66 | - if ((0 == $numberDays |
|
| 67 | - && ((int) $value->Attributes()->hour >= (int) date('H', $lastCaptcha['timestamp']) |
|
| 68 | - && ((int) $value->Attributes()->hour <= (int) date('H'))) |
|
| 69 | - ) || $numberDays > 0) { |
|
| 70 | - $captcha['timestamp'] = |
|
| 71 | - strtotime(date('Y-m-d', $day).' '.$value->Attributes()->hour.':00') + date('Z'); |
|
| 72 | - $captcha['captcha_accs'] = (string) $value->volume; |
|
| 73 | - $capdatas[] = $captcha; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - --$numberDays; |
|
| 77 | - } |
|
| 65 | + foreach ($capXml as $key => $value) { |
|
| 66 | + if ((0 == $numberDays |
|
| 67 | + && ((int) $value->Attributes()->hour >= (int) date('H', $lastCaptcha['timestamp']) |
|
| 68 | + && ((int) $value->Attributes()->hour <= (int) date('H'))) |
|
| 69 | + ) || $numberDays > 0) { |
|
| 70 | + $captcha['timestamp'] = |
|
| 71 | + strtotime(date('Y-m-d', $day).' '.$value->Attributes()->hour.':00') + date('Z'); |
|
| 72 | + $captcha['captcha_accs'] = (string) $value->volume; |
|
| 73 | + $capdatas[] = $captcha; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + --$numberDays; |
|
| 77 | + } |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // Write to file |
@@ -90,7 +90,8 @@ |
||
| 90 | 90 | touch($pokedex_rarity_file); |
| 91 | 91 | // update pokedex rarity |
| 92 | 92 | include_once SYS_PATH.'/core/cron/pokedex_rarity.cron.php'; |
| 93 | -} elseif ((file_update_ago($nests_parks_file) >= 43200) && (time() - $migration >= 43200) && (time() - $migration < 86400)) { // extra update 12h after migration |
|
| 93 | +} elseif ((file_update_ago($nests_parks_file) >= 43200) && (time() - $migration >= 43200) && (time() - $migration < 86400)) { |
|
| 94 | +// extra update 12h after migration |
|
| 94 | 95 | if (is_file($nests_parks_file)) { |
| 95 | 96 | $prevNestTime = filemtime($nests_parks_file); |
| 96 | 97 | } else { |
@@ -37,13 +37,13 @@ discard block |
||
| 37 | 37 | $pokemonstats_file = SYS_PATH.'/core/json/pokemon.stats.json'; |
| 38 | 38 | |
| 39 | 39 | if (is_file($gym_file)) { |
| 40 | - $gymsdatas = json_decode(file_get_contents($gym_file), true); |
|
| 40 | + $gymsdatas = json_decode(file_get_contents($gym_file), true); |
|
| 41 | 41 | } |
| 42 | 42 | if (is_file($pokestop_file)) { |
| 43 | - $stopdatas = json_decode(file_get_contents($pokestop_file), true); |
|
| 43 | + $stopdatas = json_decode(file_get_contents($pokestop_file), true); |
|
| 44 | 44 | } |
| 45 | 45 | if (is_file($pokemonstats_file)) { |
| 46 | - $pokedatas = json_decode(file_get_contents($pokemonstats_file), true); |
|
| 46 | + $pokedatas = json_decode(file_get_contents($pokemonstats_file), true); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $timestamp = time(); |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | include_once SYS_PATH.'/core/cron/pokemon.cron.php'; |
| 60 | 60 | include_once SYS_PATH.'/core/cron/pokestop.cron.php'; |
| 61 | 61 | if ($config->system->captcha_support) { |
| 62 | - include_once SYS_PATH.'/core/cron/captcha.cron.php'; |
|
| 62 | + include_once SYS_PATH.'/core/cron/captcha.cron.php'; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // The following files are updated every 24h only because the queries are quite expensive |
@@ -72,48 +72,48 @@ discard block |
||
| 72 | 72 | $migration->setTimezone(new DateTimeZone('UTC')); |
| 73 | 73 | $migration->setTimestamp(1493856000); |
| 74 | 74 | do { |
| 75 | - $migrationPrev = clone $migration; |
|
| 76 | - $migration->modify('+14 days'); |
|
| 75 | + $migrationPrev = clone $migration; |
|
| 76 | + $migration->modify('+14 days'); |
|
| 77 | 77 | } while ($migration < new DateTime()); |
| 78 | 78 | $migration = $migrationPrev->getTimestamp(); |
| 79 | 79 | |
| 80 | 80 | if (!is_file($nests_parks_file) || filemtime($nests_parks_file) - $migration <= 0) { |
| 81 | - file_put_contents($nests_file, json_encode(array())); |
|
| 82 | - file_put_contents($nests_parks_file, json_encode(array())); |
|
| 83 | - touch($nests_parks_file, 1); |
|
| 81 | + file_put_contents($nests_file, json_encode(array())); |
|
| 82 | + file_put_contents($nests_parks_file, json_encode(array())); |
|
| 83 | + touch($nests_parks_file, 1); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | // Do not update both files at the same time to lower cpu load |
| 87 | 87 | if (file_update_ago($pokedex_rarity_file) > 86400) { |
| 88 | - // set file mtime to now before executing long running queries |
|
| 89 | - // so we don't try to update the file twice |
|
| 90 | - touch($pokedex_rarity_file); |
|
| 91 | - // update pokedex rarity |
|
| 92 | - include_once SYS_PATH.'/core/cron/pokedex_rarity.cron.php'; |
|
| 88 | + // set file mtime to now before executing long running queries |
|
| 89 | + // so we don't try to update the file twice |
|
| 90 | + touch($pokedex_rarity_file); |
|
| 91 | + // update pokedex rarity |
|
| 92 | + include_once SYS_PATH.'/core/cron/pokedex_rarity.cron.php'; |
|
| 93 | 93 | } elseif ((file_update_ago($nests_parks_file) >= 43200) && (time() - $migration >= 43200) && (time() - $migration < 86400)) { // extra update 12h after migration |
| 94 | - if (is_file($nests_parks_file)) { |
|
| 95 | - $prevNestTime = filemtime($nests_parks_file); |
|
| 96 | - } else { |
|
| 97 | - $prevNestTime = 1; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - // set file mtime to now before executing long running queries |
|
| 101 | - // so we don't try to update the file twice |
|
| 102 | - touch($nests_parks_file); |
|
| 103 | - // update nests |
|
| 104 | - $nestTime = 12; |
|
| 105 | - include_once SYS_PATH.'/core/cron/nests.cron.php'; |
|
| 94 | + if (is_file($nests_parks_file)) { |
|
| 95 | + $prevNestTime = filemtime($nests_parks_file); |
|
| 96 | + } else { |
|
| 97 | + $prevNestTime = 1; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + // set file mtime to now before executing long running queries |
|
| 101 | + // so we don't try to update the file twice |
|
| 102 | + touch($nests_parks_file); |
|
| 103 | + // update nests |
|
| 104 | + $nestTime = 12; |
|
| 105 | + include_once SYS_PATH.'/core/cron/nests.cron.php'; |
|
| 106 | 106 | } elseif ((file_update_ago($nests_parks_file) >= 86400) && (time() - $migration >= 86400)) { |
| 107 | - if (is_file($nests_parks_file)) { |
|
| 108 | - $prevNestTime = filemtime($nests_parks_file); |
|
| 109 | - } else { |
|
| 110 | - $prevNestTime = 1; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // set file mtime to now before executing long running queries |
|
| 114 | - // so we don't try to update the file twice |
|
| 115 | - touch($nests_parks_file); |
|
| 116 | - // update nests |
|
| 117 | - $nestTime = 24; |
|
| 118 | - include_once SYS_PATH.'/core/cron/nests.cron.php'; |
|
| 107 | + if (is_file($nests_parks_file)) { |
|
| 108 | + $prevNestTime = filemtime($nests_parks_file); |
|
| 109 | + } else { |
|
| 110 | + $prevNestTime = 1; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // set file mtime to now before executing long running queries |
|
| 114 | + // so we don't try to update the file twice |
|
| 115 | + touch($nests_parks_file); |
|
| 116 | + // update nests |
|
| 117 | + $nestTime = 24; |
|
| 118 | + include_once SYS_PATH.'/core/cron/nests.cron.php'; |
|
| 119 | 119 | } |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | $trainer_lvl = []; |
| 28 | 28 | // For all 3 teams |
| 29 | 29 | for ($teamid = 1; $teamid <= 3; ++$teamid) { |
| 30 | - $data = $manager->getTrainerLevelCount($teamid); |
|
| 31 | - $trainer_lvl[$teamid] = $data; |
|
| 30 | + $data = $manager->getTrainerLevelCount($teamid); |
|
| 31 | + $trainer_lvl[$teamid] = $data; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | ?> |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | borderColor: 'rgba(59,129,255,1)', |
| 69 | 69 | borderWidth: 1, |
| 70 | 70 | data: [<?php if (isset($trainer_lvl[1])) { |
| 71 | - echo implode(',', $trainer_lvl[1]); |
|
| 71 | + echo implode(',', $trainer_lvl[1]); |
|
| 72 | 72 | } ?>], |
| 73 | 73 | }, |
| 74 | 74 | { |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | borderColor: 'rgba(247,10,20,1)', |
| 78 | 78 | borderWidth: 1, |
| 79 | 79 | data: [<?php if (isset($trainer_lvl[2])) { |
| 80 | - echo implode(',', $trainer_lvl[2]); |
|
| 80 | + echo implode(',', $trainer_lvl[2]); |
|
| 81 | 81 | } ?>], |
| 82 | 82 | }, |
| 83 | 83 | { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | borderColor: 'rgba(248,153,0,1)', |
| 87 | 87 | borderWidth: 1, |
| 88 | 88 | data: [<?php if (isset($trainer_lvl[3])) { |
| 89 | - echo implode(',', $trainer_lvl[3]); |
|
| 89 | + echo implode(',', $trainer_lvl[3]); |
|
| 90 | 90 | } ?>], |
| 91 | 91 | } |
| 92 | 92 | ] |
@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | - // Send Javascript header |
|
| 3 | - header('Content-type: text/javascript'); |
|
| 4 | - |
|
| 5 | - // Load variables and locales |
|
| 6 | - include_once '../../config.php'; |
|
| 7 | - $variables = SYS_PATH.'/core/json/variables.json'; |
|
| 8 | - $config = json_decode(file_get_contents($variables)); |
|
| 9 | - include_once '../process/locales.loader.php'; |
|
| 10 | - include_once '../../functions.php'; |
|
| 2 | + // Send Javascript header |
|
| 3 | + header('Content-type: text/javascript'); |
|
| 4 | + |
|
| 5 | + // Load variables and locales |
|
| 6 | + include_once '../../config.php'; |
|
| 7 | + $variables = SYS_PATH.'/core/json/variables.json'; |
|
| 8 | + $config = json_decode(file_get_contents($variables)); |
|
| 9 | + include_once '../process/locales.loader.php'; |
|
| 10 | + include_once '../../functions.php'; |
|
| 11 | 11 | ?> |
| 12 | 12 | |
| 13 | 13 | /** global: google */ |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | var pokemon = { |
| 17 | 17 | <?php |
| 18 | - foreach ($pokemons->pokemon as $pokeid => $pokemon) { |
|
| 19 | - echo $pokeid.':"'.$pokemon->name.'",'; |
|
| 20 | - } |
|
| 18 | + foreach ($pokemons->pokemon as $pokeid => $pokemon) { |
|
| 19 | + echo $pokeid.':"'.$pokemon->name.'",'; |
|
| 20 | + } |
|
| 21 | 21 | ?> |
| 22 | 22 | } |
| 23 | 23 | var map; |
@@ -3,9 +3,9 @@ |
||
| 3 | 3 | // Test to check if the file is called properly |
| 4 | 4 | |
| 5 | 5 | if (!isset($_GET['id'])) { |
| 6 | - http_response_code(400); |
|
| 7 | - echo 'Bad Request'; |
|
| 8 | - exit(); |
|
| 6 | + http_response_code(400); |
|
| 7 | + echo 'Bad Request'; |
|
| 8 | + exit(); |
|
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | // Send Javascript header |
@@ -58,78 +58,78 @@ discard block |
||
| 58 | 58 | $captcha_accs = array(); |
| 59 | 59 | |
| 60 | 60 | foreach ($stats as $data) { |
| 61 | - if ($data->timestamp > $lastweek) { |
|
| 62 | - $labels_global[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 63 | - $total[] = $data->pokemon_now; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ($data->timestamp > $yesterday) { |
|
| 67 | - $labels[] = '"'.date('H:i', $data->timestamp).'"'; |
|
| 68 | - |
|
| 69 | - if (isset($data->rarity_spawn->{'Very common'})) { |
|
| 70 | - $veco[] = $data->rarity_spawn->{'Very common'}; |
|
| 71 | - } else { |
|
| 72 | - $veco[] = 0; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if (isset($data->rarity_spawn->Common)) { |
|
| 76 | - $commo[] = $data->rarity_spawn->Common; |
|
| 77 | - } else { |
|
| 78 | - $commo[] = 0; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - if (isset($data->rarity_spawn->Rare)) { |
|
| 82 | - $rare[] = $data->rarity_spawn->Rare; |
|
| 83 | - } else { |
|
| 84 | - $rare[] = 0; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - if (isset($data->rarity_spawn->Mythic)) { |
|
| 88 | - $myth[] = $data->rarity_spawn->Mythic; |
|
| 89 | - } else { |
|
| 90 | - $myth[] = 0; |
|
| 91 | - } |
|
| 92 | - } |
|
| 61 | + if ($data->timestamp > $lastweek) { |
|
| 62 | + $labels_global[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 63 | + $total[] = $data->pokemon_now; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ($data->timestamp > $yesterday) { |
|
| 67 | + $labels[] = '"'.date('H:i', $data->timestamp).'"'; |
|
| 68 | + |
|
| 69 | + if (isset($data->rarity_spawn->{'Very common'})) { |
|
| 70 | + $veco[] = $data->rarity_spawn->{'Very common'}; |
|
| 71 | + } else { |
|
| 72 | + $veco[] = 0; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if (isset($data->rarity_spawn->Common)) { |
|
| 76 | + $commo[] = $data->rarity_spawn->Common; |
|
| 77 | + } else { |
|
| 78 | + $commo[] = 0; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + if (isset($data->rarity_spawn->Rare)) { |
|
| 82 | + $rare[] = $data->rarity_spawn->Rare; |
|
| 83 | + } else { |
|
| 84 | + $rare[] = 0; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + if (isset($data->rarity_spawn->Mythic)) { |
|
| 88 | + $myth[] = $data->rarity_spawn->Mythic; |
|
| 89 | + } else { |
|
| 90 | + $myth[] = 0; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $stats_file = SYS_PATH.'/core/json/gym.stats.json'; |
| 96 | 96 | $stats = json_decode(file_get_contents($stats_file)); |
| 97 | 97 | |
| 98 | 98 | foreach ($stats as $data) { |
| 99 | - if ($data->timestamp > $lastweek) { |
|
| 100 | - $labels_gym[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 99 | + if ($data->timestamp > $lastweek) { |
|
| 100 | + $labels_gym[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 101 | 101 | |
| 102 | - $mystic_average[] = $data->team->mystic->average; |
|
| 103 | - $mystic_owned[] = $data->team->mystic->gym_owned; |
|
| 102 | + $mystic_average[] = $data->team->mystic->average; |
|
| 103 | + $mystic_owned[] = $data->team->mystic->gym_owned; |
|
| 104 | 104 | |
| 105 | - $valor_average[] = $data->team->valor->average; |
|
| 106 | - $valor_owned[] = $data->team->valor->gym_owned; |
|
| 105 | + $valor_average[] = $data->team->valor->average; |
|
| 106 | + $valor_owned[] = $data->team->valor->gym_owned; |
|
| 107 | 107 | |
| 108 | - $instinct_average[] = $data->team->instinct->average; |
|
| 109 | - $instinct_owned[] = $data->team->instinct->gym_owned; |
|
| 110 | - } |
|
| 108 | + $instinct_average[] = $data->team->instinct->average; |
|
| 109 | + $instinct_owned[] = $data->team->instinct->gym_owned; |
|
| 110 | + } |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | $stats_file = SYS_PATH.'/core/json/pokestop.stats.json'; |
| 114 | 114 | $stats = json_decode(file_get_contents($stats_file)); |
| 115 | 115 | |
| 116 | 116 | foreach ($stats as $data) { |
| 117 | - if ($data->timestamp > $lastweek) { |
|
| 118 | - $labels_stops[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 119 | - $lure[] = $data->lured; |
|
| 120 | - } |
|
| 117 | + if ($data->timestamp > $lastweek) { |
|
| 118 | + $labels_stops[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 119 | + $lure[] = $data->lured; |
|
| 120 | + } |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | if ($config->system->captcha_support) { |
| 124 | - $stats_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 125 | - $stats = json_decode(file_get_contents($stats_file)); |
|
| 126 | - |
|
| 127 | - foreach ($stats as $data) { |
|
| 128 | - if ($data->timestamp > $lastweek) { |
|
| 129 | - $labels_captcha[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 130 | - $captcha_accs[] = $data->captcha_accs; |
|
| 131 | - } |
|
| 132 | - } |
|
| 124 | + $stats_file = SYS_PATH.'/core/json/captcha.stats.json'; |
|
| 125 | + $stats = json_decode(file_get_contents($stats_file)); |
|
| 126 | + |
|
| 127 | + foreach ($stats as $data) { |
|
| 128 | + if ($data->timestamp > $lastweek) { |
|
| 129 | + $labels_captcha[] = '"'.date('D H:i', $data->timestamp).'"'; |
|
| 130 | + $captcha_accs[] = $data->captcha_accs; |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | ?> |
@@ -563,7 +563,7 @@ discard block |
||
| 563 | 563 | // ------------- |
| 564 | 564 | |
| 565 | 565 | <?php if ($config->system->captcha_support) { |
| 566 | - ?> |
|
| 566 | + ?> |
|
| 567 | 567 | var ctx_captcha_accs = $('#captcha'); |
| 568 | 568 | |
| 569 | 569 | var data_captcha_accs = { |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | <link href="core/css/font-awesome.min.css" rel="stylesheet"> |
| 22 | 22 | <link href="<?php auto_ver('core/css/style.css'); ?>" rel="stylesheet"> |
| 23 | 23 | <?php if ('pokemon' == $page) { |
| 24 | - ?> |
|
| 24 | + ?> |
|
| 25 | 25 | <link href="<?php auto_ver('core/css/jQRangeSlider-bootstrap.min.css'); ?>" rel="stylesheet"> |
| 26 | 26 | <?php |
| 27 | 27 | } ?> |
@@ -29,11 +29,11 @@ discard block |
||
| 29 | 29 | <body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top"> |
| 30 | 30 | |
| 31 | 31 | <?php |
| 32 | - // Google Analytics |
|
| 33 | - if (is_file('analyticstracking.php')) { |
|
| 34 | - include_once 'analyticstracking.php'; |
|
| 35 | - } |
|
| 36 | - ?> |
|
| 32 | + // Google Analytics |
|
| 33 | + if (is_file('analyticstracking.php')) { |
|
| 34 | + include_once 'analyticstracking.php'; |
|
| 35 | + } |
|
| 36 | + ?> |
|
| 37 | 37 | |
| 38 | 38 | <nav class="navbar navbar-default navbar-fixed-top"> |
| 39 | 39 | <div class="container"> |
@@ -53,15 +53,15 @@ discard block |
||
| 53 | 53 | <ul class="nav navbar-nav navbar-right"> |
| 54 | 54 | |
| 55 | 55 | <?php |
| 56 | - if (!isset($config->menu)) { |
|
| 57 | - echo 'Please update variables.json file with menu values'; |
|
| 58 | - exit(); |
|
| 59 | - } |
|
| 56 | + if (!isset($config->menu)) { |
|
| 57 | + echo 'Please update variables.json file with menu values'; |
|
| 58 | + exit(); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - foreach ($config->menu as $menu) { |
|
| 62 | - printMenuitems($menu, 1, $locales); |
|
| 63 | - } |
|
| 64 | - ?> |
|
| 61 | + foreach ($config->menu as $menu) { |
|
| 62 | + printMenuitems($menu, 1, $locales); |
|
| 63 | + } |
|
| 64 | + ?> |
|
| 65 | 65 | |
| 66 | 66 | </ul> |
| 67 | 67 | </div> <!-- /.navbar-collapse --> |
@@ -70,21 +70,21 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | <div class="container"> |
| 72 | 72 | <?php |
| 73 | - // Include the pages |
|
| 74 | - if (!empty($_GET['page'])) { |
|
| 75 | - $file = SYS_PATH.'/pages/'.$page.'.page.php'; |
|
| 76 | - |
|
| 77 | - if (is_file($file)) { |
|
| 78 | - echo '<!-- Page :: '.$page.' -->'; |
|
| 79 | - include $file; |
|
| 80 | - } else { |
|
| 81 | - include 'pages/home.page.php'; |
|
| 82 | - } |
|
| 83 | - } else { |
|
| 84 | - include 'pages/home.page.php'; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - ?> |
|
| 73 | + // Include the pages |
|
| 74 | + if (!empty($_GET['page'])) { |
|
| 75 | + $file = SYS_PATH.'/pages/'.$page.'.page.php'; |
|
| 76 | + |
|
| 77 | + if (is_file($file)) { |
|
| 78 | + echo '<!-- Page :: '.$page.' -->'; |
|
| 79 | + include $file; |
|
| 80 | + } else { |
|
| 81 | + include 'pages/home.page.php'; |
|
| 82 | + } |
|
| 83 | + } else { |
|
| 84 | + include 'pages/home.page.php'; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + ?> |
|
| 88 | 88 | </div> |
| 89 | 89 | |
| 90 | 90 | <footer> |
@@ -107,8 +107,8 @@ discard block |
||
| 107 | 107 | <script src="core/js/bootstrap.min.js"></script> |
| 108 | 108 | |
| 109 | 109 | <?php // Load scripts only for page |
| 110 | - if (empty($page)) { |
|
| 111 | - ?> |
|
| 110 | + if (empty($page)) { |
|
| 111 | + ?> |
|
| 112 | 112 | |
| 113 | 113 | <script src="<?php auto_ver('core/js/home.script.js'); ?>"></script> |
| 114 | 114 | |
@@ -124,10 +124,10 @@ discard block |
||
| 124 | 124 | updateCounter(<?= $home->teams->rocket; ?>,'.total-rocket-js'); |
| 125 | 125 | </script> |
| 126 | 126 | <?php |
| 127 | - } else { |
|
| 128 | - switch ($page) { |
|
| 129 | - case 'pokemon': |
|
| 130 | - ?> |
|
| 127 | + } else { |
|
| 128 | + switch ($page) { |
|
| 129 | + case 'pokemon': |
|
| 130 | + ?> |
|
| 131 | 131 | |
| 132 | 132 | <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> |
| 133 | 133 | <script src="core/js/pokemon.graph.js.php?id=<?= $pokemon_id; ?>"></script> |
@@ -141,19 +141,19 @@ discard block |
||
| 141 | 141 | <script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization&callback=initMap&v=3"></script> |
| 142 | 142 | |
| 143 | 143 | <?php |
| 144 | - break; |
|
| 144 | + break; |
|
| 145 | 145 | |
| 146 | - case 'pokestops': |
|
| 147 | - ?> |
|
| 146 | + case 'pokestops': |
|
| 147 | + ?> |
|
| 148 | 148 | |
| 149 | 149 | <script src="<?php auto_ver('core/js/pokestops.maps.js'); ?>"></script> |
| 150 | 150 | <script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization&callback=initMap&v=3"></script> |
| 151 | 151 | |
| 152 | 152 | <?php |
| 153 | - break; |
|
| 153 | + break; |
|
| 154 | 154 | |
| 155 | - case 'gym': |
|
| 156 | - ?> |
|
| 155 | + case 'gym': |
|
| 156 | + ?> |
|
| 157 | 157 | |
| 158 | 158 | <script src="<?php auto_ver('core/js/gym.script.js'); ?>"></script> |
| 159 | 159 | <script> |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | <script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization&callback=initMap&v=3"></script> |
| 172 | 172 | |
| 173 | 173 | <?php |
| 174 | - break; |
|
| 174 | + break; |
|
| 175 | 175 | |
| 176 | - case 'pokedex': |
|
| 177 | - ?> |
|
| 176 | + case 'pokedex': |
|
| 177 | + ?> |
|
| 178 | 178 | |
| 179 | 179 | <script src="core/js/holmes.min.js"></script> |
| 180 | 180 | <script> |
@@ -191,56 +191,56 @@ discard block |
||
| 191 | 191 | </script> |
| 192 | 192 | |
| 193 | 193 | <?php |
| 194 | - break; |
|
| 194 | + break; |
|
| 195 | 195 | |
| 196 | - case 'dashboard': |
|
| 197 | - ?> |
|
| 196 | + case 'dashboard': |
|
| 197 | + ?> |
|
| 198 | 198 | |
| 199 | 199 | <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> |
| 200 | 200 | <script src="core/js/dashboard.graph.js.php"></script> |
| 201 | 201 | |
| 202 | 202 | <?php |
| 203 | - break; |
|
| 203 | + break; |
|
| 204 | 204 | |
| 205 | - case 'trainer': |
|
| 206 | - ?> |
|
| 205 | + case 'trainer': |
|
| 206 | + ?> |
|
| 207 | 207 | |
| 208 | 208 | <script src="<?php auto_ver('core/js/trainer.content.js'); ?>"></script> |
| 209 | 209 | <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.min.js"></script> |
| 210 | 210 | <script src="core/js/trainer.graph.js.php"></script> |
| 211 | 211 | |
| 212 | 212 | <?php |
| 213 | - break; |
|
| 213 | + break; |
|
| 214 | 214 | |
| 215 | - case 'nests': |
|
| 216 | - ?> |
|
| 215 | + case 'nests': |
|
| 216 | + ?> |
|
| 217 | 217 | |
| 218 | 218 | <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script> |
| 219 | 219 | <script src="core/js/nests.maps.js.php"></script> |
| 220 | 220 | <script src="https://maps.googleapis.com/maps/api/js?key=<?= $config->system->GMaps_Key; ?>&libraries=visualization,geometry&callback=initMap&v=3"></script> |
| 221 | 221 | |
| 222 | 222 | <?php |
| 223 | - break; |
|
| 223 | + break; |
|
| 224 | 224 | |
| 225 | - case 'raids': |
|
| 226 | - ?> |
|
| 225 | + case 'raids': |
|
| 226 | + ?> |
|
| 227 | 227 | |
| 228 | 228 | <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js"></script> |
| 229 | 229 | <script src="<?php auto_ver('core/js/raids.content.js'); ?>"></script> |
| 230 | 230 | |
| 231 | 231 | <?php |
| 232 | - break; |
|
| 232 | + break; |
|
| 233 | 233 | |
| 234 | - case 'gymhistory': |
|
| 235 | - ?> |
|
| 234 | + case 'gymhistory': |
|
| 235 | + ?> |
|
| 236 | 236 | |
| 237 | 237 | <script src="<?php auto_ver('core/js/gymhistory.content.js'); ?>"></script> |
| 238 | 238 | |
| 239 | 239 | <?php |
| 240 | - break; |
|
| 241 | - } |
|
| 242 | - } |
|
| 243 | - ?> |
|
| 240 | + break; |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | + ?> |
|
| 244 | 244 | |
| 245 | 245 | </body> |
| 246 | 246 | </html> |
@@ -199,11 +199,14 @@ discard block |
||
| 199 | 199 | //####################################################################### |
| 200 | 200 | function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) |
| 201 | 201 | { |
| 202 | - if ($depth == $currentDepth) { // Found depth |
|
| 202 | + if ($depth == $currentDepth) { |
|
| 203 | +// Found depth |
|
| 203 | 204 | return tree_remove_bellow($trees, $max_pokemon); |
| 204 | - } else { // Go deeper |
|
| 205 | + } else { |
|
| 206 | +// Go deeper |
|
| 205 | 207 | $arr = array(); |
| 206 | - foreach ($trees as $temp) { // Go into all trees |
|
| 208 | + foreach ($trees as $temp) { |
|
| 209 | +// Go into all trees |
|
| 207 | 210 | $tree = $temp->evolutions; |
| 208 | 211 | $results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon); |
| 209 | 212 | $arr = tree_check_array($results, $arr, 1 == $depth - $currentDepth); |
@@ -220,9 +223,12 @@ discard block |
||
| 220 | 223 | { |
| 221 | 224 | $count = count($array_check); |
| 222 | 225 | $i = 0; |
| 223 | - if (!is_null($array_check)) { // check if exists |
|
| 224 | - foreach ($array_check as $res) { // Check if above, equal or bellow center |
|
| 225 | - if (1 != $count && $correct_arrow) { // only add arrow once |
|
| 226 | + if (!is_null($array_check)) { |
|
| 227 | +// check if exists |
|
| 228 | + foreach ($array_check as $res) { |
|
| 229 | +// Check if above, equal or bellow center |
|
| 230 | + if (1 != $count && $correct_arrow) { |
|
| 231 | +// only add arrow once |
|
| 226 | 232 | $num = $i / ($count - 1); |
| 227 | 233 | if ($num < 0.5) { |
| 228 | 234 | $res->array_sufix = '_up'; |
@@ -251,7 +257,8 @@ discard block |
||
| 251 | 257 | return null; |
| 252 | 258 | } |
| 253 | 259 | $arr = array(); |
| 254 | - foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 260 | + foreach ($tree as $item) { |
|
| 261 | +// Check if above, equal or bellow center |
|
| 255 | 262 | if ($item->id <= $max_pokemon) { |
| 256 | 263 | $arr[] = $item; |
| 257 | 264 | } |
@@ -295,15 +302,18 @@ discard block |
||
| 295 | 302 | for ($i = 1; $i < $geos_count; ++$i) { |
| 296 | 303 | $geo1 = $geos[$i - 1]; |
| 297 | 304 | $geo2 = $geos[$i]; |
| 298 | - if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) { // On one of the coords |
|
| 305 | + if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) { |
|
| 306 | +// On one of the coords |
|
| 299 | 307 | return true; |
| 300 | 308 | } |
| 301 | - if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) { // Check if point is on an horizontal polygon boundary |
|
| 309 | + if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) { |
|
| 310 | +// Check if point is on an horizontal polygon boundary |
|
| 302 | 311 | return true; |
| 303 | 312 | } |
| 304 | 313 | if ($lng > min($geo1['lng'], $geo2['lng']) and $lng <= max($geo1['lng'], $geo2['lng']) and $lat <= max($geo1['lat'], $geo2['lat']) and $geo1['lng'] != $geo2['lng']) { |
| 305 | 314 | $xinters = ($lng - $geo1['lng']) * ($geo2['lat'] - $geo1['lat']) / ($geo2['lng'] - $geo1['lng']) + $geo1['lat']; |
| 306 | - if ($xinters == $lat) { // Check if point is on the polygon boundary (other than horizontal) |
|
| 315 | + if ($xinters == $lat) { |
|
| 316 | +// Check if point is on the polygon boundary (other than horizontal) |
|
| 307 | 317 | return true; |
| 308 | 318 | } |
| 309 | 319 | if ($geo1['lat'] == $geo2['lat'] || $lat <= $xinters) { |
@@ -10,54 +10,54 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | function time_ago($timestamp, $locales) |
| 12 | 12 | { |
| 13 | - // Set up our variables. |
|
| 14 | - $minute_in_seconds = 60; |
|
| 15 | - $hour_in_seconds = $minute_in_seconds * 60; |
|
| 16 | - $day_in_seconds = $hour_in_seconds * 24; |
|
| 17 | - $week_in_seconds = $day_in_seconds * 7; |
|
| 18 | - $month_in_seconds = $day_in_seconds * 30; |
|
| 19 | - $year_in_seconds = $day_in_seconds * 365; |
|
| 20 | - |
|
| 21 | - // current time |
|
| 22 | - $now = time(); |
|
| 23 | - |
|
| 24 | - // Calculate the time difference between the current time reference point and the timestamp we're comparing. |
|
| 25 | - // The difference is defined negative, when in the future. |
|
| 26 | - $time_difference = $now - $timestamp; |
|
| 27 | - |
|
| 28 | - // Calculate the time ago using the smallest applicable unit. |
|
| 29 | - if ($time_difference < $hour_in_seconds) { |
|
| 30 | - $difference_value = abs(round($time_difference / $minute_in_seconds)); |
|
| 31 | - $difference_label = 'MINUTE'; |
|
| 32 | - } elseif ($time_difference < $day_in_seconds) { |
|
| 33 | - $difference_value = abs(round($time_difference / $hour_in_seconds)); |
|
| 34 | - $difference_label = 'HOUR'; |
|
| 35 | - } elseif ($time_difference < $week_in_seconds) { |
|
| 36 | - $difference_value = abs(round($time_difference / $day_in_seconds)); |
|
| 37 | - $difference_label = 'DAY'; |
|
| 38 | - } elseif ($time_difference < $month_in_seconds) { |
|
| 39 | - $difference_value = abs(round($time_difference / $week_in_seconds)); |
|
| 40 | - $difference_label = 'WEEK'; |
|
| 41 | - } elseif ($time_difference < $year_in_seconds) { |
|
| 42 | - $difference_value = abs(round($time_difference / $month_in_seconds)); |
|
| 43 | - $difference_label = 'MONTH'; |
|
| 44 | - } else { |
|
| 45 | - $difference_value = abs(round($time_difference / $year_in_seconds)); |
|
| 46 | - $difference_label = 'YEAR'; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - // plural |
|
| 50 | - if (1 != $difference_value) { |
|
| 51 | - $difference_label = $difference_label.'S'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if ($time_difference <= 0) { |
|
| 55 | - // Present |
|
| 56 | - return sprintf($locales->TIME_LEFT, $difference_value.' '.$locales->$difference_label); |
|
| 57 | - } else { |
|
| 58 | - // Past |
|
| 59 | - return sprintf($locales->TIME_AGO, $difference_value.' '.$locales->$difference_label); |
|
| 60 | - } |
|
| 13 | + // Set up our variables. |
|
| 14 | + $minute_in_seconds = 60; |
|
| 15 | + $hour_in_seconds = $minute_in_seconds * 60; |
|
| 16 | + $day_in_seconds = $hour_in_seconds * 24; |
|
| 17 | + $week_in_seconds = $day_in_seconds * 7; |
|
| 18 | + $month_in_seconds = $day_in_seconds * 30; |
|
| 19 | + $year_in_seconds = $day_in_seconds * 365; |
|
| 20 | + |
|
| 21 | + // current time |
|
| 22 | + $now = time(); |
|
| 23 | + |
|
| 24 | + // Calculate the time difference between the current time reference point and the timestamp we're comparing. |
|
| 25 | + // The difference is defined negative, when in the future. |
|
| 26 | + $time_difference = $now - $timestamp; |
|
| 27 | + |
|
| 28 | + // Calculate the time ago using the smallest applicable unit. |
|
| 29 | + if ($time_difference < $hour_in_seconds) { |
|
| 30 | + $difference_value = abs(round($time_difference / $minute_in_seconds)); |
|
| 31 | + $difference_label = 'MINUTE'; |
|
| 32 | + } elseif ($time_difference < $day_in_seconds) { |
|
| 33 | + $difference_value = abs(round($time_difference / $hour_in_seconds)); |
|
| 34 | + $difference_label = 'HOUR'; |
|
| 35 | + } elseif ($time_difference < $week_in_seconds) { |
|
| 36 | + $difference_value = abs(round($time_difference / $day_in_seconds)); |
|
| 37 | + $difference_label = 'DAY'; |
|
| 38 | + } elseif ($time_difference < $month_in_seconds) { |
|
| 39 | + $difference_value = abs(round($time_difference / $week_in_seconds)); |
|
| 40 | + $difference_label = 'WEEK'; |
|
| 41 | + } elseif ($time_difference < $year_in_seconds) { |
|
| 42 | + $difference_value = abs(round($time_difference / $month_in_seconds)); |
|
| 43 | + $difference_label = 'MONTH'; |
|
| 44 | + } else { |
|
| 45 | + $difference_value = abs(round($time_difference / $year_in_seconds)); |
|
| 46 | + $difference_label = 'YEAR'; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + // plural |
|
| 50 | + if (1 != $difference_value) { |
|
| 51 | + $difference_label = $difference_label.'S'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if ($time_difference <= 0) { |
|
| 55 | + // Present |
|
| 56 | + return sprintf($locales->TIME_LEFT, $difference_value.' '.$locales->$difference_label); |
|
| 57 | + } else { |
|
| 58 | + // Past |
|
| 59 | + return sprintf($locales->TIME_AGO, $difference_value.' '.$locales->$difference_label); |
|
| 60 | + } |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | //####################################################################### |
@@ -70,12 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | function percent($val, $val_total) |
| 72 | 72 | { |
| 73 | - $count1 = $val_total / $val; |
|
| 74 | - $count2 = $count1 * 100; |
|
| 73 | + $count1 = $val_total / $val; |
|
| 74 | + $count2 = $count1 * 100; |
|
| 75 | 75 | |
| 76 | - $count = number_format($count2, 0); |
|
| 76 | + $count = number_format($count2, 0); |
|
| 77 | 77 | |
| 78 | - return $count; |
|
| 78 | + return $count; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | //####################################################################### |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | function auto_ver($url) |
| 89 | 89 | { |
| 90 | - if (is_file(SYS_PATH.'/'.$url)) { |
|
| 91 | - $path = pathinfo($url); |
|
| 92 | - $ver = '.'.filemtime(SYS_PATH.'/'.$url).'.'; |
|
| 93 | - echo $path['dirname'].'/'.preg_replace('/\.(css|js|json)$/', $ver.'$1', $path['basename']); |
|
| 94 | - } else { |
|
| 95 | - echo $url; |
|
| 96 | - } |
|
| 90 | + if (is_file(SYS_PATH.'/'.$url)) { |
|
| 91 | + $path = pathinfo($url); |
|
| 92 | + $ver = '.'.filemtime(SYS_PATH.'/'.$url).'.'; |
|
| 93 | + echo $path['dirname'].'/'.preg_replace('/\.(css|js|json)$/', $ver.'$1', $path['basename']); |
|
| 94 | + } else { |
|
| 95 | + echo $url; |
|
| 96 | + } |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | //####################################################################### |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | function file_update_ago($filepath) |
| 107 | 107 | { |
| 108 | - if (is_file($filepath)) { |
|
| 109 | - $filemtime = filemtime($filepath); |
|
| 110 | - $now = time(); |
|
| 111 | - $diff = $now - $filemtime; |
|
| 112 | - |
|
| 113 | - return $diff; |
|
| 114 | - } |
|
| 115 | - // file doesn't exist yet! |
|
| 116 | - return PHP_INT_MAX; |
|
| 108 | + if (is_file($filepath)) { |
|
| 109 | + $filemtime = filemtime($filepath); |
|
| 110 | + $now = time(); |
|
| 111 | + $diff = $now - $filemtime; |
|
| 112 | + |
|
| 113 | + return $diff; |
|
| 114 | + } |
|
| 115 | + // file doesn't exist yet! |
|
| 116 | + return PHP_INT_MAX; |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | //####################################################################### |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | function trim_stats_json($array, $timestamp) |
| 128 | 128 | { |
| 129 | - foreach ($array as $key => $value) { |
|
| 130 | - if ($value['timestamp'] < $timestamp) { |
|
| 131 | - unset($array[$key]); |
|
| 132 | - } |
|
| 133 | - } |
|
| 129 | + foreach ($array as $key => $value) { |
|
| 130 | + if ($value['timestamp'] < $timestamp) { |
|
| 131 | + unset($array[$key]); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - return $array; |
|
| 135 | + return $array; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | //####################################################################### |
@@ -144,31 +144,31 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | function gym_level($prestige) |
| 146 | 146 | { |
| 147 | - if (0 == $prestige) { |
|
| 148 | - $gym_level = 0; |
|
| 149 | - } elseif ($prestige < 2000) { |
|
| 150 | - $gym_level = 1; |
|
| 151 | - } elseif ($prestige < 4000) { |
|
| 152 | - $gym_level = 2; |
|
| 153 | - } elseif ($prestige < 8000) { |
|
| 154 | - $gym_level = 3; |
|
| 155 | - } elseif ($prestige < 12000) { |
|
| 156 | - $gym_level = 4; |
|
| 157 | - } elseif ($prestige < 16000) { |
|
| 158 | - $gym_level = 5; |
|
| 159 | - } elseif ($prestige < 20000) { |
|
| 160 | - $gym_level = 6; |
|
| 161 | - } elseif ($prestige < 30000) { |
|
| 162 | - $gym_level = 7; |
|
| 163 | - } elseif ($prestige < 40000) { |
|
| 164 | - $gym_level = 8; |
|
| 165 | - } elseif ($prestige < 50000) { |
|
| 166 | - $gym_level = 9; |
|
| 167 | - } else { |
|
| 168 | - $gym_level = 10; |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - return $gym_level; |
|
| 147 | + if (0 == $prestige) { |
|
| 148 | + $gym_level = 0; |
|
| 149 | + } elseif ($prestige < 2000) { |
|
| 150 | + $gym_level = 1; |
|
| 151 | + } elseif ($prestige < 4000) { |
|
| 152 | + $gym_level = 2; |
|
| 153 | + } elseif ($prestige < 8000) { |
|
| 154 | + $gym_level = 3; |
|
| 155 | + } elseif ($prestige < 12000) { |
|
| 156 | + $gym_level = 4; |
|
| 157 | + } elseif ($prestige < 16000) { |
|
| 158 | + $gym_level = 5; |
|
| 159 | + } elseif ($prestige < 20000) { |
|
| 160 | + $gym_level = 6; |
|
| 161 | + } elseif ($prestige < 30000) { |
|
| 162 | + $gym_level = 7; |
|
| 163 | + } elseif ($prestige < 40000) { |
|
| 164 | + $gym_level = 8; |
|
| 165 | + } elseif ($prestige < 50000) { |
|
| 166 | + $gym_level = 9; |
|
| 167 | + } else { |
|
| 168 | + $gym_level = 10; |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + return $gym_level; |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | //####################################################################### |
@@ -179,13 +179,13 @@ discard block |
||
| 179 | 179 | //####################################################################### |
| 180 | 180 | function get_depth($arr) |
| 181 | 181 | { |
| 182 | - $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); |
|
| 183 | - $depth = 0; |
|
| 184 | - foreach ($it as $v) { |
|
| 185 | - $it->getDepth() > $depth && $depth = $it->getDepth(); |
|
| 186 | - } |
|
| 182 | + $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); |
|
| 183 | + $depth = 0; |
|
| 184 | + foreach ($it as $v) { |
|
| 185 | + $it->getDepth() > $depth && $depth = $it->getDepth(); |
|
| 186 | + } |
|
| 187 | 187 | |
| 188 | - return $depth; |
|
| 188 | + return $depth; |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | //####################################################################### |
@@ -199,18 +199,18 @@ discard block |
||
| 199 | 199 | //####################################################################### |
| 200 | 200 | function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) |
| 201 | 201 | { |
| 202 | - if ($depth == $currentDepth) { // Found depth |
|
| 203 | - return tree_remove_bellow($trees, $max_pokemon); |
|
| 204 | - } else { // Go deeper |
|
| 205 | - $arr = array(); |
|
| 206 | - foreach ($trees as $temp) { // Go into all trees |
|
| 207 | - $tree = $temp->evolutions; |
|
| 208 | - $results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon); |
|
| 209 | - $arr = tree_check_array($results, $arr, 1 == $depth - $currentDepth); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - return $arr; |
|
| 213 | - } |
|
| 202 | + if ($depth == $currentDepth) { // Found depth |
|
| 203 | + return tree_remove_bellow($trees, $max_pokemon); |
|
| 204 | + } else { // Go deeper |
|
| 205 | + $arr = array(); |
|
| 206 | + foreach ($trees as $temp) { // Go into all trees |
|
| 207 | + $tree = $temp->evolutions; |
|
| 208 | + $results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon); |
|
| 209 | + $arr = tree_check_array($results, $arr, 1 == $depth - $currentDepth); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + return $arr; |
|
| 213 | + } |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | //####################################################################### |
@@ -218,28 +218,28 @@ discard block |
||
| 218 | 218 | //####################################################################### |
| 219 | 219 | function tree_check_array($array_check, $array_add, $correct_arrow) |
| 220 | 220 | { |
| 221 | - $count = count($array_check); |
|
| 222 | - $i = 0; |
|
| 223 | - if (!is_null($array_check)) { // check if exists |
|
| 224 | - foreach ($array_check as $res) { // Check if above, equal or bellow center |
|
| 225 | - if (1 != $count && $correct_arrow) { // only add arrow once |
|
| 226 | - $num = $i / ($count - 1); |
|
| 227 | - if ($num < 0.5) { |
|
| 228 | - $res->array_sufix = '_up'; |
|
| 229 | - } elseif ($num > 0.5) { |
|
| 230 | - $res->array_sufix = '_down'; |
|
| 231 | - } else { |
|
| 232 | - $res->array_sufix = ''; |
|
| 233 | - } |
|
| 234 | - } elseif (!isset($res->array_sufix)) { |
|
| 235 | - $res->array_sufix = ''; |
|
| 236 | - } |
|
| 237 | - $array_add[] = $res; |
|
| 238 | - ++$i; |
|
| 239 | - } |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - return $array_add; |
|
| 221 | + $count = count($array_check); |
|
| 222 | + $i = 0; |
|
| 223 | + if (!is_null($array_check)) { // check if exists |
|
| 224 | + foreach ($array_check as $res) { // Check if above, equal or bellow center |
|
| 225 | + if (1 != $count && $correct_arrow) { // only add arrow once |
|
| 226 | + $num = $i / ($count - 1); |
|
| 227 | + if ($num < 0.5) { |
|
| 228 | + $res->array_sufix = '_up'; |
|
| 229 | + } elseif ($num > 0.5) { |
|
| 230 | + $res->array_sufix = '_down'; |
|
| 231 | + } else { |
|
| 232 | + $res->array_sufix = ''; |
|
| 233 | + } |
|
| 234 | + } elseif (!isset($res->array_sufix)) { |
|
| 235 | + $res->array_sufix = ''; |
|
| 236 | + } |
|
| 237 | + $array_add[] = $res; |
|
| 238 | + ++$i; |
|
| 239 | + } |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + return $array_add; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | //####################################################################### |
@@ -247,17 +247,17 @@ discard block |
||
| 247 | 247 | //####################################################################### |
| 248 | 248 | function tree_remove_bellow($tree, $max_pokemon) |
| 249 | 249 | { |
| 250 | - if (is_null($tree)) { |
|
| 251 | - return null; |
|
| 252 | - } |
|
| 253 | - $arr = array(); |
|
| 254 | - foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 255 | - if ($item->id <= $max_pokemon) { |
|
| 256 | - $arr[] = $item; |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - return $arr; |
|
| 250 | + if (is_null($tree)) { |
|
| 251 | + return null; |
|
| 252 | + } |
|
| 253 | + $arr = array(); |
|
| 254 | + foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 255 | + if ($item->id <= $max_pokemon) { |
|
| 256 | + $arr[] = $item; |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + return $arr; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | //####################################################################### |
@@ -265,22 +265,22 @@ discard block |
||
| 265 | 265 | //####################################################################### |
| 266 | 266 | function generation($id) |
| 267 | 267 | { |
| 268 | - switch ($id) { |
|
| 269 | - case $id >= 1 && $id <= 151: |
|
| 270 | - return [1, 'Kanto']; |
|
| 271 | - case $id >= 152 && $id <= 251: |
|
| 272 | - return [2, 'Johto']; |
|
| 273 | - case $id >= 252 && $id <= 386: |
|
| 274 | - return [3, 'Hoenn']; |
|
| 275 | - case $id >= 387 && $id <= 493: |
|
| 276 | - return [4, 'Sinnoh']; |
|
| 277 | - case $id >= 494 && $id <= 649: |
|
| 278 | - return [5, 'Teselia']; |
|
| 279 | - case $id >= 650 && $id <= 721: |
|
| 280 | - return [6, 'Kalos']; |
|
| 281 | - case $id >= 722 && $id <= 802: |
|
| 282 | - return [7, 'Alola']; |
|
| 283 | - } |
|
| 268 | + switch ($id) { |
|
| 269 | + case $id >= 1 && $id <= 151: |
|
| 270 | + return [1, 'Kanto']; |
|
| 271 | + case $id >= 152 && $id <= 251: |
|
| 272 | + return [2, 'Johto']; |
|
| 273 | + case $id >= 252 && $id <= 386: |
|
| 274 | + return [3, 'Hoenn']; |
|
| 275 | + case $id >= 387 && $id <= 493: |
|
| 276 | + return [4, 'Sinnoh']; |
|
| 277 | + case $id >= 494 && $id <= 649: |
|
| 278 | + return [5, 'Teselia']; |
|
| 279 | + case $id >= 650 && $id <= 721: |
|
| 280 | + return [6, 'Kalos']; |
|
| 281 | + case $id >= 722 && $id <= 802: |
|
| 282 | + return [7, 'Alola']; |
|
| 283 | + } |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | //####################################################################### |
@@ -288,34 +288,34 @@ discard block |
||
| 288 | 288 | //####################################################################### |
| 289 | 289 | function pointIsInsidePolygon($lat, $lng, $geos, $bounds) |
| 290 | 290 | { |
| 291 | - if ($lat >= $bounds['minlat'] && $lat <= $bounds['maxlat'] && $lng >= $bounds['minlon'] && $lng <= $bounds['maxlon']) { |
|
| 292 | - $intersections = 0; |
|
| 293 | - $geos_count = count($geos); |
|
| 294 | - |
|
| 295 | - for ($i = 1; $i < $geos_count; ++$i) { |
|
| 296 | - $geo1 = $geos[$i - 1]; |
|
| 297 | - $geo2 = $geos[$i]; |
|
| 298 | - if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) { // On one of the coords |
|
| 299 | - return true; |
|
| 300 | - } |
|
| 301 | - if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) { // Check if point is on an horizontal polygon boundary |
|
| 302 | - return true; |
|
| 303 | - } |
|
| 304 | - if ($lng > min($geo1['lng'], $geo2['lng']) and $lng <= max($geo1['lng'], $geo2['lng']) and $lat <= max($geo1['lat'], $geo2['lat']) and $geo1['lng'] != $geo2['lng']) { |
|
| 305 | - $xinters = ($lng - $geo1['lng']) * ($geo2['lat'] - $geo1['lat']) / ($geo2['lng'] - $geo1['lng']) + $geo1['lat']; |
|
| 306 | - if ($xinters == $lat) { // Check if point is on the polygon boundary (other than horizontal) |
|
| 307 | - return true; |
|
| 308 | - } |
|
| 309 | - if ($geo1['lat'] == $geo2['lat'] || $lat <= $xinters) { |
|
| 310 | - ++$intersections; |
|
| 311 | - } |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - // If the number of edges we passed through is odd, then it's in the polygon. |
|
| 315 | - return 0 != $intersections % 2; |
|
| 316 | - } else { |
|
| 317 | - return false; // outside bounds |
|
| 318 | - } |
|
| 291 | + if ($lat >= $bounds['minlat'] && $lat <= $bounds['maxlat'] && $lng >= $bounds['minlon'] && $lng <= $bounds['maxlon']) { |
|
| 292 | + $intersections = 0; |
|
| 293 | + $geos_count = count($geos); |
|
| 294 | + |
|
| 295 | + for ($i = 1; $i < $geos_count; ++$i) { |
|
| 296 | + $geo1 = $geos[$i - 1]; |
|
| 297 | + $geo2 = $geos[$i]; |
|
| 298 | + if ($geo1['lng'] == $lng && $geo1['lat'] == $lat) { // On one of the coords |
|
| 299 | + return true; |
|
| 300 | + } |
|
| 301 | + if ($geo1['lng'] == $geo2['lng'] and $geo1['lng'] == $lng and $lat > min($geo1['lat'], $geo2['lat']) and $lat < max($geo1['lat'], $geo2['lat'])) { // Check if point is on an horizontal polygon boundary |
|
| 302 | + return true; |
|
| 303 | + } |
|
| 304 | + if ($lng > min($geo1['lng'], $geo2['lng']) and $lng <= max($geo1['lng'], $geo2['lng']) and $lat <= max($geo1['lat'], $geo2['lat']) and $geo1['lng'] != $geo2['lng']) { |
|
| 305 | + $xinters = ($lng - $geo1['lng']) * ($geo2['lat'] - $geo1['lat']) / ($geo2['lng'] - $geo1['lng']) + $geo1['lat']; |
|
| 306 | + if ($xinters == $lat) { // Check if point is on the polygon boundary (other than horizontal) |
|
| 307 | + return true; |
|
| 308 | + } |
|
| 309 | + if ($geo1['lat'] == $geo2['lat'] || $lat <= $xinters) { |
|
| 310 | + ++$intersections; |
|
| 311 | + } |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + // If the number of edges we passed through is odd, then it's in the polygon. |
|
| 315 | + return 0 != $intersections % 2; |
|
| 316 | + } else { |
|
| 317 | + return false; // outside bounds |
|
| 318 | + } |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | //####################################################################### |
@@ -323,18 +323,18 @@ discard block |
||
| 323 | 323 | //####################################################################### |
| 324 | 324 | function polyIsInsidePolygon($geoIn, $boundsIn, $geoOut, $boundsOut) |
| 325 | 325 | { |
| 326 | - if ($boundsIn['minlat'] >= $boundsOut['minlat'] && $boundsIn['maxlat'] <= $boundsOut['maxlat'] && $boundsIn['minlon'] >= $boundsOut['minlon'] && $boundsIn['maxlon'] <= $boundsOut['maxlon']) { |
|
| 327 | - $insideCount = 0; |
|
| 328 | - foreach ($geoIn as $coord) { |
|
| 329 | - if (pointIsInsidePolygon($coord['lat'], $coord['lng'], $geoOut, $boundsOut)) { |
|
| 330 | - ++$insideCount; |
|
| 331 | - } |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - return $insideCount / count($geoIn) >= 0.95; |
|
| 335 | - } else { |
|
| 336 | - return false; // bounds outside |
|
| 337 | - } |
|
| 326 | + if ($boundsIn['minlat'] >= $boundsOut['minlat'] && $boundsIn['maxlat'] <= $boundsOut['maxlat'] && $boundsIn['minlon'] >= $boundsOut['minlon'] && $boundsIn['maxlon'] <= $boundsOut['maxlon']) { |
|
| 327 | + $insideCount = 0; |
|
| 328 | + foreach ($geoIn as $coord) { |
|
| 329 | + if (pointIsInsidePolygon($coord['lat'], $coord['lng'], $geoOut, $boundsOut)) { |
|
| 330 | + ++$insideCount; |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + return $insideCount / count($geoIn) >= 0.95; |
|
| 335 | + } else { |
|
| 336 | + return false; // bounds outside |
|
| 337 | + } |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | //####################################################################### |
@@ -342,45 +342,45 @@ discard block |
||
| 342 | 342 | //####################################################################### |
| 343 | 343 | function combineOuter($outers) |
| 344 | 344 | { |
| 345 | - $polygons = array(); |
|
| 346 | - $index = 0; |
|
| 347 | - $count = 0; |
|
| 348 | - $maxCount = count($outers); |
|
| 349 | - while (0 != count($outers) && $count <= $maxCount) { |
|
| 350 | - ++$count; |
|
| 351 | - foreach ($outers as $key => $outer) { |
|
| 352 | - if (!isset($polygons[$index])) { |
|
| 353 | - $polygons[$index] = $outer; |
|
| 354 | - unset($outers[$key]); |
|
| 355 | - } else { |
|
| 356 | - $firstEle = $outer[0]; |
|
| 357 | - $lastEle = $outer[count($outer) - 1]; |
|
| 358 | - $firstElePoly = $polygons[$index][0]; |
|
| 359 | - $lastElePoly = $polygons[$index][count($polygons[$index]) - 1]; |
|
| 360 | - if ($firstEle == $lastElePoly) { |
|
| 361 | - $polygons[$index] = array_merge($polygons[$index], $outer); |
|
| 362 | - unset($outers[$key]); |
|
| 363 | - } elseif ($lastEle == $lastElePoly) { |
|
| 364 | - $polygons[$index] = array_merge($polygons[$index], array_reverse($outer)); |
|
| 365 | - unset($outers[$key]); |
|
| 366 | - } elseif ($firstEle == $firstElePoly) { |
|
| 367 | - $polygons[$index] = array_merge(array_reverse($outer), $polygons[$index]); |
|
| 368 | - unset($outers[$key]); |
|
| 369 | - } elseif ($lastEle == $firstElePoly) { |
|
| 370 | - $polygons[$index] = array_merge($outer, $polygons[$index]); |
|
| 371 | - unset($outers[$key]); |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - $firstElePoly = $polygons[$index][0]; |
|
| 376 | - $lastElePoly = $polygons[$index][count($polygons[$index]) - 1]; |
|
| 377 | - if ($firstElePoly == $lastElePoly) { |
|
| 378 | - ++$index; |
|
| 379 | - } |
|
| 380 | - } |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - return $polygons; |
|
| 345 | + $polygons = array(); |
|
| 346 | + $index = 0; |
|
| 347 | + $count = 0; |
|
| 348 | + $maxCount = count($outers); |
|
| 349 | + while (0 != count($outers) && $count <= $maxCount) { |
|
| 350 | + ++$count; |
|
| 351 | + foreach ($outers as $key => $outer) { |
|
| 352 | + if (!isset($polygons[$index])) { |
|
| 353 | + $polygons[$index] = $outer; |
|
| 354 | + unset($outers[$key]); |
|
| 355 | + } else { |
|
| 356 | + $firstEle = $outer[0]; |
|
| 357 | + $lastEle = $outer[count($outer) - 1]; |
|
| 358 | + $firstElePoly = $polygons[$index][0]; |
|
| 359 | + $lastElePoly = $polygons[$index][count($polygons[$index]) - 1]; |
|
| 360 | + if ($firstEle == $lastElePoly) { |
|
| 361 | + $polygons[$index] = array_merge($polygons[$index], $outer); |
|
| 362 | + unset($outers[$key]); |
|
| 363 | + } elseif ($lastEle == $lastElePoly) { |
|
| 364 | + $polygons[$index] = array_merge($polygons[$index], array_reverse($outer)); |
|
| 365 | + unset($outers[$key]); |
|
| 366 | + } elseif ($firstEle == $firstElePoly) { |
|
| 367 | + $polygons[$index] = array_merge(array_reverse($outer), $polygons[$index]); |
|
| 368 | + unset($outers[$key]); |
|
| 369 | + } elseif ($lastEle == $firstElePoly) { |
|
| 370 | + $polygons[$index] = array_merge($outer, $polygons[$index]); |
|
| 371 | + unset($outers[$key]); |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + $firstElePoly = $polygons[$index][0]; |
|
| 376 | + $lastElePoly = $polygons[$index][count($polygons[$index]) - 1]; |
|
| 377 | + if ($firstElePoly == $lastElePoly) { |
|
| 378 | + ++$index; |
|
| 379 | + } |
|
| 380 | + } |
|
| 381 | + } |
|
| 382 | + |
|
| 383 | + return $polygons; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | //####################################################################### |
@@ -388,63 +388,63 @@ discard block |
||
| 388 | 388 | //####################################################################### |
| 389 | 389 | function printMenuitems($menu, $level, $locales) |
| 390 | 390 | { |
| 391 | - if (isset($menu->locale)) { |
|
| 392 | - $locale = $menu->locale; |
|
| 393 | - $text = $locales->$locale; |
|
| 394 | - } elseif (isset($menu->text)) { |
|
| 395 | - $text = $menu->text; |
|
| 396 | - } else { |
|
| 397 | - $text = ''; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - switch ($menu->type) { |
|
| 401 | - case 'group': |
|
| 402 | - ?> |
|
| 391 | + if (isset($menu->locale)) { |
|
| 392 | + $locale = $menu->locale; |
|
| 393 | + $text = $locales->$locale; |
|
| 394 | + } elseif (isset($menu->text)) { |
|
| 395 | + $text = $menu->text; |
|
| 396 | + } else { |
|
| 397 | + $text = ''; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + switch ($menu->type) { |
|
| 401 | + case 'group': |
|
| 402 | + ?> |
|
| 403 | 403 | |
| 404 | 404 | <li> |
| 405 | 405 | <a class="menu-label"><i class="fa <?= $menu->icon; ?>" aria-hidden="true"></i> <?= $text; ?></a> |
| 406 | 406 | <ul class="dropdown"> |
| 407 | 407 | |
| 408 | 408 | <?php |
| 409 | - foreach ($menu->members as $childmenu) { |
|
| 410 | - printMenuitems($childmenu, $level + 1, $locales); |
|
| 411 | - } |
|
| 412 | - ?> |
|
| 409 | + foreach ($menu->members as $childmenu) { |
|
| 410 | + printMenuitems($childmenu, $level + 1, $locales); |
|
| 411 | + } |
|
| 412 | + ?> |
|
| 413 | 413 | |
| 414 | 414 | </ul> |
| 415 | 415 | </li> |
| 416 | 416 | |
| 417 | 417 | <?php |
| 418 | - break; |
|
| 418 | + break; |
|
| 419 | 419 | |
| 420 | - case 'link': |
|
| 421 | - ?> |
|
| 420 | + case 'link': |
|
| 421 | + ?> |
|
| 422 | 422 | |
| 423 | 423 | <li> |
| 424 | 424 | <a href="<?= $menu->href; ?>" class="menu-label"><i class="fa <?= $menu->icon; ?>" aria-hidden="true"></i> <?= $text; ?></a> |
| 425 | 425 | </li> |
| 426 | 426 | |
| 427 | 427 | <?php |
| 428 | - break; |
|
| 428 | + break; |
|
| 429 | 429 | |
| 430 | - case 'link_external': |
|
| 431 | - ?> |
|
| 430 | + case 'link_external': |
|
| 431 | + ?> |
|
| 432 | 432 | |
| 433 | 433 | <li> |
| 434 | 434 | <a href="<?= $menu->href; ?>" target="_blank" class="menu-label"><i class="fa <?= $menu->icon; ?>" aria-hidden="true"></i> <?= $menu->text; ?></a> |
| 435 | 435 | </li> |
| 436 | 436 | |
| 437 | 437 | <?php |
| 438 | - break; |
|
| 438 | + break; |
|
| 439 | 439 | |
| 440 | - case 'html': |
|
| 441 | - ?> |
|
| 440 | + case 'html': |
|
| 441 | + ?> |
|
| 442 | 442 | |
| 443 | 443 | <li> <?= $menu->value; ?> </li> |
| 444 | 444 | |
| 445 | 445 | <?php |
| 446 | - break; |
|
| 447 | - } |
|
| 446 | + break; |
|
| 447 | + } |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | ?> |