Файл: billing/_rootinc/domain.class.inc.php
Строк: 1149
<?
/**
* This class checks the availability of a domain and gets the whois data
*
* @author Sven Wagener <sven.wagener@intertribe.de>
* @copyright Intertribe Limited
* @include Funktion:_include_
*/
class domain{
public $domain = "";
public $my_whois_server = "";
public $my_notfound_string = "";
public $last_error = "";
/*******************************
* Initializing server variables
* array(top level domain,whois_Server,not_found_string or MAX number of CHARS: MAXCHARS:n)
********************************/
public $servers=array(
array("ac","whois.nic.ac","No match"),
array("ac.cn","whois.cnnic.net.cn","No entries found"),
array("ac.jp","whois.nic.ad.jp","No match"),
array("ac.uk","whois.ja.net","no entries"),
array("ad.jp","whois.nic.ad.jp","No match"),
array("adm.br","whois.nic.br","No match"),
array("adv.br","whois.nic.br","No match"),
array("ae.org","whois.centralnic.com","No match for"),
array("aero","whois.information.aero","is available"),
array("ag","whois.nic.ag","does not exist"),
array("agr.br","whois.nic.br","No match"),
array("ah.cn","whois.cnnic.net.cn","No entries found"),
array("al","whois.ripe.net","No entries found"),
array("am","whois.amnic.net","No match"),
array("am.br","whois.nic.br","No match"),
array("arq.br","whois.nic.br","No match"),
array("art.museum","whois.museum","NOT FOUND"),
array("asia","whois.nic.asia","NOT FOUND"),
array("at","whois.nic.at","nothing found"),
array("au","whois.aunic.net","No Data Found"),
array("art.br","whois.nic.br","No match"),
array("as","whois.nic.as","Domain Not Found"),
array("asn.au","whois.aunic.net","No Data Found"),
array("ato.br","whois.nic.br","No match"),
array("be","whois.geektools.com","No such domain"),
array("bg","whois.digsys.bg","does not exist"),
array("bio.br","whois.nic.br","No match"),
array("biz","whois.biz","Not found"),
array("biz.ua","whois.biz.ua","No entries found"),
array("br.com","whois.centralnic.com","No match for"),
array("bz","whois2.afilias-grs.net","NOT FOUND"),
array("bj.cn","whois.cnnic.net.cn","No entries found"),
array("bmd.br","whois.nic.br","No match"),
array("br","whois.registro.br","No match"),
array("ca","whois.cira.ca","Status: AVAIL"),
array("cc","whois.nic.cc","No match"),
array("cd","whois.cd","No match"),
array("ch","whois.nic.ch","We do not have an entry"),
array("cim.br","whois.nic.br","No match"),
array("ck","whois.ck-nic.org.ck","No entries found"),
array("ck.ua","nic.cherkassy.ua","No entries found"),
array("cl","whois.nic.cl","no existe"),
array("cn","whois.cnnic.net.cn","no matching record"),
array("cn.com","whois.centralnic.com","No match for"),
array("co.in","whois.inregistry.net","NOT FOUND"),
array("co.ua","whois.co.ua","No entries found"),
array("cng.br","whois.nic.br","No match"),
array("cnt.br","whois.nic.br","No match"),
array("com","whois.verisign-grs.net","No match"),
array("com.au","whois.aunic.net","No Data Found"),
array("com.br","whois.nic.br","No match"),
array("com.cn","whois.cnnic.net.cn","no matching record"),
array("com.eg","whois.ripe.net","No entries found"),
array("com.hk","whois.hknic.net.hk","No Match for"),
array("com.mx","whois.nic.mx","Nombre del Dominio"),
array("com.ru","whois.ripn.net","No entries found"),
array("com.tw","whois.twnic.net","NO MATCH TIP"),
array("com.ua","whois.com.ua","No entries found"),
array("conf.au","whois.aunic.net","No entries found"),
array("co.jp","whois.nic.ad.jp","No match"),
array("co.uk","whois.nic.uk","No match for"),
array("crimea.ua","whois.crimea.ua","domain not in database"),
array("cq.cn","whois.cnnic.net.cn","No entries found"),
array("csiro.au","whois.aunic.net","No Data Found"),
array("cx","whois.nic.cx","No match"),
array("cz","whois.nic.cz","No data found"),
array("de","whois.denic.de","No entries found"),
array("de.com","whois.centralnic.com","No match for"),
array("dk","whois.dk-hostmaster.dk","No entries found"),
array("dn.ua","whois.dn.ua","No match record found"),
array("donetsk.ua","whois.dn.ua","No match record found"),
array("dp.ua","whois.dp.ua","MAXCHARS:50"),
array("dnepropetrovsk.ua","whois.dp.ua","MAXCHARS:50"),
array("ecn.br","whois.nic.br","No match"),
array("ee","whois.eenet.ee","NOT FOUND"),
array("edu","whois.verisign-grs.net","No match"),
array("edu.au","whois.aunic.net","No Data Found"),
array("edu.br","whois.nic.br","No match"),
array("edu.ua","whois.com.ua","No entries found"),
array("eg","whois.ripe.net","No entries found"),
array("es","whois.ripe.net","No entries found"),
array("esp.br","whois.nic.br","No match"),
array("etc.br","whois.nic.br","No match"),
array("eti.br","whois.nic.br","No match"),
array("eu","whois.eu","Status: AVAILABLE"),
array("eu.com","whois.centralnic.com","No match for"),
array("eun.eg","whois.ripe.net","No entries found"),
array("emu.id.au","whois.aunic.net","No Data Found"),
array("eng.br","whois.nic.br","No match"),
array("far.br","whois.nic.br","No match"),
array("fi","whois.ficora.fi","Domain not found"),
array("firm.in","whois.inregistry.net","NOT FOUND"),
array("fj","whois.usp.ac.fj",""),
array("fj.cn","whois.cnnic.net.cn","No entries found"),
array("fm.br","whois.nic.br","No match"),
array("fnd.br","whois.nic.br","No match"),
array("fo","whois.ripe.net","no entries found"),
array("fot.br","whois.nic.br","No match"),
array("fst.br","whois.nic.br","No match"),
array("fr","whois.nic.fr","No entries found"),
array("g12.br","whois.nic.br","No match"),
array("gb.com","whois.centralnic.com","No match for"),
array("gb.net","whois.centralnic.com","No match for"),
array("gd.cn","whois.cnnic.net.cn","No entries found"),
array("ge","whois.ripe.net","no entries found"),
array("gen.in","whois.inregistry.net","NOT FOUND"),
array("ggf.br","whois.nic.br","No match"),
array("gl","whois.ripe.net","no entries found"),
array("gr","whois.ripe.net","no entries found"),
array("gr.jp","whois.nic.ad.jp","No match"),
array("gs","whois.adamsnames.tc","is not registered"),
array("gs.cn","whois.cnnic.net.cn","No entries found"),
array("gov.au","whois.aunic.net","No Data Found"),
array("gov.br","whois.nic.br","No match"),
array("gov.cn","whois.cnnic.net.cn","No entries found"),
array("gov.hk","whois.hknic.net.hk","No Match for"),
array("gob.mx","whois.nic.mx","Nombre del Dominio"),
array("gov.ua","whois.com.ua","No entries found"),
array("gs","whois.adamsnames.tc","is not registered"),
array("gz.cn","whois.cnnic.net.cn","No entries found"),
array("gx.cn","whois.cnnic.net.cn","No entries found"),
array("he.cn","whois.cnnic.net.cn","No entries found"),
array("ha.cn","whois.cnnic.net.cn","No entries found"),
array("hb.cn","whois.cnnic.net.cn","No entries found"),
array("hi.cn","whois.cnnic.net.cn","No entries found"),
array("histoire.museum","whois.museum","NOT FOUND"),
array("history.museum","whois.museum","NOT FOUND"),
array("hl.cn","whois.cnnic.net.cn","No entries found"),
array("hn.cn","whois.cnnic.net.cn","No entries found"),
array("hm","whois.registry.hm","(null)"),
array("hk","whois.hknic.net.hk","No Match for"),
array("hk.cn","whois.cnnic.net.cn","No entries found"),
array("hu","whois.ripe.net","MAXCHARS:500"),
array("hu.com","whois.centralnic.com","No match for"),
array("id.au","whois.aunic.net","No Data Found"),
array("ie","whois.domainregistry.ie","no match"),
array("in","whois.inregistry.net","NOT FOUND"),
array("in.ua","whois.in.ua","No records found"),
array("ind.br","whois.nic.br","No match"),
array("imb.br","whois.nic.br","No match"),
array("inf.br","whois.nic.br","No match"),
array("info","whois.afilias.info","Not found"),
array("info.au","whois.aunic.net","No Data Found"),
array("international.museum","whois.museum","NOT FOUND"),
array("it","whois.nic.it","No entries found"),
array("idv.tw","whois.twnic.net","NO MATCH TIP"),
array("ind.in","whois.inregistry.net","NOT FOUND"),
array("int","whois.iana.org","not found"),
array("is","whois.isnic.is","No entries found"),
array("il","whois.isoc.org.il","No data was found"),
array("jl.cn","whois.cnnic.net.cn","No entries found"),
array("jor.br","whois.nic.br","No match"),
array("jp","whois.nic.ad.jp","No match"),
array("jpn.com","whois.centralnic.com","No match for"),
array("js.cn","whois.cnnic.net.cn","No entries found"),
array("jx.cn","whois.cnnic.net.cn","No entries found"),
array("kiev.ua","whois.com.ua","No entries found"),
array("kh.ua","whois.kh.ua","No match record found"),
array("kharkov.ua","whois.kh.ua","No match record found"),
array("kr","whois.krnic.net","is not registered"),
array("kr.com","whois.centralnic.com","No match for"),
array("kr.ua","whois.kr.ua","No such domain"),
array("kirovograd.ua","whois.kr.ua","No such domain"),
array("la","whois.nic.la","NO MATCH"),
array("lel.br","whois.nic.br","No match"),
array("lg.ua","whois.lg.ua","No match record found"),
array("lugansk.ua","whois.lg.ua","No match record found"),
array("li","whois.nic.ch","We do not have an entry"),
array("lk","whois.nic.lk","No domain registered"),
array("ln.cn","whois.cnnic.net.cn","No entries found"),
array("lt","ns.litnet.lt","No matches found"),
array("lu","whois.dns.lu","No entries found"),
array("lv","whois.ripe.net","no entries found"),
array("lviv.ua","whois.lviv.ua","no entries found"),
array("ltd.uk","whois.nic.uk","No match for"),
array("mat.br","whois.nic.br","No match"),
array("mc","whois.ripe.net","No entries found"),
array("me","whois.nic.me","NOT FOUND"),
array("me.uk","whois.nic.uk","No match for"),
array("med.br","whois.nic.br","No match"),
array("mil","whois.nic.mil","No match"),
array("mil.br","whois.nic.br","No match"),
array("mn","whois.nic.mn","Domain not found"),
array("mobi","whois.dotmobiregistry.net","NOT FOUND"),
array("mo.cn","whois.cnnic.net.cn","No entries found"),
array("ms","whois.adamsnames.tc","is not registered"),
array("mus.br","whois.nic.br","No match"),
array("museum","whois.museum","NOT FOUND"),
array("mx","whois.nic.mx","Nombre del Dominio"),
array("name","whois.nic.name","No match"),
array("national.museum","whois.museum","NOT FOUND"),
array("naturalhistory.museum","whois.museum","NOT FOUND"),
array("ne.jp","whois.nic.ad.jp","No match"),
array("net","whois.verisign-grs.net","No match"),
array("net.au","whois.aunic.net","No Data Found"),
array("net.br","whois.nic.br","No match"),
array("net.cn","whois.cnnic.net.cn","No entries found"),
array("net.eg","whois.ripe.net","No entries found"),
array("net.hk","whois.hknic.net.hk","No Match for"),
array("net.in","whois.inregistry.net","NOT FOUND"),
array("net.lu","whois.dns.lu","No entries found"),
array("net.mx","whois.nic.mx","Nombre del Dominio"),
array("net.uk","whois.nic.uk","No match for "),
array("net.ru","whois.ripn.net","No entries found"),
array("net.tw","whois.twnic.net","NO MATCH TIP"),
array("net.ua","whois.com.ua","No entries found"),
array("nl","whois.domain-registry.nl","is not a registered domain"),
array("nm.cn","whois.cnnic.net.cn","No entries found"),
array("no","whois.norid.no","no matches"),
array("no.com","whois.centralnic.com","No match for"),
array("nom.br","whois.nic.br","No match"),
array("not.br","whois.nic.br","No match"),
array("ntr.br","whois.nic.br","No match"),
array("nx.cn","whois.cnnic.net.cn","No entries found"),
array("nz","whois.domainz.net.nz","Not Listed"),
array("nu","whois.nic.nu","NO MATCH"),
array("od.ua","whois.od.ua","We have no whois information"),
array("odessa.ua","whois.od.ua","We have no whois information"),
array("odo.br","whois.nic.br","No match"),
array("oop.br","whois.nic.br","No match"),
array("or.jp","whois.nic.ad.jp","No match"),
array("org","whois.publicinterestregistry.net","NOT FOUND"),
array("org.au","whois.aunic.net","No Data Found"),
array("org.br","whois.nic.br","No match"),
array("org.cn","whois.cnnic.net.cn","No entries found"),
array("org.hk","whois.hknic.net.hk","No Match for"),
array("org.in","whois.inregistry.net","NOT FOUND"),
array("org.lu","whois.dns.lu","No entries found"),
array("org.ru","whois.ripn.net","No entries found"),
array("org.tw","whois.twnic.net","NO MATCH TIP"),
array("org.ua","whois.net.ua","No entries found"),
array("org.uk","whois.nic.uk","No match for"),
array("pl","nazgul.nask.waw.pl","does not exists"),
array("pl.ua","whois.net.ua","No entries found"),
array("poltava.ua","whois.net.ua","No entries found"),
array("plc.uk","whois.nic.uk","No match for"),
array("pp.ru","whois.ripn.net","No entries found"),
array("pp.ua","whois.pp.ua","No entries found"),
array("ppg.br","whois.nic.br","No match"),
array("pro.br","whois.nic.br","No match"),
array("psi.br","whois.nic.br","No match"),
array("psc.br","whois.nic.br","No match"),
array("pt","whois.ripe.net","No entries found"),
array("qc.com","whois.centralnic.com","No match for"),
array("qh.cn","whois.cnnic.net.cn","No entries found"),
array("qsl.br","whois.nic.br","No match"),
array("rec.br","whois.nic.br","No match"),
array("ro","whois.rotld.ro","No entries found"),
array("ru","whois.ripn.net","No entries found"),
array("ru.com","whois.centralnic.com","No match for"),
array("sa.com","whois.centralnic.com","No match for"),
array("sc.cn","whois.cnnic.net.cn","No entries found"),
array("science.museum","whois.museum","NOT FOUND"),
array("sd.cn","whois.cnnic.net.cn","No entries found"),
array("se","whois.nic-se.se","No data found"),
array("se.com","whois.centralnic.com","No match for"),
array("se.net","whois.centralnic.com","No match for"),
array("sebastopol.ua","whois.crimea.ua","domain not in database"),
array("sg","whois.nic.net.sg","NO entry found"),
array("sh","whois.nic.sh","No match for"),
array("sh.cn","whois.cnnic.net.cn","No entries found"),
array("si","whois.arnes.si","No entries found"),
array("sk","whois.ripe.net","no entries found"),
array("slg.br","whois.nic.br","No match"),
array("sm","whois.ripe.net","no entries found"),
array("sn.cn","whois.cnnic.net.cn","No entries found"),
array("srv.br","whois.nic.br","No match"),
array("st","whois.nic.st","No entries found"),
array("su","whois.ripn.net","No entries found"),
array("sx.cn","whois.cnnic.net.cn","No entries found"),
array("tc","whois.adamsnames.tc","is not registered"),
array("tel","whois.nic.tel","Not found"),
array("th","whois.nic.uk","No entries found"),
array("tj.cn","whois.cnnic.net.cn","No entries found"),
array("tmp.br","whois.nic.br","No match"),
array("to","whois.tonic.to","No match"),
array("tr","whois.ripe.net","Not found in database"),
array("travel","whois.nic.travel","Not found"),
array("trd.br","whois.nic.br","No match"),
array("tur.br","whois.nic.br","No match"),
array("tv","tvwhois.verisign-grs.com","No match for"),
array("tv.br","whois.nic.br","No match"),
array("tw","whois.twnic.net","NO MATCH TIP"),
array("tw.cn","whois.cnnic.net.cn","No entries found"),
array("ua","whois.net.ua","No entries found"),
array("uk","whois.thnic.net","No match for"),
array("uk.com","whois.centralnic.com","No match for"),
array("uk.net","whois.centralnic.com","No match for"),
array("us","whois.nic.us","Not found"),
array("us.com","whois.centralnic.com","No match for"),
array("uy.com","whois.centralnic.com","No match for"),
array("va","whois.ripe.net","No entries found"),
array("vet.br","whois.nic.br","No match"),
array("vg","whois.adamsnames.tc","is not registered"),
array("wattle.id.au","whois.aunic.net","No Data Found"),
array("ws","whois.worldsite.ws","No match for"),
array("xj.cn","whois.cnnic.net.cn","No entries found"),
array("xz.cn","whois.cnnic.net.cn","No entries found"),
array("yalta.ua","whois.crimea.ua","domain not in database"),
array("yn.cn","whois.cnnic.net.cn","No entries found"),
array("za.com","whois.centralnic.com","No match for"),
array("zlg.br","whois.nic.br","No match"),
array("zj.cn","whois.cnnic.net.cn","No entries found"),
array("zp.ua","whois.zp.ua","No match record found"),
array("zaporizhzhe.ua","whois.zp.ua","No match record found"),
);
/**
* Constructor of class domain
* @param string $str_domainame the full name of the domain
* @desc Constructor of class domain
*/
public function domain($str_domainname,$without_mysql = 0){
$this->domain = $str_domainname;
$this->my_whois_server = $this->get_whois_server($without_mysql);
$this->my_notfound_string = $this->get_notfound_string($without_mysql);
}
/**
* Returns the whois data of the domain
* @return string $whoisdata Whois data as string
* @desc Returns the whois data of the domain
*/
public function info(){
if($this->is_valid()){
$tldname=$this->get_tld();
$domainname=$this->get_domain();
$whois_server=$this->my_whois_server;
// If tldname have been found
if ($whois_server != ""){
// Getting whois information
$fp = @fsockopen($whois_server,43);
if ($fp) {
$dom=$domainname.".".$tldname;
if (preg_match("/[а-яёЁ]/ui",$dom)) {
$idna = new idna_convert();
$dom = $idna->encode($dom);
}
fputs($fp, "$domrn");
// Getting string
$string="";
while(!feof($fp)){
$string.=fgets($fp,128);
}
fclose($fp);
return $string;
} else {
$this->last_error = "Can't connect to whois server!";
return -1;
}
} else{
$this->last_error = "No whois server for this tld in list!";
return -1;
}
} else {
$this->last_error = "Domainname isn't valid!";
return -1;
}
}
/**
* Returns the whois data of the domain in HTML format
* @return string $whoisdata Whois data as string in HTML
* @desc Returns the whois data of the domain in HTML format
*/
public function html_info(){
return nl2br($this->info());
}
/**
* Returns name of the whois server of the tld
* @return string $server the whois servers hostname
* @desc Returns name of the whois server of the tld
*/
public function get_whois_server($without_mysql = 0){
$tldname=$this->get_tld();
if ($without_mysql == 0) {
$zone=GetZoneByZone($tldname);
if ($zone->whois) { return $zone->whois; }
}
for($i=0;$i<count($this->servers);$i++){
if($this->servers[$i][0]==$tldname){
$server=$this->servers[$i][1];
return $server;
}
}
# return "whois-servers.net";
}
/**
* Returns the tld of the domain without domain name
* @return string $tldname the tlds name without domain name
* @desc Returns the tld of the domain without domain name
*/
public function get_tld(){
// Splitting domainname
$domain=mb_split(".",$this->domain);
if(count($domain)>2){
$domainname=$domain[0];
for($i=1;$i<count($domain);$i++){
if($i==1){
$tldname=$domain[$i];
}else{
$tldname.=".".$domain[$i];
}
}
}else{
$domainname=$domain[0];
$tldname=$domain[1];
}
return $tldname;
}
/**
* Returns all tlds which are supported by the class
* @return array $tlds all tlds as array
* @desc Returns all tlds which are supported by the class
*/
public function get_tlds(){
$tlds="";
for($i=0;$i<count($this->servers);$i++){
$tlds[$i]=$this->servers[$i][0];
}
return $tlds;
}
/**
* Returns the name of the domain without tld
* @return string $domain the domains name without tld name
* @desc Returns the name of the domain without tld
*/
public function get_domain(){
// Splitting domainname
$domain=mb_split(".",$this->domain);
return $domain[0];
}
/**
* Returns the string which will be returned by the whois server of the tld if a domain is avalable
* @return string $notfound the string which will be returned by the whois server of the tld if a domain is avalable
* @desc Returns the string which will be returned by the whois server of the tld if a domain is avalable
*/
public function get_notfound_string($without_mysql = 0){
$tldname=$this->get_tld();
if ($without_mysql == 0) {
$zone=GetZoneByZone($tldname);
if ($zone->notfoundstring) { return $zone->notfoundstring; }
}
for($i=0;$i<count($this->servers);$i++){
if($this->servers[$i][0]==$tldname){
$notfound=$this->servers[$i][2];
return $notfound;
}
}
}
/**
* Returns if the domain is available for registering
* @return boolean $is_available Returns 1 if domain is available and 0 if domain isn't available
* @desc Returns if the domain is available for registering
*/
public function is_available(){
if (!$this->my_whois_server) {
$this->last_error = "No whois server for this tld in list!";
return true;
}
$whois_string = $this->info(); // Gets the entire WHOIS query from registrar
$not_found_string = $this->get_notfound_string(); // Gets 3rd item from array
$whois_string = preg_replace("/s+/", " ", $whois_string); //Replace whitespace with single space
$array=split(":", $not_found_string);
if($array[0] == "MAXCHARS"){
if(strlen($whois_string) <= $array[1]) {
return true;
}
else {
return false;
}
}
else {
if(preg_match("/".$not_found_string."/i",$whois_string) or $whois_string == -1 or $whois_string == ""){
return true;
}
else {
return false;
}
}
}
/**
* Returns if the domain name is valid
* @return boolean $is_valid Returns 1 if domain is valid and 0 if domain isn't valid
* @desc Returns if the domain name is valid
*/
public function is_valid(){
if (preg_match("/^[a-zA-Zа-яА-ЯёЁ0-9-]{2,}$/u",$this->get_domain()) && !preg_match("/--/u",$this->get_domain())) {
return true;
} else {
return false;
}
}
}
?>