]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10275 added fatal PHP config setting test on each page, replaces some tests done...
authorskodak <skodak>
Sun, 1 Feb 2009 13:37:42 +0000 (13:37 +0000)
committerskodak <skodak>
Sun, 1 Feb 2009 13:37:42 +0000 (13:37 +0000)
admin/index.php
lang/en_utf8/admin.php
lib/adminlib.php
lib/setup.php
lib/setuplib.php

index 6400fb399cb88afbd474714a5fe3baa7f58cbd39..2419c3ede14bc7845442e7a7f22063ad7642a02b 100644 (file)
@@ -8,9 +8,9 @@
 
 /// Check that PHP is of a sufficient version
 /// Moved here because older versions do not allow while(@ob_end_clean());
-    if (version_compare(phpversion(), "5.2.4") < 0) {
+    if (version_compare(phpversion(), "5.2.8") < 0) {
         $phpversion = phpversion();
-        echo "Sorry, Moodle requires PHP 5.2.4 or later (currently using version $phpversion)";
+        echo "Sorry, Moodle requires PHP 5.2.8 or later (currently using version $phpversion)";
         die;
     }
 
 
 /// setup critical warnings before printing admin tree block
     $insecuredataroot         = is_dataroot_insecure(true);
-    $register_globals_enabled = ini_get_bool('register_globals');
 
-    $SESSION->admin_critical_warning = ($register_globals_enabled || $insecuredataroot==INSECURE_DATAROOT_ERROR);
+    $SESSION->admin_critical_warning = ($insecuredataroot==INSECURE_DATAROOT_ERROR);
 
     $adminroot = admin_get_root();
 
         print_box(get_string("upgrade$CFG->upgrade", "admin", "$CFG->wwwroot/$CFG->admin/upgrade$CFG->upgrade.php"));
     }
 
-    if ($register_globals_enabled) {
-        print_box(get_string('globalswarning', 'admin'), 'generalbox adminerror');
-    }
-
     if ($insecuredataroot == INSECURE_DATAROOT_WARNING) {
         print_box(get_string('datarootsecuritywarning', 'admin', $CFG->dataroot), 'generalbox adminwarning');
     } else if ($insecuredataroot == INSECURE_DATAROOT_ERROR) {
index a8937cbe7e33a5dc052d2586b8e4e8c63b4d0487..9ceadd5f446d346cd3f7c5e3638e1a32eeee5572 100644 (file)
@@ -396,6 +396,8 @@ $string['experimental'] = 'Experimental';
 $string['experimentalsettings'] = 'Experimental settings';
 $string['extendedusernamechars'] = 'Allow extended characters in usernames';
 $string['extrauserselectorfields'] = 'When selecting users, search and display';
+$string['fatalsessionautostart'] = '<p>Serious configuration error detected, please notify server administrator.<p><p> To operate properly, Moodle requires that administrator changes PHP settings.</p><p><code>session.auto_start</code> must be set to <code>off</code>.</p><p>This setting is controlled by editing <code>php.ini</code>, Apache/IIS <br />configuration or <code>.htaccess</code> file on the server.</p>';
+$string['fatalmagicquotesruntime'] = '<p>Serious configuration error detected, please notify server administrator.<p><p> To operate properly, Moodle requires that administrator changes PHP settings.</p><p><code>magic_quotes_runtime</code> must be set to <code>off</code>.</p><p>This setting is controlled by editing <code>php.ini</code>, Apache/IIS <br />configuration or <code>.htaccess</code> file on the server.</p>';
 $string['filecreated'] = 'New file created';
 $string['filestoredin'] = 'Save file into folder :';
 $string['filestoredinhelp'] = 'Where the file will be stored';
index 874c3b49196cf3d81ec36ab61715983e20b29e86..8ce7df206c5e14fff311a2da5d42c12f21b575ae 100644 (file)
@@ -244,9 +244,7 @@ function admin_critical_warnings_present() {
 
     if (!isset($SESSION->admin_critical_warning)) {
         $SESSION->admin_critical_warning = 0;
-        if (ini_get_bool('register_globals')) {
-            $SESSION->admin_critical_warning = 1;
-        } else if (is_dataroot_insecure(true) === INSECURE_DATAROOT_ERROR) {
+        if (is_dataroot_insecure(true) === INSECURE_DATAROOT_ERROR) {
             $SESSION->admin_critical_warning = 1;
         }
     }
index 84d303e033a50ae651d40de1098b2d2a32a8981f..12cbb1eee2ecb757302b78c741a7b8364d05b868 100644 (file)
@@ -86,12 +86,6 @@ global $FULLSCRIPT;
 /** Relative moodle script path "/course/view.php" */
 global $SCRIPT;
 
-/// First try to detect some attacks on older buggy PHP versions
-    if (isset($_REQUEST['GLOBALS']) || isset($_COOKIE['GLOBALS']) || isset($_FILES['GLOBALS'])) {
-        die('Fatal: Illegal GLOBALS overwrite attempt detected!');
-    }
-
-
     if (!isset($CFG->wwwroot)) {
         trigger_error('Fatal: $CFG->wwwroot is not configured! Exiting.');
         die;
@@ -170,6 +164,9 @@ global $SCRIPT;
 /// set handler for uncought exceptions - equivalent to print_error() call
     set_exception_handler('default_exception_handler');
 
+/// make sure PHP is not severly misconfigured
+    setup_validate_php_configuration();
+
 /// Connect to the database
     setup_DB();
 
index d5def40508e76be42e5d2159705471edb3750295..fd92ed0c797ff1956ec7d9fc8698634054671b92 100644 (file)
@@ -84,6 +84,24 @@ function default_exception_handler($ex) {
     }
 }
 
+/**
+ * This function verifies the sanity of PHP configuration
+ * and stops execution if anything critical found.
+ */
+function setup_validate_php_configuration() {
+   // this must be very fast - no slow checks here!!!
+
+   if (ini_get_bool('register_globals')) {
+       print_error('globalswarning', 'admin');
+   }
+   if (ini_get_bool('session.auto_start')) {
+       print_error('sessionautostartwarning', 'admin');
+   }
+   if (ini_get_bool('magic_quotes_runtime')) {
+       print_error('fatalmagicquotesruntime', 'admin');
+   }
+}
+
 /**
  * Initialises $FULLME and friends.
  * @return void