Project

General

Profile

Download (24.6 KB) Statistics
| Branch: | Tag: | Revision:
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(gettext("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" => gettext("Aliases"),
103
				   "captiveportal" => gettext("Captive Portal"),
104
				   "voucher" => gettext("Captive Portal Vouchers"),
105
				   "dnsmasq" => gettext("DNS Forwarder"),
106
				   "dhcpd" => gettext("DHCP Server"),
107
				   "filter" => gettext("Firewall Rules"),
108
				   "interfaces" => gettext("Interfaces"),
109
				   "ipsec" => gettext("IPSEC"),
110
				   "nat" => gettext("NAT"),
111
				   "ovpn" => gettext("OpenVPN"),
112
				   "installedpackages" => gettext("Package Manager"),
113
				   "pptpd" => gettext("PPTP Server"),
114
				   "cron" => gettext("Scheduled Tasks"),
115
				   "syslog" => gettext("Syslog"),
116
				   "system" => gettext("System"),
117
				   "staticroutes" => gettext("Static routes"),
118
				   "sysctl" => gettext("System tunables"),
119
				   "snmpd" => gettext("SNMP Server"),
120
				   "shaper" => gettext("Traffic Shaper"),
121
				   "vlans" => gettext("VLANS"),
122
				   "wol" => gettext("Wake on LAN")
123
	);
124

    
125
	$select  = "<select name=\"{$area}\" id=\"{$aread}\" ";
126
	if ($area == "backuparea")
127
		$select .= " onChange=backuparea_change(this)";
128
	$select .= " >\n";
129
	$select .= "<option VALUE=\"\">" . gettext("ALL") . "</option>";
130

    
131
	if($showall == true)
132
		foreach($areas as $area => $areaname)
133
			$select .= "<option value='{$area}'>{$areaname}</option>\n";
134
	else
135
		foreach($areas as $area => $areaname)
136
			if(check_and_returnif_section_exists($area) == true)
137
				$select .= "<option value='{$area}'>{$areaname}</option>\n";
138

    
139
	$select .= "</select>\n";
140

    
141
	echo $select;
142

    
143
}
144

    
145
if ($_POST['apply']) {
146
        ob_flush();
147
        flush();
148
		conf_mount_rw();
149
		clear_subsystem_dirty("restore");
150
		conf_mount_ro();
151
        exit;
152
}
153

    
154
if ($_POST) {
155
	unset($input_errors);
156
	if (stristr($_POST['Submit'], gettext("Restore configuration")))
157
		$mode = "restore";
158
	else if (stristr($_POST['Submit'], gettext("Reinstall")))
159
		$mode = "reinstallpackages";
160
	else if (stristr($_POST['Submit'], gettext("Download")))
161
		$mode = "download";
162
	else if (stristr($_POST['Submit'], gettext("Restore version")))
163
		$mode = "restore_ver";
164

    
165
	if ($_POST["nopackages"] <> "")
166
		$options = "nopackages";
167

    
168
	if ($_POST["ver"] <> "")
169
		$ver2restore = $_POST["ver"];
170

    
171
	if ($mode) {
172

    
173
		if ($mode == "download") {
174

    
175
			if ($_POST['encrypt']) {
176
				if(!$_POST['encrypt_password'] || !$_POST['encrypt_passconf'])
177
					$input_errors[] = gettext("You must supply and confirm the password for encryption.");
178
				if($_POST['encrypt_password'] != $_POST['encrypt_passconf'])
179
					$input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match.");
180
			}
181

    
182
			if (!$input_errors) {
183

    
184
				//$lockbckp = lock('config');
185

    
186
				$host = "{$config['system']['hostname']}.{$config['system']['domain']}";
187
				$name = "config-{$host}-".date("YmdHis").".xml";
188
				$data = "";
189

    
190
				if($options == "nopackages") {
191
					if(!$_POST['backuparea']) {
192
						/* backup entire configuration */
193
						$data = file_get_contents("{$g['conf_path']}/config.xml");
194
					} else {
195
						/* backup specific area of configuration */
196
						$data = backup_config_section($_POST['backuparea']);
197
						$name = "{$_POST['backuparea']}-{$name}";
198
					}
199
					$sfn = "{$g['tmp_path']}/config.xml.nopkg";
200
					file_put_contents($sfn, $data);
201
					exec("sed '/<installedpackages>/,/<\/installedpackages>/d' {$sfn} > {$sfn}-new");
202
					$data = file_get_contents($sfn . "-new");
203
				} else {
204
					if(!$_POST['backuparea']) {
205
						/* backup entire configuration */
206
						$data = file_get_contents("{$g['conf_path']}/config.xml");
207
					} else {
208
						/* backup specific area of configuration */
209
						$data = backup_config_section($_POST['backuparea']);
210
						$name = "{$_POST['backuparea']}-{$name}";
211
					}
212
				}
213

    
214
				//unlock($lockbckp);
215

    
216
				if ($_POST['encrypt']) {
217
					$data = encrypt_data($data, $_POST['encrypt_password']);
218
					tagfile_reformat($data, $data, "config.xml");
219
				}
220

    
221
				/*
222
				 *  Backup RRD Data
223
				 */
224
				if(!$_POST['donotbackuprrd']) {
225
					$data = str_replace("</pfsense>", "\t<rrddata>", $data);
226
					$rrd_files_var_db_rrd = split("\n",`cd /var/db/rrd && ls *.rrd`);
227
					foreach($rrd_files_var_db_rrd as $rrd) {
228
						if($rrd) {
229
							$rrd_data = file_get_contents("{$g['vardb_path']}/rrd/{$rrd}");
230
							if($rrd_data) {
231
								$data .= "\t\t<rrddatafile>\n";
232
								$data .= "\t\t\t<filename>{$rrd}</filename>\n";
233
								$data .= "\t\t\t<data>" . base64_encode(gzdeflate($rrd_data)) . "</data>\n";
234
								$data .= "\t\t</rrddatafile>\n";
235
							}
236
						}
237
					}
238
					$data .= "\t</rrddata>\n";
239
					$data .= "</pfsense>\n";
240
				}
241

    
242
				$size = strlen($data);
243
				header("Content-Type: application/octet-stream");
244
				header("Content-Disposition: attachment; filename={$name}");
245
				header("Content-Length: $size");
246
				if (isset($_SERVER['HTTPS'])) {
247
					header('Pragma: ');
248
					header('Cache-Control: ');
249
				} else {
250
					header("Pragma: private");
251
					header("Cache-Control: private, must-revalidate");
252
				}
253
				echo $data;
254

    
255
				exit;
256
			}
257
		}
258

    
259
		if ($mode == "restore") {
260

    
261
			if ($_POST['decrypt']) {
262
				if(!$_POST['decrypt_password'] || !$_POST['decrypt_passconf'])
263
					$input_errors[] = gettext("You must supply and confirm the password for decryption.");
264
				if($_POST['decrypt_password'] != $_POST['decrypt_passconf'])
265
					$input_errors[] = gettext("The supplied 'Password' and 'Confirm' field values must match.");
266
			}
267

    
268
			if (!$input_errors) {
269

    
270
				if (is_uploaded_file($_FILES['conffile']['tmp_name'])) {
271

    
272
					/* read the file contents */
273
					$data = file_get_contents($_FILES['conffile']['tmp_name']);
274
					if(!$data) {
275
						log_error(gettext("Warning, could not read file") . " " . $_FILES['conffile']['tmp_name']);
276
						return 1;
277
					}
278

    
279
					if ($_POST['decrypt']) {
280
						if (!tagfile_deformat($data, $data, "config.xml")) {
281
							$input_errors[] = gettext("The uploaded file does not appear to contain an encrypted pfsense configuration.");
282
							return 1;
283
						}
284
						$data = decrypt_data($data, $_POST['decrypt_password']);
285
					}
286

    
287
					if(stristr($data, "<m0n0wall>")) {
288
						log_error(gettext("Upgrading m0n0wall configuration to pfsense."));
289
						/* m0n0wall was found in config.  convert it. */
290
						$data = str_replace("m0n0wall", "pfsense", $data);
291
						$m0n0wall_upgrade = true;
292
					}
293
					if($_POST['restorearea']) {
294
						/* restore a specific area of the configuration */
295
						if(!stristr($data, $_POST['restorearea'])) {
296
							$input_errors[] = gettext("You have selected to restore an area but we could not locate the correct xml tag.");
297
						} else {
298
							restore_config_section($_POST['restorearea'], $data);
299
							filter_configure();
300
							$savemsg = gettext("The configuration area has been restored.  You may need to reboot the firewall.");
301
						}
302
					} else {
303
						if(!stristr($data, "<" . $g['xml_rootobj'] . ">")) {
304
							$input_errors[] = gettext("You have selected to restore the full configuration but we could not locate a") . " " . $g['xml_rootobj'] . " " . gettext("tag.");
305
						} else {
306
							/* restore the entire configuration */
307
							file_put_contents($_FILES['conffile']['tmp_name'], $data);
308
							if (config_install($_FILES['conffile']['tmp_name']) == 0) {
309
								/* this will be picked up by /index.php */
310
								conf_mount_rw();
311
								mark_subsystem_dirty("restore");
312
								touch("/conf/needs_package_sync");
313
								/* remove cache, we will force a config reboot */
314
								if(file_exists("{$g['tmp_path']}/config.cache"))
315
									unlink("{$g['tmp_path']}/config.cache");
316
								$config = parse_config(true);
317
								/* extract out rrd items, unset from $confgi when done */
318
								if($config['rrddata']) {
319
									foreach($config['rrddata']['rrddatafile'] as $rrd) {
320
										$rrd_fd = fopen("{$g['vardb_path']}/rrd/{$rrd['filename']}", "w");
321
										$data = base64_decode($rrd['data']);
322
										/* Try to decompress the data. */
323
										$dcomp = @gzinflate($data);
324
										if ($dcomp) {
325
											/* If the decompression worked, write the decompressed data */
326
											fwrite($rrd_fd, $dcomp);
327
										} else {
328
											/* If the decompression failed, it wasn't compressed, so write raw data */
329
											fwrite($rrd_fd, $data);
330
										}
331
										fclose($rrd_fd);
332
									}
333
									unset($config['rrddata']);
334
									unlink_if_exists("{$g['tmp_path']}/config.cache");
335
									write_config();
336
									add_base_packages_menu_items();
337
									convert_config();
338
									conf_mount_ro();
339
								}
340
								if($m0n0wall_upgrade == true) {
341
									if($config['system']['gateway'] <> "")
342
										$config['interfaces']['wan']['gateway'] = $config['system']['gateway'];
343
									unset($config['shaper']);
344
									/* optional if list */
345
									$ifdescrs = get_configured_interface_list(true, true);
346
									/* remove special characters from interface descriptions */
347
									if(is_array($ifdescrs))
348
										foreach($ifdescrs as $iface)
349
											$config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']);
350
									/* check for interface names with an alias */
351
									if(is_array($ifdescrs)) {
352
										foreach($ifdescrs as $iface) {
353
											if(is_alias($config['interfaces'][$iface]['descr'])) {
354
												// Firewall rules
355
												$origname = $config['interfaces'][$iface]['descr'];
356
												$newname  = $config['interfaces'][$iface]['descr'] . "Alias";
357
												update_alias_names_upon_change('filter', 'rule', 'source', 'address', $newname, $origname);
358
												update_alias_names_upon_change('filter', 'rule', 'destination', 'address', $newname, $origname);
359
												// NAT Rules
360
												update_alias_names_upon_change('nat', 'rule', 'source', 'address', $newname, $origname);
361
												update_alias_names_upon_change('nat', 'rule', 'source', 'port', $newname, $origname);
362
												update_alias_names_upon_change('nat', 'rule', 'destination', 'address', $newname, $origname);
363
												update_alias_names_upon_change('nat', 'rule', 'destination', 'port', $newname, $origname);
364
												update_alias_names_upon_change('nat', 'rule', 'target', '', $newname, $origname);
365
												update_alias_names_upon_change('nat', 'rule', 'local-port', '', $newname, $origname);
366
												// Alias in an alias
367
												update_alias_names_upon_change('aliases', 'alias', 'address', '', $newname, $origname);
368
											}
369
										}
370
									}
371
									unlink_if_exists("{$g['tmp_path']}/config.cache");
372
									// Reset configuration version to something low
373
									// in order to force the config upgrade code to
374
									// run through with all steps that are required.
375
									$config['system']['version'] = "1.0";
376
									// Deal with descriptions longer than 63 characters
377
									for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
378
										if(count($config['filter']['rule'][$i]['descr']) > 63)
379
											$config['filter']['rule'][$i]['descr'] = substr($config['filter']['rule'][$i]['descr'], 0, 63);
380
									}
381
									// Move interface from ipsec to enc0
382
									for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
383
										if($config['filter']['rule'][$i]['interface'] == "ipsec")
384
											$config['filter']['rule'][$i]['interface'] = "enc0";
385
									}
386
									// Convert icmp types
387
									// http://www.openbsd.org/cgi-bin/man.cgi?query=icmp&sektion=4&arch=i386&apropos=0&manpath=OpenBSD+Current
388
									for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
389
										if($config["filter"]["rule"][$i]['icmptype']) {
390
											switch($config["filter"]["rule"][$i]['icmptype']) {
391
												case "echo":
392
													$config["filter"]["rule"][$i]['icmptype'] = "echoreq";
393
													break;
394
					                            case "unreach":
395
													$config["filter"]["rule"][$i]['icmptype'] = "unreach";
396
													break;
397
					                            case "echorep":
398
													$config["filter"]["rule"][$i]['icmptype'] = "echorep";
399
													break;
400
					                            case "squench":
401
													$config["filter"]["rule"][$i]['icmptype'] = "squench";
402
													break;
403
					                            case "redir":
404
													$config["filter"]["rule"][$i]['icmptype'] = "redir";
405
													break;
406
					                            case "timex":
407
													$config["filter"]["rule"][$i]['icmptype'] = "timex";
408
													break;
409
					                            case "paramprob":
410
													$config["filter"]["rule"][$i]['icmptype'] = "paramprob";
411
													break;
412
					                            case "timest":
413
													$config["filter"]["rule"][$i]['icmptype'] = "timereq";
414
													break;
415
					                            case "timestrep":
416
													$config["filter"]["rule"][$i]['icmptype'] = "timerep";
417
													break;
418
					                            case "inforeq":
419
													$config["filter"]["rule"][$i]['icmptype'] = "inforeq";
420
													break;
421
					                            case "inforep":
422
													$config["filter"]["rule"][$i]['icmptype'] = "inforep";
423
													break;
424
					                            case "maskreq":
425
													$config["filter"]["rule"][$i]['icmptype'] = "maskreq";
426
													break;
427
					                            case "maskrep":
428
													$config["filter"]["rule"][$i]['icmptype'] = "maskrep";
429
													break;
430
											}
431
										}
432
									}
433
									$config['diag']['ipv6nat'] = true;
434
									write_config();
435
									add_base_packages_menu_items();
436
									convert_config();
437
									conf_mount_ro();
438
									$savemsg = gettext("The m0n0wall configuration has been restored and upgraded to pfSense.");
439
									mark_subsystem_dirty("restore");
440
								}
441
								if(isset($config['captiveportal']['enable'])) {
442
									/* for some reason ipfw doesn't init correctly except on bootup sequence */
443
									mark_subsystem_dirty("restore");
444
								}
445
								setup_serial_port();
446
								if(is_interface_mismatch() == true) {
447
									touch("/var/run/interface_mismatch_reboot_needed");
448
									clear_subsystem_dirty("restore");
449
									convert_config();
450
									header("Location: interfaces_assign.php");
451
									exit;
452
								}
453
							} else {
454
								$input_errors[] = gettext("The configuration could not be restored.");
455
							}
456
						}
457
					}
458
				} else {
459
					$input_errors[] = gettext("The configuration could not be restored (file upload error).");
460
				}
461
			}
462
		}
463

    
464
		if ($mode == "reinstallpackages") {
465

    
466
			header("Location: pkg_mgr_install.php?mode=reinstallall");
467
			exit;
468
                } else if ($mode == "restore_ver") {
469
			$input_errors[] = gettext("XXX - this feature may hose your config (do NOT backrev configs!) - billm");
470
			if ($ver2restore <> "") {
471
				$conf_file = "{$g['cf_conf_path']}/bak/config-" . strtotime($ver2restore) . ".xml";
472
				if (config_install($conf_file) == 0) {
473
						mark_subsystem_dirty("restore");
474
                        } else {
475
                        	$input_errors[] = gettext("The configuration could not be restored.");
476
                        }
477
                } else {
478
                        $input_errors[] = gettext("No version selected.");
479
                }
480
		}
481
	}
482
}
483

    
484
$id = rand() . '.' . time();
485

    
486
$mth = ini_get('upload_progress_meter.store_method');
487
$dir = ini_get('upload_progress_meter.file.filename_template');
488

    
489
$pgtitle = array(gettext("Diagnostics"),gettext("Backup/restore"));
490
include("head.inc");
491

    
492
?>
493

    
494
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
495
<?php include("fbegin.inc"); ?>
496
<script language="JavaScript">
497
<!--
498

    
499
function encrypt_change() {
500

    
501
	if (!document.iform.encrypt.checked)
502
		document.getElementById("encrypt_opts").style.display="none";
503
	else
504
		document.getElementById("encrypt_opts").style.display="";
505
}
506

    
507
function decrypt_change() {
508

    
509
	if (!document.iform.decrypt.checked)
510
		document.getElementById("decrypt_opts").style.display="none";
511
	else
512
		document.getElementById("decrypt_opts").style.display="";
513
}
514

    
515
function backuparea_change(obj) {
516

    
517
        if (obj.value == "")
518
                document.getElementById("dotnotbackuprrd").checked = false;
519
        else
520
                document.getElementById("dotnotbackuprrd").checked = true;
521
}
522
//-->
523
</script>
524

    
525
<?php if ($input_errors) print_input_errors($input_errors); ?>
526
<?php if ($savemsg) print_info_box($savemsg); ?>
527
<?php if (is_subsystem_dirty('restore')): ?><p>
528
<form action="reboot.php" method="post">
529
<input name="Submit" type="hidden" value=" Yes ">
530
<?php print_info_box(gettext("The firewall configuration has been changed.") . "<br/>" . gettext("The firewall is now rebooting."));?><br>
531
</form>
532
<?php endif; ?>
533
<form action="diag_backup.php" method="post" name="iform" enctype="multipart/form-data">
534
<table width="100%" border="0" cellspacing="0" cellpadding="0">
535
	<tr>
536
		<td>
537
<?php
538
		$tab_array = array();
539
		$tab_array[0] = array(gettext("Config History"), false, "diag_confbak.php");
540
		$tab_array[1] = array(gettext("Backup/Restore"), true, "diag_backup.php");
541
		display_top_tabs($tab_array);
542
?>
543
		</td>
544
	</tr>
545
	<tr>
546
		<td>
547
			<div id="mainarea">
548
			<table class="tabcont" align="center" width="100%" border="0" cellpadding="6" cellspacing="0">
549
				<tr>
550
					<td colspan="2" class="listtopic"><?=gettext("Backup configuration"); ?></td>
551
				</tr>
552
				<tr>
553
					<td width="22%" valign="baseline" class="vncell">&nbsp;</td>
554
					<td width="78%" class="vtable">
555
						<p><?=gettext("Click this button to download the system configuration in XML format."); ?><br /><br /> <?=gettext("Backup area:"); ?> <?php spit_out_select_items("backuparea", false); ?></p>
556
						<table>
557
							<tr>
558
								<td>
559
									<input name="nopackages" type="checkbox" class="formcheckbox" id="nopackages">
560
								</td>
561
								<td>
562
									<span class="vexpl"><?=gettext("Do not backup package information."); ?></span>
563
								</td>
564
							</tr>
565
						</table>
566
						<table>
567
							<tr>
568
								<td>
569
									<input name="encrypt" type="checkbox" class="formcheckbox" id="nopackages" onClick="encrypt_change()">
570
								</td>
571
								<td>
572
									<span class="vexpl"><?=gettext("Encrypt this configuration file."); ?></span>
573
								</td>
574
							</tr>
575
							<tr>
576
								<td>
577
									<input name="donotbackuprrd" type="checkbox" class="formcheckbox" id="dotnotbackuprrd" checked>
578
								</td>
579
								<td>
580
									<span class="vexpl"><?=gettext("Do not backup RRD data (NOTE: RRD Data can consume 4+ megabytes of config.xml space!)"); ?></span>
581
								</td>
582
							</tr>
583
						</table>
584
						<table id="encrypt_opts">
585
							<tr>
586
								<td>
587
									<span class="vexpl"><?=gettext("Password"); ?> :</span>
588
								</td>
589
								<td>
590
									<input name="encrypt_password" type="password" class="formfld pwd" size="20" value="" />
591
								</td>
592
							</tr>
593
							<tr>
594
								<td>
595
									<span class="vexpl"><?=gettext("confirm"); ?> :</span>
596
								</td>
597
								<td>
598
									<input name="encrypt_passconf" type="password" class="formfld pwd" size="20" value="" />
599
								</td>
600
							</tr>
601
						</table>
602
						<p><input name="Submit" type="submit" class="formbtn" id="download" value="<?=gettext("Download configuration"); ?>"></p>
603
					</td>
604
				</tr>
605
				<tr>
606
					<td colspan="2" class="list" height="12">&nbsp;</td>
607
                </tr>
608
                <tr>
609
					<td colspan="2" class="listtopic"><?=gettext("Restore configuration"); ?></td>
610
				</tr>
611
				<tr>
612
					<td width="22%" valign="baseline" class="vncell">&nbsp;</td>
613
					<td width="78%" class="vtable">
614
						<?=gettext("Open a"); ?> <?=$g['[product_name']?> <?=gettext("configuration XML file and click the button below to restore the configuration."); ?> <br /><br /> <?=gettext("Restore area:"); ?> <?php spit_out_select_items("restorearea", true); ?>
615
						<p><input name="conffile" type="file" class="formfld unknown" id="conffile" size="40"></p>
616
						<table>
617
							<tr>
618
								<td>
619
									<input name="decrypt" type="checkbox" class="formcheckbox" id="nopackages" onClick="decrypt_change()">
620
								</td>
621
								<td>
622
									<span class="vexpl"><?=gettext("Configuration file is encrypted."); ?></span>
623
								</td>
624
							</tr>
625
						</table>
626
						<table id="decrypt_opts">
627
							<tr>
628
								<td>
629
									<span class="vexpl"><?=gettext("Password :"); ?></span>
630
								</td>
631
								<td>
632
									<input name="decrypt_password" type="password" class="formfld pwd" size="20" value="" />
633
								</td>
634
							</tr>
635
							<tr>
636
								<td>
637
									<span class="vexpl"><?=gettext("confirm :"); ?></span>
638
								</td>
639
								<td>
640
									<input name="decrypt_passconf" type="password" class="formfld pwd" size="20" value="" />
641
								</td>
642
							</tr>
643
						</table>
644
						<p><input name="Submit" type="submit" class="formbtn" id="restore" value="<?=gettext("Restore configuration"); ?>"></p>
645
                      	<p><strong><span class="red"><?=gettext("Note"); ?>:</span></strong><br /><?=gettext("The firewall will reboot after restoring the configuration."); ?><br /></p>
646
					</td>
647
				</tr>
648
				<?php if($config['installedpackages']['package'] != "") { ?>
649
				<tr>
650
					<td colspan="2" class="list" height="12">&nbsp;</td>
651
				</tr>
652
				<tr>
653
					<td colspan="2" class="listtopic"><?=gettext("Reinstall packages"); ?></td>
654
				</tr>
655
				<tr>
656
					<td width="22%" valign="baseline" class="vncell">&nbsp;</td>
657
					<td width="78%" class="vtable">
658
						<p><?=gettext("Click this button to reinstall all system packages.  This may take a while."); ?> <br /><br />
659
		  				<input name="Submit" type="submit" class="formbtn" id="reinstallpackages" value="<?=gettext("Reinstall packages"); ?>">
660
					</td>
661
				</tr>
662
				<?php } ?>
663
			</table>
664
			</div>
665
		</td>
666
	</tr>
667
</table>
668
</form>
669

    
670
<script language="JavaScript">
671
<!--
672
encrypt_change();
673
decrypt_change();
674
//-->
675
</script>
676

    
677
<?php include("fend.inc"); ?>
678
</body>
679
</html>
680
<?php
681

    
682
if (is_subsystem_dirty('restore'))
683
	system_reboot();
684

    
685
?>
(6-6/222)