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
Advertisement
Associates
Associates
techtuts Darkmindz
CSS Tutorials Tutorialsphere.com - Free Online Tutorials
Boston PHP SurfnLearn
Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2008, 04: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, 10:56 PM   #2 (permalink)
The Contributor
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 50
Thanks: 5
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, 11: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, 01:32 PM   #4 (permalink)
The Addict
Zend Certified 
 
Join Date: Sep 2007
Location: Denmark
Posts: 241
Thanks: 5
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
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 06:34 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0