note 66181 added to function.gethostbyaddr
| From: | alexatnoinc at osu1 dot php dot net | Date: | Tue, 16 May 2006 18:12:28 +0000 |
| Subject: | note 66181 added to function.gethostbyaddr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111399@lists.php.net to get a copy of this message | ||
here is a handy little func , can be used with gethostbyaddr like it comes stock ...if you like that
func .. or u can drop in one of the replacements the other comments above have noted ...
this one is nice because it will do one of the following depending on what's available:
1. "hostname (IP) @ proxy host (proxy IP)"
2. "IP @ proxy IP"
3. "hostname (IP)"
4. "IP"
i.e. it will give u whatever it can get ...with bare minimum being IP only
function host_info() {
global $HTTP_SERVER_VARS;
if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"] != ""){
$IP = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
$proxy_IP = $HTTP_SERVER_VARS["REMOTE_ADDR"];
$proxy_host = @gethostbyaddr($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"]);
}
if ($host != $IP)
$host = "$host ($IP)";
if (isset($proxy_host)) {
$host .= ' @' . $proxy_host;
if ($proxy_host != $proxy_IP)
$host .= " ($proxy_IP)";
}
return $host;
}
----
Server IP: 64.71.164.2
Probable Submitter: 66.93.57.98
----
X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
UPPERCASE_25_50 autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.gethostbyaddr.php
Edit -- http://master.php.net/note/edit/66181
Del: integrated -- http://master.php.net/note/delete/66181/integrated
Del: useless -- http://master.php.net/note/delete/66181/useless
Del: bad code -- http://master.php.net/note/delete/66181/bad+code
Del: spam -- http://master.php.net/note/delete/66181/spam
Del: non-english -- http://master.php.net/note/delete/66181/non-english
Del: in docs -- http://master.php.net/note/delete/66181/in+docs
Del: other reasons-- http://master.php.net/note/delete/66181
Reject -- http://master.php.net/note/reject/66181
Search -- http://master.php.net/manage/user-notes.php