Hei wrote:
> Can I use PHP to check server software???

you can use curl, see the func below. needs the php-curl libary enabled.

phil.

<title>showHeader - lese HTTP Header Antwort des entfernten Servers</title>
<form action="<?php echo $PHP_SELF ?>">
<input type="text" name="url" value="<?php echo $url ?>" style="width:300px;">
<input type="submit" name="submit" value="showHeader">
</form>

<pre>
<?php

include_once("getHttpHeader.php");

if ($url == "" || ereg("^[ ]{1,}$",$url)) // string leer oder aus nur einem 
oder mehreren leerzeichen  // url ungesetzt oder nur leerzeichen
{
        echo "<p>... waiting for url</p>";
        exit;
}
else
{
        echo "<p><b>$url</b><br />returned the following header:</p>";
        echo getHttpHeader($url);
}
?>
</pre>

-----------------------------

<?php

function getHttpHeader($url) {
        
        ob_start(); // send all output to a buffer instead of being displayed
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL, $url);
        #curl_setopt($ch, CURLOPT_USERPWD, $user.":".$password);
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_NOBODY, 1);
        #curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "HEAD / HTTP/1.0");
        
        curl_exec($ch);
        curl_close ($ch);
        
        $header = ob_get_contents(); // put all buffered output into $header
        ob_end_clean();
        
        return $header;
}

?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to