From facccbd66a258549554de3fa87386223c3bf8852 Mon Sep 17 00:00:00 2001
From: pedro_morgan <pedro_morgan@ispconfig3>
Date: Sun, 19 Aug 2007 21:37:44 -0400
Subject: [PATCH] * Tidiied up teh configure_fatabases() * Made parts php5 * Other minor tweaks
---
install/install.php | 8 ++++++--
install/lib/installer_base.lib.php | 41 ++++++++++++++++++++++-------------------
install/lib/mysql.lib.php | 1 +
3 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/install/install.php b/install/install.php
index 8228971..40bb450 100644
--- a/install/install.php
+++ b/install/install.php
@@ -66,10 +66,13 @@
//TODO: this is not there ????
$conf['dist'] = $dist;
-//** Lets go !
+//****************************************************************************************************
+//** Installer Interface
+//****************************************************************************************************
$inst = new installer();
swriteln($inst->lng(' Following will be a few questions for primary configuration so be careful.'));
-swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>'."\n\n"));
+swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>.'));
+swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
//** Select the language
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en');
@@ -89,6 +92,7 @@
$tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']);
$tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']);
$tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
+ //TODO: it does not ask for which database ?
//* Initialize the MySQL server connection
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index 637047a..6d247b4 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -115,38 +115,41 @@
}
- /*
- This function creates the database for ISPConfig
- */
-
- function configure_database() {
+ /** Create the database for ISPConfig */
+ public function configure_database()
+ {
global $conf;
-
- // Create the database
- if(!$this->db->query("CREATE DATABASE IF NOT EXISTS ".$conf["mysql"]["database"])) {
- $this->error('Unable to create MySQL database: '.$conf["mysql"]["database"].';');
+ $cf = $conf['mysql']; // make $conf['mysql'] more accessible
+ //** Create the database
+ if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$cf['database'])) {
+ $this->error('Unable to create MySQL database: '.$cf['database'].'.');
}
- // Create the ISPConfig database user
- if(!$this->db->query("GRANT SELECT, INSERT, UPDATE, DELETE ON ".$conf["mysql"]["database"].".* TO '".$conf["mysql"]["ispconfig_user"]."'@'".$conf["mysql"]["host"]."' IDENTIFIED BY '".$conf["mysql"]["ispconfig_password"]."';")) {
- $this->error('Unable to create database user: '.$conf["mysql"]["ispconfig_user"]);
+ //* Create the ISPConfig database user
+ $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$cf['database'].".* "
+ ."TO '".$cf['ispconfig_user']."'@'".$cf['host']."' "
+ ."IDENTIFIED BY '".$cf['ispconfig_password']."';";
+ if(!$this->db->query($query)) {
+ $this->error('Unable to create database user: '.$cf['ispconfig_user']);
}
- // Reload database priveliges
+ //* Reload database privelages
$this->db->query('FLUSH PRIVILEGES;');
- // Set the database name in the DB library
- $this->db->dbName = $conf["mysql"]["database"];
+ //* Set the database name in the DB library
+ $this->db->dbName = $cf['database'];
- // loading the database dump into the database, if database is empty
+ //* Load the database dump into the database, if database contains no tables
$db_tables = $this->db->getTables();
if(count($db_tables) > 0) {
$this->error('Stopped: Database contains already some tables.');
} else {
- if($conf["mysql"]["admin_password"] == '') {
- caselog("mysql -h '".$conf["mysql"]["host"]."' -u '".$conf["mysql"]["admin_user"]."' '".$conf["mysql"]["database"]."' < 'sql/ispconfig3.sql' &> /dev/null", $FILE, __LINE__,"read in ispconfig3.sql","could not read in ispconfig3.sql");
+ if($cf['admin_password'] == '') {
+ caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' '".$cf['database']."' < 'sql/ispconfig3.sql' &> /dev/null",
+ $FILE, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
} else {
- caselog("mysql -h '".$conf["mysql"]["host"]."' -u '".$conf["mysql"]["admin_user"]."' -p'".$conf["mysql"]["admin_password"]."' '".$conf["mysql"]["database"]."' < 'sql/ispconfig3.sql' &> /dev/null", $FILE, __LINE__,"read in ispconfig3.sql","could not read in ispconfig3.sql");
+ caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' -p'".$cf['admin_password']."' '".$cf['database']."' < 'sql/ispconfig3.sql' &> /dev/null",
+ $FILE, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
}
$db_tables = $this->db->getTables();
if(count($db_tables) == 0) {
diff --git a/install/lib/mysql.lib.php b/install/lib/mysql.lib.php
index b930bba..eac33e5 100644
--- a/install/lib/mysql.lib.php
+++ b/install/lib/mysql.lib.php
@@ -356,6 +356,7 @@
$database_name = $this->dbName;
}
$result = mysql_query("SHOW TABLES FROM `$database_name`");
+ $tb_names = array();
for ($i = 0; $i < mysql_num_rows($result); $i++) {
$tb_names[$i] = mysql_tablename($result, $i);
}
--
Gitblit v1.9.1