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