diff options
-rw-r--r-- | etc/inc/config.inc | 14 | ||||
-rwxr-xr-x | usr/local/www/diag_backup.php | 44 |
2 files changed, 58 insertions, 0 deletions
diff --git a/etc/inc/config.inc b/etc/inc/config.inc index 6241927..66c46a6 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -488,6 +488,7 @@ function convert_config() { function write_config() { global $config, $g; + $lastchange = $config['lastchange']; config_lock(); @@ -499,6 +500,19 @@ function write_config() { /* generate configuration XML */ $xmlconfig = dump_xml_config($config, $g['xml_rootobj']); + /* archive off old config */ + /* XXX: billm beginning of version control functionality + * needs it's own directory, a front end, a way to prompt for change comments, and much more + * really just stubbing this in, not for use! + */ + if (isset($config['system']['version_control'])) { + $fd = fopen("{$g['cf_conf_path']}/bak/config-{$lastchange}.xml", "w"); + if (!$fd) + die("Unable to open config{$config['lastchange']}.xml for writing in write_config()\n"); + fwrite($fd, $xmlconfig); + fclose($fd); + } + /* write configuration */ $fd = fopen("{$g['cf_conf_path']}/config.xml", "w"); diff --git a/usr/local/www/diag_backup.php b/usr/local/www/diag_backup.php index d048d00..3cc4a8d 100755 --- a/usr/local/www/diag_backup.php +++ b/usr/local/www/diag_backup.php @@ -100,6 +100,27 @@ if ($_POST) { } } } + + +/* XXX - billm: begginnings of version control code + * This code sucks and is really more of a PoC - it needs cleanup (and doesn't work) + * don't set system/version_control :) + */ +if (isset($config['system']['version_control'])) { + $dir="{$g['cf_conf_path']}/bak"; + $old_versions = array(); + if (is_dir($dir)) { + if ($dh = opendir($dir)) { + while (($file = readdir($dh)) !== false) { + if ($file != "." && $file != "..") { + array_push(&$old_versions, $file); + } + } + closedir($dh); + } + } +} + ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> @@ -164,6 +185,29 @@ if ($_POST) { </tr> </table> </form> +<?php + /* XXX - billm: begginnings of version control code + * This code sucks and is really more of a PoC - it needs cleanup (and doesn't work) + * don't set system/version_control :) + */ + if (isset($config['system']['version_control'])) { +?> + <br> + <form action="diag_backup.php" method="post" name="version_control" id="version_control"> + <table width="100%" border="0" cellspacing="0" cellpadding="6"> + <tr> + <td colspan="3" class="listtopic">Config backups</td> + </tr> +<?php foreach ($old_versions as $ver): ?> + <tr> + <td width="22%" valign="baseline" class="vncell">Filename</td> + <td width="56%" class="vtable"><? echo $ver; ?></td + <td width="22%" class="vtable"><input name="restore" type="submit" class="formbtn" id="restore" value="Restore version"></td> + </tr> +<?php endforeach; ?> + </table> + </form> +<?php }; ?> <?php include("fend.inc"); ?> </body> </html> |