1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
diag_backup.php
|
5
|
Copyright (C) 2004-2009 Scott Ullrich
|
6
|
All rights reserved.
|
7
|
|
8
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
9
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10
|
All rights reserved.
|
11
|
|
12
|
Redistribution and use in source and binary forms, with or without
|
13
|
modification, are permitted provided that the following conditions are met:
|
14
|
|
15
|
1. Redistributions of source code must retain the above copyright notice,
|
16
|
this list of conditions and the following disclaimer.
|
17
|
|
18
|
2. Redistributions in binary form must reproduce the above copyright
|
19
|
notice, this list of conditions and the following disclaimer in the
|
20
|
documentation and/or other materials provided with the distribution.
|
21
|
|
22
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
23
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
24
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
25
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
26
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
27
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
28
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
29
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
30
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
31
|
POSSIBILITY OF SUCH DAMAGE.
|
32
|
*/
|
33
|
|
34
|
/*
|
35
|
pfSense_BUILDER_BINARIES: /sbin/shutdown
|
36
|
pfSense_MODULE: backup
|
37
|
*/
|
38
|
|
39
|
##|+PRIV
|
40
|
##|*IDENT=page-diagnostics-backup/restore
|
41
|
##|*NAME=Diagnostics: Backup/restore page
|
42
|
##|*DESCR=Allow access to the 'Diagnostics: Backup/restore' page.
|
43
|
##|*MATCH=diag_backup.php*
|
44
|
##|-PRIV
|
45
|
|
46
|
/* Allow additional execution time 0 = no limit. */
|
47
|
ini_set('max_execution_time', '0');
|
48
|
ini_set('max_input_time', '0');
|
49
|
|
50
|
/* omit no-cache headers because it confuses IE with file downloads */
|
51
|
$omit_nocacheheaders = true;
|
52
|
require("guiconfig.inc");
|
53
|
require_once("functions.inc");
|
54
|
require_once("filter.inc");
|
55
|
require_once("shaper.inc");
|
56
|
|
57
|
function add_base_packages_menu_items() {
|
58
|
global $g, $config;
|
59
|
$base_packages = split($g['base_packages'], ",");
|
60
|
$modified_config = false;
|
61
|
foreach($base_packages as $bp) {
|
62
|
$basepkg_path = "/usr/local/pkg/{$bp}";
|
63
|
$tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION);
|
64
|
if($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) {
|
65
|
$pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui");
|
66
|
if($pkg_config['menu'] != "") {
|
67
|
if(is_array($pkg_config['menu'])) {
|
68
|
foreach($pkg_config['menu'] as $menu) {
|
69
|
if(is_array($config['installedpackages']['menu']))
|
70
|
foreach($config['installedpackages']['menu'] as $amenu)
|
71
|
if($amenu['name'] == $menu['name'])
|
72
|
continue;
|
73
|
$config['installedpackages']['menu'][] = $menu;
|
74
|
$modified_config = true;
|
75
|
}
|
76
|
}
|
77
|
$static_output .= "done.\n";
|
78
|
update_output_window($static_output);
|
79
|
}
|
80
|
}
|
81
|
}
|
82
|
if($modified_config) {
|
83
|
write_confg("Restored base_package menus after configuration restore.");
|
84
|
$config = parse_config(true);
|
85
|
}
|
86
|
}
|
87
|
|
88
|
function remove_bad_chars($string) {
|
89
|
return preg_replace('/[^a-z|_|0-9]/i','',$string);
|
90
|
}
|
91
|
|
92
|
function check_and_returnif_section_exists($section) {
|
93
|
global $config;
|
94
|
if(is_array($config[$section]))
|
95
|
return true;
|
96
|
return false;
|
97
|
}
|
98
|
|
99
|
function spit_out_select_items($area, $showall) {
|
100
|
global $config;
|
101
|
|
102
|
$areas = array("aliases" => "Aliases",
|
103
|
"captiveportal" => "Captive Portal",
|
104
|
"dnsmasq" => "DNS Forwarder",
|
105
|
"dhcpd" => "DHCP Server",
|
106
|
"filter" => "Firewall Rules",
|
107
|
"interfaces" => "Interfaces",
|
108
|
"ipsec" => "IPSEC",
|
109
|
"nat" => "NAT",
|
110
|
"ovpn" => "OpenVPN",
|
111
|
"installedpackages" => "Package Manager",
|
112
|
"pptpd" => "PPTP Server",
|
113
|
"cron" => "Scheduled Tasks",
|
114
|
"syslog" => "Syslog",
|
115
|
"system" => "System",
|
116
|
"staticroutes" => "Static routes",
|
117
|
"sysctl" => "System tunables",
|
118
|
"snmpd" => "SNMP Server",
|
119
|
"shaper" => "Traffic Shaper",
|
120
|
"vlans" => "VLANS",
|
121
|
"wol" => "Wake on LAN"
|
122
|
);
|
123
|
|
124
|
$select = "<select name=\"{$area}\">\n";
|
125
|
$select .= "<option VALUE=\"\">ALL</option>";
|
126
|
|
127
|
if($showall == true)
|
128
|
foreach($areas as $area => $areaname)
|
129
|
$select .= "<option value='{$area}'>{$areaname}</option>\n";
|
130
|
else
|
131
|
foreach($areas as $area => $areaname)
|
132
|
if(check_and_returnif_section_exists($area) == true)
|
133
|
$select .= "<option value='{$area}'>{$areaname}</option>\n";
|
134
|
|
135
|
$select .= "</select>\n";
|
136
|
|
137
|
echo $select;
|
138
|
|
139
|
}
|
140
|
|
141
|
if ($_POST['apply']) {
|
142
|
ob_flush();
|
143
|
flush();
|
144
|
conf_mount_rw();
|
145
|
clear_subsystem_dirty("restore");
|
146
|
conf_mount_ro();
|
147
|
exit;
|
148
|
}
|
149
|
|
150
|
if ($_POST) {
|
151
|
unset($input_errors);
|
152
|
if (stristr($_POST['Submit'], "Restore configuration"))
|
153
|
$mode = "restore";
|
154
|
else if (stristr($_POST['Submit'], "Reinstall"))
|
155
|
$mode = "reinstallpackages";
|
156
|
else if (stristr($_POST['Submit'], "Download"))
|
157
|
$mode = "download";
|
158
|
else if (stristr($_POST['Submit'], "Restore version"))
|
159
|
$mode = "restore_ver";
|
160
|
|
161
|
if ($_POST["nopackages"] <> "")
|
162
|
$options = "nopackages";
|
163
|
|
164
|
if ($_POST["ver"] <> "")
|
165
|
$ver2restore = $_POST["ver"];
|
166
|
|
167
|
if ($mode) {
|
168
|
|
169
|
if ($mode == "download") {
|
170
|
|
171
|
if ($_POST['encrypt']) {
|
172
|
if(!$_POST['encrypt_password'] || !$_POST['encrypt_passconf'])
|
173
|
$input_errors[] = "You must supply and confirm the password for encryption.";
|
174
|
if($_POST['encrypt_password'] != $_POST['encrypt_passconf'])
|
175
|
$input_errors[] = "The supplied 'Password' and 'Confirm' field values must match.";
|
176
|
}
|
177
|
|
178
|
if (!$input_errors) {
|
179
|
|
180
|
//$lockbckp = lock('config');
|
181
|
|
182
|
$host = "{$config['system']['hostname']}.{$config['system']['domain']}";
|
183
|
$name = "config-{$host}-".date("YmdHis").".xml";
|
184
|
$data = "";
|
185
|
|
186
|
if($options == "nopackages") {
|
187
|
if(!$_POST['backuparea']) {
|
188
|
/* backup entire configuration */
|
189
|
$data = file_get_contents("{$g['conf_path']}/config.xml");
|
190
|
} else {
|
191
|
/* backup specific area of configuration */
|
192
|
$data = backup_config_section($_POST['backuparea']);
|
193
|
$name = "{$_POST['backuparea']}-{$name}";
|
194
|
}
|
195
|
$sfn = "{$g['tmp_path']}/config.xml.nopkg";
|
196
|
file_put_contents($sfn, $data);
|
197
|
exec("sed '/<installedpackages>/,/<\/installedpackages>/d' {$sfn} > {$sfn}-new");
|
198
|
$data = file_get_contents($sfn . "-new");
|
199
|
} else {
|
200
|
if(!$_POST['backuparea']) {
|
201
|
/* backup entire configuration */
|
202
|
$data = file_get_contents("{$g['conf_path']}/config.xml");
|
203
|
} else {
|
204
|
/* backup specific area of configuration */
|
205
|
$data = backup_config_section($_POST['backuparea']);
|
206
|
$name = "{$_POST['backuparea']}-{$name}";
|
207
|
}
|
208
|
}
|
209
|
|
210
|
//unlock($lockbckp);
|
211
|
|
212
|
if ($_POST['encrypt']) {
|
213
|
$data = encrypt_data($data, $_POST['encrypt_password']);
|
214
|
tagfile_reformat($data, $data, "config.xml");
|
215
|
}
|
216
|
|
217
|
/*
|
218
|
* Backup RRD Data
|
219
|
*/
|
220
|
if(!$_POST['donotbackuprrd']) {
|
221
|
$data = str_replace("</pfsense>", "\t<rrddata>", $data);
|
222
|
$rrd_files_var_db_rrd = split("\n",`cd /var/db/rrd && ls *.rrd`);
|
223
|
foreach($rrd_files_var_db_rrd as $rrd) {
|
224
|
if($rrd) {
|
225
|
$rrd_data = file_get_contents("{$g['vardb_path']}/rrd/{$rrd}");
|
226
|
if($rrd_data) {
|
227
|
$data .= "\t\t<rrddatafile>\n";
|
228
|
$data .= "\t\t\t<filename>{$rrd}</filename>\n";
|
229
|
$data .= "\t\t\t<data>" . base64_encode($rrd_data) . "</data>\n";
|
230
|
$data .= "\t\t</rrddatafile>\n";
|
231
|
}
|
232
|
}
|
233
|
}
|
234
|
$data .= "\t</rrddata>\n";
|
235
|
$data .= "</pfsense>\n";
|
236
|
}
|
237
|
|
238
|
$size = strlen($data);
|
239
|
header("Content-Type: application/octet-stream");
|
240
|
header("Content-Disposition: attachment; filename={$name}");
|
241
|
header("Content-Length: $size");
|
242
|
echo $data;
|
243
|
|
244
|
exit;
|
245
|
}
|
246
|
}
|
247
|
|
248
|
if ($mode == "restore") {
|
249
|
|
250
|
if ($_POST['decrypt']) {
|
251
|
if(!$_POST['decrypt_password'] || !$_POST['decrypt_passconf'])
|
252
|
$input_errors[] = "You must supply and confirm the password for decryption.";
|
253
|
if($_POST['decrypt_password'] != $_POST['decrypt_passconf'])
|
254
|
$input_errors[] = "The supplied 'Password' and 'Confirm' field values must match.";
|
255
|
}
|
256
|
|
257
|
if (!$input_errors) {
|
258
|
|
259
|
if (is_uploaded_file($_FILES['conffile']['tmp_name'])) {
|
260
|
|
261
|
/* read the file contents */
|
262
|
$data = file_get_contents($_FILES['conffile']['tmp_name']);
|
263
|
if(!$data) {
|
264
|
log_error("Warning, could not read file " . $_FILES['conffile']['tmp_name']);
|
265
|
return 1;
|
266
|
}
|
267
|
|
268
|
if ($_POST['decrypt']) {
|
269
|
if (!tagfile_deformat($data, $data, "config.xml")) {
|
270
|
$input_errors[] = "The uploaded file does not appear to contain an encrypted pfsense configuration.";
|
271
|
return 1;
|
272
|
}
|
273
|
$data = decrypt_data($data, $_POST['decrypt_password']);
|
274
|
}
|
275
|
|
276
|
if(stristr($data, "<m0n0wall>")) {
|
277
|
log_error("Upgrading m0n0wall configuration to pfsense.");
|
278
|
/* m0n0wall was found in config. convert it. */
|
279
|
$data = str_replace("m0n0wall", "pfsense", $data);
|
280
|
$m0n0wall_upgrade = true;
|
281
|
}
|
282
|
if($_POST['restorearea']) {
|
283
|
/* restore a specific area of the configuration */
|
284
|
if(!stristr($data, $_POST['restorearea'])) {
|
285
|
$input_errors[] = "You have selected to restore an area but we could not locate the correct xml tag.";
|
286
|
} else {
|
287
|
restore_config_section($_POST['restorearea'], $data);
|
288
|
filter_configure();
|
289
|
$savemsg = "The configuration area has been restored. You may need to reboot the firewall.";
|
290
|
}
|
291
|
} else {
|
292
|
if(!stristr($data, "<" . $g['xml_rootobj'] . ">")) {
|
293
|
$input_errors[] = "You have selected to restore the full configuration but we could not locate a " . $g['xml_rootobj'] . " tag.";
|
294
|
} else {
|
295
|
/* restore the entire configuration */
|
296
|
file_put_contents($_FILES['conffile']['tmp_name'], $data);
|
297
|
if (config_install($_FILES['conffile']['tmp_name']) == 0) {
|
298
|
/* this will be picked up by /index.php */
|
299
|
conf_mount_rw();
|
300
|
mark_subsystem_dirty("restore");
|
301
|
touch("/conf/needs_package_sync");
|
302
|
/* remove cache, we will force a config reboot */
|
303
|
if(file_exists("{$g['tmp_path']}/config.cache"))
|
304
|
unlink("{$g['tmp_path']}/config.cache");
|
305
|
$config = parse_config(true);
|
306
|
/* extract out rrd items, unset from $confgi when done */
|
307
|
if($config['rrddata']) {
|
308
|
foreach($config['rrddata']['rrddatafile'] as $rrd) {
|
309
|
$rrd_fd = fopen("{$g['vardb_path']}/rrd/{$rrd['filename']}", "w");
|
310
|
fwrite($rrd_fd, base64_decode($rrd['data']));
|
311
|
fclose($rrd_fd);
|
312
|
}
|
313
|
unset($config['rrddata']);
|
314
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
315
|
write_config();
|
316
|
add_base_packages_menu_items();
|
317
|
convert_config();
|
318
|
conf_mount_ro();
|
319
|
}
|
320
|
if($m0n0wall_upgrade == true) {
|
321
|
if($config['system']['gateway'] <> "")
|
322
|
$config['interfaces']['wan']['gateway'] = $config['system']['gateway'];
|
323
|
unset($config['shaper']);
|
324
|
/* optional if list */
|
325
|
$ifdescrs = get_configured_interface_list(true, true);
|
326
|
/* remove special characters from interface descriptions */
|
327
|
if(is_array($ifdescrs))
|
328
|
foreach($ifdescrs as $iface)
|
329
|
$config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']);
|
330
|
/* check for interface names with an alias */
|
331
|
if(is_array($ifdescrs)) {
|
332
|
foreach($ifdescrs as $iface) {
|
333
|
if(is_alias($config['interfaces'][$iface]['descr'])) {
|
334
|
// Firewall rules
|
335
|
$origname = $config['interfaces'][$iface]['descr'];
|
336
|
$newname = $config['interfaces'][$iface]['descr'] . "Alias";
|
337
|
update_alias_names_upon_change('filter', 'rule', 'source', 'address', $newname, $origname);
|
338
|
update_alias_names_upon_change('filter', 'rule', 'destination', 'address', $newname, $origname);
|
339
|
// NAT Rules
|
340
|
update_alias_names_upon_change('nat', 'rule', 'target', '', $newname, $origname);
|
341
|
update_alias_names_upon_change('nat', 'rule', 'external-port', '', $newname, $origname);
|
342
|
update_alias_names_upon_change('nat', 'rule', 'local-port', '', $newname, $origname);
|
343
|
// Alias in an alias
|
344
|
update_alias_names_upon_change('aliases', 'alias', 'address', '', $newname, $origname);
|
345
|
}
|
346
|
}
|
347
|
}
|
348
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
349
|
// Reset configuration version to something low
|
350
|
// in order to force the config upgrade code to
|
351
|
// run through with all steps that are required.
|
352
|
$config['system']['version'] = "1.0";
|
353
|
// Deal with descriptions longer than 63 characters
|
354
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
355
|
if(count($config['filter']['rule'][$i]['descr']) > 63)
|
356
|
$config['filter']['rule'][$i]['descr'] = substr($config['filter']['rule'][$i]['descr'], 0, 63);
|
357
|
}
|
358
|
// Move interface from ipsec to enc0
|
359
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
360
|
if($config['filter']['rule'][$i]['interface'] == "ipsec")
|
361
|
$config['filter']['rule'][$i]['interface'] = "enc0";
|
362
|
}
|
363
|
// Convert icmp types
|
364
|
// http://www.openbsd.org/cgi-bin/man.cgi?query=icmp&sektion=4&arch=i386&apropos=0&manpath=OpenBSD+Current
|
365
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
366
|
if($config["filter"]["rule"][$i]['icmptype']) {
|
367
|
switch($config["filter"]["rule"][$i]['icmptype']) {
|
368
|
case "echo":
|
369
|
$config["filter"]["rule"][$i]['icmptype'] = "echoreq";
|
370
|
break;
|
371
|
case "unreach":
|
372
|
$config["filter"]["rule"][$i]['icmptype'] = "unreach";
|
373
|
break;
|
374
|
case "echorep":
|
375
|
$config["filter"]["rule"][$i]['icmptype'] = "echorep";
|
376
|
break;
|
377
|
case "squench":
|
378
|
$config["filter"]["rule"][$i]['icmptype'] = "squench";
|
379
|
break;
|
380
|
case "redir":
|
381
|
$config["filter"]["rule"][$i]['icmptype'] = "redir";
|
382
|
break;
|
383
|
case "timex":
|
384
|
$config["filter"]["rule"][$i]['icmptype'] = "timex";
|
385
|
break;
|
386
|
case "paramprob":
|
387
|
$config["filter"]["rule"][$i]['icmptype'] = "paramprob";
|
388
|
break;
|
389
|
case "timest":
|
390
|
$config["filter"]["rule"][$i]['icmptype'] = "timereq";
|
391
|
break;
|
392
|
case "timestrep":
|
393
|
$config["filter"]["rule"][$i]['icmptype'] = "timerep";
|
394
|
break;
|
395
|
case "inforeq":
|
396
|
$config["filter"]["rule"][$i]['icmptype'] = "inforeq";
|
397
|
break;
|
398
|
case "inforep":
|
399
|
$config["filter"]["rule"][$i]['icmptype'] = "inforep";
|
400
|
break;
|
401
|
case "maskreq":
|
402
|
$config["filter"]["rule"][$i]['icmptype'] = "maskreq";
|
403
|
break;
|
404
|
case "maskrep":
|
405
|
$config["filter"]["rule"][$i]['icmptype'] = "maskrep";
|
406
|
break;
|
407
|
}
|
408
|
}
|
409
|
}
|
410
|
$config['diag']['ipv6nat'] = true;
|
411
|
write_config();
|
412
|
add_base_packages_menu_items();
|
413
|
convert_config();
|
414
|
conf_mount_ro();
|
415
|
$savemsg = "The m0n0wall configuration has been restored and upgraded to pfSense.";
|
416
|
mark_subsystem_dirty("restore");
|
417
|
}
|
418
|
if(isset($config['captiveportal']['enable'])) {
|
419
|
/* for some reason ipfw doesn't init correctly except on bootup sequence */
|
420
|
mark_subsystem_dirty("restore");
|
421
|
}
|
422
|
setup_serial_port();
|
423
|
if(is_interface_mismatch() == true) {
|
424
|
touch("/var/run/interface_mismatch_reboot_needed");
|
425
|
clear_subsystem_dirty("restore");
|
426
|
convert_config();
|
427
|
header("Location: interfaces_assign.php");
|
428
|
exit;
|
429
|
}
|
430
|
} else {
|
431
|
$input_errors[] = "The configuration could not be restored.";
|
432
|
}
|
433
|
}
|
434
|
}
|
435
|
} else {
|
436
|
$input_errors[] = "The configuration could not be restored (file upload error).";
|
437
|
}
|
438
|
}
|
439
|
}
|
440
|
|
441
|
if ($mode == "reinstallpackages") {
|
442
|
|
443
|
header("Location: pkg_mgr_install.php?mode=reinstallall");
|
444
|
exit;
|
445
|
} else if ($mode == "restore_ver") {
|
446
|
$input_errors[] = "XXX - this feature may hose your config (do NOT backrev configs!) - billm";
|
447
|
if ($ver2restore <> "") {
|
448
|
$conf_file = "{$g['cf_conf_path']}/bak/config-" . strtotime($ver2restore) . ".xml";
|
449
|
if (config_install($conf_file) == 0) {
|
450
|
mark_subsystem_dirty("restore");
|
451
|
} else {
|
452
|
$input_errors[] = "The configuration could not be restored.";
|
453
|
}
|
454
|
} else {
|
455
|
$input_errors[] = "No version selected.";
|
456
|
}
|
457
|
}
|
458
|
}
|
459
|
}
|
460
|
|
461
|
$id = rand() . '.' . time();
|
462
|
|
463
|
$mth = ini_get('upload_progress_meter.store_method');
|
464
|
$dir = ini_get('upload_progress_meter.file.filename_template');
|
465
|
|
466
|
$pgtitle = array("Diagnostics","Backup/restore");
|
467
|
include("head.inc");
|
468
|
|
469
|
?>
|
470
|
|
471
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
472
|
<?php include("fbegin.inc"); ?>
|
473
|
<script language="JavaScript">
|
474
|
<!--
|
475
|
|
476
|
function encrypt_change() {
|
477
|
|
478
|
if (!document.iform.encrypt.checked)
|
479
|
document.getElementById("encrypt_opts").style.display="none";
|
480
|
else
|
481
|
document.getElementById("encrypt_opts").style.display="";
|
482
|
}
|
483
|
|
484
|
function decrypt_change() {
|
485
|
|
486
|
if (!document.iform.decrypt.checked)
|
487
|
document.getElementById("decrypt_opts").style.display="none";
|
488
|
else
|
489
|
document.getElementById("decrypt_opts").style.display="";
|
490
|
}
|
491
|
|
492
|
//-->
|
493
|
</script>
|
494
|
|
495
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
496
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
497
|
<?php if (is_subsystem_dirty('restore')): ?><p>
|
498
|
<form action="reboot.php" method="post">
|
499
|
<input name="Submit" type="hidden" value=" Yes ">
|
500
|
<?php print_info_box("The firewall configuration has been changed.<br/>The firewall is now rebooting.");?><br>
|
501
|
</form>
|
502
|
<?php endif; ?>
|
503
|
<form action="diag_backup.php" method="post" name="iform" enctype="multipart/form-data">
|
504
|
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
505
|
<tr>
|
506
|
<td>
|
507
|
<?php
|
508
|
$tab_array = array();
|
509
|
$tab_array[0] = array("Config History", false, "diag_confbak.php");
|
510
|
$tab_array[1] = array("Backup/Restore", true, "diag_backup.php");
|
511
|
display_top_tabs($tab_array);
|
512
|
?>
|
513
|
</td>
|
514
|
</tr>
|
515
|
<tr>
|
516
|
<td>
|
517
|
<div id="mainarea">
|
518
|
<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
|
519
|
<tr>
|
520
|
<td colspan="2" class="listtopic">Backup configuration</td>
|
521
|
</tr>
|
522
|
<tr>
|
523
|
<td width="22%" valign="baseline" class="vncell"> </td>
|
524
|
<td width="78%" class="vtable">
|
525
|
<p>Click this button to download the system configuration in XML format.<br /><br /> Backup area: <?php spit_out_select_items("backuparea", false); ?></p>
|
526
|
<table>
|
527
|
<tr>
|
528
|
<td>
|
529
|
<input name="nopackages" type="checkbox" class="formcheckbox" id="nopackages">
|
530
|
</td>
|
531
|
<td>
|
532
|
<span class="vexpl">Do not backup package information.</span>
|
533
|
</td>
|
534
|
</tr>
|
535
|
</table>
|
536
|
<table>
|
537
|
<tr>
|
538
|
<td>
|
539
|
<input name="encrypt" type="checkbox" class="formcheckbox" id="nopackages" onClick="encrypt_change()">
|
540
|
</td>
|
541
|
<td>
|
542
|
<span class="vexpl">Encrypt this configuration file.</span>
|
543
|
</td>
|
544
|
</tr>
|
545
|
<tr>
|
546
|
<td>
|
547
|
<input name="donotbackuprrd" type="checkbox" class="formcheckbox" id="dotnotbackuprrd">
|
548
|
</td>
|
549
|
<td>
|
550
|
<span class="vexpl">Do not backup RRD data (NOTE: RRD Data can consume 4+ megabytes of config.xml space!)</span>
|
551
|
</td>
|
552
|
</tr>
|
553
|
</table>
|
554
|
<table id="encrypt_opts">
|
555
|
<tr>
|
556
|
<td>
|
557
|
<span class="vexpl">Password :</span>
|
558
|
</td>
|
559
|
<td>
|
560
|
<input name="encrypt_password" type="password" class="formfld pwd" size="20" value="" />
|
561
|
</td>
|
562
|
</tr>
|
563
|
<tr>
|
564
|
<td>
|
565
|
<span class="vexpl">confirm :</span>
|
566
|
</td>
|
567
|
<td>
|
568
|
<input name="encrypt_passconf" type="password" class="formfld pwd" size="20" value="" />
|
569
|
</td>
|
570
|
</tr>
|
571
|
</table>
|
572
|
<p><input name="Submit" type="submit" class="formbtn" id="download" value="Download configuration"></p>
|
573
|
</td>
|
574
|
</tr>
|
575
|
<tr>
|
576
|
<td colspan="2" class="list" height="12"> </td>
|
577
|
</tr>
|
578
|
<tr>
|
579
|
<td colspan="2" class="listtopic">Restore configuration</td>
|
580
|
</tr>
|
581
|
<tr>
|
582
|
<td width="22%" valign="baseline" class="vncell"> </td>
|
583
|
<td width="78%" class="vtable">
|
584
|
Open a <?=$g['[product_name']?> configuration XML file and click the button below to restore the configuration. <br /><br /> Restore area: <?php spit_out_select_items("restorearea", true); ?>
|
585
|
<p><input name="conffile" type="file" class="formfld unknown" id="conffile" size="40"></p>
|
586
|
<table>
|
587
|
<tr>
|
588
|
<td>
|
589
|
<input name="decrypt" type="checkbox" class="formcheckbox" id="nopackages" onClick="decrypt_change()">
|
590
|
</td>
|
591
|
<td>
|
592
|
<span class="vexpl">Configuration file is encrypted.</span>
|
593
|
</td>
|
594
|
</tr>
|
595
|
</table>
|
596
|
<table id="decrypt_opts">
|
597
|
<tr>
|
598
|
<td>
|
599
|
<span class="vexpl">Password :</span>
|
600
|
</td>
|
601
|
<td>
|
602
|
<input name="decrypt_password" type="password" class="formfld pwd" size="20" value="" />
|
603
|
</td>
|
604
|
</tr>
|
605
|
<tr>
|
606
|
<td>
|
607
|
<span class="vexpl">confirm :</span>
|
608
|
</td>
|
609
|
<td>
|
610
|
<input name="decrypt_passconf" type="password" class="formfld pwd" size="20" value="" />
|
611
|
</td>
|
612
|
</tr>
|
613
|
</table>
|
614
|
<p><input name="Submit" type="submit" class="formbtn" id="restore" value="Restore configuration"></p>
|
615
|
<p><strong><span class="red">Note:</span></strong><br />The firewall will reboot after restoring the configuration.<br /></p>
|
616
|
</td>
|
617
|
</tr>
|
618
|
<?php if($config['installedpackages']['package'] != "") { ?>
|
619
|
<tr>
|
620
|
<td colspan="2" class="list" height="12"> </td>
|
621
|
</tr>
|
622
|
<tr>
|
623
|
<td colspan="2" class="listtopic">Reinstall packages</td>
|
624
|
</tr>
|
625
|
<tr>
|
626
|
<td width="22%" valign="baseline" class="vncell"> </td>
|
627
|
<td width="78%" class="vtable">
|
628
|
<p>Click this button to reinstall all system packages. This may take a while. <br /><br />
|
629
|
<input name="Submit" type="submit" class="formbtn" id="reinstallpackages" value="Reinstall packages">
|
630
|
</td>
|
631
|
</tr>
|
632
|
<?php } ?>
|
633
|
</table>
|
634
|
</div>
|
635
|
</td>
|
636
|
</tr>
|
637
|
</table>
|
638
|
</form>
|
639
|
|
640
|
<script language="JavaScript">
|
641
|
<!--
|
642
|
encrypt_change();
|
643
|
decrypt_change();
|
644
|
//-->
|
645
|
</script>
|
646
|
|
647
|
<?php include("fend.inc"); ?>
|
648
|
</body>
|
649
|
</html>
|
650
|
<?php
|
651
|
|
652
|
if (is_subsystem_dirty('restore'))
|
653
|
exec("/etc/rc.reboot");
|
654
|
|
655
|
?>
|