Use the following function to obtain the complete details of any domain name user.
- Function whois_query ($ domain ){
-
- // Fix the domain name:
- $ Domain = strtolower (trim ($ domain ));
- $ Domain = preg_replace ('/^ http: \\// I', '', $ domain );
- $ Domain = preg_replace ('/^ www \./I', '', $ domain );
- $ Domain = explode ('/', $ domain );
- $ Domain = trim ($ domain [0]);
-
- // Split the TLD from domain name
- $ _ Domain = explode ('.', $ domain );
- $ Lst = count ($ _ domain)-1;
- $ Ext = $ _ domain [$ lst];
-
- // You find resources and lists
- // Like these on wikipedia:
- //
- // Http://de.wikipedia.org/wiki/Whois
- //
- $ Servers = array (
- "Biz" => "whois. neulevel. biz ",
- "Com" => "whois.internic.net ",
- "Us" => "whois. nic. us ",
- "Coop" => "whois. nic. coop ",
- "Info" => "whois.nic.info ",
- "Name" => "whois. nic. name ",
- "Net" => "whois.internic.net ",
- "Gov" => "whois.nic.gov ",
- "Edu" => "whois.internic.net ",
- "Mil" => "rs.internic.net ",
- "Int" => "whois.iana.org ",
- "Ac" => "whois. nic. ac ",
- "AE" => "whois. uaenic. AE ",
- "At" => "whois.ripe.net ",
- "Au" => "whois.aunic.net ",
- "Be" => "whois. dns. be ",
- "Bg" => "whois.ripe.net ",
- "Br" => "whois.registro.br ",
- "Bz" => "whois. belizenic. bz ",
- "Ca" => "whois. cira. ca ",
- "Cc" => "whois. nic. cc ",
- "Ch" => "whois. nic. ch ",
- "Cl" => "whois. nic. cl ",
- "Cn" => "whois.cnnic.net.cn ",
- "Cz" => "whois. nic. cz ",
- "De" => "whois.nic.de ",
- "Fr" => "whois. nic. fr ",
- "Hu" => "whois. nic. hu ",
- "Ie" => "whois. domainregistry. ie ",
- "Il" => "whois.isoc.org. il ",
- "In" => "whois. ncst. ernet. in ",
- "Ir" => "whois. nic. ir ",
- "Mc" => "whois.ripe.net ",
- "To" => "whois. tonic. ",
- "TV" => "whois. TV ",
- "Ru" => "whois.ripn.net ",
- "Org" => "whois.pir.org ",
- "Aero" => "whois. information. aero ",
- "Nl" => "whais. domain-registry.nl"
- );
-
- If (! Isset ($ servers [$ ext]) {
- Die ('Error: No matching nic server found! ');
- }
-
- $ Nic_server = $ servers [$ ext];
-
- $ Output = '';
-
- // Connect to whois server:
- If ($ conn = fsockopen ($ nic_server, 43 )){
- Fputs ($ conn, $ domain. "\ r \ n ");
- While (! Feof ($ conn )){
- $ Output. = fgets ($ conn, 128 );
- }
- Fclose ($ conn );
- }
- Else {die ('Error: cocould not connect to '. $ nic_server .'! ');}
-
- Return $ output;
- }
Usage:
- $ Domain = "http://www.open-open.com ";
- $ Result = whois_query ($ domain );
- Print_r ($ result );
- ?>
|