Get IP and Proxy address of the user
Tagged:

The code below gets the real IP of the user and it also gets the proxy address of the user if he is using one.


if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$proxy = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
$ip = isset($_SERVER['HTTP_CLIENT_IP']) ? $_SERVER['HTTP_CLIENT_IP'] : $_SERVER['REMOTE_ADDR'];
}

echo "Host IP: ". $ip ."
";
echo "Hostname: ". gethostbyaddr($ip) ."

";

//If the variable proxy is set, then the user is using Proxy so display proxy information
if(isset($proxy)){
echo "Proxy IP: ". $proxy ."
";
echo "Proxyname: ". gethostbyaddr($proxy)."
";
}