您的位置:首页网页设计PHP技巧 → 一个用于网络的工具函数库

一个用于网络的工具函数库

时间:2004/11/7 3:15:00来源:本站整理作者:蓝点我要评论(0)




/*

PHP Net Toolpack v0.1 08.05.2000,

by waddler(@netlife.fi)

phpnettoolpack.sourceforge.net

To be distributed under GNU GPL

*/



// whois(hostname [,username, [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 Server:", $buf))

{

$a_server = str_replace( "Whois Server: ", "", $buf);

$a_server = trim($a_server);

}

}

fclose($sock);



if ($a_server)

{

print "$a_query is registered at $a_server:
";

$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)
n";

} else {

fputs($sock, "$a_queryrn");

while(!feof($sock))

{

echo fgets($sock,128);

}

fclose($sock);

}

} else {

echo "$a_query was not found.
";

}

}

}





// 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)
n";

} else {

fputs($sock,"$a_queryn");

while (!feof($sock)) { $ret_str .= fgets($sock,128); }

fclose($sock);

}

echo $ret_str;

return $ret_str;

}





// traceroute(hostname)

Function traceroute ($a_query) {

exec("traceroute $a_query",$ret_strs);

$str_count = count($ret_strs);

for ($count=0; $count < $str_count; $count++)

print "$count/$str_count".$ret_strs[$count]."n";

}





// -----------------------------------------------------------





$app_name = "PHP Net Toolpack";

$app_version = "0.1";



$TOOLS = array(

"finger" => "Finger",

"traceroute" => "Traceroute",

"whois" => "Whois?"

);



// when included inside


Query :









}

break;



case "traceroute":

if ($query)

{

print "
n"; 

traceroute($query);

print "
";

} else {

?>





Query :









}

break;





case "whois":

if ($query)

{

print "
n"; 

whois($server,$query);

print "
";

} else {

?>  









This will find .com, .org, and .net domains


Server :


Query :









}

break;



default:

print "
    Currently supported tools are:n";

    while (list($key, $val) = each($TOOLS)) {

    echo "
  • ".$val."
  • n";

    }

    print "
n";

break;

}



print "n
".$app_name." v".$app_version."n";

print "n";



?> 

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 如何恢复Discuz!7.0被 CSS实现Tab技巧Linux配置DHCP服务器实例:linux配置教程如何在IIS7下设置支持PHP程序PHP技巧--通过COM使用ADODB

人气排行 dedecms数据库表和字段说明最小化数据传输——在客户端存储数据php如何自动跳转中英文页面如何在IIS7下设置支持PHP程序php批量获取首字母(汉字、数字、英文)经典php实现大文件上传源代码Windows环境PHP的session不能正常使用解决办PHP聊天室技术