summaryrefslogtreecommitdiffstats
path: root/app/model
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2015-12-24 17:15:09 -0500
committerMalf Furious <m@lfurio.us>2015-12-24 17:15:09 -0500
commitaae92b703d57d95d27cce359420f9f0d626f7843 (patch)
tree807efd175f80a5612df2eeb5900cec9a9d339b00 /app/model
parent9068e6916ad68194fce2518ab5841af1c8949f3d (diff)
downloadscrott-aae92b703d57d95d27cce359420f9f0d626f7843.tar.gz
scrott-aae92b703d57d95d27cce359420f9f0d626f7843.zip
* Now performing a database connection test before allowing the sytsconf page submission to succeed
Diffstat (limited to 'app/model')
-rw-r--r--app/model/sysconf.mod.php21
1 files changed, 20 insertions, 1 deletions
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)