cvs: docweb /scripts checkent.php
| From: | Nuno Lopes | Date: | Wed, 19 Jan 2005 20:38:33 +0000 |
| Subject: | cvs: docweb /scripts checkent.php | ||
| Groups: | php.doc.web | ||
| Request: | Send a blank email to doc-web+get-495@lists.php.net to get a copy of this message | ||
nlopess Wed Jan 19 15:38:33 2005 EDT
Modified files:
/docweb/scripts checkent.php
Log:
add support for https, non-default ports, URLs with ?querys.
Also print supported protocols
http://cvs.php.net/diff.php/docweb/scripts/checkent.php?r1=1.4&r2=1.5&ty=u
Index: docweb/scripts/checkent.php
diff -u docweb/scripts/checkent.php:1.4 docweb/scripts/checkent.php:1.5
--- docweb/scripts/checkent.php:1.4 Wed Jan 19 12:13:58 2005
+++ docweb/scripts/checkent.php Wed Jan 19 15:38:33 2005
@@ -18,7 +18,7 @@
* | Docweb port: Nuno Lopes <nlopess@php.net> |
* | Mehdi Achour <didou@php.net> |
* +----------------------------------------------------------------------+
- * $Id: checkent.php,v 1.4 2005/01/19 17:13:58 nlopess Exp $
+ * $Id: checkent.php,v 1.5 2005/01/19 20:38:33 nlopess Exp $
*/
set_time_limit(0);
@@ -33,6 +33,10 @@
$schemes[] = 'ftp';
}
+if (extension_loaded('openssl')) {
+ $schemes[] = 'https';
+}
+
// constants for errors
define('UNKNOWN_HOST', 0);
define('FTP_CONNECT', 1);
@@ -79,9 +83,27 @@
switch($url['scheme']) {
case 'http':
- $url['path'] = isset($url['path']) ? $url['path'] :
'/';
+ case 'https':
+
+ if (isset($parsed_url['path'])) {
+ $url['path'] = $url['path'] . (isset($url['query']) ?
'?' . $url['query'] : '');
+ } else {
+ $url['path'] = '/';
+ }
+
+ /* check if using secure http */
+ if ($url['scheme'] == 'https') {
+ $port = 443;
+ $scheme = 'ssl://';
+ } else {
+ $port = 80;
+ $scheme = '';
+ }
+
+ $port = isset($url['port']) ? $url['port'] : $port;
+
- if (!$fp = @fsockopen($url['host'], 80, $errno, $errstr, 30)) {
+ if (!$fp = @fsockopen($scheme . $url['host'], $port)) {
$errors[HTTP_CONNECT][] = array($num);
} else {
@@ -89,7 +111,7 @@
$str = '';
while (!feof($fp)) {
- $str .= fgets($fp, 2048);
+ $str .= @fgets($fp, 2048);
}
fclose ($fp);
@@ -151,7 +173,8 @@
// ouput the html
echo "<?php include_once '../include/init.inc.php';
echo site_header('docweb.common.header.checkent');
-?><p>Last check: " . date('r') . "</p>";
+?><p>Last check: " . date('r') . "<br/>
+Supported Protocols: " . implode(', ', $schemes) .
'</p><p> </p>';
if (isset($errors[UNKNOWN_HOST])) {
echo '<h2>Unknown host (' . count($errors[UNKNOWN_HOST]) .
')</h2>' .