Project

General

Profile

Download (6.32 KB) Statistics
| Branch: | Tag: | Revision:
1 cfc707f7 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 c5d81585 Renato Botelho
 * status_logs.php
4 fd9ebcd5 Stephen Beaver
 *
5 c5d81585 Renato Botelho
 * part of pfSense (https://www.pfsense.org)
6 38809d47 Renato Botelho do Couto
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8 a68f7a3d Luiz Otavio O Souza
 * Copyright (c) 2014-2024 Rubicon Communications, LLC (Netgate)
9 c5d81585 Renato Botelho
 * All rights reserved.
10 fd9ebcd5 Stephen Beaver
 *
11 c5d81585 Renato Botelho
 * originally based on m0n0wall (http://m0n0.ch/wall)
12
 * Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
13
 * All rights reserved.
14 fd9ebcd5 Stephen Beaver
 *
15 b12ea3fb Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 *
19 b12ea3fb Renato Botelho
 * http://www.apache.org/licenses/LICENSE-2.0
20 fd9ebcd5 Stephen Beaver
 *
21 b12ea3fb Renato Botelho
 * 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 fd9ebcd5 Stephen Beaver
 */
27 5b237745 Scott Ullrich
28 6b07c15a Matthew Grooms
##|+PRIV
29
##|*IDENT=page-diagnostics-logs-system
30 5230f468 jim-p
##|*NAME=Status: Logs: System
31 0b8328c5 jim-p
##|*DESCR=Allow access to the 'Status: System Logs: General' page.
32 1af5edbf Stephen Beaver
##|*MATCH=status_logs.php
33 6b07c15a Matthew Grooms
##|-PRIV
34
35 55f8344d NOYB
require_once("status_logs_common.inc");
36
37 5b237745 Scott Ullrich
38 d8af270c jim-p
/*
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 3bd74348 bruno
	"system" => array("name" => gettext("General"),
44 d8af270c jim-p
		    "shortcut" => ""),
45 3bd74348 bruno
	"dhcpd" => array("name" => gettext("DHCP"),
46 d8af270c jim-p
		    "shortcut" => "dhcp"),
47 49967ae7 jim-p
	"auth" => array("name" => gettext("General"),
48
		    "shortcut" => ""),
49 44c0a159 k-paulius
	"portalauth" => array("name" => gettext("Captive Portal Auth"),
50 d8af270c jim-p
		    "shortcut" => "captiveportal"),
51 3bd74348 bruno
	"ipsec" => array("name" => gettext("IPsec"),
52 d8af270c jim-p
		    "shortcut" => "ipsec"),
53 3bd74348 bruno
	"ppp" => array("name" => gettext("PPP"),
54 d8af270c jim-p
		    "shortcut" => ""),
55 3bd74348 bruno
	"openvpn" => array("name" => gettext("OpenVPN"),
56 d8af270c jim-p
		    "shortcut" => "openvpn"),
57 44c0a159 k-paulius
	"ntpd" => array("name" => gettext("NTP"),
58 d8af270c jim-p
		    "shortcut" => "ntp"),
59 3bd74348 bruno
	"gateways" => array("name" => gettext("Gateways"),
60 d8af270c jim-p
		    "shortcut" => "gateways"),
61 3bd74348 bruno
	"routing" => array("name" => gettext("Routing"),
62 d8af270c jim-p
		    "shortcut" => "routing"),
63 3bd74348 bruno
	"resolver" => array("name" => gettext("DNS Resolver"),
64 d8af270c jim-p
		    "shortcut" => "resolver"),
65 3bd74348 bruno
	"wireless" => array("name" => gettext("Wireless"),
66 d8af270c jim-p
		    "shortcut" => "wireless"),
67 db948c42 jim-p
	"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 d8af270c jim-p
);
76
77 1a8b6554 Steve Beaver
// The logs to display are specified in a REQUEST argument. Default to 'system' logs
78
if (!$_REQUEST['logfile']) {
79 0a5d0b7b sbeaver
	$logfile = 'system';
80 d8af270c jim-p
} else {
81 1a8b6554 Steve Beaver
	$logfile = $_REQUEST['logfile'];
82 d8af270c jim-p
	if (!array_key_exists($logfile, $allowed_logs)) {
83
		/* Do not let someone attempt to load an unauthorized log. */
84
		$logfile = 'system';
85
	}
86
}
87 0a5d0b7b sbeaver
88 76af8cdb NOYB
89 55f8344d NOYB
// Log Filter Submit - System
90
log_filter_form_system_submit();
91 76af8cdb NOYB
92
93 55f8344d NOYB
// Manage Log Section - Code
94
manage_log_code();
95 5b237745 Scott Ullrich
96
97 0039dab0 NOYB
// Status Logs Common - Code
98
status_logs_common_code();
99 0541e302 Scott Ullrich
100
101 5f601060 Phil Davis
if ($filtertext) {
102 36a166de Scott Ullrich
	$filtertextmeta="?filtertext=$filtertext";
103 5f601060 Phil Davis
}
104 59769c23 Scott Ullrich
105 db948c42 jim-p
if (in_array($logfile, array('system', 'gateways', 'routing', 'resolver', 'wireless', 'nginx', 'dmesg.boot'))) {
106 44c0a159 k-paulius
	$pgtitle = array(gettext("Status"), gettext("System Logs"), gettext("System"), $allowed_logs[$logfile]["name"]);
107 edcd7535 Phil Davis
	$pglinks = array("", "status_logs.php", "status_logs.php", "@self");
108 49967ae7 jim-p
} elseif (in_array($logfile, array('auth', 'portalauth', 'utx', 'userlog'))) {
109 db948c42 jim-p
	$pgtitle = array(gettext("Status"), gettext("System Logs"), gettext("Authentication"), $allowed_logs[$logfile]["name"]);
110
	$pglinks = array("", "status_logs.php", "status_logs.php", "@self");
111 44c0a159 k-paulius
} else {
112
	$pgtitle = array(gettext("Status"), gettext("System Logs"), $allowed_logs[$logfile]["name"]);
113 edcd7535 Phil Davis
	$pglinks = array("", "status_logs.php", "@self");
114 44c0a159 k-paulius
}
115 db948c42 jim-p
116
if (in_array($logfile, array('userlog', 'dmesg.boot'))) {
117
	$rawfilter = true;
118
}
119
120 b63695db Scott Ullrich
include("head.inc");
121
122 44c42356 Phil Davis
if ($changes_applied) {
123
	print_apply_result_box($retval, $extra_save_msg);
124 76af8cdb NOYB
	$manage_log_active = false;
125
}
126
127 55f8344d NOYB
// Tab Array
128
tab_array_logs_common();
129 33d52df1 sbeaver
130 c05363c8 NOYB
// Manage Log - Section/Form
131
if ($system_logs_manage_log_form_hidden) {
132
	manage_log_section();
133
}
134
135 55f8344d NOYB
// Filter Section/Form - System
136
filter_form_system();
137 ee4390ff jim-p
if (($logfile == 'resolver') || ($logfile == 'system')) {
138
	$inverse = array("ppp");
139
} else {
140
	$inverse = null;
141
}
142 76af8cdb NOYB
if (!$rawfilter) {
143 dc14d2b0 NOYB
	system_log_filter();
144 ee4390ff jim-p
}
145
146 e0977fed smos
?>
147 9279147a Stephen Beaver
148 e3efcb23 NOYB
<div class="panel panel-default">
149
	<div class="panel-heading">
150
		<h2 class="panel-title">
151 ee4390ff jim-p
<?php print(system_log_table_panel_title()); ?>
152 e3efcb23 NOYB
		</h2>
153
	</div>
154
	<div class="panel-body">
155 ee4390ff jim-p
	    <div class="table-responsive">
156 b9db8882 NOYB
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
157 ee4390ff jim-p
<?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 style="width:100%"><?=gettext("Message")?></th>
170
				</tr>
171
			</thead>
172
<?php else: ?>
173 b9db8882 NOYB
			<thead>
174 b77cef66 Colin Fleming
				<tr class="text-nowrap">
175 b9db8882 NOYB
					<th><?=gettext("Time")?></th>
176
					<th><?=gettext("Process")?></th>
177 13474eee NOYB
					<th><?=gettext("PID")?></th>
178
					<th style="width:100%"><?=gettext("Message")?></th>
179 b9db8882 NOYB
				</tr>
180
			</thead>
181 ee4390ff jim-p
<?php endif; ?>
182
183 b9db8882 NOYB
			<tbody>
184 ee4390ff jim-p
<?php if (!$rawfilter): ?>
185
<?php	foreach ($filterlog as $filterent): ?>
186 b77cef66 Colin Fleming
				<tr class="text-nowrap">
187 13474eee NOYB
					<td>
188 b9db8882 NOYB
						<?=htmlspecialchars($filterent['time'])?>
189
					</td>
190 13474eee NOYB
					<td>
191 b9db8882 NOYB
						<?=htmlspecialchars($filterent['process'])?>
192
					</td>
193 13474eee NOYB
					<td>
194 b9db8882 NOYB
						<?=htmlspecialchars($filterent['pid'])?>
195
					</td>
196
					<td style="word-wrap:break-word; word-break:break-all; white-space:normal">
197
						<?=htmlspecialchars($filterent['message'])?>
198
					</td>
199
				</tr>
200 ee4390ff jim-p
<?php	endforeach; ?>
201
<?php else:
202
	system_log_filter(); ?>
203
<?php endif; ?>
204 be5bacfd NOYB
			</tbody>
205 e3efcb23 NOYB
		</table>
206 ee4390ff jim-p
<?php if ($rawfilter): ?>
207 7345fad6 NOYB
<script type="text/javascript">
208
//<![CDATA[
209
events.push(function() {
210
	$("#count").html(<?=$rows?>);
211
});
212
//]]>
213
</script>
214 ee4390ff jim-p
<?php else:
215
	$rows = count($filterlog); ?>
216
<?php endif; ?>
217 e3efcb23 NOYB
<?php
218 abe98adb Phil Davis
	if ($rows == 0) {
219 8545adde k-paulius
		print_info_box(gettext('No logs to display.'));
220 abe98adb Phil Davis
	}
221 76af8cdb NOYB
?>
222 ee4390ff jim-p
		</div>
223 76af8cdb NOYB
	</div>
224
</div>
225
<?php
226 e3efcb23 NOYB
227 76af8cdb NOYB
# Manage Log - Section/Form
228 c05363c8 NOYB
if (!$system_logs_manage_log_form_hidden) {
229
	manage_log_section();
230
}
231 e3efcb23 NOYB
?>
232 33d52df1 sbeaver
233 9bd56e9d Christian McDonald
<?php
234
include("foot.inc");