TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-15-2008, 03:31 PM   #1 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Default Hostname Regex

Hey, it's been a while

Kinda have a small issue. I'm trying get the actual hostname of a domain the problem i face is subdomains.

For example, i'm trying to produce a regex that could at least get all the follow to result in domain.com:

sub.domain.com
domain.co.uk
domain.com
sub.domain.co.uk
sub.sub.domain.gov.uk

etc.. Any ideas?

Thanks!
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 08-15-2008, 09:56 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

are you trying to get the hostnames of your website or all the hostnames that have your word (in this example 'domain') from the Internet?
tony is offline  
Reply With Quote
Old 08-16-2008, 10:25 AM   #3 (permalink)
The Acquainted
Inquisitive 
 
WinSrev's Avatar
 
Join Date: Sep 2007
Posts: 133
Thanks: 6
WinSrev is on a distinguished road
Default

Just a hostname, they are purely examples. The "domain" part could be anything.
Send a message via ICQ to WinSrev
WinSrev is offline  
Reply With Quote
Old 08-16-2008, 12:32 PM   #4 (permalink)
The Frequenter
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 352
Thanks: 8
Kalle is on a distinguished road
Default

You could use the parse_url() function built into PHP to fetch the domain name =)

PHP Code:
<?php
    $url 
'http://www.talkphp.com/';

    
var_dump(parse_url($url));
?>
Note, on invalid url's parse_url() will return false and throw an E_WARNING, so calling it with the error control operator prefixed (@).
__________________
Send a message via MSN to Kalle Send a message via Skype™ to Kalle
Kalle is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:39 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design