1 |
8ccc8f1a
|
Scott Ullrich
|
<?php
|
2 |
b46bfcf5
|
Bill Marquette
|
/* $Id$ */
|
3 |
5b237745
|
Scott Ullrich
|
/*
|
4 |
|
|
diag_backup.php
|
5 |
|
|
*/
|
6 |
fd9ebcd5
|
Stephen Beaver
|
/* ====================================================================
|
7 |
0e834fc5
|
Stephen Beaver
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
8 |
|
|
* Copyright (c) 2004, 2005 Scott Ullrich
|
9 |
fd9ebcd5
|
Stephen Beaver
|
*
|
10 |
0e834fc5
|
Stephen Beaver
|
* Redistribution and use in source and binary forms, with or without modification,
|
11 |
|
|
* are permitted provided that the following conditions are met:
|
12 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
0e834fc5
|
Stephen Beaver
|
* 1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
* this list of conditions and the following disclaimer.
|
15 |
fd9ebcd5
|
Stephen Beaver
|
*
|
16 |
0e834fc5
|
Stephen Beaver
|
* 2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
* notice, this list of conditions and the following disclaimer in
|
18 |
|
|
* the documentation and/or other materials provided with the
|
19 |
|
|
* distribution.
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*
|
21 |
0e834fc5
|
Stephen Beaver
|
* 3. All advertising materials mentioning features or use of this software
|
22 |
|
|
* must display the following acknowledgment:
|
23 |
|
|
* "This product includes software developed by the pfSense Project
|
24 |
|
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
25 |
fd9ebcd5
|
Stephen Beaver
|
*
|
26 |
0e834fc5
|
Stephen Beaver
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
27 |
|
|
* endorse or promote products derived from this software without
|
28 |
|
|
* prior written permission. For written permission, please contact
|
29 |
|
|
* coreteam@pfsense.org.
|
30 |
fd9ebcd5
|
Stephen Beaver
|
*
|
31 |
0e834fc5
|
Stephen Beaver
|
* 5. Products derived from this software may not be called "pfSense"
|
32 |
|
|
* nor may "pfSense" appear in their names without prior written
|
33 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
34 |
fd9ebcd5
|
Stephen Beaver
|
*
|
35 |
0e834fc5
|
Stephen Beaver
|
* 6. Redistributions of any form whatsoever must retain the following
|
36 |
|
|
* acknowledgment:
|
37 |
fd9ebcd5
|
Stephen Beaver
|
*
|
38 |
0e834fc5
|
Stephen Beaver
|
* "This product includes software developed by the pfSense Project
|
39 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
40 |
fd9ebcd5
|
Stephen Beaver
|
*
|
41 |
0e834fc5
|
Stephen Beaver
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
42 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
43 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
44 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
45 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
46 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
47 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
48 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
49 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
50 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
51 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
52 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
53 |
fd9ebcd5
|
Stephen Beaver
|
*
|
54 |
0e834fc5
|
Stephen Beaver
|
* ====================================================================
|
55 |
fd9ebcd5
|
Stephen Beaver
|
*
|
56 |
|
|
*/
|
57 |
5b237745
|
Scott Ullrich
|
|
58 |
13d193c2
|
Scott Ullrich
|
/*
|
59 |
|
|
pfSense_BUILDER_BINARIES: /sbin/shutdown
|
60 |
0e834fc5
|
Stephen Beaver
|
pfSense_MODULE: backup
|
61 |
13d193c2
|
Scott Ullrich
|
*/
|
62 |
|
|
|
63 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
64 |
|
|
##|*IDENT=page-diagnostics-backup/restore
|
65 |
|
|
##|*NAME=Diagnostics: Backup/restore page
|
66 |
|
|
##|*DESCR=Allow access to the 'Diagnostics: Backup/restore' page.
|
67 |
|
|
##|*MATCH=diag_backup.php*
|
68 |
|
|
##|-PRIV
|
69 |
|
|
|
70 |
47d11b79
|
Mark Crane
|
/* Allow additional execution time 0 = no limit. */
|
71 |
3420028c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
72 |
|
|
ini_set('max_input_time', '0');
|
73 |
47d11b79
|
Mark Crane
|
|
74 |
5b237745
|
Scott Ullrich
|
/* omit no-cache headers because it confuses IE with file downloads */
|
75 |
|
|
$omit_nocacheheaders = true;
|
76 |
99b1cc43
|
Scott Ullrich
|
$nocsrf = true;
|
77 |
8ccc8f1a
|
Scott Ullrich
|
require("guiconfig.inc");
|
78 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
79 |
|
|
require_once("filter.inc");
|
80 |
|
|
require_once("shaper.inc");
|
81 |
5b237745
|
Scott Ullrich
|
|
82 |
8bdb6879
|
Darren Embry
|
$rrddbpath = "/var/db/rrd";
|
83 |
|
|
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
|
84 |
|
|
|
85 |
|
|
function rrd_data_xml() {
|
86 |
|
|
global $rrddbpath;
|
87 |
|
|
global $rrdtool;
|
88 |
73ed069b
|
Renato Botelho
|
|
89 |
8bdb6879
|
Darren Embry
|
$result = "\t<rrddata>\n";
|
90 |
|
|
$rrd_files = glob("{$rrddbpath}/*.rrd");
|
91 |
|
|
$xml_files = array();
|
92 |
|
|
foreach ($rrd_files as $rrd_file) {
|
93 |
|
|
$basename = basename($rrd_file);
|
94 |
|
|
$xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file);
|
95 |
|
|
exec("$rrdtool dump '{$rrd_file}' '{$xml_file}'");
|
96 |
|
|
$xml_data = file_get_contents($xml_file);
|
97 |
|
|
unlink($xml_file);
|
98 |
|
|
if ($xml_data !== false) {
|
99 |
|
|
$result .= "\t\t<rrddatafile>\n";
|
100 |
|
|
$result .= "\t\t\t<filename>{$basename}</filename>\n";
|
101 |
|
|
$result .= "\t\t\t<xmldata>" . base64_encode(gzdeflate($xml_data)) . "</xmldata>\n";
|
102 |
|
|
$result .= "\t\t</rrddatafile>\n";
|
103 |
|
|
}
|
104 |
|
|
}
|
105 |
|
|
$result .= "\t</rrddata>\n";
|
106 |
|
|
return $result;
|
107 |
|
|
}
|
108 |
|
|
|
109 |
754b75d0
|
Darren Embry
|
function restore_rrddata() {
|
110 |
7eead1fc
|
Darren Embry
|
global $config, $g, $rrdtool, $input_errors;
|
111 |
5f601060
|
Phil Davis
|
foreach ($config['rrddata']['rrddatafile'] as $rrd) {
|
112 |
754b75d0
|
Darren Embry
|
if ($rrd['xmldata']) {
|
113 |
|
|
$rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}";
|
114 |
|
|
$xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file);
|
115 |
08877746
|
Darren Embry
|
if (file_put_contents($xml_file, gzinflate(base64_decode($rrd['xmldata']))) === false) {
|
116 |
|
|
log_error("Cannot write $xml_file");
|
117 |
|
|
continue;
|
118 |
|
|
}
|
119 |
|
|
$output = array();
|
120 |
|
|
$status = null;
|
121 |
|
|
exec("$rrdtool restore -f '{$xml_file}' '{$rrd_file}'", $output, $status);
|
122 |
|
|
if ($status) {
|
123 |
f757431d
|
Darren Embry
|
log_error("rrdtool restore -f '{$xml_file}' '{$rrd_file}' failed returning {$status}.");
|
124 |
08877746
|
Darren Embry
|
continue;
|
125 |
|
|
}
|
126 |
754b75d0
|
Darren Embry
|
unlink($xml_file);
|
127 |
5f601060
|
Phil Davis
|
} else if ($rrd['data']) {
|
128 |
7eead1fc
|
Darren Embry
|
$rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}";
|
129 |
|
|
$rrd_fd = fopen($rrd_file, "w");
|
130 |
08877746
|
Darren Embry
|
if (!$rrd_fd) {
|
131 |
|
|
log_error("Cannot write $rrd_file");
|
132 |
|
|
continue;
|
133 |
|
|
}
|
134 |
754b75d0
|
Darren Embry
|
$data = base64_decode($rrd['data']);
|
135 |
|
|
/* Try to decompress the data. */
|
136 |
|
|
$dcomp = @gzinflate($data);
|
137 |
|
|
if ($dcomp) {
|
138 |
|
|
/* If the decompression worked, write the decompressed data */
|
139 |
08877746
|
Darren Embry
|
if (fwrite($rrd_fd, $dcomp) === false) {
|
140 |
|
|
log_error("fwrite $rrd_file failed");
|
141 |
|
|
continue;
|
142 |
|
|
}
|
143 |
754b75d0
|
Darren Embry
|
} else {
|
144 |
|
|
/* If the decompression failed, it wasn't compressed, so write raw data */
|
145 |
08877746
|
Darren Embry
|
if (fwrite($rrd_fd, $data) === false) {
|
146 |
|
|
log_error("fwrite $rrd_file failed");
|
147 |
|
|
continue;
|
148 |
|
|
}
|
149 |
|
|
}
|
150 |
|
|
if (fclose($rrd_fd) === false) {
|
151 |
|
|
log_error("fclose $rrd_file failed");
|
152 |
|
|
continue;
|
153 |
754b75d0
|
Darren Embry
|
}
|
154 |
|
|
}
|
155 |
|
|
}
|
156 |
|
|
}
|
157 |
|
|
|
158 |
3420028c
|
Scott Ullrich
|
function add_base_packages_menu_items() {
|
159 |
|
|
global $g, $config;
|
160 |
52c7f0d4
|
jim-p
|
$base_packages = explode(",", $g['base_packages']);
|
161 |
3420028c
|
Scott Ullrich
|
$modified_config = false;
|
162 |
5f601060
|
Phil Davis
|
foreach ($base_packages as $bp) {
|
163 |
da17d77e
|
Ermal Lu?i
|
$basepkg_path = "/usr/local/pkg/{$bp}";
|
164 |
a250f179
|
Renato Botelho
|
$tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION);
|
165 |
5f601060
|
Phil Davis
|
if ($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) {
|
166 |
da17d77e
|
Ermal Lu?i
|
$pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui");
|
167 |
5f601060
|
Phil Davis
|
if ($pkg_config['menu'] != "") {
|
168 |
|
|
if (is_array($pkg_config['menu'])) {
|
169 |
|
|
foreach ($pkg_config['menu'] as $menu) {
|
170 |
|
|
if (is_array($config['installedpackages']['menu'])) {
|
171 |
|
|
foreach ($config['installedpackages']['menu'] as $amenu) {
|
172 |
|
|
if ($amenu['name'] == $menu['name']) {
|
173 |
3420028c
|
Scott Ullrich
|
continue;
|
174 |
5f601060
|
Phil Davis
|
}
|
175 |
|
|
}
|
176 |
|
|
}
|
177 |
3420028c
|
Scott Ullrich
|
$config['installedpackages']['menu'][] = $menu;
|
178 |
|
|
$modified_config = true;
|
179 |
|
|
}
|
180 |
|
|
}
|
181 |
|
|
$static_output .= "done.\n";
|
182 |
|
|
update_output_window($static_output);
|
183 |
|
|
}
|
184 |
|
|
}
|
185 |
|
|
}
|
186 |
5f601060
|
Phil Davis
|
if ($modified_config) {
|
187 |
f3ceee6e
|
Vinicius Coque
|
write_config(gettext("Restored base_package menus after configuration restore."));
|
188 |
3420028c
|
Scott Ullrich
|
$config = parse_config(true);
|
189 |
|
|
}
|
190 |
|
|
}
|
191 |
|
|
|
192 |
645ec835
|
Scott Ullrich
|
function remove_bad_chars($string) {
|
193 |
699737d9
|
Phil Davis
|
return preg_replace('/[^a-z_0-9]/i', '', $string);
|
194 |
645ec835
|
Scott Ullrich
|
}
|
195 |
|
|
|
196 |
b3277798
|
Scott Ullrich
|
function check_and_returnif_section_exists($section) {
|
197 |
|
|
global $config;
|
198 |
5f601060
|
Phil Davis
|
if (is_array($config[$section])) {
|
199 |
b3277798
|
Scott Ullrich
|
return true;
|
200 |
5f601060
|
Phil Davis
|
}
|
201 |
b3277798
|
Scott Ullrich
|
return false;
|
202 |
|
|
}
|
203 |
|
|
|
204 |
da17d77e
|
Ermal Lu?i
|
if ($_POST['apply']) {
|
205 |
73ed069b
|
Renato Botelho
|
ob_flush();
|
206 |
|
|
flush();
|
207 |
c9a19238
|
Darren Embry
|
conf_mount_rw();
|
208 |
|
|
clear_subsystem_dirty("restore");
|
209 |
|
|
conf_mount_ro();
|
210 |
73ed069b
|
Renato Botelho
|
exit;
|
211 |
da17d77e
|
Ermal Lu?i
|
}
|
212 |
|
|
|
213 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
214 |
|
|
unset($input_errors);
|
215 |
5f601060
|
Phil Davis
|
if (stristr($_POST['Submit'], gettext("Restore configuration"))) {
|
216 |
5b237745
|
Scott Ullrich
|
$mode = "restore";
|
217 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Reinstall"))) {
|
218 |
8ccc8f1a
|
Scott Ullrich
|
$mode = "reinstallpackages";
|
219 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Clear Package Lock"))) {
|
220 |
039cb920
|
jim-p
|
$mode = "clearpackagelock";
|
221 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Download"))) {
|
222 |
5b237745
|
Scott Ullrich
|
$mode = "download";
|
223 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Restore version"))) {
|
224 |
7cf03119
|
Bill Marquette
|
$mode = "restore_ver";
|
225 |
5f601060
|
Phil Davis
|
}
|
226 |
|
|
if ($_POST["nopackages"] <> "") {
|
227 |
528cad39
|
Colin Smith
|
$options = "nopackages";
|
228 |
5f601060
|
Phil Davis
|
}
|
229 |
|
|
if ($_POST["ver"] <> "") {
|
230 |
7cf03119
|
Bill Marquette
|
$ver2restore = $_POST["ver"];
|
231 |
5f601060
|
Phil Davis
|
}
|
232 |
5b237745
|
Scott Ullrich
|
if ($mode) {
|
233 |
|
|
if ($mode == "download") {
|
234 |
8ff5ffcc
|
Matthew Grooms
|
if ($_POST['encrypt']) {
|
235 |
5f601060
|
Phil Davis
|
if (!$_POST['encrypt_password'] || !$_POST['encrypt_passconf']) {
|
236 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("You must supply and confirm the password for encryption.");
|
237 |
5f601060
|
Phil Davis
|
}
|
238 |
|
|
if ($_POST['encrypt_password'] != $_POST['encrypt_passconf']) {
|
239 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match.");
|
240 |
5f601060
|
Phil Davis
|
}
|
241 |
528cad39
|
Colin Smith
|
}
|
242 |
73ed069b
|
Renato Botelho
|
|
243 |
8ff5ffcc
|
Matthew Grooms
|
if (!$input_errors) {
|
244 |
73ed069b
|
Renato Botelho
|
|
245 |
07b1797b
|
sullrich
|
//$lockbckp = lock('config');
|
246 |
73ed069b
|
Renato Botelho
|
|
247 |
8ff5ffcc
|
Matthew Grooms
|
$host = "{$config['system']['hostname']}.{$config['system']['domain']}";
|
248 |
|
|
$name = "config-{$host}-".date("YmdHis").".xml";
|
249 |
|
|
$data = "";
|
250 |
73ed069b
|
Renato Botelho
|
|
251 |
5f601060
|
Phil Davis
|
if ($options == "nopackages") {
|
252 |
|
|
if (!$_POST['backuparea']) {
|
253 |
4195c967
|
sullrich
|
/* backup entire configuration */
|
254 |
|
|
$data = file_get_contents("{$g['conf_path']}/config.xml");
|
255 |
|
|
} else {
|
256 |
|
|
/* backup specific area of configuration */
|
257 |
|
|
$data = backup_config_section($_POST['backuparea']);
|
258 |
|
|
$name = "{$_POST['backuparea']}-{$name}";
|
259 |
|
|
}
|
260 |
da17d77e
|
Ermal Lu?i
|
$sfn = "{$g['tmp_path']}/config.xml.nopkg";
|
261 |
4195c967
|
sullrich
|
file_put_contents($sfn, $data);
|
262 |
|
|
exec("sed '/<installedpackages>/,/<\/installedpackages>/d' {$sfn} > {$sfn}-new");
|
263 |
a250f179
|
Renato Botelho
|
$data = file_get_contents($sfn . "-new");
|
264 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
265 |
5f601060
|
Phil Davis
|
if (!$_POST['backuparea']) {
|
266 |
8ff5ffcc
|
Matthew Grooms
|
/* backup entire configuration */
|
267 |
|
|
$data = file_get_contents("{$g['conf_path']}/config.xml");
|
268 |
7eead1fc
|
Darren Embry
|
} else if ($_POST['backuparea'] === "rrddata") {
|
269 |
|
|
$data = rrd_data_xml();
|
270 |
|
|
$name = "{$_POST['backuparea']}-{$name}";
|
271 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
272 |
|
|
/* backup specific area of configuration */
|
273 |
|
|
$data = backup_config_section($_POST['backuparea']);
|
274 |
|
|
$name = "{$_POST['backuparea']}-{$name}";
|
275 |
|
|
}
|
276 |
181462b5
|
Scott Ullrich
|
}
|
277 |
73ed069b
|
Renato Botelho
|
|
278 |
07b1797b
|
sullrich
|
//unlock($lockbckp);
|
279 |
73ed069b
|
Renato Botelho
|
|
280 |
a250f179
|
Renato Botelho
|
/*
|
281 |
0e834fc5
|
Stephen Beaver
|
* Backup RRD Data
|
282 |
1390b049
|
Scott Ullrich
|
*/
|
283 |
7eead1fc
|
Darren Embry
|
if ($_POST['backuparea'] !== "rrddata" && !$_POST['donotbackuprrd']) {
|
284 |
8bdb6879
|
Darren Embry
|
$rrd_data_xml = rrd_data_xml();
|
285 |
|
|
$closing_tag = "</" . $g['xml_rootobj'] . ">";
|
286 |
|
|
$data = str_replace($closing_tag, $rrd_data_xml . $closing_tag, $data);
|
287 |
1390b049
|
Scott Ullrich
|
}
|
288 |
73ed069b
|
Renato Botelho
|
|
289 |
4cfd2390
|
Renato Botelho
|
if ($_POST['encrypt']) {
|
290 |
|
|
$data = encrypt_data($data, $_POST['encrypt_password']);
|
291 |
|
|
tagfile_reformat($data, $data, "config.xml");
|
292 |
|
|
}
|
293 |
|
|
|
294 |
8ff5ffcc
|
Matthew Grooms
|
$size = strlen($data);
|
295 |
|
|
header("Content-Type: application/octet-stream");
|
296 |
|
|
header("Content-Disposition: attachment; filename={$name}");
|
297 |
a8c35980
|
Scott Ullrich
|
header("Content-Length: $size");
|
298 |
e77ea573
|
jim-p
|
if (isset($_SERVER['HTTPS'])) {
|
299 |
|
|
header('Pragma: ');
|
300 |
|
|
header('Cache-Control: ');
|
301 |
|
|
} else {
|
302 |
|
|
header("Pragma: private");
|
303 |
|
|
header("Cache-Control: private, must-revalidate");
|
304 |
|
|
}
|
305 |
8ff5ffcc
|
Matthew Grooms
|
echo $data;
|
306 |
73ed069b
|
Renato Botelho
|
|
307 |
8ff5ffcc
|
Matthew Grooms
|
exit;
|
308 |
|
|
}
|
309 |
|
|
}
|
310 |
73ed069b
|
Renato Botelho
|
|
311 |
8ff5ffcc
|
Matthew Grooms
|
if ($mode == "restore") {
|
312 |
|
|
if ($_POST['decrypt']) {
|
313 |
5f601060
|
Phil Davis
|
if (!$_POST['decrypt_password'] || !$_POST['decrypt_passconf']) {
|
314 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("You must supply and confirm the password for decryption.");
|
315 |
5f601060
|
Phil Davis
|
}
|
316 |
|
|
if ($_POST['decrypt_password'] != $_POST['decrypt_passconf']) {
|
317 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match.");
|
318 |
5f601060
|
Phil Davis
|
}
|
319 |
8ff5ffcc
|
Matthew Grooms
|
}
|
320 |
73ed069b
|
Renato Botelho
|
|
321 |
8ff5ffcc
|
Matthew Grooms
|
if (!$input_errors) {
|
322 |
|
|
if (is_uploaded_file($_FILES['conffile']['tmp_name'])) {
|
323 |
73ed069b
|
Renato Botelho
|
|
324 |
8ff5ffcc
|
Matthew Grooms
|
/* read the file contents */
|
325 |
|
|
$data = file_get_contents($_FILES['conffile']['tmp_name']);
|
326 |
5f601060
|
Phil Davis
|
if (!$data) {
|
327 |
dae4c487
|
Carlos Eduardo Ramos
|
log_error(sprintf(gettext("Warning, could not read file %s"), $_FILES['conffile']['tmp_name']));
|
328 |
8ff5ffcc
|
Matthew Grooms
|
return 1;
|
329 |
9fd18b1f
|
Scott Ullrich
|
}
|
330 |
73ed069b
|
Renato Botelho
|
|
331 |
8ff5ffcc
|
Matthew Grooms
|
if ($_POST['decrypt']) {
|
332 |
|
|
if (!tagfile_deformat($data, $data, "config.xml")) {
|
333 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The uploaded file does not appear to contain an encrypted pfsense configuration.");
|
334 |
8ff5ffcc
|
Matthew Grooms
|
return 1;
|
335 |
|
|
}
|
336 |
|
|
$data = decrypt_data($data, $_POST['decrypt_password']);
|
337 |
|
|
}
|
338 |
73ed069b
|
Renato Botelho
|
|
339 |
5f601060
|
Phil Davis
|
if (stristr($data, "<m0n0wall>")) {
|
340 |
205da5a0
|
Neriberto C.Prado
|
log_error(gettext("Upgrading m0n0wall configuration to pfsense."));
|
341 |
8ff5ffcc
|
Matthew Grooms
|
/* m0n0wall was found in config. convert it. */
|
342 |
|
|
$data = str_replace("m0n0wall", "pfsense", $data);
|
343 |
|
|
$m0n0wall_upgrade = true;
|
344 |
|
|
}
|
345 |
5f601060
|
Phil Davis
|
if ($_POST['restorearea']) {
|
346 |
8ff5ffcc
|
Matthew Grooms
|
/* restore a specific area of the configuration */
|
347 |
5f601060
|
Phil Davis
|
if (!stristr($data, "<" . $_POST['restorearea'] . ">")) {
|
348 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("You have selected to restore an area but we could not locate the correct xml tag.");
|
349 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
350 |
8dcca9b5
|
Darren Embry
|
if (!restore_config_section($_POST['restorearea'], $data)) {
|
351 |
|
|
$input_errors[] = gettext("You have selected to restore an area but we could not locate the correct xml tag.");
|
352 |
|
|
} else {
|
353 |
|
|
if ($config['rrddata']) {
|
354 |
|
|
restore_rrddata();
|
355 |
|
|
unset($config['rrddata']);
|
356 |
|
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
357 |
|
|
write_config();
|
358 |
|
|
add_base_packages_menu_items();
|
359 |
|
|
convert_config();
|
360 |
|
|
conf_mount_ro();
|
361 |
|
|
}
|
362 |
|
|
filter_configure();
|
363 |
|
|
$savemsg = gettext("The configuration area has been restored. You may need to reboot the firewall.");
|
364 |
7eead1fc
|
Darren Embry
|
}
|
365 |
8ff5ffcc
|
Matthew Grooms
|
}
|
366 |
181462b5
|
Scott Ullrich
|
} else {
|
367 |
5f601060
|
Phil Davis
|
if (!stristr($data, "<" . $g['xml_rootobj'] . ">")) {
|
368 |
dae4c487
|
Carlos Eduardo Ramos
|
$input_errors[] = sprintf(gettext("You have selected to restore the full configuration but we could not locate a %s tag."), $g['xml_rootobj']);
|
369 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
370 |
|
|
/* restore the entire configuration */
|
371 |
|
|
file_put_contents($_FILES['conffile']['tmp_name'], $data);
|
372 |
|
|
if (config_install($_FILES['conffile']['tmp_name']) == 0) {
|
373 |
|
|
/* this will be picked up by /index.php */
|
374 |
|
|
conf_mount_rw();
|
375 |
da17d77e
|
Ermal Lu?i
|
mark_subsystem_dirty("restore");
|
376 |
09821234
|
Scott Ullrich
|
touch("/conf/needs_package_sync");
|
377 |
8ff5ffcc
|
Matthew Grooms
|
/* remove cache, we will force a config reboot */
|
378 |
5f601060
|
Phil Davis
|
if (file_exists("{$g['tmp_path']}/config.cache")) {
|
379 |
da17d77e
|
Ermal Lu?i
|
unlink("{$g['tmp_path']}/config.cache");
|
380 |
5f601060
|
Phil Davis
|
}
|
381 |
8ff5ffcc
|
Matthew Grooms
|
$config = parse_config(true);
|
382 |
0174c480
|
Ermal LUÇI
|
if (file_exists("/boot/loader.conf")) {
|
383 |
|
|
$loaderconf = file_get_contents("/boot/loader.conf");
|
384 |
08af94cb
|
Chris Buechler
|
if (strpos($loaderconf, "console=\"comconsole")) {
|
385 |
0174c480
|
Ermal LUÇI
|
$config['system']['enableserial'] = true;
|
386 |
|
|
write_config("Restore serial console enabling in configuration.");
|
387 |
|
|
}
|
388 |
5d4b8830
|
Ermal LUÇI
|
unset($loaderconf);
|
389 |
0174c480
|
Ermal LUÇI
|
}
|
390 |
67bc955d
|
Chris Buechler
|
/* extract out rrd items, unset from $config when done */
|
391 |
5f601060
|
Phil Davis
|
if ($config['rrddata']) {
|
392 |
754b75d0
|
Darren Embry
|
restore_rrddata();
|
393 |
a2b8f7b2
|
Scott Ullrich
|
unset($config['rrddata']);
|
394 |
da17d77e
|
Ermal Lu?i
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
395 |
a2b8f7b2
|
Scott Ullrich
|
write_config();
|
396 |
3420028c
|
Scott Ullrich
|
add_base_packages_menu_items();
|
397 |
d442e4e2
|
Scott Ullrich
|
convert_config();
|
398 |
a2b8f7b2
|
Scott Ullrich
|
conf_mount_ro();
|
399 |
1390b049
|
Scott Ullrich
|
}
|
400 |
5f601060
|
Phil Davis
|
if ($m0n0wall_upgrade == true) {
|
401 |
|
|
if ($config['system']['gateway'] <> "") {
|
402 |
8ff5ffcc
|
Matthew Grooms
|
$config['interfaces']['wan']['gateway'] = $config['system']['gateway'];
|
403 |
5f601060
|
Phil Davis
|
}
|
404 |
8ff5ffcc
|
Matthew Grooms
|
unset($config['shaper']);
|
405 |
|
|
/* optional if list */
|
406 |
|
|
$ifdescrs = get_configured_interface_list(true, true);
|
407 |
|
|
/* remove special characters from interface descriptions */
|
408 |
5f601060
|
Phil Davis
|
if (is_array($ifdescrs)) {
|
409 |
|
|
foreach ($ifdescrs as $iface) {
|
410 |
8ff5ffcc
|
Matthew Grooms
|
$config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']);
|
411 |
5f601060
|
Phil Davis
|
}
|
412 |
|
|
}
|
413 |
b6db8ea3
|
sullrich
|
/* check for interface names with an alias */
|
414 |
5f601060
|
Phil Davis
|
if (is_array($ifdescrs)) {
|
415 |
|
|
foreach ($ifdescrs as $iface) {
|
416 |
|
|
if (is_alias($config['interfaces'][$iface]['descr'])) {
|
417 |
b6db8ea3
|
sullrich
|
// Firewall rules
|
418 |
|
|
$origname = $config['interfaces'][$iface]['descr'];
|
419 |
6c07db48
|
Phil Davis
|
$newname = $config['interfaces'][$iface]['descr'] . "Alias";
|
420 |
f1ac1733
|
Erik Fonnesbeck
|
update_alias_names_upon_change(array('filter', 'rule'), array('source', 'address'), $newname, $origname);
|
421 |
|
|
update_alias_names_upon_change(array('filter', 'rule'), array('destination', 'address'), $newname, $origname);
|
422 |
b6db8ea3
|
sullrich
|
// NAT Rules
|
423 |
f1ac1733
|
Erik Fonnesbeck
|
update_alias_names_upon_change(array('nat', 'rule'), array('source', 'address'), $newname, $origname);
|
424 |
|
|
update_alias_names_upon_change(array('nat', 'rule'), array('destination', 'address'), $newname, $origname);
|
425 |
|
|
update_alias_names_upon_change(array('nat', 'rule'), array('target'), $newname, $origname);
|
426 |
b6db8ea3
|
sullrich
|
// Alias in an alias
|
427 |
f1ac1733
|
Erik Fonnesbeck
|
update_alias_names_upon_change(array('aliases', 'alias'), array('address'), $newname, $origname);
|
428 |
b6db8ea3
|
sullrich
|
}
|
429 |
|
|
}
|
430 |
|
|
}
|
431 |
da17d77e
|
Ermal Lu?i
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
432 |
888e7a27
|
Scott Ullrich
|
// Reset configuration version to something low
|
433 |
a250f179
|
Renato Botelho
|
// in order to force the config upgrade code to
|
434 |
888e7a27
|
Scott Ullrich
|
// run through with all steps that are required.
|
435 |
|
|
$config['system']['version'] = "1.0";
|
436 |
798cb31a
|
Scott Ullrich
|
// Deal with descriptions longer than 63 characters
|
437 |
|
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
438 |
5f601060
|
Phil Davis
|
if (count($config['filter']['rule'][$i]['descr']) > 63) {
|
439 |
798cb31a
|
Scott Ullrich
|
$config['filter']['rule'][$i]['descr'] = substr($config['filter']['rule'][$i]['descr'], 0, 63);
|
440 |
5f601060
|
Phil Davis
|
}
|
441 |
798cb31a
|
Scott Ullrich
|
}
|
442 |
|
|
// Move interface from ipsec to enc0
|
443 |
|
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
444 |
5f601060
|
Phil Davis
|
if ($config['filter']['rule'][$i]['interface'] == "ipsec") {
|
445 |
798cb31a
|
Scott Ullrich
|
$config['filter']['rule'][$i]['interface'] = "enc0";
|
446 |
5f601060
|
Phil Davis
|
}
|
447 |
798cb31a
|
Scott Ullrich
|
}
|
448 |
|
|
// Convert icmp types
|
449 |
|
|
// http://www.openbsd.org/cgi-bin/man.cgi?query=icmp&sektion=4&arch=i386&apropos=0&manpath=OpenBSD+Current
|
450 |
|
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
451 |
5f601060
|
Phil Davis
|
if ($config["filter"]["rule"][$i]['icmptype']) {
|
452 |
|
|
switch ($config["filter"]["rule"][$i]['icmptype']) {
|
453 |
|
|
case "echo":
|
454 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "echoreq";
|
455 |
|
|
break;
|
456 |
|
|
case "unreach":
|
457 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "unreach";
|
458 |
|
|
break;
|
459 |
|
|
case "echorep":
|
460 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "echorep";
|
461 |
|
|
break;
|
462 |
|
|
case "squench":
|
463 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "squench";
|
464 |
|
|
break;
|
465 |
|
|
case "redir":
|
466 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "redir";
|
467 |
|
|
break;
|
468 |
|
|
case "timex":
|
469 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "timex";
|
470 |
|
|
break;
|
471 |
|
|
case "paramprob":
|
472 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "paramprob";
|
473 |
|
|
break;
|
474 |
|
|
case "timest":
|
475 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "timereq";
|
476 |
|
|
break;
|
477 |
|
|
case "timestrep":
|
478 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "timerep";
|
479 |
|
|
break;
|
480 |
|
|
case "inforeq":
|
481 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "inforeq";
|
482 |
|
|
break;
|
483 |
|
|
case "inforep":
|
484 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "inforep";
|
485 |
|
|
break;
|
486 |
|
|
case "maskreq":
|
487 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "maskreq";
|
488 |
|
|
break;
|
489 |
|
|
case "maskrep":
|
490 |
|
|
$config["filter"]["rule"][$i]['icmptype'] = "maskrep";
|
491 |
|
|
break;
|
492 |
798cb31a
|
Scott Ullrich
|
}
|
493 |
|
|
}
|
494 |
dec5cb85
|
Scott Ullrich
|
}
|
495 |
|
|
$config['diag']['ipv6nat'] = true;
|
496 |
8ff5ffcc
|
Matthew Grooms
|
write_config();
|
497 |
a250f179
|
Renato Botelho
|
add_base_packages_menu_items();
|
498 |
d442e4e2
|
Scott Ullrich
|
convert_config();
|
499 |
8ff5ffcc
|
Matthew Grooms
|
conf_mount_ro();
|
500 |
205da5a0
|
Neriberto C.Prado
|
$savemsg = gettext("The m0n0wall configuration has been restored and upgraded to pfSense.");
|
501 |
da17d77e
|
Ermal Lu?i
|
mark_subsystem_dirty("restore");
|
502 |
8ff5ffcc
|
Matthew Grooms
|
}
|
503 |
5f601060
|
Phil Davis
|
if (is_array($config['captiveportal'])) {
|
504 |
|
|
foreach ($config['captiveportal'] as $cp) {
|
505 |
2e19a683
|
Renato Botelho
|
if (isset($cp['enable'])) {
|
506 |
|
|
/* for some reason ipfw doesn't init correctly except on bootup sequence */
|
507 |
|
|
mark_subsystem_dirty("restore");
|
508 |
|
|
break;
|
509 |
|
|
}
|
510 |
|
|
}
|
511 |
8ff5ffcc
|
Matthew Grooms
|
}
|
512 |
|
|
setup_serial_port();
|
513 |
5f601060
|
Phil Davis
|
if (is_interface_mismatch() == true) {
|
514 |
8ff5ffcc
|
Matthew Grooms
|
touch("/var/run/interface_mismatch_reboot_needed");
|
515 |
da17d77e
|
Ermal Lu?i
|
clear_subsystem_dirty("restore");
|
516 |
f5a57bb0
|
Scott Ullrich
|
convert_config();
|
517 |
8ff5ffcc
|
Matthew Grooms
|
header("Location: interfaces_assign.php");
|
518 |
bafaf123
|
Scott Ullrich
|
exit;
|
519 |
8ff5ffcc
|
Matthew Grooms
|
}
|
520 |
66bcba1b
|
Ermal
|
if (is_interface_vlan_mismatch() == true) {
|
521 |
|
|
touch("/var/run/interface_mismatch_reboot_needed");
|
522 |
|
|
clear_subsystem_dirty("restore");
|
523 |
|
|
convert_config();
|
524 |
|
|
header("Location: interfaces_assign.php");
|
525 |
|
|
exit;
|
526 |
|
|
}
|
527 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
528 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The configuration could not be restored.");
|
529 |
db3996df
|
Scott Ullrich
|
}
|
530 |
9c72b993
|
Scott Ullrich
|
}
|
531 |
181462b5
|
Scott Ullrich
|
}
|
532 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
533 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The configuration could not be restored (file upload error).");
|
534 |
db3996df
|
Scott Ullrich
|
}
|
535 |
5b237745
|
Scott Ullrich
|
}
|
536 |
8ff5ffcc
|
Matthew Grooms
|
}
|
537 |
73ed069b
|
Renato Botelho
|
|
538 |
8ff5ffcc
|
Matthew Grooms
|
if ($mode == "reinstallpackages") {
|
539 |
8ccc8f1a
|
Scott Ullrich
|
header("Location: pkg_mgr_install.php?mode=reinstallall");
|
540 |
|
|
exit;
|
541 |
039cb920
|
jim-p
|
} else if ($mode == "clearpackagelock") {
|
542 |
|
|
clear_subsystem_dirty('packagelock');
|
543 |
|
|
$savemsg = "Package Lock Cleared";
|
544 |
73ed069b
|
Renato Botelho
|
} else if ($mode == "restore_ver") {
|
545 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("XXX - this feature may hose your config (do NOT backrev configs!) - billm");
|
546 |
7cf03119
|
Bill Marquette
|
if ($ver2restore <> "") {
|
547 |
|
|
$conf_file = "{$g['cf_conf_path']}/bak/config-" . strtotime($ver2restore) . ".xml";
|
548 |
343bb325
|
sullrich
|
if (config_install($conf_file) == 0) {
|
549 |
c9a19238
|
Darren Embry
|
mark_subsystem_dirty("restore");
|
550 |
|
|
} else {
|
551 |
|
|
$input_errors[] = gettext("The configuration could not be restored.");
|
552 |
|
|
}
|
553 |
|
|
} else {
|
554 |
|
|
$input_errors[] = gettext("No version selected.");
|
555 |
|
|
}
|
556 |
5b237745
|
Scott Ullrich
|
}
|
557 |
|
|
}
|
558 |
|
|
}
|
559 |
6a1e6651
|
Bill Marquette
|
|
560 |
02e1170d
|
Scott Ullrich
|
$id = rand() . '.' . time();
|
561 |
|
|
|
562 |
|
|
$mth = ini_get('upload_progress_meter.store_method');
|
563 |
|
|
$dir = ini_get('upload_progress_meter.file.filename_template');
|
564 |
|
|
|
565 |
a4af095c
|
Renato Botelho
|
function build_area_list($showall) {
|
566 |
|
|
global $config;
|
567 |
b63695db
|
Scott Ullrich
|
|
568 |
0e834fc5
|
Stephen Beaver
|
$areas = array(
|
569 |
|
|
"aliases" => gettext("Aliases"),
|
570 |
a4af095c
|
Renato Botelho
|
"captiveportal" => gettext("Captive Portal"),
|
571 |
|
|
"voucher" => gettext("Captive Portal Vouchers"),
|
572 |
|
|
"dnsmasq" => gettext("DNS Forwarder"),
|
573 |
|
|
"unbound" => gettext("DNS Resolver"),
|
574 |
|
|
"dhcpd" => gettext("DHCP Server"),
|
575 |
|
|
"dhcpdv6" => gettext("DHCPv6 Server"),
|
576 |
|
|
"filter" => gettext("Firewall Rules"),
|
577 |
|
|
"interfaces" => gettext("Interfaces"),
|
578 |
|
|
"ipsec" => gettext("IPSEC"),
|
579 |
|
|
"nat" => gettext("NAT"),
|
580 |
|
|
"openvpn" => gettext("OpenVPN"),
|
581 |
|
|
"installedpackages" => gettext("Package Manager"),
|
582 |
|
|
"pptpd" => gettext("PPTP Server"),
|
583 |
|
|
"rrddata" => gettext("RRD Data"),
|
584 |
|
|
"cron" => gettext("Scheduled Tasks"),
|
585 |
|
|
"syslog" => gettext("Syslog"),
|
586 |
|
|
"system" => gettext("System"),
|
587 |
|
|
"staticroutes" => gettext("Static routes"),
|
588 |
|
|
"sysctl" => gettext("System tunables"),
|
589 |
|
|
"snmpd" => gettext("SNMP Server"),
|
590 |
|
|
"shaper" => gettext("Traffic Shaper"),
|
591 |
|
|
"vlans" => gettext("VLANS"),
|
592 |
|
|
"wol" => gettext("Wake on LAN")
|
593 |
|
|
);
|
594 |
0e834fc5
|
Stephen Beaver
|
|
595 |
|
|
$list = array("" => gettext("All"));
|
596 |
|
|
|
597 |
a4af095c
|
Renato Botelho
|
if($showall)
|
598 |
0e834fc5
|
Stephen Beaver
|
return($list + $areas);
|
599 |
a4af095c
|
Renato Botelho
|
else {
|
600 |
|
|
foreach ($areas as $area => $areaname) {
|
601 |
|
|
if ($area === "rrddata" || check_and_returnif_section_exists($area) == true) {
|
602 |
|
|
$list[$area] = $areaname;
|
603 |
|
|
}
|
604 |
|
|
}
|
605 |
8ff5ffcc
|
Matthew Grooms
|
|
606 |
0e834fc5
|
Stephen Beaver
|
return($list);
|
607 |
5f601060
|
Phil Davis
|
}
|
608 |
8ff5ffcc
|
Matthew Grooms
|
}
|
609 |
|
|
|
610 |
a4af095c
|
Renato Botelho
|
$pgtitle = array(gettext("Diagnostics"), gettext("Backup/restore"));
|
611 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
612 |
|
|
|
613 |
a4af095c
|
Renato Botelho
|
if ($input_errors)
|
614 |
|
|
print_input_errors($input_errors);
|
615 |
0e834fc5
|
Stephen Beaver
|
|
616 |
a4af095c
|
Renato Botelho
|
if ($savemsg)
|
617 |
|
|
print_info_box($savemsg, 'success');
|
618 |
0e834fc5
|
Stephen Beaver
|
|
619 |
a4af095c
|
Renato Botelho
|
if (is_subsystem_dirty('restore')):
|
620 |
5b237745
|
Scott Ullrich
|
?>
|
621 |
a4af095c
|
Renato Botelho
|
<br/>
|
622 |
7d5b007c
|
Sjon Hortensius
|
<form action="reboot.php" method="post">
|
623 |
|
|
<input name="Submit" type="hidden" value="Yes" />
|
624 |
a4af095c
|
Renato Botelho
|
<?=print_info_box(gettext("The firewall configuration has been changed.") . "<br />" . gettext("The firewall is now rebooting."))?>
|
625 |
|
|
<br />
|
626 |
7d5b007c
|
Sjon Hortensius
|
</form>
|
627 |
0e834fc5
|
Stephen Beaver
|
<?php
|
628 |
a4af095c
|
Renato Botelho
|
endif;
|
629 |
|
|
|
630 |
|
|
$tab_array = array();
|
631 |
|
|
$tab_array[] = array(gettext("Config History"), false, "diag_confbak.php");
|
632 |
|
|
$tab_array[] = array(gettext("Backup/Restore"), true, "diag_backup.php");
|
633 |
|
|
display_top_tabs($tab_array);
|
634 |
|
|
|
635 |
ad2879b8
|
PiBa-NL
|
require_once('classes/Form.class.php');
|
636 |
a4af095c
|
Renato Botelho
|
|
637 |
|
|
$form = new Form(false);
|
638 |
|
|
|
639 |
|
|
$section = new Form_Section('Backup configuration');
|
640 |
|
|
|
641 |
|
|
$section->addInput(new Form_Select(
|
642 |
|
|
'backuparea',
|
643 |
|
|
'Backup area',
|
644 |
|
|
'',
|
645 |
|
|
build_area_list(false)
|
646 |
|
|
));
|
647 |
|
|
|
648 |
|
|
$section->addInput(new Form_Checkbox(
|
649 |
|
|
'nopackages',
|
650 |
|
|
'Skip packages',
|
651 |
|
|
'Do not backup package information.',
|
652 |
|
|
false
|
653 |
|
|
));
|
654 |
|
|
|
655 |
|
|
$section->addInput(new Form_Checkbox(
|
656 |
|
|
'donotbackuprrd',
|
657 |
|
|
'Skip RRD data',
|
658 |
|
|
'Do not backup RRD data (NOTE: RRD Data can consume 4+ megabytes of config.xml space!)',
|
659 |
|
|
true
|
660 |
|
|
));
|
661 |
|
|
|
662 |
|
|
$section->addInput(new Form_Checkbox(
|
663 |
|
|
'encrypt',
|
664 |
|
|
'Encryption',
|
665 |
|
|
'Encrypt this configuration file.',
|
666 |
|
|
false
|
667 |
|
|
))->toggles('.toggle-passwords');;
|
668 |
|
|
|
669 |
|
|
$section->addInput(new Form_Input(
|
670 |
|
|
'encrypt_password',
|
671 |
|
|
null,
|
672 |
|
|
'password',
|
673 |
|
|
null,
|
674 |
|
|
['placeholder' => 'Password']
|
675 |
|
|
))->addClass('toggle-passwords');
|
676 |
|
|
|
677 |
|
|
$section->addInput(new Form_Input(
|
678 |
|
|
'encrypt_passconf',
|
679 |
|
|
null,
|
680 |
|
|
'password',
|
681 |
|
|
null,
|
682 |
|
|
['placeholder' => 'Confirm password']
|
683 |
|
|
))->addClass('toggle-passwords');
|
684 |
|
|
|
685 |
|
|
$group = new Form_Group('');
|
686 |
|
|
$group->add(new Form_Button(
|
687 |
|
|
'Submit',
|
688 |
|
|
'Download configuration as XML'
|
689 |
|
|
));
|
690 |
|
|
|
691 |
|
|
$section->add($group);
|
692 |
|
|
$form->add($section);
|
693 |
|
|
|
694 |
|
|
$section = new Form_Section('Restore backup');
|
695 |
|
|
|
696 |
|
|
$section->addInput(new Form_StaticText(
|
697 |
|
|
null,
|
698 |
|
|
gettext("Open a ") . $g['[product_name'] . gettext(" configuration XML file and click the button below to restore the configuration.")
|
699 |
|
|
));
|
700 |
|
|
|
701 |
|
|
$section->addInput(new Form_Select(
|
702 |
|
|
'restorearea',
|
703 |
|
|
'Restore area',
|
704 |
|
|
'',
|
705 |
|
|
build_area_list(false)
|
706 |
|
|
));
|
707 |
|
|
|
708 |
|
|
$section->addInput(new Form_Input(
|
709 |
|
|
'conffile',
|
710 |
|
|
'Configuration file',
|
711 |
|
|
'file',
|
712 |
|
|
null
|
713 |
|
|
));
|
714 |
|
|
|
715 |
|
|
$section->addInput(new Form_Checkbox(
|
716 |
|
|
'encrypt',
|
717 |
|
|
'Encryption',
|
718 |
|
|
'Encrypt this configuration file.',
|
719 |
|
|
false
|
720 |
|
|
))->toggles('.toggle-dpasswords');;
|
721 |
|
|
|
722 |
|
|
$section->addInput(new Form_Input(
|
723 |
|
|
'decrypt_password',
|
724 |
|
|
null,
|
725 |
|
|
'password',
|
726 |
|
|
null,
|
727 |
|
|
['placeholder' => 'Password']
|
728 |
|
|
))->addClass('toggle-dpasswords');
|
729 |
|
|
|
730 |
|
|
$section->addInput(new Form_Input(
|
731 |
|
|
'decrypt_passconf',
|
732 |
|
|
null,
|
733 |
|
|
'password',
|
734 |
|
|
null,
|
735 |
|
|
['placeholder' => 'Confirm password']
|
736 |
|
|
))->addClass('toggle-dpasswords');
|
737 |
|
|
|
738 |
|
|
$group = new Form_Group('');
|
739 |
|
|
$group->add(new Form_Button(
|
740 |
|
|
'Submit',
|
741 |
|
|
'Restore configuration'
|
742 |
|
|
))->setHelp('The firewall will reboot after restoring the configuration.')->removeClass('btn-primary')->addClass('btn-danger');
|
743 |
|
|
|
744 |
|
|
$section->add($group);
|
745 |
|
|
|
746 |
|
|
$form->add($section);
|
747 |
|
|
|
748 |
|
|
if (($config['installedpackages']['package'] != "") || (is_subsystem_dirty("packagelock"))) {
|
749 |
|
|
$section = new Form_Section('Package functions');
|
750 |
0e834fc5
|
Stephen Beaver
|
|
751 |
a4af095c
|
Renato Botelho
|
if ($config['installedpackages']['package'] != "") {
|
752 |
|
|
$group = new Form_Group('');
|
753 |
|
|
$group->add(new Form_Button(
|
754 |
|
|
'Submit',
|
755 |
|
|
'Reinstall packages'
|
756 |
|
|
))->setHelp('Click this button to reinstall all system packages. This may take a while.')->removeClass('btn-primary')->addClass('btn-warning');
|
757 |
0e834fc5
|
Stephen Beaver
|
|
758 |
a4af095c
|
Renato Botelho
|
$section->add($group);
|
759 |
7eead1fc
|
Darren Embry
|
}
|
760 |
0e834fc5
|
Stephen Beaver
|
|
761 |
a4af095c
|
Renato Botelho
|
if (is_subsystem_dirty("packagelock")) {
|
762 |
|
|
$group = new Form_Group('');
|
763 |
|
|
$group->add(new Form_Button(
|
764 |
|
|
'Submit',
|
765 |
|
|
'Clear Package Lock'
|
766 |
|
|
))->setHelp('Click this button to clear the package lock if a package fails to reinstall properly after an upgrade.')->removeClass('btn-primary')->addClass('btn-warning');
|
767 |
0e834fc5
|
Stephen Beaver
|
|
768 |
a4af095c
|
Renato Botelho
|
$section->add($group);
|
769 |
|
|
}
|
770 |
0e834fc5
|
Stephen Beaver
|
|
771 |
a4af095c
|
Renato Botelho
|
$form->add($section);
|
772 |
a1003d57
|
Ermal Lu?i
|
}
|
773 |
a4af095c
|
Renato Botelho
|
|
774 |
|
|
print($form);
|
775 |
|
|
|
776 |
|
|
include("foot.inc");
|
777 |
7a7f3af1
|
sullrich
|
|
778 |
5f601060
|
Phil Davis
|
if (is_subsystem_dirty('restore')) {
|
779 |
cf9a4467
|
jim-p
|
system_reboot();
|
780 |
a4af095c
|
Renato Botelho
|
}
|