Skip to content

Commit facccbd

Browse files
author
pedro_morgan
committed
* Tidiied up teh configure_fatabases()
* Made parts php5 * Other minor tweaks
1 parent b84d475 commit facccbd

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

install/install.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@
6666
//TODO: this is not there ????
6767
$conf['dist'] = $dist;
6868

69-
//** Lets go !
69+
//****************************************************************************************************
70+
//** Installer Interface
71+
//****************************************************************************************************
7072
$inst = new installer();
7173
swriteln($inst->lng(' Following will be a few questions for primary configuration so be careful.'));
72-
swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>'."\n\n"));
74+
swriteln($inst->lng(' Default values are in [brackets] and can be accepted with <ENTER>.'));
75+
swriteln($inst->lng(' Tap in "quit" (without the quotes) to stop the installer.'."\n\n"));
7376

7477
//** Select the language
7578
$conf['language'] = $inst->simple_query('Select language', array('en','de'), 'en');
@@ -89,6 +92,7 @@
8992
$tmp_mysql_server_host = $inst->free_query('MySQL server hostname', $conf['mysql']['host']);
9093
$tmp_mysql_server_admin_user = $inst->free_query('MySQL root username', $conf['mysql']['admin_user']);
9194
$tmp_mysql_server_admin_password = $inst->free_query('MySQL root password', $conf['mysql']['admin_password']);
95+
//TODO: it does not ask for which database ?
9296
9397
//* Initialize the MySQL server connection
9498
if(@mysql_connect($tmp_mysql_server_host, $tmp_mysql_server_admin_user, $tmp_mysql_server_admin_password)) {

install/lib/installer_base.lib.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -115,38 +115,41 @@ function request_language() {
115115

116116
}
117117

118-
/*
119-
This function creates the database for ISPConfig
120-
*/
121-
122-
function configure_database() {
118+
/** Create the database for ISPConfig */
119+
public function configure_database()
120+
{
123121
global $conf;
124-
125-
// Create the database
126-
if(!$this->db->query("CREATE DATABASE IF NOT EXISTS ".$conf["mysql"]["database"])) {
127-
$this->error('Unable to create MySQL database: '.$conf["mysql"]["database"].';');
122+
$cf = $conf['mysql']; // make $conf['mysql'] more accessible
123+
//** Create the database
124+
if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$cf['database'])) {
125+
$this->error('Unable to create MySQL database: '.$cf['database'].'.');
128126
}
129127

130-
// Create the ISPConfig database user
131-
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"]."';")) {
132-
$this->error('Unable to create database user: '.$conf["mysql"]["ispconfig_user"]);
128+
//* Create the ISPConfig database user
129+
$query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$cf['database'].".* "
130+
."TO '".$cf['ispconfig_user']."'@'".$cf['host']."' "
131+
."IDENTIFIED BY '".$cf['ispconfig_password']."';";
132+
if(!$this->db->query($query)) {
133+
$this->error('Unable to create database user: '.$cf['ispconfig_user']);
133134
}
134135

135-
// Reload database priveliges
136+
//* Reload database privelages
136137
$this->db->query('FLUSH PRIVILEGES;');
137138

138-
// Set the database name in the DB library
139-
$this->db->dbName = $conf["mysql"]["database"];
139+
//* Set the database name in the DB library
140+
$this->db->dbName = $cf['database'];
140141

141-
// loading the database dump into the database, if database is empty
142+
//* Load the database dump into the database, if database contains no tables
142143
$db_tables = $this->db->getTables();
143144
if(count($db_tables) > 0) {
144145
$this->error('Stopped: Database contains already some tables.');
145146
} else {
146-
if($conf["mysql"]["admin_password"] == '') {
147-
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");
147+
if($cf['admin_password'] == '') {
148+
caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' '".$cf['database']."' < 'sql/ispconfig3.sql' &> /dev/null",
149+
$FILE, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
148150
} else {
149-
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");
151+
caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' -p'".$cf['admin_password']."' '".$cf['database']."' < 'sql/ispconfig3.sql' &> /dev/null",
152+
$FILE, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
150153
}
151154
$db_tables = $this->db->getTables();
152155
if(count($db_tables) == 0) {

install/lib/mysql.lib.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ function getTables($database_name = '') {
356356
$database_name = $this->dbName;
357357
}
358358
$result = mysql_query("SHOW TABLES FROM `$database_name`");
359+
$tb_names = array();
359360
for ($i = 0; $i < mysql_num_rows($result); $i++) {
360361
$tb_names[$i] = mysql_tablename($result, $i);
361362
}

0 commit comments

Comments
 (0)