]> git.mjollnir.org Git - moodle.git/commitdiff
healthcenter fixes - new extra whitespace detection, fixed automatic slasharguments...
authorskodak <skodak>
Wed, 5 Jul 2006 07:44:20 +0000 (07:44 +0000)
committerskodak <skodak>
Wed, 5 Jul 2006 07:44:20 +0000 (07:44 +0000)
admin/health.php
lib/setup.php
lib/weblib.php

index e0ef7cab05be61cb78be4f0ab2157168c2fef674..b2211d3963dc2f82aeeb7b944ccb890259f77bc5 100644 (file)
@@ -1,7 +1,17 @@
 <?php  // $Id$
 
+    ob_start(); //for whitespace test
     require_once('../config.php');
 
+       // extra whitespace test - intentionally breaks cookieless mode
+       $extraws = '';
+    while (true) {
+        $extraws .= ob_get_contents();
+        if (!@ob_end_clean()) { //
+            break;
+        }
+    }
+
     define('SEVERITY_NOTICE',      'notice');
     define('SEVERITY_ANNOYANCE',   'annoyance');
     define('SEVERITY_SIGNIFICANT', 'significant');
@@ -217,18 +227,13 @@ class problem_000001 extends problem_base {
 
 class problem_000002 extends problem_base {
     function title() {
-        return 'Extra characters at the end of config.php';
+        return 'Extra characters at the end of config.php or other library function';
     }
     function exists() {
-        // [pj] When the requirements are raised to PHP 4.3.0 this will be file_get_contents()
-        if($fp = @fopen('../config.php', 'r')) {
-            $contents = fread($fp, 16384); // 16K should be enough
-            $ending = substr($contents, -2);
-            unset($contents);
-            if($ending == '?>') {
-                return false;
-            }
-            fclose($fp);
+        global $extraws;
+
+        if($extraws === '') {
+            return false;
         }
         return true;
     }
@@ -236,11 +241,11 @@ class problem_000002 extends problem_base {
         return SEVERITY_SIGNIFICANT;
     }
     function description() {
-        return 'Your Moodle configuration file, config.php, contains some characters after the closing PHP tag (?>). This could cause Moodle to exhibit several kinds of problems and should be fixed.';
+        return 'Your Moodle configuration file config.php or another library file, contains some characters after the closing PHP tag (?>). This causes Moodle to exhibit several kinds of problems (such as broken downloaded files) and must be fixed.';
     }
     function solution() {
         global $CFG;
-        return 'You need to edit <strong>'.$CFG->dirroot.'/config.php</strong> and remove all characters (including spaces and returns) after the ending ?> tag. These two characters should be the very last in that file.';
+        return 'You need to edit <strong>'.$CFG->dirroot.'/config.php</strong> and remove all characters (including spaces and returns) after the ending ?> tag. These two characters should be the very last in that file. The extra trailing whitespace may be also present in other PHP files that are included from lib/setup.php.';
     }
 }
 
@@ -463,13 +468,13 @@ class problem_000010 extends problem_base {
     function status() {
         global $CFG;
         $handle = @fopen($CFG->wwwroot.'/file.php?file=/testslasharguments', "r");
-        $contents = trim(@fread($handle, 7));
+        $contents = @trim(fread($handle, 10));
         @fclose($handle);
         if ($contents != 'test -1') {
             return -1;
         }
         $handle = @fopen($CFG->wwwroot.'/file.php/testslasharguments', "r");
-        $contents = trim(@fread($handle, 6));
+        $contents = trim(@fread($handle, 10));
         @fclose($handle);
         switch ($contents) {
             case 'test 1': return 1;
index 120bf33e7a9c802d3494b44be6989ab92ff9be9b..2558bd1c8a523f02499ae244e9a5153b55fa9cf4 100644 (file)
@@ -534,7 +534,7 @@ $CFG->os = PHP_OS;
     }
 
     if ($CFG->theme == 'standard' or $CFG->theme == 'standardwhite') {    // Temporary measure to help with XHTML validation
-        if (empty($_SESSION['USER']->id)) {      // Allow W3CValidator in as user called w3cvalidator (or guest)
+        if (isset($_SERVER['HTTP_USER_AGENT']) and empty($_SESSION['USER']->id)) {      // Allow W3CValidator in as user called w3cvalidator (or guest)
             if ((strpos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') !== false) or
                 (strpos($_SERVER['HTTP_USER_AGENT'], 'Cynthia') !== false )) {
                 if ($USER = get_complete_user_data("username", "w3cvalidator")) {
index da51dd0a4ef1d59c320c14a8df6649d82f9f779b..56a3d5b7b50fbbf2c9c92ab79e9216af20cbeb3f 100644 (file)
@@ -1085,7 +1085,7 @@ function get_file_argument($scriptname) {
     // first try normal parameter (compatible method == no relative links!)
     $relativepath = optional_param('file', FALSE, PARAM_PATH);
     if ($relativepath === '/testslasharguments') {
-        echo 'test -1: Incorrect use - try "file.php/testslasharguments" instead'; //indicate fopen/fread works for health center
+        echo 'test -1      : Incorrect use - try "file.php/testslasharguments" instead'; //indicate fopen/fread works for health center
         die;
     }
 
@@ -1096,7 +1096,7 @@ function get_file_argument($scriptname) {
         if (!strpos($path_info, $scriptname)) {
             $relativepath = clean_param(rawurldecode($path_info), PARAM_PATH);
             if ($relativepath === '/testslasharguments') {
-                echo 'test 1: Slasharguments test passed. Server confguration is compatible with file.php/1/pic.jpg slashargument setting.'; //indicate ok for health center
+                echo 'test 1      : Slasharguments test passed. Server confguration is compatible with file.php/1/pic.jpg slashargument setting.'; //indicate ok for health center
                 die;
             }
         }
@@ -1110,7 +1110,7 @@ function get_file_argument($scriptname) {
             $path_info = strip_querystring($arr[1]);
             $relativepath = clean_param(rawurldecode($path_info), PARAM_PATH);
             if ($relativepath === '/testslasharguments') {
-                echo 'test 2:Slasharguments test passed (compatibility hack). Server confguration may be compatible with file.php/1/pic.jpg slashargument setting'; //indicate ok for health center
+                echo 'test 2      : Slasharguments test passed (compatibility hack). Server confguration may be compatible with file.php/1/pic.jpg slashargument setting'; //indicate ok for health center
                 die;
             }
         }