Re: reverse DNS lookup with PHP
| From: | Lars Torben Wilson | Date: | Sat, 14 Jun 2003 21:58:00 +0000 |
| Subject: | Re: reverse DNS lookup with PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151521@lists.php.net to get a copy of this message | ||
On Sat, 2003-06-14 at 14:38, Tom Ray [Lists] wrote:
> $_SERVER[REMOTE_HOST];
>
> This will do a reverse lookup on their IP.
>
> Manual Link:
>
> http://ca3.php.net/manual/en/reserved.variables.php#reserved.variables.server
Actually, this isn't true. $_SERVER['REMOTE_HOST'] will contain the
hostname of the client if and only if the web server has placed that
value there. Simply referring to the variable does not cause a lookup
to be done.
To do the lookup yourself, use gethostbyaddr():
http://www.php.net/gethostbyaddr
Hope this clarifies it a bit,
Torben
> Hope it helps
>
> Tim Thorburn wrote:
>
> > Hi,
> >
> > I'm setting up a simple tracking program for a website I'm working
> > on. Currently it records a visitors IP address, but I would like to
> > be able to do a DNS lookup of these IP addresses. Is this possible
> > with PHP and if so, how is it done? I've been looking through Google,
> > and the very few real results I've come across are large perl programs
> > which make little to no sense to me.
> >
> > Any help would be greatly appreciated.
> >
> > Thanks
> > -Tim
--
Torben Wilson <torben@php.net> +1.604.709.0506
http://www.thebuttlesschaps.com http://www.inflatableeye.com
http://www.hybrid17.com http://www.themainonmain.com
-----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----