Commit 665b3c2d authored by Franco Fichtner's avatar Franco Fichtner

configuration: layout and other things

(cherry picked from commit 61ec0fcd)
(cherry picked from commit f42e229b)
(cherry picked from commit 3161dece)
(cherry picked from commit a35211fd)
parent c9065278
...@@ -227,6 +227,7 @@ ...@@ -227,6 +227,7 @@
<interval>monthly</interval> <interval>monthly</interval>
</bogons> </bogons>
<kill_states/> <kill_states/>
<backupcount>60</backupcount>
</system> </system>
<interfaces> <interfaces>
<wan> <wan>
......
...@@ -288,7 +288,8 @@ function cleanup_backups() ...@@ -288,7 +288,8 @@ function cleanup_backups()
if (isset($config['system']['backupcount']) && is_numeric($config['system']['backupcount']) && ($config['system']['backupcount'] >= 0)) { if (isset($config['system']['backupcount']) && is_numeric($config['system']['backupcount']) && ($config['system']['backupcount'] >= 0)) {
$revisions = intval($config['system']['backupcount']); $revisions = intval($config['system']['backupcount']);
} else { } else {
$revisions = 30; /* XXX this value used to be left out of the config */
$revisions = 60;
} }
$cnf = OPNsense\Core\Config::getInstance(); $cnf = OPNsense\Core\Config::getInstance();
......
...@@ -3432,4 +3432,8 @@ function upgrade_111_to_112() ...@@ -3432,4 +3432,8 @@ function upgrade_111_to_112()
} }
} }
} }
if (!isset($config['system']['backupcount'])) {
$config['system']['backupcount'] = 60;
}
} }
...@@ -33,6 +33,12 @@ require_once("guiconfig.inc"); ...@@ -33,6 +33,12 @@ require_once("guiconfig.inc");
if ($_SERVER['REQUEST_METHOD'] === 'GET') { if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$cnf = OPNsense\Core\Config::getInstance(); $cnf = OPNsense\Core\Config::getInstance();
$confvers = $cnf->getBackups(true); $confvers = $cnf->getBackups(true);
if (isset($config['system']['backupcount'])) {
$pconfig['backupcount'] = $config['system']['backupcount'];
} else {
# XXX fallback value for older configs
$pconfig['backupcount'] = 60;
}
if (!empty($_GET['getcfg'])) { if (!empty($_GET['getcfg'])) {
foreach ($confvers as $filename => $revision) { foreach ($confvers as $filename => $revision) {
if ($revision['time'] == $_GET['getcfg']) { if ($revision['time'] == $_GET['getcfg']) {
...@@ -79,16 +85,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -79,16 +85,24 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} }
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$input_errors = array();
$pconfig = $_POST;
if (!empty($pconfig['save'])) {
if (!isset($pconfig['backupcount']) || !is_numeric($pconfig['backupcount']) || $pconfig['backupcount'] <= 0) {
$input_errors[] = gettext('Backup count must be greater than zero.');
}
if (count($input_errors) == 0) {
$config['system']['backupcount'] = $pconfig['backupcount'];
write_config(gettext('Changed backup revision count.'));
$savemsg = get_std_save_message();
}
}
$cnf = OPNsense\Core\Config::getInstance(); $cnf = OPNsense\Core\Config::getInstance();
$confvers = $cnf->getBackups(true); $confvers = $cnf->getBackups(true);
if (!empty($_POST['save'])) {
if (is_numeric($_POST['backupcount']) && ($_POST['backupcount'] >= 0)) { if (!empty($_POST['act']) && $_POST['act'] == "revert") {
$config['system']['backupcount'] = $_POST['backupcount'];
} elseif (isset($config['system']['backupcount'])) {
unset($config['system']['backupcount']);
}
write_config(gettext('Changed backup revision count.'));
} elseif (!empty($_POST['act']) && $_POST['act'] == "revert") {
foreach ($confvers as $filename => $revision) { foreach ($confvers as $filename => $revision) {
if (isset($revision['time']) && $revision['time'] == $_POST['time']) { if (isset($revision['time']) && $revision['time'] == $_POST['time']) {
if (config_restore($filename) == 0) { if (config_restore($filename) == 0) {
...@@ -113,14 +127,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -113,14 +127,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
} }
} }
} }
} }
include("head.inc"); include("head.inc");
?> ?>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
$( document ).ready(function() { $( document ).ready(function() {
...@@ -176,168 +187,165 @@ $( document ).ready(function() { ...@@ -176,168 +187,165 @@ $( document ).ready(function() {
<body> <body>
<?php <?php
include("fbegin.inc"); include("fbegin.inc");
if($savemsg) if (isset($input_errors) && count($input_errors) > 0) {
print_input_errors($input_errors);
}
if ($savemsg) {
print_info_box($savemsg); print_info_box($savemsg);
}
?> ?>
<section class="page-content-main"> <section class="page-content-main">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<section class="col-xs-12"> <section class="col-xs-12">
<div class="container-fluid"> <form method="post" id="iform">
<form method="post" id="iform"> <input type="hidden" id="time" name="time" value="" />
<input type="hidden" id="time" name="time" value="" /> <input type="hidden" id="action" name="act" value="" />
<input type="hidden" id="action" name="act" value="" /> <div class="content-box tab-content table-responsive __mb">
<section style="margin-bottom:15px;"> <table class="table table-striped">
<div class="content-box"> <tr>
<div class="content-box-main"> <th colspan="2" valign="top" class="listtopic"><?=gettext("Backup Count"); ?></th>
<div class="table-responsive"> </tr>
<table class="table table-striped"> <tr>
<thead> <td><input name="backupcount" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($pconfig['backupcount']);?>"/></td>
<tr> <td><?= gettext("Enter the number of older configurations to keep in the local backup cache."); ?></td>
<th><?=gettext("Backup Count");?></th> </tr>
<th></th> <tr>
</tr> <td>
</thead> <input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
<tbody> </td>
<tr> <td>
<td><input name="backupcount" type="text" class="formfld unknown" size="5" value="<?=htmlspecialchars($config['system']['backupcount']);?>"/></td> <?= gettext('Be aware of how much space is consumed by backups before adjusting this value.'); ?>
<td><?= gettext("Enter the number of older configurations to keep in the local backup cache. By default this is 30."); ?></td> <?php if (count($confvers)) {
</tr> print gettext('Current space used:') . ' ' . exec("/usr/bin/du -sh /conf/backup | /usr/bin/awk '{print $1;}'");
<tr> } ?>
<td> </td>
<input name="save" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" /> </tr>
</td> </table>
</tr> </div>
</tbody> </form>
</table> <?php if ($diff): ?>
<hr/> <section style="margin-bottom:15px;">
<div class="container-fluid"> <div class="content-box">
<?= gettext("NOTE: Be aware of how much space is consumed by backups before adjusting this value. Current space used by backups: "); ?> <?= exec("/usr/bin/du -sh /conf/backup | /usr/bin/awk '{print $1;}'") ?> <header class="content-box-head container-fluid">
</div> <h3><?=gettext("Configuration diff from");?> <?= date(gettext("n/j/y H:i:s"), $oldtime); ?> <?=gettext("to");?> <?=date(gettext("n/j/y H:i:s"), $newtime); ?></h3>
</div> </header>
</div> <div class="content-box-main">
</div> <div class="container-fluid __mb">
</section> <div class="table-responsive" style="overflow: scroll;">
</form> <table class="table table-condensed table-striped">
<?php if ($diff): ?>
<section style="margin-bottom:15px;">
<div class="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext("Configuration diff from");?> <?= date(gettext("n/j/y H:i:s"), $oldtime); ?> <?=gettext("to");?> <?=date(gettext("n/j/y H:i:s"), $newtime); ?></h3>
</header>
<div class="content-box-main">
<div class="container-fluid __mb">
<div class="table-responsive" style="overflow: scroll;">
<table class="table table-condensed table-striped">
<?php
foreach ($diff as $line):
switch (substr($line, 0, 1)) {
case '+':
$color = '#3bbb33';
break;
case '-':
$color = '#c13928';
break;
case '@':
$color = '#3bb9c3';
break;
default:
$color = '#000000';
}
?>
<tr>
<td style="color: <?=$color;?>; white-space: pre-wrap; font-family: monospace;"><?=htmlentities($line);?></td>
</tr>
<?php
endforeach;?>
</table>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>
<form method="get">
<section>
<div class="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext('History');?></h3>
</header>
<div class="content-box-main">
<div class="container-fluid __mb">
<table class="table table-condensed">
<tr>
<td>
<button type="submit" name="diff" class="btn btn-primary pull-left" value="Diff">
<?=gettext('View differences');?>
</button>
</td>
<td>
<?= gettext("To view the differences between an older configuration and a newer configuration, select the older configuration using the left column of radio options and select the newer configuration in the right column, then press the button."); ?>
</td>
</tr>
</table>
</div>
<table class="table table-striped">
<thead>
<tr>
<th colspan="2"><?=gettext("Diff");?></th>
<th><?=gettext("Date");?></th>
<th><?=gettext("Version");?></th>
<th><?=gettext("Size");?></th>
<th><?=gettext("Configuration Change");?></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>
<input type="radio" name="newtime" value="current" <?= !isset($newcheck) || $newcheck == 'current' ? 'checked="checked"' : '' ?>/>
</td>
<td> <?=date(gettext("n/j/y H:i:s"), $config['revision']['time']) ?></td>
<td> <?=$config['version'] ?></td>
<td> <?=format_bytes(filesize("/conf/config.xml")) ?></td>
<td> <?="{$config['revision']['username']}: {$config['revision']['description']}" ?></td>
<td><b><?=gettext("Current");?></b></td>
</tr>
<?php <?php
$i = 0; foreach ($diff as $line):
foreach($confvers as $version):?> switch (substr($line, 0, 1)) {
case '+':
$color = '#3bbb33';
break;
case '-':
$color = '#c13928';
break;
case '@':
$color = '#3bb9c3';
break;
default:
$color = '#000000';
}
?>
<tr> <tr>
<td> <td style="color: <?=$color;?>; white-space: pre-wrap; font-family: monospace;"><?=htmlentities($line);?></td>
<input type="radio" name="oldtime" value="<?=$version['time'];?>" <?= (!isset($oldcheck) && $i == 0) || (isset($oldcheck) && $oldcheck == $version['time']) ? 'checked="checked"' : '' ?>/>
</td>
<td>
<input type="radio" name="newtime" value="<?=$version['time'];?>" <?= isset($newcheck) && $newcheck == $version['time'] ? 'checked="checked"' : ''?>/>
</td>
<td> <?= date(gettext("n/j/y H:i:s"), $version['time']) ?></td>
<td> <?= $version['version'] ?></td>
<td> <?= format_bytes($version['filesize']) ?></td>
<td> <?= "{$version['username']}: {$version['description']}" ?></td>
<td>
<a data-id="<?=$version['time'];?>" href="#" class="act_revert btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Revert to this configuration");?>">
<span class="glyphicon glyphicon-log-in"></span>
</a>
<a data-id="<?=$version['time'];?>" href="#" class="act_delete btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Remove this backup");?>" >
<span class="fa fa-trash text-muted"></span>
</a>
<a href="diag_confbak.php?getcfg=<?=$version['time'];?>" class="btn btn-default btn-xs" title="<?=gettext("Download this backup");?>">
<span class="glyphicon glyphicon-download"></span>
</a>
</td>
</tr> </tr>
<?php <?php
$i++;
endforeach;?> endforeach;?>
</tbody> </table>
</div>
</div>
</div>
</div>
</section>
<?php endif; ?>
<?php if (count($confvers)): ?>
<form method="get">
<section>
<div class="content-box">
<header class="content-box-head container-fluid">
<h3><?=gettext('History');?></h3>
</header>
<div class="content-box-main">
<div class="container-fluid __mb">
<table class="table table-condensed">
<tr>
<td>
<button type="submit" name="diff" class="btn btn-primary pull-left" value="Diff">
<?=gettext('View differences');?>
</button>
</td>
<td>
<?= gettext("To view the differences between an older configuration and a newer configuration, select the older configuration using the left column of radio options and select the newer configuration in the right column, then press the button."); ?>
</td>
</tr>
</table> </table>
</div> </div>
<table class="table table-striped">
<thead>
<tr>
<th colspan="2"><?=gettext("Diff");?></th>
<th><?=gettext("Date");?></th>
<th><?=gettext("Version");?></th>
<th><?=gettext("Size");?></th>
<th><?=gettext("Configuration Change");?></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td>
<input type="radio" name="newtime" value="current" <?= !isset($newcheck) || $newcheck == 'current' ? 'checked="checked"' : '' ?>/>
</td>
<td> <?=date(gettext("n/j/y H:i:s"), $config['revision']['time']) ?></td>
<td> <?=$config['version'] ?></td>
<td> <?=format_bytes(filesize("/conf/config.xml")) ?></td>
<td> <?="{$config['revision']['username']}: {$config['revision']['description']}" ?></td>
<td><b><?=gettext("Current");?></b></td>
</tr>
<?php
$last = count($confvers);
$curr = 1;
foreach($confvers as $version):?>
<tr>
<td>
<input type="radio" name="oldtime" value="<?=$version['time'];?>" <?= (!isset($oldcheck) && $curr == 1) || (isset($oldcheck) && $oldcheck == $version['time']) ? 'checked="checked"' : '' ?>/>
</td>
<td>
<?php if ($curr != $last): ?>
<input type="radio" name="newtime" value="<?=$version['time'];?>" <?= isset($newcheck) && $newcheck == $version['time'] ? 'checked="checked"' : ''?>/>
<?php endif ?>
</td>
<td> <?= date(gettext("n/j/y H:i:s"), $version['time']) ?></td>
<td> <?= $version['version'] ?></td>
<td> <?= format_bytes($version['filesize']) ?></td>
<td> <?= "{$version['username']}: {$version['description']}" ?></td>
<td>
<a data-id="<?=$version['time'];?>" href="#" class="act_revert btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Revert to this configuration");?>">
<span class="glyphicon glyphicon-log-in"></span>
</a>
<a data-id="<?=$version['time'];?>" href="#" class="act_delete btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("Remove this backup");?>" >
<span class="fa fa-trash text-muted"></span>
</a>
<a href="diag_confbak.php?getcfg=<?=$version['time'];?>" class="btn btn-default btn-xs" title="<?=gettext("Download this backup");?>">
<span class="glyphicon glyphicon-download"></span>
</a>
</td>
</tr>
<?php
$curr++;
endforeach;?>
</tbody>
</table>
</div> </div>
</section> </div>
</form> </section>
</div> </form>
<?php endif ?>
</section> </section>
</div> </div>
</div> </div>
......
...@@ -351,11 +351,8 @@ $(document).ready(function() { ...@@ -351,11 +351,8 @@ $(document).ready(function() {
</tr> </tr>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<p> <?=gettext("Graphs will not be allowed to be recreated within a 1 minute interval, please " .
<strong><span class="text-danger"><?=gettext("Note:");?></span></strong><br /> "take this into account after changing the style.");?>
<?=gettext("Graphs will not be allowed to be recreated within a 1 minute interval, please " .
"take this into account after changing the style.");?>
</p>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -565,10 +562,10 @@ $(document).ready(function() { ...@@ -565,10 +562,10 @@ $(document).ready(function() {
</td> </td>
</tr> </tr>
<tr> <tr>
<td colspan="2"><strong><span class="text-danger"><?=gettext("Note:")?></span></strong><br /> <td colspan="2">
<?=gettext("Syslog sends UDP datagrams to port 514 on the specified " . <?=gettext("Syslog sends UDP datagrams to port 514 on the specified " .
"remote syslog server, unless another port is specified. Be sure to set syslogd on the " . "remote syslog server, unless another port is specified. Be sure to set syslogd on the " .
"remote server to accept remote syslog messages.");?> "remote server to accept remote syslog messages.");?>
</td> </td>
</tr> </tr>
</table> </table>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment