]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fixed PHP Notices:
authorJeffery To <jeffery.to@gmail.com>
Sun, 2 Aug 2009 12:10:31 +0000 (20:10 +0800)
committerJeffery To <jeffery.to@gmail.com>
Sun, 2 Aug 2009 12:10:31 +0000 (20:10 +0800)
    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

lib/util.php

index db794181ca63d75abf23e5ddf23cf9503124ef74..c8e318efec6e4491157e16d6444ab46de7db84f7 100644 (file)
@@ -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);
 }