Zend - The PHP Company




Miscellaneous

Add Code


A Better WhoIs  

Type: code fragment
Added by: quonsar
Entered: 02/03/2000
Last modified: 08/12/1999
Rating: *** (3 votes)
Views: 9872
Works with the new registry system. Fetches whois server for the domain then queries that server for the registration data.


<?php

// always scour user input
$domain=escapeshellcmd($url);

// path to whois
$cmd="/usr/local/php/bin/whois $domain";

exec($cmd,$data);
$max=count($data);
$count=0;
if(
$max):
    while(
$count <= $max):
        echo 
"$data[$count]<br>";
        
// check each line returned for the whois server for the domain        
        
if(ereg("Whois Server: "$data[$count])):
                
$whoserver=ereg_replace("Whois Server: """$data[$count]);
        endif;
        
$count++;
    endwhile;
endif;
if(isset(
$whoserver)):
    
$cmd="/usr/local/php/bin/whois -h$whoserver $domain";
    unset(
$data);
    
exec($cmd,$data);
    
$max=count($data);
    
$count=0;
    if(
$max):
        while(
$count <= $max):
            echo 
"$data[$count]<br>";
            
$count++;
        endwhile;
    endif;
endif;
?>


Usage Example




Rate This Script





Search



This Category All Categories