1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
system_firmware.php
|
6
|
Copyright (C) 2004, 2005 Scott Ullrich and 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
|
|
32
|
if ($_GET['newver']) {
|
33
|
$conf_file = "/cf/conf/backup/config-${_GET['newver']}.xml";
|
34
|
|
35
|
if (config_install($conf_file) == 0) {
|
36
|
system_reboot();
|
37
|
$savemsg = "The configuration has been restored. The firewall is now rebooting.";
|
38
|
} else {
|
39
|
$input_errors[] = "The configuration could not be restored.";
|
40
|
}
|
41
|
}
|
42
|
|
43
|
require("guiconfig.inc");
|
44
|
|
45
|
?>
|
46
|
|
47
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
48
|
<html>
|
49
|
<head>
|
50
|
<title><?=gentitle("Diagnostics: Configuration Restore");?></title>
|
51
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
52
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
53
|
</head>
|
54
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
55
|
<?php
|
56
|
include("fbegin.inc");
|
57
|
?>
|
58
|
<p class="pgtitle">Diagnostics: Local Restore</p>
|
59
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
60
|
<br>
|
61
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
62
|
<ul id="tabnav">
|
63
|
<li class="tabinact"><a href="diag_backup.php">Remote</a></li>
|
64
|
<li class="tabact">Local</a></li>
|
65
|
</ul>
|
66
|
</td></tr>
|
67
|
<tr>
|
68
|
<td class="tabcont">
|
69
|
<?php
|
70
|
if(file_exists("/conf/backup/backup.cache")) {
|
71
|
$confvers = unserialize(file_get_contents("/cf/conf/backup/backup.cache"));
|
72
|
} else {
|
73
|
print_info_box("No backups found.");
|
74
|
}
|
75
|
if(is_array($confvers)) { ?>
|
76
|
<table align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
|
77
|
<tr>
|
78
|
<td width="30%" class="listhdrr">Date</td>
|
79
|
<td width="70%" class="listhdrr">Configuration Change</td>
|
80
|
</tr>
|
81
|
|
82
|
<?php
|
83
|
$curconfigs = array();
|
84
|
$i = 0;
|
85
|
foreach($confvers as $version) {
|
86
|
$changes = array();
|
87
|
if($version == $config['revision']['time'] and $i == 0) {
|
88
|
$i++;
|
89
|
$changes['description'] = $config['revision']['description'];
|
90
|
$changes['time'] = $version;
|
91
|
$changes['date'] = "Current";
|
92
|
} else { // Use backup.cache to find the next usable backup.
|
93
|
if(file_exists("/conf/backup/config-{$version['time']}.xml")) {
|
94
|
$changes = $version;
|
95
|
$changes['date'] = date("n/j H:i:s", $changes['time']);
|
96
|
} else {
|
97
|
$i++;
|
98
|
continue;
|
99
|
}
|
100
|
}
|
101
|
|
102
|
if($changes['time'] == "") $changes['date'] = "Unknown.";
|
103
|
|
104
|
?>
|
105
|
<tr valign="top">
|
106
|
<td class="listlr"> <?= $changes['date'] ?></td>
|
107
|
<td class="listlr"> <?= $changes['description'] ?></td>
|
108
|
<?php if($changes['date'] != "Current") { ?>
|
109
|
<td valign="middle" class="list" nowrap>
|
110
|
<a href="diag_confbak.php?newver=<?=$changes['time'];?>"><img src="plus.gif" width="17" height="17" border="0"></a>
|
111
|
</td>
|
112
|
<?php } ?>
|
113
|
</tr>
|
114
|
<?php
|
115
|
$i++;
|
116
|
} ?>
|
117
|
</table>
|
118
|
<?php } ?>
|
119
|
</td>
|
120
|
</tr>
|
121
|
</table>
|
122
|
</body>
|
123
|
</html>
|