@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return array|null |
| 53 | 53 | */ |
| 54 | - public function current(){ |
|
| 54 | + public function current() { |
|
| 55 | 55 | return $this->get($this->remote_address->getIpAddress()); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | * |
| 62 | 62 | * @return array|null |
| 63 | 63 | */ |
| 64 | - public function get($ip){ |
|
| 64 | + public function get($ip) { |
|
| 65 | 65 | if (isset($this->cache[$ip])) { |
| 66 | 66 | return $this->cache[$ip]; |
| 67 | 67 | } |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | $output = curl_exec($ch); |
| 89 | 89 | curl_close($ch); |
| 90 | 90 | |
| 91 | - if($output == false) { |
|
| 91 | + if ($output == false) { |
|
| 92 | 92 | sleep(1); |
| 93 | - }else{ |
|
| 93 | + } else { |
|
| 94 | 94 | return json_decode($output, true); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $retries++; |
| 98 | 98 | } |
| 99 | - while($retries > 0); |
|
| 99 | + while ($retries > 0); |
|
| 100 | 100 | |
| 101 | 101 | return null; |
| 102 | 102 | } |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | |
| 91 | 91 | if($output == false) { |
| 92 | 92 | sleep(1); |
| 93 | - }else{ |
|
| 93 | + } else{ |
|
| 94 | 94 | return json_decode($output, true); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | public function boot() { |
| 31 | 31 | $this->publishes([ |
| 32 | - __DIR__ . '/../config/geoip.php' => config_path('geoip.php'), |
|
| 32 | + __DIR__.'/../config/geoip.php' => config_path('geoip.php'), |
|
| 33 | 33 | ]); |
| 34 | 34 | } |
| 35 | 35 | |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | private function setVendorConfig() { |
| 57 | 57 | $config_key = 'geoip'; |
| 58 | - $path = __DIR__ . '/../config/' . $config_key . '.php'; |
|
| 58 | + $path = __DIR__.'/../config/'.$config_key.'.php'; |
|
| 59 | 59 | |
| 60 | 60 | $vendor_config = require $path; |
| 61 | 61 | $config = $this->app['config']->get($config_key); |
@@ -86,11 +86,15 @@ discard block |
||
| 86 | 86 | $arrays = func_get_args(); |
| 87 | 87 | $base = array_shift($arrays); |
| 88 | 88 | |
| 89 | - if (!is_array($base)) $base = empty($base) ? array() : array($base); |
|
| 89 | + if (!is_array($base)) { |
|
| 90 | + $base = empty($base) ? array() : array($base); |
|
| 91 | + } |
|
| 90 | 92 | |
| 91 | 93 | foreach ($arrays as $append) { |
| 92 | 94 | |
| 93 | - if (!is_array($append)) $append = array($append); |
|
| 95 | + if (!is_array($append)) { |
|
| 96 | + $append = array($append); |
|
| 97 | + } |
|
| 94 | 98 | |
| 95 | 99 | foreach ($append as $key => $value) { |
| 96 | 100 | |
@@ -102,7 +106,9 @@ discard block |
||
| 102 | 106 | if (is_array($value) or is_array($base[$key])) { |
| 103 | 107 | $base[$key] = $this->array_merge_recursive_distinct($base[$key], $append[$key]); |
| 104 | 108 | } else if (is_numeric($key)) { |
| 105 | - if (!in_array($value, $base)) $base[] = $value; |
|
| 109 | + if (!in_array($value, $base)) { |
|
| 110 | + $base[] = $value; |
|
| 111 | + } |
|
| 106 | 112 | } else { |
| 107 | 113 | $base[$key] = $value; |
| 108 | 114 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | public function getIpAddress() { |
| 106 | 106 | $ip_address = $this->getIpAddressFromProxy(); |
| 107 | 107 | |
| 108 | - if($ip_address == "127.0.0.1" || strlen($ip_address) < 7) { |
|
| 108 | + if ($ip_address == "127.0.0.1" || strlen($ip_address) < 7) { |
|
| 109 | 109 | $ip_address = false; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | $ip_address = $this->getServerVariable("REMOTE_ADDR"); |
| 117 | 117 | |
| 118 | - if(strlen($ip_address) < 7) { |
|
| 118 | + if (strlen($ip_address) < 7) { |
|
| 119 | 119 | $ip_address = "127.0.0.1"; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | $header = strtoupper($header); |
| 176 | 176 | $header = str_replace('-', '_', $header); |
| 177 | 177 | if (0 !== strpos($header, 'HTTP_')) { |
| 178 | - $header = 'HTTP_' . $header; |
|
| 178 | + $header = 'HTTP_'.$header; |
|
| 179 | 179 | } |
| 180 | 180 | return $header; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | - protected function getServerVariable($key, $default = null){ |
|
| 183 | + protected function getServerVariable($key, $default = null) { |
|
| 184 | 184 | if (!isset($_SERVER[$key]) || empty($_SERVER[$key])) { |
| 185 | 185 | return $default; |
| 186 | 186 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | /** |
| 192 | 192 | * @return bool |
| 193 | 193 | */ |
| 194 | - public function isProxy(){ |
|
| 194 | + public function isProxy() { |
|
| 195 | 195 | $test_HTTP_proxy_headers = [ |
| 196 | 196 | 'HTTP_VIA', |
| 197 | 197 | 'VIA', |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | 'HTTP_PROXY_CONNECTION' |
| 218 | 218 | ]; |
| 219 | 219 | |
| 220 | - foreach($test_HTTP_proxy_headers as $header){ |
|
| 220 | + foreach ($test_HTTP_proxy_headers as $header) { |
|
| 221 | 221 | if ($this->getServerVariable($header, false)) { |
| 222 | 222 | return true; |
| 223 | 223 | } |
@@ -248,8 +248,9 @@ |
||
| 248 | 248 | } else { |
| 249 | 249 | $myisp = $isp[1].'.'.$isp[0]; |
| 250 | 250 | } |
| 251 | - if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $myisp)) |
|
| 252 | - return null; |
|
| 251 | + if (preg_match("/[0-9]{1,3}\.[0-9]{1,3}/", $myisp)) { |
|
| 252 | + return null; |
|
| 253 | + } |
|
| 253 | 254 | |
| 254 | 255 | $isp = explode('.', $myisp); |
| 255 | 256 | return $isp[0]; |