The “/samswhois/samswhois.class.php” file is at the heart of Sams Whois. It provides all the low-level functions including parsing the server config file, doing the whois lookup, caching results, cleaning and hilighting the whois data.
In most cases you will not need to touch this file or use any of its functions directly as the “/samswhois/samswhois.inc.php” include file handles all this for you.
A brief outline of the main user functions of this class are listed here; for further information on how to use it, see the “/samswhois/samswhois.inc.php” file.
The code snippet below illustrates basic usage of the SamsWhois class to set which tlds to use, output a list of these tlds to the browser, lookup a domain and display the results with cleaning and hilighting:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
<?php /* include the samswhois class file. */ require_once(dirname(__FILE__).'/samswhois/samswhois.class.php'); /* create a new samswhois object */ $whois = new SamsWhois(); /* cache lookups for 1 hour */ $whois->SetCacheLifetime(60); /* Set the tlds that we want to support */ $whois->SetTlds('com,net,org,info,biz'); /* Display a list of supported tlds, separating each one by a <br /> */ echo "This script will lookup domains with the following extensions:<br />"; echo join('<br />',$whois->GetTlds()); $clean = true; $hilite = true; $domain = 'mydomain.com'; /* Lookup the domain */ if( $whois->Lookup($domain) ){ /* output the whois data, cleaned and hilighted */ echo $whois->GetData(0,$clean, $hilite); }else{ echo "An error occurred with the lookup."; } ?> |