Commit facccbd6 authored by pedro_morgan's avatar pedro_morgan
Browse files

* Tidiied up teh configure_fatabases()

* Made parts php5
* Other minor tweaks
parent b84d475d
......@@ -66,10 +66,13 @@ include_once('dist/conf/'.$conf['distname'].'.conf.php');
//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 @@ do {
$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)) {
......
......@@ -115,38 +115,41 @@ class installer_base {
}
/*
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) {
......
......@@ -356,6 +356,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$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);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment