/*
PHP Net Toolpack v0.1 08.05.2000,
由waddler(@netlife.fi)
phpnettoolpack.sourceforge.net
待分發>*/
// whois(主機名稱[,使用者名稱, [port]])
Function whois ($a_server, $a_query="", $a_port=43) {
$ sock = fsockopen($a_server, $a_port, &$errno, &$errstr, 10);
if (!$sock)
{
echo "$errstr ($errno)
n" ;
} else {
fputs($sock, "$a_queryrn");
while(!feof($sock))
{
$buf = fgets($sock,128) ;
if (ereg( "Whois 伺服器:", $buf))
{
$a_server = str_replace( "Whois 伺服器:", "", $buf);
$a_server = trim ($a_server);
}
}
fclose($sock);
if ($a_server)
{
print "$a_query 已在$ a_server 註冊:
";
$sock = fsockopen($a_server, 43, &$errno, &$errstr, 10);
if(!$sock)
{
echo "無法在連接埠$a_port.n 上開啟與$a_server 的連線";
echo "$errstr ($errno)
n";
} else {
fputs($sock , "$a_queryrn");
while(!feof($sock))
{
echo fgets($sock,128);
}
fclose($sock);
}
} else {
echo "找不到$a_query。
";
}
}
}
//finger($a_server, $a_query="", $a_port=79) {
$sock=fsockopen($a_server,$ a_port, &$errno, &$errstr, 10);
if (!$sock)
{
$ret_str = "$errstr ($errno)
n";
} else {
fputs($sock,"$a_queryn");
while (!feof($sock)) { $ret_str .= fgets($sock,128); }
fclose($sock);
}
echo $ret_str;
回傳$ret_str;
}
//traceroute(主機名稱)
函數traceroute ($a_query) {
函數traceroute ($a_query) {
函數traceroute ($a_query) {
>exec("traceroute $a_query",$ret_strs);
$str_count = count($ret_strs);
for ($count=0; $count print "$ count/$str_count".$ret_strs[$count]."n";
}
// ------------------ ----------------- ------------------------
$app_name = "PHP Net 工具包";
$app_version = "0.1";
$TOOLS = array(
"finger" => "Finger",
"traceroute" = > "Traceroute",
"whois" => "Whois?"
);
// 當包含在