Hi Alicia.
Welcome to the list.

On Friday 11 June 2004 12:58 pm, Alicia Riggs wrote:
> 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.

Are you talking about regular old (browser-based) 
Javascript? Javascript and (server-based) PHP are like 
apples and oranges. You can't really get the same 
error from each because they are doing completely 
different things in completely different places.

> 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.

PHP functions are executed by the server. The browser 
(Netscape and IE) have nothing to do with them.

gethostbyaddr is a simple reverse-DNS lookup (of the 
REMOTE_ADDR ip address) requested by your server to 
its nameserver. This never goes near the user's IE or 
Netscape browser.

The IP address used is the one your webserver is using 
in its HTTP (TCP) connection with the browser (or its 
agent -- a firewall or proxy, for example). 

If there is no DNS entry for the ip address, there 
should be no hostname returned because by definition 
there is no host name to be returned.

> 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");
> */
> ?>

For debugging purposes, I would add more verbose echos: 
particularly for IP address and full host name 
returned ($hn).

How are you deducing that you are getting different 
results based on the user's browser?

Are there firewalls or web proxies involved? This could 
account for getting conflicting IP addresses for the 
same user reported by the browser (via Javascript) and 
server.

> Thanks in advance for any ideas!
>
> Alicia Riggs
> PSG - Web Development Engineer
> 214-550-7452

Hope this helps.

Regards,
John

---------------------------------------
John Hicks
Gulfbridge, Inc.
"Putting the Web to work for your business."
http://gulfbridge.com
561-586-8116

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to