cvs: phpweb / mirror-info.php
| From: | Hannes Magnusson | Date: | Mon, 21 Apr 2008 11:10:54 +0000 |
| Subject: | cvs: phpweb / mirror-info.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-1583@lists.php.net to get a copy of this message | ||
bjori Mon Apr 21 11:10:54 2008 UTC
Modified files:
/phpweb mirror-info.php
Log:
Add self-testing
# Will use this for the mirror-test script once mirrors sync
http://cvs.php.net/viewvc.cgi/phpweb/mirror-info.php?r1=1.22&r2=1.23&diff_format=u
Index: phpweb/mirror-info.php
diff -u phpweb/mirror-info.php:1.22 phpweb/mirror-info.php:1.23
--- phpweb/mirror-info.php:1.22 Thu Mar 29 18:24:31 2007
+++ phpweb/mirror-info.php Mon Apr 21 11:10:54 2008
@@ -1,5 +1,5 @@
<?php
-// $Id: mirror-info.php,v 1.22 2007/03/29 18:24:31 bjori Exp $
+// $Id: mirror-info.php,v 1.23 2008/04/21 11:10:54 bjori Exp $
// Define $MYSITE and $LAST_UPDATED variables
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
@@ -20,6 +20,21 @@
// Does this mirror have sqlite?
$sqlite = (int) function_exists("sqlite_open");
+if (isset($_GET["token"]) && md5($_GET["token"]) ===
"19a3ec370affe2d899755f005e5cd90e") {
+ $retval = run_self_tests();
+ $output = isset($_GET["output"]) ? $_GET["output"] : "php";
+ switch($output) {
+ case "human":
+ var_dump($retval);
+ break;
+
+ case "php":
+ default:
+ echo serialize($retval);
+ }
+ exit(0);
+}
+
echo join('|', array(
$MYSITE, // 0: ServerName problems
phpversion(), // 1: PHP version overview
@@ -30,3 +45,56 @@
'manual-noalias', // 6: /manual alias check is done elsewhere now
$md5_ok, // 7: Rsync setup problems
));
+
+function run_self_tests() {
+ global $MYSITE;
+ global $LAST_UPDATED, $sqlite, $mirror_stats, $md5_ok;
+
+ $content = fetch_contents($MYSITE . "manual/noalias.txt");
+ if (trim($content) !== 'manual-noalias') {
+ return array(
+ "name" => "Apache manual alias",
+ "see" => $MYSITE . "mirroring-troubles.php#manual-redirect",
+ );
+ }
+
+ $ctype = fetch_header($MYSITE . "manual/en/faq.html.php", "content-type");
+ if (strpos($ctype, "text/html") === false) {
+ return array(
+ "name" => "Header weirdness. Pages named '.html.php' are returning
wrong status headers",
+ "see" => $MYSITE . "mirroring-troubles.php#content-type",
+ );
+ }
+
+ $ctype = fetch_header($MYSITE . "functions", "content-type");
+ if (is_array($ctype)) {
+ $ctype = current($ctype);
+ }
+ if (strpos($ctype, "text/html") === false) {
+ return array(
+ "name" => "MultiViews on",
+ "see" => $MYSITE . "mirroring-troubles.php#multiviews"
+ );
+ }
+
+ $header = fetch_header($MYSITE . "manual/en/ref.var.php", 0);
+ list($ver, $status, $msg) = explode(" ", $header, 3);
+ if($status != 200) {
+ return array(
+ "name" => "Var Handler",
+ "see" => $MYSITE . "mirroring-troubles.php#var",
+ );
+ }
+
+ return array(
+ "servername" => $MYSITE,
+ "version" => phpversion(),
+ "updated" => $LAST_UPDATED,
+ "sqlite" => $sqlite,
+ "stats" => $mirror_stats,
+ "language" => default_language(),
+ "rsync" => $md5_ok,
+ );
+
+}
+