fork download
  1. <?php
  2.  
  3. $domain = "yoba.org";
  4. $site = whois_query($domain); # получаем whois-запись
  5.  
  6. preg_match("!^\s*Domain Name:\s+([\w\.]+)\b!im", $site, $matches); # извлекаем адрес whois-сервера
  7. $server = $matches[1];
  8.  
  9. preg_match("!^\s*Whois Server:\s+([\w\.]+)\b!im", $site, $matches); # извлекаем адрес whois-сервера
  10. $server = $matches[1];
  11.  
  12. preg_match("!^\s*Expiration Date:\s+([\w\-]+)\b!im", $site, $matches); # извлекаем дату истечения срока домена
  13. $expiry = $matches[1];
  14.  
  15. $exptime = strtotime($expiry); # вычисляем количество дней до окончания срока
  16. $expdays = round(($exptime - time()) / 84600);
  17. $expiry = date("d/m/Y", $exptime);
  18.  
  19. print "$domain &#160; ";
  20. print "$server &#160; ";
  21. print "$expiry &#160; ";
  22. print "days: $expdays"; /**/
  23.  
  24. function whois_query($domain) {
  25.  
  26. // fix the domain name:
  27. $domain = strtolower(trim($domain));
  28. $domain = preg_replace('/^http:\/\//i', '', $domain);
  29. $domain = preg_replace('/^www\./i', '', $domain);
  30. $domain = explode('/', $domain);
  31. $domain = trim($domain[0]);
  32.  
  33. // split the TLD from domain name
  34. $_domain = explode('.', $domain);
  35. $lst = count($_domain)-1;
  36. $ext = $_domain[$lst];
  37.  
  38. // You find resources and lists
  39. // like these on wikipedia:
  40. //
  41. // http://d...content-available-to-author-only...a.org/wiki/Whois
  42. //
  43. $servers = array(
  44. "biz" => "whois.neulevel.biz",
  45. "com" => "whois.internic.net",
  46. "us" => "whois.nic.us",
  47. "coop" => "whois.nic.coop",
  48. "info" => "whois.nic.info",
  49. "name" => "whois.nic.name",
  50. "net" => "whois.internic.net",
  51. "gov" => "whois.nic.gov",
  52. "edu" => "whois.internic.net",
  53. "mil" => "rs.internic.net",
  54. "int" => "whois.iana.org",
  55. "ac" => "whois.nic.ac",
  56. "ae" => "whois.uaenic.ae",
  57. "at" => "whois.ripe.net",
  58. "au" => "whois.aunic.net",
  59. "be" => "whois.dns.be",
  60. "bg" => "whois.ripe.net",
  61. "br" => "whois.registro.br",
  62. "bz" => "whois.belizenic.bz",
  63. "ca" => "whois.cira.ca",
  64. "cc" => "whois.nic.cc",
  65. "ch" => "whois.nic.ch",
  66. "cl" => "whois.nic.cl",
  67. "cn" => "whois.cnnic.net.cn",
  68. "cz" => "whois.nic.cz",
  69. "de" => "whois.nic.de",
  70. "fr" => "whois.nic.fr",
  71. "hu" => "whois.nic.hu",
  72. "ie" => "whois.domainregistry.ie",
  73. "il" => "whois.isoc.org.il",
  74. "in" => "whois.ncst.ernet.in",
  75. "ir" => "whois.nic.ir",
  76. "mc" => "whois.ripe.net",
  77. "to" => "whois.tonic.to",
  78. "tv" => "whois.tv",
  79. "ru" => "whois.ripn.net",
  80. "org" => "whois.pir.org",
  81. "aero" => "whois.information.aero",
  82. "nl" => "whois.domain-registry.nl"
  83. );
  84.  
  85. if (!isset($servers[$ext])){
  86. die('Error: No matching nic server found!');
  87. }
  88.  
  89. $nic_server = $servers[$ext];
  90.  
  91. $output = '';
  92.  
  93. // connect to whois server:
  94. if ($conn = fsockopen ($nic_server, 43)) {
  95. fputs($conn, $domain."\r\n");
  96. while(!feof($conn)) {
  97. $output .= fgets($conn,128);
  98. }
  99. fclose($conn);
  100. }
  101. else { die('Error: Could not connect to ' . $nic_server . '!'); }
  102.  
  103. return $output;
  104. }
  105.  
  106.  
  107.  
  108. echo "<pre>\n" . $site . "\n</pre>\n";
  109.  
  110.  
  111.  
  112. ?>
Success #stdin #stdout #stderr 0.01s 20640KB
stdin
Standard input is empty
stdout
Error: Could not connect to whois.pir.org!
stderr
PHP Warning:  fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/X2UGJu/prog.php on line 94
PHP Warning:  fsockopen(): unable to connect to whois.pir.org:43 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/X2UGJu/prog.php on line 94