summaryrefslogtreecommitdiffstats
path: root/system/core/Input.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-10-04 12:05:03 +0200
committerAndrey Andreev <narf@bofh.bg>2012-10-04 12:05:03 +0200
commit5b92ae1dfb6ac99630693d193b0d3f60f9df525f (patch)
tree82fabae2546d11a3c0fae58910b816edfd0766ca /system/core/Input.php
parent226e7042ee4e9259b024b94a8b7e9ffa3bfcaa7c (diff)
Misc. style fixes [ci skip]
Diffstat (limited to 'system/core/Input.php')
-rw-r--r--system/core/Input.php20
1 files changed, 12 insertions, 8 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index 5b8e62389..657fce625 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -330,10 +330,10 @@ class CI_Input {
if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR'))
{
- $has_ranges = strpos($proxies, '/') !== false;
+ $has_ranges = strpos($proxies, '/') !== FALSE;
$proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY);
$proxies = is_array($proxies) ? $proxies : array($proxies);
-
+
if ($has_ranges)
{
$long_ip = ip2long($_SERVER['REMOTE_ADDR']);
@@ -341,21 +341,25 @@ class CI_Input {
// Go through each of the IP Addresses to check for and
// test against range notation
- foreach($proxies as $ip)
+ foreach ($proxies as $ip)
{
- list($address, $mask_length) = explode('/', $ip);
+ list($address, $mask_length) = explode('/', $ip, 2);
// Generate the bitmask for a 32 bit IP Address
- $bitmask = $bit_32 - (1 << (32 - (int)$mask_length));
- if (($long_ip & $bitmask) == $address)
+ $bitmask = $bit_32 - (1 << (32 - (int) $mask_length));
+ if (($long_ip & $bitmask) === $address)
{
$this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
break;
}
}
- } else {
- $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
+ }
+ else
+ {
+ $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies)
+ ? $_SERVER['HTTP_X_FORWARDED_FOR']
+ : $_SERVER['REMOTE_ADDR'];
}
}
elseif ( ! $this->server('HTTP_CLIENT_IP') && $this->server('REMOTE_ADDR'))