aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/actions.php3
-rw-r--r--engine/lib/elgglib.php67
-rw-r--r--engine/lib/install.php97
-rw-r--r--engine/start.php20
4 files changed, 15 insertions, 172 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index 6b2967964..d164b14d6 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -60,12 +60,9 @@ function action($action, $forwarder = "") {
// @todo REMOVE THESE ONCE #1509 IS IN PLACE.
// Allow users to disable plugins without a token in order to
// remove plugins that are incompatible.
- // Installation cannot use tokens because it requires site secret to be
- // working. (#1462)
// Login and logout are for convenience.
// file/download (see #2010)
$exceptions = array(
- 'systemsettings/install',
'admin/plugins/disable',
'logout',
'login',
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index c00a88e84..16e20ef7c 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -584,73 +584,6 @@ function elgg_get_file_list($directory, $exceptions = array(), $list = array(),
}
/**
- * Checks that Elgg has been installed and attempts to complete installation if not.
- *
- * This is called by {@link engine/start.php} immediately after Elgg libraries are loaded
- * to check the installation state.
- *
- * Elgg's installation state is determined by (1) the existence of the engine/settings.php
- * file, (2) a .htaccess file, and (3) a populated database. This function checks
- * for 1 and 2, while 3 is checked by {@link is_installed()} and {@link is_db_installed()}.
- *
- * If settings.php doesn't exist and $_REQUEST['db_install_vars'] is present,
- * this function attempts to write the values from 'db_install_vars' to settings.php.
- *
- * If .htaccess doens't exist this function attempts to copy htaccess_dist to .htaccess.
- *
- * If there are any problems, this function calls {@link register_error()} and returns FALSE.
- * Since this function is called during bootstrapping, the viewtype is failsafe.
- * Returning FALSE results in an InstallationException, which halts execution.
- *
- * @return bool
- */
-function sanitised() {
- $sanitised = true;
-
- if (!file_exists(dirname(dirname(__FILE__)) . "/settings.php")) {
- // See if we are being asked to save the file
- $save_vars = get_input('db_install_vars');
- $result = "";
- if ($save_vars) {
- $rtn = db_check_settings($save_vars['CONFIG_DBUSER'],
- $save_vars['CONFIG_DBPASS'],
- $save_vars['CONFIG_DBNAME'],
- $save_vars['CONFIG_DBHOST'] );
- if ($rtn == FALSE) {
- register_error(elgg_view("messages/sanitisation/dbsettings_error"));
- register_error(elgg_view("messages/sanitisation/settings",
- array( 'settings.php' => $result,
- 'sticky' => $save_vars)));
- return FALSE;
- }
-
- $result = create_settings($save_vars, dirname(dirname(__FILE__)) . "/settings.example.php");
-
-
- if (file_put_contents(dirname(dirname(__FILE__)) . "/settings.php", $result)) {
- // blank result to stop it being displayed in textarea
- $result = "";
- }
- }
-
- // Recheck to see if the file is still missing
- if (!file_exists(dirname(dirname(__FILE__)) . "/settings.php")) {
- register_error(elgg_view("messages/sanitisation/settings", array('settings.php' => $result)));
- $sanitised = false;
- }
- }
-
- if (!file_exists(dirname(dirname(dirname(__FILE__))) . "/.htaccess")) {
- if (!@copy(dirname(dirname(dirname(__FILE__))) . "/htaccess_dist", dirname(dirname(dirname(__FILE__))) . "/.htaccess")) {
- register_error(elgg_view("messages/sanitisation/htaccess", array('.htaccess' => file_get_contents(dirname(dirname(dirname(__FILE__))) . "/htaccess_dist"))));
- $sanitised = false;
- }
- }
-
- return $sanitised;
-}
-
-/**
* Adds an entry in $CONFIG[$register_name][$subregister_name].
*
* This is only used for the site-wide menu. See {@link add_menu()}.
diff --git a/engine/lib/install.php b/engine/lib/install.php
index f1ad74b23..9deec9e26 100644
--- a/engine/lib/install.php
+++ b/engine/lib/install.php
@@ -11,63 +11,6 @@
*/
/**
- * Check that the installed version of PHP meets the minimum requirements (currently 5.2 or greater).
- *
- * @return bool
- */
-function php_check_version() {
- if (version_compare(phpversion(), '5.1.2', '>=')) {
- return true;
- }
-
- return false;
-}
-
-/**
- * Validate the platform Elgg is being installed on.
- *
- * @throws ConfigurationException if the validation fails.
- * @return bool
- */
-function validate_platform() {
- // Get database version
- if (!db_check_version()) {
- throw new ConfigurationException(elgg_echo('ConfigurationException:BadDatabaseVersion'));
- }
-
- // Now check PHP
- if (!php_check_version()) {
- throw new ConfigurationException(elgg_echo('ConfigurationException:BadPHPVersion'));
- }
-
- // @todo Consider checking for installed modules etc
- return true;
-}
-
-/**
- * Confirm the settings for the database
- *
- * @param string $user
- * @param string $password
- * @param string $dbname
- * @param string $host
- * @return bool
- * @since 1.7.1
- */
-function db_check_settings($user, $password, $dbname, $host) {
- $mysql_dblink = mysql_connect($host, $user, $password, true);
- if ($mysql_dblink == FALSE) {
- return $FALSE;
- }
-
- $result = mysql_select_db($dbname, $mysql_dblink);
-
- mysql_close($mysql_dblink);
-
- return $result;
-}
-
-/**
* Returns whether or not the database has been installed
*
* @return true|false Whether the database has been installed
@@ -104,37 +47,13 @@ function is_installed() {
return datalist_get('installed');
}
-/**
- * Copy and create a new settings.php from settings.example.php, substituting the variables in
- * $vars where appropriate.
- *
- * $vars is an associate array of $key => $value, where $key is the variable text you wish to substitute (eg
- * CONFIG_DBNAME will replace {{CONFIG_DBNAME}} in the settings file.
- *
- * @param array $vars The array of vars
- * @param string $in_file Optional input file (if not settings.example.php)
- * @return string The file containing substitutions.
- */
-function create_settings(array $vars, $in_file="engine/settings.example.php") {
- $file = file_get_contents($in_file);
-
- if (!$file) {
- return false;
- }
-
- foreach ($vars as $k => $v) {
- $file = str_replace("{{".$k."}}", $v, $file);
+function verify_installation() {
+ $installed = FALSE;
+ try {
+ $installed = is_installed();
+ } catch (DatabaseException $e) {}
+ if (!$installed) {
+ header("Location: install.php");
+ exit;
}
-
- return $file;
-}
-
-/**
- * Initialisation for installation functions
- *
- */
-function install_init() {
- register_action("systemsettings/install",true);
}
-
-register_elgg_event_handler("boot","system","install_init"); \ No newline at end of file
diff --git a/engine/start.php b/engine/start.php
index ce011f5c4..a84a19e0d 100644
--- a/engine/start.php
+++ b/engine/start.php
@@ -82,7 +82,8 @@ set_exception_handler('__elgg_php_exception_handler');
* Load the system settings
*/
if (!include_once(dirname(__FILE__) . "/settings.php")) {
- throw new InstallationException("Elgg could not load the settings file.");
+ $msg = elgg_echo('InstallationException:CannotLoadSettings');
+ throw new InstallationException($msg);
}
@@ -94,7 +95,7 @@ $lib_files = array(
'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',
+ 'input.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',
@@ -107,20 +108,13 @@ foreach($lib_files as $file) {
$file = $lib_dir . $file;
elgg_log("Loading $file...");
if (!include_once($file)) {
- throw new InstallationException("Could not load {$file}");
+ $msg = sprint(elgg_echo('InstallationException:MissingLibrary'), $file);
+ throw new InstallationException($msg);
}
}
-// 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;
-}
+// confirm that the installation completed successfully
+verify_installation();
// Autodetect some default configuration settings
set_default_config();