Project

General

Profile

Download (6.69 KB) Statistics
| Branch: | Tag: | Revision:
1 cfc707f7 Scott Ullrich
<?php
2 5b237745 Scott Ullrich
/*
3
	diag_logs.php
4
*/
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
##|*NAME=Diagnostics: Logs: System page
66
##|*DESCR=Allow access to the 'Diagnostics: Logs: System' page.
67
##|*MATCH=diag_logs.php*
68
##|-PRIV
69
70 5b237745 Scott Ullrich
require("guiconfig.inc");
71
72 0a5d0b7b sbeaver
// The logs to display are specified in a GET argument. Default to 'system' logs
73 288a2a0f Phil Davis
if (!$_GET['logfile'])
74 0a5d0b7b sbeaver
	$logfile = 'system';
75
else
76
	$logfile = $_GET['logfile'];
77
78
$system_logfile = "{$g['varlog_path']}/{$logfile}.log";
79 963d5343 Bill Marquette
80 5b237745 Scott Ullrich
$nentries = $config['syslog']['nentries'];
81 5f601060 Phil Davis
if (!$nentries) {
82 5b237745 Scott Ullrich
	$nentries = 50;
83 5f601060 Phil Davis
}
84 5b237745 Scott Ullrich
85 5f601060 Phil Davis
if ($_POST['clear']) {
86 d6abaa18 Scott Ullrich
	clear_log_file($system_logfile);
87 5f601060 Phil Davis
}
88 5b237745 Scott Ullrich
89 5f601060 Phil Davis
if ($_GET['filtertext']) {
90 daab67a1 Scott Ullrich
	$filtertext = htmlspecialchars($_GET['filtertext']);
91 5f601060 Phil Davis
}
92 0541e302 Scott Ullrich
93 5f601060 Phil Davis
if ($_POST['filtertext']) {
94 daab67a1 Scott Ullrich
	$filtertext = htmlspecialchars($_POST['filtertext']);
95 5f601060 Phil Davis
}
96 0541e302 Scott Ullrich
97 5f601060 Phil Davis
if ($filtertext) {
98 36a166de Scott Ullrich
	$filtertextmeta="?filtertext=$filtertext";
99 5f601060 Phil Davis
}
100 59769c23 Scott Ullrich
101 4e3b667c Phil Davis
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("General"));
102 b63695db Scott Ullrich
include("head.inc");
103
104 33d52df1 sbeaver
$tab_array = array();
105 0a5d0b7b sbeaver
$tab_array[] = array(gettext("System"), ($logfile == 'system'), "diag_logs.php");
106 33d52df1 sbeaver
$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
107 0a5d0b7b sbeaver
$tab_array[] = array(gettext("DHCP"), ($logfile == 'dhcpd'), "diag_logs.php?logfile=dhcpd");
108
$tab_array[] = array(gettext("Portal Auth"), ($logfile == 'portalauth'), "diag_logs.php?logfile=portalauth");
109
$tab_array[] = array(gettext("IPsec"), ($logfile == 'ipsec'), "diag_logs.php?logfile=ipsec");
110
$tab_array[] = array(gettext("PPP"), ($logfile == 'ppp'), "diag_logs.php?logfile=ppp");
111 33d52df1 sbeaver
$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
112 0a5d0b7b sbeaver
$tab_array[] = array(gettext("Load Balancer"), ($logfile == 'relayd'), "diag_logs.php?logfile=relayd");
113
$tab_array[] = array(gettext("OpenVPN"), ($logfile == 'openvpn'), "diag_logs.php?logfile=openvpn");
114
$tab_array[] = array(gettext("NTP"), ($logfile == 'ntpd'), "diag_logs.php?logfile=ntpd");
115 33d52df1 sbeaver
$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
116
display_top_tabs($tab_array);
117
118
$tab_array = array();
119 cb578e18 sbeaver
if (in_array($logfile, array('system', 'gateways', 'routing', 'resolver', 'wireless')))	 {
120 0a5d0b7b sbeaver
	$tab_array[] = array(gettext("General"), ($logfile == 'system'), "/diag_logs.php");
121
	$tab_array[] = array(gettext("Gateways"), ($logfile == 'gateways'), "/diag_logs.php?logfile=gateways");
122
	$tab_array[] = array(gettext("Routing"), ($logfile == 'routing'), "/diag_logs.php?logfile=routing");
123
	$tab_array[] = array(gettext("Resolver"), ($logfile == 'resolver'), "/diag_logs.php?logfile=resolver");
124
	$tab_array[] = array(gettext("Wireless"), ($logfile == 'wireless'), "/diag_logs.php?logfile=wireless");
125
	display_top_tabs($tab_array, false, 'nav nav-tabs');
126
}
127 33d52df1 sbeaver
128 ad2879b8 PiBa-NL
require_once('classes/Form.class.php');
129 33d52df1 sbeaver
130
$form = new Form(false);
131
132
$section = new Form_Section('Log file filter');
133
134
$section->addInput(new Form_Input(
135
	'filtertext',
136
	'Filter',
137
	'text',
138
	$filtertext,
139
	['placeholder' => 'Filter text']
140
));
141
142 9279147a Stephen Beaver
$btnsubmit = new Form_Button(
143 33d52df1 sbeaver
	'filtersubmit',
144 9279147a Stephen Beaver
	'Filter',
145
	null,
146
	'fa-filter'
147
);
148
149
$btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm');
150 33d52df1 sbeaver
151 9279147a Stephen Beaver
$btnclear = new Form_Button(
152 33d52df1 sbeaver
	'clear',
153 9279147a Stephen Beaver
	'Clear log',
154
	null,
155
	'fa-trash'
156
);
157
158
$btnclear->removeClass('btn-primary')->addClass('btn-danger')->addClass('btn-sm');
159
160
$section->addInput(new Form_StaticText(
161
	'',
162
	$btnsubmit . $btnclear
163
));
164 33d52df1 sbeaver
165
$form->add($section);
166
print $form;
167 5b237745 Scott Ullrich
168 288a2a0f Phil Davis
if ($logfile == 'dhcpd')
169 5d7a0cca sbeaver
	print_info_box('Warning: Clearing the log file will restart the DHCP daemon.');
170
171 e0977fed smos
?>
172 9279147a Stephen Beaver
173 5d7a0cca sbeaver
<div class="panel panel-default">
174 f17594c7 Sjon Hortensius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Last ")?><?=$nentries?> <?=$logfile?><?=gettext(" log entries")?></h2></div>
175 ba6c5357 Stephen Beaver
	<div class="table table-responsive">
176
		<table class="table table-striped table-hover">
177
			<thead>
178
				<tr>
179
					<th class="col-sm-2"></th>
180
					<th></th>
181
				</tr>
182
			</thead>
183
			<tbody>
184
<?php
185 288a2a0f Phil Davis
	if (($logfile == 'resolver') || ($logfile == 'system'))
186 5d7a0cca sbeaver
		$inverse = array("ppp");
187
	else
188
		$inverse = null;
189
190 288a2a0f Phil Davis
	if ($filtertext)
191 ba6c5357 Stephen Beaver
		dump_clog($system_logfile, $nentries, true, array("$filtertext"), $inverse);
192 5d7a0cca sbeaver
	else
193 ba6c5357 Stephen Beaver
		dump_clog($system_logfile, $nentries, true, array(), $inverse);
194 b63695db Scott Ullrich
?>
195 ba6c5357 Stephen Beaver
			</tbody>
196
		</table>
197
	</div>
198 5d7a0cca sbeaver
</div>
199 33d52df1 sbeaver
200 c10cb196 Stephen Beaver
<?php include("foot.inc"); ?>