判断WebSERVER类型
<?PHP
function WebServerSpy($ServerURL)
{
$filepointer = fsockopen($ServerURL,80,&$errno,&$errstr);
if(!$filepointer)
{
$WebServer="Error: $errstr ($errno)<br>
";
}
else
{
fputs($filepointer,"GET / HTTP/1.0
");
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>");
时间: 2024-11-03 05:01:31