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 324da1f3 Phil Davis
$tab_array[] = array(gettext("Settings"), false, "status_logs_settings.php");
300 33d52df1 sbeaver
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
if ($filter_active)
313
	$filter_state = SEC_OPEN;
314
else
315
	$filter_state = SEC_CLOSED;
316
317
if (!$rawfilter) { // Advanced log filter form
318 e3efcb23 NOYB
	$form = new Form(false);
319 33d52df1 sbeaver
320 76af8cdb NOYB
	$section = new Form_Section('Advanced Log Filter', 'adv-filter-panel', COLLAPSIBLE|$filter_state);
321 33d52df1 sbeaver
322 e3efcb23 NOYB
	$group = new Form_Group('');
323
324
	$group->add(new Form_Input(
325
		'filterlogentries_time',
326
		null,
327
		'text',
328
		$filterfieldsarray['time']
329 76af8cdb NOYB
	))->setWidth(3)->setHelp('Time');
330 e3efcb23 NOYB
331
	$group->add(new Form_Input(
332
		'filterlogentries_process',
333
		null,
334
		'text',
335
		$filterfieldsarray['process']
336 76af8cdb NOYB
	))->setWidth(2)->setHelp('Process');
337 e3efcb23 NOYB
338
	$group->add(new Form_Input(
339
		'filterlogentries_pid',
340
		null,
341 648ffe73 NOYB
		'text',
342 e3efcb23 NOYB
		$filterfieldsarray['pid']
343 76af8cdb NOYB
	))->setWidth(2)->setHelp('PID');
344 e3efcb23 NOYB
345
	$group->add(new Form_Input(
346
		'filterlogentries_qty',
347
		null,
348
		'number',
349
		$filterlogentries_qty,
350
		['placeholder' => $nentries]
351 76af8cdb NOYB
	))->setWidth(2)->setHelp('Quantity');
352 e3efcb23 NOYB
353
	$section->add($group);
354
355
	$group = new Form_Group('');
356
357
	$group->add(new Form_Input(
358
		'filterlogentries_message',
359
		null,
360
		'text',
361
		$filterfieldsarray['message']
362 76af8cdb NOYB
	))->setWidth(7)->setHelp('Message');
363 16a597f6 NOYB
364
	$btnsubmit = new Form_Button(
365
		'filterlogentries_submit',
366 a00c9cb3 NOYB
		' ' . gettext('Apply Filter'),
367 16a597f6 NOYB
		null,
368
		'fa-filter'
369
	);
370 e3efcb23 NOYB
}
371
else { // Simple log filter form
372
	$form = new Form(false);
373
374 76af8cdb NOYB
	$section = new Form_Section('Log Filter', 'basic-filter-panel', COLLAPSIBLE|$filter_state);
375 e3efcb23 NOYB
376
	$group = new Form_Group('');
377
378
	$group->add(new Form_Input(
379
		'filtertext',
380
		null,
381
		'text',
382
		$filtertext
383 76af8cdb NOYB
	))->setWidth(6)->setHelp('Filter Expression');
384 e3efcb23 NOYB
385
	$group->add(new Form_Input(
386
		'filterlogentries_qty',
387
		null,
388
		'number',
389
		$filterlogentries_qty,
390
		['placeholder' => $nentries]
391 76af8cdb NOYB
	))->setWidth(2)->setHelp('Quantity');
392 33d52df1 sbeaver
393 16a597f6 NOYB
	$btnsubmit = new Form_Button(
394
		'filtersubmit',
395 a00c9cb3 NOYB
		' ' . gettext('Apply Filter'),
396 16a597f6 NOYB
		null,
397
		'fa-filter'
398
	);
399
}
400 9279147a Stephen Beaver
401
$btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm');
402 33d52df1 sbeaver
403 e3efcb23 NOYB
$group->add(new Form_StaticText(
404 9279147a Stephen Beaver
	'',
405 e3efcb23 NOYB
	$btnsubmit
406 9279147a Stephen Beaver
));
407 33d52df1 sbeaver
408 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.'));
409 e3efcb23 NOYB
$section->add($group);
410 33d52df1 sbeaver
$form->add($section);
411
print $form;
412 5b237745 Scott Ullrich
413 e3efcb23 NOYB
// Now the forms are complete we can draw the log table and its controls
414 76af8cdb NOYB
if (!$rawfilter) {
415 e3efcb23 NOYB
	if ($filterlogentries_submit)
416
		$filterlog = conv_log_filter($system_logfile, $nentries, $nentries + 100, $filterfieldsarray);
417
	else
418
		$filterlog = conv_log_filter($system_logfile, $nentries, $nentries + 100, $filtertext);
419 e0977fed smos
?>
420 9279147a Stephen Beaver
421 e3efcb23 NOYB
<div class="panel panel-default">
422
	<div class="panel-heading">
423
		<h2 class="panel-title">
424
<?php
425
	if ((!$filtertext) && (!$filterfieldsarray))
426 76af8cdb NOYB
		printf(gettext("Last %d %s log entries."), count($filterlog), gettext($allowed_logs[$logfile]["name"]));
427 e3efcb23 NOYB
	else
428 76af8cdb NOYB
		printf(gettext("%d matched %s log entries."), count($filterlog), gettext($allowed_logs[$logfile]["name"]));
429 e3efcb23 NOYB
430 76af8cdb NOYB
	printf(" (" . gettext("Maximum %d") . ")", $nentries);
431 e3efcb23 NOYB
?>
432
		</h2>
433
	</div>
434
	<div class="panel-body">
435
	   <div class="table-responsive">
436 b9db8882 NOYB
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
437
			<thead>
438
				<tr>
439
					<th><?=gettext("Time")?></th>
440
					<th><?=gettext("Process")?></th>
441
					<th><?=gettext("PID")?></th>
442
					<th style="width:100%"><?=gettext("Message")?></th>
443
				</tr>
444
			</thead>
445
			<tbody>
446 e3efcb23 NOYB
<?php
447
	foreach ($filterlog as $filterent) {
448
?>
449 b9db8882 NOYB
				<tr>
450
					<td style="white-space:nowrap;">
451
						<?=htmlspecialchars($filterent['time'])?>
452
					</td>
453
					<td style="white-space:nowrap;">
454
						<?=htmlspecialchars($filterent['process'])?>
455
					</td>
456
					<td style="white-space:nowrap;">
457
						<?=htmlspecialchars($filterent['pid'])?>
458
					</td>
459
					<td style="word-wrap:break-word; word-break:break-all; white-space:normal">
460
						<?=htmlspecialchars($filterent['message'])?>
461
					</td>
462
				</tr>
463 e3efcb23 NOYB
<?php
464
	} // e-o-foreach
465
?>
466 be5bacfd NOYB
			</tbody>
467 e3efcb23 NOYB
		</table>
468 76af8cdb NOYB
<?php
469
	if (count($filterlog) == 0)
470
		print_info_box(gettext('No logs to display'));
471
?>
472 e3efcb23 NOYB
		</div>
473
	</div>
474
</div>
475
<?php
476
}
477
else
478
{
479
?>
480 5d7a0cca sbeaver
<div class="panel panel-default">
481 76af8cdb NOYB
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Last ")?><?=$nentries?> <?=gettext($allowed_logs[$logfile]["name"])?><?=gettext(" log entries")?></h2></div>
482 ba6c5357 Stephen Beaver
	<div class="table table-responsive">
483
		<table class="table table-striped table-hover">
484
			<thead>
485
				<tr>
486 95acc890 NOYB
					<th><?=gettext("Time")?></th>
487
					<th style="width:100%"><?=gettext("Message")?></th>
488 ba6c5357 Stephen Beaver
				</tr>
489
			</thead>
490
			<tbody>
491
<?php
492 288a2a0f Phil Davis
	if (($logfile == 'resolver') || ($logfile == 'system'))
493 5d7a0cca sbeaver
		$inverse = array("ppp");
494
	else
495
		$inverse = null;
496
497 288a2a0f Phil Davis
	if ($filtertext)
498 e3efcb23 NOYB
		$rows = dump_clog($system_logfile, $nentries, true, array("$filtertext"), $inverse);
499 5d7a0cca sbeaver
	else
500 e3efcb23 NOYB
		$rows = dump_clog($system_logfile, $nentries, true, array(), $inverse);
501 b63695db Scott Ullrich
?>
502 ba6c5357 Stephen Beaver
			</tbody>
503
		</table>
504 e3efcb23 NOYB
<?php
505
	if ($rows == 0)
506 a00c9cb3 NOYB
		print_info_box(gettext('No logs to display'));
507 76af8cdb NOYB
?>
508
	</div>
509
</div>
510
<?php
511 e3efcb23 NOYB
}
512
?>
513
514
<?php
515 76af8cdb NOYB
# Manage Log - Section/Form
516
517
if ($input_errors) {
518
	print_input_errors($input_errors);
519
	$manage_log_active = true;
520
}
521
522
if ($manage_log_active)
523
	$manage_log_state = SEC_OPEN;
524
else
525
	$manage_log_state = SEC_CLOSED;
526
527 e3efcb23 NOYB
$form = new Form(false);
528
529 76af8cdb NOYB
$section = new Form_Section(gettext('Manage') . ' ' . gettext($allowed_logs[$logfile]["name"]) . ' ' . gettext('Log'), 'log-manager-panel', COLLAPSIBLE|$manage_log_state);
530
531
$section->addInput(new Form_StaticText(
532
	'',
533
	'These settings override the "General Logging Options" settings.'
534
));
535
536 95acc890 NOYB
537
# All
538 76af8cdb NOYB
$group = new Form_Group('Forward/Reverse Display');
539
540
$group->add(new Form_Checkbox(
541
	'cronorder',
542
	null,
543
	'Forward',
544
	($pconfig['cronorder'] == 'forward') ? true : false,
545
	'forward'
546 b0132e5a NOYB
))->displayAsRadio()->setHelp('(newest at bottom)');
547 76af8cdb NOYB
548
$group->add(new Form_Checkbox(
549
	'cronorder',
550
	null,
551
	'Reverse',
552
	($pconfig['cronorder'] == 'reverse') ? true : false,
553
	'reverse'
554 b0132e5a NOYB
))->displayAsRadio()->setHelp('(newest at top)');
555 76af8cdb NOYB
556
$group->add(new Form_Checkbox(
557
	'cronorder',
558
	null,
559
	'General Logging Options Setting',
560
	($pconfig['cronorder'] == '') ? true : false,
561
	''
562
))->displayAsRadio();
563
564 b0132e5a NOYB
$group->setHelp('Show log entries in forward or reverse order.');
565 76af8cdb NOYB
$section->add($group);
566
567
$group = new Form_Group('GUI Log Entries');
568 e3efcb23 NOYB
569 76af8cdb NOYB
# Use the general logging options setting (global) as placeholder.
570
$group->add(new Form_Input(
571
	'nentries',
572
	'GUI Log Entries',
573
	'number',
574
	$pconfig['nentries'],
575
	['placeholder' => $config['syslog']['nentries']]
576
))->setWidth(2);
577
578
$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.');
579
$section->add($group);
580
581
$group = new Form_Group('Log file size (Bytes)');
582
583
# Use the general logging options setting (global) as placeholder.
584
$group->add(new Form_Input(
585
	'logfilesize',
586
	'Log file size (Bytes)',
587
	'number',
588
	$pconfig['logfilesize'],
589
	['placeholder' => $config['syslog']['logfilesize'] ? $config['syslog']['logfilesize'] : "511488"]
590
))->setWidth(2);
591
$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." .
592
					'<br /><br />' .
593
			"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. ");
594
$section->add($group);
595
596
$group = new Form_Group('Formatted/Raw Display');
597
598
$group->add(new Form_Checkbox(
599
	'format',
600
	null,
601
	'Formatted',
602
	($pconfig['format'] == 'formatted') ? true : false,
603
	'formatted'
604
))->displayAsRadio();
605
606
$group->add(new Form_Checkbox(
607
	'format',
608
	null,
609
	'Raw',
610
	($pconfig['format'] == 'raw') ? true : false,
611
	'raw'
612
))->displayAsRadio();
613
614
$group->add(new Form_Checkbox(
615
	'format',
616
	null,
617
	'General Logging Options Setting',
618
	($pconfig['format'] == '') ? true : false,
619
	''
620
))->displayAsRadio();
621
622 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.');
623 76af8cdb NOYB
$section->add($group);
624
625 95acc890 NOYB
626
# System General (main) Specific
627 76af8cdb NOYB
if ($logfile == 'system') {
628
	$section->addInput(new Form_Checkbox(
629
		'loglighttpd',
630
		'Web Server Log',
631
		'Log errors from the web server process',
632
		$pconfig['loglighttpd']
633
	))->setHelp('If this is checked, errors from the lighttpd web server process for the GUI or Captive Portal will appear in the system log.');
634
}
635
636 95acc890 NOYB
637
$group = new Form_Group('Action');
638
639 76af8cdb NOYB
$btnsavesettings = new Form_Button(
640
	'save_settings',
641
	gettext('Save'),
642
	null
643
);
644
645
$btnsavesettings->addClass('btn-sm');
646 e3efcb23 NOYB
647 95acc890 NOYB
$group->add(new Form_StaticText(
648
	'',
649
	$btnsavesettings
650
))->setHelp('Saves changed settings.');
651
652
653 e3efcb23 NOYB
$btnclear = new Form_Button(
654
	'clear',
655 a00c9cb3 NOYB
	' ' . gettext('Clear log'),
656 e3efcb23 NOYB
	null,
657
	'fa-trash'
658
);
659
660
$btnclear->removeClass('btn-primary')->addClass('btn-danger')->addClass('btn-sm');
661
662
$group->add(new Form_StaticText(
663
	'',
664
	$btnclear
665 76af8cdb NOYB
))->setHelp('Clears local log file and reinitializes it as an empty log. Save any settings changes first.');
666 e3efcb23 NOYB
667
$section->add($group);
668
$form->add($section);
669
print $form;
670
?>
671 33d52df1 sbeaver
672 c10cb196 Stephen Beaver
<?php include("foot.inc"); ?>