From 4d480b36ea4b503ed997b1b9c60c433b5508e4aa Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 17 Jul 2013 08:04:15 +0200 Subject: Respect HTTP_X_FORWARDED_FOR and HTTP_X_REAL_IP variables for session IP check --- program/lib/Roundcube/rcube_utils.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'program/lib/Roundcube/rcube_utils.php') diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index 6c3bd2143..cf87dedb7 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -665,6 +665,21 @@ class rcube_utils } + /** + * Returns the real remote IP address + * + * @return string Remote IP address + */ + public static function remote_addr() + { + foreach (array('HTTP_X_FORWARDED_FOR','HTTP_X_REAL_IP','REMOTE_ADDR') as $prop) { + if (!empty($_SERVER[$prop])) + return $_SERVER[$prop]; + } + + return ''; + } + /** * Read a specific HTTP request header. * -- cgit v1.2.3