diff options
author | Jeffery To <jeffery.to@gmail.com> | 2009-08-02 20:10:31 +0800 |
---|---|---|
committer | Jeffery To <jeffery.to@gmail.com> | 2009-08-02 20:10:31 +0800 |
commit | e670e4306bf3e0e7e90523bcbfa2eb8060f4ed67 (patch) | |
tree | a266d202e817f77ad74e04328be0c18b123ba537 /lib | |
parent | 20c536fdd461c8f39dd6a03751b534a996a94078 (diff) |
Fixed PHP Notices:
Undefined index: HTTP_X_FORWARDED_FOR
Undefined index: HTTP_CLIENT_IP
Undefined variable: proxy
Also fixed the return value order to match calls to common_client_ip() in actions/api.php and lib/rssaction.php
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/util.php b/lib/util.php index db794181c..c8e318efe 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1410,20 +1410,21 @@ function common_client_ip() return null; } - if ($_SERVER['HTTP_X_FORWARDED_FOR']) { - if ($_SERVER['HTTP_CLIENT_IP']) { + if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { + if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) { $proxy = $_SERVER['HTTP_CLIENT_IP']; } else { $proxy = $_SERVER['REMOTE_ADDR']; } $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { - if ($_SERVER['HTTP_CLIENT_IP']) { + $proxy = null; + if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) { $ip = $_SERVER['HTTP_CLIENT_IP']; } else { $ip = $_SERVER['REMOTE_ADDR']; } } - return array($ip, $proxy); + return array($proxy, $ip); } |