判断WebSERVER类型
时间:2007-02-17 来源:PHP爱好者
<?PHP
function WebServerSpy($ServerURL)
{
$filepointer = fsockopen($ServerURL,80,&$errno,&$errstr);
if(!$filepointer)
{
$WebServer="Error: $errstr ($errno)<br>n";
}
else
{
fputs($filepointer,"GET / HTTP/1.0nn");
while(!feof($filepointer))
{
$WebServer=fgets($filepointer,4096);
if (ereg("^Server:",$WebServer))
{
$WebServer=trim(ereg_replace("^Server:","",$WebServer));
break;
}
}
fclose($filepointer);
}
return($WebServer);
}
?>
<?PHP /**************** Example *******************/
if ($ServerURL<>"") { $WebServer=WebServerSpy($ServerURL); }
?>
<HTML>
<HEAD>
<TITLE>Ostis WebServer Spy</TITLE>
</HEAD>
<BODY>
<?PHP
if ($WebServer<>"" and $ServerURL<>"")
{
echo("<PRE>Server $ServerURL is running $WebServer.</PRE>");
}
?>
<FORM ACTION="<?PHP echo($PHP_SELF); ?>" METHOD="post">
http:// <INPUT TYPE="text" NAME="ServerURL" SIZE="40" MAXLENGTH="100">
<INPUT TYPE=hidden NAME="WebServer" VALUE="">
<INPUT TYPE=submit VALUE="Spy this Server!"><INPUT TYPE=reset VALUE="Reset">
</FORM>
</BODY>
</HTML>
非常全面的一个php技术网站,php爱好者站 http://www.phpfans.net 有相当丰富的文章和源代码.