getIp() update to new header method

This commit is contained in:
DeveloperMarius
2021-03-22 22:25:59 +01:00
parent d5dc81e26e
commit 5508c73e85
+6 -10
View File
@@ -208,22 +208,18 @@ class Request
*/ */
public function getIp(bool $safe = false): ?string public function getIp(bool $safe = false): ?string
{ {
return $this->getHeader( $client_header = null;
if(!$safe){
$client_header = $this->getHeader(
'http-cf-connecting-ip', 'http-cf-connecting-ip',
$this->getHeader(
'http-client-ip',
$this->getHeader( $this->getHeader(
'http-x-forwarded-for', 'http-x-forwarded-for',
$this->getHeader('remote-addr') $this->getHeader('remote-addr')
) )
)
); );
$client_header = null;
if(!$safe){
if ($this->getHeader('http-cf-connecting-ip') !== null) {
$client_header = $this->getHeader('http-cf-connecting-ip');
}else if($this->getHeader('http-client-ip') !== null){
$client_header = $this->getHeader('http-client-ip');
}else if($this->getHeader('http-x-forwarded-for') !== null){
$client_header = $this->getHeader('http-x-forwarded-for');
}
} }
if($client_header === null) if($client_header === null)
$client_header = $this->getHeader('remote-addr'); $client_header = $this->getHeader('remote-addr');