Using LOCALE defines, not strings
[moodle.git] / lib / setup.php
CommitLineData
f9903ed0 1<?PHP // $Id$
2//
3// setup.php
4//
5// Sets up sessions, connects to databases and so on
6//
7// Normally this is only called by the main config.php file
8//
9// Normally this file does not need to be edited.
10//
f9903ed0 11//////////////////////////////////////////////////////////////
12
74944b73 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
f9903ed0 15
74944b73 16/// Load up standard libraries
1e3e716f 17
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
22
74944b73 23/// Connect to the database using adodb
1e3e716f 24
25 ADOLoadCode($CFG->dbtype);
26 $db = &ADONewConnection();
27 $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname);
28
ae7aafeb 29/// Set error reporting back to normal
30 error_reporting(7);
31
32
74944b73 33/// Load up any configuration from the config table
34
35 if ($configs = get_records_sql("SELECT * FROM config")) {
36 $CFG = (array)$CFG;
37 foreach ($configs as $config) {
38 $CFG[$config->name] = $config->value;
39 }
40 $CFG = (object)$CFG;
41 unset($configs);
42 unset($config);
43 }
f9903ed0 44
1e3e716f 45
74944b73 46/// Location of standard files
f9903ed0 47
f9903ed0 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";
ca4f8eb8 53 $CFG->moddata = "moddata";
f9903ed0 54
ae7aafeb 55
74944b73 56/// Load up theme variables (colours etc)
1e3e716f 57
74944b73 58 if (!isset($CFG->theme)) {
59 $CFG->theme = "standard";
60 }
1e3e716f 61 require("$CFG->dirroot/theme/$CFG->theme/config.php");
62
ae7aafeb 63
fa0c7d6d 64/// Set language/locale of printed times etc (must be supported by OS)
7a302afc 65
7209909e 66 if (!$CFG->locale) {
67 $CFG->locale = $CFG->lang; // Might work
6df680ca 68 }
8dfc9d0f 69 setlocale (LC_TIME, $CFG->locale);
70 setlocale (LC_CTYPE, $CFG->locale);
71 setlocale (LC_COLLATE, $CFG->locale);
7a302afc 72
0ee8d920 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;
84// }
85// } else { // Array
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;
91// }
92// }
93// }
94// }
95// }
ae7aafeb 96
74944b73 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
b0cb5e22 100
74944b73 101 if (isset($_REQUEST)) {
102 extract($_REQUEST);
103 }
104 if (isset($_SERVER)) {
105 extract($_SERVER);
b0cb5e22 106 }
ae7aafeb 107
f9903ed0 108
74944b73 109/// Load up global environment variables
f9903ed0 110
111 class object {};
112
113 session_start();
8223d271 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
f9903ed0 117
118 $FULLME = qualified_me();
119 $ME = strip_querystring($FULLME);
120
f9903ed0 121
f9903ed0 122?>