Page 1 of 1
only display certain fields of a whois result
Posted: Wed May 07, 2003 10:42 pm
by volumeserver
I am trying to find a code that will only display two fields of a whois query
i want a code that will make the output something similar to the below
Registra: ABC registra
Nameservers: ns1.example.com,ns2.example.com
Expiration date: 12-30-2003
Can anyone help me out?
Posted: Thu May 08, 2003 3:11 am
by volka
what's your current code?
Posted: Thu May 08, 2003 3:20 am
by volumeserver
I dont have one
Sorry
Posted: Thu May 08, 2003 3:23 am
by volka
do you want to use a local whois-application?
Posted: Thu May 08, 2003 3:25 am
by volumeserver
I was hoping to use internic
Im sorry but i am very unfamiliar with the "whois" process
Posted: Thu May 08, 2003 5:08 am
by volka
internic offers a
web-interface to its database. Please note
For Whois information about country-code (two-letter) top-level domains, try Uwhois.com
so cannot get the whois entry for e.g.
http://www.heise.de from internic.
To get the whois entry for
http://www.php.net you can use the link
http://reports.internic.net/cgi-bin/who ... ype=domain
Code: Select all
<?php
$domain = 'php.net';
$url = 'http://reports.internic.net/cgi-bin/whois?whois_nic='.$domain.'&type=domain';
readfile($url);
?>
but you want the data for processing not only to display it
Code: Select all
<?php
$domain = 'php.net';
$url = 'http://reports.internic.net/cgi-bin/whois?whois_nic='.$domain.'&type=domain';
$result = file_get_contents($url); // php4.3+ function
?>
now you have to separate the useful data. I chose <pre>...>>> to limit the search
Code: Select all
<?php
$posStart = strpos($result, '<pre>');
$posEnd = strpos($result, '>>>', $posStart);
$result = substr($result, $posStart, $posEnd-$posStart);
?>
and then a regular expression to extract the fields
Code: Select all
<?php
$info = preg_match_all("!^\s+([^:]*):\s(.*)\n!mi", $result, $matches);
echo '<pre>';
print_r($matches);
echo '</pre>';
?>
There are probably better ways to perform this and no error checking is included.
Please do not abuse the web-interface by querrying each host that requests a document from your server.
Posted: Thu May 08, 2003 5:11 am
by volumeserver
Acctually im using it in a CPanel Theme everytime a customer logs in to CPanel there is a section that will display the expiration date of there domain