Project

General

Profile

Download (7.49 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	status_logs.php
4
*/
5
/* ====================================================================
6
 *  Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *
8
 *  Some or all of this file is based on the m0n0wall project which is
9
 *  Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10
 *
11
 *  Redistribution and use in source and binary forms, with or without modification,
12
 *  are permitted provided that the following conditions are met:
13
 *
14
 *  1. Redistributions of source code must retain the above copyright notice,
15
 *      this list of conditions and the following disclaimer.
16
 *
17
 *  2. Redistributions in binary form must reproduce the above copyright
18
 *      notice, this list of conditions and the following disclaimer in
19
 *      the documentation and/or other materials provided with the
20
 *      distribution.
21
 *
22
 *  3. All advertising materials mentioning features or use of this software
23
 *      must display the following acknowledgment:
24
 *      "This product includes software developed by the pfSense Project
25
 *       for use in the pfSense software distribution. (http://www.pfsense.org/).
26
 *
27
 *  4. The names "pfSense" and "pfSense Project" must not be used to
28
 *       endorse or promote products derived from this software without
29
 *       prior written permission. For written permission, please contact
30
 *       coreteam@pfsense.org.
31
 *
32
 *  5. Products derived from this software may not be called "pfSense"
33
 *      nor may "pfSense" appear in their names without prior written
34
 *      permission of the Electric Sheep Fencing, LLC.
35
 *
36
 *  6. Redistributions of any form whatsoever must retain the following
37
 *      acknowledgment:
38
 *
39
 *  "This product includes software developed by the pfSense Project
40
 *  for use in the pfSense software distribution (http://www.pfsense.org/).
41
 *
42
 *  THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
43
 *  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
45
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
46
 *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
48
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
51
 *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
52
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53
 *  OF THE POSSIBILITY OF SUCH DAMAGE.
54
 *
55
 *  ====================================================================
56
 *
57
 */
58

    
59
##|+PRIV
60
##|*IDENT=page-diagnostics-logs-system
61
##|*NAME=Status: Logs: System
62
##|*DESCR=Allow access to the 'Status: System Logs: General' page.
63
##|*MATCH=status_logs.php
64
##|-PRIV
65

    
66
require_once("status_logs_common.inc");
67

    
68

    
69
/*
70
Build a list of allowed log files so we can reject others to prevent the page
71
from acting on unauthorized files.
72
*/
73
$allowed_logs = array(
74
	"system" => array("name" => "General",
75
		    "shortcut" => ""),
76
	"dhcpd" => array("name" => "DHCP",
77
		    "shortcut" => "dhcp"),
78
	"portalauth" => array("name" => "Captive Portal Authentication",
79
		    "shortcut" => "captiveportal"),
80
	"ipsec" => array("name" => "IPsec",
81
		    "shortcut" => "ipsec"),
82
	"ppp" => array("name" => "PPP",
83
		    "shortcut" => ""),
84
	"relayd" => array("name" => "Load Balancer",
85
		    "shortcut" => "relayd"),
86
	"openvpn" => array("name" => "OpenVPN",
87
		    "shortcut" => "openvpn"),
88
	"ntpd" => array("name" => "NTPd",
89
		    "shortcut" => "ntp"),
90
	"gateways" => array("name" => "Gateways",
91
		    "shortcut" => "gateways"),
92
	"routing" => array("name" => "Routing",
93
		    "shortcut" => "routing"),
94
	"resolver" => array("name" => "DNS Resolver",
95
		    "shortcut" => "resolver"),
96
	"wireless" => array("name" => "Wireless",
97
		    "shortcut" => "wireless"),
98
);
99

    
100
// The logs to display are specified in a GET argument. Default to 'system' logs
101
if (!$_GET['logfile']) {
102
	$logfile = 'system';
103
} else {
104
	$logfile = $_GET['logfile'];
105
	if (!array_key_exists($logfile, $allowed_logs)) {
106
		/* Do not let someone attempt to load an unauthorized log. */
107
		$logfile = 'system';
108
	}
109
}
110

    
111

    
112
// Log Filter Submit - System
113
log_filter_form_system_submit();
114

    
115

    
116
// Manage Log Section - Code
117
manage_log_code();
118

    
119

    
120
// Status Logs Common - Code
121
status_logs_common_code();
122

    
123

    
124
if ($filtertext) {
125
	$filtertextmeta="?filtertext=$filtertext";
126
}
127

    
128
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"]));
129
include("head.inc");
130

    
131
if (!$input_errors && $savemsg) {
132
	print_info_box($savemsg);
133
	$manage_log_active = false;
134
}
135

    
136
// Tab Array
137
tab_array_logs_common();
138

    
139

    
140
// Filter Section/Form - System
141
filter_form_system();
142

    
143

    
144
// Now the forms are complete we can draw the log table and its controls
145
if (!$rawfilter) {
146
	if ($filterlogentries_submit) {
147
		$filterlog = conv_log_filter($logfile_path, $nentries, $nentries + 100, $filterfieldsarray);
148
	} else {
149
		$filterlog = conv_log_filter($logfile_path, $nentries, $nentries + 100, $filtertext);
150
	}
151
?>
152

    
153
<div class="panel panel-default">
154
	<div class="panel-heading">
155
		<h2 class="panel-title">
156
<?php
157
	if ((!$filtertext) && (!$filterfieldsarray)) {
158
		printf(gettext("Last %d %s log entries."), count($filterlog), gettext($allowed_logs[$logfile]["name"]));
159
	} else {
160
		printf(gettext("%d matched %s log entries."), count($filterlog), gettext($allowed_logs[$logfile]["name"]));
161
	}
162

    
163
	printf(" (" . gettext("Maximum %d") . ")", $nentries);
164
?>
165
		</h2>
166
	</div>
167
	<div class="panel-body">
168
	   <div class="table-responsive">
169
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
170
			<thead>
171
				<tr class="text-nowrap">
172
					<th><?=gettext("Time")?></th>
173
					<th><?=gettext("Process")?></th>
174
					<th><?=gettext("PID")?></th>
175
					<th style="width:100%"><?=gettext("Message")?></th>
176
				</tr>
177
			</thead>
178
			<tbody>
179
<?php
180
	foreach ($filterlog as $filterent) {
181
?>
182
				<tr class="text-nowrap">
183
					<td>
184
						<?=htmlspecialchars($filterent['time'])?>
185
					</td>
186
					<td>
187
						<?=htmlspecialchars($filterent['process'])?>
188
					</td>
189
					<td>
190
						<?=htmlspecialchars($filterent['pid'])?>
191
					</td>
192
					<td style="word-wrap:break-word; word-break:break-all; white-space:normal">
193
						<?=htmlspecialchars($filterent['message'])?>
194
					</td>
195
				</tr>
196
<?php
197
	} // e-o-foreach
198
?>
199
			</tbody>
200
		</table>
201
<?php
202
	if (count($filterlog) == 0) {
203
		print_info_box(gettext('No logs to display'));
204
	}
205
?>
206
		</div>
207
	</div>
208
</div>
209
<?php
210
} else {
211
?>
212
<div class="panel panel-default">
213
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Last ")?><?=$nentries?> <?=gettext($allowed_logs[$logfile]["name"])?><?=gettext(" log entries")?></h2></div>
214
	<div class="table table-responsive">
215
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
216
			<thead>
217
				<tr class="text-nowrap">
218
					<th><?=gettext("Time")?></th>
219
					<th style="width:100%"><?=gettext("Message")?></th>
220
				</tr>
221
			</thead>
222
			<tbody>
223
<?php
224
	if (($logfile == 'resolver') || ($logfile == 'system')) {
225
		$inverse = array("ppp");
226
	} else {
227
		$inverse = null;
228
	}
229

    
230
	if ($filtertext) {
231
		$rows = dump_clog($logfile_path, $nentries, true, array("$filtertext"), $inverse);
232
	} else {
233
		$rows = dump_clog($logfile_path, $nentries, true, array(), $inverse);
234
	}
235
?>
236
			</tbody>
237
		</table>
238
<?php
239
	if ($rows == 0) {
240
		print_info_box(gettext('No logs to display'));
241
	}
242
?>
243
	</div>
244
</div>
245
<?php
246
}
247
?>
248

    
249
<?php
250
# Manage Log - Section/Form
251
manage_log_section();
252
?>
253

    
254
<?php include("foot.inc"); ?>
(170-170/229)