Find user IP
Posted: Sat Jan 22, 2005 10:03 pm
Hi all,
A while back I found some code that found a clients IP address, at least that is what it was supposed to do.
Anyhow, someone told me that I should turn error reporting to E_ALL in order to help me make the site a little more error free. What is happening however, is that I am getting errors from the above code, namely:
Is this an indication that the code isnt actually doing what it is supposed to? If not, is there similar code which would work.
Also, does having a warning appear count as info before the header? I'm getting those messages all the time as well when the messages are turned on.
Thanks
A while back I found some code that found a clients IP address, at least that is what it was supposed to do.
Code: Select all
function PCF_getIP() {
if ($_SERVER['HTTP_CLIENT_IP'] && strcasecmp($_SERVER['HTTP_CLIENT_IP'], "unknown"))
$ip = $_SERVER['HTTP_CLIENT_IP'];
else if ($_SERVER['HTTP_X_FORWARDED_FOR'] && strcasecmp($_SERVER['HTTP_X_FORWARDED_FOR'], "unknown"))
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if ($_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], "unknown"))
$ip = $_SERVER['REMOTE_ADDR'];
else $ip = "unknown";
return($ip);
}Code: Select all
Notice: Undefined index: HTTP_CLIENT_IP in modules/common.php on line 21
Notice: Undefined index: HTTP_X_FORWARDED_FOR in modules/common.php on line 23Also, does having a warning appear count as info before the header? I'm getting those messages all the time as well when the messages are turned on.
Thanks