gethostbyaddr
| From: | Alicia Riggs | Date: | Fri, 11 Jun 2004 16:58:34 +0000 |
| Subject: | gethostbyaddr | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-188116@lists.php.net to get a copy of this message | ||
Hi guys, I am new to this list, and signed up specifically for this
problem. If any one has any ideas it would be greatly appreciated.
I am writing a function to allow users from a specific intranet
permission to view a directory. I am getting very different results
from IE and Netscape. I have written this in JavaScript as well as PHP,
and I am getting the same error in both languages.
When I use the gethostbyaddr call, in IE I get a domain name the
majority of the time, with a few exceptions.
When I use the gethostbyaddr call in Netscape I only receive a domain
name if there is a DNS entry. If there is no DNS entry, Netscape
returns an IP address.
I am not sure what IE is using to get the domain names when there is no
DNS entry.
How do I get the correct info to be returned from Netscape?
Here is the code I am using
***********************************
<?php
//echo "<pre>";
//print_r($_SERVER);
//echo "</pre>";
$hn = gethostbyaddr($_SERVER['REMOTE_ADDR']);
echo "host by addr = " . $hn . "\n<br>";
$darr = explode(".", $hn);
$cnt = count($darr);
$host = $darr[$cnt - 2] . "." . $darr[$cnt - 1];
echo "host = " . $host . "\n<br>";
/*
if($host == "xyz.com")
header("Location: xyz.html");
else
if($host == "abc.com")
header("Location: abc.html");
else
header("Location: error.html");
*/
?>
Thanks in advance for any ideas!
Alicia Riggs
PSG - Web Development Engineer
214-550-7452