Project

General

Profile

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