summaryrefslogtreecommitdiff
path: root/kohana/libraries/Input.php
diff options
context:
space:
mode:
Diffstat (limited to 'kohana/libraries/Input.php')
-rw-r--r--kohana/libraries/Input.php21
1 files changed, 11 insertions, 10 deletions
diff --git a/kohana/libraries/Input.php b/kohana/libraries/Input.php
index 04e8ee4d..4549bf4a 100644
--- a/kohana/libraries/Input.php
+++ b/kohana/libraries/Input.php
@@ -237,17 +237,18 @@ class Input_Core {
if ($this->ip_address !== NULL)
return $this->ip_address;
- if ($ip = $this->server('HTTP_CLIENT_IP'))
- {
- $this->ip_address = $ip;
- }
- elseif ($ip = $this->server('REMOTE_ADDR'))
- {
- $this->ip_address = $ip;
- }
- elseif ($ip = $this->server('HTTP_X_FORWARDED_FOR'))
+ // Server keys that could contain the client IP address
+ $keys = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'REMOTE_ADDR');
+
+ foreach ($keys as $key)
{
- $this->ip_address = $ip;
+ if ($ip = $this->server($key))
+ {
+ $this->ip_address = $ip;
+
+ // An IP address has been found
+ break;
+ }
}
if ($comma = strrpos($this->ip_address, ',') !== FALSE)