За последние 24 часа нас посетили 19030 программистов и 1631 робот. Сейчас ищет 901 программист ...

whois Непонимаю.

Тема в разделе "PHP для новичков", создана пользователем 2m0rr0w2, 29 май 2008.

  1. 2m0rr0w2

    2m0rr0w2 Активный пользователь

    С нами с:
    5 апр 2008
    Сообщения:
    14
    Симпатии:
    0
    Код (Text):
    1. <?
    2. /**
    3. * This class checks the availability of a domain and gets the whois data
    4. *
    5. * @author    Sven Wagener <sven.wagener@intertribe.de>
    6. * @copyright Intertribe Limited
    7. * @include   Funktion:_include_
    8. */
    9. class domain{
    10.     var $domain="";
    11.    
    12.     /*******************************
    13.     * Initializing server variables
    14.     * array(top level domain,whois_Server,not_found_string or MAX number of CHARS: MAXCHARS:n)
    15.     **/
    16.     var $servers=array(
    17.     array("ac","whois.nic.ac","No match"),
    18.     array("ac.cn","whois.cnnic.net.cn","No entries found"),
    19.     array("ac.jp","whois.nic.ad.jp","No match"),
    20.     array("ac.uk","whois.ja.net","no entries"),
    21.     array("ad.jp","whois.nic.ad.jp","No match"),
    22.     array("adm.br","whois.nic.br","No match"),
    23.     array("adv.br","whois.nic.br","No match"),
    24.     array("aero","whois.information.aero","is available"),
    25.     array("ag","whois.nic.ag","does not exist"),
    26.     array("agr.br","whois.nic.br","No match"),
    27.     array("ah.cn","whois.cnnic.net.cn","No entries found"),
    28.     array("al","whois.ripe.net","No entries found"),
    29.     array("am.br","whois.nic.br","No match"),
    30.     array("arq.br","whois.nic.br","No match"),
    31.     array("at","whois.nic.at","nothing found"),
    32.     array("au","whois.aunic.net","No Data Found"),
    33.     array("art.br","whois.nic.br","No match"),
    34.     array("as","whois.nic.as","Domain Not Found"),
    35.     array("asn.au","whois.aunic.net","No Data Found"),
    36.     array("ato.br","whois.nic.br","No match"),
    37.     array("be","whois.geektools.com","No such domain"),
    38.     array("bg","whois.digsys.bg","does not exist"),
    39.     array("bio.br","whois.nic.br","No match"),
    40.     array("biz","whois.biz","Not found"),
    41.     array("bj.cn","whois.cnnic.net.cn","No entries found"),
    42.     array("bmd.br","whois.nic.br","No match"),
    43.     array("br","whois.registro.br","No match"),
    44.     array("ca","whois.cira.ca","Status: AVAIL"),
    45.     array("cc","whois.nic.cc","No match"),
    46.     array("cd","whois.cd","No match"),
    47.     array("ch","whois.nic.ch","We do not have an entry"),
    48.     array("cim.br","whois.nic.br","No match"),
    49.     array("ck","whois.ck-nic.org.ck","No entries found"),
    50.     array("cl","whois.nic.cl","no existe"),
    51.     array("cn","whois.cnnic.net.cn","No entries found"),
    52.     array("cng.br","whois.nic.br","No match"),
    53.     array("cnt.br","whois.nic.br","No match"),
    54.     array("com","whois.verisign-grs.net","No match"),
    55.     array("com.au","whois.aunic.net","No Data Found"),
    56.     array("com.br","whois.nic.br","No match"),
    57.     array("com.cn","whois.cnnic.net.cn","No entries found"),
    58.     array("com.eg","whois.ripe.net","No entries found"),
    59.     array("com.hk","whois.hknic.net.hk","No Match for"),
    60.     array("com.mx","whois.nic.mx","Nombre del Dominio"),
    61.     array("com.ru","whois.ripn.ru","No entries found"),
    62.     array("com.tw","whois.twnic.net","NO MATCH TIP"),
    63.     array("conf.au","whois.aunic.net","No entries found"),
    64.     array("co.jp","whois.nic.ad.jp","No match"),
    65.     array("co.uk","whois.nic.uk","No match for"),
    66.     array("cq.cn","whois.cnnic.net.cn","No entries found"),
    67.     array("csiro.au","whois.aunic.net","No Data Found"),
    68.     array("cx","whois.nic.cx","No match"),
    69.     array("cz","whois.nic.cz","No data found"),
    70.     array("de","whois.denic.de","No entries found"),
    71.     array("dk","whois.dk-hostmaster.dk","No entries found"),
    72.     array("ecn.br","whois.nic.br","No match"),
    73.     array("ee","whois.eenet.ee","NOT FOUND"),
    74.     array("edu","whois.verisign-grs.net","No match"),
    75.     array("edu.au","whois.aunic.net","No Data Found"),
    76.     array("edu.br","whois.nic.br","No match"),
    77.     array("eg","whois.ripe.net","No entries found"),
    78.     array("es","whois.ripe.net","No entries found"),
    79.     array("esp.br","whois.nic.br","No match"),
    80.     array("etc.br","whois.nic.br","No match"),
    81.     array("eti.br","whois.nic.br","No match"),
    82.     array("eun.eg","whois.ripe.net","No entries found"),
    83.     array("emu.id.au","whois.aunic.net","No Data Found"),
    84.     array("eng.br","whois.nic.br","No match"),
    85.     array("far.br","whois.nic.br","No match"),
    86.     array("fi","whois.ripe.net","No entries found"),
    87.     array("fj","whois.usp.ac.fj",""),
    88.     array("fj.cn","whois.cnnic.net.cn","No entries found"),
    89.     array("fm.br","whois.nic.br","No match"),
    90.     array("fnd.br","whois.nic.br","No match"),
    91.     array("fo","whois.ripe.net","no entries found"),
    92.     array("fot.br","whois.nic.br","No match"),
    93.     array("fst.br","whois.nic.br","No match"),
    94.     array("fr","whois.nic.fr","No entries found"),
    95.     array("g12.br","whois.nic.br","No match"),
    96.     array("gd.cn","whois.cnnic.net.cn","No entries found"),
    97.     array("ge","whois.ripe.net","no entries found"),
    98.     array("ggf.br","whois.nic.br","No match"),
    99.     array("gl","whois.ripe.net","no entries found"),
    100.     array("gr","whois.ripe.net","no entries found"),
    101.     array("gr.jp","whois.nic.ad.jp","No match"),
    102.     array("gs","whois.adamsnames.tc","is not registered"),
    103.     array("gs.cn","whois.cnnic.net.cn","No entries found"),
    104.     array("gov.au","whois.aunic.net","No Data Found"),
    105.     array("gov.br","whois.nic.br","No match"),
    106.     array("gov.cn","whois.cnnic.net.cn","No entries found"),
    107.     array("gov.hk","whois.hknic.net.hk","No Match for"),
    108.     array("gob.mx","whois.nic.mx","Nombre del Dominio"),
    109.     array("gs","whois.adamsnames.tc","is not registered"),
    110.     array("gz.cn","whois.cnnic.net.cn","No entries found"),
    111.     array("gx.cn","whois.cnnic.net.cn","No entries found"),
    112.     array("he.cn","whois.cnnic.net.cn","No entries found"),
    113.     array("ha.cn","whois.cnnic.net.cn","No entries found"),
    114.     array("hb.cn","whois.cnnic.net.cn","No entries found"),
    115.     array("hi.cn","whois.cnnic.net.cn","No entries found"),
    116.     array("hl.cn","whois.cnnic.net.cn","No entries found"),
    117.     array("hn.cn","whois.cnnic.net.cn","No entries found"),
    118.     array("hm","whois.registry.hm","(null)"),
    119.     array("hk","whois.hknic.net.hk","No Match for"),
    120.     array("hk.cn","whois.cnnic.net.cn","No entries found"),
    121.     array("hu","whois.ripe.net","MAXCHARS:500"),
    122.     array("id.au","whois.aunic.net","No Data Found"),
    123.     array("ie","whois.domainregistry.ie","no match"),
    124.     array("ind.br","whois.nic.br","No match"),
    125.     array("imb.br","whois.nic.br","No match"),
    126.     array("inf.br","whois.nic.br","No match"),
    127.     array("info","whois.afilias.info","Not found"),
    128.     array("info.au","whois.aunic.net","No Data Found"),
    129.     array("it","whois.nic.it","No entries found"),
    130.     array("idv.tw","whois.twnic.net","NO MATCH TIP"),
    131.     array("int","whois.iana.org","not found"),
    132.     array("is","whois.isnic.is","No entries found"),
    133.     array("il","whois.isoc.org.il","No data was found"),
    134.     array("jl.cn","whois.cnnic.net.cn","No entries found"),
    135.     array("jor.br","whois.nic.br","No match"),
    136.     array("jp","whois.nic.ad.jp","No match"),
    137.     array("js.cn","whois.cnnic.net.cn","No entries found"),
    138.     array("jx.cn","whois.cnnic.net.cn","No entries found"),
    139.     array("kr","whois.krnic.net","is not registered"),
    140.     array("la","whois.nic.la","NO MATCH"),
    141.     array("lel.br","whois.nic.br","No match"),
    142.     array("li","whois.nic.ch","We do not have an entry"),
    143.     array("lk","whois.nic.lk","No domain registered"),
    144.     array("ln.cn","whois.cnnic.net.cn","No entries found"),
    145.     array("lt","ns.litnet.lt","No matches found"),
    146.     array("lu","whois.dns.lu","No entries found"),
    147.     array("lv","whois.ripe.net","no entries found"),
    148.     array("ltd.uk","whois.nic.uk","No match for"),
    149.     array("mat.br","whois.nic.br","No match"),
    150.     array("mc","whois.ripe.net","No entries found"),
    151.     array("med.br","whois.nic.br","No match"),
    152.     array("mil","whois.nic.mil","No match"),
    153.     array("mil.br","whois.nic.br","No match"),
    154.     array("mn","whois.nic.mn","Domain not found"),
    155.     array("mo.cn","whois.cnnic.net.cn","No entries found"),
    156.     array("ms","whois.adamsnames.tc","is not registered"),
    157.     array("mus.br","whois.nic.br","No match"),
    158.     array("mx","whois.nic.mx","Nombre del Dominio"),
    159.     array("name","whois.nic.name","No match"),
    160.     array("ne.jp","whois.nic.ad.jp","No match"),
    161.     array("net","whois.verisign-grs.net","No match"),
    162.     array("net.au","whois.aunic.net","No Data Found"),
    163.     array("net.br","whois.nic.br","No match"),
    164.     array("net.cn","whois.cnnic.net.cn","No entries found"),
    165.     array("net.eg","whois.ripe.net","No entries found"),
    166.     array("net.hk","whois.hknic.net.hk","No Match for"),
    167.     array("net.lu","whois.dns.lu","No entries found"),
    168.     array("net.mx","whois.nic.mx","Nombre del Dominio"),
    169.     array("net.uk","whois.nic.uk","No match for "),
    170.     array("net.ru","whois.ripn.ru","No entries found"),
    171.     array("net.tw","whois.twnic.net","NO MATCH TIP"),
    172.     array("nl","whois.domain-registry.nl","is not a registered domain"),
    173.     array("nm.cn","whois.cnnic.net.cn","No entries found"),
    174.     array("no","whois.norid.no","no matches"),
    175.     array("nom.br","whois.nic.br","No match"),
    176.     array("not.br","whois.nic.br","No match"),
    177.     array("ntr.br","whois.nic.br","No match"),
    178.     array("nx.cn","whois.cnnic.net.cn","No entries found"),
    179.     array("nz","whois.domainz.net.nz","Not Listed"),
    180.     array("plc.uk","whois.nic.uk","No match for"),
    181.     array("odo.br","whois.nic.br","No match"),
    182.     array("oop.br","whois.nic.br","No match"),
    183.     array("or.jp","whois.nic.ad.jp","No match"),
    184.     array("org","whois.verisign-grs.net","No match"),
    185.     array("org.au","whois.aunic.net","No Data Found"),
    186.     array("org.br","whois.nic.br","No match"),
    187.     array("org.cn","whois.cnnic.net.cn","No entries found"),
    188.     array("org.hk","whois.hknic.net.hk","No Match for"),
    189.     array("org.lu","whois.dns.lu","No entries found"),
    190.     array("org.ru","whois.ripn.ru","No entries found"),
    191.     array("org.tw","whois.twnic.net","NO MATCH TIP"),
    192.     array("org.uk","whois.nic.uk","No match for"),
    193.     array("pl","nazgul.nask.waw.pl","does not exists"),
    194.     array("pp.ru","whois.ripn.ru","No entries found"),
    195.     array("ppg.br","whois.nic.br","No match"),
    196.     array("pro.br","whois.nic.br","No match"),
    197.     array("psi.br","whois.nic.br","No match"),
    198.     array("psc.br","whois.nic.br","No match"),
    199.     array("pt","whois.ripe.net","No entries found"),
    200.     array("qh.cn","whois.cnnic.net.cn","No entries found"),
    201.     array("qsl.br","whois.nic.br","No match"),
    202.     array("rec.br","whois.nic.br","No match"),
    203.     array("ro","whois.rotld.ro","No entries found"),
    204.     array("ru","whois.ripn.ru","No entries found"),
    205.     array("sc.cn","whois.cnnic.net.cn","No entries found"),
    206.     array("sd.cn","whois.cnnic.net.cn","No entries found"),
    207.     array("se","whois.nic-se.se","No data found"),
    208.     array("sg","whois.nic.net.sg","NO entry found"),
    209.     array("sh","whois.nic.sh","No match for"),
    210.     array("sh.cn","whois.cnnic.net.cn","No entries found"),
    211.     array("si","whois.arnes.si","No entries found"),
    212.     array("sk","whois.ripe.net","no entries found"),
    213.     array("slg.br","whois.nic.br","No match"),
    214.     array("sm","whois.ripe.net","no entries found"),
    215.     array("sn.cn","whois.cnnic.net.cn","No entries found"),
    216.     array("srv.br","whois.nic.br","No match"),
    217.     array("st","whois.nic.st","No entries found"),
    218.     array("sx.cn","whois.cnnic.net.cn","No entries found"),
    219.     array("tc","whois.adamsnames.tc","is not registered"),
    220.     array("th","whois.nic.uk","No entries found"),
    221.     array("tj.cn","whois.cnnic.net.cn","No entries found"),
    222.     array("tmp.br","whois.nic.br","No match"),
    223.     array("to","whois.tonic.to","No match"),
    224.     array("tr","whois.ripe.net","Not found in database"),
    225.     array("trd.br","whois.nic.br","No match"),
    226.     array("tur.br","whois.nic.br","No match"),
    227.     array("tv","whois.tv","MAXCHARS:75"),
    228.     array("tv.br","whois.nic.br","No match"),
    229.     array("tw","whois.twnic.net","NO MATCH TIP"),
    230.     array("tw.cn","whois.cnnic.net.cn","No entries found"),
    231.     array("uk","whois.thnic.net","No match for"),
    232.     array("va","whois.ripe.net","No entries found"),
    233.     array("vet.br","whois.nic.br","No match"),
    234.     array("vg","whois.adamsnames.tc","is not registered"),
    235.     array("wattle.id.au","whois.aunic.net","No Data Found"),
    236.     array("ws","whois.worldsite.ws","No match for"),
    237.     array("xj.cn","whois.cnnic.net.cn","No entries found"),
    238.     array("xz.cn","whois.cnnic.net.cn","No entries found"),
    239.     array("yn.cn","whois.cnnic.net.cn","No entries found"),
    240.     array("zlg.br","whois.nic.br","No match"),
    241.     array("zj.cn","whois.cnnic.net.cn","No entries found")
    242.     );
    243.    
    244.     /**
    245.     * Constructor of class domain
    246.     * @param string $str_domainame    the full name of the domain
    247.     * @desc Constructor of class domain
    248.     */
    249.     function domain($str_domainname){
    250.         $this->domain=$str_domainname;
    251.     }
    252.    
    253.     /**
    254.     * Returns the whois data of the domain
    255.     * @return string $whoisdata Whois data as string
    256.     * @desc Returns the whois data of the domain
    257.     */
    258.     function info(){
    259.         if($this->is_valid()){
    260.            
    261.             $tldname=$this->get_tld();
    262.             $domainname=$this->get_domain();
    263.             $whois_server=$this->get_whois_server();
    264.            
    265.             // If tldname have been found
    266.             if($whois_server!=""){
    267.                 // Getting whois information
    268.                 $fp = fsockopen($whois_server,43);
    269.                
    270.                 $dom=$domainname.".".$tldname;
    271.                 fputs($fp, "$dom\r\n");
    272.                
    273.                 // Getting string
    274.                 $string="";
    275.                 while(!feof($fp)){
    276.                     $string.=fgets($fp,128);
    277.                 }
    278.                 fclose($fp);
    279.                 return $string;
    280.             }else{
    281.                 return "No whois server for this tld in list!";
    282.             }
    283.         }else{
    284.             return "Domainname isn't valid!";
    285.         }
    286.     }
    287.    
    288.     /**
    289.     * Returns the whois data of the domain in HTML format
    290.     * @return string $whoisdata Whois data as string in HTML
    291.     * @desc Returns the whois data of the domain  in HTML format
    292.     */
    293.     function html_info(){
    294.         return nl2br($this->info());
    295.     }
    296.    
    297.     /**
    298.     * Returns name of the whois server of the tld
    299.     * @return string $server the whois servers hostname
    300.     * @desc Returns name of the whois server of the tld
    301.     */
    302.     function get_whois_server(){
    303.         $found=false;
    304.         $tldname=$this->get_tld();
    305.         for($i=0;$i<count($this->servers);$i++){
    306.             if($this->servers[$i][0]==$tldname){
    307.                 $server=$this->servers[$i][1];
    308.                 $full_dom=$this->servers[$i][3];
    309.                 $found=true;
    310.             }
    311.         }
    312.         return $server;
    313.     }
    314.    
    315.     /**
    316.     * Returns the tld of the domain without domain name
    317.     * @return string $tldname the tlds name without domain name
    318.     * @desc Returns the tld of the domain without domain name
    319.     */
    320.     function get_tld(){
    321.         // Splitting domainname
    322.         $domain=split("\.",$this->domain);
    323.         if(count($domain)>2){
    324.             $domainname=$domain[0];
    325.             for($i=1;$i<count($domain);$i++){
    326.                 if($i==1){
    327.                     $tldname=$domain[$i];
    328.                 }else{
    329.                     $tldname.=".".$domain[$i];
    330.                 }
    331.             }
    332.         }else{
    333.             $domainname=$domain[0];
    334.             $tldname=$domain[1];
    335.         }
    336.         return $tldname;
    337.     }
    338.    
    339.     /**
    340.     * Returns all tlds which are supported by the class
    341.     * @return array $tlds all tlds as array
    342.     * @desc Returns all tlds which are supported by the class
    343.     */
    344.     function get_tlds(){
    345.         $tlds="";
    346.         for($i=0;$i<count($this->servers);$i++){
    347.             $tlds[$i]=$this->servers[$i][0];
    348.         }
    349.         return $tlds;
    350.     }
    351.    
    352.     /**
    353.     * Returns the name of the domain without tld
    354.     * @return string $domain the domains name without tld name
    355.     * @desc Returns the name of the domain without tld
    356.     */
    357.     function get_domain(){
    358.         // Splitting domainname
    359.         $domain=split("\.",$this->domain);
    360.         return $domain[0];
    361.     }
    362.    
    363.     /**
    364.     * Returns the string which will be returned by the whois server of the tld if a domain is avalable
    365.     * @return string $notfound  the string which will be returned by the whois server of the tld if a domain is avalable
    366.     * @desc Returns the string which will be returned by the whois server of the tld if a domain is avalable
    367.     */
    368.     function get_notfound_string(){
    369.         $found=false;
    370.         $tldname=$this->get_tld();
    371.         for($i=0;$i<count($this->servers);$i++){
    372.             if($this->servers[$i][0]==$tldname){
    373.                 $notfound=$this->servers[$i][2];
    374.             }
    375.         }
    376.         return $notfound;
    377.     }
    378.    
    379.     /**
    380.     * Returns if the domain is available for registering
    381.     * @return boolean $is_available Returns 1 if domain is available and 0 if domain isn't available
    382.     * @desc Returns if the domain is available for registering
    383.     */
    384.     function is_available(){
    385.         $whois_string=$this->info(); // Gets the entire WHOIS query from registrar
    386.         $not_found_string=$this->get_notfound_string(); // Gets 3rd item from array
    387.         $domain=$this->domain; // Gets current domain being queried
    388.        
    389.         $whois_string2=ereg_replace("$domain","",$whois_string);
    390.        
    391.         $whois_string = preg_replace("/\s+/"," ",$whois_string); //Replace whitespace with single space
    392.        
    393.         $array=split(":",$not_found_string);
    394.        
    395.         if($array[0]=="MAXCHARS"){
    396.             if(strlen($whois_string2)<=$array[1]){
    397.                 return true;
    398.             }else{
    399.                 return false;
    400.             }
    401.         }else{
    402.             if(preg_match("/".$not_found_string."/i",$whois_string)){
    403.                 return true;
    404.             }else{
    405.                 return false;
    406.             }
    407.         }
    408.     }
    409.    
    410.    
    411.     /**
    412.     * Returns if the domain name is valid
    413.     * @return boolean $is_valid Returns 1 if domain is valid and 0 if domain isn't valid
    414.     * @desc Returns if the domain name is valid
    415.     */
    416.     function is_valid(){
    417.         if(ereg("^[a-zA-Z0-9\-]{3,}$",$this->get_domain()) && !preg_match("/--/",$this->get_domain())){
    418.             return true;
    419.         }else{
    420.             return false;
    421.         }
    422.     }
    423. }
    424. ?>
    Скачал данный класс для запроса whois по доменам.
    Голову сломал, не могу понять как им пользоваться,
    вызываю функцию domain ("test.com"); и ничего не происходит, помогите плз..
     
  2. Kreker

    Kreker Старожил

    С нами с:
    8 апр 2007
    Сообщения:
    5.433
    Симпатии:
    0
    Может быть так?
    PHP:
    1.  
    2. <?php
    3. $whois = new domain();
    4. $whois->domain("test.com");
    5. ?>
     
  3. nimistar

    nimistar Активный пользователь

    С нами с:
    30 май 2007
    Сообщения:
    919
    Симпатии:
    0
    PHP:
    1.  
    2. <?php
    3.  
    4.  
    5. $whois = new domain("test.com");
    6. $whois->html_info(); //просто инфа о домене в хтмль формате
    7. //и т.д. там много функци и все документированны ;-)
    8.  
    9. ?>
     
  4. 2m0rr0w2

    2m0rr0w2 Активный пользователь

    С нами с:
    5 апр 2008
    Сообщения:
    14
    Симпатии:
    0
    Спасибо!!!