From aae92b703d57d95d27cce359420f9f0d626f7843 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 24 Dec 2015 17:15:09 -0500 Subject: * Now performing a database connection test before allowing the sytsconf page submission to succeed --- app/model/sysconf.mod.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'app/model/sysconf.mod.php') diff --git a/app/model/sysconf.mod.php b/app/model/sysconf.mod.php index 30ebd58..49e3b4d 100644 --- a/app/model/sysconf.mod.php +++ b/app/model/sysconf.mod.php @@ -19,6 +19,8 @@ class SysconfModel extends MasterModel */ function save($input) { + global $_SCROTT; + $form = new Form(); $form->field_text("dbAddress"); $form->field_text("dbName"); @@ -32,8 +34,25 @@ class SysconfModel extends MasterModel return; } - /* TODO -- test database connection before proceeding */ + /* test database connection (set global vars and try to get a db object) */ + $_SCROTT['conf'] = 'conf'; + $_SCROTT['dbEngine'] = 'mysql'; + $_SCROTT['dbAddress'] = $form->dbAddress; + $_SCROTT['dbName'] = $form->dbName; + $_SCROTT['dbUser'] = $form->dbUser; + $_SCROTT['dbPass'] = $form->dbPass; + + try + { + $db = $this->getDbConnection(); + } + catch (Exception $e) + { + $this->logError($e->getMessage()); + return; + } + /* write file */ $f = fopen($this->CONF_FILE, "w"); if (!$f) -- cgit v1.2.3