aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/settings.example.php98
-rw-r--r--engine/start.php153
2 files changed, 69 insertions, 182 deletions
diff --git a/engine/settings.example.php b/engine/settings.example.php
index 4f47872cb..aa50be6bc 100644
--- a/engine/settings.example.php
+++ b/engine/settings.example.php
@@ -29,105 +29,24 @@ if (!isset($CONFIG)) {
* to explain, but if you know you need it, skip past this section.
*/
-/**
- * The database username
- *
- * @global string $CONFIG->dbuser
- * @name $CONFIG->dbuser
- */
-$CONFIG->dbuser = '{{CONFIG_DBUSER}}';
-
-/**
- * The database password
- *
- * @global string $CONFIG->dbpass
- */
-$CONFIG->dbpass = '{{CONFIG_DBPASS}}';
-
-/**
- * The database name
- *
- * @global string $CONFIG->dbname
- */
-$CONFIG->dbname = '{{CONFIG_DBNAME}}';
-
-/**
- * The database host.
- *
- * For most installations, this is 'localhost'
- *
- * @global string $CONFIG->dbhost
- */
-$CONFIG->dbhost = '{{CONFIG_DBHOST}}';
-
-/**
- * The database prefix
- *
- * This prefix will be appended to all Elgg tables. If you're sharing
- * a database with other applications, use a database prefix to namespace tables
- * in order to avoid table name collisions.
- *
- * @global string $CONFIG->dbprefix
- */
-$CONFIG->dbprefix = '{{CONFIG_DBPREFIX}}';
-
-/**
- * Multiple database connections
- *
- * Here you can set up multiple connections for reads and writes. To do this, uncomment out
- * the lines below.
- *
- * @todo Does this work?
- */
-
-/*
-
-// Yes! We want to split reads and writes
-$CONFIG->db->split = true;
-
-// READS
-// Database username
-$CONFIG->db['read']->dbuser = "";
-
-// Database password
-$CONFIG->db['read']->dbpass = "";
-
-// Database name
-$CONFIG->db['read']->dbname = "";
-
-// Database server
-// (For most configurations, you can leave this as 'localhost')
-$CONFIG->db['read']->dbhost = "localhost";
-
-// WRITES
// Database username
-$CONFIG->db['write']->dbuser = "";
+$CONFIG->dbuser = '{{dbuser}}';
// Database password
-$CONFIG->db['write']->dbpass = "";
+$CONFIG->dbpass = '{{dbpassword}}';
// Database name
-$CONFIG->db['write']->dbname = "";
+$CONFIG->dbname = '{{dbname}}';
// Database server
// (For most configurations, you can leave this as 'localhost')
-$CONFIG->db['write']->dbhost = "localhost";
+$CONFIG->dbhost = '{{dbhost}}';
- */
-
-/*
- * For extra connections for both reads and writes, you can turn both
- * $CONFIG->db['read'] and $CONFIG->db['write'] into an array, eg:
- *
- * $CONFIG->db['read'][0]->dbhost = "localhost";
- *
- * Note that the array keys must be numeric and consecutive, i.e., they start
- * at 0, the next one must be at 1, etc.
- */
+// Database table prefix
+// If you're sharing a database with other applications, you will want to use this
+// to differentiate Elgg's tables.
+$CONFIG->dbprefix = '{{dbprefix}}';
-/*
- * Optional configuration
- */
/**
* Memcache setup (optional)
@@ -146,6 +65,7 @@ $CONFIG->db['write']->dbhost = "localhost";
// array('server2', 11211)
//);
+
/**
* Use non-standard headers for broken MTAs.
*
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
+}