From 9f04fef3e046d7b4778ddf449589c9b1a3a67857 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 30 Mar 2009 18:09:17 +0000 Subject: Updated to r807 --- kohana/libraries/Input.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'kohana/libraries/Input.php') 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) -- cgit v1.2.3