Home >> Snippet List >> Snippet

Name
WebServer Spy
Description
WebServerSpy checks which kind of Webserver is running, Apache, Netscape , Fasttrack, IIS, HTTP-Header, HTTP 10, GET, spy, WWW
PHP Snippet
<?PHP 
 
FUNCTION WebServerSpy($ServerURL) 
{ 
  $filepointer = FSOCKOPEN($ServerURL,80,&$errno,&$errstr); 
  IF(!$filepointer) 
  { 
    $WebServer="Error: $errstr ($errno)<br>\n"; 
  } 
  ELSE 
  { 
    FPUTS($filepointer,"GET / HTTP/1.0\n\n"); 
    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); ?>