WHOIS directory lookup in PHP


Posted in: php | Save to del.icio.us | Twit This! 13 Sep 2008

Net_Whois lets you query a internet name directory service in a easy to use manner. WHOIS is a protocol which is widely used to determine the owner of a domain name, an IP address by querying an official name database. One possible application I can think of is to see if DNS servers are set correctly for various domains I handle regularly.

Installation

Net_Whois being a Pear package we will use the Pear installer as below. I recommend to always use the Pear installer to download packages rather than downloading it manually as the Pear installer automatically downloads any dependent packages.

pear install Net_Whois-1.0.2

Usage

The current library uses the following servers to execute the query:
whois.crsnic.net
whois.networksolutions.com
whois.nic.mil
whois.nic.gov
whois.arin.net
whois.ripe.net
whois.apnic.net
whois.ripn.net
whois.ra.net
.whois-servers.net
whois.6bone.net
whois.registro.br

A example code is shown below.

<?php
 
    require_once "Net/Whois.php";
 
    $whois = new Net_Whois();
    /* You can add other NIC server as a second parameter. */
    $info = $whois->query('example.com');
    echo($info);
 
?>

Note that the class returns a string, so you would need to use regular expressions to get to the relevant information.




Share this post

Share on Facebook
Share on Twitter
Share on StumbleUpon
Share on Delicious
Share on Digg
Share on Technorati
Share on Reddit
Feeds RSS Subscribe to site Feed

Other related posts



3 Responses

1

Ricky

March 12th, 2009 at 11:31 pm

This is not works for me…..

sameer

March 13th, 2009 at 2:29 am

Whats the problem?

3

For Technical Information

April 22nd, 2009 at 7:12 am

I cant download the package net

Comment Form

Use the html <code> tag to insert small source code snippets

For longer code examples use http://pastie.org/.

Get latest updates by E-mail

About this blog

This site is a digital habitat of Sameer, a freelance web developer working from Pune.More

Recent Comments

  • sameer: Check to see if the 'IDE > options > format' is set to HTML. [...]
  • sameer: Google strips any newline characters form the text. Although it does accept it with the online trans [...]
  • Arjan: Fiddler is a debugging tool for IE (not Microsoft's Fiddler) [...]
  • Susan Martin: while creating a test for site, command icons on IDE greyed out and do not respond when selected. I [...]
  • Saar: Thanks for this example. helped me a lot. I have 1 problem, I am translating chunks of code, but I [...]
  • sameer: You can add extra GET variables in the options array as below: $pager_options = array( 'mode [...]
  • Martin: How can you carry over your own variables into the URL? I am using a form to POST a couple of var [...]
  • nancy: thanks very much ! first tools [...]

  • Users Online

    • 8 Users Online
    • 6 Guests, 2 Bots