Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $url_parts = parse_url("http://mail.xxxxxxx.net");
- $domain = $url_parts['host'];
- $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."<br>";
- echo "the domain name is :".$finalDomain."<br />";
- echo "the subdomain is: ";
- echo (!empty($subDomain)) ? $subDomain : "n/a";
- echo "<br>";
- break;
- }
- }
- ?>
- DATABASE
- CREATE TABLE `domain_info` (
- `tld` varchar(20) collate latin1_general_ci NOT NULL default '',
- `whois_server` varchar(100) collate latin1_general_ci NOT NULL default '',
- `is_free` varchar(100) collate latin1_general_ci NOT NULL default '',
- UNIQUE KEY `tld` (`tld`)
- ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
- --
- -- Dumping data for table `domain_info`
- --
- INSERT INTO `domain_info` (`tld`, `whois_server`, `is_free`) VALUES
- ('ac', 'whois.nic.ac', 'No match'),
- ('ac.cn', 'whois.cnnic.net.cn', 'no matching record'),
- ('ac.jp', 'whois.nic.ad.jp', 'No match'),
- ('ac.uk', 'whois.ja.net', 'No such domain'),
- ('ad.jp', 'whois.nic.ad.jp', 'No match'),
- ('adm.br', 'whois.nic.br', 'No match'),
- ('adv.br', 'whois.nic.br', 'No match'),
- ('aero', 'whois.information.aero', 'is available'),
- ('ag', 'whois.nic.ag', 'Not found'),
- ('agr.br', 'whois.nic.br', 'No match'),
- ('ah.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('al', 'whois.ripe.net', 'No entries found'),
- ('am', 'whois.amnic.net', 'No match'),
- ('am.br', 'whois.nic.br', 'No match'),
- ('arq.br', 'whois.nic.br', 'No match'),
- ('art.br', 'whois.nic.br', 'No match'),
- ('as', 'whois.nic.as', 'Domain Not Found'),
- ('asn.au', 'whois.aunic.net', 'No Data Found'),
- ('at', 'whois.nic.at', 'nothing found'),
- ('ato.br', 'whois.nic.br', 'No match'),
- ('au', 'whois.aunic.net', 'No Data Found'),
- ('av.tr', 'whois.nic.tr', 'Not found in database'),
- ('az', 'whois.ripe.net', 'no entries found'),
- ('ba', 'whois.ripe.net', 'No match for'),
- ('be', 'whois.geektools.com', 'No such domain'),
- ('bel.tr', 'whois.nic.tr', 'Not found in database'),
- ('bg', 'whois.digsys.bg', 'does not exist'),
- ('bio.br', 'whois.nic.br', 'No match'),
- ('biz', 'whois.biz', 'Not found'),
- ('biz.tr', 'whois.nic.tr', 'Not found in database'),
- ('bj.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('bmd.br', 'whois.nic.br', 'No match'),
- ('br', 'whois.registro.br', 'No match'),
- ('by', 'whois.ripe.net', 'no entries found'),
- ('ca', 'whois.cira.ca', 'Status: AVAIL'),
- ('cc', 'whois.nic.cc', 'No match'),
- ('cd', 'whois.cd', 'No match'),
- ('ch', 'whois.nic.ch', 'We do not have an entry'),
- ('cim.br', 'whois.nic.br', 'No match'),
- ('ck', 'whois.ck-nic.org.ck', 'No entries found'),
- ('cl', 'whois.nic.cl', 'no existe'),
- ('cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('cng.br', 'whois.nic.br', 'No match'),
- ('cnt.br', 'whois.nic.br', 'No match'),
- ('co.at', 'whois.nic.at', 'nothing found'),
- ('co.jp', 'whois.nic.ad.jp', 'No match'),
- ('co.uk', 'whois.nic.uk', 'No match for'),
- ('com', 'whois.crsnic.net', 'No match'),
- ('com.au', 'whois.aunic.net', 'No Data Found'),
- ('com.br', 'whois.nic.br', 'No match'),
- ('com.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('com.eg', 'whois.ripe.net', 'No entries found'),
- ('com.hk', 'whois.hknic.net.hk', 'No Match for'),
- ('com.mx', 'whois.nic.mx', 'Nombre del Dominio'),
- ('com.ru', 'whois.ripn.ru', 'No entries found'),
- ('com.tr', 'whois.nic.tr', 'Not found in database'),
- ('com.tw', 'whois.twnic.net', 'NO MATCH TIP'),
- ('conf.au', 'whois.aunic.net', 'No entries found'),
- ('cq.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('csiro.au', 'whois.aunic.net', 'No Data Found'),
- ('cx', 'whois.nic.cx', 'No match'),
- ('cy', 'whois.ripe.net', 'no entries found'),
- ('cz', 'whois.nic.cz', 'No data found'),
- ('de', 'whois.denic.de', 'not found'),
- ('dk', 'whois.dk-hostmaster.dk', 'No entries found'),
- ('dr.tr', 'whois.nic.tr', 'Not found in database'),
- ('dz', 'whois.ripe.net', 'no entries found'),
- ('ecn.br', 'whois.nic.br', 'No match'),
- ('edu', 'whois.crsnic.net', 'No match'),
- ('edu.au', 'whois.aunic.net', 'No Data Found'),
- ('edu.br', 'whois.nic.br', 'No match'),
- ('edu.tr', 'whois.nic.tr', 'Not found in database'),
- ('ee', 'whois.eenet.ee', 'NOT FOUND'),
- ('eg', 'whois.ripe.net', 'No entries found'),
- ('emu.id.au', 'whois.aunic.net', 'No Data Found'),
- ('eng.br', 'whois.nic.br', 'No match'),
- ('es', 'whois.ripe.net', 'No entries found'),
- ('esp.br', 'whois.nic.br', 'No match'),
- ('etc.br', 'whois.nic.br', 'No match'),
- ('eti.br', 'whois.nic.br', 'No match'),
- ('eu', 'whois.eu', 'Status: FREE'),
- ('eun.eg', 'whois.ripe.net', 'No entries found'),
- ('far.br', 'whois.nic.br', 'No match'),
- ('fi', 'whois.ripe.net', 'No entries found'),
- ('fj', 'whois.usp.ac.fj', ''),
- ('fj.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('fm.br', 'whois.nic.br', 'No match'),
- ('fnd.br', 'whois.nic.br', 'No match'),
- ('fo', 'whois.ripe.net', 'no entries found'),
- ('fot.br', 'whois.nic.br', 'No match'),
- ('fr', 'whois.nic.fr', 'No entries found'),
- ('fst.br', 'whois.nic.br', 'No match'),
- ('g12.br', 'whois.nic.br', 'No match'),
- ('gb', 'whois.ripe.net', 'No match for'),
- ('gb.com', 'whois.nomination.net', 'No match for'),
- ('gb.net', 'whois.nomination.net', 'No match for'),
- ('gd.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('ge', 'whois.ripe.net', 'no entries found'),
- ('gen.tr', 'whois.nic.tr', 'Not found in database'),
- ('ggf.br', 'whois.nic.br', 'No match'),
- ('gl', 'whois.ripe.net', 'no entries found'),
- ('gob.mx', 'whois.nic.mx', 'Nombre del Dominio'),
- ('gov.au', 'whois.aunic.net', 'No Data Found'),
- ('gov.br', 'whois.nic.br', 'No match'),
- ('gov.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('gov.hk', 'whois.hknic.net.hk', 'No Match for'),
- ('gov.tr', 'whois.nic.tr', 'Not found in database'),
- ('gr', 'whois.ripe.net', 'no entries found'),
- ('gr.jp', 'whois.nic.ad.jp', 'No match'),
- ('gs', 'whois.adamsnames.tc', 'is not registered'),
- ('gs.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('gx.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('gz.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('ha.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('hb.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('he.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('hi.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('hk', 'whois.hknic.net.hk', 'No Match for'),
- ('hk.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('hl.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('hm', 'whois.registry.hm', '(null)'),
- ('hn.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('hu', 'whois.ripe.net', 'MAXCHARS:500'),
- ('id.au', 'whois.aunic.net', 'No Data Found'),
- ('idv.tw', 'whois.twnic.net', 'NO MATCH TIP'),
- ('ie', 'whois.domainregistry.ie', 'no match'),
- ('il', 'whois.isoc.org.il', 'No data was found'),
- ('imb.br', 'whois.nic.br', 'No match'),
- ('ind.br', 'whois.nic.br', 'No match'),
- ('inf.br', 'whois.nic.br', 'No match'),
- ('info', 'whois.afilias.info', 'Not found'),
- ('info.au', 'whois.aunic.net', 'No Data Found'),
- ('info.tr', 'whois.nic.tr', 'Not found in database'),
- ('int', 'whois.iana.org', 'not found'),
- ('is', 'whois.isnic.is', 'No entries found'),
- ('it', 'whois.nic.it', 'No entries found'),
- ('jl.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('jor.br', 'whois.nic.br', 'No match'),
- ('jp', 'whois.nic.ad.jp', 'No match'),
- ('js.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('jx.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('k12.tr', 'whois.nic.tr', 'Not found in database'),
- ('ke', 'whois.rg.net', 'No match for'),
- ('kr', 'whois.krnic.net', 'is not registered'),
- ('la', 'whois.nic.la', 'NO MATCH'),
- ('lel.br', 'whois.nic.br', 'No match'),
- ('li', 'whois.nic.ch', 'We do not have an entry'),
- ('lk', 'whois.nic.lk', 'No domain registered'),
- ('ln.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('lt', 'ns.litnet.lt', 'No matches found'),
- ('ltd.uk', 'whois.nic.uk', 'No match for'),
- ('lu', 'whois.dns.lu', 'No entries found'),
- ('lv', 'whois.ripe.net', 'no entries found'),
- ('ma', 'whois.ripe.net', 'No entries found'),
- ('mat.br', 'whois.nic.br', 'No match'),
- ('mc', 'whois.ripe.net', 'No entries found'),
- ('md', 'whois.ripe.net', 'No match for'),
- ('me.uk', 'whois.nic.uk', 'No match for'),
- ('med.br', 'whois.nic.br', 'No match'),
- ('mil', 'whois.nic.mil', 'No match'),
- ('mil.br', 'whois.nic.br', 'No match'),
- ('mil.tr', 'whois.nic.tr', 'Not found in database'),
- ('mk', 'whois.ripe.net', 'No match for'),
- ('mn', 'whois.nic.mn', 'Domain not found'),
- ('mo.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('ms', 'whois.adamsnames.tc', 'is not registered'),
- ('mt', 'whois.ripe.net', 'No Entries found'),
- ('mus.br', 'whois.nic.br', 'No match'),
- ('mx', 'whois.nic.mx', 'Nombre del Dominio'),
- ('name', 'whois.nic.name', 'No match'),
- ('name.tr', 'whois.nic.tr', 'Not found in database'),
- ('ne.jp', 'whois.nic.ad.jp', 'No match'),
- ('net', 'whois.crsnic.net', 'No match'),
- ('net.au', 'whois.aunic.net', 'No Data Found'),
- ('net.br', 'whois.nic.br', 'No match'),
- ('net.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('net.eg', 'whois.ripe.net', 'No entries found'),
- ('net.hk', 'whois.hknic.net.hk', 'No Match for'),
- ('net.lu', 'whois.dns.lu', 'No entries found'),
- ('net.mx', 'whois.nic.mx', 'Nombre del Dominio'),
- ('net.ru', 'whois.ripn.ru', 'No entries found'),
- ('net.tr', 'whois.nic.tr', 'Not found in database'),
- ('net.tw', 'whois.twnic.net', 'NO MATCH TIP'),
- ('net.uk', 'whois.nic.uk', 'No match for'),
- ('nl', 'whois.domain-registry.nl', 'is not a registered domain'),
- ('nm.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('no', 'whois.norid.no', 'no matches'),
- ('no.com', 'whois.nomination.net', 'No match for'),
- ('nom.br', 'whois.nic.br', 'No match'),
- ('not.br', 'whois.nic.br', 'No match'),
- ('ntr.br', 'whois.nic.br', 'No match'),
- ('nu', 'whois.nic.nu', 'NO MATCH for'),
- ('nx.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('nz', 'whois.domainz.net.nz', 'Not Listed'),
- ('odo.br', 'whois.nic.br', 'No match'),
- ('oop.br', 'whois.nic.br', 'No match'),
- ('or.at', 'whois.nic.at', 'nothing found'),
- ('or.jp', 'whois.nic.ad.jp', 'No match'),
- ('org', 'whois.pir.org', 'NOT FOUND'),
- ('org.au', 'whois.aunic.net', 'No Data Found'),
- ('org.br', 'whois.nic.br', 'No match'),
- ('org.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('org.hk', 'whois.hknic.net.hk', 'No Match for'),
- ('org.lu', 'whois.dns.lu', 'No entries found'),
- ('org.ru', 'whois.ripn.ru', 'No entries found'),
- ('org.tr', 'whois.nic.tr', 'Not found in database'),
- ('org.tw', 'whois.twnic.net', 'NO MATCH TIP'),
- ('org.uk', 'whois.nic.uk', 'No match for'),
- ('pk', 'whois.pknic.net', 'is not registered'),
- ('pl', 'whois.ripe.net', 'No information about'),
- ('plc.uk', 'whois.nic.uk', 'No match for'),
- ('pol.tr', 'whois.nic.tr', 'Not found in database'),
- ('pp.ru', 'whois.ripn.ru', 'No entries found'),
- ('ppg.br', 'whois.nic.br', 'No match'),
- ('pro.br', 'whois.nic.br', 'No match'),
- ('psc.br', 'whois.nic.br', 'No match'),
- ('psi.br', 'whois.nic.br', 'No match'),
- ('pt', 'whois.ripe.net', 'No match for'),
- ('qh.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('qsl.br', 'whois.nic.br', 'No match'),
- ('rec.br', 'whois.nic.br', 'No match'),
- ('ro', 'whois.ripe.net', 'No entries found'),
- ('ru', 'whois.ripn.ru', 'No entries found'),
- ('sc.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('sd.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('se', 'whois.nic-se.se', 'No data found'),
- ('se.com', 'whois.nomination.net', 'No match for'),
- ('se.net', 'whois.nomination.net', 'No match for'),
- ('sg', 'whois.nic.net.sg', 'NO entry found'),
- ('sh', 'whois.nic.sh', 'No match for'),
- ('sh.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('si', 'whois.arnes.si', 'No entries found'),
- ('sk', 'whois.ripe.net', 'no entries found'),
- ('slg.br', 'whois.nic.br', 'No match'),
- ('sm', 'whois.ripe.net', 'no entries found'),
- ('sn.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('srv.br', 'whois.nic.br', 'No match'),
- ('st', 'whois.nic.st', 'No entries found'),
- ('su', 'whois.ripe.net', 'No entries found'),
- ('sx.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('tc', 'whois.adamsnames.tc', 'is not registered'),
- ('tel.tr', 'whois.nic.tr', 'Not found in database'),
- ('th', 'whois.nic.uk', 'No entries found'),
- ('tj.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('tm', 'whois.nic.tm', 'No match for'),
- ('tmp.br', 'whois.nic.br', 'No match'),
- ('tn', 'whois.ripe.net', 'No entries found'),
- ('to', 'whois.tonic.to', 'No match'),
- ('trd.br', 'whois.nic.br', 'No match'),
- ('tur.br', 'whois.nic.br', 'No match'),
- ('tv', 'whois.nic.tv', 'MAXCHARS:75'),
- ('tv.br', 'whois.nic.br', 'No match'),
- ('tw', 'whois.twnic.net', 'NO MATCH TIP'),
- ('tw.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('ua', 'whois.ripe.net', 'No entries found'),
- ('uk', 'whois.thnic.net', 'No match for'),
- ('uk.com', 'whois.nomination.net', 'No match for'),
- ('uk.net', 'whois.nomination.net', 'No match for'),
- ('us', 'whois.nic.us', 'Not found'),
- ('va', 'whois.ripe.net', 'No entries found'),
- ('vet.br', 'whois.nic.br', 'No match'),
- ('vg', 'whois.adamsnames.tc', 'is not registered'),
- ('wattle.id.au', 'whois.aunic.net', 'No Data Found'),
- ('web.tr', 'whois.nic.tr', 'Not found in database'),
- ('ws', 'whois.worldsite.ws', 'No match for'),
- ('xj.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('xz.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('yn.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('yu', 'whois.ripe.net', 'No entries found'),
- ('za', 'whois.frd.ac.za', 'No match for'),
- ('zj.cn', 'whois.cnnic.net.cn', 'No entries found'),
- ('zlg.br', 'whois.nic.br', 'No match'),
- ('co.nr', '', ''),
- ('co.nz', '', ''),
- ('tk', '', ''),
- ('in', '', ''),
- ('gov', '', ''),
- ('hr', '', ''),
- ('fm', 'n/a', 'n/a'),
- ('com.gr', '', ''),
- ('net.gr', '', ''),
- ('org.gr', '', ''),
- ('edu.gr', '', '');
Advertisement
Add Comment
Please, Sign In to add comment