Project

General

Profile

Feature #14761 » diag_confbak.php-v1.0.patch

Phil Wardt, 09/08/2023 01:36 PM

View differences:

src/usr/local/www/diag_confbak.php
64 64
	$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']));
65 65
}
66 66

  
67
if ($_REQUEST['del_x'] == 'DelAll') {
68
	if (is_array($_REQUEST['confdel_x']) && count($_REQUEST['confdel_x'])) {
69
		$savemsg = "";
70
		foreach ($_REQUEST['confdel_x'] as $version) {
71
			$conf_file = g_get('conf_path') . '/backup/config-' . $version . '.xml';
72
			if (file_exists($conf_file)) {
73
				unlink($conf_file);
74
				$savemsg .= sprintf(gettext('Deleted backup with timestamp %1$s and description "%2$s"<br />'), date(gettext("n/j/y H:i:s"), $version), htmlspecialchars($confvers[$version]['description']));
75
				$savemsg .= gettext('&nbsp;&nbsp;&nbsp;&nbsp; ->' . htmlspecialchars($g['conf_path']) . '/backup/config-' . htmlspecialchars($version) . '.xml' . "<br />");
76
			} else {
77
				$input_errors[] .= gettext("Could not find config file: " . htmlspecialchars($conf_file));
78
			}
79
		}
80
	} else {
81
		$input_errors = gettext("You must select at least one config to delete.");
82
	}
83
}
84

  
67 85
if ($_REQUEST['getcfg'] != "") {
68 86
	$_REQUEST['getcfg'] = basename($_REQUEST['getcfg']);
69 87
	send_user_download('file',
......
94 112
unset($confvers['versions']);
95 113

  
96 114
$pgtitle = array(gettext("Diagnostics"), htmlspecialchars(gettext("Backup & Restore")), gettext("Config History"));
97
$pglinks = array("", "diag_backup.php", "@self");
115
$pglinks = array("", "diag_backup.php", "diag_confbak.php");
98 116
include("head.inc");
99 117

  
100 118
if ($input_errors) {
......
215 233
					<th><?=gettext("Size")?></th>
216 234
					<th><?=gettext("Configuration Change")?></th>
217 235
					<th><?=gettext("Actions")?></th>
236
					<th>
237
						<button id="del_x" name="del_x" type="submit" class="btn btn-danger btn-xs" value="DelAll" disabled title="Delete selected configs">
238
							<i class="fa fa-trash icon-embed-btn"></i>
239
							<?=gettext("Delete"); ?>
240
						</button>
241
					</th>
218 242
				</tr>
219 243
			</thead>
220 244
			<tbody>
......
233 257
<?php
234 258
	// And now for the table of prior backups
235 259
	$c = 0;
260
	$nconfig = 0;
236 261
	foreach ($confvers as $version):
237 262
		if ($version['time'] != 0) {
238 263
			$date = date(gettext("n/j/y H:i:s"), $version['time']);
......
240 265
			$date = gettext("Unknown");
241 266
		}
242 267
?>
243
				<tr>
268
				<tr id="fr<?=$nconfig;?>" onClick="fr_toggle(<?=$nconfig;?>)">
244 269
					<td>
245 270
						<input type="radio" name="oldtime" value="<?=$version['time']?>" />
246 271
					</td>
......
263 288
						<a class="fa fa-download"		title="<?=gettext('Download this configuration revision')?>"			href="diag_confbak.php?getcfg=<?=$version['time']?>"></a>
264 289
						<a class="fa fa-trash"			title="<?=gettext('Delete this configuration revision')?>"			href="diag_confbak.php?rmver=<?=$version['time']?>" usepost></a>
265 290
					</td>
291
					<td>
292
						<input type="checkbox" id="frc<?=$nconfig;?>" onClick="fr_toggle(<?=$nconfig;?>)" name="confdel_x[]" value="<?=$version['time']?>"/>
293
					</td>
266 294
				</tr>
267 295
<?php
296
	$nconfig++;
268 297
	endforeach;
269 298
?>
270 299
				<tr>
......
276 305
					</td>
277 306
					<td colspan="5"></td>
278 307
				</tr>
308

  
309
<script type="text/javascript">
310
//<![CDATA[
311
events.push(function() {
312
	$('[id^=fr]').click(function () {
313
		buttonsmode('frc', ['del_x']);
314
	});
315
});
316
//]]>
317
</script>
318

  
319

  
279 320
<?php
280 321
else:
281 322
	print_info_box(gettext("No backups found."), 'danger');
(1-1/2)