mirror of
https://github.com/telephone/LookingGlass.git
synced 2026-04-25 07:56:01 +03:00
[GH-ISSUE #21] Expand the get real ip function #18
Labels
No labels
enhancement
enhancement
enhancement
pull-request
v1
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/LookingGlass#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (May 1, 2014).
Original GitHub issue: https://github.com/telephone/LookingGlass/issues/21
Expand the Your IP Address with perhaps the following function
function getRealIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
@ldrrp commented on GitHub (Jan 23, 2015):
This one supports cloudflare too.
public function GET_IP(){ return getenv('HTTP_CLIENT_IP')?: getenv('HTTP_X_FORWARDED_FOR')?: getenv('HTTP_X_FORWARDED')?: getenv('HTTP_FORWARDED_FOR')?: getenv('HTTP_FORWARDED')?: getenv('REMOTE_ADDR')?: getenv('HTTP_CF_CONNECTING_IP')?: 'UNKNOWN'; }@telephone commented on GitHub (Jan 26, 2015):
Leaving v1 as is for IP retrieval. This will be pushed to v2.