Beste PHPérs,
Ik krijg mijn domeinchecker niet meer werkend.
Graag zou ik willen dat na mijn domeincheck direct de beschikbaarheid word getoond.
Het script zou moeten werken omdat het elders wel werkt.
Bij mij geeft hij bij alles aan dat het domein bezet is
Het invoeren van het domein kan bijvoorbeeld op mijn index pagina:
Klik hier om naar toe te gaan
Alle hulp is welkom groeten, Stef
Ziet iemand wat ik fout doe? hier heb ik de code:
(whois.php)
[code]
<?php
/****** Aan te passen gegevens ***********/
$template = "domein.php"; //vul hier een template naam in
//deze page moet "<!--DOMAIN RESULTS-->" bevatten
$registerlink = "bestel.php"; //bestelpagina
$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('stefdev.nl');
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"),
"eu" => array("whois.eu","FREE"),
"org" => array("whois.pir.org","NOT FOUND"),
"biz" => array("whois.nic.biz","Not found"),
"info" => array("whois.afilias.net","NOT FOUND"),
"de" => array("whois.nic.de","FREE"),
"in" => array("whois.inregistry.in","NOT FOUND"),
"nl" => array("whois.domain-registry.nl","not a registered domain"),
"name" => array("whois.nic.name","No match"),
"us" => array("whois.nic.us","Not Found:"),
"ws" => array("whois.nic.ws","No match for"),
"be" => array("whois.dns.be","FREE"),
"nu" => array("whois.nic.nu","NO MATCH for"),
"it" => array("whois.nic.it","No entries found"),
"nl" => array("whois.domain-registry.nl","is free"),
"pl" => array("whois.dns.pl","No information about"),
"tv" => array("whois.nic.tv","No match for"),
"co.uk" => array("whois.nic.uk","No match"),
"org.uk" => array("whois.nic.uk","No match"),
"me.uk" => array("whois.nic.uk","No match"),
"tk" => array("whois.dot.tk","not known"),
"cc" => array("whois.nic.cc","No match"),
"ac" => array("whois.nic.ac","No match for"),
"ru" => array("whois.ripn.net","No entries found"),
"ag" => array("whois.nic.ag","NOT FOUND"),
"am" => array("whois.nic.am","No information available"),
"bz" => array("mhpwhois1.verisign-grs.net","No match"),
"gs" => array("whois.adamsnames.tc","is not registered"),
"co.in" => array("whois.iisc.ernet.in","no entries found"),
"jp" => array("whois.nic.ad.jp","No match!!"),
"ms" => array("whois.adamsnames.tc","is not registered"),
"com.sg" => array("whois.nic.net.sg","NOMATCH"),
"sh" => array("whois.nic.sh","No match"),
"com.tw" => array("whois.twnic.net","No Records Found"),
"org.tw" => array("whois.twnic.net","No Records Found"),
"vg" => array("whois.adamsnames.tc","is not registered"),
"la" => array("whois.nic.la","NO MATCH"),
"tc" => array("whois.adamsnames.tc","is not registered"),
"fm" => array("cwhois1.completewhois.com","not known"),
);
/*********************** 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=main>\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 class=main color=\"green\">\n<b>Vrij!</b>\n</font>\n</td>\n", $domain, $ext);
$layout .= sprintf("<td>\n<a class=main href=\"%s?domain=%s.%s\">registreer nu</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>\nKan geen verbinding maken met de server.</td>\n</tr>\n";
}
else
{
$layout .= sprintf("\n<tr>\n<td>\n%s.%s</td>\n<td>\n<font class=main color=\"red\">bezet\n</font>\n</td>\n", $domain, $ext);
$layout .= sprintf("<td>\n<a class=main href=\"%s?domain=%s.%s\">verhuis nu</a>\n</td>\n</tr>\n", $registerlink, $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 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<br>
please correct this if you are the webmaster of this site<br>
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], "<!--DOMAIN RESULTS-->") && $line < $numtlines) {
echo $template[$line];
$line++;
}
if($layout=="0"){
$line++;
print "<h3>Het domein: \"$domain.$ext\" is vrij!</h3><a href=\"$registerlink?domein=$domain.$ext\" >registreer nu!</a>";
}
elseif($layout=="1"){
$line++;
print "<h3>Het domein: \"$domain.$ext\" is reeds bezet.</h3><font class=main>Bent u de eigenaar van dit domein dan kunt u het naar ons <a href=\"$registerlink?domein=$domain.$ext\" >verhuizen.</a>";
}
elseif($layout=="2"){
$line++;
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=main>\n";
print "<tr>\n<td>\n<b>\nResultaten voor \"$domain.$ext\"</b>\n<br>\n</td>\n</tr>\n";
print "<tr>\n<td>\n<b>Kan geen verbinding maken met de server $server</b>\n<br>\n</td>\n</tr>\n";
print "</table>\n";
}
else{
$line++;
print "<table width=\"100%\" border=\"0\" cellPadding=2 class=main>\n";
print "<tr>\n<td>\n<b>Resultaten voor \"$domain.$ext\"</b>\n<br>\n</td>\n</tr>\n";
print $layout;
print "</table>\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<br>
please correct this if you are the webmaster of this site<br>
The script can not continue exiting......";
exit;
}
$template = file ($template);
$numtlines = count ($template);
$line = 0;
while (! stristr ($template[$line], "<!--DOMAIN RESULTS-->") && $line < $numtlines) {
echo $template[$line];
$line++;
}
$line++;
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<br>\n";
}
}
/****** This checks the name for invaild characters *******************************/
function namecheck($domain)
{
if($domain==""){$layout = "<tr>\n<td>\n<font color=\"red\">\nU moet een domeinnaam invullen om te controleren.</font>\n<br>\n";
print_results($layout);exit;}
if(strlen($domain)< 3){$layout = "<tr>\n<td>\n<font color=\"red\">\nDe domeinnaam $domain is te kort.</font>\n</td>\n</tr>\n"; print_results($layout);exit;}
if(strlen($domain)>57){$layout = "<tr>\n<td>\n<font color=\"red\">\nDe domeinnaam $domain is te lang.</font>\n</td>\n</tr>\n"; print_results($layout);exit;}
if(@ereg("^-|-$",$domain)){$layout = "<tr>\n<td>\n<font color=\"red\">\nDomeinnaam mag niet beginnen met een hyphen</font>\n</td>\n</tr>\n"; print_results($layout);exit;}
if(!ereg("([a-z]|[A-Z]|[0-9]|-){".strlen($domain)."}",$domain))
{$layout = "<tr>\n<td>\n<font color=\"red\">\nDomeinnaam mag geen speciale tekens bevatten.</font>\n</td>\n</tr>\n"; print_results($layout);exit;}
}
/********** function to return whois record via socket ***********************/
function cozawhois($domain){
$errno = 0;
$errostr = "";
$timeout = 30;
$fp = fsockopen("co.za",80,$errno,$errstr,$timeout);
if($fp){
socket_set_timeout($fp,$timeout);
$url = "GET /cgi-bin/whois.sh?Domain=$domain HTTP/1.0\r\n Host: co.za\r\n";
$url .= "Connection: Keep-Alive\r\n User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.3705)\r\n";
$url .= "Referer: http://co.za/whois.shtml\r\n Accept: text/plain, text/html\r\n\r\n";
fputs($fp,$url);
$output = "";
while(!feof($fp)){
$output .= fgets($fp,128);
}
fclose($fp);
$temp_code = strip_tags($output);
$startp = strpos($temp_code,"The CO.ZA simple whois server");
$dis = substr($temp_code,$startp);
print_whois($dis);
}else{
$layout = "<tr>\n<td>\nThe script could not connect to the co.za whois server<br>";
$layout.= "<b>DEBUG INFO:</b><br><br>";
$layout.= "Error No: $errno<br>Error Description:<br>$errstr</td>\n</tr>\n";
print_results($layout);
exit;
}
}
/***<--------------------------------end functions------------------------------------>***/
2.251 views