Re: Can I use PHP to check server software????

From: Date: Thu, 28 Feb 2002 11:01:15 +0000
Subject: Re: Can I use PHP to check server software????
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-86564@lists.php.net to get a copy of this message
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; } ?>

« previous php.general (#86564) next »