summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--installer/helpers/installer.php12
-rw-r--r--installer/install.php6
-rw-r--r--installer/libraries/Install_Mysql_Driver.php15
-rw-r--r--installer/libraries/Install_Mysqli_Driver.php15
4 files changed, 43 insertions, 5 deletions
diff --git a/installer/helpers/installer.php b/installer/helpers/installer.php
index 9214060d..640e4335 100644
--- a/installer/helpers/installer.php
+++ b/installer/helpers/installer.php
@@ -274,6 +274,15 @@ class installer {
"error" => false);
}
+ $tables = self::$database->list_tables(self::$config["dbname"]);
+
+ $valid = count($tables) == 0;
+ if (!$valid) {
+ $db_config_valid = false;
+ $section["msgs"]["Database Empty"] = array("text" => "Database '$dbname' is not empty",
+ "error" => true);
+ }
+
$missing = array();
$rights = self::$database->get_access_rights($dbname);
@@ -292,7 +301,6 @@ class installer {
"error" => false);
}
-
self::$messages[] = $section;
return $db_config_valid;
@@ -314,7 +322,7 @@ class installer {
"error" => true);
}
self::$messages[] = $section;
- return $writable;
+ return !$writable;
}
private static function _render($view) {
diff --git a/installer/install.php b/installer/install.php
index 9ed20d6d..9802bbd2 100644
--- a/installer/install.php
+++ b/installer/install.php
@@ -69,8 +69,8 @@ define('THEMEPATH', strtr(realpath('themes') . '/', DIRECTORY_SEPARATOR, '/'));
define('SYSPATH', strtr(realpath('kohana') . '/', DIRECTORY_SEPARATOR, '/'));
define('EXT', ".php");
-//set_error_handler(array('Kohana', 'exception_handler'));
-set_error_handler(create_function('$x, $y', 'throw new Exception($y, $x);'));
+set_error_handler(create_function('$errno, $errstr, $errfile, $errline',
+ 'throw new ErrorException($errstr, 0, $errno, $errfile, $errline);'));
// Set exception handler
set_exception_handler('exception_handler');
@@ -93,7 +93,7 @@ try {
die("Specifed User does not have sufficient authority to install Gallery3\n");
}
-$config_valid = installer::check_docroot_writable();
+$config_valid &= installer::check_docroot_writable();
installer::display_requirements(!$config_valid);
diff --git a/installer/libraries/Install_Mysql_Driver.php b/installer/libraries/Install_Mysql_Driver.php
index aac49acd..d380b140 100644
--- a/installer/libraries/Install_Mysql_Driver.php
+++ b/installer/libraries/Install_Mysql_Driver.php
@@ -61,4 +61,19 @@ class Install_Mysql_Driver {
return $permissions;
}
+ public function select_db($dbname) {
+ mysql_select_db($dbname);
+ }
+
+ public function list_tables($dbname) {
+ $select = "SHOW TABLES FROM $dbname;";
+ $db_tables = mysql_query($select, $this->_link);
+ $tables = array();
+ if ($db_tables) {
+ while ($row = mysql_fetch_assoc($db_tables)) {
+ $tables[$row["Tables_in_$dbname"]] = 1;
+ }
+ }
+ return $tables;
+ }
}
diff --git a/installer/libraries/Install_Mysqli_Driver.php b/installer/libraries/Install_Mysqli_Driver.php
index ce141066..43894722 100644
--- a/installer/libraries/Install_Mysqli_Driver.php
+++ b/installer/libraries/Install_Mysqli_Driver.php
@@ -66,5 +66,20 @@ class Install_Mysqli_Driver {
return $permissions;
}
+ public function select_db($dbname) {
+ $this->_mysqli->select_db($dbname);
+ }
+
+ public function list_tables($dbname) {
+ $select = "SHOW TABLES FROM $dbname;";
+ $db_tables = $this->_mysqli->query($select);
+ $tables = array();
+ if ($db_tables) {
+ while ($row = $db_tables->fetch_row()) {
+ $tables[strtolower($row[0])] = 1;
+ }
+ }
+ return $tables;
+ }
}