1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +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:
Nick Liu
2020-01-17 15:11:45 +01:00
parent c232613e44
commit bcba1e065f

View File

@@ -171,7 +171,7 @@ class eIPHandler
$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();
$ipStatus = $this->checkIP($this->ourIP);
@@ -334,7 +334,7 @@ class eIPHandler
{
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 (!$this->isAddressRoutable($ip))
@@ -344,10 +344,6 @@ class eIPHandler
$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
}
return $this->ourIP;