Buy Sell Discuss UK Domain Names at AcornDomains.co.uk

Today's Drop Dates are: 07-11-2011 or 14-11-2011   All times are GMT. The time now is 09:22:37 PM.
Domain Name Sales Domain Software Calculate UK Domain Drop Dates Domain Registration NameDrive Domain Parking Subscribe to our Domains For Sale newsletter
Go Back   Domain Forum Acorn Domains Buy Sell Auction UK Domains > Website Design and Promotion > Website Design > Scripts and Coding
Connect with Facebook

Scripts and Coding PHP, MySQL, scripts

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 16-02-2009, 12:15:35 PM     #1 (permalink)

 
Join Date: Sep 2006
Posts: 407
purg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond repute

PHP eregi domain

Any simple way to dig out just the domain without hlq?
www.test.co.uk

Ive also noticed $_SERVER['SERVER_NAME'] sometimes contains WWW. that needs stripping.

blar.domain.co.uk = domain
www.domain.co.uk = domain
domain.co.uk = domain

Last edited by purg; 17-02-2009 at 01:30:12 PM.
purg is offline  
Old 16-02-2009, 01:30:28 PM     #2 (permalink)

 
Join Date: May 2006
Posts: 1,192
Jeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond repute

what bit do you want specifically? Just the 'test' in www.test.co.uk ?
Jeewhizz is offline  
Old 16-02-2009, 02:45:15 PM     #3 (permalink)

 
Skinner's Avatar
 
Join Date: Jul 2008
Location: Manchester
Posts: 2,501
Skinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond repute

Eregi for detecting domain names is crazy as http://www.i.am.adding.many.sub-domain.test.co.uk is a valid name, so it takes some fancy regex to detect all the varients, I wrote about 100 lines of code to do this and still had some name getting thru so I went with a quick and nasty snippet.

PHP Code:
/////////////// START DOMAIN CAPTURE BLOCK ////////////////
    
$domainz substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1);
    if (
strlen($domainz) <= 6) {
        
$domainz $_SERVER['HTTP_HOST'];
        if(
$debug == true) { echo '<p>var $domainz - Length: ' strlen($domainz) . ' - Value: ' .  $domainz ' - Sub Domain: No</p>'; }
    } else {
        
$domainz substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.')+1);
        if(
$debug == true){ echo '<p>var $domainz - Length: ' strlen($domainz) . ' - Value: ' .  $domainz ' - Sub Domain: Yes</p>'; }
    }    
    
//////////////// END DOMAIN CAPTURE BLOCK ///////////////// 
This works for most .uk names that I tested, if it was for a client I'd have my programming house write it but this was a parking script after I got spanked over my signature links :P
__________________
Browse:
Skinner is offline  
Old 16-02-2009, 02:50:36 PM     #4 (permalink)

 
Skinner's Avatar
 
Join Date: Jul 2008
Location: Manchester
Posts: 2,501
Skinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond repute

Have a look at

http://www.acorndomains.co.uk/genera...tml#post162895

I posted a stack of code on my parking script, which I still havent finished or made look pretty :P
__________________
Browse:
Skinner is offline  
Old 17-02-2009, 01:28:49 PM     #5 (permalink)

 
Join Date: Sep 2006
Posts: 407
purg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond reputepurg has a reputation beyond repute

Whizz.... Correct

Skinner.... thanks for the link but:-
My draft looks similar to your snippet but caters and removes sub domain levels. Only failed style of domain would be two char hlq domains (xx.xx.CC or WS style of names) with one char subdomain.
I dont own any so not a problem for my needs.

PHP Code:
$arr = array("/""?""%");
$pos "256";

foreach (
$arr as $findme) {
    if (
strpos($_SERVER['HTTP_HOST'], $findme) !== false) {
        
$pos strpos($_SERVER['HTTP_HOST'], $findme);
        break;
    }
}

$pos $pos strpos(substr($_SERVER['HTTP_HOST'], $pos-66);
$domname substr($_SERVER['HTTP_HOST'], 0$pos);
$domname substr($domnamestrrchr($domname,'.')+1);

echo 
$domname
(untested)

Last edited by purg; 17-02-2009 at 01:31:50 PM.
purg is offline  
Old 17-02-2009, 01:58:35 PM     #6 (permalink)

 
Skinner's Avatar
 
Join Date: Jul 2008
Location: Manchester
Posts: 2,501
Skinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond repute

Due to .ac, .com, .info, .travel, .museum, .whogizzafuck the scripts was all failing on full tests.

My original 100 line function, used a multidimentional array, where I exploded the URL on a period, then tested the highest element of the array against tld[x], then tested tld[x][y] on highest -1, to see if that existed on the second level, if it was a positive then I accepted url+tld[x][y]+tld[x], else I assumed url+tld[x], then I performed a DNS look up to test it, where URL = part -3 of the exploded url.

However it was a nightmare finding all the official subs to build the multi-dim and it slowed the script down doing look ups and stuff so I went all slasher movie and hacked it up
__________________
Browse:
Skinner is offline  
Old 17-02-2009, 03:38:54 PM     #7 (permalink)

 
Join Date: May 2006
Posts: 1,192
Jeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond reputeJeewhizz has a reputation beyond repute

Goodness me. Either I'm not understanding this right, or you are all handling this wrong

The below code will take an array of domains in a variety of formats, and will get you just the domain element (i.e. no subdomains, no TLDs).

Let me know how you get on:

PHP Code:
$domains = array("www.test.com","www.test2.co.uk","www.test3.info","www.test4.wz","www.test5.museum","http://test6.co.uk","test7.co.uk","http://www.test8.co.uk");

foreach(
$domains as $domain) {
    if(
preg_match("/\.?([a-z0-9-]+)\.co\.[a-z]{2}$/i",$domain,$m)) {
        
//we've matched a ******.co.** domain
        
$dom $m[1];
    } else {
        
//treat the domain as a .com/net/org/ws/biz/info
        
preg_match("/\.?([a-z0-9-]+)\.[a-z]{2,}$/i",$domain,$m);
        
$dom $m[1];
    }
    echo 
$domain.': '.$dom.'<br />';

Output for the above code:

Quote:
www.test.com: test
www.test2.co.uk: test2
www.test3.info: test3
www.test4.wz: test4
www.test5.museum: test5
http://test6.co.uk: test6
test7.co.uk: test7
http://www.test8.co.uk: test8
Jeewhizz is offline  
Old 17-02-2009, 11:19:32 PM     #8 (permalink)

 
Skinner's Avatar
 
Join Date: Jul 2008
Location: Manchester
Posts: 2,501
Skinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond reputeSkinner has a reputation beyond repute

Whizz, we are talking about returning ONLY the domain.ext with no subdomains.

Checking if its a valid domain is easy, but slicing the www. or del. or whatever else off the end of the start of a domain is no easy task.

If you knew for a fact that you would only ever get www. you'd just reg replace, but on a parking script ideally you want wildcard sub domains but need a way to pull your database entry

Quote:
select * from domains where dom = del.icio.us
select * from domains where dom = http://www.icio.us
select * from domains where dom = http://icio.us
select * from domains where dom = v.icio.us
would all return different data and be useless for domain dependant data.

Now because the .ext's can be between 2 and 7 chars long and between 1-2 sections (.com vs .co.uk), it makes separating them hard work.

If you have a nice easy way I'd love to see it :P
__________________
Browse:
Skinner is offline  
Old 17-02-2009, 11:52:01 PM     #9 (permalink)

 
grantw's Avatar
 
Join Date: Mar 2005
Posts: 3,597
grantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond repute

I'm no PHP expert but surely Jees script does almost what you're asking, it currently returns the main part of the domain, without subdomains or the extension. You just need to alter it slightly to include the extension?

Grant
grantw is offline  
Old 18-02-2009, 12:05:41 AM     #10 (permalink)

 
grantw's Avatar
 
Join Date: Mar 2005
Posts: 3,597
grantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond reputegrantw has a reputation beyond repute

Also, again 'im no php expert' but can't you do this with explode?

Get the domain
explode it by "."
If the last part of the returned array contains "uk" then your domain with extension is made up of the last 3 parts of the array
If it doesn't contain "uk" the last two parts of the array are what you want

Or maybe I'm making this up as I go along

Grant
grantw is offline  
Closed Thread



Bookmarks

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

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

Similar Threads
Thread Thread Starter Domain Name Community Replies Last Post
Bounce.co.uk appeal decision michaeltoth Domain Name Disputes 65 22-07-2006 04:14:14 AM


All times are GMT. The time now is 09:22:37 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.0 RC 2
All content on Acorn Domains is member generated and is not moderated before posting. All content is viewed and used by you at your own risk and AD does not warrant the accuracy or reliability of any of the information. The views expressed are those of the individual contributors and not necessarily those of AD. Please contact us to report any issues or send a PM to "Admin".