aboutsummaryrefslogtreecommitdiff
path: root/install
diff options
context:
space:
mode:
Diffstat (limited to 'install')
-rw-r--r--install/ElggInstaller.php25
-rw-r--r--install/ElggRewriteTester.php4
-rw-r--r--install/cli/sample_installer.php35
-rw-r--r--install/js/install.js21
-rw-r--r--install/languages/en.php2
5 files changed, 76 insertions, 11 deletions
diff --git a/install/ElggInstaller.php b/install/ElggInstaller.php
index 03c84a43e..775bbf5b6 100644
--- a/install/ElggInstaller.php
+++ b/install/ElggInstaller.php
@@ -157,7 +157,7 @@ class ElggInstaller {
'password',
);
foreach ($requiredParams as $key) {
- if (!array_key_exists($key, $params)) {
+ if (empty($params[$key])) {
$msg = elgg_echo('install:error:requiredfield', array($key));
throw new InstallationException($msg);
}
@@ -1519,22 +1519,27 @@ class ElggInstaller {
protected function createAdminAccount($submissionVars, $login = FALSE) {
global $CONFIG;
- $guid = register_user(
- $submissionVars['username'],
- $submissionVars['password1'],
- $submissionVars['displayname'],
- $submissionVars['email']
- );
+ try {
+ $guid = register_user(
+ $submissionVars['username'],
+ $submissionVars['password1'],
+ $submissionVars['displayname'],
+ $submissionVars['email']
+ );
+ } catch (Exception $e) {
+ register_error($e->getMessage());
+ return false;
+ }
if (!$guid) {
register_error(elgg_echo('install:admin:cannot_create'));
- return FALSE;
+ return false;
}
$user = get_entity($guid);
if (!$user) {
register_error(elgg_echo('install:error:loadadmin'));
- return FALSE;
+ return false;
}
elgg_set_ignore_access(TRUE);
@@ -1543,7 +1548,7 @@ class ElggInstaller {
} else {
datalist_set('admin_registered', 1);
}
- elgg_set_ignore_access(FALSE);
+ elgg_set_ignore_access(false);
// add validation data to satisfy user validation plugins
create_metadata($guid, 'validated', TRUE, '', 0, ACCESS_PUBLIC);
diff --git a/install/ElggRewriteTester.php b/install/ElggRewriteTester.php
index c01510f60..ab68da2b7 100644
--- a/install/ElggRewriteTester.php
+++ b/install/ElggRewriteTester.php
@@ -154,6 +154,8 @@ class ElggRewriteTester {
if ($this->serverSupportsRemoteRead == FALSE) {
$msg = elgg_echo('install:warning:rewrite:unknown', array($url));
+ $msg .= elgg_view('install/js_rewrite_check', array('url' => $url));
+
return array(
'severity' => 'warning',
'message' => $msg,
@@ -165,6 +167,8 @@ class ElggRewriteTester {
$msg = "$serverString\n\n";
if (!isset($this->htaccessIssue)) {
$msg .= elgg_echo('install:error:rewrite:allowoverride');
+ $msg .= elgg_view('install/js_rewrite_check', array('url' => $url));
+
return array(
'severity' => 'failure',
'message' => $msg,
diff --git a/install/cli/sample_installer.php b/install/cli/sample_installer.php
index 954169a6a..0bae0cd23 100644
--- a/install/cli/sample_installer.php
+++ b/install/cli/sample_installer.php
@@ -3,10 +3,27 @@
* Sample cli installer script
*/
+$enabled = false;
+
+// Do not edit below this line. //////////////////////////////
+
+
+if (!$enabled) {
+ echo "To enable this script, change \$enabled to true.\n";
+ echo "You *must* disable this script after a successful installation.\n";
+ exit;
+}
+
+if (PHP_SAPI !== 'cli') {
+ echo "You must use the command line to run this script.";
+ exit;
+}
+
require_once(dirname(dirname(__FILE__)) . "/ElggInstaller.php");
$installer = new ElggInstaller();
+// none of the following may be empty
$params = array(
// database parameters
'dbuser' => '',
@@ -28,3 +45,21 @@ $params = array(
// install and create the .htaccess file
$installer->batchInstall($params, TRUE);
+
+// at this point installation has completed (otherwise an exception halted execution).
+
+// try to rewrite the script to disable it.
+if (is_writable(__FILE__)) {
+ $code = file_get_contents(__FILE__);
+ if (preg_match('~\\$enabled\\s*=\\s*(true|1)\\s*;~i', $code)) {
+ // looks safe to rewrite
+ $code = preg_replace('~\\$enabled\\s*=\\s*(true|1)\\s*;~i', '$enabled = false;', $code);
+ file_put_contents(__FILE__, $code);
+
+ echo "\nNote: This script has been disabled for your safety.\n";
+ exit;
+ }
+}
+
+echo "\nWarning: You *must* disable this script by setting \$enabled = false;.\n";
+echo "Leaving this script enabled could endanger your installation.\n";
diff --git a/install/js/install.js b/install/js/install.js
index 49b2be10c..37e5b0dc3 100644
--- a/install/js/install.js
+++ b/install/js/install.js
@@ -19,3 +19,24 @@ $(function() {
}
});
});
+
+elgg = {
+ installer: {}
+};
+
+/**
+ * Check the rewrite address for "success" and then allows the installation to proceed.
+ */
+elgg.installer.rewriteTest = function(url, success_msg, nextURL) {
+ $.ajax(url, {
+ success: function(data, status, xhr) {
+ if (data == 'success') {
+ $('.elgg-require-rewrite li').attr('class', 'pass');
+ $('.elgg-require-rewrite li').html('<p>' + success_msg + '</p>');
+ $('.elgg-install-nav a.elgg-state-disabled')
+ .removeClass('elgg-state-disabled')
+ .attr('href', nextURL);
+ }
+ }
+ });
+}
diff --git a/install/languages/en.php b/install/languages/en.php
index 3a692e020..b2583fbc9 100644
--- a/install/languages/en.php
+++ b/install/languages/en.php
@@ -154,7 +154,7 @@ If you are ready to proceed, click the Next button.",
'install:error:rewrite:htaccess:cannot_copy' => 'A unknown error occurred while creating the .htaccess file. You need to manually copy htaccess_dist to .htaccess in Elgg\'s directory.',
'install:error:rewrite:altserver' => 'The rewrite rules test failed. You need to configure your web server with Elgg\'s rewrite rules and try again.',
'install:error:rewrite:unknown' => 'Oof. We couldn\'t figure out what kind of web server is running on your server and it failed the rewrite rules. We cannot offer any specific advice. Please check the troubleshooting link.',
- 'install:warning:rewrite:unknown' => 'Your server does not support automatic testing of the rewrite rules. You can continue the installation, but you may experience problems with your site. You can manually test the rewrite rules by clicking this link: <a href="%s" target="_blank">test</a>. You will see the word success if the rules are working.',
+ 'install:warning:rewrite:unknown' => 'Your server does not support automatic testing of the rewrite rules and your browser does not support checking via JavaScript. You can continue the installation, but you may experience problems with your site. You can manually test the rewrite rules by clicking this link: <a href="%s" target="_blank">test</a>. You will see the word success if the rules are working.',
);
add_translation("en", $english);