Page 1 of 1

Retrieving IP address and hostname from user

Posted: Mon Aug 11, 2008 12:21 pm
by bill1one
I am trying to log ip addresses and hostname of users of the Internet on our LAN. Each user when they open their browser goes through ipcop to a PHP with the following code:

Code: Select all

 
<?php
function ip()
    { 
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
        $vip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    else $vip=$_SERVER['REMOTE_ADDR'];
 
    return trim($vip);
    }
$ip = ip();
$hostname = gethostbyaddr($ip);
 
include 'config.php';
include 'opendb.php';
 
$sql = "INSERT INTO tbl_log (ip, hostname)" .
       "VALUES ('$ip', '$hostname')";
mysql_query($sql);
 
header( 'Location: LINK TO INTERNAL WEB SITE' ) ;
 
include 'closedb.php';
 
?>
 
This code works fine, in that it retrieves the ip address and hostname of the user, but since it is passing through ipcop, it picks up the ip address and hostname of the ipcop machine. So essentially I get the same ip and host for every user. Can anyone help me figure a way to pass original ip and host through ipcop.

Thanks. Bill.

Re: Retrieving IP address and hostname from user

Posted: Tue Aug 12, 2008 7:35 pm
by lukewilkins
To my knowledge, I do not think there is a way around this. This happens within basically any form of network. The internet is going to see the same outward facing IP for any of those computers.

Maybe I'm wrong, in which case I'd like to see this also.