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;
}
}
?>