Project

General

Profile

Download (4.64 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
    diag_confbak.php
5
    Copyright (C) 2005 Colin Smith
6
    All rights reserved.
7

    
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

    
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

    
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

    
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
##|+PRIV
31
##|*IDENT=page-diagnostics-configurationhistory
32
##|*NAME=Diagnostics: Configuration History page
33
##|*DESCR=Allow access to the 'Diagnostics: Configuration History' page.
34
##|*MATCH=diag_confbak.php*
35
##|-PRIV
36

    
37

    
38
require("guiconfig.inc");
39

    
40
if($_GET['newver'] != "") {
41
	$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
42
	if(config_restore($g['conf_path'] . '/backup/config-' . $_GET['newver'] . '.xml') == 0)
43
		$savemsg = "Successfully reverted to timestamp " . date("n/j/y H:i:s", $_GET['newver']) . " with description \"" . $confvers[$_GET['newver']]['description'] . "\".";
44
	else
45
		$savemsg = "Unable to revert to the selected configuration.";
46
}
47

    
48
if($_GET['rmver'] != "") {
49
	$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
50
	unlink_if_exists($g['conf_path'] . '/backup/config-' . $_GET['rmver'] . '.xml');
51
	$savemsg = "Deleted backup with timestamp " . date("n/j/y H:i:s", $_GET['rmver']) . " and description \"" . $confvers[$_GET['rmver']]['description'] . "\".";
52
}
53

    
54
cleanup_backupcache();
55
$confvers = get_backups();
56
unset($confvers['versions']);
57

    
58
$pgtitle = array("Diagnostics","Configuration History");
59
include("head.inc");
60

    
61
?>
62

    
63
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
	<?php
65
		include("fbegin.inc");
66
		if($savemsg)
67
			print_info_box($savemsg);
68
	?>
69
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
70
		<tr>
71
			<td>
72
			<?php
73
				$tab_array = array();
74
				$tab_array[0] = array("Config History", true, "diag_confbak.php");
75
				$tab_array[1] = array("Backup/Restore", false, "diag_backup.php");
76
				display_top_tabs($tab_array);
77
			?>			
78
			</td>
79
		</tr>
80
		<tr>
81
			<td>
82
				<div id="mainarea">
83
					<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
84
						<?php if (is_array($confvers)): ?>
85
						<tr>
86
							<td width="30%" class="listhdrr">Date</td>
87
							<td width="70%" class="listhdrr">Configuration Change</td>
88
						</tr>
89
						<tr valign="top">
90
							<td class="listlr"> <?= date("n/j/y H:i:s", $config['revision']['time']) ?></td>
91
							<td class="listr"> <?= $config['revision']['description'] ?></td>
92
							<td colspan="2" valign="middle" class="list" nowrap><b>Current</b></td>
93
						</tr>
94
						<?php
95
							foreach($confvers as $version):
96
								if($version['time'] != 0)
97
									$date = date("n/j/y H:i:s", $version['time']);
98
								else
99
									$date = "Unknown";
100
								$desc = $version['description'];
101
						?>
102
						<tr valign="top">
103
							<td class="listlr"> <?= $date ?></td>
104
							<td class="listr"> <?= $desc ?></td>
105
							<td valign="middle" class="list" nowrap>
106
								<a href="diag_confbak.php?newver=<?=$version['time'];?>">
107
									<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0">
108
								</a>
109
							</td>
110
							<td valign="middle" class="list" nowrap>
111
								<a href="diag_confbak.php?rmver=<?=$version['time'];?>">
112
									<img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0">
113
								</a>
114
							</td>
115
						</tr>
116
						<?php endforeach; ?>
117
						<?php else: ?>
118
						<tr>
119
							<td>
120
								<?php print_info_box("No backups found."); ?>
121
							</td>
122
						</tr>
123
						<?php endif; ?>
124
					</table>
125
				</div>
126
			</td>
127
		</tr>
128
	</table>
129
</form>
130
<?php include("fend.inc"); ?>
131
</body>
132
</html>
(4-4/206)