Project

General

Profile

Download (6.69 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	diag_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
/*
60
	pfSense_MODULE:	system
61
*/
62

    
63
##|+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
require("guiconfig.inc");
71

    
72
// The logs to display are specified in a GET argument. Default to 'system' logs
73
if (!$_GET['logfile'])
74
	$logfile = 'system';
75
else
76
	$logfile = $_GET['logfile'];
77

    
78
$system_logfile = "{$g['varlog_path']}/{$logfile}.log";
79

    
80
$nentries = $config['syslog']['nentries'];
81
if (!$nentries) {
82
	$nentries = 50;
83
}
84

    
85
if ($_POST['clear']) {
86
	clear_log_file($system_logfile);
87
}
88

    
89
if ($_GET['filtertext']) {
90
	$filtertext = htmlspecialchars($_GET['filtertext']);
91
}
92

    
93
if ($_POST['filtertext']) {
94
	$filtertext = htmlspecialchars($_POST['filtertext']);
95
}
96

    
97
if ($filtertext) {
98
	$filtertextmeta="?filtertext=$filtertext";
99
}
100

    
101
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("General"));
102
include("head.inc");
103

    
104
$tab_array = array();
105
$tab_array[] = array(gettext("System"), ($logfile == 'system'), "diag_logs.php");
106
$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
107
$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
$tab_array[] = array(gettext("VPN"), false, "diag_logs_vpn.php");
112
$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
$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
116
display_top_tabs($tab_array);
117

    
118
$tab_array = array();
119
if (in_array($logfile, array('system', 'gateways', 'routing', 'resolver', 'wireless')))	 {
120
	$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

    
128
require_once('classes/Form.class.php');
129

    
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
$btnsubmit = new Form_Button(
143
	'filtersubmit',
144
	'Filter',
145
	null,
146
	'fa-filter'
147
);
148

    
149
$btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm');
150

    
151
$btnclear = new Form_Button(
152
	'clear',
153
	'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

    
165
$form->add($section);
166
print $form;
167

    
168
if ($logfile == 'dhcpd')
169
	print_info_box('Warning: Clearing the log file will restart the DHCP daemon.');
170

    
171
?>
172

    
173
<div class="panel panel-default">
174
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Last ")?><?=$nentries?> <?=$logfile?><?=gettext(" log entries")?></h2></div>
175
	<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
	if (($logfile == 'resolver') || ($logfile == 'system'))
186
		$inverse = array("ppp");
187
	else
188
		$inverse = null;
189

    
190
	if ($filtertext)
191
		dump_clog($system_logfile, $nentries, true, array("$filtertext"), $inverse);
192
	else
193
		dump_clog($system_logfile, $nentries, true, array(), $inverse);
194
?>
195
			</tbody>
196
		</table>
197
	</div>
198
</div>
199

    
200
<?php include("foot.inc"); ?>
(21-21/235)