/** initialise the program, setup database, read configuration, etc. * @return void */ function initialise() { if (!defined('E_NONE')) { /** consistency in PHPs defined error levels requires E_NONE too, imho */ define('E_NONE', 0); } if (!function_exists('microtime')) { /** Kludge for environments without microtime() * @return string microseconds always 0.0 and current timestamp (seconds) */ function microtime() { return "0.0 " . time(); } } /** This global keeps track of the script performance * * We record the start time of the script execution as soon as we are able to. * When all is said and done, we can do calculations about elapsed time, etc.. * @global object $PERFORMANCE */ global $PERFORMANCE; $PERFORMANCE = new stdClass(); $PERFORMANCE->time_start = microtime(); /** This global variable holds all configuration parameters * * The following essential parameters are defined in /config.php * (see {@link config-example.php} for more information): * * - $CFG->db_type defines the database type. * - $CFG->db_server defines the name of the database server. * - $CFG->db_username holds the username to use when connecting to the server. * - $CFG->db_password holds the password to use when connecting to the server. * - $CFG->db_name holds the name of the database to use. * - $CFG->prefix holds the tablename prefix. * - $CFG->dir is the absolute directory path of 'index.php' and 'config.php'. * - $CFG->www is the URI which corresponds with the directory $CFG->dir. * - $CFG->progdir is the absolute path to the program directory * - $CFG->progwww is the URI which corresponds with the directory $CFG->progdir. * - $CFG->datadir is the absolute path to a private directory outside the document root. * * There is one optional parameter than can be specified in /config.php: * * - $CFG->debug is a parameter to switch debugging ON * * Two additional parameters are derived from $CFG->www and $CFG->progwww * (see {@link calculate_uri_shortcuts()} for more information): * * - $CFG->www_short (uri without scheme/authority when identical with progwww) * - $CFG->progwww_short (uri without scheme/authority when identical with www) * * All other configuration parameters are retrieved from the database. * * @global object $CFG */ global $CFG; /** this global object is associated with the logged in user * * @global object $USER */ global $USER; /* keep error messages to ourselves; don't leak information while not debugging */ error_reporting(E_NONE); if (!isset($CFG->debug)) { $CFG->debug = FALSE; } if ($CFG->debug) { error_reporting(E_ALL); } /** 'version.php' defines internal and external version numbers */ require_once $CFG->progdir . '/version.php'; /** 'utf8lib.php' contains essential routines for manipulating UTF-8 string */ require_once $CFG->progdir . '/lib/utf8lib.php'; /** the name of the script (entrypoint) that is currently running (see {@link wasentry_script_name()}) */ global $WAS_SCRIPT_NAME; $WAS_SCRIPT_NAME = wasentry_script_name(WASENTRY); /** This global object is used to access the database * * @global object $DB */ global $DB; /** Manufacture an object of the database class corresponding with '$CFG->db_type' */ include_once $CFG->progdir . '/lib/database/databaselib.php'; $DB = database_factory($CFG->prefix, $CFG->db_type); if ($DB === FALSE) { error_exit('020'); } if (!$DB->connect($CFG->db_server, $CFG->db_username, $CFG->db_password, $CFG->db_name)) { trigger_error($DB->errno . '/' . $DB->error); error_exit('030'); } /* Trying to get rid of the magic (see also magic_unquote()) asap, ie. before reading from database */ if (ini_get('magic_quotes_sybase') == 1) { error_exit('060'); } if (get_magic_quotes_runtime() == 1) { set_magic_quotes_runtime(0); } /** utility routines, including shortcuts for database manupulation */ require_once $CFG->progdir . '/lib/waslib.php'; /** utility routines for generating HTML-code */ require_once $CFG->progdir . '/lib/htmllib.php'; /** utility routines for generating HTML-dialogs */ require_once $CFG->progdir . '/lib/dialoglib.php'; /* retrieve all configuration settings from the database, including the internal database version */ $properties = get_properties(); if ($properties !== FALSE) { foreach ($properties as $name => $value) { if (!isset($CFG->{$name})) { $CFG->{$name} = $value; } } unset($name); unset($value); } else { $CFG->version = '?'; } unset($properties); // Maybe calculate a shortcut for 'www' and 'progwww' (needed in appropriate_legal_notices() called in error_exit()) list($CFG->www_short, $CFG->progwww_short) = calculate_uri_shortcuts($CFG->www, $CFG->progwww); /** this global array holds all valid and active languages * * @global object $LANGUAGE; */ global $LANGUAGE; /** Load the code for the global LANGUAGE object */ include_once $CFG->progdir . '/lib/language.class.php'; $LANGUAGE = new Language(); }
/** perform the actual initialisation of the cms * * this routine initialises the database: creates tables, * inserts essential data (first user account, other defaults) * and optional demonstration data. * * The strategy is as follows. * * - (1) manufacture a database object in the global $DB * - (2A) create the main tables (from /program/install/tabledefs.php) * - (2B) insert essential data (from /program/install/tabledata.php) * - (2C) store the collected data (website title, etc.), * - (3) if necessary, create the data directory * - (4) record the currently available languages in the database * - (5) create the first useraccount, * * Once the main part is done, install modules and themes based on the * relevant information that is stored in the corresponding manifest-file * by performing the following steps for each module and theme: * * - (6A) insert a record in the appropriate table with active = FALSE * - (6B) create the tables (if any tables are necessary according to the manifest) * - (6C) install the item by including a file and executing function <item>_install() * - (6D) flip the active flag in the record from step 5A to indicate success * * Subsequently the optional demodata is installed. * * - (7A) a foundation is created via the function demodata() from /program/install/demodata.php * - (7B) all modules + themes can add to the demo data via the appropriate subroutines * * If all goes well, this routine ends with an attempt to * * - (8) save the config.php file at the correct location. * (it is not an error if that does not work; it only * means that the user has to upload the config.php * file manually. * * @return bool TRUE on success, FALSE otherwise + messages in $this->messages[] * @todo should we save the config.php to the datadir if the main dir fails? Mmmm.... security implications? * @todo this routine badly needs refactoring */ function perform_installation() { global $DB; $retval = TRUE; // assume success // 0 -- do we have sane values at this point? If not, send user back to correct data if (!$this->check_validation()) { return FALSE; } // 1 -- try to create $DB /** Manufacture an object of the database class corresponding with requested db_type */ include_once dirname(__FILE__) . '/lib/database/databaselib.php'; $DB = database_factory($_SESSION['INSTALL']['db_prefix'], $_SESSION['INSTALL']['db_type']); if ($DB === FALSE) { // internal error, shouldn't happen (we already checked the database access a few dialogs ago) $this->messages[] = 'Internal error: cannot create database object'; return FALSE; } if (!@$DB->connect($_SESSION['INSTALL']['db_server'], $_SESSION['INSTALL']['db_username'], $_SESSION['INSTALL']['db_password'], $_SESSION['INSTALL']['db_name'])) { $this->messages[] = $this->t('error_db_cannot_connect') . ' (' . $DB->errno . '/\'' . $DB->error . '\')'; return FALSE; } // At this point we have a working database in our hands in the global $DB. // 2A -- create the main tables if (!$this->create_tables(dirname(__FILE__) . '/install/tabledefs.php')) { $retval = FALSE; } // 2B -- enter essential data in main tables (defaults etc.) if (!$this->insert_tabledata(dirname(__FILE__) . '/install/tabledata.php')) { $retval = FALSE; } // 2C -- enter additional configuration data to tables $config_updates = array('version' => $_SESSION['INSTALL']['WAS_VERSION'], 'salt' => $this->quasi_random_string(rand(22, 42), 62), 'title' => $_SESSION['INSTALL']['cms_title'], 'website_from_address' => $_SESSION['INSTALL']['cms_website_from_address'], 'website_replyto_address' => $_SESSION['INSTALL']['cms_website_replyto_address'], 'language_key' => $_SESSION['INSTALL']['language_key'], 'friendly_url' => $_SESSION['INSTALL']['friendly_url'] ? '1' : '0', 'clamscan_path' => $_SESSION['INSTALL']['clamscan_path'], 'clamscan_mandatory' => $_SESSION['INSTALL']['clamscan_mandatory'] ? '1' : '0'); foreach ($config_updates as $name => $value) { $where = array('name' => $name); $fields = array('value' => strval($value)); if (db_update('config', $fields, $where) === FALSE) { $params = array('{CONFIG}' => $name, '{ERRNO}' => $DB->errno, '{ERROR}' => $DB->error); $this->messages[] = $this->t('error_update_config', $params); $retval = FALSE; } } // 3A -- maybe create dataroot $dataroot = $_SESSION['INSTALL']['cms_dataroot']; if (!is_dir($dataroot)) { // dataroot does not exist, try to create it if (!@mkdir($dataroot, 0700)) { $params = array('{FIELD}' => $this->t('cms_datadir_label'), '{DIRECTORY}' => htmlspecialchars($dataroot)); $this->messages[] = $this->t('error_not_create_dir', $params); $retval = FALSE; } // else { success creating $dataroot } } // else { nothing to do; we already tested for directory writability // 3B -- "protect" the datadirectory with a blank index.html @touch($dataroot . '/index.html'); // 3C -- setup our REAL datadirectory $subdirectory = $_SESSION['INSTALL']['cms_datasubdir']; if (empty($subdirectory)) { $subdirectory = md5($_SESSION['INSTALL']['cms_dir'] . $_SESSION['INSTALL']['cms_www'] . $this->quasi_random_string(13, 62) . $_SESSION['INSTALL']['cms_progdir'] . $_SESSION['INSTALL']['cms_progwww'] . $_SESSION['INSTALL']['cms_title'] . strval(time())); $datadir = $dataroot . '/' . $subdirectory; $params = array('{FIELD}' => $this->t('cms_datadir_label'), '{DIRECTORY}' => htmlspecialchars($datadir)); if (is_dir($datadir)) { $this->messages[] = $this->t('error_directory_exists', $params); $retval = FALSE; } elseif (!@mkdir($datadir, 0700)) { $this->messages[] = $this->t('error_not_create_dir', $params); $retval = FALSE; } else { $_SESSION['INSTALL']['cms_datasubdir'] = $subdirectory; } } // If the user changed $dataroot after a 1st failed attempt, // $subdirectory may not yet exist, we doublecheck and maybe mkdir $datadir = $dataroot . '/' . $subdirectory; if (!is_dir($datadir)) { if (!@mkdir($datadir, 0700)) { $params = array('{FIELD}' => $this->t('cms_datadir_label'), '{DIRECTORY}' => htmlspecialchars($datadir)); $this->messages[] = $this->t('error_not_create_dir', $params); $retval = FALSE; } } $_SESSION['INSTALL']['cms_datadir'] = $datadir; // construct_config_php() needs this @touch($datadir . '/index.html'); // "protect" directory // 3D -- setup essential subdirectories under our REAL datadirectory $datadir_subdirectories = array($datadir . '/areas', $datadir . '/users', $datadir . '/groups', $datadir . '/languages'); foreach ($datadir_subdirectories as $datadir_subdirectory) { if (!is_dir($datadir_subdirectory) && !@mkdir($datadir_subdirectory, 0700)) { $params = array('{FIELD}' => $this->t('cms_datadir_label'), '{DIRECTORY}' => htmlspecialchars($datadir_subdirectory)); $this->messages[] = $this->t('error_not_create_dir', $params); $retval = FALSE; } @touch($datadir_subdirectory . '/index.html'); // "protect" directory } // 4 -- languages: only add entry to table, no tabledefs or installer here $datadir_languages = $datadir . '/languages'; $languages = $this->get_manifests(dirname(__FILE__) . '/languages'); foreach ($languages as $language_key => $manifest) { $language_key = strval($language_key); if (!is_dir($datadir_languages . '/' . $language_key) && !@mkdir($datadir_languages . '/' . $language_key, 0700)) { $params = array('{FIELD}' => $this->t('cms_datadir_label'), '{DIRECTORY}' => htmlspecialchars($datadir_languages . '/' . $language_key)); $this->messages[] = $this->t('error_not_create_dir', $params); $retval = FALSE; } @touch($datadir_languages . '/' . $language_key . '/index.html'); // "protect" directory $table = 'languages'; $fields = array('language_key' => $language_key, 'language_name' => isset($manifest['language_name']) ? strval($manifest['language_name']) : '(' . $language_key . ')', 'parent_language_key' => isset($manifest['parent_language_key']) ? strval($manifest['parent_language_key']) : '', 'version' => intval($manifest['version']), 'manifest' => $manifest['manifest'], 'is_core' => isset($manifest['is_core']) && $manifest['is_core'] ? TRUE : FALSE, 'is_active' => TRUE, 'dialect_in_database' => FALSE, 'dialect_in_file' => FALSE); if (db_insert_into($table, $fields) === FALSE) { // This shouldn't happen in a freshly created database. However, try to continue with the next $params = array('{TABLENAME}' => $DB->prefix . $table, '{ERRNO}' => $DB->errno, '{ERROR}' => $DB->error); $this->messages[] = $this->t('error_insert_into_table', $params); $retval = FALSE; continue; } } // 5 -- insert the first user account // 5A -- construct acl with all privileges for this main (root) user $table = 'acls'; $key_field = 'acl_id'; $fields = array('permissions_jobs' => -1, 'permissions_intranet' => -1, 'permissions_modules' => -1, 'permissions_nodes' => -1); $acl_id = db_insert_into_and_get_id($table, $fields, $key_field); if ($acl_id === FALSE) { // This shouldn't happen in a freshly created database. $params = array('{TABLENAME}' => $DB->prefix . $table, '{ERRNO}' => $DB->errno, '{ERROR}' => $DB->error); $this->messages[] = $this->t('error_insert_into_table', $params); return FALSE; } // 5B -- create a personal datadirectory (based on the specified username) $username = $_SESSION['INSTALL']['user_username']; $userdata_directory = utf8_strtolower($this->sanitise_filename($username)); // If the username consists of only non-mappable UTF-8 chars, we end up with '_'; make that more readable... if ($userdata_directory == '_') { $userdata_directory = '_webmaster'; } $datadir_subdirectory = $datadir . '/users/' . $userdata_directory; if (!is_dir($datadir_subdirectory) && !@mkdir($datadir_subdirectory, 0700)) { $params = array('{FIELD}' => $this->t('cms_datadir_label'), '{DIRECTORY}' => htmlspecialchars($datadir_subdirectory)); $this->messages[] = $this->t('error_not_create_dir', $params); $retval = FALSE; } @touch($datadir_subdirectory . '/index.html'); // "protect" directory // 5C -- actually create the record in the users table $salt = $this->quasi_random_string(12, 62); // pick 12 characters from [0-9][A-Z][a-z] $table = 'users'; $key_field = 'user_id'; $fields = array('username' => $username, 'salt' => $salt, 'password_hash' => md5($salt . $_SESSION['INSTALL']['user_password']), 'full_name' => $_SESSION['INSTALL']['user_full_name'], 'email' => $_SESSION['INSTALL']['user_email'], 'is_active' => TRUE, 'redirect' => '', 'language_key' => $_SESSION['INSTALL']['language_key'], 'path' => $userdata_directory, 'acl_id' => intval($acl_id), 'editor' => 'ckeditor', 'skin' => $_SESSION['INSTALL']['high_visibility'] ? 'textonly' : 'base'); $user_id = db_insert_into_and_get_id($table, $fields, $key_field); if ($user_id === FALSE) { $params = array('{TABLENAME}' => $DB->prefix . $table, '{ERRNO}' => $DB->errno, '{ERROR}' => $DB->error); $this->messages[] = $this->t('error_insert_into_table', $params); $retval = FALSE; } // 6 -- install modules and themes $subsystems = array('modules' => $this->get_manifests(dirname(__FILE__) . '/modules'), 'themes' => $this->get_manifests(dirname(__FILE__) . '/themes')); foreach ($subsystems as $subsystem => $manifests) { foreach ($manifests as $item => $manifest) { if (empty($manifest)) { $this->messages[] = $this->t('warning_no_manifest', array('{ITEM}' => $item)); continue; } // 6A -- prepare entry in the corresponding table switch ($subsystem) { case 'modules': $fields = array('name' => strval($item), 'version' => intval($manifest['version']), 'manifest' => $manifest['manifest'], 'is_core' => isset($manifest['is_core']) && $manifest['is_core'] ? TRUE : FALSE, 'is_active' => FALSE, 'has_acls' => isset($manifest['has_acls']) && $manifest['has_acls'] ? TRUE : FALSE, 'view_script' => isset($manifest['view_script']) ? $manifest['view_script'] : NULL, 'admin_script' => isset($manifest['admin_script']) ? $manifest['admin_script'] : NULL, 'search_script' => isset($manifest['search_script']) ? $manifest['search_script'] : NULL, 'cron_script' => isset($manifest['cron_script']) ? $manifest['cron_script'] : NULL, 'cron_interval' => isset($manifest['cron_interval']) ? intval($manifest['cron_interval']) : NULL, 'cron_next' => NULL); $key_field = 'module_id'; $table = 'modules'; break; case 'themes': $fields = array('name' => strval($item), 'version' => intval($manifest['version']), 'manifest' => $manifest['manifest'], 'is_core' => isset($manifest['is_core']) && $manifest['is_core'] ? TRUE : FALSE, 'is_active' => FALSE, 'class' => isset($manifest['class']) ? $manifest['class'] : NULL, 'class_file' => isset($manifest['class_file']) ? $manifest['class_file'] : NULL); $key_field = 'theme_id'; $table = 'themes'; break; default: $this->messages[] = 'Internal error: unknown subsystem ' . htmlspecialchars($subsystem); continue; break; } if (($item_id = db_insert_into_and_get_id($table, $fields, $key_field)) === FALSE) { // This shouldn't happen in a freshly created database. However, try to continue with the next $params = array('{TABLENAME}' => $DB->prefix . $table, '{ERRNO}' => $DB->errno, '{ERROR}' => $DB->error); $this->messages[] = $this->t('error_insert_into_table', $params); $retval = FALSE; continue; } $is_active = TRUE; // assume we can successfully install the item // 6B -- maybe insert tables for item if (isset($manifest['tabledefs']) && !empty($manifest['tabledefs'])) { $filename = dirname(__FILE__) . '/' . $subsystem . '/' . $item . '/' . $manifest['tabledefs']; if (file_exists($filename)) { if (!$this->create_tables($filename)) { $retval = FALSE; $is_active = FALSE; } } } // 6C -- maybe install this module or theme if (isset($manifest['install_script']) && !empty($manifest['install_script'])) { $filename = dirname(__FILE__) . '/' . $subsystem . '/' . $item . '/' . $manifest['install_script']; if (file_exists($filename)) { @(include_once $filename); $item_install = $item . '_install'; if (function_exists($item_install)) { if (!$item_install($this->messages, $item_id)) { $retval = FALSE; $is_active = FALSE; } } } } // 6D -- indicate everything went well if ($is_active) { $where = array($key_field => $item_id); $fields = array('is_active' => $is_active); if (db_update($table, $fields, $where) === FALSE) { $params = array('{CONFIG}' => $item, '{ERRNO}' => $DB->errno, '{ERROR}' => $DB->error); $this->messages[] = $this->t('error_update_config', $params); $retval = FALSE; $is_active = FALSE; // this should not happen (famous last words...) } } $subsystems[$subsystem][$item]['is_active'] = $is_active; $subsystems[$subsystem][$item]['key_field'] = $key_field; $subsystems[$subsystem][$item]['item_id'] = $item_id; } // foreach item } // foreach subsystem // 7 -- Demodata if ($_SESSION['INSTALL']['cms_demodata']) { // 7A -- prepare essential information for demodata installation $demodata_config = array('language_key' => $_SESSION['INSTALL']['language_key'], 'dir' => $_SESSION['INSTALL']['cms_dir'], 'www' => $_SESSION['INSTALL']['cms_www'], 'progdir' => $_SESSION['INSTALL']['cms_progdir'], 'progwww' => $_SESSION['INSTALL']['cms_progwww'], 'datadir' => $_SESSION['INSTALL']['cms_datadir'], 'title' => $_SESSION['INSTALL']['cms_title'], 'replyto' => $_SESSION['INSTALL']['cms_website_replyto_address'], 'user_username' => $_SESSION['INSTALL']['user_username'], 'user_full_name' => $_SESSION['INSTALL']['user_full_name'], 'user_email' => $_SESSION['INSTALL']['user_email'], 'user_id' => $user_id, 'demo_salt' => $_SESSION['INSTALL']['cms_demodata_salt'], 'demo_password' => $_SESSION['INSTALL']['cms_demodata_password'], 'friendly_url' => $_SESSION['INSTALL']['friendly_url'], 'demo_areas' => array(), 'demo_groups' => array(), 'demo_users' => array(), 'demo_nodes' => array()); $filename = dirname(__FILE__) . '/install/demodata.php'; include_once $filename; if (!demodata($this->messages, $demodata_config)) { $this->messages[] = $this->t('error_install_demodata'); $retval = FALSE; } // 7B -- insert demodata for all modules and themes foreach ($subsystems as $subsystem => $manifests) { foreach ($manifests as $item => $manifest) { $item_demodata = $item . '_demodata'; if (function_exists($item_demodata)) { if (!$item_demodata($this->messages, intval($manifest['item_id']), $demodata_config, $manifest)) { $this->messages[] = $this->t('error_install_demodata'); $retval = FALSE; } } } } } // 8 -- Finish with attempt to write config.php if ($retval) { $_SESSION['INSTALL']['config_php_written'] = $this->write_config_php(); } return $retval; }
/** * Load a config file from another local Moodle instance and set the database * values in the $CFG global and initializing the new ADODB database connection. * * @uses $CFG * @uses $CURMAN * @uses $db * @param string $file The full system path to the config.php file. * @param bool $justroot Just get and set the wwwroot value, don't actually reset the * global DB connection or load the alternate config options. * @return object bool True on sucess, false otherwise. */ function moodle_load_config($file, $justroot = false) { global $CFG, $CURMAN, $db; $return = false; if (file_exists($file) && ($fp = fopen($file, 'r'))) { //print_object($file); while ($line = fgets($fp)) { if ($line[0] != '$') { continue; } $regex = "/^\$CFG->[a-z]+|= '(.+|)';/"; $parts = preg_split($regex, $line, -1, PREG_SPLIT_DELIM_CAPTURE); if (count($parts) < 2) { continue; } $arg = trim($parts[0]); $val = trim($parts[1]); if ($justroot) { if ($arg == '$CFG->wwwroot') { return $val; } } else { if ($arg == '$CFG->dbtype') { $CFG->dbtype = $val; } else { if ($arg == '$CFG->dbhost') { $CFG->dbhost = $val; } else { if ($arg == '$CFG->dbname') { $CFG->dbname = $val; } else { if ($arg == '$CFG->dbuser') { $CFG->dbuser = $val; } else { if ($arg == '$CFG->dbpass') { $CFG->dbpass = $val; } else { if ($arg == '$CFG->dbpersist') { $CFG->dbpersist = $val == 'true' ? true : false; } else { if ($arg == '$CFG->prefix') { $CFG->prefix = $val; } } } } } } } } } /* print_object('$CFG->dbtype: ' . $CFG->dbtype); print_object('$CFG->dbhost: ' . $CFG->dbhost); print_object('$CFG->dbname: ' . $CFG->dbname); print_object('$CFG->dbuser: '******'$CFG->dbpersist: ' . $CFG->dbpersist); print_object('$CFG->prefix: ' . $CFG->prefix); */ require_once $CFG->libdir . '/adodb/adodb.inc.php'; /// Initialize the new DB connection. $db->Disconnect(); unset($db); $db =& ADONewConnection($CFG->dbtype); if (!isset($CFG->dbpersist) or !empty($CFG->dbpersist)) { // Use persistent connection (default) $dbconnected = $db->PConnect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); } else { // Use single connection $dbconnected = $db->Connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname); } /// Save the new global objects. if ($dbconnected) { $GLOBALS['CFG'] = $CFG; $GLOBALS['db'] = $db; $CURMAN->db = database_factory(CURMAN_APPPLATFORM); $CURMAN->db = database_factory('airtran'); $GLOBALS['CURMAN'] = $CURMAN; $return = true; } } return $return; }
} define('CURMAN_UDB_DBHOST', $CFG->dbhost); if (!empty($CFG->dbuser)) { define('CURMAN_UDB_DBUSER', $CFG->dbuser); } if (!empty($CFG->dbpass)) { define('CURMAN_UDB_DBPASS', $CFG->dbpass); } } else { /// Other application-specific setup: /// Define where this file is (non-Moodle installations) define('CURMAN_DIRLOCATION', '/root/where/this/is/located'); } require_once CURMAN_DIRLOCATION . '/lib/lib.php'; require_once CURMAN_DIRLOCATION . '/lib/data.class.php'; global $CURMAN; // To be safe... Never sure what context this may be included in. $CURMAN = new stdClass(); /// Setup database connections: //$CURMAN->db = database_factory('wr'); //$CURMAN->db->prefix = ''; //$CURMAN->db = NULL; $CURMAN->db = database_factory(CURMAN_APPPLATFORM); define('CMCONFIGTABLE', 'crlm_config'); $CURMAN->config = new stdClass(); /// Override any config settings. /// e.g. $CURMAN->config->textpassword = 1; require_once dirname(__FILE__) . '/version.php'; /// Load all configuration variable/structures. $CURMAN->config = cm_load_config(); cm_add_config_defaults();