Codice PHP:
/****** THIS SECTION SHOULD BE CUSTOMISED BY YOU TO REFLECT YOUR SITE ***********/
$template = "temp.html"; //this is the page where the results will be displayed
//this page must contain this ""
//where ever you want the results to be displayed
$registerlink = "signup.php"; //this is the page a user is taken to if they want to
//register the domain name from you or your affiliate
//it should be a script preferably because this script
//will pass it the $domain variable using the get method
//for example signup.php?domain=topdog-software.com
$restrict = 0; //set to 0 if you don't want to restrict access
//set to 1 if you want to restrict access remember to
//change $REFERERS below to reflect your site.
$REFERERS = array('topdog-software.com', 'www.topdog-software.com');
//These are the domains allowed to access the script
//if you decide to restrict access
error_reporting(0);
/************************ END CUSTOMISATIONS ************************************/
/************************ SERVER DEFINITIONS ************************************/
$serverdefs= array(
"com" => array("whois.crsnic.net","No match for"),
"net" => array("whois.crsnic.net","No match for"),
"org" => array(" whois.pir.org","NOT FOUND"),
"biz" => array("whois.biz","Not found"),
"info" => array("whois.afilias.net","NOT FOUND"),
"co.uk" => array("whois.nic.uk","No match"),
"co.ug" => array("wawa.eahd.or.ug","No entries found"),
"or.ug" => array("wawa.eahd.or.ug","No entries found"),
"ac.ug" => array("wawa.eahd.or.ug","No entries found"),
"ne.ug" => array("wawa.eahd.or.ug","No entries found"),
"sc.ug" => array("wawa.eahd.or.ug","No entries found"),
"nl" => array("whois.domain-registry.nl","not a registered domain"),
"ro" => array("whois.rotld.ro","No entries found for the selected"),
"com.au" => array("whois.ausregistry.net.au","No data Found"),
"ca" => array("whois.cira.ca", "AVAIL"),
"org.uk" => array("whois.crsnic.net","No match for"),
"name" => array("whois.nic.name","No match"),
"us" => array("whois.nic.us","Not Found"),
"ws" => array("whois.website.ws","No Match"),
"be" => array("whois.ripe.net","No entries"),
"com.cn" => array("whois.cnnic.cn","no matching record"),
"net.cn" => array("whois.cnnic.cn","no matching record"),
"org.cn" => array("whois.cnnic.cn","no matching record"),
"no" => array("whois.norid.no","no matches"),
"se" => array("whois.nic-se.se","No data found"),
"nu" => array("whois.nic.nu","NO MATCH for"),
"com.tw" => array("whois.twnic.net","No such Domain Name"),
"net.tw" => array("whois.twnic.net","No such Domain Name"),
"org.tw" => array("whois.twnic.net","No such Domain Name"),
"cc" => array("whois.nic.cc","No match"),
"nl" => array("whois.domain-registry.nl","is free"),
"pl" => array("whois.dns.pl","No information about"),
"pt" => array("whois.ripe.net","No entries found")
);
/*********************** END SERVER DEFINITIONS *********************************/
if ($_SERVER['REQUEST_METHOD'] == 'GET'){
$domain = $_GET['domain'];
$ext = $_GET['ext'];
$option = $_GET['option'];
}else{
$domain = $_POST['domain'];
$ext = $_POST['ext'];
$option = $_POST['option'];
}
if($restrict ==1){
check_referer();
}
/************* Perform checks domain x-ters *************************************/
namecheck($domain);
/************* Check domain zone ************************************/
if ($serverdefs[$ext]){
$server = $serverdefs[$ext][0];
$nomatch = $serverdefs[$ext][1];
if($option=="check")
{
$layout = check_domain($domain,$ext);
print_results($layout);
}
if($option=="whois")
{
whois($domain,$ext);
}
}
elseif($ext == "co.za"){
if($option == "check"){
if(function_exists(curl_init)){
$layout = cozacurlcheck($domain);
}else{
$layout = cozacheck($domain);
}
print_results($layout);
}elseif($option=="whois"){
if(function_exists(curl_init)){
cozacurlwhois($domain);
}else{
cozawhois($domain);
}
}
}
elseif($ext == "all"){
$layout = "<tr>\n<td>\n<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
foreach($serverdefs as $ext => $servers)
{
$server = $servers[0];
$nomatch = $servers[1];
$available = check_domain($domain, $ext);
if ($available == 0)
{
$layout .= sprintf("<tr>\n<td>\n%s.%s</td>\n<td>\n<font color=\"green\">\n[b]Available![/b]\n</font>\n</td>\n", $domain, $ext);
$layout .= sprintf("<td>\n<a href=\"%s?domain=%s.%s\">register now</a>\n</td>\n</tr>\n", $registerlink, $domain, $ext);
}
elseif ($available == 2)
{
$layout .= sprintf("<tr>\n<td>\n%s.%s</td>\n<td>\n<font color=\"grey\">\nUnknown</font>\n</td>\n", $domain, $ext);
$layout .= "<td>\nCould not contact server</td>\n</tr>\n";
}
else
{
$layout .= sprintf("\n<tr>\n<td>\n%s.%s</td>\n<td>\n<font color=\"red\">Taken\n</font>\n</td>\n", $domain, $ext);
$layout .= sprintf("<td>\n<a href=\"%s?domain=%s&ext=%s&option=whois\">check whois</a></td>\n</tr>\n", $PHP_SELF, $domain, $ext);
}
}
$layout .= "</table>\n</td>\n</tr>\n";
$ext = " all supported domains";
print_results($layout);
}
/** <------------------------------------functions--------------------------------> **/
function check_domain($domain,$ext)
{
global $nomatch,$server;
$output="";
if(($sc = fsockopen($server,43))==false){return 2;}
fputs($sc,"$domain.$ext\n");
while(!feof($sc)){$output.=fgets($sc,128);}
fclose($sc);
//compare what has been returned by the server
if (eregi($nomatch,$output)){
return 0;
}else{
return 1;
}
}
/********* Function to return whois results ***********************************/
function whois($domain,$ext)
{ global $template,$server;
if(($sc = fsockopen($server,43))==false){
if(($sc = fsockopen($server,43))==false){
//echo"There is a temporary service disruption Please again try later";
$layout =2;
print_results($layout);
exit;
}
}
if($ext=="com"||$ext=="net"){
//
fputs($sc, "$domain.$ext\n");
while(!feof($sc)){
$temp = fgets($sc,128);
if(ereg("Whois Server:", $temp)) {
$server = str_replace("Whois Server: ", "", $temp);
$server = trim($server);
}
}
fclose($sc);
if(($sc = fsockopen($server,43))==false){
//echo"There is a temporary service disruption Please try later";
$layout =2;
print_results($layout);
exit;
}
}
$output="";
fputs($sc,"$domain.$ext\n");
while(!feof($sc)){$output.=fgets($sc,128);}
fclose($sc);
//print
print_whois($output);
}