[thelist] PHP: getting domain names from a url - being foiled by .co.uk addresses
Dunstan Orchard
dunstan at 1976design.com
Sun Dec 7 18:10:16 CST 2003
Hey everyone,
Sorry I didn't reply last night, I fell asleep at my desk and only woke
up when I fell off the yoga ball I use as a chair. It gave me a bit of a
shock I can tell you :o)
Anyway, where have I reached with this problem - well:
[1] Manuel suggested exploding the url at the dots.
[2] Kelly suggested doing the same and then using a lookup table to
determine if multiple dots represented subdomains, or a url with a
.co.uk address or similar.
[3] Tony and Ken suggested looking up the IP address and then using that
to look up the domain name.
I like the last suggestion the best (seemes like much less work) but of
the first three examples I tried, I found two problems:
asda.co.uk
ip = 161.165.200.102
hostname = asda.co.uk
news.yahoo.com (or indeed just 'yahoo.com')
ip = 216.109.124.244
hostname = story1.news.vip.dcn.yahoo.com
dev.[secret url].org
ip = xxx.xxx.xxx.xxx
hostname = xxx-xx-xx-xx.[secret].net
So, although it works on most straight forward urls, 2 of the first 3 I
tried brought back some horrible results - though they're obviously correct.
Does anyone know of a way to return the public-facing urls?
Thanks again,
- Dunstan
-------------------------------------
Dorset, England
Work: http://www.1976design.com/
Play: http://www.1976design.com/blog/
Learn: http://webstandards.org/
More information about the thelist
mailing list