@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | * @var array |
| 12 | 12 | */ |
| 13 | 13 | private $privateIp = array( |
| 14 | - '/^0\./','/^127\.0\.0\.1/', |
|
| 15 | - '/^192\.168\..*/','/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', |
|
| 14 | + '/^0\./', '/^127\.0\.0\.1/', |
|
| 15 | + '/^192\.168\..*/', '/^172\.((1[6-9])|(2[0-9])|(3[0-1]))\..*/', |
|
| 16 | 16 | '/^10\..*/' |
| 17 | 17 | ); |
| 18 | 18 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $hostname = NULL; |
| 62 | 62 | |
| 63 | - if(!is_null($this->ip)) { |
|
| 63 | + if (!is_null($this->ip)) { |
|
| 64 | 64 | $hostname = gethostbyaddr($this->ip); |
| 65 | 65 | } |
| 66 | 66 | return $hostname; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | private function getIpForwarded() |
| 74 | 74 | { |
| 75 | - if(!!$this->isHttpXForwardedFor()) { |
|
| 75 | + if (!!$this->isHttpXForwardedFor()) { |
|
| 76 | 76 | $entries = $this->getHttpXForwardedForEntities(); |
| 77 | 77 | $this->ip = $this->getXForwardedIp($entries); |
| 78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private function isHttpXForwardedFor() |
| 86 | 86 | { |
| 87 | - return !!isset($this->server['HTTP_X_FORWARDED_FOR'])&&$this->server['HTTP_X_FORWARDED_FOR']!=''; |
|
| 87 | + return !!isset($this->server['HTTP_X_FORWARDED_FOR']) && $this->server['HTTP_X_FORWARDED_FOR'] != ''; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | $ip = $this->ip; |
| 109 | 109 | while (list(, $entry) = each($entries)) { |
| 110 | 110 | $entry = trim($entry); |
| 111 | - if ( preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list)) { |
|
| 112 | - $found_ip = preg_replace( $this->privateIp, $ip, $ip_list[1]); |
|
| 111 | + if (preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", $entry, $ip_list)) { |
|
| 112 | + $found_ip = preg_replace($this->privateIp, $ip, $ip_list[1]); |
|
| 113 | 113 | |
| 114 | 114 | if ($ip != $found_ip) { |
| 115 | 115 | $ip = $found_ip; |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | private function getRemodeAddr() |
| 128 | 128 | { |
| 129 | 129 | $ip = NULL; |
| 130 | - if(PHP_SAPI=='cli') { |
|
| 130 | + if (PHP_SAPI == 'cli') { |
|
| 131 | 131 | $ip = gethostbyname(gethostname()); |
| 132 | - } elseif($this->hasServerRemoteAddr()) { |
|
| 132 | + } elseif ($this->hasServerRemoteAddr()) { |
|
| 133 | 133 | $ip = $this->server['REMOTE_ADDR']; |
| 134 | - } elseif($this->hasEnvRemoteAddr()) { |
|
| 134 | + } elseif ($this->hasEnvRemoteAddr()) { |
|
| 135 | 135 | $ip = $this->env['REMOTE_ADDR']; |
| 136 | 136 | } |
| 137 | 137 | return $ip; |