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 /// Connect to the database using adodb
18 require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
19 ADOLoadCode($CFG->dbtype
);
20 $db = &ADONewConnection();
21 if (! $db->PConnect($CFG->dbhost
,$CFG->dbuser
,$CFG->dbpass
,$CFG->dbname
)) {
22 echo "<P><FONT COLOR=RED>The database details specified in config.php are not correct, or the database is down.</P>";
27 /// Load up standard libraries
29 if (!isset($external_moodle_access)) { // See lib/makeclass.php
30 require("$CFG->libdir/weblib.php"); // Standard web page functions
31 require("$CFG->libdir/moodlelib.php"); // Various Moodle functions
35 /// Set error reporting back to normal
39 /// Load up any configuration from the config table
41 if ($configs = get_records_sql("SELECT * FROM config")) {
43 foreach ($configs as $config) {
44 $CFG[$config->name
] = $config->value
;
52 /// Location of standard files
54 $CFG->wordlist
= "$CFG->libdir/wordlist.txt";
55 $CFG->javascript
= "$CFG->libdir/javascript.php";
56 $CFG->stylesheet
= "$CFG->wwwroot/theme/$CFG->theme/styles.php";
57 $CFG->header
= "$CFG->dirroot/theme/$CFG->theme/header.html";
58 $CFG->footer
= "$CFG->dirroot/theme/$CFG->theme/footer.html";
59 $CFG->moddata
= "moddata";
62 /// Load up theme variables (colours etc)
64 if (!isset($CFG->theme
)) {
65 $CFG->theme
= "standard";
67 require("$CFG->dirroot/theme/$CFG->theme/config.php");
71 /// Reference code to remove magic quotes from everything ... just in case.
72 /// If you have problems with slashes everywhere then you might want to
73 /// uncomment this code. It will not be necessary on 99.9% of PHP servers.
74 /// Got this from http://www.php.net/manual/en/configuration.php
75 // if (ini_get("magic_quotes_gpc") ) {
76 // foreach ($GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"] as $key => $value) {
77 // if (!is_array($value)) { // Simple value
78 // $newval = stripslashes($value);
79 // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key] = $newval;
80 // if (ini_get("register_globals")) {
81 // $GLOBALS[$key] = $newval;
84 // foreach ($value as $k => $v) {
85 // $newval = stripslashes($v);
86 // $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key][$k] = $newval;
87 // if (ini_get("register_globals")) {
88 // $GLOBALS[$key][$k] = $newval;
95 /// The following is a hack to get around the problem of PHP installations
96 /// that have "register_globals" turned off (default since PHP 4.1.0).
97 /// Eventually I'll go through and upgrade all the code to make this unnecessary
99 if (isset($_REQUEST)) {
102 if (isset($_SERVER)) {
107 /// Load up global environment variables
112 if (! isset($_SESSION["SESSION"])) { $_SESSION["SESSION"] = new object; }
113 if (! isset($_SESSION["USER"])) { $_SESSION["USER"] = new object; }
114 extract($_SESSION); // Makes $SESSION and $USER available for read-only access
116 $FULLME = qualified_me();
117 $ME = strip_querystring($FULLME);
120 /// Set language/locale of printed times. If user has chosen a language that
121 /// that is different from the site language, then use the locale specified
122 /// in the language file. Otherwise, if the admin hasn't specified a locale
123 /// then use the one from the default language. Otherwise (and this is the
124 /// majority of cases), use the stored locale specified by admin.
126 if ($USER->lang
and ($USER->lang
!= $CFG->lang
) ) {
127 $CFG->locale
= get_string("locale");
128 } else if (!$CFG->locale
) {
129 $CFG->locale
= get_string("locale");
130 set_config("locale", $CFG->locale
); // cache it to save lookups in future
132 setlocale (LC_TIME
, $CFG->locale
);
133 setlocale (LC_CTYPE
, $CFG->locale
);
134 setlocale (LC_COLLATE
, $CFG->locale
);