PHP Methods for querying whois information _php tutorial

Source: Internet
Author: User
Tags php programming

How to query whois information in PHP


In this paper, we explain how to query whois information in PHP. Share to everyone for your reference. Specific as follows:

Use PHP to query the list of websites that query whois information

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21st

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

function Whois_query ($domain) {

Fix the domain name:

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

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

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

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

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

Split the TLD from domain name

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

$lst = count ($_domain)-1;

$ext = $_domain[$lst];

You find resources and lists

Like these on Wikipedia:

//

Http://de.wikipedia.org/wiki/Whois

//

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

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

);

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

Die (' error:no matching NIC server found! ');

}

$nic _server = $servers [$ext];

$output = ";

Connect to WHOIS Server:

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

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

while (!feof ($conn)) {

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

}

Fclose ($conn);

}

else {die (' error:could does connect to '. $nic _server. '!'); }

return $output;

}

Some Example Queries:

Print whois_query (' jonasjohn.de ');

Print whois_query (' example.com ');

Print whois_query (' example.org ');

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/1012986.html www.bkjia.com true http://www.bkjia.com/PHPjc/1012986.html techarticle A method of querying whois information in PHP This article describes how PHP queries whois information. Share to everyone for your reference. Here's a list of sites that use PHP to query whois information ...

  • 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.