Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12427627
WithRemoteAddress.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
893 B
Referenced Files
None
Subscribers
None
WithRemoteAddress.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\HTTP\Requests
;
trait
WithRemoteAddress
{
/**
* Gets remote IP address.
*
* This is intended as a drop-in replacement for $_SERVER['REMOTE_ADDR'],
* which takes in consideration proxy values, blindly trusted.
*
* This method should is only for environment where headers are controlled,
* like nginx + php_fpm, where HTTP_ headers are reserved for the server
* information, and where the headers sent by the web server to nginx are
* checked or populated by nginx itself.
*
* @return string the remote address
*/
public
static
function
getRemoteAddress
()
:
string
{
return
RemoteAddress
::
fromServer
()->
getClientAddress
();
}
public
static
function
isFromLocalHost
()
:
bool
{
return
RemoteAddress
::
fromServer
()->
isFromLocalHost
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 7, 08:48 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3132100
Default Alt Text
WithRemoteAddress.php (893 B)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment