mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Null coalescing for $_SERVER keys in iphandler_class.php
Resolves CLI-invoked E_NOTICE in: * eIPHandler::__construct() * eIPHandler::getCurrentIP() Also resolves possible blank eIPHandler::$serverIP
This commit is contained in:
@@ -171,7 +171,7 @@ class eIPHandler
|
|||||||
|
|
||||||
$this->ourIP = $this->ipEncode($this->getCurrentIP());
|
$this->ourIP = $this->ipEncode($this->getCurrentIP());
|
||||||
|
|
||||||
$this->serverIP = $this->ipEncode($_SERVER['SERVER_ADDR']);
|
$this->serverIP = $this->ipEncode(isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : 'x.x.x.x');
|
||||||
|
|
||||||
$this->makeUserToken();
|
$this->makeUserToken();
|
||||||
$ipStatus = $this->checkIP($this->ourIP);
|
$ipStatus = $this->checkIP($this->ourIP);
|
||||||
@@ -334,7 +334,7 @@ class eIPHandler
|
|||||||
{
|
{
|
||||||
if(!$this->ourIP)
|
if(!$this->ourIP)
|
||||||
{
|
{
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'x.x.x.x';
|
||||||
if ($ip4 = getenv('HTTP_X_FORWARDED_FOR'))
|
if ($ip4 = getenv('HTTP_X_FORWARDED_FOR'))
|
||||||
{
|
{
|
||||||
if (!$this->isAddressRoutable($ip))
|
if (!$this->isAddressRoutable($ip))
|
||||||
@@ -344,10 +344,6 @@ class eIPHandler
|
|||||||
$this->logBanItem(0, 'X_Forward '.$ip4.' --> '.$ip); // Just log for interest ATM
|
$this->logBanItem(0, 'X_Forward '.$ip4.' --> '.$ip); // Just log for interest ATM
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($ip == '')
|
|
||||||
{
|
|
||||||
$ip = 'x.x.x.x';
|
|
||||||
}
|
|
||||||
$this->ourIP = $this->ipEncode($ip); // Normalise for storage
|
$this->ourIP = $this->ipEncode($ip); // Normalise for storage
|
||||||
}
|
}
|
||||||
return $this->ourIP;
|
return $this->ourIP;
|
||||||
|
Reference in New Issue
Block a user