Slickire Posted September 13, 2007 Share Posted September 13, 2007 Hi, I am creating a simple traffic log for my homepage which is located on a university server. The web server automatically maps URLs of the form http://www.uniserver.ac.uk/~username/ to the filesystem path /homes/username/public_html/index.html. The problem is that instead of logging the clients IP address, my script will log the servers IP. How do i get the clients IP only?? I have tried searching for a solution, but to be honest i don't know how to properly describe it. Here is part of the script that creates the log. It is PHP, but the file is called stats.cgi and is run everytime the homepage is requested: $userAgent = ( isset($_SERVER['HTTP_USER_AGENT']) && ($_SERVER['HTTP_USER_AGENT'] != "")) ? $_SERVER['HTTP_USER_AGENT'] : "Unknown"; $userIp = ( isset($_SERVER['REMOTE_ADDR']) && ($_SERVER['REMOTE_ADDR'] != "")) ? $_SERVER['REMOTE_ADDR'] : "Unknown"; $refferer = ( isset($_SERVER['HTTP_REFERER']) && ($_SERVER['HTTP_REFERER'] != "")) ? $_SERVER['HTTP_REFERER'] : "Unknown"; $uri = ( isset($_SERVER['REQUEST_URI']) && ($_SERVER['REQUEST_URI'] != "")) ? $_SERVER['REQUEST_URI'] : "Unknown"; //$hostName = gethostbyaddr($userIp); $actualTime = date(DATE_FORMAT); $logEntry = "<tr id=\"row\"> <td>$actualTime</td> <td>$userIp</td> <td>$hostName</td> <td>$userAgent</td> <td>$uri</td> <td>$refferer</td> </tr>"; Oh, the uni server is running php v4.3.0 if that helps, and Apache server version 1.3.27 on Linux. I only have access to my personal directory. Cheers, Slicikire Quote Link to comment https://forums.phpfreaks.com/topic/69243-getting-a-clients-ip-after-a-server-url-maps-to-filesystem/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.