note 27924 added to function.gethostbyaddr
| From: | webmaster at 4so9 dot com | Date: | Wed, 25 Dec 2002 16:12:33 +0000 |
| Subject: | note 27924 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41280@lists.php.net to get a copy of this message | ||
I could never get one host name from this function. I have even tried to turn on
"HostnameLookup On" w/o success. I have combined all your your advises into this piece of
codes. Any help on this is greatly appreciated.
------
function getRemoteInfo () {
$proxy="";
$IP = "";
if (isSet($_SERVER)) {
if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$IP = $_SERVER["HTTP_X_FORWARDED_FOR"];
$proxy = $_SERVER["REMOTE_ADDR"];
} 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' );
$proxy = getenv( 'REMOTE_ADDR' );
} elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
$IP = getenv( 'HTTP_CLIENT_IP' );
} else {
$IP = getenv( 'REMOTE_ADDR' );
}
}
if (strstr($IP, ',')) {
$ips = explode(',', $IP);
$IP = $ips[0];
}
$RemoteInfo[0]=$IP;
$RemoteInfo[1]=@GetHostByAddr($IP);
$RemoteInfo[2]=$proxy;
return $RemoteInfo;
}
-------
Thanks,
Steve
--
http://www.php.net/manual/en/function.gethostbyaddr.php
http://master.php.net/manage/user-notes.php?action=edit+27924
http://master.php.net/manage/user-notes.php?action=delete+27924
http://master.php.net/manage/user-notes.php?action=reject+27924