Revision 5f601060
Added by Phil Davis over 10 years ago
usr/local/www/diag_confbak.php | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
/* $Id$ */ |
3 | 3 |
/* |
4 |
diag_confbak.php
|
|
5 |
Copyright (C) 2005 Colin Smith
|
|
6 |
Copyright (C) 2010 Jim Pingle
|
|
7 |
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
|
8 |
All rights reserved.
|
|
4 |
diag_confbak.php
|
|
5 |
Copyright (C) 2005 Colin Smith
|
|
6 |
Copyright (C) 2010 Jim Pingle
|
|
7 |
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
|
8 |
All rights reserved.
|
|
9 | 9 |
|
10 |
Redistribution and use in source and binary forms, with or without
|
|
11 |
modification, are permitted provided that the following conditions are met:
|
|
10 |
Redistribution and use in source and binary forms, with or without
|
|
11 |
modification, are permitted provided that the following conditions are met:
|
|
12 | 12 |
|
13 |
1. Redistributions of source code must retain the above copyright notice,
|
|
14 |
this list of conditions and the following disclaimer.
|
|
13 |
1. Redistributions of source code must retain the above copyright notice,
|
|
14 |
this list of conditions and the following disclaimer.
|
|
15 | 15 |
|
16 |
2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
notice, this list of conditions and the following disclaimer in the
|
|
18 |
documentation and/or other materials provided with the distribution.
|
|
16 |
2. Redistributions in binary form must reproduce the above copyright
|
|
17 |
notice, this list of conditions and the following disclaimer in the
|
|
18 |
documentation and/or other materials provided with the distribution.
|
|
19 | 19 |
|
20 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
21 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
22 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
23 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
24 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29 |
POSSIBILITY OF SUCH DAMAGE.
|
|
20 |
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
21 |
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
22 |
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
23 |
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
24 |
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
25 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
26 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
27 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
28 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29 |
POSSIBILITY OF SUCH DAMAGE.
|
|
30 | 30 |
*/ |
31 | 31 |
|
32 | 32 |
/* |
... | ... | |
59 | 59 |
|
60 | 60 |
conf_mount_rw(); |
61 | 61 |
$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache')); |
62 |
if($_POST['newver'] != "") { |
|
63 |
if(config_restore($g['conf_path'] . '/backup/config-' . $_POST['newver'] . '.xml') == 0)
|
|
64 |
$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'])); |
|
65 |
else
|
|
62 |
if ($_POST['newver'] != "") {
|
|
63 |
if (config_restore($g['conf_path'] . '/backup/config-' . $_POST['newver'] . '.xml') == 0) {
|
|
64 |
$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']));
|
|
65 |
} else {
|
|
66 | 66 |
$savemsg = gettext("Unable to revert to the selected configuration."); |
67 |
} |
|
67 | 68 |
} |
68 |
if($_POST['rmver'] != "") { |
|
69 |
if ($_POST['rmver'] != "") {
|
|
69 | 70 |
unlink_if_exists($g['conf_path'] . '/backup/config-' . $_POST['rmver'] . '.xml'); |
70 | 71 |
$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'])); |
71 | 72 |
} |
72 | 73 |
conf_mount_ro(); |
73 | 74 |
} |
74 | 75 |
|
75 |
if($_GET['getcfg'] != "") { |
|
76 |
if ($_GET['getcfg'] != "") {
|
|
76 | 77 |
$file = $g['conf_path'] . '/backup/config-' . $_GET['getcfg'] . '.xml'; |
77 | 78 |
|
78 | 79 |
$exp_name = urlencode("config-{$config['system']['hostname']}.{$config['system']['domain']}-{$_GET['getcfg']}.xml"); |
... | ... | |
86 | 87 |
exit; |
87 | 88 |
} |
88 | 89 |
|
89 |
if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime']) |
|
90 |
&& is_numeric($_GET['oldtime']) && (is_numeric($_GET['newtime']) || ($_GET['newtime'] == 'current'))) { |
|
90 |
if (($_GET['diff'] == 'Diff') && isset($_GET['oldtime']) && isset($_GET['newtime']) && |
|
91 |
(is_numeric($_GET['oldtime'])) && |
|
92 |
(is_numeric($_GET['newtime']) || ($_GET['newtime'] == 'current'))) { |
|
91 | 93 |
$diff = ""; |
92 | 94 |
$oldfile = $g['conf_path'] . '/backup/config-' . $_GET['oldtime'] . '.xml'; |
93 | 95 |
$oldtime = $_GET['oldtime']; |
... | ... | |
115 | 117 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> |
116 | 118 |
<?php |
117 | 119 |
include("fbegin.inc"); |
118 |
if($savemsg)
|
|
120 |
if ($savemsg) {
|
|
119 | 121 |
print_info_box($savemsg); |
122 |
} |
|
120 | 123 |
?> |
121 | 124 |
<?php if ($diff) { ?> |
122 | 125 |
<table align="center" width="100%" border="0" cellspacing="0" style="padding-top: 4px; padding-bottom: 4px; vertical-align:middle;" summary="diag confbak"> |
... | ... | |
160 | 163 |
<form action="diag_confbak.php" method="post"> |
161 | 164 |
<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0" summary="tabcont"> |
162 | 165 |
|
163 |
<?PHP if ($_GET["newver"] || $_GET["rmver"]): ?>
|
|
164 |
<tr> |
|
165 |
<td colspan="2" valign="top" class="listtopic"><?PHP echo gettext("Confirm Action"); ?></td>
|
|
166 |
</tr> |
|
167 |
<tr> |
|
168 |
<td width="22%" valign="top" class="vncell"> </td> |
|
169 |
<td width="78%" class="vtable"> |
|
166 |
<?php if ($_GET["newver"] || $_GET["rmver"]): ?>
|
|
167 |
<tr>
|
|
168 |
<td colspan="2" valign="top" class="listtopic"><?php echo gettext("Confirm Action"); ?></td>
|
|
169 |
</tr>
|
|
170 |
<tr>
|
|
171 |
<td width="22%" valign="top" class="vncell"> </td>
|
|
172 |
<td width="78%" class="vtable">
|
|
170 | 173 |
|
171 |
<strong><?PHP echo gettext("Please confirm the selected action"); ?></strong>:
|
|
172 |
<br /> |
|
173 |
<br /><strong><?PHP echo gettext("Action"); ?>:</strong>
|
|
174 |
<?PHP if (!empty($_GET["newver"])) {
|
|
175 |
echo gettext("Restore from Configuration Backup"); |
|
176 |
$target_config = $_GET["newver"]; ?> |
|
177 |
<input type="hidden" name="newver" value="<?PHP echo htmlspecialchars($_GET["newver"]); ?>" />
|
|
178 |
<?PHP } elseif (!empty($_GET["rmver"])) {
|
|
179 |
echo gettext("Remove Configuration Backup"); |
|
180 |
$target_config = $_GET["rmver"]; ?> |
|
181 |
<input type="hidden" name="rmver" value="<?PHP echo htmlspecialchars($_GET["rmver"]); ?>" />
|
|
182 |
<?PHP } ?>
|
|
183 |
<br /><strong><?PHP echo gettext("Target Configuration"); ?>:</strong>
|
|
184 |
<?PHP echo sprintf(gettext('Timestamp %1$s'), date(gettext("n/j/y H:i:s"), $target_config)); ?>
|
|
185 |
<br /><input type="submit" name="confirm" value="<?PHP echo gettext("Confirm"); ?>" />
|
|
186 |
</td> |
|
187 |
</tr> |
|
188 |
<?PHP else: ?>
|
|
174 |
<strong><?php echo gettext("Please confirm the selected action"); ?></strong>:
|
|
175 |
<br />
|
|
176 |
<br /><strong><?php echo gettext("Action"); ?>:</strong>
|
|
177 |
<?php if (!empty($_GET["newver"])) {
|
|
178 |
echo gettext("Restore from Configuration Backup");
|
|
179 |
$target_config = $_GET["newver"]; ?>
|
|
180 |
<input type="hidden" name="newver" value="<?php echo htmlspecialchars($_GET["newver"]); ?>" />
|
|
181 |
<?php } elseif (!empty($_GET["rmver"])) {
|
|
182 |
echo gettext("Remove Configuration Backup");
|
|
183 |
$target_config = $_GET["rmver"]; ?>
|
|
184 |
<input type="hidden" name="rmver" value="<?php echo htmlspecialchars($_GET["rmver"]); ?>" />
|
|
185 |
<?php } ?>
|
|
186 |
<br /><strong><?php echo gettext("Target Configuration"); ?>:</strong>
|
|
187 |
<?php echo sprintf(gettext('Timestamp %1$s'), date(gettext("n/j/y H:i:s"), $target_config)); ?>
|
|
188 |
<br /><input type="submit" name="confirm" value="<?php echo gettext("Confirm"); ?>" />
|
|
189 |
</td>
|
|
190 |
</tr>
|
|
191 |
<?php else: ?>
|
|
189 | 192 |
|
190 | 193 |
<tr> |
191 | 194 |
<td width="10%"> </td> |
... | ... | |
236 | 239 |
</tr> |
237 | 240 |
<?php |
238 | 241 |
$c = 0; |
239 |
foreach($confvers as $version): |
|
240 |
if($version['time'] != 0)
|
|
242 |
foreach ($confvers as $version):
|
|
243 |
if ($version['time'] != 0) {
|
|
241 | 244 |
$date = date(gettext("n/j/y H:i:s"), $version['time']); |
242 |
else
|
|
245 |
} else {
|
|
243 | 246 |
$date = gettext("Unknown"); |
247 |
} |
|
244 | 248 |
?> |
245 | 249 |
<tr valign="top"> |
246 | 250 |
<td class="list"> |
Also available in: Unified diff
Code style usr-local-www diag