]> git.mjollnir.org Git - moodle.git/commitdiff
Slight improvements to import of global variables
authormoodler <moodler>
Mon, 26 May 2003 15:38:52 +0000 (15:38 +0000)
committermoodler <moodler>
Mon, 26 May 2003 15:38:52 +0000 (15:38 +0000)
  - don't globalise cookies
  - better checking of lang variables

lib/setup.php

index 7063a576a47c1356dd6cff20332b91fc4a10588b..89f4f88d6db26850a2e425ae43ec3b9851ce0250 100644 (file)
@@ -82,7 +82,7 @@
     if (empty($CFG->debug)) {
         $CFG->debug = 7;
     }
-    error_reporting($CFG->debug);   
+    error_reporting($CFG->debug);
 
 
 /// File permissions on created directories in the $CFG->dataroot
 /// that have "register_globals" turned off (default since PHP 4.1.0).
 /// Eventually I'll go through and upgrade all the code to make this unnecessary
 
-    if (isset($_REQUEST)) {
-        if (isset($_REQUEST['CFG'])) {
-            unset($_REQUEST['CFG']);  // We don't want to overwrite $CFG!
-        }
-        extract($_REQUEST);
+    if (isset($_GET)) {
+        extract($_GET, EXTR_SKIP);    // Skip existing variables, ie CFG
+    }
+    if (isset($_POST)) {
+        extract($_POST, EXTR_SKIP);   // Skip existing variables, ie CFG
     }
     if (isset($_SERVER)) { 
         extract($_SERVER);
 /// then use the one from the default language.  Otherwise (and this is the 
 /// majority of cases), use the stored locale specified by admin.
 
-    if (isset($lang)) {
+    if (isset($_GET['lang'])) {
         $SESSION->lang = $lang;
     }
-
+    if (empty($CFG->lang)) {
+        $CFG->lang = "en";
+    }
     if (!empty($SESSION->lang) and ($SESSION->lang != $CFG->lang) ) {
         $CFG->locale = get_string("locale");
     } else if (!empty($USER->lang) and ($USER->lang != $CFG->lang) ) {