1 |
8ccc8f1a
|
Scott Ullrich
|
<?php
|
2 |
5b237745
|
Scott Ullrich
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* diag_backup.php
|
4 |
9da2cf1c
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11 |
|
|
* All rights reserved.
|
12 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
14 |
|
|
* you may not use this file except in compliance with the License.
|
15 |
|
|
* You may obtain a copy of the License at
|
16 |
fd9ebcd5
|
Stephen Beaver
|
*
|
17 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
20 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
21 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
22 |
|
|
* See the License for the specific language governing permissions and
|
23 |
|
|
* limitations under the License.
|
24 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
25 |
5b237745
|
Scott Ullrich
|
|
26 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
27 |
5d916fc7
|
Stephen Beaver
|
##|*IDENT=page-diagnostics-backup-restore
|
28 |
0f298138
|
k-paulius
|
##|*NAME=Diagnostics: Backup & Restore
|
29 |
|
|
##|*DESCR=Allow access to the 'Diagnostics: Backup & Restore' page.
|
30 |
6b07c15a
|
Matthew Grooms
|
##|*MATCH=diag_backup.php*
|
31 |
|
|
##|-PRIV
|
32 |
|
|
|
33 |
47d11b79
|
Mark Crane
|
/* Allow additional execution time 0 = no limit. */
|
34 |
3420028c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
35 |
|
|
ini_set('max_input_time', '0');
|
36 |
47d11b79
|
Mark Crane
|
|
37 |
5b237745
|
Scott Ullrich
|
/* omit no-cache headers because it confuses IE with file downloads */
|
38 |
|
|
$omit_nocacheheaders = true;
|
39 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
40 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
41 |
|
|
require_once("filter.inc");
|
42 |
|
|
require_once("shaper.inc");
|
43 |
5b237745
|
Scott Ullrich
|
|
44 |
8bdb6879
|
Darren Embry
|
$rrddbpath = "/var/db/rrd";
|
45 |
|
|
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
|
46 |
|
|
|
47 |
|
|
function rrd_data_xml() {
|
48 |
|
|
global $rrddbpath;
|
49 |
|
|
global $rrdtool;
|
50 |
73ed069b
|
Renato Botelho
|
|
51 |
8bdb6879
|
Darren Embry
|
$result = "\t<rrddata>\n";
|
52 |
|
|
$rrd_files = glob("{$rrddbpath}/*.rrd");
|
53 |
|
|
$xml_files = array();
|
54 |
|
|
foreach ($rrd_files as $rrd_file) {
|
55 |
|
|
$basename = basename($rrd_file);
|
56 |
|
|
$xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file);
|
57 |
|
|
exec("$rrdtool dump '{$rrd_file}' '{$xml_file}'");
|
58 |
|
|
$xml_data = file_get_contents($xml_file);
|
59 |
|
|
unlink($xml_file);
|
60 |
|
|
if ($xml_data !== false) {
|
61 |
|
|
$result .= "\t\t<rrddatafile>\n";
|
62 |
|
|
$result .= "\t\t\t<filename>{$basename}</filename>\n";
|
63 |
|
|
$result .= "\t\t\t<xmldata>" . base64_encode(gzdeflate($xml_data)) . "</xmldata>\n";
|
64 |
|
|
$result .= "\t\t</rrddatafile>\n";
|
65 |
|
|
}
|
66 |
|
|
}
|
67 |
|
|
$result .= "\t</rrddata>\n";
|
68 |
|
|
return $result;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
754b75d0
|
Darren Embry
|
function restore_rrddata() {
|
72 |
7eead1fc
|
Darren Embry
|
global $config, $g, $rrdtool, $input_errors;
|
73 |
5f601060
|
Phil Davis
|
foreach ($config['rrddata']['rrddatafile'] as $rrd) {
|
74 |
754b75d0
|
Darren Embry
|
if ($rrd['xmldata']) {
|
75 |
|
|
$rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}";
|
76 |
|
|
$xml_file = preg_replace('/\.rrd$/', ".xml", $rrd_file);
|
77 |
08877746
|
Darren Embry
|
if (file_put_contents($xml_file, gzinflate(base64_decode($rrd['xmldata']))) === false) {
|
78 |
ff30e319
|
bruno
|
log_error(sprintf(gettext("Cannot write %s"), $xml_file));
|
79 |
08877746
|
Darren Embry
|
continue;
|
80 |
|
|
}
|
81 |
|
|
$output = array();
|
82 |
|
|
$status = null;
|
83 |
|
|
exec("$rrdtool restore -f '{$xml_file}' '{$rrd_file}'", $output, $status);
|
84 |
|
|
if ($status) {
|
85 |
f757431d
|
Darren Embry
|
log_error("rrdtool restore -f '{$xml_file}' '{$rrd_file}' failed returning {$status}.");
|
86 |
08877746
|
Darren Embry
|
continue;
|
87 |
|
|
}
|
88 |
754b75d0
|
Darren Embry
|
unlink($xml_file);
|
89 |
5f601060
|
Phil Davis
|
} else if ($rrd['data']) {
|
90 |
7eead1fc
|
Darren Embry
|
$rrd_file = "{$g['vardb_path']}/rrd/{$rrd['filename']}";
|
91 |
|
|
$rrd_fd = fopen($rrd_file, "w");
|
92 |
08877746
|
Darren Embry
|
if (!$rrd_fd) {
|
93 |
ff30e319
|
bruno
|
log_error(sprintf(gettext("Cannot write %s"), $rrd_file));
|
94 |
08877746
|
Darren Embry
|
continue;
|
95 |
|
|
}
|
96 |
754b75d0
|
Darren Embry
|
$data = base64_decode($rrd['data']);
|
97 |
|
|
/* Try to decompress the data. */
|
98 |
|
|
$dcomp = @gzinflate($data);
|
99 |
|
|
if ($dcomp) {
|
100 |
|
|
/* If the decompression worked, write the decompressed data */
|
101 |
08877746
|
Darren Embry
|
if (fwrite($rrd_fd, $dcomp) === false) {
|
102 |
ff30e319
|
bruno
|
log_error(sprintf(gettext("fwrite %s failed"), $rrd_file));
|
103 |
08877746
|
Darren Embry
|
continue;
|
104 |
|
|
}
|
105 |
754b75d0
|
Darren Embry
|
} else {
|
106 |
|
|
/* If the decompression failed, it wasn't compressed, so write raw data */
|
107 |
08877746
|
Darren Embry
|
if (fwrite($rrd_fd, $data) === false) {
|
108 |
ff30e319
|
bruno
|
log_error(sprintf(gettext("fwrite %s failed"), $rrd_file));
|
109 |
08877746
|
Darren Embry
|
continue;
|
110 |
|
|
}
|
111 |
|
|
}
|
112 |
|
|
if (fclose($rrd_fd) === false) {
|
113 |
ff30e319
|
bruno
|
log_error(sprintf(gettext("fclose %s failed"), $rrd_file));
|
114 |
08877746
|
Darren Embry
|
continue;
|
115 |
754b75d0
|
Darren Embry
|
}
|
116 |
|
|
}
|
117 |
|
|
}
|
118 |
|
|
}
|
119 |
|
|
|
120 |
3420028c
|
Scott Ullrich
|
function add_base_packages_menu_items() {
|
121 |
|
|
global $g, $config;
|
122 |
52c7f0d4
|
jim-p
|
$base_packages = explode(",", $g['base_packages']);
|
123 |
3420028c
|
Scott Ullrich
|
$modified_config = false;
|
124 |
5f601060
|
Phil Davis
|
foreach ($base_packages as $bp) {
|
125 |
da17d77e
|
Ermal Lu?i
|
$basepkg_path = "/usr/local/pkg/{$bp}";
|
126 |
a250f179
|
Renato Botelho
|
$tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION);
|
127 |
5f601060
|
Phil Davis
|
if ($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) {
|
128 |
da17d77e
|
Ermal Lu?i
|
$pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui");
|
129 |
5f601060
|
Phil Davis
|
if ($pkg_config['menu'] != "") {
|
130 |
|
|
if (is_array($pkg_config['menu'])) {
|
131 |
|
|
foreach ($pkg_config['menu'] as $menu) {
|
132 |
|
|
if (is_array($config['installedpackages']['menu'])) {
|
133 |
|
|
foreach ($config['installedpackages']['menu'] as $amenu) {
|
134 |
|
|
if ($amenu['name'] == $menu['name']) {
|
135 |
3420028c
|
Scott Ullrich
|
continue;
|
136 |
5f601060
|
Phil Davis
|
}
|
137 |
|
|
}
|
138 |
|
|
}
|
139 |
3420028c
|
Scott Ullrich
|
$config['installedpackages']['menu'][] = $menu;
|
140 |
|
|
$modified_config = true;
|
141 |
|
|
}
|
142 |
|
|
}
|
143 |
|
|
}
|
144 |
|
|
}
|
145 |
|
|
}
|
146 |
5f601060
|
Phil Davis
|
if ($modified_config) {
|
147 |
f3ceee6e
|
Vinicius Coque
|
write_config(gettext("Restored base_package menus after configuration restore."));
|
148 |
3420028c
|
Scott Ullrich
|
$config = parse_config(true);
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
|
|
|
152 |
645ec835
|
Scott Ullrich
|
function remove_bad_chars($string) {
|
153 |
699737d9
|
Phil Davis
|
return preg_replace('/[^a-z_0-9]/i', '', $string);
|
154 |
645ec835
|
Scott Ullrich
|
}
|
155 |
|
|
|
156 |
b3277798
|
Scott Ullrich
|
function check_and_returnif_section_exists($section) {
|
157 |
|
|
global $config;
|
158 |
5f601060
|
Phil Davis
|
if (is_array($config[$section])) {
|
159 |
b3277798
|
Scott Ullrich
|
return true;
|
160 |
5f601060
|
Phil Davis
|
}
|
161 |
b3277798
|
Scott Ullrich
|
return false;
|
162 |
|
|
}
|
163 |
|
|
|
164 |
da17d77e
|
Ermal Lu?i
|
if ($_POST['apply']) {
|
165 |
73ed069b
|
Renato Botelho
|
ob_flush();
|
166 |
|
|
flush();
|
167 |
c9a19238
|
Darren Embry
|
clear_subsystem_dirty("restore");
|
168 |
73ed069b
|
Renato Botelho
|
exit;
|
169 |
da17d77e
|
Ermal Lu?i
|
}
|
170 |
|
|
|
171 |
5b237745
|
Scott Ullrich
|
if ($_POST) {
|
172 |
|
|
unset($input_errors);
|
173 |
5f601060
|
Phil Davis
|
if (stristr($_POST['Submit'], gettext("Restore configuration"))) {
|
174 |
5b237745
|
Scott Ullrich
|
$mode = "restore";
|
175 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Reinstall"))) {
|
176 |
8ccc8f1a
|
Scott Ullrich
|
$mode = "reinstallpackages";
|
177 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Clear Package Lock"))) {
|
178 |
039cb920
|
jim-p
|
$mode = "clearpackagelock";
|
179 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Download"))) {
|
180 |
5b237745
|
Scott Ullrich
|
$mode = "download";
|
181 |
5f601060
|
Phil Davis
|
} else if (stristr($_POST['Submit'], gettext("Restore version"))) {
|
182 |
7cf03119
|
Bill Marquette
|
$mode = "restore_ver";
|
183 |
5f601060
|
Phil Davis
|
}
|
184 |
|
|
if ($_POST["nopackages"] <> "") {
|
185 |
528cad39
|
Colin Smith
|
$options = "nopackages";
|
186 |
5f601060
|
Phil Davis
|
}
|
187 |
|
|
if ($_POST["ver"] <> "") {
|
188 |
7cf03119
|
Bill Marquette
|
$ver2restore = $_POST["ver"];
|
189 |
5f601060
|
Phil Davis
|
}
|
190 |
5b237745
|
Scott Ullrich
|
if ($mode) {
|
191 |
|
|
if ($mode == "download") {
|
192 |
8ff5ffcc
|
Matthew Grooms
|
if ($_POST['encrypt']) {
|
193 |
76d6d925
|
Stephen Beaver
|
if (!$_POST['encrypt_password']) {
|
194 |
89854d71
|
NewEraCracker
|
$input_errors[] = gettext("A password for encryption must be supplied and confirmed.");
|
195 |
5f601060
|
Phil Davis
|
}
|
196 |
528cad39
|
Colin Smith
|
}
|
197 |
73ed069b
|
Renato Botelho
|
|
198 |
8ff5ffcc
|
Matthew Grooms
|
if (!$input_errors) {
|
199 |
73ed069b
|
Renato Botelho
|
|
200 |
07b1797b
|
sullrich
|
//$lockbckp = lock('config');
|
201 |
73ed069b
|
Renato Botelho
|
|
202 |
8ff5ffcc
|
Matthew Grooms
|
$host = "{$config['system']['hostname']}.{$config['system']['domain']}";
|
203 |
|
|
$name = "config-{$host}-".date("YmdHis").".xml";
|
204 |
|
|
$data = "";
|
205 |
73ed069b
|
Renato Botelho
|
|
206 |
5f601060
|
Phil Davis
|
if ($options == "nopackages") {
|
207 |
|
|
if (!$_POST['backuparea']) {
|
208 |
4195c967
|
sullrich
|
/* backup entire configuration */
|
209 |
|
|
$data = file_get_contents("{$g['conf_path']}/config.xml");
|
210 |
|
|
} else {
|
211 |
|
|
/* backup specific area of configuration */
|
212 |
|
|
$data = backup_config_section($_POST['backuparea']);
|
213 |
|
|
$name = "{$_POST['backuparea']}-{$name}";
|
214 |
|
|
}
|
215 |
da17d77e
|
Ermal Lu?i
|
$sfn = "{$g['tmp_path']}/config.xml.nopkg";
|
216 |
4195c967
|
sullrich
|
file_put_contents($sfn, $data);
|
217 |
|
|
exec("sed '/<installedpackages>/,/<\/installedpackages>/d' {$sfn} > {$sfn}-new");
|
218 |
a250f179
|
Renato Botelho
|
$data = file_get_contents($sfn . "-new");
|
219 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
220 |
5f601060
|
Phil Davis
|
if (!$_POST['backuparea']) {
|
221 |
8ff5ffcc
|
Matthew Grooms
|
/* backup entire configuration */
|
222 |
|
|
$data = file_get_contents("{$g['conf_path']}/config.xml");
|
223 |
7eead1fc
|
Darren Embry
|
} else if ($_POST['backuparea'] === "rrddata") {
|
224 |
|
|
$data = rrd_data_xml();
|
225 |
|
|
$name = "{$_POST['backuparea']}-{$name}";
|
226 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
227 |
|
|
/* backup specific area of configuration */
|
228 |
|
|
$data = backup_config_section($_POST['backuparea']);
|
229 |
|
|
$name = "{$_POST['backuparea']}-{$name}";
|
230 |
|
|
}
|
231 |
181462b5
|
Scott Ullrich
|
}
|
232 |
73ed069b
|
Renato Botelho
|
|
233 |
07b1797b
|
sullrich
|
//unlock($lockbckp);
|
234 |
73ed069b
|
Renato Botelho
|
|
235 |
a250f179
|
Renato Botelho
|
/*
|
236 |
0e834fc5
|
Stephen Beaver
|
* Backup RRD Data
|
237 |
1390b049
|
Scott Ullrich
|
*/
|
238 |
7eead1fc
|
Darren Embry
|
if ($_POST['backuparea'] !== "rrddata" && !$_POST['donotbackuprrd']) {
|
239 |
8bdb6879
|
Darren Embry
|
$rrd_data_xml = rrd_data_xml();
|
240 |
|
|
$closing_tag = "</" . $g['xml_rootobj'] . ">";
|
241 |
|
|
$data = str_replace($closing_tag, $rrd_data_xml . $closing_tag, $data);
|
242 |
1390b049
|
Scott Ullrich
|
}
|
243 |
73ed069b
|
Renato Botelho
|
|
244 |
4cfd2390
|
Renato Botelho
|
if ($_POST['encrypt']) {
|
245 |
|
|
$data = encrypt_data($data, $_POST['encrypt_password']);
|
246 |
|
|
tagfile_reformat($data, $data, "config.xml");
|
247 |
|
|
}
|
248 |
|
|
|
249 |
8ff5ffcc
|
Matthew Grooms
|
$size = strlen($data);
|
250 |
|
|
header("Content-Type: application/octet-stream");
|
251 |
|
|
header("Content-Disposition: attachment; filename={$name}");
|
252 |
a8c35980
|
Scott Ullrich
|
header("Content-Length: $size");
|
253 |
e77ea573
|
jim-p
|
if (isset($_SERVER['HTTPS'])) {
|
254 |
|
|
header('Pragma: ');
|
255 |
|
|
header('Cache-Control: ');
|
256 |
|
|
} else {
|
257 |
|
|
header("Pragma: private");
|
258 |
|
|
header("Cache-Control: private, must-revalidate");
|
259 |
|
|
}
|
260 |
8ff5ffcc
|
Matthew Grooms
|
echo $data;
|
261 |
73ed069b
|
Renato Botelho
|
|
262 |
8ff5ffcc
|
Matthew Grooms
|
exit;
|
263 |
|
|
}
|
264 |
|
|
}
|
265 |
73ed069b
|
Renato Botelho
|
|
266 |
8ff5ffcc
|
Matthew Grooms
|
if ($mode == "restore") {
|
267 |
|
|
if ($_POST['decrypt']) {
|
268 |
76d6d925
|
Stephen Beaver
|
if (!$_POST['decrypt_password']) {
|
269 |
89854d71
|
NewEraCracker
|
$input_errors[] = gettext("A password for decryption must be supplied and confirmed.");
|
270 |
5f601060
|
Phil Davis
|
}
|
271 |
8ff5ffcc
|
Matthew Grooms
|
}
|
272 |
73ed069b
|
Renato Botelho
|
|
273 |
8ff5ffcc
|
Matthew Grooms
|
if (!$input_errors) {
|
274 |
|
|
if (is_uploaded_file($_FILES['conffile']['tmp_name'])) {
|
275 |
73ed069b
|
Renato Botelho
|
|
276 |
8ff5ffcc
|
Matthew Grooms
|
/* read the file contents */
|
277 |
|
|
$data = file_get_contents($_FILES['conffile']['tmp_name']);
|
278 |
5f601060
|
Phil Davis
|
if (!$data) {
|
279 |
dae4c487
|
Carlos Eduardo Ramos
|
log_error(sprintf(gettext("Warning, could not read file %s"), $_FILES['conffile']['tmp_name']));
|
280 |
8ff5ffcc
|
Matthew Grooms
|
return 1;
|
281 |
9fd18b1f
|
Scott Ullrich
|
}
|
282 |
73ed069b
|
Renato Botelho
|
|
283 |
8ff5ffcc
|
Matthew Grooms
|
if ($_POST['decrypt']) {
|
284 |
|
|
if (!tagfile_deformat($data, $data, "config.xml")) {
|
285 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The uploaded file does not appear to contain an encrypted pfsense configuration.");
|
286 |
8ff5ffcc
|
Matthew Grooms
|
return 1;
|
287 |
|
|
}
|
288 |
|
|
$data = decrypt_data($data, $_POST['decrypt_password']);
|
289 |
|
|
}
|
290 |
73ed069b
|
Renato Botelho
|
|
291 |
5f601060
|
Phil Davis
|
if (stristr($data, "<m0n0wall>")) {
|
292 |
205da5a0
|
Neriberto C.Prado
|
log_error(gettext("Upgrading m0n0wall configuration to pfsense."));
|
293 |
8ff5ffcc
|
Matthew Grooms
|
/* m0n0wall was found in config. convert it. */
|
294 |
|
|
$data = str_replace("m0n0wall", "pfsense", $data);
|
295 |
|
|
$m0n0wall_upgrade = true;
|
296 |
|
|
}
|
297 |
5f601060
|
Phil Davis
|
if ($_POST['restorearea']) {
|
298 |
8ff5ffcc
|
Matthew Grooms
|
/* restore a specific area of the configuration */
|
299 |
5f601060
|
Phil Davis
|
if (!stristr($data, "<" . $_POST['restorearea'] . ">")) {
|
300 |
b6078bed
|
NOYB
|
$input_errors[] = gettext("An area to restore was selected but the correct xml tag could not be located.");
|
301 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
302 |
8dcca9b5
|
Darren Embry
|
if (!restore_config_section($_POST['restorearea'], $data)) {
|
303 |
b6078bed
|
NOYB
|
$input_errors[] = gettext("An area to restore was selected but the correct xml tag could not be located.");
|
304 |
8dcca9b5
|
Darren Embry
|
} else {
|
305 |
|
|
if ($config['rrddata']) {
|
306 |
|
|
restore_rrddata();
|
307 |
|
|
unset($config['rrddata']);
|
308 |
|
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
309 |
|
|
write_config();
|
310 |
|
|
add_base_packages_menu_items();
|
311 |
|
|
convert_config();
|
312 |
|
|
}
|
313 |
|
|
filter_configure();
|
314 |
b6078bed
|
NOYB
|
$savemsg = gettext("The configuration area has been restored. The firewall may need to be rebooted.");
|
315 |
7eead1fc
|
Darren Embry
|
}
|
316 |
8ff5ffcc
|
Matthew Grooms
|
}
|
317 |
181462b5
|
Scott Ullrich
|
} else {
|
318 |
5f601060
|
Phil Davis
|
if (!stristr($data, "<" . $g['xml_rootobj'] . ">")) {
|
319 |
b6078bed
|
NOYB
|
$input_errors[] = sprintf(gettext("A full configuration restore was selected but a %s tag could not be located."), $g['xml_rootobj']);
|
320 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
321 |
|
|
/* restore the entire configuration */
|
322 |
|
|
file_put_contents($_FILES['conffile']['tmp_name'], $data);
|
323 |
|
|
if (config_install($_FILES['conffile']['tmp_name']) == 0) {
|
324 |
|
|
/* this will be picked up by /index.php */
|
325 |
da17d77e
|
Ermal Lu?i
|
mark_subsystem_dirty("restore");
|
326 |
e6068346
|
Phil Davis
|
touch("/conf/needs_package_sync_after_reboot");
|
327 |
8ff5ffcc
|
Matthew Grooms
|
/* remove cache, we will force a config reboot */
|
328 |
5f601060
|
Phil Davis
|
if (file_exists("{$g['tmp_path']}/config.cache")) {
|
329 |
da17d77e
|
Ermal Lu?i
|
unlink("{$g['tmp_path']}/config.cache");
|
330 |
5f601060
|
Phil Davis
|
}
|
331 |
8ff5ffcc
|
Matthew Grooms
|
$config = parse_config(true);
|
332 |
0174c480
|
Ermal LUÇI
|
if (file_exists("/boot/loader.conf")) {
|
333 |
|
|
$loaderconf = file_get_contents("/boot/loader.conf");
|
334 |
08af94cb
|
Chris Buechler
|
if (strpos($loaderconf, "console=\"comconsole")) {
|
335 |
0174c480
|
Ermal LUÇI
|
$config['system']['enableserial'] = true;
|
336 |
ff30e319
|
bruno
|
write_config(gettext("Restore serial console enabling in configuration."));
|
337 |
0174c480
|
Ermal LUÇI
|
}
|
338 |
5d4b8830
|
Ermal LUÇI
|
unset($loaderconf);
|
339 |
0174c480
|
Ermal LUÇI
|
}
|
340 |
67bc955d
|
Chris Buechler
|
/* extract out rrd items, unset from $config when done */
|
341 |
5f601060
|
Phil Davis
|
if ($config['rrddata']) {
|
342 |
754b75d0
|
Darren Embry
|
restore_rrddata();
|
343 |
a2b8f7b2
|
Scott Ullrich
|
unset($config['rrddata']);
|
344 |
da17d77e
|
Ermal Lu?i
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
345 |
a2b8f7b2
|
Scott Ullrich
|
write_config();
|
346 |
3420028c
|
Scott Ullrich
|
add_base_packages_menu_items();
|
347 |
d442e4e2
|
Scott Ullrich
|
convert_config();
|
348 |
1390b049
|
Scott Ullrich
|
}
|
349 |
5f601060
|
Phil Davis
|
if ($m0n0wall_upgrade == true) {
|
350 |
|
|
if ($config['system']['gateway'] <> "") {
|
351 |
8ff5ffcc
|
Matthew Grooms
|
$config['interfaces']['wan']['gateway'] = $config['system']['gateway'];
|
352 |
5f601060
|
Phil Davis
|
}
|
353 |
8ff5ffcc
|
Matthew Grooms
|
unset($config['shaper']);
|
354 |
|
|
/* optional if list */
|
355 |
|
|
$ifdescrs = get_configured_interface_list(true, true);
|
356 |
|
|
/* remove special characters from interface descriptions */
|
357 |
5f601060
|
Phil Davis
|
if (is_array($ifdescrs)) {
|
358 |
|
|
foreach ($ifdescrs as $iface) {
|
359 |
8ff5ffcc
|
Matthew Grooms
|
$config['interfaces'][$iface]['descr'] = remove_bad_chars($config['interfaces'][$iface]['descr']);
|
360 |
5f601060
|
Phil Davis
|
}
|
361 |
|
|
}
|
362 |
b6db8ea3
|
sullrich
|
/* check for interface names with an alias */
|
363 |
5f601060
|
Phil Davis
|
if (is_array($ifdescrs)) {
|
364 |
|
|
foreach ($ifdescrs as $iface) {
|
365 |
|
|
if (is_alias($config['interfaces'][$iface]['descr'])) {
|
366 |
b6db8ea3
|
sullrich
|
// Firewall rules
|
367 |
|
|
$origname = $config['interfaces'][$iface]['descr'];
|
368 |
6c07db48
|
Phil Davis
|
$newname = $config['interfaces'][$iface]['descr'] . "Alias";
|
369 |
f1ac1733
|
Erik Fonnesbeck
|
update_alias_names_upon_change(array('filter', 'rule'), array('source', 'address'), $newname, $origname);
|
370 |
|
|
update_alias_names_upon_change(array('filter', 'rule'), array('destination', 'address'), $newname, $origname);
|
371 |
b6db8ea3
|
sullrich
|
// NAT Rules
|
372 |
f1ac1733
|
Erik Fonnesbeck
|
update_alias_names_upon_change(array('nat', 'rule'), array('source', 'address'), $newname, $origname);
|
373 |
|
|
update_alias_names_upon_change(array('nat', 'rule'), array('destination', 'address'), $newname, $origname);
|
374 |
|
|
update_alias_names_upon_change(array('nat', 'rule'), array('target'), $newname, $origname);
|
375 |
b6db8ea3
|
sullrich
|
// Alias in an alias
|
376 |
f1ac1733
|
Erik Fonnesbeck
|
update_alias_names_upon_change(array('aliases', 'alias'), array('address'), $newname, $origname);
|
377 |
b6db8ea3
|
sullrich
|
}
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
da17d77e
|
Ermal Lu?i
|
unlink_if_exists("{$g['tmp_path']}/config.cache");
|
381 |
888e7a27
|
Scott Ullrich
|
// Reset configuration version to something low
|
382 |
a250f179
|
Renato Botelho
|
// in order to force the config upgrade code to
|
383 |
888e7a27
|
Scott Ullrich
|
// run through with all steps that are required.
|
384 |
|
|
$config['system']['version'] = "1.0";
|
385 |
798cb31a
|
Scott Ullrich
|
// Deal with descriptions longer than 63 characters
|
386 |
|
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
387 |
5f601060
|
Phil Davis
|
if (count($config['filter']['rule'][$i]['descr']) > 63) {
|
388 |
798cb31a
|
Scott Ullrich
|
$config['filter']['rule'][$i]['descr'] = substr($config['filter']['rule'][$i]['descr'], 0, 63);
|
389 |
5f601060
|
Phil Davis
|
}
|
390 |
798cb31a
|
Scott Ullrich
|
}
|
391 |
|
|
// Move interface from ipsec to enc0
|
392 |
|
|
for ($i = 0; isset($config["filter"]["rule"][$i]); $i++) {
|
393 |
5f601060
|
Phil Davis
|
if ($config['filter']['rule'][$i]['interface'] == "ipsec") {
|
394 |
798cb31a
|
Scott Ullrich
|
$config['filter']['rule'][$i]['interface'] = "enc0";
|
395 |
5f601060
|
Phil Davis
|
}
|
396 |
798cb31a
|
Scott Ullrich
|
}
|
397 |
|
|
// Convert icmp types
|
398 |
|
|
// http://www.openbsd.org/cgi-bin/man.cgi?query=icmp&sektion=4&arch=i386&apropos=0&manpath=OpenBSD+Current
|
399 |
0ce1667b
|
stilez
|
$convert = array('echo' => 'echoreq', 'timest' => 'timereq', 'timestrep' => 'timerep');
|
400 |
|
|
foreach ($config["filter"]["rule"] as $ruleid => &$ruledata) {
|
401 |
|
|
if ($convert[$ruledata['icmptype']]) {
|
402 |
|
|
$ruledata['icmptype'] = $convert[$ruledata['icmptype']];
|
403 |
798cb31a
|
Scott Ullrich
|
}
|
404 |
dec5cb85
|
Scott Ullrich
|
}
|
405 |
|
|
$config['diag']['ipv6nat'] = true;
|
406 |
8ff5ffcc
|
Matthew Grooms
|
write_config();
|
407 |
a250f179
|
Renato Botelho
|
add_base_packages_menu_items();
|
408 |
d442e4e2
|
Scott Ullrich
|
convert_config();
|
409 |
205da5a0
|
Neriberto C.Prado
|
$savemsg = gettext("The m0n0wall configuration has been restored and upgraded to pfSense.");
|
410 |
da17d77e
|
Ermal Lu?i
|
mark_subsystem_dirty("restore");
|
411 |
8ff5ffcc
|
Matthew Grooms
|
}
|
412 |
5f601060
|
Phil Davis
|
if (is_array($config['captiveportal'])) {
|
413 |
|
|
foreach ($config['captiveportal'] as $cp) {
|
414 |
2e19a683
|
Renato Botelho
|
if (isset($cp['enable'])) {
|
415 |
|
|
/* for some reason ipfw doesn't init correctly except on bootup sequence */
|
416 |
|
|
mark_subsystem_dirty("restore");
|
417 |
|
|
break;
|
418 |
|
|
}
|
419 |
|
|
}
|
420 |
8ff5ffcc
|
Matthew Grooms
|
}
|
421 |
|
|
setup_serial_port();
|
422 |
5f601060
|
Phil Davis
|
if (is_interface_mismatch() == true) {
|
423 |
8ff5ffcc
|
Matthew Grooms
|
touch("/var/run/interface_mismatch_reboot_needed");
|
424 |
da17d77e
|
Ermal Lu?i
|
clear_subsystem_dirty("restore");
|
425 |
f5a57bb0
|
Scott Ullrich
|
convert_config();
|
426 |
8ff5ffcc
|
Matthew Grooms
|
header("Location: interfaces_assign.php");
|
427 |
bafaf123
|
Scott Ullrich
|
exit;
|
428 |
8ff5ffcc
|
Matthew Grooms
|
}
|
429 |
66bcba1b
|
Ermal
|
if (is_interface_vlan_mismatch() == true) {
|
430 |
|
|
touch("/var/run/interface_mismatch_reboot_needed");
|
431 |
|
|
clear_subsystem_dirty("restore");
|
432 |
|
|
convert_config();
|
433 |
|
|
header("Location: interfaces_assign.php");
|
434 |
|
|
exit;
|
435 |
|
|
}
|
436 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
437 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The configuration could not be restored.");
|
438 |
db3996df
|
Scott Ullrich
|
}
|
439 |
9c72b993
|
Scott Ullrich
|
}
|
440 |
181462b5
|
Scott Ullrich
|
}
|
441 |
8ff5ffcc
|
Matthew Grooms
|
} else {
|
442 |
205da5a0
|
Neriberto C.Prado
|
$input_errors[] = gettext("The configuration could not be restored (file upload error).");
|
443 |
db3996df
|
Scott Ullrich
|
}
|
444 |
5b237745
|
Scott Ullrich
|
}
|
445 |
8ff5ffcc
|
Matthew Grooms
|
}
|
446 |
73ed069b
|
Renato Botelho
|
|
447 |
8ff5ffcc
|
Matthew Grooms
|
if ($mode == "reinstallpackages") {
|
448 |
8ccc8f1a
|
Scott Ullrich
|
header("Location: pkg_mgr_install.php?mode=reinstallall");
|
449 |
|
|
exit;
|
450 |
039cb920
|
jim-p
|
} else if ($mode == "clearpackagelock") {
|
451 |
|
|
clear_subsystem_dirty('packagelock');
|
452 |
8545adde
|
k-paulius
|
$savemsg = "Package lock cleared.";
|
453 |
73ed069b
|
Renato Botelho
|
} else if ($mode == "restore_ver") {
|
454 |
b6078bed
|
NOYB
|
$input_errors[] = gettext("XXX - this feature may hose the config (do NOT backrev configs!) - billm");
|
455 |
7cf03119
|
Bill Marquette
|
if ($ver2restore <> "") {
|
456 |
|
|
$conf_file = "{$g['cf_conf_path']}/bak/config-" . strtotime($ver2restore) . ".xml";
|
457 |
343bb325
|
sullrich
|
if (config_install($conf_file) == 0) {
|
458 |
c9a19238
|
Darren Embry
|
mark_subsystem_dirty("restore");
|
459 |
|
|
} else {
|
460 |
|
|
$input_errors[] = gettext("The configuration could not be restored.");
|
461 |
|
|
}
|
462 |
|
|
} else {
|
463 |
|
|
$input_errors[] = gettext("No version selected.");
|
464 |
|
|
}
|
465 |
5b237745
|
Scott Ullrich
|
}
|
466 |
|
|
}
|
467 |
|
|
}
|
468 |
6a1e6651
|
Bill Marquette
|
|
469 |
02e1170d
|
Scott Ullrich
|
$id = rand() . '.' . time();
|
470 |
|
|
|
471 |
|
|
$mth = ini_get('upload_progress_meter.store_method');
|
472 |
|
|
$dir = ini_get('upload_progress_meter.file.filename_template');
|
473 |
|
|
|
474 |
a4af095c
|
Renato Botelho
|
function build_area_list($showall) {
|
475 |
|
|
global $config;
|
476 |
b63695db
|
Scott Ullrich
|
|
477 |
0e834fc5
|
Stephen Beaver
|
$areas = array(
|
478 |
|
|
"aliases" => gettext("Aliases"),
|
479 |
a4af095c
|
Renato Botelho
|
"captiveportal" => gettext("Captive Portal"),
|
480 |
|
|
"voucher" => gettext("Captive Portal Vouchers"),
|
481 |
|
|
"dnsmasq" => gettext("DNS Forwarder"),
|
482 |
|
|
"unbound" => gettext("DNS Resolver"),
|
483 |
|
|
"dhcpd" => gettext("DHCP Server"),
|
484 |
|
|
"dhcpdv6" => gettext("DHCPv6 Server"),
|
485 |
|
|
"filter" => gettext("Firewall Rules"),
|
486 |
|
|
"interfaces" => gettext("Interfaces"),
|
487 |
|
|
"ipsec" => gettext("IPSEC"),
|
488 |
|
|
"nat" => gettext("NAT"),
|
489 |
|
|
"openvpn" => gettext("OpenVPN"),
|
490 |
|
|
"installedpackages" => gettext("Package Manager"),
|
491 |
|
|
"rrddata" => gettext("RRD Data"),
|
492 |
|
|
"cron" => gettext("Scheduled Tasks"),
|
493 |
|
|
"syslog" => gettext("Syslog"),
|
494 |
|
|
"system" => gettext("System"),
|
495 |
|
|
"staticroutes" => gettext("Static routes"),
|
496 |
|
|
"sysctl" => gettext("System tunables"),
|
497 |
|
|
"snmpd" => gettext("SNMP Server"),
|
498 |
|
|
"shaper" => gettext("Traffic Shaper"),
|
499 |
|
|
"vlans" => gettext("VLANS"),
|
500 |
7ca42d47
|
k-paulius
|
"wol" => gettext("Wake-on-LAN")
|
501 |
a4af095c
|
Renato Botelho
|
);
|
502 |
0e834fc5
|
Stephen Beaver
|
|
503 |
|
|
$list = array("" => gettext("All"));
|
504 |
|
|
|
505 |
288a2a0f
|
Phil Davis
|
if ($showall) {
|
506 |
0e834fc5
|
Stephen Beaver
|
return($list + $areas);
|
507 |
288a2a0f
|
Phil Davis
|
} else {
|
508 |
a4af095c
|
Renato Botelho
|
foreach ($areas as $area => $areaname) {
|
509 |
|
|
if ($area === "rrddata" || check_and_returnif_section_exists($area) == true) {
|
510 |
|
|
$list[$area] = $areaname;
|
511 |
|
|
}
|
512 |
|
|
}
|
513 |
8ff5ffcc
|
Matthew Grooms
|
|
514 |
0e834fc5
|
Stephen Beaver
|
return($list);
|
515 |
5f601060
|
Phil Davis
|
}
|
516 |
8ff5ffcc
|
Matthew Grooms
|
}
|
517 |
|
|
|
518 |
0f298138
|
k-paulius
|
$pgtitle = array(gettext("Diagnostics"), htmlspecialchars(gettext("Backup & Restore")), htmlspecialchars(gettext("Backup & Restore")));
|
519 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
520 |
|
|
|
521 |
947141fd
|
Phil Davis
|
if ($input_errors) {
|
522 |
a4af095c
|
Renato Botelho
|
print_input_errors($input_errors);
|
523 |
947141fd
|
Phil Davis
|
}
|
524 |
0e834fc5
|
Stephen Beaver
|
|
525 |
947141fd
|
Phil Davis
|
if ($savemsg) {
|
526 |
a4af095c
|
Renato Botelho
|
print_info_box($savemsg, 'success');
|
527 |
947141fd
|
Phil Davis
|
}
|
528 |
0e834fc5
|
Stephen Beaver
|
|
529 |
a4af095c
|
Renato Botelho
|
if (is_subsystem_dirty('restore')):
|
530 |
5b237745
|
Scott Ullrich
|
?>
|
531 |
a4af095c
|
Renato Botelho
|
<br/>
|
532 |
1af5edbf
|
Stephen Beaver
|
<form action="diag_reboot.php" method="post">
|
533 |
7d5b007c
|
Sjon Hortensius
|
<input name="Submit" type="hidden" value="Yes" />
|
534 |
f6aebbcc
|
NewEraCracker
|
<?php print_info_box(gettext("The firewall configuration has been changed.") . "<br />" . gettext("The firewall is now rebooting.")); ?>
|
535 |
a4af095c
|
Renato Botelho
|
<br />
|
536 |
7d5b007c
|
Sjon Hortensius
|
</form>
|
537 |
0e834fc5
|
Stephen Beaver
|
<?php
|
538 |
a4af095c
|
Renato Botelho
|
endif;
|
539 |
|
|
|
540 |
|
|
$tab_array = array();
|
541 |
0f298138
|
k-paulius
|
$tab_array[] = array(htmlspecialchars(gettext("Backup & Restore")), true, "diag_backup.php");
|
542 |
a4af095c
|
Renato Botelho
|
$tab_array[] = array(gettext("Config History"), false, "diag_confbak.php");
|
543 |
|
|
display_top_tabs($tab_array);
|
544 |
|
|
|
545 |
|
|
$form = new Form(false);
|
546 |
3beeb66a
|
Stephen Beaver
|
$form->setMultipartEncoding(); // Allow file uploads
|
547 |
a4af095c
|
Renato Botelho
|
|
548 |
5f88f964
|
k-paulius
|
$section = new Form_Section('Backup Configuration');
|
549 |
a4af095c
|
Renato Botelho
|
|
550 |
|
|
$section->addInput(new Form_Select(
|
551 |
|
|
'backuparea',
|
552 |
|
|
'Backup area',
|
553 |
|
|
'',
|
554 |
|
|
build_area_list(false)
|
555 |
|
|
));
|
556 |
|
|
|
557 |
|
|
$section->addInput(new Form_Checkbox(
|
558 |
|
|
'nopackages',
|
559 |
|
|
'Skip packages',
|
560 |
|
|
'Do not backup package information.',
|
561 |
|
|
false
|
562 |
|
|
));
|
563 |
|
|
|
564 |
|
|
$section->addInput(new Form_Checkbox(
|
565 |
|
|
'donotbackuprrd',
|
566 |
|
|
'Skip RRD data',
|
567 |
|
|
'Do not backup RRD data (NOTE: RRD Data can consume 4+ megabytes of config.xml space!)',
|
568 |
|
|
true
|
569 |
|
|
));
|
570 |
|
|
|
571 |
|
|
$section->addInput(new Form_Checkbox(
|
572 |
|
|
'encrypt',
|
573 |
|
|
'Encryption',
|
574 |
|
|
'Encrypt this configuration file.',
|
575 |
|
|
false
|
576 |
7c0f116b
|
Jared Dillard
|
));
|
577 |
a4af095c
|
Renato Botelho
|
|
578 |
76d6d925
|
Stephen Beaver
|
$section->addInput(new Form_Input(
|
579 |
a4af095c
|
Renato Botelho
|
'encrypt_password',
|
580 |
c8b10b4c
|
Stephen Beaver
|
'Password',
|
581 |
a4af095c
|
Renato Botelho
|
'password',
|
582 |
c8b10b4c
|
Stephen Beaver
|
null
|
583 |
7c0f116b
|
Jared Dillard
|
));
|
584 |
a4af095c
|
Renato Botelho
|
|
585 |
|
|
$group = new Form_Group('');
|
586 |
1d80d714
|
NOYB
|
// Note: ID attribute of each element created is to be unique. Not being used, suppressing it.
|
587 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Button(
|
588 |
|
|
'Submit',
|
589 |
faab522f
|
Renato Botelho
|
'Download configuration as XML',
|
590 |
37676f4e
|
jim-p
|
null,
|
591 |
|
|
'fa-download'
|
592 |
|
|
))->setAttribute('id')->addClass('btn-primary');
|
593 |
a4af095c
|
Renato Botelho
|
|
594 |
|
|
$section->add($group);
|
595 |
|
|
$form->add($section);
|
596 |
|
|
|
597 |
5f88f964
|
k-paulius
|
$section = new Form_Section('Restore Backup');
|
598 |
a4af095c
|
Renato Botelho
|
|
599 |
|
|
$section->addInput(new Form_StaticText(
|
600 |
|
|
null,
|
601 |
52e416cc
|
Phil Davis
|
sprintf(gettext("Open a %s configuration XML file and click the button below to restore the configuration."), $g['product_name'])
|
602 |
a4af095c
|
Renato Botelho
|
));
|
603 |
|
|
|
604 |
|
|
$section->addInput(new Form_Select(
|
605 |
|
|
'restorearea',
|
606 |
|
|
'Restore area',
|
607 |
|
|
'',
|
608 |
ce3eca6e
|
Phil Davis
|
build_area_list(true)
|
609 |
a4af095c
|
Renato Botelho
|
));
|
610 |
|
|
|
611 |
|
|
$section->addInput(new Form_Input(
|
612 |
|
|
'conffile',
|
613 |
|
|
'Configuration file',
|
614 |
|
|
'file',
|
615 |
|
|
null
|
616 |
|
|
));
|
617 |
|
|
|
618 |
|
|
$section->addInput(new Form_Checkbox(
|
619 |
7c0f116b
|
Jared Dillard
|
'decrypt',
|
620 |
a4af095c
|
Renato Botelho
|
'Encryption',
|
621 |
7c0f116b
|
Jared Dillard
|
'Configuration file is encrypted.',
|
622 |
a4af095c
|
Renato Botelho
|
false
|
623 |
7c0f116b
|
Jared Dillard
|
));
|
624 |
a4af095c
|
Renato Botelho
|
|
625 |
76d6d925
|
Stephen Beaver
|
$section->addInput(new Form_Input(
|
626 |
a4af095c
|
Renato Botelho
|
'decrypt_password',
|
627 |
c8b10b4c
|
Stephen Beaver
|
'Password',
|
628 |
a4af095c
|
Renato Botelho
|
'password',
|
629 |
|
|
null,
|
630 |
|
|
['placeholder' => 'Password']
|
631 |
7c0f116b
|
Jared Dillard
|
));
|
632 |
a4af095c
|
Renato Botelho
|
|
633 |
|
|
$group = new Form_Group('');
|
634 |
1d80d714
|
NOYB
|
// Note: ID attribute of each element created is to be unique. Not being used, suppressing it.
|
635 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Button(
|
636 |
|
|
'Submit',
|
637 |
faab522f
|
Renato Botelho
|
'Restore Configuration',
|
638 |
37676f4e
|
jim-p
|
null,
|
639 |
|
|
'fa-undo'
|
640 |
|
|
))->setHelp('The firewall will reboot after restoring the configuration.')->addClass('btn-danger restore')->setAttribute('id');
|
641 |
a4af095c
|
Renato Botelho
|
|
642 |
|
|
$section->add($group);
|
643 |
|
|
|
644 |
|
|
$form->add($section);
|
645 |
|
|
|
646 |
|
|
if (($config['installedpackages']['package'] != "") || (is_subsystem_dirty("packagelock"))) {
|
647 |
5f88f964
|
k-paulius
|
$section = new Form_Section('Package Functions');
|
648 |
0e834fc5
|
Stephen Beaver
|
|
649 |
a4af095c
|
Renato Botelho
|
if ($config['installedpackages']['package'] != "") {
|
650 |
|
|
$group = new Form_Group('');
|
651 |
1d80d714
|
NOYB
|
// Note: ID attribute of each element created is to be unique. Not being used, suppressing it.
|
652 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Button(
|
653 |
|
|
'Submit',
|
654 |
faab522f
|
Renato Botelho
|
'Reinstall Packages',
|
655 |
37676f4e
|
jim-p
|
null,
|
656 |
|
|
'fa-retweet'
|
657 |
|
|
))->setHelp('Click this button to reinstall all system packages. This may take a while.')->addClass('btn-success')->setAttribute('id');
|
658 |
0e834fc5
|
Stephen Beaver
|
|
659 |
a4af095c
|
Renato Botelho
|
$section->add($group);
|
660 |
7eead1fc
|
Darren Embry
|
}
|
661 |
0e834fc5
|
Stephen Beaver
|
|
662 |
a4af095c
|
Renato Botelho
|
if (is_subsystem_dirty("packagelock")) {
|
663 |
|
|
$group = new Form_Group('');
|
664 |
1d80d714
|
NOYB
|
// Note: ID attribute of each element created is to be unique. Not being used, suppressing it.
|
665 |
a4af095c
|
Renato Botelho
|
$group->add(new Form_Button(
|
666 |
|
|
'Submit',
|
667 |
faab522f
|
Renato Botelho
|
'Clear Package Lock',
|
668 |
37676f4e
|
jim-p
|
null,
|
669 |
|
|
'fa-wrench'
|
670 |
|
|
))->setHelp('Click this button to clear the package lock if a package fails to reinstall properly after an upgrade.')->addClass('btn-warning')->setAttribute('id');
|
671 |
0e834fc5
|
Stephen Beaver
|
|
672 |
a4af095c
|
Renato Botelho
|
$section->add($group);
|
673 |
|
|
}
|
674 |
0e834fc5
|
Stephen Beaver
|
|
675 |
a4af095c
|
Renato Botelho
|
$form->add($section);
|
676 |
a1003d57
|
Ermal Lu?i
|
}
|
677 |
a4af095c
|
Renato Botelho
|
|
678 |
|
|
print($form);
|
679 |
7c0f116b
|
Jared Dillard
|
?>
|
680 |
|
|
<script type="text/javascript">
|
681 |
|
|
//<![CDATA[
|
682 |
947141fd
|
Phil Davis
|
events.push(function() {
|
683 |
7c0f116b
|
Jared Dillard
|
|
684 |
|
|
// ------- Show/hide sections based on checkbox settings --------------------------------------
|
685 |
0da0d43e
|
Phil Davis
|
|
686 |
7c0f116b
|
Jared Dillard
|
function hideSections(hide) {
|
687 |
|
|
hidePasswords();
|
688 |
|
|
}
|
689 |
|
|
|
690 |
|
|
function hidePasswords() {
|
691 |
3beeb66a
|
Stephen Beaver
|
|
692 |
7c0f116b
|
Jared Dillard
|
encryptHide = !($('input[name="encrypt"]').is(':checked'));
|
693 |
|
|
decryptHide = !($('input[name="decrypt"]').is(':checked'));
|
694 |
|
|
|
695 |
|
|
hideInput('encrypt_password', encryptHide);
|
696 |
c8b10b4c
|
Stephen Beaver
|
hideInput('encrypt_password_confirm', encryptHide);
|
697 |
7c0f116b
|
Jared Dillard
|
hideInput('decrypt_password', decryptHide);
|
698 |
c8b10b4c
|
Stephen Beaver
|
hideInput('decrypt_password_confirm', decryptHide);
|
699 |
7c0f116b
|
Jared Dillard
|
}
|
700 |
|
|
|
701 |
ff59b884
|
Stephen Beaver
|
// ---------- Click handlers ------------------------------------------------------------------
|
702 |
7c0f116b
|
Jared Dillard
|
|
703 |
|
|
$('input[name="encrypt"]').on('change', function() {
|
704 |
|
|
hidePasswords();
|
705 |
|
|
});
|
706 |
|
|
|
707 |
|
|
$('input[name="decrypt"]').on('change', function() {
|
708 |
|
|
hidePasswords();
|
709 |
3beeb66a
|
Stephen Beaver
|
});
|
710 |
7c0f116b
|
Jared Dillard
|
|
711 |
947141fd
|
Phil Davis
|
$('#conffile').change(function () {
|
712 |
40f146c5
|
Phil Davis
|
if (document.getElementById("conffile").value) {
|
713 |
|
|
$('.restore').prop('disabled', false);
|
714 |
|
|
} else {
|
715 |
|
|
$('.restore').prop('disabled', true);
|
716 |
|
|
}
|
717 |
ff59b884
|
Stephen Beaver
|
});
|
718 |
eef93144
|
Jared Dillard
|
// ---------- On initial page load ------------------------------------------------------------
|
719 |
|
|
|
720 |
7c0f116b
|
Jared Dillard
|
hideSections();
|
721 |
ff59b884
|
Stephen Beaver
|
$('.restore').prop('disabled', true);
|
722 |
7c0f116b
|
Jared Dillard
|
});
|
723 |
|
|
//]]>
|
724 |
|
|
</script>
|
725 |
|
|
|
726 |
|
|
<?php
|
727 |
a4af095c
|
Renato Botelho
|
include("foot.inc");
|
728 |
7a7f3af1
|
sullrich
|
|
729 |
5f601060
|
Phil Davis
|
if (is_subsystem_dirty('restore')) {
|
730 |
cf9a4467
|
jim-p
|
system_reboot();
|
731 |
c9d46a8e
|
Renato Botelho
|
}
|