Project

General

Profile

Download (23.3 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("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}\" id=\"{$aread}\" ";
125
	if ($area == "backuparea")
126
		$select .= " onChange=backuparea_change(this)";
127
	$select .= " >\n";
128
	$select .= "<option VALUE=\"\">ALL</option>";
129

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

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

    
142
}
143

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

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

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

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

    
170
	if ($mode) {
171

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

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

    
181
			if (!$input_errors) {
182

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

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

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

    
213
				//unlock($lockbckp);
214

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

    
220
				/* 
221
				 *  Backup RRD Data
222
				 */
223
				if(!$_POST['donotbackuprrd']) {
224
					$data = str_replace("</pfsense>", "\t<rrddata>", $data);
225
					$rrd_files_var_db_rrd = split("\n",`cd /var/db/rrd && ls *.rrd`);
226
					foreach($rrd_files_var_db_rrd as $rrd) {
227
						if($rrd) {
228
							$rrd_data = file_get_contents("{$g['vardb_path']}/rrd/{$rrd}");
229
							if($rrd_data) {
230
								$data .= "\t\t<rrddatafile>\n";
231
								$data .= "\t\t\t<filename>{$rrd}</filename>\n";
232
								$data .= "\t\t\t<data>" . base64_encode($rrd_data) . "</data>\n";
233
								$data .= "\t\t</rrddatafile>\n";
234
							}
235
						}
236
					}
237
					$data .= "\t</rrddata>\n";
238
					$data .= "</pfsense>\n";
239
				}
240
				
241
				$size = strlen($data);
242
				header("Content-Type: application/octet-stream");
243
				header("Content-Disposition: attachment; filename={$name}");
244
				header("Content-Length: $size");
245
				if (isset($_SERVER['HTTPS'])) {
246
					header('Pragma: ');
247
					header('Cache-Control: ');
248
				} else {
249
					header("Pragma: private");
250
					header("Cache-Control: private, must-revalidate");
251
				}
252
				echo $data;
253

    
254
				exit;
255
			}
256
		}
257

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

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

    
267
			if (!$input_errors) {
268

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

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

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

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

    
454
		if ($mode == "reinstallpackages") {
455

    
456
			header("Location: pkg_mgr_install.php?mode=reinstallall");
457
			exit;
458
                } else if ($mode == "restore_ver") {
459
			$input_errors[] = "XXX - this feature may hose your config (do NOT backrev configs!) - billm";
460
			if ($ver2restore <> "") {
461
				$conf_file = "{$g['cf_conf_path']}/bak/config-" . strtotime($ver2restore) . ".xml";
462
				if (config_install($conf_file) == 0) {
463
						mark_subsystem_dirty("restore");
464
                        } else {
465
                        	$input_errors[] = "The configuration could not be restored.";
466
                        }
467
                } else {
468
                        $input_errors[] = "No version selected.";
469
                }
470
		}
471
	}
472
}
473

    
474
$id = rand() . '.' . time();
475

    
476
$mth = ini_get('upload_progress_meter.store_method');
477
$dir = ini_get('upload_progress_meter.file.filename_template');
478

    
479
$pgtitle = array("Diagnostics","Backup/restore");
480
include("head.inc");
481

    
482
?>
483

    
484
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
485
<?php include("fbegin.inc"); ?>
486
<script language="JavaScript">
487
<!--
488

    
489
function encrypt_change() {
490

    
491
	if (!document.iform.encrypt.checked)
492
		document.getElementById("encrypt_opts").style.display="none";
493
	else
494
		document.getElementById("encrypt_opts").style.display="";
495
}
496

    
497
function decrypt_change() {
498

    
499
	if (!document.iform.decrypt.checked)
500
		document.getElementById("decrypt_opts").style.display="none";
501
	else
502
		document.getElementById("decrypt_opts").style.display="";
503
}
504

    
505
function backuparea_change(obj) {
506

    
507
        if (obj.value == "")
508
                document.getElementById("dotnotbackuprrd").checked = false;
509
        else
510
                document.getElementById("dotnotbackuprrd").checked = true;
511
}
512
//-->
513
</script>
514

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

    
660
<script language="JavaScript">
661
<!--
662
encrypt_change();
663
decrypt_change();
664
//-->
665
</script>
666

    
667
<?php include("fend.inc"); ?>
668
</body>
669
</html>
670
<?php
671

    
672
if (is_subsystem_dirty('restore'))
673
	exec("/etc/rc.reboot");
674

    
675
?>
(6-6/217)