Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Slasharguments test for health center, please test

  • Loading branch information...
commit 39ba6d586aa1af250051a36e0a4452c6208109c6 1 parent dae66d9
skodak authored
Showing with 74 additions and 6 deletions.
  1. +72 −0 admin/health.php
  2. +2 −6 lib/weblib.php
View
72 admin/health.php
@@ -391,6 +391,78 @@ function solution() {
}
}
+class problem_000010 extends problem_base {
+ function title() {
+ return 'Uploaded files: slasharguments disabled or not working';
+ }
+ function exists() {
+ if (!$this->is_enabled()) {
+ return true;
+ }
+ if ($this->status() == 0) {
+ return true;
+ }
+ return false;
+ }
+ function severity() {
+ if ($this->is_enabled() and $this->status() == 0) {
+ return SEVERITY_SIGNIFICANT;
+ } else {
+ return SEVERITY_ANNOYANCE;
+ }
+ }
+ function description() {
+ $desc = 'Slasharguments are needed for relative linking in uploaded resources:<ul>';
+ if (!$this->is_enabled()) {
+ $desc .= '<li>slasharguments are <strong>disabled</strong> in Moodle configuration</li>';
+ } else {
+ $desc .= '<li>slasharguments are enabled in Moodle configuration</li>';
+ }
+ if ($this->status() == 0) {
+ $desc .= '<li>slashargument test <strong>failed</strong>, please check server configuration</li>';
+ } else {
+ $desc .= '<li>slashargument test passed</li>';
+ }
+ $desc .= '</ul>';
+ return $desc;
+ }
+ function solution() {
+ $enabled = $this->is_enabled();
+ $status = $this->status();
+ $solution = '';
+ if ($enabled and ($status == 0)) {
+ $solution .= 'Slasharguments are enabled, but the test failed. Please disable slasharguments in Moodle configuration or fix the server configuration.<hr />';
+ } else if ((!$enabled) and ($status == 0)) {
+ $solution .= 'Slasharguments are disabled and the test failed. You may try to fix the server configuration.<hr />';
+ } else if ((!$enabled) and ($status > 0)) {
+ $solution .= 'Slasharguments are disabled though the iternal test is OK. You should enable slasharguments in Moodle configuration.';
+ } else if ($enabled and ($status > 0)) {
+ $solution .= 'Congratulations - everything seems OK now :-D';
+ }
+ if ($status ==0) {
+ $solution .= '<p>IIS:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li><li>do NOT enable AllowPathInfoForScriptMappings !!!</li><li>slasharguments may not work when using ISAPI and PHP 4.3.10 and older</li></ul></p>';
+ $solution .= '<p>Apache 1:<ul><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
+ $solution .= '<p>Apache 2:<ul><li>you must add <code>AcceptPathInfo on</code> to php.ini or .htaccess</li><li>try to add <code>cgi.fix_pathinfo=1</code> to php.ini</li></ul></p>';
+ }
+ return $solution;
+ }
+ function is_enabled() {
+ global $CFG;
+ return !empty($CFG->slasharguments);
+ }
+ function status() {
+ global $CFG;
+ $handle = @fopen($CFG->wwwroot.'/file.php/test', "r");
+ $contents = trim(@fread($handle, 10));
+ @fclose($handle);
+ switch ($contents) {
+ case '1': return 1;
+ case '2': return 2;
+ default: return 0;
+ }
+ }
+}
+
class problem_00000x extends problem_base {
function title() {
View
8 lib/weblib.php
@@ -810,9 +810,7 @@ function get_file_argument($scriptname) {
if (!strpos($path_info, $scriptname)) {
$relativepath = clean_param(rawurldecode($path_info), PARAM_PATH);
if ($relativepath === '/test') {
- print_header();
- notice ('Slasharguments work - using PATH_INFO parameter :-D');
- print_footer();
+ echo '1'; //indicate ok for health center
die;
}
}
@@ -826,9 +824,7 @@ function get_file_argument($scriptname) {
$path_info = strip_querystring($arr[1]);
$relativepath = clean_param(rawurldecode($path_info), PARAM_PATH);
if ($relativepath === '/test') {
- print_header();
- notice ('Slasharguments work - using compatibility hack :-|');
- print_footer();
+ echo '2'; //indicate ok for health center
die;
}
}

0 comments on commit 39ba6d5

Please sign in to comment.
Something went wrong with that request. Please try again.