Added method to pull the user's IP
Browser::remoteIP();
This commit is contained in:
parent
bf15f592e9
commit
b4d9b0e182
2 changed files with 68 additions and 10 deletions
|
@ -87,6 +87,18 @@ class Browser extends Object
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Go Home
|
||||
*
|
||||
* Alias for `Browser::redirect('/');`
|
||||
*
|
||||
* @static
|
||||
*/
|
||||
public static function goHome()
|
||||
{
|
||||
Browser::redirect('/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Is Mobile
|
||||
*
|
||||
|
@ -126,15 +138,32 @@ class Browser extends Object
|
|||
}
|
||||
|
||||
/**
|
||||
* Go Home
|
||||
* Remote IP
|
||||
*
|
||||
* Alias for `Browser::redirect('/');`
|
||||
* Returns the user's IP address.
|
||||
*
|
||||
* @static
|
||||
* @return mixed IP address or false if unable to determine
|
||||
*/
|
||||
public static function goHome()
|
||||
public static function remoteIP()
|
||||
{
|
||||
Browser::redirect('/');
|
||||
if (!empty($_SERVER['HTTP_CLIENT_IP']))
|
||||
{
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
}
|
||||
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
|
||||
{
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
elseif (isset($_SERVER['REMOTE_ADDR']))
|
||||
{
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$ip = false;
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue