PHP Forums Archive

PHP URL / domain name splitter install

Tags: whois, domain, query, tld

rnrewebsite posted on 2011-01-25 04:09:33 #

Hello
I have set up my data base, I just have a couple questions.. to get this to work. Is there a complete install quote here for PHP URL / domain name splitter ver. 1.00?

is this the part we insert into the page we are working our whois from?

<?php
define("DB_SERVER", "localhost");
define("DB_NAME", "********");
define ("DB_USER", "*******");
define ("DB_PASSWORD", "********");
?>

<?php
$url_parts = parse_url("http://mail.finalwebsites.co.uk"); //<< this.. what do we change this to?
$domain = $url_parts['']
$res = mysql_query("SELECT tld FROM domain_info ORDER BY LENGTH(tld) DESC");
// "ORDER BY LENGTH(tld)" will give first the co.uk and then the uk
while ($arr = mysql_fetch_assoc($res)) {
    $tmp_tld = substr($domain, -strlen(".".$arr['tld']));
    if ($tmp_tld == ".".$arr['tld']) { // You found the tld
        $tld = ltrim($arr['tld'], ".");
        $domainLeft = substr($domain, 0, -(strlen($tld) + 1)); // It will left the whatever, without the extension and the .
        if (strpos($domainLeft, ".") === false) { // It hasn't a subdomain
            $subDomain = "";
            $finalDomain = $domainLeft;
        } else {
            $domain_parts = explode(".", $domainLeft);
            $finalDomain = array_pop($domain_parts); // select the domain and remove it from the array
            $subDomain = implode(".", $domain_parts); // a subdomain can more then one parts seperated with dot's
        }
        echo "The tld is: ".$tld."";
        echo "the domain name is :".$finalDomain."";
        echo "the subdomain is: ";
        echo (!empty($subDomain)) ? $subDomain : "n/a";
        echo "";
        break;
    }
}
?>

Comments / discussions

Olaf posted on 2011-01-25 07:24:40 #

Hi,

it seems there was some small part of code missing, you need to replace the second row with this:
$domain = $url_parts['host'];

The value 'http://mail.finalwebsites.co.uk' is the url you need to enter by yourself.

btw. this function is not used for a whois query ;)

testuser posted on 2011-01-25 07:29:27 #

If you need a whois function check the php class or try the "whois" function from your linux server

Olaf posted on 2011-01-25 08:14:34 #

btw. do you imported the domain extenstion list? This data is required to get this working, not this list is not maintained during the last moths.

Download via http://db.tt/Sb7iPdb

rnrewebsite posted on 2011-01-25 13:42:24 #

Oh..ok I thought this domain name splitter worked with a whois,, when someone searches a domain name this function returns a list of other possible domain names you could use, incase the one you picked was taken.

rnrewebsite posted on 2011-01-25 15:53:05 #

could I get you to email me the install directions to get this to work please?

Olaf posted on 2011-01-27 07:37:31 #

Quote from: rnrewebsite
"could I get you to email me the install directions to get this to work please?"

I don't have one, but works like:

1. create a regular whois
2. split the requested domain
3. make another whois queries for the TLD's you offer
4. show the result for all of them (add a register / transfer option beside each result)

This is something you need to build by yourself. I don't think that there is a ready-made script for this.