2001-11-22 06:23:56 +00:00
|
|
|
<?PHP // $Id$
|
|
|
|
//
|
|
|
|
// setup.php
|
|
|
|
//
|
|
|
|
// Sets up sessions, connects to databases and so on
|
|
|
|
//
|
|
|
|
// Normally this is only called by the main config.php file
|
|
|
|
//
|
|
|
|
// Normally this file does not need to be edited.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// If there are any errors in the standard libraries we want to know!
|
2003-01-01 06:40:31 +00:00
|
|
|
error_reporting(E_ALL);
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-12-07 07:27:58 +00:00
|
|
|
/// Connect to the database using adodb
|
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
|
2003-01-02 11:34:00 +00:00
|
|
|
|
|
|
|
$db = &ADONewConnection($CFG->dbtype);
|
|
|
|
|
2002-12-07 07:27:58 +00:00
|
|
|
if (! $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname)) {
|
|
|
|
echo "<P><FONT COLOR=RED>The database details specified in config.php are not correct, or the database is down.</P>";
|
|
|
|
die;
|
|
|
|
}
|
|
|
|
|
2003-01-01 09:29:05 +00:00
|
|
|
if (!isset($CFG->prefix)) { // Just in case it isn't defined in config.php
|
|
|
|
$CFG->prefix = "";
|
|
|
|
}
|
2003-01-02 15:12:34 +00:00
|
|
|
//$CFG->prefix = "$CFG->dbname.$CFG->prefix";
|
2003-01-01 09:29:05 +00:00
|
|
|
|
|
|
|
|
2002-12-07 07:27:58 +00:00
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// Load up standard libraries
|
2002-08-17 13:01:06 +00:00
|
|
|
|
2003-01-05 14:19:20 +00:00
|
|
|
require_once("$CFG->libdir/weblib.php"); // Functions for producing HTML
|
|
|
|
require_once("$CFG->libdir/datalib.php"); // Functions for accessing databases
|
|
|
|
require_once("$CFG->libdir/moodlelib.php"); // Other general-purpose functions
|
2002-08-17 13:01:06 +00:00
|
|
|
|
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// Load up any configuration from the config table
|
|
|
|
|
2002-12-20 14:44:14 +00:00
|
|
|
if ($configs = get_records("config")) {
|
2002-09-19 12:01:55 +00:00
|
|
|
$CFG = (array)$CFG;
|
|
|
|
foreach ($configs as $config) {
|
|
|
|
$CFG[$config->name] = $config->value;
|
|
|
|
}
|
|
|
|
$CFG = (object)$CFG;
|
|
|
|
unset($configs);
|
|
|
|
unset($config);
|
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-08-17 13:01:06 +00:00
|
|
|
|
2002-12-30 03:24:07 +00:00
|
|
|
/// Set error reporting back to normal
|
2003-01-01 08:48:15 +00:00
|
|
|
if (empty($CFG->debug)) {
|
|
|
|
$CFG->debug = 7;
|
|
|
|
}
|
2002-12-30 03:24:07 +00:00
|
|
|
error_reporting($CFG->debug);
|
|
|
|
|
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// Location of standard files
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
$CFG->wordlist = "$CFG->libdir/wordlist.txt";
|
|
|
|
$CFG->javascript = "$CFG->libdir/javascript.php";
|
2002-08-28 13:07:10 +00:00
|
|
|
$CFG->moddata = "moddata";
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-09-19 14:07:24 +00:00
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// Load up theme variables (colours etc)
|
2002-08-17 13:01:06 +00:00
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
if (!isset($CFG->theme)) {
|
|
|
|
$CFG->theme = "standard";
|
|
|
|
}
|
2002-12-13 03:15:28 +00:00
|
|
|
include("$CFG->dirroot/theme/$CFG->theme/config.php");
|
2002-08-17 13:01:06 +00:00
|
|
|
|
2002-12-10 13:37:37 +00:00
|
|
|
$CFG->stylesheet = "$CFG->wwwroot/theme/$CFG->theme/styles.php";
|
|
|
|
$CFG->header = "$CFG->dirroot/theme/$CFG->theme/header.html";
|
|
|
|
$CFG->footer = "$CFG->dirroot/theme/$CFG->theme/footer.html";
|
|
|
|
|
2002-09-19 14:07:24 +00:00
|
|
|
|
2002-07-02 07:02:28 +00:00
|
|
|
|
2002-10-26 02:31:49 +00:00
|
|
|
/// Reference code to remove magic quotes from everything ... just in case.
|
|
|
|
/// If you have problems with slashes everywhere then you might want to
|
|
|
|
/// uncomment this code. It will not be necessary on 99.9% of PHP servers.
|
|
|
|
/// Got this from http://www.php.net/manual/en/configuration.php
|
|
|
|
// if (ini_get("magic_quotes_gpc") ) {
|
|
|
|
// foreach ($GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"] as $key => $value) {
|
|
|
|
// if (!is_array($value)) { // Simple value
|
|
|
|
// $newval = stripslashes($value);
|
|
|
|
// $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key] = $newval;
|
|
|
|
// if (ini_get("register_globals")) {
|
|
|
|
// $GLOBALS[$key] = $newval;
|
|
|
|
// }
|
|
|
|
// } else { // Array
|
|
|
|
// foreach ($value as $k => $v) {
|
|
|
|
// $newval = stripslashes($v);
|
|
|
|
// $GLOBALS["HTTP_".$GLOBALS["REQUEST_METHOD"]."_VARS"][$key][$k] = $newval;
|
|
|
|
// if (ini_get("register_globals")) {
|
|
|
|
// $GLOBALS[$key][$k] = $newval;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2002-09-19 14:07:24 +00:00
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// The following is a 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
|
2002-08-23 02:14:19 +00:00
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
if (isset($_REQUEST)) {
|
|
|
|
extract($_REQUEST);
|
|
|
|
}
|
|
|
|
if (isset($_SERVER)) {
|
|
|
|
extract($_SERVER);
|
2002-08-23 02:14:19 +00:00
|
|
|
}
|
2002-09-19 14:07:24 +00:00
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-09-19 12:01:55 +00:00
|
|
|
/// Load up global environment variables
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
class object {};
|
|
|
|
|
|
|
|
session_start();
|
2002-08-06 17:23:45 +00:00
|
|
|
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
|
2001-11-22 06:23:56 +00:00
|
|
|
|
2002-12-29 04:17:32 +00:00
|
|
|
if (isset($FULLME)) {
|
|
|
|
$ME = $FULLME;
|
|
|
|
} else {
|
2002-12-20 14:44:14 +00:00
|
|
|
$FULLME = qualified_me();
|
2002-12-29 04:17:32 +00:00
|
|
|
$ME = strip_querystring($FULLME);
|
2002-12-20 14:44:14 +00:00
|
|
|
}
|
2001-11-22 06:23:56 +00:00
|
|
|
|
|
|
|
|
2002-12-08 17:26:21 +00:00
|
|
|
/// Set language/locale of printed times. If user has chosen a language that
|
|
|
|
/// that is different from the site language, then use the locale specified
|
|
|
|
/// in the language file. Otherwise, if the admin hasn't specified a locale
|
|
|
|
/// then use the one from the default language. Otherwise (and this is the
|
|
|
|
/// majority of cases), use the stored locale specified by admin.
|
|
|
|
|
2002-12-29 17:32:32 +00:00
|
|
|
if (!empty($USER->lang) and ($USER->lang != $CFG->lang) ) {
|
2002-12-08 17:26:21 +00:00
|
|
|
$CFG->locale = get_string("locale");
|
2002-12-29 17:32:32 +00:00
|
|
|
} else if (empty($CFG->locale)) {
|
2002-12-08 17:26:21 +00:00
|
|
|
$CFG->locale = get_string("locale");
|
|
|
|
set_config("locale", $CFG->locale); // cache it to save lookups in future
|
|
|
|
}
|
|
|
|
setlocale (LC_TIME, $CFG->locale);
|
|
|
|
setlocale (LC_CTYPE, $CFG->locale);
|
|
|
|
setlocale (LC_COLLATE, $CFG->locale);
|
|
|
|
|
2001-11-22 06:23:56 +00:00
|
|
|
?>
|