<?
// --------------- das ist die domaincheck.php
require("config.php");
$whoisservers = array(
array("de","whois.denic.de"),
array("com","whois.internic.net"),
array("net","whois.internic.net"),
array("org","whois.pir.org"),
array("info","whois.afilias.net"),
array("biz","whois.biz"),
array("at","whois.nic.at"),
array("ch","whois.nic.ch"),
array("li","whois.nic.ch"),
array("co.uk","whois.nic.uk"),
array("cc","whois.nic.cc"),
array("dk","whois.dk-hostmaster.dk"),
array("it","whois.nic.it"),
array("ws","whois.worldsite.ws"),
array("in","whois.inregistry.net"),
array("name","whois.nic.name"),
array("eu","whois.eu")
);
function get_whois_server($domain){
global $whoisservers;
$whocnt = count($whoisservers);
for($x = 0; $x < $whocnt; $x++) {
$artld = $whoisservers[$x][0];
$tldlen = intval(0 - strlen($artld));
if(substr($domain, $tldlen) == $artld)
$whosrv = $whoisservers[$x][1];
}
return $whosrv;
}
$dchecked = array();
function check_domain($url, &$domchecked) {
$lusrv = get_whois_server($url);
if(!$lusrv)
return "";
$fp = fsockopen($lusrv,43);
if($lusrv == "whois.denic.de")
fputs($fp, "-C ISO-8859-1 -T ace,dn $url\r\n");
else
fputs($fp, "$url\r\n");
$string = "";
while(!feof($fp))
$string.= fgets($fp,128);
fclose($fp);
$reg = "/Whois Server: (.*?)\n/i";
preg_match_all($reg, $string, $matches);
$secondtry = $matches[1][0];
if($secondtry) {
$fp = fsockopen($secondtry,43);
fputs($fp, "$url\r\n");
$string="";
while(!feof($fp))
$string.=fgets($fp,128);
fclose($fp);
}
if(ereg("(nothing found|No match|No entries found|NOT FOUND|Not found|not found in database|Whois information is not available for domain|We do not have an entry in our database matching your query)",$string)) {
$domchecked['msg'] = "<center><b><font color=\"#00FF00\">Der Domainname ".$url." ist frei.</font></b></center><br>";
}
else {
$domchecked['msg'] = "<center><b><font color=\"#FF0000\">Der Domainname ".$url." ist vergeben.</font></b> ";
$domchecked['infos'] = "<a href=\"#\" onClick=\"javascript:show('".$url."'); return false\">Infos anzeigen</a></center>";
$domchecked['div'] = "<pre><font size=\"12pt\"><div style=\"display: none\" id=\"".$url."\">".$string."</div></font></pre>";
}
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if($_POST['endung'] == "alle")
{
for($i = 0; $i < count($whoisservers); $i++)
{
$dom = $_POST['dom'].".".$whoisservers[$i][0];
check_domain($dom, &$domchecked);
}
}
else
{
$dom = $_POST['dom'].$_POST['endung'];
check_domain($dom, &$domchecked);
}
}
?>
<?php
// ------ mit dem array $domchecked die Informationen ausgeben. index.php
// ------ Die index.php muss das Javascript und den css style sheet beinhalten.
print $domchecked['msg'];
print $domchecked['infos'];
print $domchecked['div'];
?>