Forum Moderators: coopster
Using PHP v4, I want to get the IP address of each visitor with
$_SERVER["REMOTE_ADDR"]. But it always show the same IP address
What could I be doing wrong?
PS: I've just changed my server configuration, from IPv6 to IPv4 following these steps:
[fedorasolved.org...]
Thank you very much.
[edited by: coopster at 9:56 pm (utc) on Jan. 11, 2008]
[edit reason] removed ip address [/edit]
function getIpAddress() {$ip = "";
if($_SERVER) {
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}elseif(isset($_SERVER['HTTP_CLIENT_IP'])){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
} else {
if(getenv('HTTP_X_FORWARDED_FOR')){
$ip = getenv('HTTP_X_FORWARDED_FOR');
}elseif(getenv('HTTP_CLIENT_IP')){
$ip = getenv('HTTP_CLIENT_IP');
}else{
$ip = getenv('REMOTE_ADDR');
}
}
return $ip;
}