diff --git a/common_functions.php b/common_functions.php index 1269e6a3967..2f66064c05c 100644 --- a/common_functions.php +++ b/common_functions.php @@ -7262,15 +7262,19 @@ function ls_json_encode($val) */ function getIPAddress() { - if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet + global $bServerBehindProxy; + if ($bServerBehindProxy) { - return $_SERVER['HTTP_CLIENT_IP']; - } - elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy - { - return $_SERVER['HTTP_X_FORWARDED_FOR']; + if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet + { + return $_SERVER['HTTP_CLIENT_IP']; + } + elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy + { + return $_SERVER['HTTP_X_FORWARDED_FOR']; + } } - elseif (!empty($_SERVER['REMOTE_ADDR'])) + if (!empty($_SERVER['REMOTE_ADDR'])) { return $_SERVER['REMOTE_ADDR']; } diff --git a/config-defaults.php b/config-defaults.php index cfef41daa74..a74dbf8159a 100644 --- a/config-defaults.php +++ b/config-defaults.php @@ -573,6 +573,15 @@ */ $iFileUploadTotalSpaceMB=0; +/** +* Set this variable to true to indicate that your server is behind a proxy. +* This will ensure the correct captioning of IP addresses instead of just the proxy address +* +* @var $bServerBehindProxy Default: false +* +*/ +$bServerBehindProxy=false; + //DO NOT EVER CHANGE THE FOLLOWING 5 LINES --------------- require_once(dirname(__FILE__).'/config.php'); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']!='' && $_SERVER['HTTPS']!='off')