Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find server software for a site 1

Status
Not open for further replies.

miraclemaker

Programmer
Oct 16, 2002
127
GB
Hi there.
Does anyone know if there's a way to retrieve what server software a site is using through PHP. I'm after something similar to what netcraft provides through their 'what's that site running' service:
 
Are we asking to determine the server software on another's server? If so, you might be able to open (PHP function: fopen) the index page from the remote server and read the header that describes that server.

- - picklefish - -
Why is everyone in this forum responding to me as picklefish?
 
Yeah it is to retrieve the server information for a remote server.
Netcraft describe their way of doing it as "Netcraft determines the operating system of the queried host by looking in detail at the network characteristics of the HTTP reply received from the web site."

without knowing exactly how they do it would mean it would be a pain to do my own implementation.
 
It's not hard to get the server software of a foreign web server if you have cURL available to your PHP installation:

The following script:
Code:
<?php
$ch = curl_init();

$fh = fopen('/tmp/foo.txt', 'w');

curl_setopt($ch, CURLOPT_URL, '[URL unfurl="true"]http://www.mit.edu');[/URL]
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_WRITEHEADER, $fh);

$page = curl_exec($ch);

fclose ($fh);
curl_close($ch);

print '<pre>';
readfile ('/tmp/foo.txt');
?>

returns:
Code:
HTTP/1.1 200 OK
Date: Fri, 16 Apr 2004 14:19:30 GMT
Server: Apache/1.3.20 (Unix)
Last-Modified: Fri, 16 Apr 2004 12:30:01 GMT
ETag: "2a712-3db0-407fd1c9"
Accept-Ranges: bytes
Content-Length: 15792
Content-Type: text/html

If the script were modified to analyze the "Server:" header instead of outputting all the headers, you could get what you want.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top