From 46bc6e545a17e77202aaf01ec0cd8d5a46567525 Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Tue, 25 Aug 2015 08:08:24 -0300 Subject: Move main pfSense content to src/ --- src/usr/local/www/diag_confbak.php | 301 +++++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+) create mode 100644 src/usr/local/www/diag_confbak.php (limited to 'src/usr/local/www/diag_confbak.php') diff --git a/src/usr/local/www/diag_confbak.php b/src/usr/local/www/diag_confbak.php new file mode 100644 index 0000000..cc1da99 --- /dev/null +++ b/src/usr/local/www/diag_confbak.php @@ -0,0 +1,301 @@ += 0)) { + $config['system']['backupcount'] = $_POST['backupcount']; + $changedescr = $config['system']['backupcount']; + } else { + unset($config['system']['backupcount']); + $changedescr = "(platform default)"; + } + write_config("Changed backup revision count to {$changedescr}"); +} elseif ($_POST) { + if (!isset($_POST['confirm']) || ($_POST['confirm'] != gettext("Confirm")) || (!isset($_POST['newver']) && !isset($_POST['rmver']))) { + header("Location: diag_confbak.php"); + return; + } + + conf_mount_rw(); + $confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache')); + if ($_POST['newver'] != "") { + if (config_restore($g['conf_path'] . '/backup/config-' . $_POST['newver'] . '.xml') == 0) { + $savemsg = sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['newver']), htmlspecialchars($confvers[$_POST['newver']]['description'])); + } else { + $savemsg = gettext("Unable to revert to the selected configuration."); + } + } + if ($_POST['rmver'] != "") { + unlink_if_exists($g['conf_path'] . '/backup/config-' . $_POST['rmver'] . '.xml'); + $savemsg = sprintf(gettext('Deleted backup with timestamp %1$s and description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['rmver']), htmlspecialchars($confvers[$_POST['rmver']]['description'])); + } + conf_mount_ro(); +} + +if ($_GET['getcfg'] != "") { + $file = $g['conf_path'] . '/backup/config-' . $_GET['getcfg'] . '.xml'; + + $exp_name = urlencode("config-{$config['system']['hostname']}.{$config['system']['domain']}-{$_GET['getcfg']}.xml"); + $exp_data = file_get_contents($file); + $exp_size = strlen($exp_data); + + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename={$exp_name}"); + header("Content-Length: $exp_size"); + echo $exp_data; + exit; +} + +if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime']) && + (is_numeric($_GET['oldtime'])) && + (is_numeric($_GET['newtime']) || ($_GET['newtime'] == 'current'))) { + $diff = ""; + $oldfile = $g['conf_path'] . '/backup/config-' . $_GET['oldtime'] . '.xml'; + $oldtime = $_GET['oldtime']; + if ($_GET['newtime'] == 'current') { + $newfile = $g['conf_path'] . '/config.xml'; + $newtime = $config['revision']['time']; + } else { + $newfile = $g['conf_path'] . '/backup/config-' . $_GET['newtime'] . '.xml'; + $newtime = $_GET['newtime']; + } + if (file_exists($oldfile) && file_exists($newfile)) { + exec("/usr/bin/diff -u " . escapeshellarg($oldfile) . " " . escapeshellarg($newfile), $diff); + } +} + +cleanup_backupcache(false); +$confvers = get_backups(); +unset($confvers['versions']); + +$pgtitle = array(gettext("Diagnostics"), gettext("Configuration History")); +include("head.inc"); + +?> + + + + + + + + + + + + + +
+
+ + + + + + + + +
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
  + + : +
+
: + + " /> + + " /> + +
: + +
" /> +
  + + + + " />
  + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

+
" /> 
+ +
+ + + + + +   + + + + <?=gettext(" title="" /> + + + <?=gettext(" title="" /> + + + <?=gettext(" title="" /> + +
" />
+ +
+
+
+
+ + + + -- cgit v1.1