summaryrefslogtreecommitdiffstats
path: root/system/core/Input.php
diff options
context:
space:
mode:
authorDaniel Morris <daniel@honestempire.com>2012-10-04 23:28:38 +0200
committerDaniel Morris <daniel@honestempire.com>2012-10-04 23:28:38 +0200
commit0fc4a10fab7041585def63ff562f5247790915f3 (patch)
treefdaf8ce4f07b712fa4388b0d84b457b28c46cf29 /system/core/Input.php
parent7885c5cac9932e0598719682522b1c4902c15876 (diff)
parent5b92ae1dfb6ac99630693d193b0d3f60f9df525f (diff)
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into develop
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'))