Project

General

Profile

Download (18.8 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * status.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2022 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://neon1.net/m0n0wall)
12
 * Copyright (c) 2003 Jim McBeath <jimmc@macrovision.com>
13
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
14
 * All rights reserved.
15
 *
16
 * Licensed under the Apache License, Version 2.0 (the "License");
17
 * you may not use this file except in compliance with the License.
18
 * You may obtain a copy of the License at
19
 *
20
 * http://www.apache.org/licenses/LICENSE-2.0
21
 *
22
 * Unless required by applicable law or agreed to in writing, software
23
 * distributed under the License is distributed on an "AS IS" BASIS,
24
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
 * See the License for the specific language governing permissions and
26
 * limitations under the License.
27
 */
28

    
29
##|+PRIV
30
##|*IDENT=page-hidden-detailedstatus
31
##|*NAME=Hidden: Detailed Status
32
##|*DESCR=Allow access to the 'Hidden: Detailed Status' page.
33
##|*MATCH=status.php*
34
##|-PRIV
35

    
36
/* Execute a command, with a title, and generate an HTML table
37
 * showing the results.
38
 */
39

    
40
global $console;
41
global $show_output;
42

    
43
$console = false;
44
$show_output = !isset($_GET['archiveonly']);
45

    
46
if ((php_sapi_name() == 'cli') || (defined('STDIN'))) {
47
	/* Running from console/shell, not web */
48
	$console = true;
49
	$show_output = false;
50
	parse_str($argv[1], $_GET);
51
}
52

    
53
/* include all configuration functions */
54
if ($console) {
55
	require_once("config.inc");
56
} else {
57
	require_once("guiconfig.inc");
58
}
59
require_once("functions.inc");
60
require_once("gwlb.inc");
61
$output_path = "/tmp/status_output/";
62
$output_file = "/tmp/status_output.tgz";
63

    
64
$filtered_tags = array(
65
	'accountkey', 'authorizedkeys', 'auth_pass',
66
	'auth_server_shared_secret', 'auth_server_shared_secret2', 'auth_user',
67
	'barnyard_dbpwd', 'bcrypt-hash', 'cert_key', 'community', 'crypto_password',
68
	'crypto_password2', 'dns_nsupdatensupdate_key', 'ddnsdomainkey', 'encryption_password',
69
	'etpro_code', 'etprocode', 'gold_encryption_password', 'gold_password',
70
	'influx_pass', 'ipsecpsk', 'ldap_bindpw', 'ldapbindpass', 'ldap_pass',
71
	'lighttpd_ls_password', 'maxmind_geoipdb_key', 'maxmind_key', 'md5-hash',
72
	'md5password', 'md5sigkey', 'md5sigpass', 'nt-hash', 'oinkcode',
73
	'oinkmastercode', 'pass', 'passphrase', 'password', 'passwordagain',
74
	'pkcs11pin', 'postgresqlpasswordenc', 'pre-shared-key', 'presharedkey', 'privatekey', 'proxypass',
75
	'proxy_passwd', 'proxyuser', 'proxy_user', 'prv', 'radmac_secret', 'radius_secret',
76
	'redis_password', 'redis_passwordagain', 'rocommunity',	'secret', 'secret2', 'securiteinfo_id',
77
       	'serverauthkey', 'sha512-hash', 'shared_key', 'stats_password', 'tls', 'tlspskidentity', 'tlspskfile',
78
	'varclientpasswordinput', 'varclientsharedsecret', 'varsqlconfpassword',
79
	'varsqlconf2password', 	'varsyncpassword', 'varmodulesldappassword', 'varmodulesldap2password',
80
	'varusersmotpinitsecret', 'varusersmotppin', 'varuserspassword', 'webrootftppassword'
81
);
82

    
83
$acme_filtered_tags = array('key', 'password', 'secret', 'token', 'pwd', 'pw');
84

    
85
if ($_POST['submit'] == "DOWNLOAD" && file_exists($output_file)) {
86
	session_cache_limiter('public');
87
	send_user_download('file', $output_file);
88
}
89

    
90
if (is_dir($output_path)) {
91
	unlink_if_exists("{$output_path}/*");
92
	@rmdir($output_path);
93
}
94
unlink_if_exists($output_file);
95
mkdir($output_path);
96

    
97
function doCmdT($title, $command, $method) {
98
	global $output_path, $output_file, $filtered_tags, $acme_filtered_tags, $show_output;
99
	/* Fixup output directory */
100

    
101
	if ($show_output) {
102
		$rubbish = array('|', '-', '/', '.', ' ');  /* fixes the <a> tag to be W3C compliant */
103
		echo "\n<a name=\"" . str_replace($rubbish, '', $title) . "\" id=\"" . str_replace($rubbish, '', $title) . "\"></a>\n";
104
		print('<div class="panel panel-default">');
105
		print('<div class="panel-heading"><h2 class="panel-title">' . $title . '</h2></div>');
106
		print('<div class="panel-body">');
107
		print('<pre>');
108
	}
109

    
110
	if ($command == "dumpconfigxml") {
111
		$ofd = @fopen("{$output_path}/config-sanitized.xml", "w");
112
		$fd = @fopen("/conf/config.xml", "r");
113
		if ($fd) {
114
			while (!feof($fd)) {
115
				$line = fgets($fd);
116
				/* remove sensitive contents */
117
				foreach ($filtered_tags as $tag) {
118
					$line = preg_replace("/<{$tag}>.*?<\\/{$tag}>/", "<{$tag}>xxxxx</{$tag}>", $line);
119
				}
120
				/* remove ACME pkg sensitive contents */
121
				foreach ($acme_filtered_tags as $tag) {
122
					$line = preg_replace("/<dns_(.+){$tag}>.*?<\\/dns_(.+){$tag}>/", "<dns_$1{$tag}>xxxxx</dns_$1{$tag}>", $line);
123
				}
124
				if ($show_output) {
125
					echo htmlspecialchars(str_replace("\t", "    ", $line), ENT_NOQUOTES);
126
				}
127
				fwrite($ofd, $line);
128
			}
129
		}
130
		fclose($fd);
131
		fclose($ofd);
132
	} else {
133
		$execOutput = "";
134
		$execStatus = "";
135
		$fn = "{$output_path}/" . basename("{$title}.txt");
136
		if ($method == "exec") {
137
			exec($command . " > " . escapeshellarg($fn) . " 2>&1", $execOutput, $execStatus);
138
			if ($show_output) {
139
				$ofd = @fopen($fn, "r");
140
				if ($ofd) {
141
					while (!feof($ofd)) {
142
						echo htmlspecialchars(fgets($ofd), ENT_NOQUOTES);
143
					}
144
				}
145
				fclose($ofd);
146
			}
147
		} elseif ($method == "php_func") {
148
			$execOutput = $command();
149
			if ($show_output) {
150
				echo htmlspecialchars($execOutput, ENT_NOQUOTES);
151
			}
152
			file_put_contents($fn, $execOutput);
153
		}
154
	}
155

    
156
	if ($show_output) {
157
		print('</pre>');
158
		print('</div>');
159
		print('</div>');
160
	}
161
}
162

    
163
/* Define a command, with a title, to be executed later. */
164
function defCmdT($title, $command, $method = "exec") {
165
	global $commands;
166
	$title = htmlspecialchars($title, ENT_NOQUOTES);
167
	$commands[] = array($title, $command, $method);
168
}
169

    
170
/* List all of the commands as an index. */
171
function listCmds() {
172
	global $currentDate;
173
	global $commands;
174

    
175
	$rubbish = array('|', '-', '/', '.', ' ');	/* fixes the <a> tag to be W3C compliant */
176

    
177
	print('<div class="panel panel-default">');
178
	print('<div class="panel-heading"><h2 class="panel-title">' . sprintf(gettext("Firewall Status on %s"), $currentDate) . '</h2></div>');
179
	print('<div class="panel-body">');
180
	print('    <div class="content">');
181
	print("\n<p>" . gettext("This status page includes the following information") . ":\n");
182
	print("<ul>\n");
183
	for ($i = 0; isset($commands[$i]); $i++) {
184
		print("\t<li><strong><a href=\"#" . str_replace($rubbish, '', $commands[$i][0]) . "\">" . $commands[$i][0] . "</a></strong></li>\n");
185
	}
186

    
187
	print("</ul>\n");
188
	print('	       </div>');
189
	print('	   </div>');
190
	print('</div>');
191
}
192

    
193
/* Execute all of the commands which were defined by a call to defCmd. */
194
function execCmds() {
195
	global $commands;
196
	for ($i = 0; isset($commands[$i]); $i++) {
197
		doCmdT($commands[$i][0], $commands[$i][1], $commands[$i][2]);
198
	}
199
}
200

    
201
function get_firewall_info() {
202
	global $g, $output_path;
203
	/* Firewall Platform/Serial */
204
	$firewall_info = "Product Name: " . htmlspecialchars($g['product_label']);
205
	$platform = system_identify_specific_platform();
206
	if (!empty($platform['descr'])) {
207
		$firewall_info .= "<br/>Platform: " . htmlspecialchars($platform['descr']);
208
	}
209

    
210
	if (file_exists('/var/db/uniqueid')) {
211
		$ngid = file_get_contents('/var/db/uniqueid');
212
		if (!empty($ngid)) {
213
			$firewall_info .= "<br/>Netgate Device ID: " . htmlspecialchars($ngid);
214
		}
215
	}
216

    
217
	if (function_exists("system_get_thothid") &&
218
	    (php_uname("m") == "arm64")) {
219
		$thothid = system_get_thothid();
220
		if (!empty($thothid)) {
221
			$firewall_info .= "<br/>Netgate Crypto ID: " . htmlspecialchars(chop($thothid));
222
		}
223
	}
224

    
225
	$serial = system_get_serial();
226
	if (!empty($serial)) {
227
		$firewall_info .= "<br/>Serial: " . htmlspecialchars($serial);
228
	}
229

    
230
	if (!empty($g['product_version_string'])) {
231
		$firewall_info .= "<br/>" . htmlspecialchars($g['product_label']) .
232
		    " version: " . htmlspecialchars($g['product_version_string']);
233
	}
234

    
235
	if (file_exists('/etc/version.buildtime')) {
236
		$build_time = file_get_contents('/etc/version.buildtime');
237
		if (!empty($build_time)) {
238
			$firewall_info .= "<br/>Built On: " . htmlspecialchars($build_time);
239
		}
240
	}
241
	if (file_exists('/etc/version.lastcommit')) {
242
		$build_commit = file_get_contents('/etc/version.lastcommit');
243
		if (!empty($build_commit)) {
244
			$firewall_info .= "<br/>Last Commit: " . htmlspecialchars($build_commit);
245
		}
246
	}
247

    
248
	if (file_exists('/etc/version.gitsync')) {
249
		$gitsync = file_get_contents('/etc/version.gitsync');
250
		if (!empty($gitsync)) {
251
			$firewall_info .= "<br/>A gitsync was performed at " .
252
			    date("D M j G:i:s T Y", filemtime('/etc/version.gitsync')) .
253
			    " to commit " . htmlspecialchars($gitsync);
254
		}
255
	}
256

    
257
	file_put_contents("{$output_path}/Product-Info.txt", str_replace("<br/>", "\n", $firewall_info) . "\n");
258
	return $firewall_info;
259
}
260

    
261
function get_gateway_status() {
262
	return return_gateways_status_text(true, false);
263
}
264

    
265
global $g, $config;
266

    
267
/* Set up all of the commands we want to execute. */
268

    
269
/* OS stats/info */
270
if (function_exists("system_get_thothid") &&
271
    (php_uname("m") == "arm64")) {
272
	$thothid = system_get_thothid();
273
	if (!empty($thothid)) {
274
		defCmdT("Product-Public Key", "/usr/local/sbin/ping-auth -p");
275
	}
276
}
277

    
278
defCmdT("OS-Uptime", "/usr/bin/uptime");
279
defCmdT("Network-Interfaces", "/sbin/ifconfig -vvvvvam");
280
defCmdT("Network-Interface Statistics", "/usr/bin/netstat -nWi");
281
defCmdT("Process-Top Usage", "/usr/bin/top | /usr/bin/head -n5");
282
defCmdT("Process-List", "/bin/ps xauwwd");
283
defCmdT("Disk-Mounted Filesystems", "/sbin/mount");
284
defCmdT("Disk-Free Space", "/bin/df -hi");
285
defCmdT("Network-Routing tables", "/usr/bin/netstat -nWr");
286
defCmdT("Network-Gateway Status", 'get_gateway_status', "php_func");
287
defCmdT("Network-Mbuf Usage", "/usr/bin/netstat -mb");
288
defCmdT("Network-Protocol Statistics", "/usr/bin/netstat -s");
289
defCmdT("Network-Buffer and Timer Statistics", "/usr/bin/netstat -nWx");
290
defCmdT("Network-Listen Queues", "/usr/bin/netstat -LaAn");
291
defCmdT("Network-Sockets", "/usr/bin/sockstat");
292
defCmdT("Network-ARP Table", "/usr/sbin/arp -an");
293
defCmdT("Network-NDP Table", "/usr/sbin/ndp -na");
294
defCmdT("OS-Kernel Modules", "/sbin/kldstat -v");
295
defCmdT("OS-Kernel VMStat", "/usr/bin/vmstat -afimsz");
296

    
297
/* If a device has a switch, put the switch configuration in the status output */
298
if (file_exists("/dev/etherswitch0")) {
299
	defCmdT("Network-Switch Configuration", "/sbin/etherswitchcfg -f /dev/etherswitch0 info");
300
}
301

    
302
/* Firewall rules and info */
303
defCmdT("Firewall-Generated Ruleset", "/bin/cat {$g['tmp_path']}/rules.debug");
304
defCmdT("Firewall-Generated Ruleset Limiters", "/bin/cat {$g['tmp_path']}/rules.limiter");
305
defCmdT("Firewall-Generated Ruleset Limits", "/bin/cat {$g['tmp_path']}/rules.limits");
306
foreach (glob("{$g['tmp_path']}/rules.packages.*") as $pkgrules) {
307
	$pkgname = substr($pkgrules, strrpos($pkgrules, '.') + 1);
308
	defCmdT("Firewall-Generated Package Invalid Ruleset {$pkgname}", "/bin/cat " . escapeshellarg($pkgrules));
309
}
310
$ovpnradrules = array();
311
foreach (glob("{$g['tmp_path']}/ovpn_ovpns*.rules") as $ovpnrules) {
312
	if (preg_match('/ovpn_ovpns(\d+)\_(\w+)\_(\d+)\.rules/', basename($ovpnrules), $matches)) {
313
		$ovpnradrules[$matches[1]] .= "# user '{$matches[2]}' remote port {$matches[3]}\n";
314
		$ovpnradrules[$matches[1]] .= file_get_contents($ovpnrules);
315
		$ovpnradrules[$matches[1]] .= "\n";
316
	}
317
}
318
foreach ($ovpnradrules as $ovpns => $genrules) {
319
	defCmdT("OpenVPN-Generated RADIUS ACL Ruleset for server{$ovpns}",
320
	  "echo " .  escapeshellarg($genrules));
321
}
322
defCmdT("Firewall-pf NAT Rules", "/sbin/pfctl -vvsn");
323
defCmdT("Firewall-pf Firewall Rules", "/sbin/pfctl -vvsr");
324
defCmdT("Firewall-pf Tables", "/sbin/pfctl -vs Tables");
325
defCmdT("Firewall-pf State Table Contents", "/sbin/pfctl -vvss");
326
defCmdT("Firewall-pf Info", "/sbin/pfctl -si");
327
defCmdT("Firewall-pf Show All", "/sbin/pfctl -sa");
328
defCmdT("Firewall-pf Queues", "/sbin/pfctl -s queue -v");
329
defCmdT("Firewall-pf OSFP", "/sbin/pfctl -s osfp");
330
defCmdT("Firewall-pftop Default", "/usr/local/sbin/pftop -a -b");
331
defCmdT("Firewall-pftop Long", "/usr/local/sbin/pftop -w 150 -a -b -v long");
332
defCmdT("Firewall-pftop Queue", "/usr/local/sbin/pftop -w 150 -a -b -v queue");
333
defCmdT("Firewall-pftop Rules", "/usr/local/sbin/pftop -w 150 -a -b -v rules");
334
defCmdT("Firewall-pftop Size", "/usr/local/sbin/pftop -w 150 -a -b -v size");
335
defCmdT("Firewall-pftop Speed", "/usr/local/sbin/pftop -w 150 -a -b -v speed");
336
defCmdT("Firewall-Limiter Info", "/sbin/dnctl pipe show");
337
defCmdT("Firewall-Queue Info", "/sbin/dnctl queue show");
338

    
339
/* Configuration Files */
340
defCmdT("Disk-Contents of var run", "/bin/ls /var/run");
341
defCmdT("Disk-Contents of conf", "/bin/ls /conf");
342
defCmdT("config.xml", "dumpconfigxml");
343
defCmdT("DNS-Resolution Configuration", "/bin/cat /etc/resolv.conf");
344
defCmdT("DNS-Resolver Access Lists", "/bin/cat /var/unbound/access_lists.conf");
345
defCmdT("DNS-Resolver Configuration", "/bin/cat /var/unbound/unbound.conf");
346
defCmdT("DNS-Resolver Domain Overrides", "/bin/cat /var/unbound/domainoverrides.conf");
347
defCmdT("DNS-Resolver Host Overrides", "/bin/cat /var/unbound/host_entries.conf");
348
defCmdT("DHCP-IPv4 Configuration", '/usr/bin/sed "s/\([[:blank:]]secret \).*/\1<redacted>/" /var/dhcpd/etc/dhcpd.conf');
349
defCmdT("DHCP-IPv6-Configuration", '/usr/bin/sed "s/\([[:blank:]]secret \).*/\1<redacted>/" /var/dhcpd/etc/dhcpdv6.conf');
350
defCmdT("IPsec-strongSwan Configuration", '/usr/bin/sed "s/\([[:blank:]]secret = \).*/\1<redacted>/" /var/etc/ipsec/strongswan.conf');
351
defCmdT("IPsec-Configuration", '/usr/bin/sed -E "s/([[:blank:]]*(secret|pin) = ).*/\1<redacted>/" /var/etc/ipsec/swanctl.conf');
352
defCmdT("IPsec-Status-Statistics", "/usr/local/sbin/swanctl --stats --pretty");
353
defCmdT("IPsec-Status-Connections", "/usr/local/sbin/swanctl --list-conns");
354
defCmdT("IPsec-Status-Active SAs", "/usr/local/sbin/swanctl --list-sas");
355
defCmdT("IPsec-Status-Policies", "/usr/local/sbin/swanctl --list-pols");
356
defCmdT("IPsec-Status-Certificates", "/usr/local/sbin/swanctl --list-certs --utc");
357
defCmdT("IPsec-Status-Pools", "/usr/local/sbin/swanctl --list-pools --leases");
358
defCmdT("IPsec-SPD", "/sbin/setkey -DP");
359
defCmdT("IPsec-SAD", "/sbin/setkey -D");
360
if (file_exists("/cf/conf/upgrade_log.txt")) {
361
	defCmdT("OS-Upgrade Log", "/bin/cat /cf/conf/upgrade_log.txt");
362
}
363
if (file_exists("/cf/conf/upgrade_log.latest.txt")) {
364
	defCmdT("OS-Upgrade Log Latest", "/bin/cat /cf/conf/upgrade_log.latest.txt");
365
}
366
if (file_exists("/boot/loader.conf")) {
367
	defCmdT("OS-Boot Loader Configuration", "/bin/cat /boot/loader.conf");
368
}
369
if (file_exists("/boot/loader.conf.local")) {
370
	defCmdT("OS-Boot Loader Configuration (Local)", "/bin/cat /boot/loader.conf.local");
371
}
372
if (file_exists("/var/etc/filterdns.conf")) {
373
	defCmdT("DNS-filterdns Daemon Configuration", "/bin/cat /var/etc/filterdns.conf");
374
}
375

    
376
if (is_dir("/var/etc/openvpn")) {
377
	foreach(glob('/var/etc/openvpn/*/config.ovpn') as $file) {
378
		$ovpnfile = explode('/', $file);
379
		if (!count($ovpnfile) || (count($ovpnfile) < 6)) {
380
			continue;
381
		}
382
		defCmdT("OpenVPN-Configuration {$ovpnfile[4]}", "/bin/cat " . escapeshellarg($file));
383
	}
384
}
385

    
386
if (file_exists("/var/etc/l2tp-vpn/mpd.conf")) {
387
	defCmdT("L2TP-Configuration", '/usr/bin/sed -E "s/([[:blank:]](secret|radius server .*) ).*/\1<redacted>/" /var/etc/l2tp-vpn/mpd.conf');
388
}
389

    
390
/* Config History */
391
$confvers = get_backups();
392
unset($confvers['versions']);
393
if (count($confvers) != 0) {
394
	for ($c = count($confvers)-1; $c >= 0; $c--) {
395
		$conf_history .= backup_info($confvers[$c], $c+1);
396
		$conf_history .= "\n";
397
	}
398
	defCmdT("Config History", "echo " . escapeshellarg($conf_history));
399
}
400

    
401
/* Logs */
402
function status_add_log($name, $logfile, $number = 1000) {
403
	if (!file_exists($logfile)) {
404
		return;
405
	}
406
	$descr = "Log-{$name}";
407
	$tail = '';
408
	if ($number != "all") {
409
		$descr .= "-Last {$number} entries";
410
		$tail = ' | tail -n ' . escapeshellarg($number);
411
	}
412
	defCmdT($descr, system_log_get_cat() . ' ' . sort_related_log_files($logfile, true, true) . $tail);
413
}
414

    
415
status_add_log("System", '/var/log/system.log');
416
status_add_log("DHCP", '/var/log/dhcpd.log');
417
status_add_log("Filter", '/var/log/filter.log');
418
status_add_log("Gateways", '/var/log/gateways.log');
419
status_add_log("IPsec", '/var/log/ipsec.log');
420
status_add_log("L2TP", '/var/log/l2tps.log');
421
status_add_log("NTP", '/var/log/ntpd.log');
422
status_add_log("OpenVPN", '/var/log/openvpn.log');
423
status_add_log("Captive Portal Authentication", '/var/log/portalauth.log');
424
status_add_log("PPP", '/var/log/ppp.log');
425
status_add_log("PPPoE Server", '/var/log/poes.log');
426
status_add_log("DNS", '/var/log/resolver.log');
427
status_add_log("Routing", '/var/log/routing.log');
428
status_add_log("Wireless", '/var/log/wireless.log');
429
status_add_log("PHP Errors", '/tmp/PHP_errors.log', 'all');
430

    
431
defCmdT("OS-Message Buffer", "/sbin/dmesg -a");
432
defCmdT("OS-Message Buffer (Boot)", "/bin/cat /var/log/dmesg.boot");
433

    
434
/* OS/Hardware Status */
435
defCmdT("OS-sysctl values", "/sbin/sysctl -aq");
436
defCmdT("OS-Kernel Environment", "/bin/kenv");
437
defCmdT("OS-Kernel Memory Usage", "/usr/local/sbin/kmemusage.sh");
438
defCmdT("OS-Installed Packages", "/usr/local/sbin/pkg-static info");
439
defCmdT("OS-Package Manager Configuration", "/usr/local/sbin/pkg-static -vv");
440
defCmdT("Hardware-PCI Devices", "/usr/sbin/pciconf -lvb");
441
defCmdT("Hardware-USB Devices", "/usr/sbin/usbconfig dump_device_desc");
442

    
443
if (is_module_loaded("zfs.ko")) {
444
	defCmdT("Disk-ZFS List", "/sbin/zfs list");
445
	defCmdT("Disk-ZFS Properties", "/sbin/zfs get all");
446
	defCmdT("Disk-ZFS Pool List", "/sbin/zpool list");
447
	defCmdT("Disk-ZFS Pool Status", "/sbin/zpool status");
448
}
449
defCmdT("Disk-GEOM Mirror Status", "/sbin/gmirror status");
450

    
451
exec("/bin/date", $dateOutput, $dateStatus);
452
$currentDate = $dateOutput[0];
453

    
454
$pgtitle = array($g['product_label'], "Status");
455

    
456
if (!$console):
457
include("head.inc"); ?>
458

    
459
<form action="status.php" method="post">
460

    
461
<?php print_info_box(
462
	gettext("Make sure all sensitive information is removed! (Passwords, etc.) before posting information from this page in public places such as forum or social media sites.") .
463
	'<br />' .
464
	gettext("Common password and other private fields in config.xml have been automatically redacted.") .
465
	'<br />' .
466
	sprintf(gettext('When the page has finished loading, the output is stored in %1$s. It may be downloaded via scp or using this button: '), $output_file) .
467
	' <button name="submit" type="submit" class="btn btn-primary btn-sm" id="download" value="DOWNLOAD">' .
468
	'<i class="fa fa-download icon-embed-btn"></i>' .
469
	gettext("Download") .
470
	'</button>'); ?>
471

    
472
</form>
473

    
474
<?php print_info_box(get_firewall_info(), 'info', false);
475

    
476
if ($show_output) {
477
	listCmds();
478
} else {
479
	print_info_box(gettext("Status output suppressed. Download archive to view."), 'info', false);
480
}
481

    
482
endif;
483

    
484
if ($console) {
485
	print(gettext("Gathering status data...") . "\n");
486
	get_firewall_info();
487
}
488
execCmds();
489

    
490
print(gettext("Saving output to archive..."));
491

    
492
if (is_dir($output_path)) {
493
	mwexec("/usr/bin/tar czpf " . escapeshellarg($output_file) . " -C " . escapeshellarg(dirname($output_path)) . " " . escapeshellarg(basename($output_path)));
494

    
495
	if (!isset($_GET["nocleanup"])) {
496
		unlink_if_exists("{$output_path}/*");
497
		@rmdir($output_path);
498
	}
499
}
500

    
501
print(gettext("Done.") . "\n");
502

    
503
if (!$console) {
504
	include("foot.inc");
505
}
(150-150/228)