Why is $_SERVER["REMOTE_ADD R"] returning multiple IP Addresses?
Actually, I'm not sure if it's $_SERVER["REMOTE_ADD R"] -- or which if/else
statement -- that's the problem, but what I'm getting as a value for $visip
looks like this:
172.16.42.181, 62.138.35.94
Why am I getting more than one IP Address? Which IP is the originating IP
Address? Is there a way to get only the originating IP?
Here's the code:
if (isset($_SERVER ))
{
if (isset($_SERVER["HTTP_X_FORWARD ED_FOR"]))
{
$visip = $_SERVER["HTTP_X_FORWARD ED_FOR"];
}
elseif (isset($_SERVER["HTTP_CLIENT_IP "]))
{
$visip = $_SERVER["HTTP_CLIENT_IP "];
}
else
{
$visip = $_SERVER["REMOTE_ADD R"];
}
}
else
{
if (getenv('HTTP_X _FORWARDED_FOR' ))
{
$visip = getenv('HTTP_X_ FORWARDED_FOR') ;
}
elseif (getenv('HTTP_C LIENT_IP'))
{
$visip = getenv('HTTP_CL IENT_IP');
}
else
{
$visip = getenv('REMOTE_ ADDR');
}
}
You can view the page that displays the results here:
http://www.clearpointsystems.com/stats.php
(scroll to entry for Oct 29 2004 10:17 am and Oct 30 2004 05:26 am)
Thanks in advance.