1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
diag_confbak.php
|
6
|
Copyright (C) 2005 Colin Smith
|
7
|
All rights reserved.
|
8
|
|
9
|
Redistribution and use in source and binary forms, with or without
|
10
|
modification, are permitted provided that the following conditions are met:
|
11
|
|
12
|
1. Redistributions of source code must retain the above copyright notice,
|
13
|
this list of conditions and the following disclaimer.
|
14
|
|
15
|
2. Redistributions in binary form must reproduce the above copyright
|
16
|
notice, this list of conditions and the following disclaimer in the
|
17
|
documentation and/or other materials provided with the distribution.
|
18
|
|
19
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28
|
POSSIBILITY OF SUCH DAMAGE.
|
29
|
*/
|
30
|
|
31
|
require("guiconfig.inc");
|
32
|
|
33
|
if($_GET['newver'] != "") {
|
34
|
$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
|
35
|
if(config_restore($g['conf_path'] . '/backup/config-' . $_GET['newver'] . '.xml') == 0) {
|
36
|
$savemsg = "Successfully reverted to timestamp " . date("n/j/y H:i:s", $_GET['newver']) . " with description \"" . $confvers[$_GET['newver']]['description'] . "\".";
|
37
|
} else {
|
38
|
$savemsg = "Unable to revert to the selected configuration.";
|
39
|
}
|
40
|
}
|
41
|
|
42
|
if($_GET['rmver'] != "") {
|
43
|
$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
|
44
|
unlink_if_exists($g['conf_path'] . '/backup/config-' . $_GET['rmver'] . '.xml');
|
45
|
$savemsg = "Deleted backup with timestamp " . date("n/j/y H:i:s", $_GET['rmver']) . " and description \"" . $confvers[$_GET['rmver']]['description'] . "\".";
|
46
|
}
|
47
|
|
48
|
cleanup_backupcache();
|
49
|
$confvers = get_backups();
|
50
|
unset($confvers['versions']);
|
51
|
|
52
|
$pgtitle = "Diagnostics: Configuration History";
|
53
|
include("head.inc");
|
54
|
|
55
|
?>
|
56
|
|
57
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
58
|
<?php include("fbegin.inc"); ?>
|
59
|
<p class="pgtitle"><?=$pgtitle?></p>
|
60
|
<?php if($savemsg) print_info_box($savemsg); ?>
|
61
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
62
|
<?php
|
63
|
$tab_array = array();
|
64
|
$tab_array[0] = array("Remote", false, "diag_backup.php");
|
65
|
$tab_array[1] = array("Local", true, "diag_confbak.php");
|
66
|
display_top_tabs($tab_array);
|
67
|
?>
|
68
|
</td></tr>
|
69
|
<tr>
|
70
|
<td>
|
71
|
<div id="mainarea">
|
72
|
<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
|
73
|
<?php
|
74
|
if(is_array($confvers)) {
|
75
|
?>
|
76
|
<tr>
|
77
|
<td width="30%" class="listhdrr">Date</td>
|
78
|
<td width="70%" class="listhdrr">Configuration Change</td>
|
79
|
</tr>
|
80
|
|
81
|
<tr valign="top">
|
82
|
<td class="listlr"> <?= date("n/j/y H:i:s", $config['revision']['time']) ?></td>
|
83
|
<td class="listlr"> <?= $config['revision']['description'] ?></td>
|
84
|
<td colspan="2" valign="middle" class="list" nowrap><b>Current</b></td>
|
85
|
</tr>
|
86
|
<?php
|
87
|
foreach($confvers as $version) {
|
88
|
if($version['time'] != 0) {
|
89
|
$date = date("n/j/y H:i:s", $version['time']);
|
90
|
} else {
|
91
|
$date = "Unknown";
|
92
|
}
|
93
|
$desc = $version['description'];
|
94
|
?>
|
95
|
<tr valign="top">
|
96
|
<td class="listlr"> <?= $date ?></td>
|
97
|
<td class="listlr"> <?= $desc ?></td>
|
98
|
<td valign="middle" class="list" nowrap>
|
99
|
<a href="diag_confbak.php?newver=<?=$version['time'];?>"><img src="/themes/<?= $g['theme']; ?>/icons/icon_plus.gif" width="17" height="17" border="0"></a>
|
100
|
</td>
|
101
|
<td valign="middle" class="list" nowrap>
|
102
|
<a href="diag_confbak.php?rmver=<?=$version['time'];?>"><img src="/themes/<?= $g['theme']; ?>/icons/icon_x.gif" width="17" height="17" border="0"></a>
|
103
|
</tr>
|
104
|
<?php
|
105
|
} ?>
|
106
|
<?php } else {
|
107
|
print_info_box("No backups found.");
|
108
|
}
|
109
|
?>
|
110
|
</table>
|
111
|
</div>
|
112
|
</td>
|
113
|
</tr>
|
114
|
</table>
|
115
|
</body>
|
116
|
</html>
|
117
|
<?php include("fend.inc"); ?>
|
118
|
</body>
|
119
|
</html>
|