summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--installer/cli.php18
-rw-r--r--installer/installer.php23
-rw-r--r--installer/web.php8
3 files changed, 18 insertions, 31 deletions
diff --git a/installer/cli.php b/installer/cli.php
index 93d4d502..fb497635 100644
--- a/installer/cli.php
+++ b/installer/cli.php
@@ -46,13 +46,17 @@ if (!installer::connect($config)) {
oops("Couldn't create var/database.php");
} else {
system("chmod -R 777 " . VARPATH);
- list ($user, $password) = installer::create_admin($config);
- print "Your Gallery has been successfully installed!\n";
- print "We've created an account for you to use:\n";
- print " username: $user\n";
- print " password: $password\n";
- print "\n";
- exit(0);
+ try {
+ list ($user, $password) = installer::create_admin($config);
+ print "Your Gallery has been successfully installed!\n";
+ print "We've created an account for you to use:\n";
+ print " username: $user\n";
+ print " password: $password\n";
+ print "\n";
+ exit(0);
+ } catch (Exception $e) {
+ oops($e->getMessage());
+ }
}
function oops($message) {
diff --git a/installer/installer.php b/installer/installer.php
index cd410571..62523308 100644
--- a/installer/installer.php
+++ b/installer/installer.php
@@ -34,22 +34,6 @@ class installer {
return false;
}
- static function setup_var() {
- $errors = array();
- if (is_writable(VARPATH)) {
- return;
- }
-
- if (is_writable(dirname(VARPATH)) && !mkdir(VARPATH)) {
- $errors["Filesystem"] =
- sprintf("The %s directory doesn't exist and can't be created", VARPATH);
- }
-
- if ($errors) {
- throw new InstallException($errors);
- }
- }
-
static function create_database_config($config) {
$db_config_file = VARPATH . "database.php";
ob_start();
@@ -95,7 +79,6 @@ class installer {
}
static function create_admin($config) {
- $errors = array();
$salt = "";
for ($i = 0; $i < 4; $i++) {
$char = mt_rand(48, 109);
@@ -106,11 +89,7 @@ class installer {
$hashed_password = $salt . md5($salt . $password);
if (mysql_query("UPDATE `users` SET `password` = '$hashed_password' WHERE `id` = 2")) {
} else {
- $errors["Database"] = "Unable to set admin password. Error details:\n" . mysql_error();
- }
-
- if ($errors) {
- throw new InstallException($errors);
+ throw new Exception(mysql_error());
}
return array("admin", $password);
diff --git a/installer/web.php b/installer/web.php
index 89b0021d..cfae7a33 100644
--- a/installer/web.php
+++ b/installer/web.php
@@ -52,8 +52,12 @@ if (installer::already_installed()) {
} else if (!installer::create_database_config($config)) {
$content = oops("Couldn't create var/database.php");
} else {
- list ($user, $password) = installer::create_admin($config);
- $content = render("success.html.php", array("user" => $user, "password" => $password));
+ try {
+ list ($user, $password) = installer::create_admin($config);
+ $content = render("success.html.php", array("user" => $user, "password" => $password));
+ } catch (Exception $e) {
+ $content = oops($e->getMessage());
+ }
}
break;
}