mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Modify handling of reverse proxies
This commit is contained in:
@@ -2358,29 +2358,23 @@ class e107
|
|||||||
{
|
{
|
||||||
if(!$this->_ip_cache)
|
if(!$this->_ip_cache)
|
||||||
{
|
{
|
||||||
if(getenv('HTTP_X_FORWARDED_FOR'))
|
$ip=$_SERVER['REMOTE_ADDR'];
|
||||||
|
if (getenv('HTTP_X_FORWARDED_FOR'))
|
||||||
{
|
{
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
if (preg_match("/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/", getenv('HTTP_X_FORWARDED_FOR'), $ip3))
|
||||||
$ip3 = array();
|
|
||||||
if(preg_match('/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/', getenv('HTTP_X_FORWARDED_FOR'), $ip3))
|
|
||||||
{
|
{
|
||||||
$ip2 = array(
|
$ip2 = array('#^0\..*#',
|
||||||
'#^0\..*#' , '#^127\..*#' , // Local loopbacks
|
'#^127\..*#', // Local loopbacks
|
||||||
'#^192\.168\..*#' , // RFC1918 - Private Network
|
'#^192\.168\..*#', // RFC1918 - Private Network
|
||||||
'#^172\.(?:1[6789]|2\d|3[01])\..*#' , // RFC1918 - Private network
|
'#^172\.(?:1[6789]|2\d|3[01])\..*#', // RFC1918 - Private network
|
||||||
'#^10\..*#' , // RFC1918 - Private Network
|
'#^10\..*#', // RFC1918 - Private Network
|
||||||
'#^169\.254\..*#' , // RFC3330 - Link-local, auto-DHCP
|
'#^169\.254\..*#', // RFC3330 - Link-local, auto-DHCP
|
||||||
'#^2(?:2[456789]|[345][0-9])\..*#'
|
'#^2(?:2[456789]|[345][0-9])\..*#' // Single check for Class D and Class E
|
||||||
); // Single check for Class D and Class E
|
);
|
||||||
|
$ip = preg_replace($ip2, $ip3[1], $ip);
|
||||||
$ip = preg_replace($ip2, $ip, $ip3[1]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
if ($ip == "")
|
||||||
{
|
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
|
||||||
}
|
|
||||||
if($ip == "")
|
|
||||||
{
|
{
|
||||||
$ip = "x.x.x.x";
|
$ip = "x.x.x.x";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user