A php whois domain name check function code _php tutorial

Source: Internet
Author: User
Tags domain name server
Previously in the PHP host domain name program used by a WHOIS check code to determine whether the domain name being queried is registered, the function includes most of the domain name suffix, will be based on the suffix of the different connections to different query server, previously can use, time relationship, I am not currently testing those query URLs are still available, if not, you need to find information on your own to see what the current Web site is.

01

02function Whois_query ($domain) {

$domain = Strtolower (Trim ($domain));

$domain = preg_replace ('/^http:\/\//i ', ' ', $domain);

$domain = preg_replace ('/^www\./i ', ' ', $domain);

$domain = explode ('/', $domain);

$domain = Trim ($domain [0]);

08//Cut domain name

$_domain = Explode ('. ', $domain);

Ten $lst = count ($_domain)-1;

One $ext = $_domain[$lst];

12//Define the address of the query server to which the different domain suffixes need to connect

$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",

Notoginseng "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.to",

"TV" = "whois.tv",

"Ru" = "whois.ripn.net",

"org" = "whois.pir.org",

"Aero" = "Whois.information.aero",

"NL" = "whois.domain-registry.nl"

53);

if (!isset ($servers [$ext])) {

The Die (' Error: no matching server found! ');

56}

$nic _server = $servers [$ext];

$output = ";

59//Connect to the domain name server:

if ($conn = Fsockopen ($nic _server, 43)) {

Fputs ($conn, $domain. " \ r \ n ");

while (!feof ($conn)) {

$output. = Fgets ($conn, 128);

64}

Fclose ($conn);

66}

The else {die (' Error: Cannot connect to: '. $nic _server. '!'); }

$output of the return;

69}

70?>

After the function is called, the result is returned directly.

http://www.bkjia.com/PHPjc/765435.html www.bkjia.com true http://www.bkjia.com/PHPjc/765435.html techarticle previously in the PHP host domain name program used by a WHOIS check code to determine whether the domain name queried is registered, the function includes most of the domain name suffix, will be based on the suffix of the not ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.