این کد برای index.php
<!DOCTYPE html>
<html lang="fa">
<head>
<title>چک کردن وضعیت نام دامنه - Domain Lookup Service</title>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/bootstrap.css" rel="stylesheet" media="screen">
<link href="css/style.css" rel="stylesheet" media="screen">
<script src="js/jquery-latest.js"></script>
<script src="js/bootstrap.min.js"></script>
<link rel="search" href="http://codesign.ir/whois/lookup.xml" type="application/opensearchdescription+xml" title="Codesign Whois"/>
<meta name="description" content="ابزاری جهت اطمینان از اینکه دامنه جهت ثبت آزاد باشد. پشتیبانی از دامنههای .com .org .net .ir .af" />
<meta name="keywords" content="lookup, domain, whois,lookup domain, whois domain, .ir, .net, .org, .com, .af, جستجوگر, دامنه, دامین" />
<link rel="shortcut icon" href="http://codesign.ir/whois/favico.ico" type="image/x-icon"/>
</head>
<body>
<?php
if(strpos($_SERVER['REQUEST_URI'], '?') !== false) {
header('Location: http://codesign.ir/whois/' . implode('/', array_values($_GET)));
exit();
}
if (isset($_GET['domain'])) {
$placeholder = $_GET['domain'];
} else {
$placeholder = 'Enter Domain Name, Like: example.com';
}
?>
<div class="container rtl">
<div class="row" style=" margin:20px 0 0 0;">
<div class="span5 offset3">
<h3 class="yekan center">وضعیت نام دامنه</h3>
<div class="mitra normal"><span class="badge badge-info">!</span> از کادر زیر میتونین آزاد بودن دامین مورد نظرتون رو چک کنین.<br></div>
</div>
<div class="span5 offset3 well" style="margin-top:10px;">
<form method="get">
<div class="input-append ltr" >
<input name="domain" class="span4" type="text" id="appendedInputButton" placeholder="<?php echo ($placeholder); ?>">
<button type="submit" class="btn btn-info"><i class="icon-search icon-white"></i></button>
</div>
</form>
<?php if (isset($_GET['domain'])) {
include('functions/whois.php');
$domain = $_GET['domain'];
$dmn = explode ('.', $domain);
switch ($dmn[1])
{
case 'com' :
$server = 'whois.crsnic.net';
$resp = 'No match for';
break;
case 'net' :
$server = 'whois.crsnic.net';
$resp = 'No match for';
break;
case 'org' :
$server = 'whois.publicinterestregistry.net';
$resp = 'NOT FOUND';
break;
case 'ir' :
$server = 'whois.nic.ir';
$resp = 'no entries found';
break;
case 'af';
$server = 'whois.nic.af';
$resp = 'Available';
break;
};
$result = checkDomain($domain,$server,$resp);
if ($result) { ?>
<div class="alert alert-success rtl mitra">
تبریک میگم، دامنه مورد نظر شما جهت ثبت آزاده :)
</div>
<?php
} else { ?>
<div class="alert alert-error mitra">
متاسفانه این دامنه قبلا ثبت شده، یکی دیگه رو امتحان کن :(
</div>
<?php }
}
?>
</div>
<div class="span5 offset3">
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-518b5fd8690e5d74"></script>
<!-- AddThis Button END -->
</div>
</div>
</div>
</body>
</html>
و این کد هم برای lookup.php
<?php if (isset($_GET['domain'])) {
include('functions/whois.php');
$domain = $_GET['domain'];
$dmn = explode ('.', $domain);
switch ($dmn[1])
{
case 'com' :
$server = 'whois.crsnic.net';
$resp = 'No match for';
break;
case 'net' :
$server = 'whois.crsnic.net';
$resp = 'No match for';
break;
case 'org' :
$server = 'whois.publicinterestregistry.net';
$resp = 'NOT FOUND';
break;
case 'ir' :
$server = 'whois.nic.ir';
$resp = 'no entries found';
break;
};
$result = checkDomain($domain,$server,$resp);
if ($result) { ?>
<div id="result" class="alert alert-success rtl mitra">
تبریک میگم، دامنه مورد نظر شما جهت ثبت آزاده :)
</div>
<a class="btn btn-info btn-small yekan pull-left" href="step2.php"><i class="icon-chevron-right icon-white"></i> مرحله بعد</a>
<?php } else { ?>
<div id="result" class="alert alert-error mitra">
متاسفانه این دامنه قبلا ثبت شده، یکی دیگه رو امتحان کن :(
</div>
<?php }
}
?>
whois.php
<?php
function checkDomain($dmn,$server,$findText){
$con = fsockopen($server, 43);
if (!$con) return false;
// Send the requested doman name
fputs($con, $dmn."\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;
}
}
?>