5 // Sets up sessions, connects to databases and so on
7 // Normally this is only called by the main config.php file
9 // Normally this file does not need to be edited.
11 //////////////////////////////////////////////////////////////
13 /// If there are any errors in the standard libraries we want to know!
14 error_reporting(15); // use 0=none 7=normal 15=all
16 /// Load up standard libraries
18 require("$CFG->libdir/weblib.php"); // Standard web page functions
19 require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
20 require("$CFG->libdir/adodb/tohtml.inc.php");// Database display functions
21 require("$CFG->libdir/moodlelib.php"); // Various Moodle functions
23 /// Connect to the database using adodb
25 ADOLoadCode($CFG->dbtype);
26 $db = &ADONewConnection();
27 $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
29 /// Set error reporting back to normal
33 /// Load up any configuration from the config table
35 if ($configs = get_records_sql("SELECT * FROM config")) {
37 foreach ($configs as $config) {
38 $CFG[$config->name] = $config->value;
46 /// Location of standard files
48 $CFG->wordlist = "$CFG->libdir/wordlist.txt";
49 $CFG->javascript = "$CFG->libdir/javascript.php";
50 $CFG->stylesheet = "$CFG->wwwroot/theme/$CFG->theme/styles.css";
51 $CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html";
52 $CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html";
53 $CFG->moddata = "moddata";
56 /// Load up theme variables (colours etc)
58 if (!isset($CFG->theme)) {
59 $CFG->theme = "standard";
61 require("$CFG->dirroot/theme/$CFG->theme/config.php");
64 /// Set language/locale of printed times etc (must be supported by OS)
67 $CFG->locale = $CFG->lang; // Might work
69 setlocale (LC_TIME, $CFG->locale);
70 setlocale (LC_CTYPE, $CFG->locale);
71 setlocale (LC_COLLATE, $CFG->locale);
73 /// Reference code to remove magic quotes from everything ... just in case.
74 /// If you have problems with slashes everywhere then you might want to
75 /// uncomment this code. It will not be necessary on 99.9% of PHP servers.
76 /// Got this from http://www.php.net/manual/en/configuration.php
77 // if (ini_get("magic_quotes_gpc") ) {
78 // foreach ($GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"] as $key => $value) {
79 // if (!is_array($value)) { // Simple value
80 // $newval = stripslashes($value);
81 // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key] = $newval;
82 // if (ini_get("register_globals")) {
83 // $GLOBALS[$key] = $newval;
86 // foreach ($value as $k => $v) {
87 // $newval = stripslashes($v);
88 // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key][$k] = $newval;
89 // if (ini_get("register_globals")) {
90 // $GLOBALS[$key][$k] = $newval;
97 /// The following is a hack to get around the problem of PHP installations
98 /// that have "register_globals" turned off (default since PHP 4.1.0).
99 /// Eventually I'll go through and upgrade all the code to make this unnecessary
101 if (isset($_REQUEST)) {
104 if (isset($_SERVER)) {
109 /// Load up global environment variables
114 if (! isset($_SESSION["SESSION"])) { $_SESSION["SESSION"] = new object; }
115 if (! isset($_SESSION["USER"])) { $_SESSION["USER"] = new object; }
116 extract($_SESSION); // Makes $SESSION and $USER available for read-only access
118 $FULLME = qualified_me();
119 $ME = strip_querystring($FULLME);