@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return array Sorted list of "accept" options |
| 21 | 21 | */ |
| 22 | -$sortAccept = function ($header) { |
|
| 22 | +$sortAccept = function($header) { |
|
| 23 | 23 | $matches = array(); |
| 24 | 24 | foreach (explode(',', $header) as $option) { |
| 25 | 25 | $option = array_map('trim', explode(';', $option)); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return string|NULL a matched option, or NULL if no match |
| 54 | 54 | */ |
| 55 | -$matchAccept = function ($header, $supported) use ($sortAccept) { |
|
| 55 | +$matchAccept = function($header, $supported) use ($sortAccept) { |
|
| 56 | 56 | $matches = $sortAccept($header); |
| 57 | 57 | foreach ($matches as $key => $q) { |
| 58 | 58 | if (isset($supported[$key])) { |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * |
| 84 | 84 | * @return string The negotiated language result or the supplied default. |
| 85 | 85 | */ |
| 86 | -$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) { |
|
| 86 | +$negotiateLanguage = function($supported, $default = 'en-US') use ($matchAccept) { |
|
| 87 | 87 | $supp = array(); |
| 88 | 88 | foreach ($supported as $lang => $isSupported) { |
| 89 | 89 | if ($isSupported) { |
@@ -19,7 +19,8 @@ discard block |
||
| 19 | 19 | * |
| 20 | 20 | * @return array Sorted list of "accept" options |
| 21 | 21 | */ |
| 22 | -$sortAccept = function ($header) { |
|
| 22 | +$sortAccept = function ($header) |
|
| 23 | +{ |
|
| 23 | 24 | $matches = array(); |
| 24 | 25 | foreach (explode(',', $header) as $option) { |
| 25 | 26 | $option = array_map('trim', explode(';', $option)); |
@@ -52,7 +53,8 @@ discard block |
||
| 52 | 53 | * |
| 53 | 54 | * @return string|NULL a matched option, or NULL if no match |
| 54 | 55 | */ |
| 55 | -$matchAccept = function ($header, $supported) use ($sortAccept) { |
|
| 56 | +$matchAccept = function ($header, $supported) use ($sortAccept) |
|
| 57 | +{ |
|
| 56 | 58 | $matches = $sortAccept($header); |
| 57 | 59 | foreach ($matches as $key => $q) { |
| 58 | 60 | if (isset($supported[$key])) { |
@@ -83,7 +85,8 @@ discard block |
||
| 83 | 85 | * |
| 84 | 86 | * @return string The negotiated language result or the supplied default. |
| 85 | 87 | */ |
| 86 | -$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) { |
|
| 88 | +$negotiateLanguage = function ($supported, $default = 'en-US') use ($matchAccept) |
|
| 89 | +{ |
|
| 87 | 90 | $supp = array(); |
| 88 | 91 | foreach ($supported as $lang => $isSupported) { |
| 89 | 92 | if ($isSupported) { |
@@ -177,7 +177,8 @@ discard block |
||
| 177 | 177 | // |
| 178 | 178 | // Retruns max depth of array |
| 179 | 179 | ######################################################################## |
| 180 | -function get_depth($arr) { |
|
| 180 | +function get_depth($arr) |
|
| 181 | +{ |
|
| 181 | 182 | $it = new RecursiveIteratorIterator(new RecursiveArrayIterator($arr)); |
| 182 | 183 | $depth = 0; |
| 183 | 184 | foreach ($it as $v) { |
@@ -195,12 +196,16 @@ discard block |
||
| 195 | 196 | // |
| 196 | 197 | // Return all pokemon with data at a certain tree depth |
| 197 | 198 | ######################################################################## |
| 198 | -function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) { |
|
| 199 | - if ($depth == $currentDepth) { // Found depth |
|
| 199 | +function get_tree_at_depth($trees, $depth, $max_pokemon, $currentDepth = 0) |
|
| 200 | +{ |
|
| 201 | + if ($depth == $currentDepth) { |
|
| 202 | +// Found depth |
|
| 200 | 203 | return tree_remove_bellow($trees, $max_pokemon); |
| 201 | - } else { // Go deeper |
|
| 204 | + } else { |
|
| 205 | +// Go deeper |
|
| 202 | 206 | $arr = array(); |
| 203 | - foreach ($trees as $temp) { // Go into all trees |
|
| 207 | + foreach ($trees as $temp) { |
|
| 208 | +// Go into all trees |
|
| 204 | 209 | $tree = $temp->evolutions; |
| 205 | 210 | $results = tree_remove_bellow(get_tree_at_depth($tree, $depth, $max_pokemon, $currentDepth + 1), $max_pokemon); |
| 206 | 211 | $arr = tree_check_array($results, $arr, $depth - $currentDepth == 1); |
@@ -212,12 +217,16 @@ discard block |
||
| 212 | 217 | ######################################################################## |
| 213 | 218 | // used in get_tree_at_depth |
| 214 | 219 | ######################################################################## |
| 215 | -function tree_check_array($array_check, $array_add, $correct_arrow) { |
|
| 220 | +function tree_check_array($array_check, $array_add, $correct_arrow) |
|
| 221 | +{ |
|
| 216 | 222 | $count = count($array_check); |
| 217 | 223 | $i = 0; |
| 218 | - if (!is_null($array_check)) { // check if exists |
|
| 219 | - foreach ($array_check as $res) { // Check if above, equal or bellow center |
|
| 220 | - if ($count != 1 && $correct_arrow) { // only add arrow once |
|
| 224 | + if (!is_null($array_check)) { |
|
| 225 | +// check if exists |
|
| 226 | + foreach ($array_check as $res) { |
|
| 227 | +// Check if above, equal or bellow center |
|
| 228 | + if ($count != 1 && $correct_arrow) { |
|
| 229 | +// only add arrow once |
|
| 221 | 230 | $num = $i / ($count - 1); |
| 222 | 231 | if ($num < 0.5) { |
| 223 | 232 | $res->array_sufix = "_up"; |
@@ -241,7 +250,8 @@ discard block |
||
| 241 | 250 | return null; |
| 242 | 251 | } |
| 243 | 252 | $arr = array(); |
| 244 | - foreach ($tree as $item) { // Check if above, equal or bellow center |
|
| 253 | + foreach ($tree as $item) { |
|
| 254 | +// Check if above, equal or bellow center |
|
| 245 | 255 | if ($item->id <= $max_pokemon) { |
| 246 | 256 | $arr[] = $item; |
| 247 | 257 | } |
@@ -323,8 +323,7 @@ |
||
| 323 | 323 | } elseif (isset($obj->info)) { |
| 324 | 324 | $infoName = 'INFO_' . $obj->info; |
| 325 | 325 | echo '<br>(' . $locales->$infoName . ')'; |
| 326 | - } |
|
| 327 | - else { |
|
| 326 | + } else { |
|
| 328 | 327 | echo '<br> </br>'; |
| 329 | 328 | } |
| 330 | 329 | ?> |
@@ -316,11 +316,11 @@ |
||
| 316 | 316 | <img src="core/img/arrow<?=$obj->array_sufix?>.png" alt="Arrow" class="img"> |
| 317 | 317 | <p class="pkmn-name"> |
| 318 | 318 | <?php |
| 319 | - if (isset($obj->candies)) { |
|
| 320 | - echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 321 | - } else { |
|
| 322 | - echo '? ' . $locales->POKEMON_CANDIES; |
|
| 323 | - } |
|
| 319 | + if (isset($obj->candies)) { |
|
| 320 | + echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 321 | + } else { |
|
| 322 | + echo '? ' . $locales->POKEMON_CANDIES; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | 325 | if (isset($obj->item)) { |
| 326 | 326 | $itemName = 'ITEM_' . $obj->item; |
@@ -317,17 +317,17 @@ |
||
| 317 | 317 | <p class="pkmn-name"> |
| 318 | 318 | <?php |
| 319 | 319 | if (isset($obj->candies)) { |
| 320 | - echo $obj->candies . ' ' . $locales->POKEMON_CANDIES; |
|
| 320 | + echo $obj->candies.' '.$locales->POKEMON_CANDIES; |
|
| 321 | 321 | } else { |
| 322 | - echo '? ' . $locales->POKEMON_CANDIES; |
|
| 322 | + echo '? '.$locales->POKEMON_CANDIES; |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | if (isset($obj->item)) { |
| 326 | - $itemName = 'ITEM_' . $obj->item; |
|
| 327 | - echo '<br>+ ' . $locales->$itemName; |
|
| 326 | + $itemName = 'ITEM_'.$obj->item; |
|
| 327 | + echo '<br>+ '.$locales->$itemName; |
|
| 328 | 328 | } elseif (isset($obj->info)) { |
| 329 | - $infoName = 'INFO_' . $obj->info; |
|
| 330 | - echo '<br>(' . $locales->$infoName . ')'; |
|
| 329 | + $infoName = 'INFO_'.$obj->info; |
|
| 330 | + echo '<br>('.$locales->$infoName.')'; |
|
| 331 | 331 | } |
| 332 | 332 | else { |
| 333 | 333 | echo '<br> </br>'; |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | $rarityarray = array(); |
| 23 | 23 | foreach ($counts as $poke_id => $total) { |
| 24 | 24 | $rarity = $pokemons->pokemon->$poke_id->rarity; |
| 25 | - isset($rarityarray[$rarity]) ? $rarityarray[$rarity]+=$total : $rarityarray[$rarity]=$total; |
|
| 25 | + isset($rarityarray[$rarity]) ? $rarityarray[$rarity] += $total : $rarityarray[$rarity] = $total; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | // Set amount of Pokemon for each rarity to 0 if there weren't any at that time |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | // Load Query Manager |
| 30 | 30 | // ################### |
| 31 | 31 | |
| 32 | -include_once __DIR__ . '/../process/queries/QueryManager.php'; |
|
| 32 | +include_once __DIR__.'/../process/queries/QueryManager.php'; |
|
| 33 | 33 | $manager = QueryManager::current(); |
| 34 | 34 | |
| 35 | 35 | |
@@ -51,10 +51,10 @@ discard block |
||
| 51 | 51 | $pokedatas = json_decode(file_get_contents($pokemonstats_file), true); |
| 52 | 52 | } |
| 53 | 53 | if (is_file($pokedex_counts_file)) { |
| 54 | - $pokecountdatas = json_decode(file_get_contents($pokedex_counts_file), true); |
|
| 54 | + $pokecountdatas = json_decode(file_get_contents($pokedex_counts_file), true); |
|
| 55 | 55 | } |
| 56 | 56 | if (is_file($pokedex_raids_file)) { |
| 57 | - $raiddatas = json_decode(file_get_contents($pokedex_raids_file), true); |
|
| 57 | + $raiddatas = json_decode(file_get_contents($pokedex_raids_file), true); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | $trainer_lvl = []; |
| 29 | 29 | # For all 3 teams |
| 30 | 30 | for ($teamid = 1; $teamid <= 3; $teamid++) { |
| 31 | - $data = $manager->getTrainerLevelCount($teamid); |
|
| 31 | + $data = $manager->getTrainerLevelCount($teamid); |
|
| 32 | 32 | $trainer_lvl[$teamid] = $data; |
| 33 | 33 | } |
| 34 | 34 | |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | // Load Query Manager |
| 21 | 21 | // ################### |
| 22 | 22 | |
| 23 | -include_once __DIR__ . '/../process/queries/QueryManager.php'; |
|
| 23 | +include_once __DIR__.'/../process/queries/QueryManager.php'; |
|
| 24 | 24 | $manager = QueryManager::current(); |
| 25 | 25 | |
| 26 | 26 | # Chart Graph datas |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | // Load Query Manager |
| 70 | 70 | // ################### |
| 71 | 71 | |
| 72 | -include_once __DIR__ . '/queries/QueryManager.php'; |
|
| 72 | +include_once __DIR__.'/queries/QueryManager.php'; |
|
| 73 | 73 | $manager = QueryManager::current(); |
| 74 | 74 | |
| 75 | 75 | |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | |
| 270 | 270 | // Gym owned and average points |
| 271 | - $data = $manager->getOwnedAndPoints($team_values->id); |
|
| 271 | + $data = $manager->getOwnedAndPoints($team_values->id); |
|
| 272 | 272 | |
| 273 | 273 | $teams->$team_key->gym_owned = $data->total; |
| 274 | 274 | $teams->$team_key->average = $data->average_points; |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | // Load Query Manager |
| 4 | 4 | // ################### |
| 5 | 5 | |
| 6 | -include_once __DIR__ . '/../core/process/queries/QueryManager.php'; |
|
| 6 | +include_once __DIR__.'/../core/process/queries/QueryManager.php'; |
|
| 7 | 7 | |
| 8 | 8 | |
| 9 | 9 | ######################################################################## |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -include_once __DIR__ . '/QueryManagerPostgresqlMonocleAlternate.php'; |
|
| 3 | +include_once __DIR__.'/QueryManagerPostgresqlMonocleAlternate.php'; |
|
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | abstract class QueryManagerPostgresql extends QueryManager { |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $this->db = pg_connect("host=".SYS_DB_HOST." port=".SYS_DB_PORT." dbname=".SYS_DB_NAME." user=".SYS_DB_USER." password=".SYS_DB_PSWD); |
| 13 | 13 | |
| 14 | 14 | if ($this->db === false) { |
| 15 | - header('Location:' . HOST_URL . 'offline.html'); |
|
| 15 | + header('Location:'.HOST_URL.'offline.html'); |
|
| 16 | 16 | exit(); |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -3,11 +3,13 @@ discard block |
||
| 3 | 3 | include_once __DIR__ . '/QueryManagerPostgresqlMonocleAlternate.php'; |
| 4 | 4 | |
| 5 | 5 | |
| 6 | -abstract class QueryManagerPostgresql extends QueryManager { |
|
| 6 | +abstract class QueryManagerPostgresql extends QueryManager |
|
| 7 | +{ |
|
| 7 | 8 | |
| 8 | 9 | protected $db; |
| 9 | 10 | |
| 10 | - protected function __construct() { |
|
| 11 | + protected function __construct() |
|
| 12 | + { |
|
| 11 | 13 | |
| 12 | 14 | $this->db = pg_connect("host=".SYS_DB_HOST." port=".SYS_DB_PORT." dbname=".SYS_DB_NAME." user=".SYS_DB_USER." password=".SYS_DB_PSWD); |
| 13 | 15 | |
@@ -17,7 +19,8 @@ discard block |
||
| 17 | 19 | } |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | - public function __destruct() { |
|
| 22 | + public function __destruct() |
|
| 23 | + { |
|
| 21 | 24 | pg_close($this->db); |
| 22 | 25 | } |
| 23 | 26 | |
@@ -25,7 +28,8 @@ discard block |
||
| 25 | 28 | // Misc |
| 26 | 29 | ///////// |
| 27 | 30 | |
| 28 | - public function getEcapedString($string) { |
|
| 31 | + public function getEcapedString($string) |
|
| 32 | + { |
|
| 29 | 33 | return pg_escape_string($this->db, $string); |
| 30 | 34 | } |
| 31 | 35 | |