I am using a script to check domains on whois but I can only see if .com is available. How can I add .net, .org and such?
The script is
Code: Select all
<?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> AVAILABLE</td></tr>";
}
else echo "<tr><td>$domain</td><td> TAKEN</td></tr>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<link href="formstyle.css" rel="stylesheet" type="text/css" />
<body>
<div id="container"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain">
<strong>Domain name</strong>
<table>
<tr><td><input name="domainname" type="text" /></td></tr>
<tr><td><input type="checkbox" name="com" checked/>.com</td></tr>
<tr><td><input type="submit" name="submitBtn" value="Check domain"/></td></tr>
</table>
</form>
<?php
// The form was submitted
if (isset($_POST['submitBtn'])){
$domainbase = (isset($_POST['domainname'])) ? $_POST['domainname'] : '';
$d_com = (isset($_POST['com'])) ? 'com' : '';
// Check domains only if the base name is big enough
if (strlen($domainbase)>0){
echo '<table>';
if ($d_com != '')
showDomainResult($domainbase.".com",
'whois.crsnic.net','No match for');
echo '</table>';
}
}
?> </div>
</body>