Project

General

Profile

Download (4.74 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
/*	
31
	pfSense_MODULE:	config
32
*/
33

    
34
##|+PRIV
35
##|*IDENT=page-diagnostics-configurationhistory
36
##|*NAME=Diagnostics: Configuration History page
37
##|*DESCR=Allow access to the 'Diagnostics: Configuration History' page.
38
##|*MATCH=diag_confbak.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42

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

    
53
if($_GET['rmver'] != "") {
54
	conf_mount_rw();
55
	$confvers = unserialize(file_get_contents($g['cf_conf_path'] . '/backup/backup.cache'));
56
	unlink_if_exists($g['conf_path'] . '/backup/config-' . $_GET['rmver'] . '.xml');
57
	$savemsg = "Deleted backup with timestamp " . date("n/j/y H:i:s", $_GET['rmver']) . " and description \"" . $confvers[$_GET['rmver']]['description'] . "\".";
58
	conf_mount_ro();
59
}
60

    
61
cleanup_backupcache();
62
$confvers = get_backups();
63
unset($confvers['versions']);
64

    
65
$pgtitle = array("Diagnostics","Configuration History");
66
include("head.inc");
67

    
68
?>
69

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