Project

General

Profile

Download (5.53 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
#!/usr/local/bin/php
2 8ccc8f1a Scott Ullrich
<?php
3 5b237745 Scott Ullrich
/*
4
	diag_backup.php
5 07bd3f83 Scott Ullrich
	part of m0n0wall (http://m0n0.ch/wall)
6 8ccc8f1a Scott Ullrich
7 5b237745 Scott Ullrich
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9 8ccc8f1a Scott Ullrich
10 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12 8ccc8f1a Scott Ullrich
13 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15 8ccc8f1a Scott Ullrich
16 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19 8ccc8f1a Scott Ullrich
20 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
/* omit no-cache headers because it confuses IE with file downloads */
33
$omit_nocacheheaders = true;
34 8ccc8f1a Scott Ullrich
require("guiconfig.inc");
35 5b237745 Scott Ullrich
36
if ($_POST) {
37
38
	unset($input_errors);
39 8ccc8f1a Scott Ullrich
40 5b237745 Scott Ullrich
	if (stristr($_POST['Submit'], "Restore"))
41
		$mode = "restore";
42 8ccc8f1a Scott Ullrich
	else if (stristr($_POST['Submit'], "Reinstall"))
43
		$mode = "reinstallpackages";
44 5b237745 Scott Ullrich
	else if (stristr($_POST['Submit'], "Download"))
45
		$mode = "download";
46 8ccc8f1a Scott Ullrich
47 5b237745 Scott Ullrich
	if ($mode) {
48
		if ($mode == "download") {
49
			config_lock();
50 8ccc8f1a Scott Ullrich
51
			$fn = "config-" . $config['system']['hostname'] . "." .
52 5b237745 Scott Ullrich
				$config['system']['domain'] . "-" . date("YmdHis") . ".xml";
53 8ccc8f1a Scott Ullrich
54 5b237745 Scott Ullrich
			$fs = filesize($g['conf_path'] . "/config.xml");
55 8ccc8f1a Scott Ullrich
			header("Content-Type: application/octet-stream");
56 5b237745 Scott Ullrich
			header("Content-Disposition: attachment; filename=$fn");
57
			header("Content-Length: $fs");
58
			readfile($g['conf_path'] . "/config.xml");
59
			config_unlock();
60
			exit;
61
		} else if ($mode == "restore") {
62
			if (is_uploaded_file($_FILES['conffile']['tmp_name'])) {
63
				if (config_install($_FILES['conffile']['tmp_name']) == 0) {
64
					system_reboot();
65
					$savemsg = "The configuration has been restored. The firewall is now rebooting.";
66
				} else {
67
					$input_errors[] = "The configuration could not be restored.";
68
				}
69
			} else {
70
				$input_errors[] = "The configuration could not be restored (file upload error).";
71
			}
72 8ccc8f1a Scott Ullrich
		} else if ($mode == "reinstallpackages") {
73
			header("Location: pkg_mgr_install.php?mode=reinstallall");
74
			exit;
75 5b237745 Scott Ullrich
		}
76
	}
77
}
78
?>
79
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
80
<html>
81
<head>
82
<title><?=gentitle("Diagnostics: Backup/restore");?></title>
83
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
84
<link href="gui.css" rel="stylesheet" type="text/css">
85
</head>
86
87
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
88
<?php include("fbegin.inc"); ?>
89
      <p class="pgtitle">Diagnostics: Backup/restore</p>
90
            <form action="diag_backup.php" method="post" enctype="multipart/form-data">
91
            <?php if ($input_errors) print_input_errors($input_errors); ?>
92
            <?php if ($savemsg) print_info_box($savemsg); ?>
93 07bd3f83 Scott Ullrich
              <table width="100%" border="0" cellspacing="0" cellpadding="6">
94 8ccc8f1a Scott Ullrich
                <tr>
95 5b237745 Scott Ullrich
                  <td colspan="2" class="listtopic">Backup configuration</td>
96
                </tr>
97 8ccc8f1a Scott Ullrich
                <tr>
98 07bd3f83 Scott Ullrich
                  <td width="22%" valign="baseline" class="vncell">&nbsp;</td>
99 8ccc8f1a Scott Ullrich
                  <td width="78%" class="vtable">
100
                    <p> Click this button to download the system configuration
101 5b237745 Scott Ullrich
                      in XML format.<br>
102
                      <br>
103 07bd3f83 Scott Ullrich
                      <input name="Submit" type="submit" class="formbtn" id="download" value="Download configuration"></td>
104
                </tr>
105 8ccc8f1a Scott Ullrich
                <tr>
106 07bd3f83 Scott Ullrich
                  <td colspan="2" class="list" height="12"></td>
107 5b237745 Scott Ullrich
                </tr>
108 8ccc8f1a Scott Ullrich
                <tr>
109 5b237745 Scott Ullrich
                  <td colspan="2" class="listtopic">Restore configuration</td>
110
                </tr>
111 8ccc8f1a Scott Ullrich
                <tr>
112 07bd3f83 Scott Ullrich
                  <td width="22%" valign="baseline" class="vncell">&nbsp;</td>
113 8ccc8f1a Scott Ullrich
                  <td width="78%" class="vtable">
114
                    Open a pfSense configuration XML file and click the button
115 5b237745 Scott Ullrich
                      below to restore the configuration.<br>
116
                      <br>
117
                      <strong><span class="red">Note:</span></strong><br>
118
                      The firewall will reboot after restoring the configuration.<br>
119
                      <br>
120
                      <input name="conffile" type="file" class="formfld" id="conffile" size="40">
121
                      <br>
122
                      <br>
123
                      <input name="Submit" type="submit" class="formbtn" id="restore" value="Restore configuration">
124 07bd3f83 Scott Ullrich
                  </td>
125 5b237745 Scott Ullrich
                </tr>
126 8ccc8f1a Scott Ullrich
		<tr>
127
		 <td colspan="2">&nbsp;</td>
128
		</tr>
129
		<tr>
130
		 <td colspan="2" class="listtopic">Reinstall packages</td>
131
		</tr>
132
		<tr>
133
		  <td width="22%" valign="baseline" class="vncell">&nbsp;</td>
134
		  <td width="78%" class="vtable">
135
		  <p> Click this button to reinstall all system packages.  This may wake a while.<br>
136
		  <br>
137
		  <input name="Submit" type="submit" class="formbtn" id="reinstallpackages" value="Reinstall packages"></td>
138
		</tr>
139 5b237745 Scott Ullrich
              </table>
140
            </form>
141
<?php include("fend.inc"); ?>
142
</body>
143
</html>