Show backup file size in config history.

This commit is contained in:
jim-p 2013-12-26 11:07:13 -05:00
parent 57671f81d4
commit bfe615ee53
2 changed files with 17 additions and 16 deletions

View File

@ -747,7 +747,8 @@ function cleanup_backupcache($revisions = 30, $lock = false) {
$tocache = array();
foreach($bakfiles as $backup) { // Check for backups in the directory not represented in the cache.
if(filesize($backup) == 0) {
$backupsize = filesize($backup);
if($backupsize == 0) {
unlink($backup);
continue;
}
@ -767,7 +768,7 @@ function cleanup_backupcache($revisions = 30, $lock = false) {
$newxml['revision']['description'] = "Unknown";
if($newxml['version'] == "")
$newxml['version'] = "?";
$tocache[$tocheck] = array('description' => $newxml['revision']['description'], 'version' => $newxml['version']);
$tocache[$tocheck] = array('description' => $newxml['revision']['description'], 'version' => $newxml['version'], 'filesize' => $backupsize);
}
}
foreach($backups as $checkbak) {
@ -778,7 +779,7 @@ function cleanup_backupcache($revisions = 30, $lock = false) {
if($g['booting']) print " " . $tocheck . "r";
}
}
foreach($newbaks as $todo) $tocache[$todo['time']] = array('description' => $todo['description'], 'version' => $todo['version']);
foreach($newbaks as $todo) $tocache[$todo['time']] = array('description' => $todo['description'], 'version' => $todo['version'], 'filesize' => $todo['filesize']);
if(is_int($revisions) and (count($tocache) > $revisions)) {
$toslice = array_slice(array_keys($tocache), 0, $revisions);
foreach($toslice as $sliced)
@ -809,7 +810,7 @@ function get_backups() {
sort($bakvers);
// $bakvers = array_reverse($bakvers);
foreach(array_reverse($bakvers) as $bakver)
$toreturn[] = array('time' => $bakver, 'description' => $confvers[$bakver]['description'], 'version' => $confvers[$bakver]['version']);
$toreturn[] = array('time' => $bakver, 'description' => $confvers[$bakver]['description'], 'version' => $confvers[$bakver]['version'], 'filesize' => $confvers[$bakver]['filesize']);
} else {
return false;
}
@ -840,14 +841,14 @@ function backup_config() {
}
$bakver = ($config['version'] == "") ? "?" : $config['version'];
copy($g['cf_conf_path'] . '/config.xml', $g['cf_conf_path'] . '/backup/config-' . $baktime . '.xml');
$bakfilename = $g['cf_conf_path'] . '/backup/config-' . $baktime . '.xml';
copy($g['cf_conf_path'] . '/config.xml', $bakfilename);
if(file_exists($g['cf_conf_path'] . '/backup/backup.cache')) {
$backupcache = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
} else {
$backupcache = array();
}
$backupcache[$baktime] = array('description' => $bakdesc, 'version' => $bakver);
$backupcache[$baktime] = array('description' => $bakdesc, 'version' => $bakver, 'filesize' => filesize($bakfilename));
$bakout = fopen($g['cf_conf_path'] . '/backup/backup.cache', "w");
fwrite($bakout, serialize($backupcache));
fclose($bakout);

View File

@ -149,10 +149,12 @@ include("head.inc");
<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
<?php if (is_array($confvers)): ?>
<tr>
<td colspan="2" valign="middle" align="center" class="list" nowrap><input type="submit" name="diff" value="<?=gettext("Diff"); ?>"></td>
<td width="22%" class="listhdrr"><?=gettext("Date");?></td>
<td width="8%" class="listhdrr"><?=gettext("Version");?></td>
<td width="70%" class="listhdrr"><?=gettext("Configuration Change");?></td>
<td width="5%" colspan="2" valign="middle" align="center" class="list" nowrap><input type="submit" name="diff" value="<?=gettext("Diff"); ?>"></td>
<td width="20%" class="listhdrr"><?=gettext("Date");?></td>
<td width="5%" class="listhdrr"><?=gettext("Version");?></td>
<td width="5%" class="listhdrr"><?=gettext("Size");?></td>
<td width="60%" class="listhdrr"><?=gettext("Configuration Change");?></td>
<td width="5%" class="list">&nbsp;</td>
</tr>
<tr valign="top">
<td valign="middle" class="list" nowrap></td>
@ -161,8 +163,9 @@ include("head.inc");
</td>
<td class="listlr"> <?= date(gettext("n/j/y H:i:s"), $config['revision']['time']) ?></td>
<td class="listr"> <?= $config['version'] ?></td>
<td class="listr"> <?= format_bytes(filesize("/conf/config.xml")) ?></td>
<td class="listr"> <?= $config['revision']['description'] ?></td>
<td colspan="3" valign="middle" class="list" nowrap><b><?=gettext("Current");?></b></td>
<td valign="middle" class="list" nowrap><b><?=gettext("Current");?></b></td>
</tr>
<?php
$c = 0;
@ -186,18 +189,15 @@ include("head.inc");
</td>
<td class="listlr"> <?= $date ?></td>
<td class="listr"> <?= $version['version'] ?></td>
<td class="listr"> <?= format_bytes($version['filesize']) ?></td>
<td class="listr"> <?= $version['description'] ?></td>
<td valign="middle" class="list" nowrap>
<a href="diag_confbak.php?newver=<?=$version['time'];?>" onclick="return confirm('<?=gettext("Revert to this configuration?");?>'")>
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0" alt="<?=gettext("Revert to this configuration");?>" title="<?=gettext("Revert to this configuration");?>">
</a>
</td>
<td valign="middle" class="list" nowrap>
<a href="diag_confbak.php?rmver=<?=$version['time'];?>" onclick="return confirm('<?=gettext("Delete this configuration backup?");?>')">
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" alt="<?=gettext("Remove this backup");?>" title="<?=gettext("Remove this backup");?>">
</a>
</td>
<td valign="middle" class="list" nowrap>
<a href="diag_confbak.php?getcfg=<?=$version['time'];?>">
<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_down.gif" width="17" height="17" border="0" alt="<?=gettext("Download this backup");?>" title="<?=gettext("Download this backup");?>">
</a>