From 440cca59013e65b8d6a20425d863db7d50b09336 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 10 Jan 2013 09:39:21 -0800 Subject: [PATCH] Minor code changes --- flight/net/Request.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/flight/net/Request.php b/flight/net/Request.php index 3baefe1..26c991a 100644 --- a/flight/net/Request.php +++ b/flight/net/Request.php @@ -46,7 +46,7 @@ class Request { 'base' => str_replace('\\', '/', dirname(getenv('SCRIPT_NAME'))), 'method' => getenv('REQUEST_METHOD') ?: 'GET', 'referrer' => getenv('HTTP_REFERER') ?: '', - 'ip' => getenv('REMOTE_ADDR'), + 'ip' => getenv('REMOTE_ADDR') ?: '', 'ajax' => getenv('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest', 'scheme' => getenv('SERVER_PROTOCOL') ?: 'HTTP/1.1', 'user_agent' => getenv('HTTP_USER_AGENT') ?: '', @@ -59,7 +59,7 @@ class Request { 'files' => new Collection($_FILES), 'secure' => getenv('HTTPS') && getenv('HTTPS') != 'off', 'accept' => getenv('HTTP_ACCEPT'), - 'proxy' => $this->getProxyIpAddress() + 'proxy_ip' => $this->getProxyIpAddress() ); } @@ -121,16 +121,19 @@ class Request { 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED' ); + $flags = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE; foreach ($forwarded as $key) { if (array_key_exists($key, $_SERVER)) { sscanf($_SERVER[$key], '%[^,]', $ip); - if(filter_var($ip, FILTER_VALIDATE_IP, $flags) !== false) { + if (filter_var($ip, \FILTER_VALIDATE_IP, $flags) !== false) { return $ip; } } } + + return ''; } } ?>