Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?
From: deko (www-dot-clearpointsystems-dot-com_at_nospam.com)
Date: 10/30/04
- Next message: Alvaro G. Vicario: "Re: Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?"
- Previous message: Geoff Berrow: "Re: Assign value to variable"
- Next in thread: Alvaro G. Vicario: "Re: Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?"
- Reply: Alvaro G. Vicario: "Re: Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 30 Oct 2004 17:34:24 GMT
Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?
Actually, I'm not sure if it's $_SERVER["REMOTE_ADDR"] -- 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_FORWARDED_FOR"]))
{
$visip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
elseif (isset($_SERVER["HTTP_CLIENT_IP"]))
{
$visip = $_SERVER["HTTP_CLIENT_IP"];
}
else
{
$visip = $_SERVER["REMOTE_ADDR"];
}
}
else
{
if (getenv('HTTP_X_FORWARDED_FOR'))
{
$visip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif (getenv('HTTP_CLIENT_IP'))
{
$visip = getenv('HTTP_CLIENT_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.
- Next message: Alvaro G. Vicario: "Re: Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?"
- Previous message: Geoff Berrow: "Re: Assign value to variable"
- Next in thread: Alvaro G. Vicario: "Re: Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?"
- Reply: Alvaro G. Vicario: "Re: Why is $_SERVER["REMOTE_ADDR"] returning multiple IP Addresses?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]