![]() |
|
How To Grab IP Address With PHP - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: PHP (https://sinister.ly/Forum-PHP) +--- Thread: How To Grab IP Address With PHP (/Thread-How-To-Grab-IP-Address-With-PHP) Pages:
1
2
|
RE: How To Grab IP Address With PHP - redN00ws - 06-16-2013 Thanks for sharing... Well done ! RE: How To Grab IP Address With PHP - Woody - 06-17-2013 No problem! RE: How To Grab IP Address With PHP - webbiz - 08-01-2013 In countries like Singapore where a nation-wide proxy is established, such IP detectors provicde only the proxy IP address of a fake one. The IP script will have to be inside the country's IP space for it to be visible as well. The following is an ip.php script to obtain such info. Code: <?
echo getip();
function getip() {
if (isset($_SERVER["HTTP_CLIENT_IP"]) && validip($_SERVER["HTTP_CLIENT_IP"])) {
return $_SERVER["HTTP_CLIENT_IP"];
}
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
foreach (explode(",",$_SERVER["HTTP_X_FORWARDED_FOR"]) as $ip) {
if (validip(trim($ip))) {
return $ip;
}
}
}
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && validip($_SERVER["HTTP_X_FORWARDED_FOR"])) {
return $_SERVER["HTTP_X_FORWARDED_FOR"];
} elseif (isset($_SERVER["HTTP_FORWARDED_FOR"]) && validip($_SERVER["HTTP_FORWARDED_FOR"])) {
return $_SERVER["HTTP_FORWARDED_FOR"];
} elseif (isset($_SERVER["HTTP_FORWARDED"]) && validip($_SERVER["HTTP_FORWARDED"])) {
return $_SERVER["HTTP_FORWARDED"];
} elseif (isset($_SERVER["HTTP_X_FORWARDED"]) && validip($_SERVER["HTTP_X_FORWARDED"])) {
return $_SERVER["HTTP_X_FORWARDED"];
} else {
return $_SERVER["REMOTE_ADDR"];
}
}
?>RE: How To Grab IP Address With PHP - sitehost - 08-06-2013 I have used a script like this from a site that gets alot of traffic and then turn around and used the ipaddress as spoof for fake traffic on other sites. Great little Script!! |