1
|
<?php
|
2
|
/*
|
3
|
* services_acb.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2008-2015 Rubicon Communications, LLC (Netgate)
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10
|
* you may not use this file except in compliance with the License.
|
11
|
* You may obtain a copy of the License at
|
12
|
*
|
13
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14
|
*
|
15
|
* Unless required by applicable law or agreed to in writing, software
|
16
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18
|
* See the License for the specific language governing permissions and
|
19
|
* limitations under the License.
|
20
|
*/
|
21
|
require("guiconfig.inc");
|
22
|
require("acb.inc");
|
23
|
|
24
|
// Separator used during client / server communications
|
25
|
$oper_sep = "\|\|";
|
26
|
$exp_sep = '||';
|
27
|
|
28
|
// $legacy is used to determine whether to work with the old "Gold" ACB system, or the
|
29
|
// current system
|
30
|
$legacy = false;
|
31
|
|
32
|
if (isset($_REQUEST['legacy'])) {
|
33
|
$legacy = true;
|
34
|
}
|
35
|
|
36
|
// Encryption password
|
37
|
if (!$legacy) {
|
38
|
$decrypt_password = $config['system']['acb']['encryption_password'];
|
39
|
} else {
|
40
|
$decrypt_password = $config['system']['acb']['gold_encryption_password'];
|
41
|
}
|
42
|
|
43
|
// Defined username. Username must be sent lowercase. See Redmine #7127 and Netgate Redmine #163
|
44
|
$username = strtolower($config['system']['acb']['gold_username']);
|
45
|
$password = $config['system']['acb']['gold_password'];
|
46
|
|
47
|
// URL to restore.php
|
48
|
$get_url = "https://portal.pfsense.org/pfSconfigbackups/restore.php";
|
49
|
|
50
|
// URL to stats
|
51
|
$stats_url = "https://portal.pfsense.org/pfSconfigbackups/showstats.php";
|
52
|
|
53
|
// URL to delete.php
|
54
|
$del_url = "https://portal.pfsense.org/pfSconfigbackups/delete.php";
|
55
|
|
56
|
// Set hostname
|
57
|
if ($_REQUEST['hostname']) {
|
58
|
$hostname = $_REQUEST['hostname'];
|
59
|
} else {
|
60
|
$hostname = $config['system']['hostname'] . "." . $config['system']['domain'];
|
61
|
}
|
62
|
|
63
|
// Hostname of local machine
|
64
|
$myhostname = $config['system']['hostname'] . "." . $config['system']['domain'];
|
65
|
|
66
|
if (!$decrypt_password) {
|
67
|
Header("Location: /services_acb_settings.php");
|
68
|
exit;
|
69
|
}
|
70
|
|
71
|
if ($_REQUEST['savemsg']) {
|
72
|
$savemsg = htmlentities($_REQUEST['savemsg']);
|
73
|
}
|
74
|
|
75
|
if ($_REQUEST['download']) {
|
76
|
$pgtitle = array("Services", "Auto Configuration Backup", "Revision Information");
|
77
|
} else {
|
78
|
$pgtitle = array("Services", "Auto Configuration Backup", "Restore");
|
79
|
}
|
80
|
|
81
|
/* Set up time zones for conversion. See #5250 */
|
82
|
$acbtz = new DateTimeZone('America/Chicago');
|
83
|
$mytz = new DateTimeZone(date_default_timezone_get());
|
84
|
|
85
|
include("head.inc");
|
86
|
|
87
|
function get_hostnames() {
|
88
|
global $stats_url, $username, $password, $oper_sep, $config, $g, $exp_sep;
|
89
|
// Populate available backups
|
90
|
$curl_session = curl_init();
|
91
|
curl_setopt($curl_session, CURLOPT_URL, $stats_url);
|
92
|
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("{$username}:{$password}")));
|
93
|
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 1);
|
94
|
curl_setopt($curl_session, CURLOPT_POST, 1);
|
95
|
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
|
96
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showstats");
|
97
|
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
|
98
|
// Proxy
|
99
|
curl_setopt_array($curl_session, configure_proxy());
|
100
|
|
101
|
$data = curl_exec($curl_session);
|
102
|
if (curl_errno($curl_session)) {
|
103
|
$fd = fopen("/tmp/acb_statsdebug.txt", "w");
|
104
|
fwrite($fd, $stats_url . "" . "action=showstats" . "\n\n");
|
105
|
fwrite($fd, $data);
|
106
|
fwrite($fd, curl_error($curl_session));
|
107
|
fclose($fd);
|
108
|
} else {
|
109
|
curl_close($curl_session);
|
110
|
}
|
111
|
|
112
|
// Loop through and create new confvers
|
113
|
$data_split = explode("\n", $data);
|
114
|
$statvers = array();
|
115
|
foreach ($data_split as $ds) {
|
116
|
$ds_split = explode($exp_sep, $ds);
|
117
|
if ($ds_split[0]) {
|
118
|
$statvers[] = $ds_split[0];
|
119
|
}
|
120
|
}
|
121
|
return $statvers;
|
122
|
}
|
123
|
|
124
|
if ($_REQUEST['rmver'] != "") {
|
125
|
$curl_session = curl_init();
|
126
|
if ($legacy) {
|
127
|
curl_setopt($curl_session, CURLOPT_URL, $del_url);
|
128
|
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("{$username}:{$password}")));
|
129
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=delete" . "&hostname=" . urlencode($hostname) . "&revision=" . urlencode($_REQUEST['rmver']));
|
130
|
} else {
|
131
|
curl_setopt($curl_session, CURLOPT_URL, "https://acb.netgate.com/rmbkp");
|
132
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "userkey=" . $userkey .
|
133
|
"&revision=" . urlencode($_REQUEST['rmver']) .
|
134
|
"&version=" . $g['product_version'] .
|
135
|
"&uid=" . urlencode($uniqueID));
|
136
|
}
|
137
|
|
138
|
curl_setopt($curl_session, CURLOPT_POST, 3);
|
139
|
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 1);
|
140
|
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
|
141
|
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
|
142
|
// Proxy
|
143
|
curl_setopt_array($curl_session, configure_proxy());
|
144
|
|
145
|
$data = curl_exec($curl_session);
|
146
|
if (curl_errno($curl_session)) {
|
147
|
$fd = fopen("/tmp/acb_deletedebug.txt", "w");
|
148
|
fwrite($fd, $get_url . "" . "action=delete&hostname=" . urlencode($hostname) . "&revision=" . urlencode($_REQUEST['rmver']) . "\n\n");
|
149
|
fwrite($fd, $data);
|
150
|
fwrite($fd, curl_error($curl_session));
|
151
|
fclose($fd);
|
152
|
$savemsg = "An error occurred while trying to remove the item from portal.pfsense.org.";
|
153
|
} else {
|
154
|
curl_close($curl_session);
|
155
|
$budate = new DateTime($_REQUEST['rmver'], $acbtz);
|
156
|
$budate->setTimezone($mytz);
|
157
|
$savemsg = "Backup revision " . htmlspecialchars($budate->format(DATE_RFC2822)) . " has been removed.";
|
158
|
}
|
159
|
}
|
160
|
|
161
|
if ($_REQUEST['newver'] != "") {
|
162
|
// Phone home and obtain backups
|
163
|
$curl_session = curl_init();
|
164
|
if ($legacy) {
|
165
|
curl_setopt($curl_session, CURLOPT_URL, $get_url);
|
166
|
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("{$username}:{$password}")));
|
167
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=restore" . "&hostname=" . urlencode($hostname) . "&revision=" . urlencode($_REQUEST['newver']));
|
168
|
} else {
|
169
|
curl_setopt($curl_session, CURLOPT_URL, "https://acb.netgate.com/getbkp");
|
170
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "userkey=" . $userkey .
|
171
|
"&revision=" . urlencode($_REQUEST['newver']) .
|
172
|
"&version=" . $g['product_version'] .
|
173
|
"&uid=" . urlencode($uniqueID));
|
174
|
}
|
175
|
|
176
|
curl_setopt($curl_session, CURLOPT_POST, 3);
|
177
|
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 1);
|
178
|
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
|
179
|
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
|
180
|
// Proxy
|
181
|
curl_setopt_array($curl_session, configure_proxy());
|
182
|
$data = curl_exec($curl_session);
|
183
|
$data_split = explode('++++', $data);
|
184
|
$sha256 = trim($data_split[0]);
|
185
|
$data = $data_split[1];
|
186
|
|
187
|
if (!tagfile_deformat($data, $data, "config.xml")) {
|
188
|
$input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration.";
|
189
|
}
|
190
|
|
191
|
$out = decrypt_data($data, $decrypt_password);
|
192
|
|
193
|
$pos = stripos($out, "</pfsense>");
|
194
|
$data = substr($out, 0, $pos);
|
195
|
$data = $data . "</pfsense>\n";
|
196
|
|
197
|
$fd = fopen("/tmp/config_restore.xml", "w");
|
198
|
fwrite($fd, $data);
|
199
|
fclose($fd);
|
200
|
|
201
|
if (strlen($data) < 50) {
|
202
|
$input_errors[] = "The decrypted config.xml is under 50 characters, something went wrong. Aborting.";
|
203
|
}
|
204
|
|
205
|
$ondisksha256 = trim(shell_exec("/sbin/sha256 /tmp/config_restore.xml | /usr/bin/awk '{ print $4 }'"));
|
206
|
// We might not have a sha256 on file for older backups
|
207
|
if ($sha256 != "0" && $sha256 != "") {
|
208
|
if ($ondisksha256 != $sha256) {
|
209
|
$input_errors[] = "SHA256 values do not match, cannot restore. $ondisksha256 != $sha256";
|
210
|
}
|
211
|
}
|
212
|
if (curl_errno($curl_session)) {
|
213
|
/* If an error occured, log the error in /tmp/ */
|
214
|
$fd = fopen("/tmp/acb_restoredebug.txt", "w");
|
215
|
fwrite($fd, $get_url . "" . "action=restore&hostname={$hostname}&revision=" . urlencode($_REQUEST['newver']) . "\n\n");
|
216
|
fwrite($fd, $data);
|
217
|
fwrite($fd, curl_error($curl_session));
|
218
|
fclose($fd);
|
219
|
} else {
|
220
|
curl_close($curl_session);
|
221
|
}
|
222
|
|
223
|
if (!$input_errors && $data) {
|
224
|
conf_mount_rw();
|
225
|
if (config_restore("/tmp/config_restore.xml") == 0) {
|
226
|
$savemsg = "Successfully reverted the pfSense configuration to revision " . urldecode($_REQUEST['newver']) . ".";
|
227
|
$savemsg .= <<<EOF
|
228
|
<br />
|
229
|
<form action="diag_reboot.php" method="post">
|
230
|
Reboot the firewall to full activate changes?
|
231
|
<input name="override" type="hidden" value="yes" />
|
232
|
<input name="Submit" type="submit" class="formbtn" value=" Yes " />
|
233
|
</form>
|
234
|
EOF;
|
235
|
} else {
|
236
|
$savemsg = "Unable to revert to the selected configuration.";
|
237
|
}
|
238
|
} else {
|
239
|
log_error("There was an error when restoring the AutoConfigBackup item");
|
240
|
}
|
241
|
unlink_if_exists("/tmp/config_restore.xml");
|
242
|
conf_mount_ro();
|
243
|
}
|
244
|
|
245
|
if ($_REQUEST['download']) {
|
246
|
// Phone home and obtain backups
|
247
|
$curl_session = curl_init();
|
248
|
|
249
|
if ($legacy) {
|
250
|
|
251
|
curl_setopt($curl_session, CURLOPT_URL, $get_url);
|
252
|
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("{$username}:{$password}")));
|
253
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=restore" .
|
254
|
"&hostname=" . urlencode($hostname) .
|
255
|
"&revision=" . urlencode($_REQUEST['download']) .
|
256
|
"&version=" . $g['product_version'] .
|
257
|
"&uid=" . urlencode($uniqueID));
|
258
|
} else {
|
259
|
curl_setopt($curl_session, CURLOPT_URL, "https://acb.netgate.com/getbkp");
|
260
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "userkey=" . $userkey . "&revision=" . urlencode($_REQUEST['download']));
|
261
|
}
|
262
|
|
263
|
curl_setopt($curl_session, CURLOPT_POST, 3);
|
264
|
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 1);
|
265
|
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
|
266
|
|
267
|
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
|
268
|
// Proxy
|
269
|
curl_setopt_array($curl_session, configure_proxy());
|
270
|
$data = curl_exec($curl_session);
|
271
|
|
272
|
if (!tagfile_deformat($data, $data1, "config.xml")) {
|
273
|
if ($legacy) {
|
274
|
$input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration.";
|
275
|
} else {
|
276
|
$input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration.";
|
277
|
}
|
278
|
} else {
|
279
|
$ds = explode('++++', $data);
|
280
|
$revision = $_REQUEST['download'];
|
281
|
$sha256sum = $ds[0];
|
282
|
if ($sha256sum == "0") {
|
283
|
$sha256sum = "None on file.";
|
284
|
}
|
285
|
$data = $ds[1];
|
286
|
$configtype = "Encrypted";
|
287
|
if (!tagfile_deformat($data, $data, "config.xml")) {
|
288
|
$input_errors[] = "The downloaded file does not appear to contain an encrypted pfSense configuration.";
|
289
|
}
|
290
|
$data = decrypt_data($data, $decrypt_password);
|
291
|
if (!strstr($data, "pfsense")) {
|
292
|
$data = "Could not decrypt. Different encryption key?";
|
293
|
$input_errors[] = "Could not decrypt config.xml";
|
294
|
}
|
295
|
}
|
296
|
}
|
297
|
|
298
|
// $confvers must be populated viewing info but there were errors
|
299
|
if ( !($_REQUEST['download']) || $input_errors) {
|
300
|
// Populate available backups
|
301
|
$curl_session = curl_init();
|
302
|
|
303
|
if ($legacy) {
|
304
|
curl_setopt($curl_session, CURLOPT_URL, $get_url);
|
305
|
curl_setopt($curl_session, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("{$username}:{$password}")));
|
306
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "action=showbackups&hostname={$hostname}");
|
307
|
} else {
|
308
|
curl_setopt($curl_session, CURLOPT_URL, "https://acb.netgate.com/list");
|
309
|
curl_setopt($curl_session, CURLOPT_POSTFIELDS, "userkey=" . $userkey .
|
310
|
"&uid=eb6a4e6f76c10734b636" .
|
311
|
"&version=" . $g['product_version'] .
|
312
|
"&uid=" . urlencode($uniqueID));
|
313
|
}
|
314
|
|
315
|
curl_setopt($curl_session, CURLOPT_SSL_VERIFYPEER, 1);
|
316
|
curl_setopt($curl_session, CURLOPT_POST, 1);
|
317
|
curl_setopt($curl_session, CURLOPT_RETURNTRANSFER, 1);
|
318
|
|
319
|
curl_setopt($curl_session, CURLOPT_USERAGENT, $g['product_name'] . '/' . rtrim(file_get_contents("/etc/version")));
|
320
|
// Proxy
|
321
|
curl_setopt_array($curl_session, configure_proxy());
|
322
|
|
323
|
$data = curl_exec($curl_session);
|
324
|
|
325
|
if (curl_errno($curl_session)) {
|
326
|
$fd = fopen("/tmp/acb_backupdebug.txt", "w");
|
327
|
fwrite($fd, $get_url . "" . "action=showbackups" . "\n\n");
|
328
|
fwrite($fd, $data);
|
329
|
fwrite($fd, curl_error($curl_session));
|
330
|
fclose($fd);
|
331
|
} else {
|
332
|
curl_close($curl_session);
|
333
|
}
|
334
|
|
335
|
// Loop through and create new confvers
|
336
|
$data_split = explode("\n", $data);
|
337
|
|
338
|
$confvers = array();
|
339
|
|
340
|
foreach ($data_split as $ds) {
|
341
|
$ds_split = explode($exp_sep, $ds);
|
342
|
$tmp_array = array();
|
343
|
$tmp_array['username'] = $ds_split[0];
|
344
|
$tmp_array['reason'] = $ds_split[1];
|
345
|
$tmp_array['time'] = $ds_split[2];
|
346
|
|
347
|
/* Convert the time from server time to local. See #5250 */
|
348
|
$budate = new DateTime($tmp_array['time'], $acbtz);
|
349
|
$budate->setTimezone($mytz);
|
350
|
$tmp_array['localtime'] = $budate->format(DATE_RFC2822);
|
351
|
|
352
|
if ($ds_split[2] && $ds_split[0]) {
|
353
|
$confvers[] = $tmp_array;
|
354
|
}
|
355
|
}
|
356
|
}
|
357
|
|
358
|
if ($input_errors) {
|
359
|
print_input_errors($input_errors);
|
360
|
}
|
361
|
if ($savemsg) {
|
362
|
print_info_box($savemsg, 'success');
|
363
|
}
|
364
|
|
365
|
$tab_array = array();
|
366
|
$tab_array[0] = array("Settings", false, "/services_acb_settings.php");
|
367
|
if ($_REQUEST['download']) {
|
368
|
$active = false;
|
369
|
} else {
|
370
|
$active = true;
|
371
|
}
|
372
|
|
373
|
$tab_array[1] = array("Restore", $active, "/services_acb.php");
|
374
|
|
375
|
if ($_REQUEST['download']) {
|
376
|
$tab_array[] = array("Revision", true, "/services_acb.php?download={$_REQUEST['download']}");
|
377
|
}
|
378
|
|
379
|
$tab_array[] = array("Backup now", false, "/services_acb_backup.php");
|
380
|
|
381
|
display_top_tabs($tab_array);
|
382
|
|
383
|
$hostnames = get_hostnames();
|
384
|
?>
|
385
|
|
386
|
<div id="loading">
|
387
|
<i class="fa fa-spinner fa-spin"></i> Loading, please wait...
|
388
|
</div>
|
389
|
|
390
|
|
391
|
<?php if ($_REQUEST['download'] && (!$input_errors)):
|
392
|
|
393
|
$form = new Form(false);
|
394
|
|
395
|
$section = new Form_Section('Backup Details');
|
396
|
|
397
|
if ($legacy) {
|
398
|
$section->addInput(new Form_Input(
|
399
|
'hostname',
|
400
|
'Hostname',
|
401
|
'text',
|
402
|
$hostname
|
403
|
))->setWidth(7)->setReadOnly();
|
404
|
}
|
405
|
|
406
|
$section->addInput(new Form_Input(
|
407
|
'download',
|
408
|
'Revision date/time',
|
409
|
'text',
|
410
|
$_REQUEST['download']
|
411
|
))->setWidth(7)->setReadOnly();
|
412
|
|
413
|
$section->addInput(new Form_Input(
|
414
|
'reason',
|
415
|
'Revision Reason',
|
416
|
'text',
|
417
|
$_REQUEST['reason']
|
418
|
))->setWidth(7)->setReadOnly();
|
419
|
|
420
|
$section->addInput(new Form_Input(
|
421
|
'shasum',
|
422
|
'SHA256 summary',
|
423
|
'text',
|
424
|
$sha256sum
|
425
|
))->setWidth(7)->setReadOnly();
|
426
|
|
427
|
$section->addInput(new Form_Textarea(
|
428
|
'config_xml',
|
429
|
'Encrypted config.xml',
|
430
|
$ds[1]
|
431
|
))->setWidth(7)->setAttribute("rows", "40")->setAttribute("wrap", "off");
|
432
|
|
433
|
$section->addInput(new Form_Textarea(
|
434
|
'dec_config_xml',
|
435
|
'Decrypted config.xml',
|
436
|
$data
|
437
|
))->setWidth(7)->setAttribute("rows", "40")->setAttribute("wrap", "off");
|
438
|
|
439
|
$form->add($section);
|
440
|
|
441
|
print($form);
|
442
|
|
443
|
?>
|
444
|
<a class="btn btn-primary" title="<?=gettext('Restore this revision')?>" href="services_acb.php?newver=<?= urlencode($_REQUEST['download']) ?>" onclick="return confirm('<?=gettext("Are you sure you want to restore {$cv['localtime']}?")?>')"><i class="fa fa-undo"></i> Install this revision</a>
|
445
|
|
446
|
<?php else:
|
447
|
|
448
|
if (!$legacy) {
|
449
|
$section2 = new Form_Section('Device key');
|
450
|
$group = new Form_Group("Device key");
|
451
|
|
452
|
$group->add(new Form_Input(
|
453
|
'devkey',
|
454
|
'Device key',
|
455
|
'text',
|
456
|
$userkey
|
457
|
))->setWidth(7)->setHelp("ID used to identify this firewall (derived from the SSH public key.) " .
|
458
|
"See help below for more details. %sPlease make a safe copy of this ID value.%s If it is lost, your backups will" .
|
459
|
" be lost too!", "<strong>", "</strong>");
|
460
|
|
461
|
$group->add(new Form_Button(
|
462
|
'upduserkey',
|
463
|
'Submit',
|
464
|
null,
|
465
|
'fa-save'
|
466
|
))->addClass('btn-success btn-xs');
|
467
|
|
468
|
$group->add(new Form_Button(
|
469
|
'restore',
|
470
|
'Reset',
|
471
|
null,
|
472
|
'fa-refresh'
|
473
|
))->addClass('btn-info btn-xs');
|
474
|
|
475
|
$section2->add($group);
|
476
|
print($section2);
|
477
|
|
478
|
print('<div class="infoblock">');
|
479
|
print_info_box(gettext("The Device key listed above is derived from the SSH public key of the firewall. When a configuration is saved, it is identified by this value." .
|
480
|
" If you are restoring the configuration of another firewall, paste the Device key from that firewall into the Device ID field above and click \"Submit\"." .
|
481
|
" This will temporarily override the ID for this session."), 'info', false);
|
482
|
print('</div>');
|
483
|
}
|
484
|
|
485
|
?>
|
486
|
<div class="panel panel-default">
|
487
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Automatic Configuration Backups")?></h2></div>
|
488
|
<div class="panel-body">
|
489
|
<div class="table-responsive">
|
490
|
<?php if ($legacy) { ?>
|
491
|
<strong>Hostname:</strong>
|
492
|
<select id="hostname" name="hostname" onchange="document.location='services_acb.php?hostname=' + this.value + '&legacy=true';">
|
493
|
<?
|
494
|
$host_not_found = true;
|
495
|
foreach ($hostnames as $hn):
|
496
|
?>
|
497
|
<option value='<?=$hn?>' <? if ($hn == $hostname) {echo " selected=\"selected\""; $host_not_found = false;} ?>>
|
498
|
<?=$hn?>
|
499
|
</option>
|
500
|
<?endforeach?>
|
501
|
<? if ($host_not_found) { ?>
|
502
|
<option value='<?=$hostname?>' SELECTED><?=$hostname?></option>
|
503
|
<? } ?>
|
504
|
</select>
|
505
|
<?php }
|
506
|
if ($legacy): ?>
|
507
|
<span class="pull-right"> </span>
|
508
|
<button id="nolegacy" class="btn btn-xs btn-warning pull-right" data-toggle="tooltip" title="<?=gettext('Exit the legacy backup system')?>">Exit legacy repository</button>
|
509
|
<?php else: ?>
|
510
|
<span class="pull-right"> </span>
|
511
|
<button id="legacy" class="btn btn-xs btn-success pull-right" data-toggle="tooltip" title="<?=gettext('Switch to the legacy backup system provided as part of the Gold program')?>">Use legacy "Gold" repository</button>
|
512
|
<?php endif; ?>
|
513
|
|
514
|
</div>
|
515
|
<div class="table-responsive">
|
516
|
<table class="table table-striped table-hover table-condensed" id="backups">
|
517
|
<thead>
|
518
|
<tr>
|
519
|
<th width="30%"><?=gettext("Date")?></th>
|
520
|
<th width="60%"><?=gettext("Configuration Change")?></th>
|
521
|
<th width="10%"><?=gettext("Actions")?></th>
|
522
|
</tr>
|
523
|
</thead>
|
524
|
<tbody>
|
525
|
|
526
|
<?php
|
527
|
$counter = 0;
|
528
|
foreach ($confvers as $cv):
|
529
|
?>
|
530
|
<tr>
|
531
|
<td><?= $cv['localtime']; ?></td>
|
532
|
<td><?= $cv['reason']; ?></td>
|
533
|
<td>
|
534
|
<a class="fa fa-undo" title="<?=gettext('Restore this revision')?>" href="services_acb.php?hostname=<?=urlencode($hostname)?>&userkey=<?=urlencode($userkey)?>&newver=<?=urlencode($cv['time'])?><?=($legacy ? "&legacy=true":"")?>" onclick="return confirm('<?=gettext("Are you sure you want to restore {$cv['localtime']}?")?>')"></a>
|
535
|
<a class="fa fa-download" title="<?=gettext('Show info')?>" href="services_acb.php?download=<?=urlencode($cv['time'])?>&hostname=<?=urlencode($hostname)?>&userkey=<?=urlencode($userkey)?>&reason=<?=urlencode($cv['reason'])?><?=($legacy ? "&legacy=true":"")?> "></a>
|
536
|
<?php
|
537
|
if ($userkey == $origkey) {
|
538
|
?>
|
539
|
<a class="fa fa-trash" title="<?=gettext('Delete config')?>" href="services_acb.php?hostname=<?=urlencode($hostname)?>&rmver=<?=urlencode($cv['time'])?><?=($legacy ? "&legacy=true":"")?>"></a>
|
540
|
<?php } ?>
|
541
|
</td>
|
542
|
</tr>
|
543
|
<?php $counter++;
|
544
|
endforeach;
|
545
|
if ($counter == 0): ?>
|
546
|
<tr>
|
547
|
<td colspan="3" align="center" class="text-danger"><strong>
|
548
|
<?=gettext("No backups could be located for this device.")?>
|
549
|
</strong>
|
550
|
</td>
|
551
|
</tr>
|
552
|
<?php else: ?>
|
553
|
<tr>
|
554
|
<td colspan="3" align="center">
|
555
|
<?php if ($legacy) { ?>
|
556
|
<br /><?=gettext("Current count of hosted backups for this hostname on portal.pfsense.org")?> : <?= $counter ?>
|
557
|
<?php } else { ?>
|
558
|
<br /><?=gettext("Current count of hosted backups")?> : <?= $counter ?>
|
559
|
<?php } ?>
|
560
|
</td>
|
561
|
</tr>
|
562
|
<?php endif; ?>
|
563
|
</tbody>
|
564
|
</table>
|
565
|
</div>
|
566
|
</div>
|
567
|
</div>
|
568
|
<?php
|
569
|
|
570
|
endif; ?>
|
571
|
|
572
|
</form>
|
573
|
|
574
|
<div id="legacynotice" class="modal fade" role="dialog">
|
575
|
<div class="modal-dialog">
|
576
|
<div class="modal-content">
|
577
|
<div class="modal-body">
|
578
|
<?php
|
579
|
|
580
|
print(gettext("<p align=\"center\"><strong>pfSense© "Gold" configuration backup system access.</strong>
|
581
|
</p>
|
582
|
<p>The "Gold" backup system may be available to allow the retrieval of older backups</p>
|
583
|
<p>Note that because these backups were stored by hostname AND username, the configured username, hostname and password will be transmitted (via HTTPS) to the server. By clicking "OK"
|
584
|
you agree that you authorize this action. The backup data is encrypted (AES-256) and the encryption key is neither transmitted, nor known outside of the firewall</p>
|
585
|
</div>"));
|
586
|
?>
|
587
|
<div class="modal-footer">
|
588
|
<button type="button" class="btn btn-xs btn-default" data-dismiss="modal" aria-label="Close">
|
589
|
<span aria-hidden="true">Cancel</span>
|
590
|
</button>
|
591
|
<button id="legacyok" type="button" class="btn btn-xs btn-success" data-dismiss="modal" aria-label="Close">
|
592
|
<span aria-hidden="true">OK</span>
|
593
|
</button>
|
594
|
</div>
|
595
|
|
596
|
</div>
|
597
|
</div>
|
598
|
</div>
|
599
|
|
600
|
<?php
|
601
|
|
602
|
if ((strlen($username) == 0) || (strlen($password) == 0) ||
|
603
|
(strlen($config['system']['acb']['gold_encryption_password']) == 0) ||
|
604
|
($config['system']['acb']['gold_encryption_password'] == "********" )) {
|
605
|
$legacyready = "no";
|
606
|
} else {
|
607
|
$legacyready = "yes";
|
608
|
}
|
609
|
|
610
|
$legacynotready = gettext("Please configure your \"Gold\" membership settings on the Settings page " .
|
611
|
"before accessing the legacy backup features");
|
612
|
?>
|
613
|
|
614
|
<script type="text/javascript">
|
615
|
//<![CDATA[
|
616
|
events.push(function(){
|
617
|
$('#loading').hide();
|
618
|
|
619
|
// Show the acceptance modal if the user wants to use the legacy system
|
620
|
$('#legacy').click(function() {
|
621
|
if ("<?=$legacyready?>" == "yes") {
|
622
|
$('#legacynotice').modal('show');
|
623
|
} else {
|
624
|
alert('<?=$legacynotready?>');
|
625
|
}
|
626
|
});
|
627
|
|
628
|
// Redraw the page if they cancel
|
629
|
$('#nolegacy').click(function() {
|
630
|
window.location.replace('/services_acb.php');
|
631
|
});
|
632
|
|
633
|
// On clicking "OK", reload the page but with a POST parameter "legacy" set
|
634
|
$('#legacyok').click(function() {
|
635
|
var $form = $('<form>');
|
636
|
|
637
|
$form
|
638
|
.attr("method", "POST")
|
639
|
.attr("action", '/services_acb.php')
|
640
|
// The CSRF magic is required because we will be viewing the results of the POST
|
641
|
.append(
|
642
|
$("<input>")
|
643
|
.attr("type", "hidden")
|
644
|
.attr("name", "__csrf_magic")
|
645
|
.val(csrfMagicToken)
|
646
|
)
|
647
|
.append(
|
648
|
$("<input>")
|
649
|
.attr("type", "hidden")
|
650
|
.attr("name", 'legacy')
|
651
|
.val("Yes")
|
652
|
)
|
653
|
.appendTo('body')
|
654
|
.submit();
|
655
|
});
|
656
|
|
657
|
// On clicking Submit", reload the page but with a POST parameter "userkey" set
|
658
|
$('#upduserkey').click(function() {
|
659
|
var $form = $('<form>');
|
660
|
var newuserkey = $('#devkey').val();
|
661
|
|
662
|
$form
|
663
|
.attr("method", "POST")
|
664
|
.attr("action", '/services_acb.php')
|
665
|
// The CSRF magic is required because we will be viewing the results of the POST
|
666
|
.append(
|
667
|
$("<input>")
|
668
|
.attr("type", "hidden")
|
669
|
.attr("name", "__csrf_magic")
|
670
|
.val(csrfMagicToken)
|
671
|
)
|
672
|
.append(
|
673
|
$("<input>")
|
674
|
.attr("type", "hidden")
|
675
|
.attr("name", "userkey")
|
676
|
.val(newuserkey)
|
677
|
)
|
678
|
.appendTo('body')
|
679
|
.submit();
|
680
|
});
|
681
|
|
682
|
$('#restore').click(function() {
|
683
|
$('#devkey').val("<?=$origkey?>");
|
684
|
});
|
685
|
});
|
686
|
//]]>
|
687
|
</script>
|
688
|
|
689
|
<?php include("foot.inc"); ?>
|