Codice PHP:
<?php
***********/
$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(
"eu" => array("whois.eu","No match"),
"it" => array("whois.nic.it","No match"),
"com" => array("whois.crsnic.net","No match"),
"net" => array("rs.internic.net","No match"),
"tv" => array("rs.internic.net","No match"),
"com.au" => array("whois.ausregistry.net.au","No data Found"),
"ca" => array("whois.cira.ca", "AVAIL"),
"org.uk" => array("whois.nic.uk","No match"),
"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("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);
}
/******* function to check referer ************************************************/
function check_referer () {
global $REFERERS, $HTTP_REFERER;
if ($HTTP_REFERER != "")
while (list($val, $ref) = each($REFERERS))
if (preg_match("/^http:\/\/$ref/", $HTTP_REFERER))
return;
$layout = "<tr>\n<td>\n<font color=\"red\">\nAccess denied to: $HTTP_REFERER</font>\n
\nPlease dont link to this script <a href=\"http://www.topdog-software.com/scripts.php\">download</a> a copy
and set it up on your site.
\n This is due to bandwidth usage ... leeching and Data mining</td>\n</tr>\n";
print_results($layout);
exit;
}
/******* Function to print the results into your template ************************/
function print_results($layout)
{
global $template,$registerlink,$domain,$ext,$server;
if(!is_file($template)){
print"The template file into which to print the results either does not exist or is
not writeable
please correct this if you are the webmaster of this site
The script can not continue exiting......";
exit;
}
$template = file ($template);
$numtlines = count ($template); //Number of lines in the template
$line = 0;
while (! stristr ($template[$line], "") && $line < $numtlines) {
echo $template[$line];
$line++;
}
if($layout=="0"){
$line++;
print "\n<!-----------------\n";
print "\tPOWERED BY\n\n";
print "\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
print "\t© KISSA ANDREW COLIN\n";
print "\tkissandrew@yahoo.com\n";
print "\twww.topdog-software.com\n";
print "\n------------------->\n";
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>";
print "<tr><td>[b]Domain query Results for \"$domain.$ext\"[/b]</td></tr>";
print "<tr><td><hr></td></tr>";
print "<tr><td>The domain is available <a href=\"$registerlink?domain=$domain.$ext\">register</a> it now</td></tr>";
print "</table>";
}
elseif($layout=="1"){
$line++;
print "\n<!-----------------\n";
print "\tPOWERED BY\n\n";
print "\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
print "\t© KISSA ANDREW COLIN\n";
print "\tkissandrew@yahoo.com\n";
print "\twww.topdog-software.com\n";
print "\n------------------->\n";
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
print "<tr>\n<td>\n[b]\nDomain query Results for \"$domain.$ext\"[/b]\n
\n</td>\n</tr>\n";
print "<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
print "<tr>\n<td>\n[b]\nThe domain is already taken <a href=\"$PHP_SELF?domain=$domain&ext=$ext&option=whois\">Check</a> the whois information
</td></tr>";
print "<tr>\n<td>\nCheck another domain name <a href=\"javascript:history.back()\">here</a></td></tr>";
print "</table>\n";
}
elseif($layout=="2"){
$line++;
print "\n<!-----------------\n";
print "\tPOWERED BY\n\n";
print "\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
print "\t© KISSA ANDREW COLIN\n";
print "\tkissandrew@yahoo.com\n";
print "\twww.topdog-software.com\n";
print "\n------------------->\n";
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
print "<tr>\n<td>\n[b]\nDomain query Results for \"$domain.$ext\"[/b]\n
\n</td>\n</tr>\n";
print "<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
print "<tr>\n<td>\n[b]Could not contact the whois server $server[/b]\n
\n</td>\n</tr>\n";
print "<tr>\n<td>\nCheck another domain name <a href=\"javascript:history.back()\">here</a>\n</td>\n</tr>\n";
print "</table>\n";
}
else{
$line++;
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
print "<tr>\n<td>\n[b]Domain query Results for \"$domain.$ext\"[/b]\n
\n</td>\n</tr>\n";
print "<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
print $layout;
print "<tr>\n<td>\nCheck another domain name <a href=\"javascript:history.back()\">here</a>\n</td>\n</tr>\n";
print "</table>\n";
}
print "
\n
\n";
print "<center>\n<font class=font1csm>\n powered by <a href=\"http://www.marikweb.com\">marikweb</a>\n</font>\n</center>\n";
while ($line < $numtlines) {
echo $template[$line];
$line++;
}
}
/******* Function to print whois results *****************************************/
function print_whois($output){
global $template,$domain,$ext;
if(!is_file($template)){
print"The template file into which to print the results either does not exist
or is not writable
please correct this if you are the webmaster of this site
The script can not continue exiting......";
exit;
}
$template = file ($template);
$numtlines = count ($template);
$line = 0;
while (! stristr ($template[$line], "") && $line < $numtlines) {
echo $template[$line];
$line++;
}
$line++;
print "\n<!-----------------\n";
print "\tPOWERED BY\n\n";
print "\tTOPDOG WHOIS & DOMAIN CHECK SCRIPT\n";
print "\t© KISSA ANDREW COLIN\n";
print "\tkissandrew@yahoo.com\n";
print "\twww.topdog-software.com\n";
print "\n------------------->\n";
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=font1l>\n";
print "<tr>\n<td>\n[b]\nDomain whois query information for \"$domain.$ext\"[/b]\n</td>\n</tr>\n";
print "<tr>\n<td>\n<hr>\n</td>\n</tr>\n";
print "<tr>\n<td>\n";
$output= explode("\n",$output);
foreach ($output as $value){
print "$value
\n";
}
print "</td>\n</tr>\n</table>\n";
print "
";
print "<center>\n<font class=font1csm>\n powered by <a href=\"http://www.topdog-software.com/scripts.php\">marikweb</a>\n</font>\n</center>\n";
while ($line < $numtlines) {
echo $template[$line];
$line++;
}
}
?>