note 10608 added to gethostbyaddr
| From: | andy at occ dot nu | Date: | Fri, 12 Jan 2001 11:48:43 +0000 |
| Subject: | note 10608 added to gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-9706@lists.php.net to get a copy of this message | ||
if the user is sitting behind a proxy server, you can do this;
<?
if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != ""){
$IP = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
$proxy = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$host = @gethostbyaddr($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"]);
}else{
$IP = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$host = @gethostbyaddr($HTTP_SERVER_VARS["REMOTE_ADDR"]);
}
?>
ps; i use $http_server_vars["something"] instead of just $something;
you can get most of the $HTTP_SERVER_VARS by just using there $something equivalent, see the manual
for that (preserved variables)
http://www.php.net/manual/function.gethostbyaddr.php