Project

General

Profile

Download (19.9 KB) Statistics
| Branch: | Tag: | Revision:
1 cfc707f7 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3 1af5edbf Stephen Beaver
	status_logs.php
4 5b237745 Scott Ullrich
*/
5 fd9ebcd5 Stephen Beaver
/* ====================================================================
6 0da0d43e Phil Davis
 *  Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 9da2cf1c Stephen Beaver
 *
8 c9df279d Stephen Beaver
 *  Some or all of this file is based on the m0n0wall project which is
9 9da2cf1c Stephen Beaver
 *  Copyright (c)  2004 Manuel Kasper (BSD 2 clause)
10 fd9ebcd5 Stephen Beaver
 *
11 0da0d43e Phil Davis
 *  Redistribution and use in source and binary forms, with or without modification,
12
 *  are permitted provided that the following conditions are met:
13 fd9ebcd5 Stephen Beaver
 *
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 0da0d43e Phil Davis
 *      distribution.
21 fd9ebcd5 Stephen Beaver
 *
22 0da0d43e Phil Davis
 *  3. All advertising materials mentioning features or use of this software
23 fd9ebcd5 Stephen Beaver
 *      must display the following acknowledgment:
24
 *      "This product includes software developed by the pfSense Project
25 0da0d43e Phil Davis
 *       for use in the pfSense software distribution. (http://www.pfsense.org/).
26 fd9ebcd5 Stephen Beaver
 *
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 0da0d43e Phil Davis
 *
42 fd9ebcd5 Stephen Beaver
 *  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 5b237745 Scott Ullrich
59 0a5d0b7b sbeaver
/*
60 13d193c2 Scott Ullrich
	pfSense_MODULE:	system
61
*/
62
63 6b07c15a Matthew Grooms
##|+PRIV
64
##|*IDENT=page-diagnostics-logs-system
65 5230f468 jim-p
##|*NAME=Status: Logs: System
66 0b8328c5 jim-p
##|*DESCR=Allow access to the 'Status: System Logs: General' page.
67 1af5edbf Stephen Beaver
##|*MATCH=status_logs.php
68 6b07c15a Matthew Grooms
##|-PRIV
69
70 5b237745 Scott Ullrich
require("guiconfig.inc");
71 e3efcb23 NOYB
require_once("filter_log.inc");
72 5b237745 Scott Ullrich
73 d8af270c jim-p
/*
74
Build a list of allowed log files so we can reject others to prevent the page
75
from acting on unauthorized files.
76
*/
77
$allowed_logs = array(
78
	"system" => array("name" => "General",
79
		    "shortcut" => ""),
80
	"dhcpd" => array("name" => "DHCP",
81
		    "shortcut" => "dhcp"),
82
	"portalauth" => array("name" => "Captive Portal Authentication",
83
		    "shortcut" => "captiveportal"),
84
	"ipsec" => array("name" => "IPsec",
85
		    "shortcut" => "ipsec"),
86
	"ppp" => array("name" => "PPP",
87
		    "shortcut" => ""),
88
	"relayd" => array("name" => "Load Balancer",
89
		    "shortcut" => "relayd"),
90
	"openvpn" => array("name" => "OpenVPN",
91
		    "shortcut" => "openvpn"),
92
	"ntpd" => array("name" => "NTPd",
93
		    "shortcut" => "ntp"),
94
	"gateways" => array("name" => "Gateways",
95
		    "shortcut" => "gateways"),
96
	"routing" => array("name" => "Routing",
97
		    "shortcut" => "routing"),
98
	"resolver" => array("name" => "DNS Resolver",
99
		    "shortcut" => "resolver"),
100
	"wireless" => array("name" => "Wireless",
101
		    "shortcut" => "wireless"),
102
);
103
104 0a5d0b7b sbeaver
// The logs to display are specified in a GET argument. Default to 'system' logs
105 d8af270c jim-p
if (!$_GET['logfile']) {
106 0a5d0b7b sbeaver
	$logfile = 'system';
107 d8af270c jim-p
} else {
108 0a5d0b7b sbeaver
	$logfile = $_GET['logfile'];
109 d8af270c jim-p
	if (!array_key_exists($logfile, $allowed_logs)) {
110
		/* Do not let someone attempt to load an unauthorized log. */
111
		$logfile = 'system';
112
	}
113
}
114 0a5d0b7b sbeaver
115 76af8cdb NOYB
$system_logfile = "{$g['varlog_path']}/" . basename($logfile) . ".log";
116
117
118 e3efcb23 NOYB
function getGETPOSTsettingvalue($settingname, $default) {
119
	$settingvalue = $default;
120
	if ($_GET[$settingname]) {
121
		$settingvalue = $_GET[$settingname];
122
	}
123
	if ($_POST[$settingname]) {
124
		$settingvalue = $_POST[$settingname];
125
	}
126
	return $settingvalue;
127
}
128
129 76af8cdb NOYB
130 e3efcb23 NOYB
$filtersubmit = getGETPOSTsettingvalue('filtersubmit', null);
131
132
if ($filtersubmit) {
133 76af8cdb NOYB
	$filter_active = true;
134 e3efcb23 NOYB
	$filtertext = getGETPOSTsettingvalue('filtertext', "");
135
	$filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null);
136
}
137
138
$filterlogentries_submit = getGETPOSTsettingvalue('filterlogentries_submit', null);
139
140
if ($filterlogentries_submit) {
141 76af8cdb NOYB
	$filter_active = true;
142 e3efcb23 NOYB
	$filterfieldsarray = array();
143
144
	$filterfieldsarray['time'] = getGETPOSTsettingvalue('filterlogentries_time', null);
145
	$filterfieldsarray['process'] = getGETPOSTsettingvalue('filterlogentries_process', null);
146
	$filterfieldsarray['pid'] = getGETPOSTsettingvalue('filterlogentries_pid', null);
147
	$filterfieldsarray['message'] = getGETPOSTsettingvalue('filterlogentries_message', null);
148
	$filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null);
149
}
150
151 963d5343 Bill Marquette
152 76af8cdb NOYB
# Manage Log - Code
153
154
$specific_log = basename($logfile) . '_settings';
155
156 95acc890 NOYB
# All
157 76af8cdb NOYB
$pconfig['cronorder'] = $config['syslog'][$specific_log]['cronorder'];
158
$pconfig['nentries'] = $config['syslog'][$specific_log]['nentries'];
159
$pconfig['logfilesize'] = $config['syslog'][$specific_log]['logfilesize'];
160
$pconfig['format'] = $config['syslog'][$specific_log]['format'];
161 95acc890 NOYB
162
# System General (main) Specific
163 76af8cdb NOYB
$pconfig['loglighttpd'] = !isset($config['syslog']['nologlighttpd']);
164
165
$save_settings = getGETPOSTsettingvalue('save_settings', null);
166
167
if ($save_settings) {
168 95acc890 NOYB
169
	# All
170 76af8cdb NOYB
	$cronorder = getGETPOSTsettingvalue('cronorder',  null);
171
	$nentries = getGETPOSTsettingvalue('nentries', null);
172
	$logfilesize = getGETPOSTsettingvalue('logfilesize', null);
173
	$format  = getGETPOSTsettingvalue('format',  null);
174 95acc890 NOYB
175
	# System General (main) Specific
176 76af8cdb NOYB
	$loglighttpd  = getGETPOSTsettingvalue('loglighttpd',  null);
177
178
	unset($input_errors);
179
	$pconfig = $_POST;
180
181
	/* input validation */
182 95acc890 NOYB
	# All
183 76af8cdb NOYB
	if (isset($nentries) && (strlen($nentries) > 0)) {
184
		if (!is_numeric($nentries) || ($nentries < 5) || ($nentries > 2000)) {
185
			$input_errors[] = gettext("Number of log entries to show must be between 5 and 2000.");
186
		}
187
	}
188
189
	if (isset($logfilesize) && (strlen($logfilesize) > 0)) {
190
		if (!is_numeric($logfilesize) || ($logfilesize < 100000)) {
191
			$input_errors[] = gettext("Log file size must be numeric and greater than or equal to 100000.");
192
		}
193
	}
194
195
	if (!$input_errors) {
196
197
		# Clear out the specific log settings and leave only the applied settings to override the general logging options (global) settings.
198
		unset($config['syslog'][$specific_log]);
199
200 95acc890 NOYB
	# All
201 76af8cdb NOYB
		if ($cronorder != '') { # if not using the general logging options setting (global)
202
			$config['syslog'][$specific_log]['cronorder'] = $cronorder;
203
		}
204
205
		if (isset($nentries) && (strlen($nentries) > 0)) {
206
			$config['syslog'][$specific_log]['nentries'] = (int)$nentries;
207
		}
208
209
		if (isset($logfilesize) && (strlen($logfilesize) > 0)) {
210
			$config['syslog'][$specific_log]['logfilesize'] = (int)$logfilesize;
211
		}
212
213
		if ($format != '') { # if not using the general logging options setting (global)
214
			$config['syslog'][$specific_log]['format'] = $format;
215
		}
216
217 95acc890 NOYB
	# System General (main) Specific
218 76af8cdb NOYB
		if ($logfile == 'system') {
219 95acc890 NOYB
			$oldnologlighttpd = isset($config['syslog']['nologlighttpd']);
220 76af8cdb NOYB
			$config['syslog']['nologlighttpd'] = $loglighttpd ? false : true;
221
		}
222
223 95acc890 NOYB
224
		write_config($desc = "Log Display Settings Saved: " . gettext($allowed_logs[$logfile]["name"]));
225 76af8cdb NOYB
226
		$retval = 0;
227
		$savemsg = get_std_save_message($retval);
228
229 95acc890 NOYB
	# System General (main) Specific
230
		if ($logfile == 'system') {
231
			if ($oldnologlighttpd !== isset($config['syslog']['nologlighttpd'])) {
232
				ob_flush();
233
				flush();
234
				log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator."));
235
				send_event("service restart webgui");
236
				$savemsg .= "<br />" . gettext("WebGUI process is restarting.");
237
			}
238 76af8cdb NOYB
		}
239
	}
240
}
241
242
243
# Formatted/Raw Display
244
if ($config['syslog'][$specific_log]['format'] == 'formatted') {
245
	$rawfilter = false;
246
}
247
else if ($config['syslog'][$specific_log]['format'] == 'raw') {
248
	$rawfilter = true;
249
}	
250
else {	# Use the general logging options setting (global).
251
	$rawfilter = isset($config['syslog']['rawfilter']);
252
}
253
254
255
isset($config['syslog'][$specific_log]['nentries']) ? $nentries = $config['syslog'][$specific_log]['nentries'] : $nentries = $config['syslog']['nentries'];
256 5b237745 Scott Ullrich
257 e3efcb23 NOYB
# Override Display Quantity
258
if ($filterlogentries_qty) {
259
	$nentries = $filterlogentries_qty;
260 5f601060 Phil Davis
}
261 5b237745 Scott Ullrich
262 e3efcb23 NOYB
if (!$nentries || !is_numeric($nentries)) {
263
	$nentries = 50;
264 5f601060 Phil Davis
}
265 0541e302 Scott Ullrich
266 e3efcb23 NOYB
if ($_POST['clear']) {
267
	clear_log_file($system_logfile);
268 5f601060 Phil Davis
}
269 0541e302 Scott Ullrich
270 5f601060 Phil Davis
if ($filtertext) {
271 36a166de Scott Ullrich
	$filtertextmeta="?filtertext=$filtertext";
272 5f601060 Phil Davis
}
273 59769c23 Scott Ullrich
274 d8af270c jim-p
/* Setup shortcuts if they exist */
275
276
if (!empty($allowed_logs[$logfile]["shortcut"])) {
277
	$shortcut_section = $allowed_logs[$logfile]["shortcut"];
278
}
279
280
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"]));
281 b63695db Scott Ullrich
include("head.inc");
282
283 76af8cdb NOYB
if (!$input_errors && $savemsg) {
284
	print_info_box($savemsg);
285
	$manage_log_active = false;
286
}
287
288 33d52df1 sbeaver
$tab_array = array();
289 1af5edbf Stephen Beaver
$tab_array[] = array(gettext("System"), ($logfile == 'system'), "status_logs.php");
290
$tab_array[] = array(gettext("Firewall"), false, "status_logs_filter.php");
291
$tab_array[] = array(gettext("DHCP"), ($logfile == 'dhcpd'), "status_logs.php?logfile=dhcpd");
292
$tab_array[] = array(gettext("Portal Auth"), ($logfile == 'portalauth'), "status_logs.php?logfile=portalauth");
293
$tab_array[] = array(gettext("IPsec"), ($logfile == 'ipsec'), "status_logs.php?logfile=ipsec");
294
$tab_array[] = array(gettext("PPP"), ($logfile == 'ppp'), "status_logs.php?logfile=ppp");
295
$tab_array[] = array(gettext("VPN"), false, "status_logs_vpn.php");
296
$tab_array[] = array(gettext("Load Balancer"), ($logfile == 'relayd'), "status_logs.php?logfile=relayd");
297
$tab_array[] = array(gettext("OpenVPN"), ($logfile == 'openvpn'), "status_logs.php?logfile=openvpn");
298
$tab_array[] = array(gettext("NTP"), ($logfile == 'ntpd'), "status_logs.php?logfile=ntpd");
299 33d52df1 sbeaver
$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
300
display_top_tabs($tab_array);
301
302
$tab_array = array();
303 cb578e18 sbeaver
if (in_array($logfile, array('system', 'gateways', 'routing', 'resolver', 'wireless')))	 {
304 1af5edbf Stephen Beaver
	$tab_array[] = array(gettext("General"), ($logfile == 'system'), "/status_logs.php");
305
	$tab_array[] = array(gettext("Gateways"), ($logfile == 'gateways'), "/status_logs.php?logfile=gateways");
306
	$tab_array[] = array(gettext("Routing"), ($logfile == 'routing'), "/status_logs.php?logfile=routing");
307
	$tab_array[] = array(gettext("Resolver"), ($logfile == 'resolver'), "/status_logs.php?logfile=resolver");
308
	$tab_array[] = array(gettext("Wireless"), ($logfile == 'wireless'), "/status_logs.php?logfile=wireless");
309 0a5d0b7b sbeaver
	display_top_tabs($tab_array, false, 'nav nav-tabs');
310
}
311 33d52df1 sbeaver
312 76af8cdb NOYB
define(SEC_OPEN, 0x00);
313
define(SEC_CLOSED, 0x04);
314
315
if ($filter_active)
316
	$filter_state = SEC_OPEN;
317
else
318
	$filter_state = SEC_CLOSED;
319
320
if (!$rawfilter) { // Advanced log filter form
321 e3efcb23 NOYB
	$form = new Form(false);
322 33d52df1 sbeaver
323 76af8cdb NOYB
	$section = new Form_Section('Advanced Log Filter', 'adv-filter-panel', COLLAPSIBLE|$filter_state);
324 33d52df1 sbeaver
325 e3efcb23 NOYB
	$group = new Form_Group('');
326
327
	$group->add(new Form_Input(
328
		'filterlogentries_time',
329
		null,
330
		'text',
331
		$filterfieldsarray['time']
332 76af8cdb NOYB
	))->setWidth(3)->setHelp('Time');
333 e3efcb23 NOYB
334
	$group->add(new Form_Input(
335
		'filterlogentries_process',
336
		null,
337
		'text',
338
		$filterfieldsarray['process']
339 76af8cdb NOYB
	))->setWidth(2)->setHelp('Process');
340 e3efcb23 NOYB
341
	$group->add(new Form_Input(
342
		'filterlogentries_pid',
343
		null,
344 648ffe73 NOYB
		'text',
345 e3efcb23 NOYB
		$filterfieldsarray['pid']
346 76af8cdb NOYB
	))->setWidth(2)->setHelp('PID');
347 e3efcb23 NOYB
348
	$group->add(new Form_Input(
349
		'filterlogentries_qty',
350
		null,
351
		'number',
352
		$filterlogentries_qty,
353
		['placeholder' => $nentries]
354 76af8cdb NOYB
	))->setWidth(2)->setHelp('Quantity');
355 e3efcb23 NOYB
356
	$section->add($group);
357
358
	$group = new Form_Group('');
359
360
	$group->add(new Form_Input(
361
		'filterlogentries_message',
362
		null,
363
		'text',
364
		$filterfieldsarray['message']
365 76af8cdb NOYB
	))->setWidth(7)->setHelp('Message');
366 16a597f6 NOYB
367
	$btnsubmit = new Form_Button(
368
		'filterlogentries_submit',
369 a00c9cb3 NOYB
		' ' . gettext('Apply Filter'),
370 16a597f6 NOYB
		null,
371
		'fa-filter'
372
	);
373 e3efcb23 NOYB
}
374
else { // Simple log filter form
375
	$form = new Form(false);
376
377 76af8cdb NOYB
	$section = new Form_Section('Log Filter', 'basic-filter-panel', COLLAPSIBLE|$filter_state);
378 e3efcb23 NOYB
379
	$group = new Form_Group('');
380
381
	$group->add(new Form_Input(
382
		'filtertext',
383
		null,
384
		'text',
385
		$filtertext
386 76af8cdb NOYB
	))->setWidth(6)->setHelp('Filter Expression');
387 e3efcb23 NOYB
388
	$group->add(new Form_Input(
389
		'filterlogentries_qty',
390
		null,
391
		'number',
392
		$filterlogentries_qty,
393
		['placeholder' => $nentries]
394 76af8cdb NOYB
	))->setWidth(2)->setHelp('Quantity');
395 33d52df1 sbeaver
396 16a597f6 NOYB
	$btnsubmit = new Form_Button(
397
		'filtersubmit',
398 a00c9cb3 NOYB
		' ' . gettext('Apply Filter'),
399 16a597f6 NOYB
		null,
400
		'fa-filter'
401
	);
402
}
403 9279147a Stephen Beaver
404
$btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm');
405 33d52df1 sbeaver
406 e3efcb23 NOYB
$group->add(new Form_StaticText(
407 9279147a Stephen Beaver
	'',
408 e3efcb23 NOYB
	$btnsubmit
409 9279147a Stephen Beaver
));
410 33d52df1 sbeaver
411 ce09e5f0 NOYB
$group->setHelp('<a target="_blank" href="http://www.php.net/manual/en/book.pcre.php">' . gettext('Regular expression reference') . '</a> ' . gettext('Precede with exclamation (!) to exclude match.'));
412 e3efcb23 NOYB
$section->add($group);
413 33d52df1 sbeaver
$form->add($section);
414
print $form;
415 5b237745 Scott Ullrich
416 e3efcb23 NOYB
// Now the forms are complete we can draw the log table and its controls
417 76af8cdb NOYB
if (!$rawfilter) {
418 e3efcb23 NOYB
	if ($filterlogentries_submit)
419
		$filterlog = conv_log_filter($system_logfile, $nentries, $nentries + 100, $filterfieldsarray);
420
	else
421
		$filterlog = conv_log_filter($system_logfile, $nentries, $nentries + 100, $filtertext);
422 e0977fed smos
?>
423 9279147a Stephen Beaver
424 e3efcb23 NOYB
<div class="panel panel-default">
425
	<div class="panel-heading">
426
		<h2 class="panel-title">
427
<?php
428
	if ((!$filtertext) && (!$filterfieldsarray))
429 76af8cdb NOYB
		printf(gettext("Last %d %s log entries."), count($filterlog), gettext($allowed_logs[$logfile]["name"]));
430 e3efcb23 NOYB
	else
431 76af8cdb NOYB
		printf(gettext("%d matched %s log entries."), count($filterlog), gettext($allowed_logs[$logfile]["name"]));
432 e3efcb23 NOYB
433 76af8cdb NOYB
	printf(" (" . gettext("Maximum %d") . ")", $nentries);
434 e3efcb23 NOYB
?>
435
		</h2>
436
	</div>
437
	<div class="panel-body">
438
	   <div class="table-responsive">
439 b9db8882 NOYB
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
440
			<thead>
441
				<tr>
442
					<th><?=gettext("Time")?></th>
443
					<th><?=gettext("Process")?></th>
444
					<th><?=gettext("PID")?></th>
445
					<th style="width:100%"><?=gettext("Message")?></th>
446
				</tr>
447
			</thead>
448
			<tbody>
449 e3efcb23 NOYB
<?php
450
	foreach ($filterlog as $filterent) {
451
?>
452 b9db8882 NOYB
				<tr>
453
					<td style="white-space:nowrap;">
454
						<?=htmlspecialchars($filterent['time'])?>
455
					</td>
456
					<td style="white-space:nowrap;">
457
						<?=htmlspecialchars($filterent['process'])?>
458
					</td>
459
					<td style="white-space:nowrap;">
460
						<?=htmlspecialchars($filterent['pid'])?>
461
					</td>
462
					<td style="word-wrap:break-word; word-break:break-all; white-space:normal">
463
						<?=htmlspecialchars($filterent['message'])?>
464
					</td>
465
				</tr>
466 e3efcb23 NOYB
<?php
467
	} // e-o-foreach
468
?>
469 be5bacfd NOYB
			</tbody>
470 e3efcb23 NOYB
		</table>
471 76af8cdb NOYB
<?php
472
	if (count($filterlog) == 0)
473
		print_info_box(gettext('No logs to display'));
474
?>
475 e3efcb23 NOYB
		</div>
476
	</div>
477
</div>
478
<?php
479
}
480
else
481
{
482
?>
483 5d7a0cca sbeaver
<div class="panel panel-default">
484 76af8cdb NOYB
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Last ")?><?=$nentries?> <?=gettext($allowed_logs[$logfile]["name"])?><?=gettext(" log entries")?></h2></div>
485 ba6c5357 Stephen Beaver
	<div class="table table-responsive">
486
		<table class="table table-striped table-hover">
487
			<thead>
488
				<tr>
489 95acc890 NOYB
					<th><?=gettext("Time")?></th>
490
					<th style="width:100%"><?=gettext("Message")?></th>
491 ba6c5357 Stephen Beaver
				</tr>
492
			</thead>
493
			<tbody>
494
<?php
495 288a2a0f Phil Davis
	if (($logfile == 'resolver') || ($logfile == 'system'))
496 5d7a0cca sbeaver
		$inverse = array("ppp");
497
	else
498
		$inverse = null;
499
500 288a2a0f Phil Davis
	if ($filtertext)
501 e3efcb23 NOYB
		$rows = dump_clog($system_logfile, $nentries, true, array("$filtertext"), $inverse);
502 5d7a0cca sbeaver
	else
503 e3efcb23 NOYB
		$rows = dump_clog($system_logfile, $nentries, true, array(), $inverse);
504 b63695db Scott Ullrich
?>
505 ba6c5357 Stephen Beaver
			</tbody>
506
		</table>
507 e3efcb23 NOYB
<?php
508
	if ($rows == 0)
509 a00c9cb3 NOYB
		print_info_box(gettext('No logs to display'));
510 76af8cdb NOYB
?>
511
	</div>
512
</div>
513
<?php
514 e3efcb23 NOYB
}
515
?>
516
517
<?php
518 76af8cdb NOYB
# Manage Log - Section/Form
519
520
if ($input_errors) {
521
	print_input_errors($input_errors);
522
	$manage_log_active = true;
523
}
524
525
if ($manage_log_active)
526
	$manage_log_state = SEC_OPEN;
527
else
528
	$manage_log_state = SEC_CLOSED;
529
530 e3efcb23 NOYB
$form = new Form(false);
531
532 76af8cdb NOYB
$section = new Form_Section(gettext('Manage') . ' ' . gettext($allowed_logs[$logfile]["name"]) . ' ' . gettext('Log'), 'log-manager-panel', COLLAPSIBLE|$manage_log_state);
533
534
$section->addInput(new Form_StaticText(
535
	'',
536
	'These settings override the "General Logging Options" settings.'
537
));
538
539 95acc890 NOYB
540
# All
541 76af8cdb NOYB
$group = new Form_Group('Forward/Reverse Display');
542
543
$group->add(new Form_Checkbox(
544
	'cronorder',
545
	null,
546
	'Forward',
547
	($pconfig['cronorder'] == 'forward') ? true : false,
548
	'forward'
549
))->displayAsRadio();
550
551
$group->add(new Form_Checkbox(
552
	'cronorder',
553
	null,
554
	'Reverse',
555
	($pconfig['cronorder'] == 'reverse') ? true : false,
556
	'reverse'
557
))->displayAsRadio();
558
559
$group->add(new Form_Checkbox(
560
	'cronorder',
561
	null,
562
	'General Logging Options Setting',
563
	($pconfig['cronorder'] == '') ? true : false,
564
	''
565
))->displayAsRadio();
566
567
$group->setHelp('Show log entries in forward (newest at bottom) or reverse (newest at top) order.');
568
$section->add($group);
569
570
$group = new Form_Group('GUI Log Entries');
571 e3efcb23 NOYB
572 76af8cdb NOYB
# Use the general logging options setting (global) as placeholder.
573
$group->add(new Form_Input(
574
	'nentries',
575
	'GUI Log Entries',
576
	'number',
577
	$pconfig['nentries'],
578
	['placeholder' => $config['syslog']['nentries']]
579
))->setWidth(2);
580
581
$group->setHelp('This is the number of log entries displayed in the GUI. It does not affect how many entries are contained in the log.');
582
$section->add($group);
583
584
$group = new Form_Group('Log file size (Bytes)');
585
586
# Use the general logging options setting (global) as placeholder.
587
$group->add(new Form_Input(
588
	'logfilesize',
589
	'Log file size (Bytes)',
590
	'number',
591
	$pconfig['logfilesize'],
592
	['placeholder' => $config['syslog']['logfilesize'] ? $config['syslog']['logfilesize'] : "511488"]
593
))->setWidth(2);
594
$group->setHelp("The log is held in a constant-size circular log file. This field controls how large the log file is, and thus how many entries may exist inside the log. The default is approximately 500KB." .
595
					'<br /><br />' .
596
			"NOTE: The log size is changed the next time it is cleared. To immediately change the log size, first save the options to set the size, then clear the log using the \"Clear Log\" action below. ");
597
$section->add($group);
598
599
$group = new Form_Group('Formatted/Raw Display');
600
601
$group->add(new Form_Checkbox(
602
	'format',
603
	null,
604
	'Formatted',
605
	($pconfig['format'] == 'formatted') ? true : false,
606
	'formatted'
607
))->displayAsRadio();
608
609
$group->add(new Form_Checkbox(
610
	'format',
611
	null,
612
	'Raw',
613
	($pconfig['format'] == 'raw') ? true : false,
614
	'raw'
615
))->displayAsRadio();
616
617
$group->add(new Form_Checkbox(
618
	'format',
619
	null,
620
	'General Logging Options Setting',
621
	($pconfig['format'] == '') ? true : false,
622
	''
623
))->displayAsRadio();
624
625 3e081161 NOYB
$group->setHelp('Show the log entries as formatted or raw output as generated by the service. The raw output will reveal more detailed information, but it is more difficult to read.');
626 76af8cdb NOYB
$section->add($group);
627
628 95acc890 NOYB
629
# System General (main) Specific
630 76af8cdb NOYB
if ($logfile == 'system') {
631
	$section->addInput(new Form_Checkbox(
632
		'loglighttpd',
633
		'Web Server Log',
634
		'Log errors from the web server process',
635
		$pconfig['loglighttpd']
636
	))->setHelp('If this is checked, errors from the lighttpd web server process for the GUI or Captive Portal will appear in the system log.');
637
}
638
639 95acc890 NOYB
640
$group = new Form_Group('Action');
641
642 76af8cdb NOYB
$btnsavesettings = new Form_Button(
643
	'save_settings',
644
	gettext('Save'),
645
	null
646
);
647
648
$btnsavesettings->addClass('btn-sm');
649 e3efcb23 NOYB
650 95acc890 NOYB
$group->add(new Form_StaticText(
651
	'',
652
	$btnsavesettings
653
))->setHelp('Saves changed settings.');
654
655
656 e3efcb23 NOYB
$btnclear = new Form_Button(
657
	'clear',
658 a00c9cb3 NOYB
	' ' . gettext('Clear log'),
659 e3efcb23 NOYB
	null,
660
	'fa-trash'
661
);
662
663
$btnclear->removeClass('btn-primary')->addClass('btn-danger')->addClass('btn-sm');
664
665
$group->add(new Form_StaticText(
666
	'',
667
	$btnclear
668 76af8cdb NOYB
))->setHelp('Clears local log file and reinitializes it as an empty log. Save any settings changes first.');
669 e3efcb23 NOYB
670
$section->add($group);
671
$form->add($section);
672
print $form;
673
?>
674 33d52df1 sbeaver
675 c10cb196 Stephen Beaver
<?php include("foot.inc"); ?>