home *** CD-ROM | disk | FTP | other *** search
- WebServerSpy
-
- WebServerSpy checks which kind of Webserver is running (via HTTP 1.0 Server-Header)
-
-
- <?PHP
- /*
- * Function WebServerSpy created to check, which kind of WebServer is
- * running (e.g. NS Fasttrack, Apache etc.).
- *
- * (c) 1999 by: Bernhard Ostheimer (bernhard.ostheimer@uni-mainz.de)
- *
- * View Example @ http://service.wiwi.uni-mainz.de/~ostheimer/php/webserverspy/
- *
- * Permission to use and modify this software and its
- * documentation for any purpose other than its incorporation
- * into a commercial product is hereby granted without fee,
- * as long as the author is notified that this piece of software
- * is being used in other applications.
- * Permission to copy and distribute this software and its
- * documentation only for non-commercial use is also granted
- * without fee, provided, however, that the above copyright
- * notice appear in all copies, that both that copyright notice
- * and this permission notice appear in supporting documentation.
- * The author makes no representations about the suitability
- * of this software for any purpose. It is provided ''as is'',
- * without express or implied warranty.
- */
-
- 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); ?>" 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>
-