A php whois domain name check function code

A php whois domain name check function code

Source: Internet
Author: User
Tags explode trim domain name server

In the previous PHP host domain name program used in a WHOIS check code, used to determine whether the queried domain name is registered, the function contains most of the domain name suffix, will be based on the suffix of different connections to different query servers, previously able to use, time relations, I do not now test those query Web site can still be used, 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);

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

08//Cutting domain name

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

$lst = count ($_domain)-1;

One $ext = $_domain[$lst];

12//Define the query server address of the connection required by different domain name suffixes

$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);

The IF (!isset ($servers [$ext])) {

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

56}

$nic _server = $servers [$ext];

$output = ';

59//Connection Domain Name server:

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

Fputs ($conn, $domain. " RN ");

The while (!feof ($conn)) {

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

64}

Fclose ($conn);

66}

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

return $output;

69}

70?>

After a function call, the result is returned directly.

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.