Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 141 lines (108 sloc) 4.822 kB
f9903ed Initial revision
martin authored
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 //
11 //////////////////////////////////////////////////////////////
12
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
13 /// If there are any errors in the standard libraries we want to know!
346b1a2 Tweaks
moodler authored
14 error_reporting(E_ALL);
f9903ed Initial revision
martin authored
15
a8a7184 If the database doesn't work then just die before anything else
moodler authored
16 /// Connect to the database using adodb
17
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>";
23 die;
24 }
25
26
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
27 /// Load up standard libraries
1e3e716 Changes related to new way of setting and recalling themes.
martin authored
28
9fa49e2 Many many changes lumped in here ... not finished yet either.
moodler authored
29 require("$CFG->libdir/weblib.php"); // Functions for producing HTML
30 require("$CFG->libdir/datalib.php"); // Functions for accessing databases
31 require("$CFG->libdir/moodlelib.php"); // Other general-purpose functions
1e3e716 Changes related to new way of setting and recalling themes.
martin authored
32
33
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
34 /// Load up any configuration from the config table
35
9fa49e2 Many many changes lumped in here ... not finished yet either.
moodler authored
36 if ($configs = get_records("config")) {
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
37 $CFG = (array)$CFG;
38 foreach ($configs as $config) {
39 $CFG[$config->name] = $config->value;
40 }
41 $CFG = (object)$CFG;
42 unset($configs);
43 unset($config);
44 }
f9903ed Initial revision
martin authored
45
1e3e716 Changes related to new way of setting and recalling themes.
martin authored
46
4fd7ccc New "debug" variable to turn debugging on and off
moodler authored
47 /// Set error reporting back to normal
48 error_reporting($CFG->debug);
49
50
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
51 /// Location of standard files
f9903ed Initial revision
martin authored
52
53 $CFG->wordlist = "$CFG->libdir/wordlist.txt";
54 $CFG->javascript = "$CFG->libdir/javascript.php";
ca4f8eb Moved uploaded assignment files into a subdirectory called moddata,
martin authored
55 $CFG->moddata = "moddata";
f9903ed Initial revision
martin authored
56
ae7aafe Got rid of errorlevel configuration - more trouble than it's worth!
martin authored
57
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
58 /// Load up theme variables (colours etc)
1e3e716 Changes related to new way of setting and recalling themes.
martin authored
59
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
60 if (!isset($CFG->theme)) {
61 $CFG->theme = "standard";
62 }
45f21f9 config.php not required ... just in case themes move or something ...
moodler authored
63 include("$CFG->dirroot/theme/$CFG->theme/config.php");
1e3e716 Changes related to new way of setting and recalling themes.
martin authored
64
e6f10ec Theme not working for brand-new setup.
moodler authored
65 $CFG->stylesheet = "$CFG->wwwroot/theme/$CFG->theme/styles.php";
66 $CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html";
67 $CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html";
68
ae7aafe Got rid of errorlevel configuration - more trouble than it's worth!
martin authored
69
7a302af Slight changes to userdate() function. It now uses gmstrftime() inst…
martin authored
70
0ee8d92 Added some commented-out code that MIGHT help people with string slas…
moodler authored
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;
82 // }
83 // } else { // Array
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;
89 // }
90 // }
91 // }
92 // }
93 // }
ae7aafe Got rid of errorlevel configuration - more trouble than it's worth!
martin authored
94
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
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
b0cb5e2 Check that PHP is a recent enough version (ie 4.1.0 or later)
martin authored
98
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
99 if (isset($_REQUEST)) {
100 extract($_REQUEST);
101 }
102 if (isset($_SERVER)) {
103 extract($_SERVER);
b0cb5e2 Check that PHP is a recent enough version (ie 4.1.0 or later)
martin authored
104 }
ae7aafe Got rid of errorlevel configuration - more trouble than it's worth!
martin authored
105
f9903ed Initial revision
martin authored
106
74944b7 Most of the configuration variables have been moved out of the config…
martin authored
107 /// Load up global environment variables
f9903ed Initial revision
martin authored
108
109 class object {};
110
111 session_start();
8223d27 Widespread changes throughout Moodle to make sure it works on
martin authored
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
f9903ed Initial revision
martin authored
115
9d37873 More little fixes
moodler authored
116 if (isset($FULLME)) {
117 $ME = $FULLME;
118 } else {
9fa49e2 Many many changes lumped in here ... not finished yet either.
moodler authored
119 $FULLME = qualified_me();
9d37873 More little fixes
moodler authored
120 $ME = strip_querystring($FULLME);
9fa49e2 Many many changes lumped in here ... not finished yet either.
moodler authored
121 }
f9903ed Initial revision
martin authored
122
123
339bb55 New code to use locale information from language packs if necessary
moodler authored
124 /// Set language/locale of printed times. If user has chosen a language that
125 /// that is different from the site language, then use the locale specified
126 /// in the language file. Otherwise, if the admin hasn't specified a locale
127 /// then use the one from the default language. Otherwise (and this is the
128 /// majority of cases), use the stored locale specified by admin.
129
9c9f7d7 Various little fixes to remove warnings (usually about empty variables)
moodler authored
130 if (!empty($USER->lang) and ($USER->lang != $CFG->lang) ) {
339bb55 New code to use locale information from language packs if necessary
moodler authored
131 $CFG->locale = get_string("locale");
9c9f7d7 Various little fixes to remove warnings (usually about empty variables)
moodler authored
132 } else if (empty($CFG->locale)) {
339bb55 New code to use locale information from language packs if necessary
moodler authored
133 $CFG->locale = get_string("locale");
134 set_config("locale", $CFG->locale); // cache it to save lookups in future
135 }
136 setlocale (LC_TIME, $CFG->locale);
137 setlocale (LC_CTYPE, $CFG->locale);
138 setlocale (LC_COLLATE, $CFG->locale);
139
f9903ed Initial revision
martin authored
140 ?>
Something went wrong with that request. Please try again.