Widespread changes throughout Moodle to make sure it works on
servers that have register_globals turned off (this is the
default setting on newer version of PHP).
In fact it's partly a hack that globalises all GET, POST, FILES
AND COOKIE variables. Unfortunately though the SESSION and
USER global session variables are only available as $_SESSION["USER"]
and $_SESSION["SESSION"], which is cumbersome to use.
So, for every request I now make a copy of these two session variables
into $USER and $SESSION. Whenever I update them thoughout Moodle I
now have to call save_session("USER") which copies them back to the
session variable. This seems to be working well now.
Because I'm using $_SESSION etc now this will raise
the required minimum version of PHP to 4.1.0
This commit is contained in:
+15
-5
@@ -38,6 +38,17 @@
|
||||
setlocale ("LC_TIME", $CFG->lang);
|
||||
}
|
||||
|
||||
// The following is a big hack to get around the problem of PHP installations
|
||||
// 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)) {
|
||||
extract($_REQUEST);
|
||||
}
|
||||
if (isset($_SERVER)) {
|
||||
extract($_SERVER);
|
||||
}
|
||||
|
||||
// Load up theme variables (colours etc)
|
||||
|
||||
require("$CFG->dirroot/theme/$CFG->theme/config.php");
|
||||
@@ -49,16 +60,16 @@
|
||||
require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
|
||||
require("$CFG->libdir/adodb/tohtml.inc.php");// Database display functions
|
||||
require("$CFG->libdir/moodlelib.php"); // Various Moodle functions
|
||||
|
||||
|
||||
// Load up global environment variables
|
||||
|
||||
class object {};
|
||||
|
||||
session_start();
|
||||
session_register("SESSION"); // Current session info
|
||||
session_register("USER"); // Current user info
|
||||
if (! isset($SESSION)) $SESSION = new object;
|
||||
if (! isset($USER)) $USER = new object;
|
||||
if (! isset($_SESSION["SESSION"])) { $_SESSION["SESSION"] = new object; }
|
||||
if (! isset($_SESSION["USER"])) { $_SESSION["USER"] = new object; }
|
||||
extract($_SESSION); // Makes $SESSION and $USER available for read-only access
|
||||
|
||||
$FULLME = qualified_me();
|
||||
$ME = strip_querystring($FULLME);
|
||||
@@ -70,5 +81,4 @@
|
||||
$db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user