Ugh....
vB 3.6.4 already comes with this built in.
So am I overwriting whats in 3.6.4?
I see a similar code EX BELOW:
ONE THAT COMES WITH
VB 3.6.4
Code:
/**
* Fetches an alternate IP address of the current visitor, attempting to detect proxies etc.
*
* @return string
*/
function fetch_alt_ip()
{
$alt_ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_CLIENT_IP']))
{
$alt_ip = $_SERVER['HTTP_CLIENT_IP'];
}
else if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches))
{
// make sure we dont pick up an internal IP defined by RFC1918
foreach ($matches[0] AS $ip)
{
if (!preg_match("#^(10|172\.16|192\.168)\.#", $ip))
{
$alt_ip = $ip;
break;
}
}
}
else if (isset($_SERVER['HTTP_FROM']))
{
$alt_ip = $_SERVER['HTTP_FROM'];
}
return $alt_ip;
}
THE ONE YOU INCLUDED IN ZIP FILE
Code:
/*
Paul M - Try to detect real ip when proxy is in use.
*/
function fetch_real_ip()
{
$real_ip = '';
$ignoreprivate = false;
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$real_ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else if (isset($_SERVER['HTTP_CLIENT_IP']))
{
$real_ip = $_SERVER['HTTP_CLIENT_IP'];
}
else if (isset($_SERVER['HTTP_FROM']))
{
$real_ip = $_SERVER['HTTP_FROM'];
}
if (preg_match("#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#", $real_ip, $iplist))
{
$real_ip = $iplist[0];
if ($ignoreprivate AND preg_match("#^(127|10|172\.(1[6-9]|2[0-9]|3[0-1])|192\.168|169\.254)\.#", $real_ip))
{
$real_ip = '';
}
}
else
{
$real_ip = '';
}
return $real_ip;
}