im looking for a php function to split a domain name
lets say i have this:
http://www.wallpaperama.com
and i want to only get the wallpaperama part from it
how do i do this?
Php Function Remove Domain Name Get Tld Splitter Split
Php Function Remove Domain Name Get Tld Splitter Split
Php Function Remove Domain Name Get Tld Splitter Split
Post Description:
Post Tags: php, function, remove, domain, name, get, tld, splitter, split, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 624 Times Since Mon Mar 03, 2008 9:51 pm Posted By hostman with 6 replies
Next Post »» php get domain name only from tld
Post Description:
Post Tags: php, function, remove, domain, name, get, tld, splitter, split, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 624 Times Since Mon Mar 03, 2008 9:51 pm Posted By hostman with 6 replies
Next Post »» php get domain name only from tld
| Php Function Remove Domain Name Get Tld Splitter Split |
Leave Your Comments
Comments and replies About Php Function Remove Domain Name Get Tld Splitter Split
:: 1 :: #44246 - Reply By lucas On Tue Mar 04, 2008 10:19 pm
have you tried this?
<?php
$url_parts = parse_url("http://mail.finalwebsites.co.uk");
$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."<br>";
echo "the domain name is :".$finalDomain."<br />";
echo "the subdomain is: ";
echo (!empty($subDomain)) ? $subDomain : "n/a";
echo "<br>";
break;
}
}
?>:: 2 :: #44247 - Reply By hostman On Tue Mar 04, 2008 10:21 pm
i tried it but it doesnt work, i dont have the mysql dump
:: 3 :: #44248 - Reply By lucas On Tue Mar 04, 2008 10:22 pm
here it is:
-- phpMyAdmin SQL Dump
-- version 2.6.0-pl3
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Mar 04, 2008 at 10:02 PM
-- Server version: 4.1.7
-- PHP Version: 5.0.3RC2-dev
--
-- Database: `mypages`
--
-- --------------------------------------------------------
--
-- Table structure for table `domain_info`
--
CREATE TABLE `domain_info` (
`tld` varchar(20) NOT NULL default '',
`whois_server` varchar(100) NOT NULL default '',
`is_free` varchar(100) NOT NULL default '',
UNIQUE KEY `tld_2` (`tld`),
KEY `tld` (`tld`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `domain_info`
--
INSERT INTO `domain_info` VALUES ('ac', 'whois.nic.ac', 'No match');
INSERT INTO `domain_info` VALUES ('ac.cn', 'whois.cnnic.net.cn', 'norn matching record');
INSERT INTO `domain_info` VALUES ('ac.jp', 'whois.nic.ad.jp', 'Norn match');
INSERT INTO `domain_info` VALUES ('ac.uk', 'whois.ja.net', 'No suchrn domain');
INSERT INTO `domain_info` VALUES ('ad.jp', 'whois.nic.ad.jp', 'Norn match');
INSERT INTO `domain_info` VALUES ('adm.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('adv.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('aero', 'whois.information.aero', 'isrn available');
INSERT INTO `domain_info` VALUES ('ag', 'whois.nic.ag', 'Not found');
INSERT INTO `domain_info` VALUES ('agr.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('ah.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('al', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('am', 'whois.amnic.net', 'No match');
INSERT INTO `domain_info` VALUES ('am.br', 'whois.nic.br', 'No match');
INSERT INTO `domain_info` VALUES ('arq.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('art.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('as', 'whois.nic.as', 'Domain Notrn Found');
INSERT INTO `domain_info` VALUES ('asn.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('at', 'whois.nic.at', 'nothingrn found');
INSERT INTO `domain_info` VALUES ('ato.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('av.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('az', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('ba', 'whois.ripe.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('be', 'whois.geektools.com', 'No suchrn domain');
INSERT INTO `domain_info` VALUES ('bel.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('bg', 'whois.digsys.bg', 'does notrn exist');
INSERT INTO `domain_info` VALUES ('bio.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('biz', 'whois.biz', 'Not found');
INSERT INTO `domain_info` VALUES ('biz.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('bj.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('bmd.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('br', 'whois.registro.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('by', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('ca', 'whois.cira.ca', 'Status:rn AVAIL');
INSERT INTO `domain_info` VALUES ('cc', 'whois.nic.cc', 'No match');
INSERT INTO `domain_info` VALUES ('cd', 'whois.cd', 'No match');
INSERT INTO `domain_info` VALUES ('ch', 'whois.nic.ch', 'We do not havern an entry');
INSERT INTO `domain_info` VALUES ('cim.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('ck', 'whois.ck-nic.org.ck', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('cl', 'whois.nic.cl', 'no existe');
INSERT INTO `domain_info` VALUES ('cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('cng.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('cnt.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('co.at', 'whois.nic.at', 'nothingrn found');
INSERT INTO `domain_info` VALUES ('co.jp', 'whois.nic.ad.jp', 'Norn match');
INSERT INTO `domain_info` VALUES ('co.uk', 'whois.nic.uk', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('com', 'whois.crsnic.net', 'Norn match');
INSERT INTO `domain_info` VALUES ('com.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('com.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('com.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('com.eg', 'whois.ripe.net', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('com.hk', 'whois.hknic.net.hk', 'Norn Match for');
INSERT INTO `domain_info` VALUES ('com.mx', 'whois.nic.mx', 'Nombre delrn Dominio');
INSERT INTO `domain_info` VALUES ('com.ru', 'whois.ripn.ru', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('com.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('com.tw', 'whois.twnic.net', 'NOrn MATCH TIP');
INSERT INTO `domain_info` VALUES ('conf.au', 'whois.aunic.net', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('cq.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('csiro.au', 'whois.aunic.net', 'Norn Data Found');
INSERT INTO `domain_info` VALUES ('cx', 'whois.nic.cx', 'No match');
INSERT INTO `domain_info` VALUES ('cy', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('cz', 'whois.nic.cz', 'No datarn found');
INSERT INTO `domain_info` VALUES ('de', 'whois.denic.de', 'not found');
INSERT INTO `domain_info` VALUES ('dk', 'whois.dk-hostmaster.dk', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('dr.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('dz', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('ecn.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('edu', 'whois.crsnic.net', 'Norn match');
INSERT INTO `domain_info` VALUES ('edu.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('edu.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('edu.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('ee', 'whois.eenet.ee', 'NOT FOUND');
INSERT INTO `domain_info` VALUES ('eg', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('emu.id.au', 'whois.aunic.net', 'Norn Data Found');
INSERT INTO `domain_info` VALUES ('eng.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('es', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('esp.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('etc.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('eti.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('eu', 'whois.eu', 'Status: rn FREE');
INSERT INTO `domain_info` VALUES ('eun.eg', 'whois.ripe.net', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('far.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('fi', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('fj', 'whois.usp.ac.fj', '');
INSERT INTO `domain_info` VALUES ('fj.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('fm.br', 'whois.nic.br', 'No match');
INSERT INTO `domain_info` VALUES ('fnd.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('fo', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('fot.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('fr', 'whois.nic.fr', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('fst.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('g12.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('gb', 'whois.ripe.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('gb.com', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('gb.net', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('gd.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('ge', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('gen.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('ggf.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('gl', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('gob.mx', 'whois.nic.mx', 'Nombre delrn Dominio');
INSERT INTO `domain_info` VALUES ('gov.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('gov.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('gov.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('gov.hk', 'whois.hknic.net.hk', 'Norn Match for');
INSERT INTO `domain_info` VALUES ('gov.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('gr', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('gr.jp', 'whois.nic.ad.jp', 'Norn match');
INSERT INTO `domain_info` VALUES ('gs', 'whois.adamsnames.tc', 'is notrn registered');
INSERT INTO `domain_info` VALUES ('gs.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('gx.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('gz.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('ha.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('hb.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('he.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('hi.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('hk', 'whois.hknic.net.hk', 'No Matchrn for');
INSERT INTO `domain_info` VALUES ('hk.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('hl.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('hm', 'whois.registry.hm', '(null)');
INSERT INTO `domain_info` VALUES ('hn.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('hu', 'whois.ripe.net', 'MAXCHARS:500');
INSERT INTO `domain_info` VALUES ('id.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('idv.tw', 'whois.twnic.net', 'NOrn MATCH TIP');
INSERT INTO `domain_info` VALUES ('ie', 'whois.domainregistry.ie', 'norn match');
INSERT INTO `domain_info` VALUES ('il', 'whois.isoc.org.il', 'No datarn was found');
INSERT INTO `domain_info` VALUES ('imb.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('ind.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('inf.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('info', 'whois.afilias.info', 'Notrn found');
INSERT INTO `domain_info` VALUES ('info.au', 'whois.aunic.net', 'Norn Data Found');
INSERT INTO `domain_info` VALUES ('info.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('int', 'whois.iana.org', 'notrn found');
INSERT INTO `domain_info` VALUES ('is', 'whois.isnic.is', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('it', 'whois.nic.it', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('jl.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('jor.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('jp', 'whois.nic.ad.jp', 'No match');
INSERT INTO `domain_info` VALUES ('js.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('jx.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('k12.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('ke', 'whois.rg.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('kr', 'whois.krnic.net', 'is notrn registered');
INSERT INTO `domain_info` VALUES ('la', 'whois.nic.la', 'NO MATCH');
INSERT INTO `domain_info` VALUES ('lel.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('li', 'whois.nic.ch', 'We do not havern an entry');
INSERT INTO `domain_info` VALUES ('lk', 'whois.nic.lk', 'No domainrn registered');
INSERT INTO `domain_info` VALUES ('ln.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('lt', 'ns.litnet.lt', 'No matchesrn found');
INSERT INTO `domain_info` VALUES ('ltd.uk', 'whois.nic.uk', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('lu', 'whois.dns.lu', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('lv', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('ma', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('mat.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('mc', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('md', 'whois.ripe.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('me.uk', 'whois.nic.uk', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('med.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('mil', 'whois.nic.mil', 'No match');
INSERT INTO `domain_info` VALUES ('mil.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('mil.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('mk', 'whois.ripe.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('mn', 'whois.nic.mn', 'Domain notrn found');
INSERT INTO `domain_info` VALUES ('mo.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('ms', 'whois.adamsnames.tc', 'is notrn registered');
INSERT INTO `domain_info` VALUES ('mt', 'whois.ripe.net', 'No Entriesrn found');
INSERT INTO `domain_info` VALUES ('mus.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('mx', 'whois.nic.mx', 'Nombre delrn Dominio');
INSERT INTO `domain_info` VALUES ('name', 'whois.nic.name', 'Norn match');
INSERT INTO `domain_info` VALUES ('name.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('ne.jp', 'whois.nic.ad.jp', 'Norn match');
INSERT INTO `domain_info` VALUES ('net', 'whois.crsnic.net', 'Norn match');
INSERT INTO `domain_info` VALUES ('net.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('net.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('net.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('net.eg', 'whois.ripe.net', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('net.hk', 'whois.hknic.net.hk', 'Norn Match for');
INSERT INTO `domain_info` VALUES ('net.lu', 'whois.dns.lu', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('net.mx', 'whois.nic.mx', 'Nombre delrn Dominio');
INSERT INTO `domain_info` VALUES ('net.ru', 'whois.ripn.ru', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('net.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('net.tw', 'whois.twnic.net', 'NOrn MATCH TIP');
INSERT INTO `domain_info` VALUES ('net.uk', 'whois.nic.uk', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('nl', 'whois.domain-registry.nl', 'isrn not a registered domain');
INSERT INTO `domain_info` VALUES ('nm.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('no', 'whois.norid.no', 'norn matches');
INSERT INTO `domain_info` VALUES ('no.com', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('nom.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('not.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('ntr.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('nu', 'whois.nic.nu', 'NO MATCHrn for');
INSERT INTO `domain_info` VALUES ('nx.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('nz', 'whois.domainz.net.nz', 'Notrn Listed');
INSERT INTO `domain_info` VALUES ('odo.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('oop.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('or.at', 'whois.nic.at', 'nothingrn found');
INSERT INTO `domain_info` VALUES ('or.jp', 'whois.nic.ad.jp', 'Norn match');
INSERT INTO `domain_info` VALUES ('org', 'whois.pir.org', 'NOT FOUND');
INSERT INTO `domain_info` VALUES ('org.au', 'whois.aunic.net', 'No Datarn Found');
INSERT INTO `domain_info` VALUES ('org.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('org.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('org.hk', 'whois.hknic.net.hk', 'Norn Match for');
INSERT INTO `domain_info` VALUES ('org.lu', 'whois.dns.lu', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('org.ru', 'whois.ripn.ru', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('org.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('org.tw', 'whois.twnic.net', 'NOrn MATCH TIP');
INSERT INTO `domain_info` VALUES ('org.uk', 'whois.nic.uk', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('pk', 'whois.pknic.net', 'is notrn registered');
INSERT INTO `domain_info` VALUES ('pl', 'whois.ripe.net', 'Norn information about');
INSERT INTO `domain_info` VALUES ('plc.uk', 'whois.nic.uk', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('pol.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('pp.ru', 'whois.ripn.ru', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('ppg.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('pro.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('psc.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('psi.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('pt', 'whois.ripe.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('qh.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('qsl.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('rec.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('ro', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('ru', 'whois.ripn.ru', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('sc.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('sd.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('se', 'whois.nic-se.se', 'No datarn found');
INSERT INTO `domain_info` VALUES ('se.com', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('se.net', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('sg', 'whois.nic.net.sg', 'NO entryrn found');
INSERT INTO `domain_info` VALUES ('sh', 'whois.nic.sh', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('sh.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('si', 'whois.arnes.si', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('sk', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('slg.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('sm', 'whois.ripe.net', 'no entriesrn found');
INSERT INTO `domain_info` VALUES ('sn.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('srv.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('st', 'whois.nic.st', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('su', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('sx.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('tc', 'whois.adamsnames.tc', 'is notrn registered');
INSERT INTO `domain_info` VALUES ('tel.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('th', 'whois.nic.uk', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('tj.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('tm', 'whois.nic.tm', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('tmp.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('tn', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('to', 'whois.tonic.to', 'No match');
INSERT INTO `domain_info` VALUES ('trd.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('tur.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('tv', 'whois.nic.tv', 'MAXCHARS:75');
INSERT INTO `domain_info` VALUES ('tv.br', 'whois.nic.br', 'No match');
INSERT INTO `domain_info` VALUES ('tw', 'whois.twnic.net', 'NO MATCHrn TIP');
INSERT INTO `domain_info` VALUES ('tw.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('ua', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('uk', 'whois.thnic.net', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('uk.com', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('uk.net', 'whois.nomination.net', 'Norn match for');
INSERT INTO `domain_info` VALUES ('us', 'whois.nic.us', 'Not found');
INSERT INTO `domain_info` VALUES ('va', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('vet.br', 'whois.nic.br', 'Norn match');
INSERT INTO `domain_info` VALUES ('vg', 'whois.adamsnames.tc', 'is notrn registered');
INSERT INTO `domain_info` VALUES ('wattle.id.au', 'whois.aunic.net', 'No Data Found');
INSERT INTO `domain_info` VALUES ('web.tr', 'whois.nic.tr', 'Not foundrn in database');
INSERT INTO `domain_info` VALUES ('ws', 'whois.worldsite.ws', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('xj.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('xz.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('yn.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('yu', 'whois.ripe.net', 'No entriesrn found');
INSERT INTO `domain_info` VALUES ('za', 'whois.frd.ac.za', 'No matchrn for');
INSERT INTO `domain_info` VALUES ('zj.cn', 'whois.cnnic.net.cn', 'Norn entries found');
INSERT INTO `domain_info` VALUES ('zlg.br', 'whois.nic.br', 'Norn match');:: 4 :: #44249 - Reply By hostman On Tue Mar 04, 2008 10:26 pm
when i run it, i get this error:
Parse error: parse error, unexpected T_VARIABLE in C:\inut/test-remove-com-from-domain.name.php on line 4
so i put the ; at the end
and now i get this:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\inut/test-remove-com-from-domain.name.php on line 6
i can't make it work, were you able to make it work for you?
Parse error: parse error, unexpected T_VARIABLE in C:\inut/test-remove-com-from-domain.name.php on line 4
so i put the ; at the end
and now i get this:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\inut/test-remove-com-from-domain.name.php on line 6
i can't make it work, were you able to make it work for you?
:: 5 :: #44252 - Reply By lucas On Tue Mar 04, 2008 10:46 pm
ok, i figure it out, i made it easy, simple and pretty for you. check it our..
NOTE: thanks for the folks at www.webune.com for their support on this, i couldn't have done it without their help.
so to make it work, just copy and save this code to your notepad and save it as webune.php and then upload to your website:
NOTE: make sure to provide the database username, password, and database name for the script to connect to your database mysql dump. otherwise, it wont work.
you should see something like this:
output:
NOTE: thanks for the folks at www.webune.com for their support on this, i couldn't have done it without their help.
so to make it work, just copy and save this code to your notepad and save it as webune.php and then upload to your website:
NOTE: make sure to provide the database username, password, and database name for the script to connect to your database mysql dump. otherwise, it wont work.
<style type="text/css">
<!--
.red {
color: #FF0000;
}
-->
</style>
<?php
// PLEASE LEAVE THIS HERE, DO NOT REMOVE
// source: http://www.finalwebsites.com/snippets.php?id=46
// bugs fixed by www.webune.com
// source: http://www.wallpaperama.com/forums/php-function-remove-domain-name-get-tld-splitter-split-t5824.html
####################### C O N F I G U R E #######################
$hostname = "localhost"; // usually localhost
$dbuser = ""; // database username
$dbpassword = ""; // database username password
$dbname = ""; // database name
####################### S T O P #######################
$db = mysql_connect($hostname, $dbuser, $dbpassword);
mysql_select_db($dbname,$db);
$url = "http://mail.www.wallpaperama.com/wallpapers";
$url_parts = parse_url($url);
echo "<h1>The Url is: $url</h1><hr>";
echo "The parse_url arry is: <strong>"; print_r($url_parts); echo "</strong><hr>";
$domain = $url_parts[host];
$sql = "SELECT tld FROM domain_info ORDER BY LENGTH(tld) DESC";
$result = mysql_query($sql ,$db);
if ($myrow = mysql_fetch_assoc($result)) {
do {
$tmp_tld = substr($domain, -strlen(".".$myrow['tld']));
if ($tmp_tld == ".".$myrow['tld']) { // You found the tld
$tld = ltrim($myrow['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 '<h1>The tld is: <span class="red">.'.$tld."</span></h1>";
echo '<h1>the domain name is : <span class="red">'.$finalDomain."</span></h1>";
echo '<h1>the subdomain is: <span class="red">';
echo (!empty($subDomain)) ? $subDomain : "</span></h1>";
echo "<br>";
break;
}
} while ($myrow = mysql_fetch_array($result));
}
?>
<!--
.red {
color: #FF0000;
}
-->
</style>
<?php
// PLEASE LEAVE THIS HERE, DO NOT REMOVE
// source: http://www.finalwebsites.com/snippets.php?id=46
// bugs fixed by www.webune.com
// source: http://www.wallpaperama.com/forums/php-function-remove-domain-name-get-tld-splitter-split-t5824.html
####################### C O N F I G U R E #######################
$hostname = "localhost"; // usually localhost
$dbuser = ""; // database username
$dbpassword = ""; // database username password
$dbname = ""; // database name
####################### S T O P #######################
$db = mysql_connect($hostname, $dbuser, $dbpassword);
mysql_select_db($dbname,$db);
$url = "http://mail.www.wallpaperama.com/wallpapers";
$url_parts = parse_url($url);
echo "<h1>The Url is: $url</h1><hr>";
echo "The parse_url arry is: <strong>"; print_r($url_parts); echo "</strong><hr>";
$domain = $url_parts[host];
$sql = "SELECT tld FROM domain_info ORDER BY LENGTH(tld) DESC";
$result = mysql_query($sql ,$db);
if ($myrow = mysql_fetch_assoc($result)) {
do {
$tmp_tld = substr($domain, -strlen(".".$myrow['tld']));
if ($tmp_tld == ".".$myrow['tld']) { // You found the tld
$tld = ltrim($myrow['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 '<h1>The tld is: <span class="red">.'.$tld."</span></h1>";
echo '<h1>the domain name is : <span class="red">'.$finalDomain."</span></h1>";
echo '<h1>the subdomain is: <span class="red">';
echo (!empty($subDomain)) ? $subDomain : "</span></h1>";
echo "<br>";
break;
}
} while ($myrow = mysql_fetch_array($result));
}
?>
you should see something like this:
output:
The Url is: http://mail.www.wallpaperama.com/wallpapers
The parse_url arry is: Array ( [scheme] => http [host] => mail.www.wallpaperama.com [path] => /wallpapers )
The tld is: .com
the domain name is : wallpaperama
the subdomain is: mail.www
The parse_url arry is: Array ( [scheme] => http [host] => mail.www.wallpaperama.com [path] => /wallpapers )
The tld is: .com
the domain name is : wallpaperama
the subdomain is: mail.www
:: 6 :: #44334 - Reply By webune On Wed Mar 05, 2008 1:41 pm
ok, i made it even easier if you dont have a mysql database, i created this function to make it work without having to use a database.
just save it as webune.php and upload to your php website and see it run
just save it as webune.php and upload to your php website and see it run
<?
function DomainSplit_ByWebune($url){
# FUNCTION CREATED BY WWW.WEBUNE.COM
# PLEASE DO NOT REMOVE THIS - THANK YOU
$tld2 = array('wattle.id.au','emu.id.au','csiro.au','name.tr','conf.au','info.tr','info.au','gov.au','k12.tr','lel.br','ltd.uk','mat.br','jor.br','med.br','net.hk','net.eg','net.cn','net.br','net.au','mus.br','mil.tr','mil.br','net.lu','inf.br','fnd.br','fot.br','fst.br','g12.br','gb.com','gb.net','gen.tr','ggf.br','gob.mx','gov.br','gov.cn','gov.hk','gov.tr','idv.tw','imb.br','ind.br','far.br','net.mx','se.com','rec.br','qsl.br','psi.br','psc.br','pro.br','ppg.br','pol.tr','se.net','slg.br','vet.br','uk.net','uk.com','tur.br','trd.br','tmp.br','tel.tr','srv.br','plc.uk','org.uk','ntr.br','not.br','nom.br','no.com','net.uk','net.tw','net.tr','net.ru','odo.br','oop.br','org.tw','org.tr','org.ru','org.lu','org.hk','org.cn','org.br','org.au','web.tr','eun.eg','zlg.br','cng.br','com.eg','bio.br','agr.br','biz.tr','cnt.br','art.br','com.hk','adv.br','cim.br','com.mx','arq.br','com.ru','com.tr','bmd.br','com.tw','adm.br','ecn.br','edu.br','etc.br','eng.br','esp.br','com.au','com.br','ato.br','com.cn','eti.br','edu.au','bel.tr','edu.tr','asn.au','jl.cn','mo.cn','sh.cn','nm.cn','js.cn','jx.cn','am.br','sc.cn','sn.cn','me.uk','co.jp','ne.jp','sx.cn','ln.cn','co.uk','co.at','sd.cn','tj.cn','cq.cn','qh.cn','gs.cn','gr.jp','dr.tr','ac.jp','hb.cn','ac.cn','gd.cn','pp.ru','xj.cn','xz.cn','yn.cn','av.tr','fm.br','fj.cn','zj.cn','gx.cn','gz.cn','ha.cn','ah.cn','nx.cn','tv.br','tw.cn','bj.cn','id.au','or.at','hn.cn','ad.jp','hl.cn','hk.cn','ac.uk','hi.cn','he.cn','or.jp','name','info','aero','edu','org','int','biz','mil','net','com','ua','st','tw','sg','uk','au','za','yu','ws','at','us','vg','as','va','tv','pt','si','sk','ag','sm','ca','su','al','am','tc','th','tm','ro','tn','to','ru','se','sh','eu','dk','ie','il','de','cz','cy','cx','is','it','jp','ke','kr','la','hu','hm','hk','fi','fj','fo','fr','es','gb','eg','ge','ee','gl','ac','gr','gs','li','lk','cd','nl','no','cc','by','br','nu','nz','bg','be','ba','az','pk','ch','ck','cl','lt','lu','lv','ma','mc','md','mk','mn','ms','mt','mx','dz','cn','pl');
$url_parts = parse_url($url);
$WebuneDomain = $url_parts[host];
$counter = 1;
do {
$tmp_tld = substr($WebuneDomain, -strlen(".".$tld2[$counter]));
if ($tmp_tld == ".".$tld2[$counter]) {
$tld = ltrim($tld2[$counter], ".");
$WebuneDomainLeft = substr($WebuneDomain, 0, -(strlen($tld) + 1));
if (strpos($WebuneDomainLeft, ".") === false) {
$subWebuneDomain = "";
$finalWebuneDomain = $WebuneDomainLeft;
} else {
$WebuneDomain_parts = explode(".", $WebuneDomainLeft);
$finalWebuneDomain = array_pop($WebuneDomain_parts);
}
return $finalWebuneDomain;
}
$counter++;
} while ($counter < count($tld2));
}
echo DomainSplit_ByWebune($url);
?>
function DomainSplit_ByWebune($url){
# FUNCTION CREATED BY WWW.WEBUNE.COM
# PLEASE DO NOT REMOVE THIS - THANK YOU
$tld2 = array('wattle.id.au','emu.id.au','csiro.au','name.tr','conf.au','info.tr','info.au','gov.au','k12.tr','lel.br','ltd.uk','mat.br','jor.br','med.br','net.hk','net.eg','net.cn','net.br','net.au','mus.br','mil.tr','mil.br','net.lu','inf.br','fnd.br','fot.br','fst.br','g12.br','gb.com','gb.net','gen.tr','ggf.br','gob.mx','gov.br','gov.cn','gov.hk','gov.tr','idv.tw','imb.br','ind.br','far.br','net.mx','se.com','rec.br','qsl.br','psi.br','psc.br','pro.br','ppg.br','pol.tr','se.net','slg.br','vet.br','uk.net','uk.com','tur.br','trd.br','tmp.br','tel.tr','srv.br','plc.uk','org.uk','ntr.br','not.br','nom.br','no.com','net.uk','net.tw','net.tr','net.ru','odo.br','oop.br','org.tw','org.tr','org.ru','org.lu','org.hk','org.cn','org.br','org.au','web.tr','eun.eg','zlg.br','cng.br','com.eg','bio.br','agr.br','biz.tr','cnt.br','art.br','com.hk','adv.br','cim.br','com.mx','arq.br','com.ru','com.tr','bmd.br','com.tw','adm.br','ecn.br','edu.br','etc.br','eng.br','esp.br','com.au','com.br','ato.br','com.cn','eti.br','edu.au','bel.tr','edu.tr','asn.au','jl.cn','mo.cn','sh.cn','nm.cn','js.cn','jx.cn','am.br','sc.cn','sn.cn','me.uk','co.jp','ne.jp','sx.cn','ln.cn','co.uk','co.at','sd.cn','tj.cn','cq.cn','qh.cn','gs.cn','gr.jp','dr.tr','ac.jp','hb.cn','ac.cn','gd.cn','pp.ru','xj.cn','xz.cn','yn.cn','av.tr','fm.br','fj.cn','zj.cn','gx.cn','gz.cn','ha.cn','ah.cn','nx.cn','tv.br','tw.cn','bj.cn','id.au','or.at','hn.cn','ad.jp','hl.cn','hk.cn','ac.uk','hi.cn','he.cn','or.jp','name','info','aero','edu','org','int','biz','mil','net','com','ua','st','tw','sg','uk','au','za','yu','ws','at','us','vg','as','va','tv','pt','si','sk','ag','sm','ca','su','al','am','tc','th','tm','ro','tn','to','ru','se','sh','eu','dk','ie','il','de','cz','cy','cx','is','it','jp','ke','kr','la','hu','hm','hk','fi','fj','fo','fr','es','gb','eg','ge','ee','gl','ac','gr','gs','li','lk','cd','nl','no','cc','by','br','nu','nz','bg','be','ba','az','pk','ch','ck','cl','lt','lu','lv','ma','mc','md','mk','mn','ms','mt','mx','dz','cn','pl');
$url_parts = parse_url($url);
$WebuneDomain = $url_parts[host];
$counter = 1;
do {
$tmp_tld = substr($WebuneDomain, -strlen(".".$tld2[$counter]));
if ($tmp_tld == ".".$tld2[$counter]) {
$tld = ltrim($tld2[$counter], ".");
$WebuneDomainLeft = substr($WebuneDomain, 0, -(strlen($tld) + 1));
if (strpos($WebuneDomainLeft, ".") === false) {
$subWebuneDomain = "";
$finalWebuneDomain = $WebuneDomainLeft;
} else {
$WebuneDomain_parts = explode(".", $WebuneDomainLeft);
$finalWebuneDomain = array_pop($WebuneDomain_parts);
}
return $finalWebuneDomain;
}
$counter++;
} while ($counter < count($tld2));
}
echo DomainSplit_ByWebune($url);
?>