PHP Whois
This PHP script displays the whois information from a given domain.
Example
Whois online tool
Required
PHP 4.0.4 or higher
License
Open Source (GNU GPL)
Sourcecode
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Whois</title>
<meta name="title" content="Whois">
<meta http-equiv="content-language" content="de-at">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if(trim($domain)=="")
$err_text.="Please enter a domain name.<br>";
if(($send=="1") && (isset($err_text))) {
echo "<p><big><b>Error:</b></big><br>";
echo "<span id=warn>$err_text</span></p>";
}
if(!$domain) $domain="google.at";
?>
<table border=0 cellspacing=0 cellpadding=2>
<form action="<?php echo $PHP_SELF; ?>" method="post">
<tr><td nowrap align=right id="formtext">Domain or IP: </td>
<td width=100%><input type="text" name="domain" size=40 maxlength=250
value="<?php echo $domain; ?>"></td></tr>
<tr><td nowrap align=right> </td>
<td width=100%><input type="submit" value="Whois" name="submit">
<input type="hidden" value="1" name="send"></td></tr>
</td></tr></form>
</table>
<?php
if(($send=="1") && (!isset($err_text))) {
$domain=strtolower($domain);
echo "<br><h4>Whois</h4>\n";
echo "<blockquote>\n";
echo "<pre>\n";
flush();
$server="whois.ripe.net";
$IP=gethostbyname($domain);
if(!$IP) $IP==$domain;
echo "Connecting to $server:43...<br>\n";
$fp=@fsockopen($server,43,&$errno,&$errstr,15);
if(!$fp)
{
echo "Connection to $server:43 can't be established.<br>\n";
echo "$errno: $errstr<br>\n";
return false;
}else{
echo "Connected with $server:43, sending query...<br>\n";
echo "(IP/Domain: $IP)<br>\n";
fputs($fp,"$IP\r\n");
while(!feof($fp))
{
echo fgets($fp,256);
}
fclose($fp);
echo "Connection closed.<br>\n";
}
echo "</pre>\n";
}
?>
</body>
</html>