Exemple #1
0
/**
 * Boots the engine
 *
 * 1. sets error handlers
 * 2. connects to database
 * 3. verifies the installation suceeded
 * 4. loads application configuration
 * 5. loads site configuration
 *
 * @access private
 */
function _elgg_engine_boot()
{
    // Register the error handlers
    set_error_handler('_elgg_php_error_handler');
    set_exception_handler('_elgg_php_exception_handler');
    register_translations(dirname(dirname(dirname(__FILE__))) . "/languages/");
    setup_db_connections();
    verify_installation();
    _elgg_load_application_config();
    _elgg_load_site_config();
    _elgg_load_cache();
}
Exemple #2
0
/**
 * Boots the engine
 *
 * 1. sets error handlers
 * 2. connects to database
 * 3. verifies the installation succeeded
 * 4. loads application configuration
 * 5. loads i18n data
 * 6. loads cached autoloader state
 * 7. loads site configuration
 *
 * @access private
 */
function _elgg_engine_boot()
{
    // Register the error handlers
    set_error_handler('_elgg_php_error_handler');
    set_exception_handler('_elgg_php_exception_handler');
    setup_db_connections();
    verify_installation();
    _elgg_load_application_config();
    _elgg_load_autoload_cache();
    _elgg_load_site_config();
    _elgg_session_boot();
    _elgg_load_cache();
    _elgg_load_translations();
}
Exemple #3
0
if (!(include_once dirname(__FILE__) . "/settings.php")) {
    $msg = elgg_echo('InstallationException:CannotLoadSettings');
    throw new InstallationException($msg);
}
// load the rest of the library files from engine/lib/
$lib_files = array('database.php', 'actions.php', 'admin.php', 'annotations.php', 'calendar.php', 'configuration.php', 'cron.php', 'entities.php', 'export.php', 'extender.php', 'filestore.php', 'group.php', 'location.php', 'mb_wrapper.php', 'memcache.php', 'metadata.php', 'metastrings.php', 'navigation.php', 'notification.php', 'objects.php', 'opendd.php', 'pagehandler.php', 'pageowner.php', 'pam.php', 'plugins.php', 'private_settings.php', 'relationships.php', 'river.php', 'sites.php', 'statistics.php', 'tags.php', 'user_settings.php', 'users.php', 'upgrade.php', 'web_services.php', 'widgets.php', 'xml.php', 'xml-rpc.php', 'deprecated-1.7.php', 'deprecated-1.8.php');
foreach ($lib_files as $file) {
    $file = $lib_dir . $file;
    elgg_log("Loading {$file}...");
    if (!(include_once $file)) {
        $msg = sprintf(elgg_echo('InstallationException:MissingLibrary'), $file);
        throw new InstallationException($msg);
    }
}
// confirm that the installation completed successfully
verify_installation();
// Autodetect some default configuration settings
set_default_config();
// needs to be set for links in html head
$viewtype = get_input('view', 'default');
$lastcached = datalist_get("simplecache_lastcached_{$viewtype}");
$CONFIG->lastcache = $lastcached;
// Trigger boot events for core. Plugins can't hook
// into this because they haven't been loaded yet.
elgg_trigger_event('boot', 'system');
// Load the plugins that are active
elgg_load_plugins();
elgg_trigger_event('plugins_boot', 'system');
// Trigger system init event for plugins
elgg_trigger_event('init', 'system');
// Regenerate the simple cache if expired.
Exemple #4
0
/**
 * Load config options from config.inc.php and database and
 * setup sane defaults.
 * Return configuration in global $config array variable
 *
 * @todo    Add security check if install.php is still available
 * @param   boolean force reload of configuration data
 */
function load_config($force_reload = false)
{
    global $config, $lang, $smarty;
    // configuration cached and not outdated?
    if (!$force_reload && !$config['recompile'] && session_get('config') && session_get('config_userid') === $_COOKIE['VDBuserid'] && session_get('config_timestamp') == filemtime(CONFIG_FILE)) {
        // load from cache
        $config = session_get('config');
    } else {
        // check MySQL extension and cache directories
        verify_installation();
        // remember modification time
        session_set('config_timestamp', filemtime(CONFIG_FILE));
        // get config options from the database
        $SELECT = 'SELECT opt,value
                     FROM ' . TBL_CONFIG;
        $result = runSQL($SELECT);
        $config = array_merge($config, array_associate($result, 'opt', 'value'));
        // check if database matches the current version
        if ($config['dbversion'] < DB_REQUIRED) {
            // run installer
            redirect('install.php?action=upgrade');
        }
        // get user config options from the database
        // does not use get_current_user_id() to allow fallback to login page after loading config
        if (is_numeric($user_id = $_COOKIE['VDBuserid'])) {
            // store user id in session to identify reload point for config
            session_set('config_userid', $user_id);
            $SQL = 'SELECT opt, value
                         FROM ' . TBL_USERCONFIG . '
                        WHERE user_id = ' . $user_id;
            $result = runSQL($SQL);
            $config = array_merge($config, array_associate($result, 'opt', 'value'));
        }
        // set some defaults
        if (empty($config['language'])) {
            $config['language'] = 'en';
        }
        if (empty($config['template'])) {
            $config['template'] = 'modern::compact';
        }
        if (empty($config['filterdefault'])) {
            $config['filterdefault'] = 'unseen';
        }
        //      if ($config['IMDBage'] < 1) $config['IMDBage']          = 60*60*24*5;
        if ($config['castcolumns'] < 1) {
            $config['castcolumns'] = 4;
        }
        if ($config['listcolumns'] < 1) {
            $config['listcolumns'] = 1;
        }
        if ($config['thumbAge'] < 1) {
            $config['thumbAge'] = 60 * 60 * 24 * 7 * 3;
        }
        if ($config['shownew'] < 1) {
            $config['shownew'] = 12;
        }
        // prepare som options for later use
        $config['languages'] = explode('::', $config['languageflags']);
        // prepare template/style
        $tpl = explode('::', $config['template']);
        $config['style'] = 'templates/' . $tpl[0] . '/' . $tpl[1] . '.css';
        $config['templatedir'] = 'templates/' . $tpl[0] . '/';
        /*
                // multiple style files - use template name as base (e.g. elegant_grey.css)
                if (!file_exists($config['style']))
                {
                    // this should be an array
                    $config['style']    = array('templates/'.$tpl[0].'/'.$tpl[0].'.css',
                                                'templates/'.$tpl[0].'/'.$tpl[0].'_'.$tpl[1].'.css');
                }
        */
        // check if selected template is valid
        if (!file_exists($config['style'])) {
            $config['template'] = 'elegant::grey';
            $config['templatedir'] = 'templates/elegant/';
            $config['style'] = 'templates/elegant/grey.css';
        }
        // smarty cacheid for multiuser mode
        $config['cacheid'] = $tpl[0];
        // get installed engines meta information
        if (empty($config['engines'])) {
            require_once './engines/engines.php';
            $config['engines'] = engineMeta();
            // translate config options of type engine xyz into config[engine]
            foreach ($config['engines'] as $engine => $meta) {
                // convert the db engine options into associative array of engine enabled status
                if ($config['engine' . $engine]) {
                    $config['engine'][$engine] = $config['engine' . $engine];
                    // add meta-engine if enabled
                    engine_setup_meta($engine, $meta);
                }
            }
        }
        /*
                // added proxy support for $_ENV
                $proxy = $config['proxy_host'];
                if (empty($proxy))
                {
                    $env = array_change_key_case($_ENV);
                    $proxy = $env['http_proxy'];
                }
                if (!empty($proxy))
                {
                    $uri = parse_url($proxy);
                    $config['proxy_host'] = ($uri['scheme']) ? $uri['host'] : $uri['path'];
                    $config['proxy_port'] = ($uri['port']) ? $uri['port'] : 8080;
                }
        */
        // store loaded configuration
        session_set('config', $config);
    }
    // setup smarty
    $smarty->template_dir = array($config['templatedir'], 'templates/modern');
    $smarty->assign('template', $config['templatedir']);
    // initialize languages
    $lang = array();
    // load english language as default
    require './language/en.php';
    // override it with local language if nessesary:
    if ($config['language'] != 'en') {
        $languages = explode('_', $config['language']);
        $file = '';
        foreach ($languages as $language) {
            if ($file) {
                $file .= '_';
            }
            $file .= $language;
            @(include './language/' . $file . '.php');
            // convert languages to utf-8 encoding
            if ($lang['encoding'] != 'utf-8') {
                $lang = iconv_array($lang['encoding'], 'utf-8', $lang);
                $lang['encoding'] = 'utf-8';
            }
        }
    }
    // set connection character set and collation
    #   db_set_encoding();
}