IP Whois Results:");
if (!$target = gethostbyname($target))
$msg .= "Can't IP Whois without an IP address.";
else{
message("Connecting to $server...
");
if (! $sock = fsockopen($server, 43, $num, $error, 20)){
unset($sock);
$msg .= "Timed-out connecting to $server (port 43)";
}
else{
fputs($sock, "$target\n");
while (!feof($sock))
$buffer .= fgets($sock, 10240);
fclose($sock);
}
if (eregi("RIPE.NET", $buffer))
$nextServer = "whois.ripe.net";
else if (eregi("whois.apnic.net", $buffer))
$nextServer = "whois.apnic.net";
else if (eregi("nic.ad.jp", $buffer)){
$nextServer = "whois.nic.ad.jp";
#/e suppresses Japanese character output from JPNIC
$extra = "/e";
}
else if (eregi("whois.registro.br", $buffer))
$nextServer = "whois.registro.br";
if($nextServer){
$buffer = "";
message("Deferred to specific whois server: $nextServer...
");
if(! $sock = fsockopen($nextServer, 43, $num, $error, 10)){
unset($sock);
$msg .= "Timed-out connecting to $nextServer (port 43)";
}
else{
fputs($sock, "$target$extra\n");
while (!feof($sock))
$buffer .= fgets($sock, 10240);
fclose($sock);
}
}
$buffer = str_replace(" ", " ", $buffer);
$msg .= nl2br($buffer);
}
$msg .= "
";
message($msg);
}
function message($msg){
echo "$msg";
flush();
}
arin($ip);
?>