healthcenter fixes - new extra whitespace detection, fixed automatic slasharguments detection; merged from MOODLE_16_STABLE

This commit is contained in:
skodak 2006-07-05 07:44:20 +00:00
parent 8ab2baa8f3
commit 9bbb40d631
3 changed files with 23 additions and 18 deletions

View 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;

View 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")) {

View 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;
}
}