Skip to content

Commit

Permalink
Fixed issue: Participant IP address not correctly captured if server …
Browse files Browse the repository at this point in the history
…is behind proxy
  • Loading branch information
c-schmitz committed Apr 15, 2012
1 parent 563e78c commit 6ef65f4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
18 changes: 11 additions & 7 deletions common_functions.php
Expand Up @@ -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'];
}
Expand Down
9 changes: 9 additions & 0 deletions config-defaults.php
Expand Up @@ -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')
Expand Down

0 comments on commit 6ef65f4

Please sign in to comment.