Click to See Complete Forum and Search --> : IP address of visitor to a site


ffurnai
06-27-2005, 03:44 PM
I was just curious, this is probably not even the right forum, does anyone know how to tell what a visitor to your site's IP address is?

Ian

BeachSide
06-27-2005, 03:46 PM
$_SERVER['REMOTE_ADDR']

ffurnai
06-27-2005, 03:49 PM
No kidding? just that simple?

well, let me take it a step further. Do you know how to tell where that IP address came from (geographically I mean)?

I saw a site that lets you input an IP address and it will tell you where that person is (roughly). Not trying to spy, just thought it would be cool "gee whiz" stuff.

BeachSide
06-27-2005, 03:58 PM
You could try this (http://us3.php.net/manual/en/function.gethostbyaddr.php) I never tried it so good luck :D

azeri
06-27-2005, 05:09 PM
This script shows real IP if visitor is conected trough a proxy too.

<?php
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif (isset($_SERVER['HTTP_VIA'])) {
$ip = $_SERVER['HTTP_VIA'];
}
elseif (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
}
else {
$ip = "unknown";
}
?>

chrislive
06-30-2005, 01:12 AM
look up some website statistics scripts.. ive seen a few that will break it down by country etc but from what i remember looking at the code they just had a big array filled with IP ranges