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:

PHP 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.

 

 

 

 

Top