From 7b3af82b950537d7f38eca30ce34dadc9b6ebf09 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 24 Jul 2013 05:45:17 -0700 Subject: [PATCH] Only create database when checked. --- e107_admin/db.php | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/e107_admin/db.php b/e107_admin/db.php index 66df4f261..b93851cc9 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -274,32 +274,37 @@ class system_tools { $mes->addSuccess("Connecting to server"); - if($sql->gen("CREATE DATABASE ".$database." CHARACTER SET `utf8`")) + if(vartrue($_POST['createdb'])) { - $mes->addSuccess("Creating Database"); - - // $sql->gen("CREATE USER ".$user."@'".$server."' IDENTIFIED BY '".$pass."';"); - $sql->gen("GRANT ALL ON `".$database."`.* TO ".$user."@'".$server."';"); - $sql->gen("FLUSH PRIVILEGES;"); - - if(!$sql->database($database)) + + if($sql->gen("CREATE DATABASE ".$database." CHARACTER SET `utf8`")) { - $mes->addError("Selecting database"); + $mes->addSuccess("Creating Database"); + + // $sql->gen("CREATE USER ".$user."@'".$server."' IDENTIFIED BY '".$pass."';"); + $sql->gen("GRANT ALL ON `".$database."`.* TO ".$user."@'".$server."';"); + $sql->gen("FLUSH PRIVILEGES;"); } - - $mes->addSuccess("Selecting database"); - - if($this->multiSiteCreateTables($sql, $prefix)) + else { - $coreConfig = e_CORE. "xml/default_install.xml"; - $ret = e107::getXml()->e107Import($coreConfig, 'add', true, false, $sql); // Add core pref values - $mes->addInfo(print_a($ret,true)); - } + $mes->addError("Creating Database"); + return; + } } - else + + if(!$sql->database($database)) { - $mes->addError("Creating Database"); + $mes->addError("Selecting database"); } + + $mes->addSuccess("Selecting database"); + + if($this->multiSiteCreateTables($sql, $prefix)) + { + $coreConfig = e_CORE. "xml/default_install.xml"; + $ret = e107::getXml()->e107Import($coreConfig, 'add', true, false, $sql); // Add core pref values + $mes->addInfo(print_a($ret,true)); + } } else