mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 12:52:14 +00:00
getIp() update to new header method
This commit is contained in:
+10
-14
@@ -208,22 +208,18 @@ class Request
|
|||||||
*/
|
*/
|
||||||
public function getIp(bool $safe = false): ?string
|
public function getIp(bool $safe = false): ?string
|
||||||
{
|
{
|
||||||
return $this->getHeader(
|
|
||||||
'http-cf-connecting-ip',
|
|
||||||
$this->getHeader(
|
|
||||||
'http-x-forwarded-for',
|
|
||||||
$this->getHeader('remote-addr')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$client_header = null;
|
$client_header = null;
|
||||||
if(!$safe){
|
if(!$safe){
|
||||||
if ($this->getHeader('http-cf-connecting-ip') !== null) {
|
$client_header = $this->getHeader(
|
||||||
$client_header = $this->getHeader('http-cf-connecting-ip');
|
'http-cf-connecting-ip',
|
||||||
}else if($this->getHeader('http-client-ip') !== null){
|
$this->getHeader(
|
||||||
$client_header = $this->getHeader('http-client-ip');
|
'http-client-ip',
|
||||||
}else if($this->getHeader('http-x-forwarded-for') !== null){
|
$this->getHeader(
|
||||||
$client_header = $this->getHeader('http-x-forwarded-for');
|
'http-x-forwarded-for',
|
||||||
}
|
$this->getHeader('remote-addr')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if($client_header === null)
|
if($client_header === null)
|
||||||
$client_header = $this->getHeader('remote-addr');
|
$client_header = $this->getHeader('remote-addr');
|
||||||
|
|||||||
Reference in New Issue
Block a user