From 6e0c8998901bcae422a41d630c8cb95441239f7b Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 1 Oct 2010 12:13:24 +0000 Subject: Refs #2129 - integrates new installer code from http://github.com/cash/Elgg - does not work yet with non-Apache web servers git-svn-id: http://code.elgg.org/elgg/trunk@6991 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/start.php | 153 ++++++++++++++++++++++--------------------------------- 1 file changed, 60 insertions(+), 93 deletions(-) (limited to 'engine/start.php') diff --git a/engine/start.php b/engine/start.php index d9ec01b87..db9bff0e4 100644 --- a/engine/start.php +++ b/engine/start.php @@ -11,19 +11,19 @@ * If Elgg is uninstalled, the browser will be redirected to an * installation page. * - * If in an installation, attempts to save the .htaccess and - * settings.php files during {@link sanitised()} - * - * @warning The view type is set to 'failsafe' during boot. This means calling - * {@link elgg_get_viewtype()} will return 'failsafe' in any function called by - * the events listed above regardless of actual view. The original view is restored - * after booting. - * * @see install.php * @package Elgg.Core * @subpackage Core */ +/* + * No settings means a fresh install + */ +if (!file_exists(dirname(__FILE__) . '/settings.php')) { + header("Location: install.php"); + exit; +} + /** * The time with microseconds when the Elgg engine was started. * @@ -73,110 +73,77 @@ foreach ($required_files as $file) { } } -// Use fallback view until sanitised -$oldview = get_input('view', 'default'); -set_input('view', 'failsafe'); - // Register the error handler set_error_handler('__elgg_php_error_handler'); set_exception_handler('__elgg_php_exception_handler'); -// attempt to save settings.php and .htaccess if in installation. -if ($sanitised = sanitised()) { - /** - * Load the system settings - */ - if (!include_once(dirname(__FILE__) . "/settings.php")) { - throw new InstallationException("Elgg could not load the settings file."); - } - // Get config - global $CONFIG; - - // load the rest of the library files from engine/lib/ - $lib_files = array( - // these need to be loaded first. - 'database.php', 'actions.php', - - 'admin.php', 'annotations.php', 'api.php', 'cache.php', - 'calendar.php', 'configuration.php', 'cron.php', 'entities.php', - 'export.php', 'extender.php', 'filestore.php', 'group.php', - 'input.php', 'install.php', 'location.php', 'mb_wrapper.php', - 'memcache.php', 'metadata.php', 'metastrings.php', 'notification.php', - 'objects.php', 'opendd.php', 'pagehandler.php', - 'pageowner.php', 'pam.php', 'plugins.php', 'query.php', - 'relationships.php', 'river.php', 'sites.php', 'social.php', - 'statistics.php', 'system_log.php', 'tags.php', 'usersettings.php', - 'users.php', 'version.php', 'widgets.php', 'xml.php', 'xml-rpc.php' - ); - - foreach($lib_files as $file) { - $file = $lib_dir . $file; - elgg_log("Loading $file..."); - if (!include_once($file)) { - throw new InstallationException("Could not load {$file}"); - } - } -} else { - throw new InstallationException(elgg_echo('installation:error:configuration')); +/** + * Load the system settings + */ +if (!include_once(dirname(__FILE__) . "/settings.php")) { + throw new InstallationException("Elgg could not load the settings file."); } -// Autodetect some default configuration settings -set_default_config(); - -// Trigger boot events for core. Plugins can't hook -// into this because they haven't been loaded yet. -trigger_elgg_event('boot', 'system'); - -// Check if installed -$installed = is_installed(); -$db_installed = is_db_installed(); -/** - * Forward if Elgg is not installed. - */ -if ((!$installed || !$db_installed) - && !substr_count($_SERVER["PHP_SELF"], "install.php") - && !substr_count($_SERVER["PHP_SELF"], "css.php") - && !substr_count($_SERVER["PHP_SELF"], "action_handler.php")) { +// load the rest of the library files from engine/lib/ +$lib_files = array( + // these need to be loaded first. + 'database.php', 'actions.php', + + 'admin.php', 'annotations.php', 'api.php', 'cache.php', + 'calendar.php', 'configuration.php', 'cron.php', 'entities.php', + 'export.php', 'extender.php', 'filestore.php', 'group.php', + 'input.php', 'install.php', 'location.php', 'mb_wrapper.php', + 'memcache.php', 'metadata.php', 'metastrings.php', 'notification.php', + 'objects.php', 'opendd.php', 'pagehandler.php', + 'pageowner.php', 'pam.php', 'plugins.php', 'query.php', + 'relationships.php', 'river.php', 'sites.php', 'social.php', + 'statistics.php', 'system_log.php', 'tags.php', 'usersettings.php', + 'users.php', 'version.php', 'widgets.php', 'xml.php', 'xml-rpc.php' +); - header("Location: install.php"); - exit; +foreach($lib_files as $file) { + $file = $lib_dir . $file; + elgg_log("Loading $file..."); + if (!include_once($file)) { + throw new InstallationException("Could not load {$file}"); + } } -// Load plugins -if (($installed) && ($db_installed) && ($sanitised)) { - load_plugins(); - - trigger_elgg_event('plugins_boot', 'system'); +// check if the install was completed +// @todo move into function +$installed = FALSE; +try { + $installed = is_installed(); +} catch (DatabaseException $e) {} +if (!$installed) { + header("Location: install.php"); + exit; } -// Trigger system init event for plugins -if (!substr_count($_SERVER["PHP_SELF"], "install.php") - && !substr_count($_SERVER["PHP_SELF"], "setup.php")) { +// Autodetect some default configuration settings +set_default_config(); - trigger_elgg_event('init', 'system'); -} +// Trigger events +trigger_elgg_event('boot', 'system'); -// System booted, return to normal view -if (!elgg_is_valid_view_type($oldview)) { - if (empty($CONFIG->view)) { - $oldview = 'default'; - } else { - $oldview = $CONFIG->view; - } -} +// Load the plugins that are active +load_plugins(); +trigger_elgg_event('plugins_boot', 'system'); -set_input('view', $oldview); +// Trigger system init event for plugins +trigger_elgg_event('init', 'system'); // Regenerate the simple cache if expired. -// Don't do it on upgrade, because upgrade does it itself. -if (($installed) && ($db_installed) && !(defined('upgrading') && upgrading == 'upgrading')) { - $lastupdate = datalist_get("simplecache_lastupdate_$oldview"); - $lastcached = datalist_get("simplecache_lastcached_$oldview"); +// Don't do it on upgrade because upgrade does it itself. +if (!defined('upgrading')) { + $view = get_input('view', 'default'); + $lastupdate = datalist_get("simplecache_lastupdate_$view"); + $lastcached = datalist_get("simplecache_lastcached_$view"); if ($lastupdate == 0 || $lastcached < $lastupdate) { - elgg_view_regenerate_simplecache($oldview); + elgg_view_regenerate_simplecache($view); } // needs to be set for links in html head $CONFIG->lastcache = $lastcached; -} \ No newline at end of file +} -- cgit v1.2.3