if (getenv("HTTP_CLIENT_IP")){
$ip = getenv("HTTP_CLIENT_IP");
}
elseif(getenv("HTTP_X_FORWARDED_FOR")) {
$ip = getenv("HTTP_X_FORWARDED_FOR");
}
elseif(getenv("REMOTE_ADDR")){
$ip = getenv("REMOTE_ADDR");
}
else {
$ip = "UNKNOWN";
}
$fullhost = gethostbyaddr($ip);
$browser = $_SERVER['HTTP_USER_AGENT'];
$page = $_SERVER['PHP_SELF'];
print("You are $fullhost ($ip)");
print("and you are using $browser to visit $page");
A more useful application of this is of course logging if you for some reason
do not have direct access to /var/log/httpd/access_log (or equivalent).