We Recommend

Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems Wicked Cool PHP: Real-World Scripts That Solve Difficult Problems
Wicked Cool PHP contains a wide variety of scripts to process credit cards, check the validity of email addresses, template HTML, and serve dynamic images and text.


Posted By

fris on 07/27/08


Tagged

parse tools domains


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

jonhenshaw
sumandahal
jprice


whois information for domain


Published in: PHP 


  1. function whois($domain,$server) {
  2. $port = 43;
  3. $whois = "[$server]\n\n";
  4. $socket = fsockopen($server, $port, $errno, $errstr, 30);
  5.  
  6. if(!$socket)
  7. {
  8. return "$errstr ($errno).\n";
  9. }
  10. else
  11. {
  12. /*query the server about the given domain name*/
  13. fputs($socket, "$domain
  14. ");
  15. while(!feof($socket))
  16. {
  17. /*get the server response*/
  18. $whois = $whois . fgets($socket,128);
  19. }
  20.  
  21. fclose ($socket);
  22. }
  23.  
  24. return $whois;
  25. }
  26.  
  27.  
  28. echo nl2br(whois('google.com','whois.internic.net'));
  29.  
  30. ?>

Report this snippet 

You need to login to post a comment.