Index: branches/5.2.x/core/kernel/utility/http_query.php =================================================================== diff -u -N -r15345 -r15569 --- branches/5.2.x/core/kernel/utility/http_query.php (.../http_query.php) (revision 15345) +++ branches/5.2.x/core/kernel/utility/http_query.php (.../http_query.php) (revision 15569) @@ -1,6 +1,6 @@ _trustProxy = isset($vars['TrustProxy']) ? (bool)$vars['TrustProxy'] : false; } /** @@ -717,7 +728,7 @@ $user_id = $session->GetField('PortalUserId'); $admin_mark = $this->Application->isAdmin ? 'ADMIN' : 'FRONT'; - $data = '[' . date('D M d H:i:s Y') . '] ' . $admin_mark . '; ip: ' . $_SERVER['REMOTE_ADDR'] . '; user_id: ' . $user_id . '; sid: ' . $this->Application->GetSID() . '; request: ' . "\n"; + $data = '[' . date('D M d H:i:s Y') . '] ' . $admin_mark . '; ip: ' . $this->getClientIp() . '; user_id: ' . $user_id . '; sid: ' . $this->Application->GetSID() . '; request: ' . "\n"; if ( $this->Get ) { $data .= "_GET:\n" . print_r($this->Get, true); } @@ -758,4 +769,34 @@ return !count($this->Get); } + /** + * Returns the client IP address. + * + * @return string The client IP address + * @access public + */ + public function getClientIp() + { + if ( $this->_trustProxy ) { + if ( array_key_exists('HTTP_CLIENT_IP', $_SERVER) ) { + return $_SERVER['HTTP_CLIENT_IP']; + } + + if ( array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) ) { + $client_ip = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); + + foreach ($client_ip as $ip_address) { + $clean_ip_address = trim($ip_address); + + if ( false !== filter_var($clean_ip_address, FILTER_VALIDATE_IP) ) { + return $clean_ip_address; + } + } + + return ''; + } + } + + return $_SERVER['REMOTE_ADDR']; + } } \ No newline at end of file