<? /*Function whois which returns the data from the server given the domain name and server name*/ function whois($domain,$server) { $port = 43; $whois = "[$server]\n\n"; /*open socket on port 43 (default port for whois server) to query the server*/ $socket = fsockopen($server, $port, $errno, $errstr, 30); if(!$socket) { return "$errstr ($errno).\n"; } else { /*query the server about the given domain name*/ fputs($socket, "$domain\r\n"); while(!feof($socket)) { /*get the server response*/ $whois = $whois . fgets($socket,128); } fclose ($socket); } return $whois; } /* Call to function whois and print the results Example: whois('linkstraffic.net','whois.networksolutions.com') */ echo nl2br(whois('domainname','whoisservername')); ?>