Project

General

Profile

Download (6.27 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-2019 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
	"portalauth" => array("name" => gettext("Captive Portal Auth"),
48
		    "shortcut" => "captiveportal"),
49
	"ipsec" => array("name" => gettext("IPsec"),
50
		    "shortcut" => "ipsec"),
51
	"ppp" => array("name" => gettext("PPP"),
52
		    "shortcut" => ""),
53
	"openvpn" => array("name" => gettext("OpenVPN"),
54
		    "shortcut" => "openvpn"),
55
	"ntpd" => array("name" => gettext("NTP"),
56
		    "shortcut" => "ntp"),
57
	"gateways" => array("name" => gettext("Gateways"),
58
		    "shortcut" => "gateways"),
59
	"routing" => array("name" => gettext("Routing"),
60
		    "shortcut" => "routing"),
61
	"resolver" => array("name" => gettext("DNS Resolver"),
62
		    "shortcut" => "resolver"),
63
	"wireless" => array("name" => gettext("Wireless"),
64
		    "shortcut" => "wireless"),
65
	"nginx" => array("name" => gettext("GUI Service"),
66
		    "shortcut" => ""),
67
	"dmesg.boot" => array("name" => gettext("OS Boot"),
68
		    "shortcut" => ""),
69
	"utx" => array("name" => gettext("OS User Events"),
70
		    "shortcut" => ""),
71
	"userlog" => array("name" => gettext("OS Account Changes"),
72
		    "shortcut" => ""),
73
);
74

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

    
86

    
87
// Log Filter Submit - System
88
log_filter_form_system_submit();
89

    
90

    
91
// Manage Log Section - Code
92
manage_log_code();
93

    
94

    
95
// Status Logs Common - Code
96
status_logs_common_code();
97

    
98

    
99
if ($filtertext) {
100
	$filtertextmeta="?filtertext=$filtertext";
101
}
102

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

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

    
118
include("head.inc");
119

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

    
125
// Tab Array
126
tab_array_logs_common();
127

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

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

    
144
?>
145

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

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

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

    
232
<?php include("foot.inc"); ?>
(168-168/225)