I have a website that I need to make sure the users are all unique. A good way of checking is by ip address. Now, in my register.php file, it logs the ip when someone signs up as:
$ip = $_SERVER['REMOTE_ADDR'];
Now, when someone uses a proxy, it just gives me the IP of the Proxy. I have tried to substitute code in from what I have found online, but none seem to work. I can not remember all that I have tried, but one is:
function GetUserIP()
{
if (isset($_SERVER))
{
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif(isset($_SERVER["HTTP_CLIENT_IP"]))
{
$ip = $_SERVER["HTTP_CLIENT_IP"];
} else
{
$ip = $_SERVER["REMOTE_ADDR"];
}
}
else
{
if ( getenv( 'HTTP_X_FORWARDED_FOR' ) )
{
$ip = getenv( 'HTTP_X_FORWARDED_FOR' );
}
elseif ( getenv( 'HTTP_CLIENT_IP' ) )
{
$ip = getenv( 'HTTP_CLIENT_IP' );
}
else
{
$ip = getenv( 'REMOTE_ADDR' );
}
}
return $ip;
}
$ip = GetUserIP();
This doesn't work, and it seems like it should. If anyone can help, it would be appreciated. I may offer a small reward.
Thanks