diff options
author | M <m@lfurio.us> | 2015-12-06 02:16:46 -0500 |
---|---|---|
committer | M <m@lfurio.us> | 2015-12-06 02:16:46 -0500 |
commit | 94b39ff32f6cc9566de651f35994d877634d7317 (patch) | |
tree | 529413a012e1507d8918e754ed11114e627eb8db /app/model/sysconf.mod.php | |
parent | 9f9d2a9d313122e9cf365e3baf4a8889b611ae28 (diff) | |
download | scrott-94b39ff32f6cc9566de651f35994d877634d7317.tar.gz scrott-94b39ff32f6cc9566de651f35994d877634d7317.zip |
* Implemented the "save" action for MVC sysconf
Diffstat (limited to '')
-rw-r--r-- | app/model/sysconf.mod.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/app/model/sysconf.mod.php b/app/model/sysconf.mod.php index 754d1a6..d86f589 100644 --- a/app/model/sysconf.mod.php +++ b/app/model/sysconf.mod.php @@ -1,15 +1,58 @@ <?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; + } + + $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()); + } } ?> |