Projet

Général

Profil

« Précédent | Suivant » 

Révision 889c83d7

Ajouté par jim-p il y a plus de 9 ans

Require click-through POST confirmation when restoring or deleting a configuation from the backup history page.

Voir les différences:

usr/local/www/diag_confbak.php
41 41

  
42 42
require("guiconfig.inc");
43 43

  
44
if($_GET['newver'] != "") {
45
	conf_mount_rw();
46
	$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
47
	if(config_restore($g['conf_path'] . '/backup/config-' . $_GET['newver'] . '.xml') == 0)
48

  
49
	$savemsg = sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $_GET['newver']), $confvers[$_GET['newver']]['description']);
50
	else
51
		$savemsg = gettext("Unable to revert to the selected configuration.");
52
	conf_mount_ro();
53
}
44
if ($_POST) {
45
	if (!isset($_POST['confirm']) || ($_POST['confirm'] != gettext("Confirm")) || (!isset($_POST['newver']) && !isset($_POST['rmver']))) {
46
		header("Location: diag_confbak.php");
47
		return;
48
	}
54 49

  
55
if($_GET['rmver'] != "") {
56 50
	conf_mount_rw();
57 51
	$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
58
	unlink_if_exists($g['conf_path'] . '/backup/config-' . $_GET['rmver'] . '.xml');
59
	$savemsg = sprintf(gettext('Deleted backup with timestamp %1$s and description "%2$s".'), date(gettext("n/j/y H:i:s"), $_GET['rmver']),$confvers[$_GET['rmver']]['description']);
52
	if($_POST['newver'] != "") {
53
		if(config_restore($g['conf_path'] . '/backup/config-' . $_POST['newver'] . '.xml') == 0)
54
		$savemsg = sprintf(gettext('Successfully reverted to timestamp %1$s with description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['newver']), $confvers[$_POST['newver']]['description']);
55
		else
56
			$savemsg = gettext("Unable to revert to the selected configuration.");
57
	}
58
	if($_POST['rmver'] != "") {
59
		unlink_if_exists($g['conf_path'] . '/backup/config-' . $_POST['rmver'] . '.xml');
60
		$savemsg = sprintf(gettext('Deleted backup with timestamp %1$s and description "%2$s".'), date(gettext("n/j/y H:i:s"), $_POST['rmver']),$confvers[$_POST['rmver']]['description']);
61
	}
60 62
	conf_mount_ro();
61 63
}
62 64

  
......
145 147
		<tr>
146 148
			<td>
147 149
				<div id="mainarea">
150
<?PHP if ($_GET["newver"] || $_GET["rmver"]): ?>
151
					<form action="diag_confbak.php" method="post">
152
<?PHP else: ?>
148 153
					<form action="diag_confbak.php" method="get">
154
<?PHP endif; ?>
149 155
					<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
156

  
157
<?PHP if ($_GET["newver"] || $_GET["rmver"]): ?>
158
					<tr>
159
						<td colspan="2" valign="top" class="listtopic"><?PHP echo gettext("Confirm Action"); ?></td>
160
					</tr>
161
					<tr>
162
						<td width="22%" valign="top" class="vncell">&nbsp;</td>
163
						<td width="78%" class="vtable">
164

  
165
							<strong><?PHP echo gettext("Please confirm the selected action"); ?></strong>:
166
							<br />
167
							<br /><strong><?PHP echo gettext("Action"); ?>:</strong>
168
						<?PHP	if (!empty($_GET["newver"])) {
169
							echo gettext("Restore from Configuration Backup");
170
							$target_config = $_GET["newver"]; ?>
171
							<input type="hidden" name="newver" value="<?PHP echo htmlspecialchars($_GET["newver"]); ?>" />
172
						<?PHP	} elseif (!empty($_GET["rmver"])) {
173
							echo gettext("Remove Configuration Backup");
174
							$target_config = $_GET["rmver"]; ?>
175
							<input type="hidden" name="rmver" value="<?PHP echo htmlspecialchars($_GET["rmver"]); ?>" />
176
						<?PHP	} ?>
177
							<br /><strong><?PHP echo gettext("Target Configuration"); ?>:</strong>
178
							<?PHP echo sprintf(gettext('Timestamp %1$s'), date(gettext("n/j/y H:i:s"), $target_config)); ?>
179
							<br /><input type="submit" name="confirm" value="<?PHP echo gettext("Confirm"); ?>" />
180
						</td>
181
					</tr>
182
<?PHP else: ?>
183

  
150 184
						<?php if (is_array($confvers)): ?>
151 185
						<tr>
152 186
							<td colspan="2" valign="middle" align="center" class="list" nowrap><input type="submit" name="diff" value="<?=gettext("Diff"); ?>"></td>
......
188 222
							<td class="listr"> <?= $version['version'] ?></td>
189 223
							<td class="listr"> <?= $version['description'] ?></td>
190 224
							<td valign="middle" class="list" nowrap>
191
							<a href="diag_confbak.php?newver=<?=$version['time'];?>" onclick="return confirm('<?=gettext("Revert to this configuration?");?>'")>
225
							<a href="diag_confbak.php?newver=<?=$version['time'];?>">
192 226
							<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");?>">
193 227
								</a>
194 228
							</td>
195 229
							<td valign="middle" class="list" nowrap>
196
							<a href="diag_confbak.php?rmver=<?=$version['time'];?>" onclick="return confirm('<?=gettext("Delete this configuration backup?");?>')">
230
							<a href="diag_confbak.php?rmver=<?=$version['time'];?>">
197 231
							<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");?>">
198 232
								</a>
199 233
							</td>
......
215 249
							</td>
216 250
						</tr>
217 251
						<?php endif; ?>
252

  
253
<?php endif; ?>
218 254
					</table>
219 255
					</form>
220 256
				</div>

Formats disponibles : Unified diff