SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    PHP Programmer QReyes's Avatar
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    698
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How can I found out a site's server type (Apache, IIS, etc.) using PHP?

    How can I found out a site's server type (Apache, IIS, etc.) using PHP?
    The Star Circle Quest Community - Community website for SCQ fans.
    Telebisyon.net - Reference guide to TV series shown in the Philippines.
    Lyrics Server Online! - All the lyrics you can get on one website.

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2004
    Location
    The Netherlands
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe $_SERVER['SERVER_SOFTWARE'] can help you?

  3. #3
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    Q,

    phpinfo();

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  4. #4
    PHP Programmer QReyes's Avatar
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    698
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not mine, others i.e. sitepoint.com, yahoo.com, google.com, cnn.com, etc.
    The Star Circle Quest Community - Community website for SCQ fans.
    Telebisyon.net - Reference guide to TV series shown in the Philippines.
    Lyrics Server Online! - All the lyrics you can get on one website.

  5. #5
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    To my knowledge, there is no sure fire way to do it.
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  6. #6
    PHP Programmer QReyes's Avatar
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    698
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Other sites were able to do it so I assume this is possible. Not sure though if it is possible with PHP.
    The Star Circle Quest Community - Community website for SCQ fans.
    Telebisyon.net - Reference guide to TV series shown in the Philippines.
    Lyrics Server Online! - All the lyrics you can get on one website.

  7. #7
    Put your best practices away. The New Guy's Avatar
    Join Date
    Sep 2002
    Location
    Canada
    Posts
    2,087
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    What other sites?
    "A nerd who gets contacts
    and a trendy hair cut is still a nerd"

    - Stephen Colbert on Apple Users

  8. #8
    PHP Programmer QReyes's Avatar
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    698
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Star Circle Quest Community - Community website for SCQ fans.
    Telebisyon.net - Reference guide to TV series shown in the Philippines.
    Lyrics Server Online! - All the lyrics you can get on one website.

  9. #9
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    with cURL you can retrieve the response header, which may include the server information, by setting CURLOPT_HEADER to 1:

    Code:
    $ch = curl_init("http://www.sitepoint.com/");
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);
    curl_close($ch);
    $regex = '~^Server: (.*)$~m';
    preg_match ($regex, $data, $m);
    echo $m[1];
    will give you "Apache/1.3.33 (Unix) PHP/4.3.10" with the complete header being:

    Code:
    HTTP/1.0 200 OK
    Connection: close
    Content-Type: text/html
    Date: Wed, 04 May 2005 13:55:09 GMT
    Server: Apache/1.3.33 (Unix) PHP/4.3.10
    X-Powered-By: PHP/4.3.10
    X-Accelerated-By: PHPA/1.3.3r2
    Cache-Control: private, max-age=600
    Set-Cookie: SID=db491ba70bc482f0720548d4335c3874; path=/
    Set-Cookie: SPabc=b; expires=Thu, 04-May-2006 13:55:09 GMT; path=/
    Or you may use this web tool: http://web-sniffer.net/
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.

  10. #10
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can do it without curl.

    Use fopen on the URL, then use stream_get_meta_data() while the stream is open. Then close it with fclose.

    stream_get_meta_data() will get the HTTP headers just like kleineme's code above. Handy when you don't have access to curl for some reason.

    Available since PHP 4.3.0.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  11. #11
    PHP Programmer QReyes's Avatar
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    698
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which is better:

    kleineme's method (using cURL)
    mmj's method (using fopen)
    The Star Circle Quest Community - Community website for SCQ fans.
    Telebisyon.net - Reference guide to TV series shown in the Philippines.
    Lyrics Server Online! - All the lyrics you can get on one website.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •