summaryrefslogtreecommitdiffstats
path: root/app/model/sysconf.mod.php
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2015-12-18 23:18:33 -0500
committerMalf Furious <m@lfurio.us>2015-12-18 23:18:33 -0500
commit9068e6916ad68194fce2518ab5841af1c8949f3d (patch)
tree2f91e9e3be00c1492cdf4ce88d8e77a909c5c287 /app/model/sysconf.mod.php
parent2ebdbaa48f10d6a6f5a1b78f4ef2c5433e50c8cf (diff)
parentb21251ef971d262dc414869fed83f52d0098bfe6 (diff)
downloadscrott-9068e6916ad68194fce2518ab5841af1c8949f3d.tar.gz
scrott-9068e6916ad68194fce2518ab5841af1c8949f3d.zip
Merge branch 'framework' into dev
Diffstat (limited to '')
-rw-r--r--app/model/sysconf.mod.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/app/model/sysconf.mod.php b/app/model/sysconf.mod.php
new file mode 100644
index 0000000..30ebd58
--- /dev/null
+++ b/app/model/sysconf.mod.php
@@ -0,0 +1,60 @@
+<?php
+
+require_once "model/master.mod.php";
+require_once "class/form.class.php";
+
+class SysconfModel extends MasterModel
+{
+ var $CONF_FILE = "scrott.conf.php";
+
+ /*
+ * Default action
+ */
+ function deflt()
+ {
+ }
+
+ /*
+ * Save the submitted data to the config file
+ */
+ function save($input)
+ {
+ $form = new Form();
+ $form->field_text("dbAddress");
+ $form->field_text("dbName");
+ $form->field_text("dbUser");
+ $form->field_text("dbPass", null, false);
+ $form->field_enum("settSSL", array("force", "neither", "forbid"));
+
+ if (!$form->populate($input))
+ {
+ $this->logFormErrors($form);
+ return;
+ }
+
+ /* TODO -- test database connection before proceeding */
+
+ $f = fopen($this->CONF_FILE, "w");
+
+ if (!$f)
+ {
+ $this->logError("Can not create configuration file");
+ return;
+ }
+
+ fwrite($f, "<?php\n");
+ fwrite($f, "\$_SCROTT['conf'] = 'conf';\n");
+ fwrite($f, "\$_SCROTT['dbEngine'] = 'mysql';\n");
+ fwrite($f, "\$_SCROTT['dbAddress'] = '" . $form->dbAddress . "';\n");
+ fwrite($f, "\$_SCROTT['dbName'] = '" . $form->dbName . "';\n");
+ fwrite($f, "\$_SCROTT['dbUser'] = '" . $form->dbUser . "';\n");
+ fwrite($f, "\$_SCROTT['dbPass'] = '" . $form->dbPass . "';\n");
+ fwrite($f, "\$_SCROTT['settSSL'] = '" . $form->settSSL . "';\n");
+ fwrite($f, "?>\n");
+
+ fclose($f);
+ $this->redirectTo($this->ar());
+ }
+}
+
+?>