Project

General

Profile

Download (6.35 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * status_logs.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-2020 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14
 *
15
 * Licensed under the Apache License, Version 2.0 (the "License");
16
 * you may not use this file except in compliance with the License.
17
 * You may obtain a copy of the License at
18
 *
19
 * http://www.apache.org/licenses/LICENSE-2.0
20
 *
21
 * Unless required by applicable law or agreed to in writing, software
22
 * distributed under the License is distributed on an "AS IS" BASIS,
23
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
 * See the License for the specific language governing permissions and
25
 * limitations under the License.
26
 */
27

    
28
##|+PRIV
29
##|*IDENT=page-diagnostics-logs-system
30
##|*NAME=Status: Logs: System
31
##|*DESCR=Allow access to the 'Status: System Logs: General' page.
32
##|*MATCH=status_logs.php
33
##|-PRIV
34

    
35
require_once("status_logs_common.inc");
36

    
37

    
38
/*
39
Build a list of allowed log files so we can reject others to prevent the page
40
from acting on unauthorized files.
41
*/
42
$allowed_logs = array(
43
	"system" => array("name" => gettext("General"),
44
		    "shortcut" => ""),
45
	"dhcpd" => array("name" => gettext("DHCP"),
46
		    "shortcut" => "dhcp"),
47
	"auth" => array("name" => gettext("General"),
48
		    "shortcut" => ""),
49
	"portalauth" => array("name" => gettext("Captive Portal Auth"),
50
		    "shortcut" => "captiveportal"),
51
	"ipsec" => array("name" => gettext("IPsec"),
52
		    "shortcut" => "ipsec"),
53
	"ppp" => array("name" => gettext("PPP"),
54
		    "shortcut" => ""),
55
	"openvpn" => array("name" => gettext("OpenVPN"),
56
		    "shortcut" => "openvpn"),
57
	"ntpd" => array("name" => gettext("NTP"),
58
		    "shortcut" => "ntp"),
59
	"gateways" => array("name" => gettext("Gateways"),
60
		    "shortcut" => "gateways"),
61
	"routing" => array("name" => gettext("Routing"),
62
		    "shortcut" => "routing"),
63
	"resolver" => array("name" => gettext("DNS Resolver"),
64
		    "shortcut" => "resolver"),
65
	"wireless" => array("name" => gettext("Wireless"),
66
		    "shortcut" => "wireless"),
67
	"nginx" => array("name" => gettext("GUI Service"),
68
		    "shortcut" => ""),
69
	"dmesg.boot" => array("name" => gettext("OS Boot"),
70
		    "shortcut" => ""),
71
	"utx" => array("name" => gettext("OS User Events"),
72
		    "shortcut" => ""),
73
	"userlog" => array("name" => gettext("OS Account Changes"),
74
		    "shortcut" => ""),
75
);
76

    
77
// The logs to display are specified in a REQUEST argument. Default to 'system' logs
78
if (!$_REQUEST['logfile']) {
79
	$logfile = 'system';
80
} else {
81
	$logfile = $_REQUEST['logfile'];
82
	if (!array_key_exists($logfile, $allowed_logs)) {
83
		/* Do not let someone attempt to load an unauthorized log. */
84
		$logfile = 'system';
85
	}
86
}
87

    
88

    
89
// Log Filter Submit - System
90
log_filter_form_system_submit();
91

    
92

    
93
// Manage Log Section - Code
94
manage_log_code();
95

    
96

    
97
// Status Logs Common - Code
98
status_logs_common_code();
99

    
100

    
101
if ($filtertext) {
102
	$filtertextmeta="?filtertext=$filtertext";
103
}
104

    
105
if (in_array($logfile, array('system', 'gateways', 'routing', 'resolver', 'wireless', 'nginx', 'dmesg.boot'))) {
106
	$pgtitle = array(gettext("Status"), gettext("System Logs"), gettext("System"), $allowed_logs[$logfile]["name"]);
107
	$pglinks = array("", "status_logs.php", "status_logs.php", "@self");
108
} elseif (in_array($logfile, array('auth', 'portalauth', 'utx', 'userlog'))) {
109
	$pgtitle = array(gettext("Status"), gettext("System Logs"), gettext("Authentication"), $allowed_logs[$logfile]["name"]);
110
	$pglinks = array("", "status_logs.php", "status_logs.php", "@self");
111
} else {
112
	$pgtitle = array(gettext("Status"), gettext("System Logs"), $allowed_logs[$logfile]["name"]);
113
	$pglinks = array("", "status_logs.php", "@self");
114
}
115

    
116
if (in_array($logfile, array('userlog', 'dmesg.boot'))) {
117
	$rawfilter = true;
118
}
119

    
120
include("head.inc");
121

    
122
if ($changes_applied) {
123
	print_apply_result_box($retval, $extra_save_msg);
124
	$manage_log_active = false;
125
}
126

    
127
// Tab Array
128
tab_array_logs_common();
129

    
130
// Manage Log - Section/Form
131
if ($system_logs_manage_log_form_hidden) {
132
	manage_log_section();
133
}
134

    
135
// Filter Section/Form - System
136
filter_form_system();
137
if (($logfile == 'resolver') || ($logfile == 'system')) {
138
	$inverse = array("ppp");
139
} else {
140
	$inverse = null;
141
}
142
if (!$rawfilter) {
143
	system_log_filter();
144
}
145

    
146
?>
147

    
148
<div class="panel panel-default">
149
	<div class="panel-heading">
150
		<h2 class="panel-title">
151
<?php print(system_log_table_panel_title()); ?>
152
		</h2>
153
	</div>
154
	<div class="panel-body">
155
	    <div class="table-responsive">
156
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
157
<?php if ($logfile == 'utx'): ?>
158
			<thead>
159
				<tr class="text-nowrap">
160
					<th><?=gettext("Login Time")?></th>
161
					<th><?=gettext("Duration")?></th>
162
					<th><?=gettext("TTY")?></th>
163
					<th style="width:100%"><?=gettext("User/Message")?></th>
164
				</tr>
165
			</thead>
166
<?php elseif ($rawfilter): ?>
167
			<thead>
168
				<tr class="text-nowrap">
169
					<th><?=gettext("Time")?></th>
170
					<th style="width:100%"><?=gettext("Message")?></th>
171
				</tr>
172
			</thead>
173
<?php else: ?>
174
			<thead>
175
				<tr class="text-nowrap">
176
					<th><?=gettext("Time")?></th>
177
					<th><?=gettext("Process")?></th>
178
					<th><?=gettext("PID")?></th>
179
					<th style="width:100%"><?=gettext("Message")?></th>
180
				</tr>
181
			</thead>
182
<?php endif; ?>
183

    
184
			<tbody>
185
<?php if (!$rawfilter): ?>
186
<?php	foreach ($filterlog as $filterent): ?>
187
				<tr class="text-nowrap">
188
					<td>
189
						<?=htmlspecialchars($filterent['time'])?>
190
					</td>
191
					<td>
192
						<?=htmlspecialchars($filterent['process'])?>
193
					</td>
194
					<td>
195
						<?=htmlspecialchars($filterent['pid'])?>
196
					</td>
197
					<td style="word-wrap:break-word; word-break:break-all; white-space:normal">
198
						<?=htmlspecialchars($filterent['message'])?>
199
					</td>
200
				</tr>
201
<?php	endforeach; ?>
202
<?php else:
203
	system_log_filter(); ?>
204
<?php endif; ?>
205
			</tbody>
206
		</table>
207
<?php if ($rawfilter): ?>
208
<script type="text/javascript">
209
//<![CDATA[
210
events.push(function() {
211
	$("#count").html(<?=$rows?>);
212
});
213
//]]>
214
</script>
215
<?php else:
216
	$rows = count($filterlog); ?>
217
<?php endif; ?>
218
<?php
219
	if ($rows == 0) {
220
		print_info_box(gettext('No logs to display.'));
221
	}
222
?>
223
		</div>
224
	</div>
225
</div>
226
<?php
227

    
228
# Manage Log - Section/Form
229
if (!$system_logs_manage_log_form_hidden) {
230
	manage_log_section();
231
}
232
?>
233

    
234
<?php include("foot.inc"); ?>
(169-169/227)