Confermo che ho eliminato la restrinzione, e come richiesto ti posto (se posso darti del tu) le varie parti richieste:
/tests/1/
Codice PHP:
Function whois ($a_server, $a_query="", $a_port=43) {
$sock = fsockopen($a_server, $a_port, &$errno, &$errstr, 10);
if (!$sock)
{
echo "$errstr ($errno)<BR>\n";
} else {
fputs($sock, "$a_query\r\n");
while(!feof($sock))
{
$buf = fgets($sock,128);
if (ereg( "Whois Server:", $buf))
{
$a_server = str_replace( "Whois Server: ", "", $buf);
$a_server = trim($a_server);
}
}
fclose($sock);
if ($a_server)
{
print "<B>$a_query is registered at $a_server:</B><BR>";
$sock = fsockopen($a_server, 43, &$errno, &$errstr, 10);
if(!$sock)
{
echo "Could not open connection to $a_server on port $a_port.\n";
echo "$errstr ($errno)<BR>\n";
} else {
fputs($sock, "$a_query\r\n");
while(!feof($sock))
{
echo fgets($sock,128);
}
fclose($sock);
}
} else {
echo "<b>$a_query was not found.</b><BR>";
}
}
}
// finger(hostname [,username, [port]])
Function finger ($a_server, $a_query="", $a_port=79) {
$sock=fsockopen($a_server,$a_port, &$errno, &$errstr, 10);
if (!$sock)
{
$ret_str = "$errstr ($errno)<BR>\n";
} else {
fputs($sock,"$a_query\n");
while (!feof($sock)) { $ret_str .= fgets($sock,128); }
fclose($sock);
}
echo $ret_str;
return $ret_str;
}
/tests/4/
Codice PHP:
function wwwhois($target){
$server = "whois.crsnic.net";
message("<p><b>WWWhois Results:</b><blockquote>");
$target = gethostbyaddr($target);
if (! eregi("[a-zA-Z]", $target))
$msg .= "Can't WWWhois without a domain name.";
else if (!eregi("\.com|\.net|\.org|\.edu", $target))
$msg .= "I currently only support .com, .net, .org, and .edu.";
else{
message("Connecting to $server...<br><br>");
if (! $sock = fsockopen($server, 43, &$num, &$error, 10)){
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("Whois Server:", $buffer)){
if(eregi("no match", $buffer))
message("NOT FOUND: No match for $target<br>");
else
message("Ambiguous query, multiple matches for $target:<br>");
}
else{
$buffer = split("\n", $buffer);
for ($i=0; $i<sizeof($buffer); $i++){
if (eregi("Whois Server:", $buffer[$i]))
$buffer = $buffer[$i];
}
$nextServer = substr($buffer, 17, (strlen($buffer)-17));
$buffer = "";
message("Deferred to specific whois server: $nextServer...<br><br>");
if(! $sock = fsockopen($nextServer, 43, &$num, &$error, 10)){
unset($sock);
$msg .= "Timed-out connecting to $nextServer (port 43)";
}
else{
fputs($sock, "$target\n");
while (!feof($sock))
$buffer .= fgets($sock, 10240);
fclose($sock);
}
}
$msg .= nl2br($buffer);
}
$msg .= "</blockquote></p>";
message($msg);
}
Per ora questi due sono quelli più importanti. Comunque tutti gli scripts che non funzionano si trovano all'interno della cartella /tests