Hi John,
Thank you for the ideas :) I am beginning to believe I need a new way
to work around this issue.
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.
This is exactly the problem, the error is DNS related and has nothing to
do with the languages, which is why I get the similar results no matter
what I write it in. And yes, they are using proxies as well as rotating
ip addresses. The client's team is behind a firewall with a specific
domain name but I am not consistently getting that IP address. To make
it more complicated, inside their firewall they have rotating ip
addresses, and only some of those have DNS entries.
I wrote it in JavaScript first, which works in IE if they are indeed
using a specific domain name, but not in Netscape, which returns IP
addresses with an occasional domain name, not sure why the browsers are
so different. So I switched to PHP... Thinking, like you, it would not
matter which browser they are using, which helped some, but I am still
unable to get domain names from all of their team. No DNS entries
listed for some of the IP addresses returned. I am not seeing a way to
do it without a consistent DNS entry for each person or at minimum fixed
ip addresses.
Thank you for helping me walk through it.
Alicia
-Original Message-
From: John Hicks [mailto:[EMAIL PROTECTED]
Sent: Friday, June 11, 2004 11:35 PM
To: PHP
Subject: Re: [PHP] gethostbyaddr
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 . \nbr;
$darr = explode(., $hn);
$cnt = count($darr);
$host = $darr[$cnt - 2] . . . $darr[$cnt - 1];
echo host = . $host . \nbr;
/*
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php