Add getIPAddress() (Bug #8620).
authorJan Schneider <jan@horde.org>
Thu, 1 Oct 2009 13:37:37 +0000 (15:37 +0200)
committerJan Schneider <jan@horde.org>
Thu, 1 Oct 2009 13:37:53 +0000 (15:37 +0200)
framework/Browser/lib/Horde/Browser.php

index bedb46d..4520c1d 100644 (file)
@@ -961,6 +961,18 @@ class Horde_Browser
     }
 
     /**
+     * Returns the IP address of the client.
+     *
+     * @return string  The client IP address.
+     */
+    public function getIPAddress()
+    {
+        return empty($_SERVER['HTTP_X_FORWARDED_FOR'])
+            ? $_SERVER['REMOTE_ADDR']
+            : $_SERVER['HTTP_X_FORWARDED_FOR'];
+    }
+
+    /**
      * Determines if files can be uploaded to the system.
      *
      * @return integer  If uploads allowed, returns the maximum size of the