<?php
function checkDomain($domain,$server,$findText){
// Open a socket connection to the whois server
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $domain."\r\n");
// Read and store the server response
$response = ' :';
while(!feof($con)) {
$response .= fgets($con,128);
}
// Close the connection
fclose($con);
// Check the response stream whether the domain is available
if (strpos($response, $findText)){
return true;
}
else {
return false;
}
}
function showDomainResult($domain,$server,$findText){
if (checkDomain($domain,$server,$findText)){
echo "<tr><td>$domain</td><td>Kaydedilebilir</td></tr>";
}
else echo "<tr><td>$domain</td><td>Daha Once Alinmis</td></tr>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Sorgulama Sistemi</title>
<link href="dd/style.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#F4F4F4">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" align="left" method="post" target="_blank" name="domain" id="domain">
<font face="Tahoma" size="2"><b>Alan Adı (Domain) Sorgulama:</b></font>
<table>
<tr><td><input class="text" name="domainname" type="text" size="38"/></td></tr>
<tr>
<td>
<input type="checkbox" name="all" checked value="ON" />Tümü
<input type="checkbox" name="com" value="ON"/>.com
<input type="checkbox" name="net" value="ON"/>.net
<input type="checkbox" name="org" value="ON"/>.org
<input type="checkbox" name="info" value="ON"/>.info
</td></tr>
<tr><td align="center"><br/><input class="text" type="submit" name="submitBtn" value="Sorgula"/></td></tr>
</table>
</form>
<?php
if (isset($_POST['submitBtn'])){
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$d_all = (isset($_POST['all'])) ? 'all' : '';
$d_com = (isset($_POST['com'])) ? 'com' : '';
$d_net = (isset($_POST['net'])) ? 'net' : '';
$d_org = (isset($_POST['org'])) ? 'org' : '';
$d_info = (isset($_POST['info'])) ? 'info' : '';
// Check domains only if the base name is big enough
if (strlen($domainbase)>2){
?>
<table width="100%">
<?php
if (($d_com != '') || ($d_all != '') ) showDomainResult($domainbase.".com",'whois.crsnic.net','No match for');
if (($d_net != '') || ($d_all != '') ) showDomainResult($domainbase.".net",'whois.crsnic.net','No match for');
if (($d_org != '') || ($d_all != '') ) showDomainResult($domainbase.".org",'whois.publicinterestregistry.net','NOT FOUND');
if (($d_info != '') || ($d_all != '') ) showDomainResult($domainbase.".info",'whois.afilias.net','NOT FOUND');
?>
</table>
</div>
<?php
}
}
?>
</body>
</html>