From 2fd8976f4d97f3f9e40f0ab0fc658be60548f716 Mon Sep 17 00:00:00 2001 From: NOYB Date: Thu, 17 Dec 2015 21:53:13 -0800 Subject: Status - System Logs - VPN Revamp log file selection method to be consistent with the other system logs. Add advanced filter section; only activated for the non-vpn.log files (needs testing with vpn.log file first, continue using dump_clog_vpn until tested). Add manage log section --- src/etc/inc/filter_log.inc | 81 +++- src/usr/local/www/status_logs_vpn.php | 765 +++++++++++++++++++++++++++++----- 2 files changed, 736 insertions(+), 110 deletions(-) (limited to 'src') diff --git a/src/etc/inc/filter_log.inc b/src/etc/inc/filter_log.inc index 1a34c03..cc8bd76 100644 --- a/src/etc/inc/filter_log.inc +++ b/src/etc/inc/filter_log.inc @@ -87,9 +87,10 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil else if ($logfile == "{$g['varlog_path']}/ipsec.log") { $logfile_type = "system"; } else if ($logfile == "{$g['varlog_path']}/ppp.log") { $logfile_type = "system"; } - else if ($logfile == "{$g['varlog_path']}/vpn.log") { $logfile_type = "tbd"; } - else if ($logfile == "{$g['varlog_path']}/poes.log") { $logfile_type = "tbd"; } - else if ($logfile == "{$g['varlog_path']}/l2tps.log") { $logfile_type = "tbd"; } +# Needs to be tested with a vpn.log file before enabling. +# else if ($logfile == "{$g['varlog_path']}/vpn.log") { $logfile_type = "vpn_login"; } + else if ($logfile == "{$g['varlog_path']}/poes.log") { $logfile_type = "vpn_service"; } + else if ($logfile == "{$g['varlog_path']}/l2tps.log") { $logfile_type = "vpn_service"; } else if ($logfile == "{$g['varlog_path']}/relayd.log") { $logfile_type = "system"; } else if ($logfile == "{$g['varlog_path']}/openvpn.log") { $logfile_type = "system"; } @@ -122,8 +123,21 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil else if ($logfile_type == 'system') { $pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $process_pid_pattern . "\ +" . $log_message_pattern . "$"; } - else if ($logfile_type == 'tbd') { - $pattern = "^\(.*\)$"; + +# Needs to be tested with a vpn.log file before enabling. +# These regex patterns are nearly certain to be incorrect. +/* else if ($logfile_type == 'vpn_login') { + $action_pattern = "\(.*?\)"; + $type_pattern = "\(.*?\)"; + $ip_address_pattern = "\(.*?\)"; + $user_pattern = "\(.*?\)"; + $pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $process_pid_pattern . "\ +" . $action_pattern . "\ +" . $type_pattern . "\ +" . $ip_address_pattern . "\ +" . $user_pattern . "$"; + } +*/ + else if ($logfile_type == 'vpn_service') { + $type_pattern = "\(.*?\):"; + $pid_pattern = "\(?:process\ +\([0-9:]*\)\)?"; + $pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $type_pattern . "\ +" . $pid_pattern . "\ *" . $log_message_pattern . "$"; } else if ($logfile_type == 'unknown') { $pattern = "^" . $date_pattern . "\ +" . $log_message_pattern . "$"; @@ -154,11 +168,13 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil break; } - if ($logfile_type == 'firewall') { $flent = parse_firewall_log_line($logent); } - else if ($logfile_type == 'system') { $flent = parse_system_log_line($logent); } - else if ($logfile_type == 'tbd') { $flent = array(); } - else if ($logfile_type == 'unknown') { $flent = parse_unknown_log_line($logent); } - else { $flent = array(); } + if ($logfile_type == 'firewall') { $flent = parse_firewall_log_line($logent); } + else if ($logfile_type == 'system') { $flent = parse_system_log_line($logent); } +# Needs to be tested with a vpn.log file before enabling. +# else if ($logfile_type == 'vpn_login') { $flent = parse_vpn_login_log_line($logent); } + else if ($logfile_type == 'vpn_service') { $flent = parse_vpn_service_log_line($logent); } + else if ($logfile_type == 'unknown') { $flent = parse_unknown_log_line($logent); } + else { $flent = array(); } if (!$filterinterface || ($filterinterface == $flent['interface'])) { if ((($flent != "") && (!is_array($filtertext)) && (match_filter_line($flent, $filtertext))) || @@ -230,6 +246,51 @@ function in_arrayi($needle, $haystack) { return in_array(strtolower($needle), array_map('strtolower', $haystack)); } +function parse_vpn_login_log_line($line) { + global $config, $g, $pattern; + + $flent = array(); + $log_split = ""; + + if (!preg_match($pattern, $line, $log_split)) + return ""; + +# Needs to be tested with a vpn.log file before enabling. +# list($all, $flent['time'], $flent['host'], $flent['process'], $flent['pid'], $flent['action'], $flent['type'], $flent['ip_address'], $flent['user']) = $log_split; + + /* If there is time, action, user, and IP address fields, then the line should be usable/good */ + if (!( (trim($flent['time']) == "") && (trim($flent['action']) == "") && (trim($flent['user']) == "") && (trim($flent['ip_address']) == "") )) { + return $flent; + } else { + if($g['debug']) { + log_error(sprintf(gettext("There was a error parsing log entry: %s. Please report to mailing list or forum."), $line)); + } + return ""; + } +} + +function parse_vpn_service_log_line($line) { + global $config, $g, $pattern; + + $flent = array(); + $log_split = ""; + + if (!preg_match($pattern, $line, $log_split)) + return ""; + + list($all, $flent['time'], $flent['host'], $flent['type'], $flent['pid'], $flent['message']) = $log_split; + + /* If there is time, type, and message fields, then the line should be usable/good */ + if (!( (trim($flent['time']) == "") && (trim($flent['type']) == "") && (trim($flent['message']) == "") )) { + return $flent; + } else { + if($g['debug']) { + log_error(sprintf(gettext("There was a error parsing log entry: %s. Please report to mailing list or forum."), $line)); + } + return ""; + } +} + function parse_unknown_log_line($line) { global $config, $g, $pattern; diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index a1335e7..73470b2 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -1,4 +1,3 @@ -#!/usr/local/bin/php 'PPPoE', 'l2tp' => 'L2TP'); - -$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN")); require("guiconfig.inc"); +require_once("filter_log.inc"); require_once("vpn.inc"); -$nentries = $config['syslog']['nentries']; -if (!$nentries) { - $nentries = 50; -} +/* +Build a list of allowed log files so we can reject others to prevent the page +from acting on unauthorized files. +*/ +$allowed_logs = array( + "vpn" => array("name" => "VPN Logins", + "shortcut" => "poes"), + "poes" => array("name" => "PPPoE Service", + "shortcut" => "poes"), + "l2tps" => array("name" => "L2TP Service", + "shortcut" => "l2tps"), +); -if (htmlspecialchars($_POST['vpntype'])) { - $vpntype = htmlspecialchars($_POST['vpntype']); -} elseif (htmlspecialchars($_GET['vpntype'])) { - $vpntype = htmlspecialchars($_GET['vpntype']); -} else { +// The logs to display are specified in a GET argument. Default to 'system' logs +if (!$_GET['logfile']) { + $logfile = 'vpn'; $vpntype = "poes"; -} -if (htmlspecialchars($_POST['mode'])) { - $mode = htmlspecialchars($_POST['mode']); -} elseif (htmlspecialchars($_GET['mode'])) { - $mode = htmlspecialchars($_GET['mode']); } else { - $mode = "login"; -} -switch ($vpntype) { - case 'poes': - $logname = "poes"; - break; - case 'l2tp': - $logname = "l2tps"; - break; + $logfile = $_GET['logfile']; + $vpntype = $_GET['vpntype']; + if (!array_key_exists($logfile, $allowed_logs)) { + /* Do not let someone attempt to load an unauthorized log. */ + $logfile = 'vpn'; + $vpntype = "poes"; + } } -if ($_POST['clear']) { - if ($mode != "raw") { - clear_log_file("/var/log/vpn.log"); - } else { - clear_log_file("/var/log/{$logname}.log"); +if ($vpntype == 'poes') { $allowed_logs['vpn']['name'] = "PPPoE Logins"; } +if ($vpntype == 'l2tp') { $allowed_logs['vpn']['name'] = "L2TP Logins"; } + +$vpn_logfile = "{$g['varlog_path']}/" . basename($logfile) . ".log"; + + +function getGETPOSTsettingvalue($settingname, $default) { + $settingvalue = $default; + if ($_GET[$settingname]) { + $settingvalue = $_GET[$settingname]; } + if ($_POST[$settingname]) { + $settingvalue = $_POST[$settingname]; + } + return $settingvalue; } -function dump_clog_vpn($logfile, $tail) { - global $g, $config, $vpntype; - $sor = isset($config['syslog']['reverse']) ? "-r" : ""; +$filtersubmit = getGETPOSTsettingvalue('filtersubmit', null); - $logarr = ""; +if ($filtersubmit) { + $filter_active = true; + $filtertext = getGETPOSTsettingvalue('filtertext', ""); + $filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null); +} - exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr); +$filterlogentries_submit = getGETPOSTsettingvalue('filterlogentries_submit', null); - $rows = 0; - foreach ($logarr as $logent) { - $logent = preg_split("/\s+/", $logent, 6); - $llent = explode(",", $logent[5]); - $iftype = substr($llent[1], 0, 4); - if ($iftype != $vpntype) { - continue; +if ($filterlogentries_submit) { + $filter_active = true; + $filterfieldsarray = array(); + + $filterfieldsarray['time'] = getGETPOSTsettingvalue('filterlogentries_time', null); + $filterfieldsarray['type'] = getGETPOSTsettingvalue('filterlogentries_type', null); + $filterfieldsarray['pid'] = getGETPOSTsettingvalue('filterlogentries_pid', null); + $filterfieldsarray['message'] = getGETPOSTsettingvalue('filterlogentries_message', null); + $filterfieldsarray['action'] = getGETPOSTsettingvalue('filterlogentries_action', null); + $filterfieldsarray['user'] = getGETPOSTsettingvalue('filterlogentries_user', null); + $filterfieldsarray['ip_address'] = getGETPOSTsettingvalue('filterlogentries_ip_address', null); + $filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null); +} + + +# Manage Log - Code + +$specific_log = basename($logfile) . '_settings'; + +# All +$pconfig['cronorder'] = $config['syslog'][$specific_log]['cronorder']; +$pconfig['nentries'] = $config['syslog'][$specific_log]['nentries']; +$pconfig['logfilesize'] = $config['syslog'][$specific_log]['logfilesize']; +$pconfig['format'] = $config['syslog'][$specific_log]['format']; + +# System General (main) Specific +$pconfig['loglighttpd'] = !isset($config['syslog']['nologlighttpd']); + +$save_settings = getGETPOSTsettingvalue('save_settings', null); + +if ($save_settings) { + + # All + $cronorder = getGETPOSTsettingvalue('cronorder', null); + $nentries = getGETPOSTsettingvalue('nentries', null); + $logfilesize = getGETPOSTsettingvalue('logfilesize', null); + $format = getGETPOSTsettingvalue('format', null); + + # System General (main) Specific + $loglighttpd = getGETPOSTsettingvalue('loglighttpd', null); + + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ + # All + if (isset($nentries) && (strlen($nentries) > 0)) { + if (!is_numeric($nentries) || ($nentries < 5) || ($nentries > 2000)) { + $input_errors[] = gettext("Number of log entries to show must be between 5 and 2000."); } - echo "\n"; - echo "" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "\n"; + } - if ($llent[0] == "login") { - echo "\n"; - } else { - echo "\n"; + if (isset($logfilesize) && (strlen($logfilesize) > 0)) { + if (!is_numeric($logfilesize) || ($logfilesize < 100000)) { + $input_errors[] = gettext("Log file size must be numeric and greater than or equal to 100000."); } + } - echo "" . htmlspecialchars($llent[3]) . "\n"; - echo "" . htmlspecialchars($llent[2]) . " \n"; - echo "\n"; + if (!$input_errors) { + + # Clear out the specific log settings and leave only the applied settings to override the general logging options (global) settings. + unset($config['syslog'][$specific_log]); + + # All + if ($cronorder != '') { # if not using the general logging options setting (global) + $config['syslog'][$specific_log]['cronorder'] = $cronorder; + } + + if (isset($nentries) && (strlen($nentries) > 0)) { + $config['syslog'][$specific_log]['nentries'] = (int)$nentries; + } + + if (isset($logfilesize) && (strlen($logfilesize) > 0)) { + $config['syslog'][$specific_log]['logfilesize'] = (int)$logfilesize; + } + + if ($format != '') { # if not using the general logging options setting (global) + $config['syslog'][$specific_log]['format'] = $format; + } + + # System General (main) Specific + if ($logfile == 'system') { + $oldnologlighttpd = isset($config['syslog']['nologlighttpd']); + $config['syslog']['nologlighttpd'] = $loglighttpd ? false : true; + } + + + write_config($desc = "Log Display Settings Saved: " . gettext($allowed_logs[$logfile]["name"])); + + $retval = 0; + $savemsg = get_std_save_message($retval); + + # System General (main) Specific + if ($logfile == 'system') { + if ($oldnologlighttpd !== isset($config['syslog']['nologlighttpd'])) { + ob_flush(); + flush(); + log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator.")); + send_event("service restart webgui"); + $savemsg .= "
" . gettext("WebGUI process is restarting."); + } + } } - return($rows); } + +# Formatted/Raw Display +if ($config['syslog'][$specific_log]['format'] == 'formatted') { + $rawfilter = false; +} else if ($config['syslog'][$specific_log]['format'] == 'raw') { + $rawfilter = true; +} else { # Use the general logging options setting (global). + $rawfilter = isset($config['syslog']['rawfilter']); +} + + +isset($config['syslog'][$specific_log]['nentries']) ? $nentries = $config['syslog'][$specific_log]['nentries'] : $nentries = $config['syslog']['nentries']; + +# Override Display Quantity +if ($filterlogentries_qty) { + $nentries = $filterlogentries_qty; +} + +if (!$nentries || !is_numeric($nentries)) { + $nentries = 50; +} + +if ($_POST['clear']) { + clear_log_file($system_logfile); +} + +if ($filtertext) { + $filtertextmeta="?filtertext=$filtertext"; +} + +/* Setup shortcuts if they exist */ + +if (!empty($allowed_logs[$logfile]["shortcut"])) { + $shortcut_section = $allowed_logs[$logfile]["shortcut"]; +} + + +#$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN")); +$pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"])); include("head.inc"); +if (!$input_errors && $savemsg) { + print_info_box($savemsg); + $manage_log_active = false; +} + + $tab_array = array(); -$tab_array[] = array(gettext("System"), false, "status_logs.php"); -$tab_array[] = array(gettext("Firewall"), false, "status_logs_filter.php"); -$tab_array[] = array(gettext("DHCP"), false, "status_logs.php?logfile=dhcpd"); -$tab_array[] = array(gettext("Portal Auth"), false, "status_logs.php?logfile=portalauth"); -$tab_array[] = array(gettext("IPsec"), false, "status_logs.php?logfile=ipsec"); -$tab_array[] = array(gettext("PPP"), false, "status_logs.php?logfile=ppp"); -$tab_array[] = array(gettext("VPN"), true, "status_logs_vpn.php"); -$tab_array[] = array(gettext("Load Balancer"), false, "status_logs.php?logfile=relayd"); -$tab_array[] = array(gettext("OpenVPN"), false, "status_logs.php?logfile=openvpn"); -$tab_array[] = array(gettext("NTP"), false, "status_logs.php?logfile=ntpd"); +$tab_array[] = array(gettext("System"), ($logfile == 'system'), "status_logs.php"); +$tab_array[] = array(gettext("Firewall"), ($logfile == 'filter'), "status_logs_filter.php"); +$tab_array[] = array(gettext("DHCP"), ($logfile == 'dhcpd'), "status_logs.php?logfile=dhcpd"); +$tab_array[] = array(gettext("Portal Auth"), ($logfile == 'portalauth'), "status_logs.php?logfile=portalauth"); +$tab_array[] = array(gettext("IPsec"), ($logfile == 'ipsec'), "status_logs.php?logfile=ipsec"); +$tab_array[] = array(gettext("PPP"), ($logfile == 'ppp'), "status_logs.php?logfile=ppp"); +$tab_array[] = array(gettext("VPN"), ($logfile == 'vpn'), "status_logs_vpn.php"); +$tab_array[] = array(gettext("Load Balancer"), ($logfile == 'relayd'), "status_logs.php?logfile=relayd"); +$tab_array[] = array(gettext("OpenVPN"), ($logfile == 'openvpn'), "status_logs.php?logfile=openvpn"); +$tab_array[] = array(gettext("NTP"), ($logfile == 'ntpd'), "status_logs.php?logfile=ntpd"); $tab_array[] = array(gettext("Settings"), false, "status_logs_settings.php"); display_top_tabs($tab_array); $tab_array = array(); $tab_array[] = array(gettext("PPPoE Logins"), - (($vpntype == "poes") && ($mode != "raw")), - "/status_logs_vpn.php?vpntype=poes"); -$tab_array[] = array(gettext("PPPoE Raw"), - (($vpntype == "poes") && ($mode == "raw")), - "/status_logs_vpn.php?vpntype=poes&mode=raw"); + (($logfile == 'vpn') && ($vpntype == "poes")), + "/status_logs_vpn.php?logfile=vpn&vpntype=poes"); +$tab_array[] = array(gettext("PPPoE Service"), + (($logfile == 'poes') && ($vpntype == "poes")), + "/status_logs_vpn.php?logfile=poes&vpntype=poes"); $tab_array[] = array(gettext("L2TP Logins"), - (($vpntype == "l2tp") && ($mode != "raw")), - "/status_logs_vpn.php?vpntype=l2tp"); -$tab_array[] = array(gettext("L2TP Raw"), - (($vpntype == "l2tp") && ($mode == "raw")), - "/status_logs_vpn.php?vpntype=l2tp&mode=raw"); + (($logfile == 'vpn') && ($vpntype == "l2tp")), + "/status_logs_vpn.php?logfile=vpn&vpntype=l2tp"); +$tab_array[] = array(gettext("L2TP Service"), + (($logfile == 'l2tps') && ($vpntype == "l2tp")), + "/status_logs_vpn.php?logfile=l2tps&vpntype=l2tp"); display_top_tabs($tab_array, false, 'nav nav-tabs'); + + +if ($filter_active) { + $filter_state = SEC_OPEN; +} else { + $filter_state = SEC_CLOSED; +} + +if (!$rawfilter) { // Advanced log filter form + $form = new Form(false); + + $section = new Form_Section('Advanced Log Filter', 'adv-filter-panel', COLLAPSIBLE|$filter_state); + + if ($logfile == "vpn") { + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_time', + null, + 'text', + $filterfieldsarray['time'] + ))->setWidth(3)->setHelp('Time'); + + $group->add(new Form_Input( + 'filterlogentries_action', + null, + 'text', + $filterfieldsarray['action'] + ))->setWidth(3)->setHelp('Action'); + + $group->add(new Form_Input( + 'filterlogentries_qty', + null, + 'number', + $filterlogentries_qty, + ['placeholder' => $nentries] + ))->setWidth(2)->setHelp('Quantity'); + + $section->add($group); + + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_user', + null, + 'text', + $filterfieldsarray['user'] + ))->setWidth(3)->setHelp('User'); + + $group->add(new Form_Input( + 'filterlogentries_ip_address', + null, + 'text', + $filterfieldsarray['ip_address'] + ))->setWidth(4)->setHelp('IP Address'); + } else { + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_time', + null, + 'text', + $filterfieldsarray['time'] + ))->setWidth(3)->setHelp('Time'); + + $group->add(new Form_Input( + 'filterlogentries_type', + null, + 'text', + $filterfieldsarray['type'] + ))->setWidth(2)->setHelp('Type'); + + $group->add(new Form_Input( + 'filterlogentries_pid', + null, + 'text', + $filterfieldsarray['pid'] + ))->setWidth(2)->setHelp('PID'); + + $group->add(new Form_Input( + 'filterlogentries_qty', + null, + 'number', + $filterlogentries_qty, + ['placeholder' => $nentries] + ))->setWidth(2)->setHelp('Quantity'); + + $section->add($group); + + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_message', + null, + 'text', + $filterfieldsarray['message'] + ))->setWidth(7)->setHelp('Log Message'); + + } + $btnsubmit = new Form_Button( + 'filterlogentries_submit', + ' ' . gettext('Apply Filter'), + null, + 'fa-filter' + ); +} else { // Simple log filter form + $form = new Form(false); + + $section = new Form_Section('Log Filter', 'basic-filter-panel', COLLAPSIBLE|$filter_state); + + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filtertext', + null, + 'text', + $filtertext + ))->setWidth(6)->setHelp('Filter Expression'); + + $group->add(new Form_Input( + 'filterlogentries_qty', + null, + 'number', + $filterlogentries_qty, + ['placeholder' => $nentries] + ))->setWidth(2)->setHelp('Quantity'); + + $btnsubmit = new Form_Button( + 'filtersubmit', + ' ' . gettext('Apply Filter'), + null, + 'fa-filter' + ); +} + +$btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm'); + +$group->add(new Form_StaticText( + '', + $btnsubmit +)); + +$group->setHelp('' . gettext('Regular expression reference') . ' ' . gettext('Precede with exclamation (!) to exclude match.')); +$section->add($group); +$form->add($section); +if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. + print $form; +} +// Now the forms are complete we can draw the log table and its controls +if (!$rawfilter) { + if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. + if ($filterlogentries_submit) { + $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filterfieldsarray); + } else { + $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filtertext); + } + } ?> -
-

-
+ +
+

+

+
+ +

+ +
- +
+ - + - + / tags + if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. + foreach ($filterlog as $filterent) { +?> + + + + + + +/ tags + if ($rows > 0) $filterlog[0] = ''; + } +?> + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+
+
-
+
+

+
+
+
+
+ + +addInput(new Form_StaticText( + '', + 'These settings override the "General Logging Options" settings.' +)); + + +# All +$group = new Form_Group('Forward/Reverse Display'); + +$group->add(new Form_Checkbox( + 'cronorder', + null, + 'Forward', + ($pconfig['cronorder'] == 'forward') ? true : false, + 'forward' +))->displayAsRadio()->setHelp('(newest at bottom)'); + +$group->add(new Form_Checkbox( + 'cronorder', + null, + 'Reverse', + ($pconfig['cronorder'] == 'reverse') ? true : false, + 'reverse' +))->displayAsRadio()->setHelp('(newest at top)'); + +$group->add(new Form_Checkbox( + 'cronorder', + null, + 'General Logging Options Setting', + ($pconfig['cronorder'] == '') ? true : false, + '' +))->displayAsRadio(); + +$group->setHelp('Show log entries in forward or reverse order.'); +$section->add($group); + +$group = new Form_Group('GUI Log Entries'); + +# Use the general logging options setting (global) as placeholder. +$group->add(new Form_Input( + 'nentries', + 'GUI Log Entries', + 'number', + $pconfig['nentries'], + ['min' => 5, 'max' => 2000, 'placeholder' => $config['syslog']['nentries']] +))->setWidth(2); + +$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.'); +$section->add($group); + +$group = new Form_Group('Log file size (Bytes)'); + +# Use the general logging options setting (global) as placeholder. +$group->add(new Form_Input( + 'logfilesize', + 'Log file size (Bytes)', + 'number', + $pconfig['logfilesize'], + ['min' => 100000, 'placeholder' => $config['syslog']['logfilesize'] ? $config['syslog']['logfilesize'] : "511488"] +))->setWidth(2); +$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." . + '

' . + "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. "); +$section->add($group); + +$group = new Form_Group('Formatted/Raw Display'); + +$group->add(new Form_Checkbox( + 'format', + null, + 'Formatted', + ($pconfig['format'] == 'formatted') ? true : false, + 'formatted' +))->displayAsRadio(); + +$group->add(new Form_Checkbox( + 'format', + null, + 'Raw', + ($pconfig['format'] == 'raw') ? true : false, + 'raw' +))->displayAsRadio(); + +$group->add(new Form_Checkbox( + 'format', + null, + 'General Logging Options Setting', + ($pconfig['format'] == '') ? true : false, + '' +))->displayAsRadio(); + +$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.'); +$section->add($group); + + +# System General (main) Specific +if ($logfile == 'system') { + $section->addInput(new Form_Checkbox( + 'loglighttpd', + 'Web Server Log', + 'Log errors from the web server process', + $pconfig['loglighttpd'] + ))->setHelp('If this is checked, errors from the lighttpd web server process for the GUI or Captive Portal will appear in the system log.'); +} + + +$group = new Form_Group('Action'); + +$btnsavesettings = new Form_Button( + 'save_settings', + gettext('Save'), + null +); + +$btnsavesettings->addClass('btn-sm'); + +$group->add(new Form_StaticText( + '', + $btnsavesettings +))->setHelp('Saves changed settings.'); + + +$btnclear = new Form_Button( + 'clear', + ' ' . gettext('Clear log'), + null, + 'fa-trash' +); + +$btnclear->removeClass('btn-primary')->addClass('btn-danger')->addClass('btn-sm'); + +$group->add(new Form_StaticText( + '', + $btnclear +))->setHelp('Clears local log file and reinitializes it as an empty log. Save any settings changes first.'); + +$section->add($group); +$form->add($section); +print $form; ?> -
+ \n"; + echo "" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "\n"; + + if ($llent[0] == "login") { + echo "\n"; + } else { + echo "\n"; + } + + echo "" . htmlspecialchars($llent[3]) . "\n"; + echo "" . htmlspecialchars($llent[2]) . " \n"; + echo "\n"; + } + return($rows); +} ?> -
- - - " /> -
-

-

-
- + Date: Sun, 20 Dec 2015 00:02:33 -0800 Subject: Staus - System - Logs - VPN - Write Config Only If no logging changes have been made, only write the config file. --- src/usr/local/www/status_logs_vpn.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 73470b2..0f32b22 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -207,17 +207,27 @@ if ($save_settings) { if ($logfile == 'system') { $oldnologlighttpd = isset($config['syslog']['nologlighttpd']); $config['syslog']['nologlighttpd'] = $loglighttpd ? false : true; + + if ($oldnologlighttpd !== $config['syslog']['nologlighttpd']) { + $logging_changed = $lighttpd_logging_changed = true; + } } - write_config($desc = "Log Display Settings Saved: " . gettext($allowed_logs[$logfile]["name"])); + // If any of the logging settings were changed then backup and sync (standard write_config). Otherwise only write config (don't backup, don't sync). + if ($logging_changed) { + write_config($desc = "Log Display Settings Saved: " . gettext($allowed_logs[$logfile]["name"]), $backup = true, $write_config_only = false); + $retval = 0; + $retval = system_syslogd_start(); + } else { + write_config($desc = "Log Display Settings Saved (no backup, no sync): " . gettext($allowed_logs[$logfile]["name"]), $backup = false, $write_config_only = true); + } - $retval = 0; - $savemsg = get_std_save_message($retval); + $savemsg = gettext("The changes have been applied successfully."); # System General (main) Specific if ($logfile == 'system') { - if ($oldnologlighttpd !== isset($config['syslog']['nologlighttpd'])) { + if ($lighttpd_logging_changed) { ob_flush(); flush(); log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator.")); -- cgit v1.1 From 4f2dc6c20c0176ede649a240fb00902625c4a977 Mon Sep 17 00:00:00 2001 From: NOYB Date: Mon, 21 Dec 2015 15:05:26 -0800 Subject: Per Colin (PR #2300) Use Bootstraps text alignment classes As per "http://getbootstrap.com/css/#type-alignment", use CLASS statement instead in inline STYLE statement (much tidier) --- src/usr/local/www/status_logs_vpn.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 0f32b22..e5e0e91 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -497,7 +497,7 @@ if (!$rawfilter) { if ($logfile == "vpn") { ?> - + @@ -509,7 +509,7 @@ if (!$rawfilter) { if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. foreach ($filterlog as $filterent) { ?> - + @@ -539,7 +539,7 @@ if (!$rawfilter) { } else { ?> - + @@ -550,7 +550,7 @@ if (!$rawfilter) { - + -- cgit v1.1 From 5cd252385a95f28b1aa16270388ecd6c7d7d950e Mon Sep 17 00:00:00 2001 From: NOYB Date: Tue, 5 Jan 2016 08:41:32 -0800 Subject: Function is now in guiconfig.inc --- src/usr/local/www/status_logs_vpn.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index e5e0e91..a4883bb 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -101,18 +101,6 @@ if ($vpntype == 'l2tp') { $allowed_logs['vpn']['name'] = "L2TP Logins"; } $vpn_logfile = "{$g['varlog_path']}/" . basename($logfile) . ".log"; -function getGETPOSTsettingvalue($settingname, $default) { - $settingvalue = $default; - if ($_GET[$settingname]) { - $settingvalue = $_GET[$settingname]; - } - if ($_POST[$settingname]) { - $settingvalue = $_POST[$settingname]; - } - return $settingvalue; -} - - $filtersubmit = getGETPOSTsettingvalue('filtersubmit', null); if ($filtersubmit) { -- cgit v1.1 From e99af53d042cb23f963a41e7da77df3abf0254f7 Mon Sep 17 00:00:00 2001 From: NOYB Date: Tue, 5 Jan 2016 10:22:57 -0800 Subject: Consolidate with status_logs_common.inc --- src/usr/local/www/status_logs_common.inc | 6 +- src/usr/local/www/status_logs_vpn.php | 685 +++++++++---------------------- 2 files changed, 206 insertions(+), 485 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_common.inc b/src/usr/local/www/status_logs_common.inc index 51c0646..35098ee 100644 --- a/src/usr/local/www/status_logs_common.inc +++ b/src/usr/local/www/status_logs_common.inc @@ -119,17 +119,17 @@ function tab_array_logs_common() { $tab_array[] = array(gettext("Dynamic View"), ($view == 'dynamic'), "/status_logs_filter_dynamic.php?logfile=filter&view=dynamic"); $tab_array[] = array(gettext("Summary View"), ($view == 'summary'), "/status_logs_filter_summary.php?logfile=filter&view=summary"); } - else if (in_array($logfile, array('poes', 'l2tp', 'vpn'))) { + else if (in_array($logfile, array('poes', 'l2tps', 'vpn'))) { $tab_array[] = array(gettext("PPPoE Logins"), (($logfile == 'vpn') && ($vpntype == "poes")), "/status_logs_vpn.php?logfile=vpn&vpntype=poes"); - $tab_array[] = array(gettext("PPPoE Raw"), + $tab_array[] = array(gettext("PPPoE Service"), (($logfile == 'poes') && ($vpntype == "poes")), "/status_logs_vpn.php?logfile=poes&vpntype=poes"); $tab_array[] = array(gettext("L2TP Logins"), (($logfile == 'vpn') && ($vpntype == "l2tp")), "/status_logs_vpn.php?logfile=vpn&vpntype=l2tp"); - $tab_array[] = array(gettext("L2TP Raw"), + $tab_array[] = array(gettext("L2TP Service"), (($logfile == 'l2tps') && ($vpntype == "l2tp")), "/status_logs_vpn.php?logfile=l2tps&vpntype=l2tp"); } diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index a4883bb..8c69998 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -64,8 +64,7 @@ ##|-PRIV -require("guiconfig.inc"); -require_once("filter_log.inc"); +require_once("status_logs_common.inc"); require_once("vpn.inc"); /* @@ -101,168 +100,22 @@ if ($vpntype == 'l2tp') { $allowed_logs['vpn']['name'] = "L2TP Logins"; } $vpn_logfile = "{$g['varlog_path']}/" . basename($logfile) . ".log"; -$filtersubmit = getGETPOSTsettingvalue('filtersubmit', null); +// Log Filter Submit - VPN +log_filter_form_vpn_submit(); -if ($filtersubmit) { - $filter_active = true; - $filtertext = getGETPOSTsettingvalue('filtertext', ""); - $filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null); -} - -$filterlogentries_submit = getGETPOSTsettingvalue('filterlogentries_submit', null); - -if ($filterlogentries_submit) { - $filter_active = true; - $filterfieldsarray = array(); - - $filterfieldsarray['time'] = getGETPOSTsettingvalue('filterlogentries_time', null); - $filterfieldsarray['type'] = getGETPOSTsettingvalue('filterlogentries_type', null); - $filterfieldsarray['pid'] = getGETPOSTsettingvalue('filterlogentries_pid', null); - $filterfieldsarray['message'] = getGETPOSTsettingvalue('filterlogentries_message', null); - $filterfieldsarray['action'] = getGETPOSTsettingvalue('filterlogentries_action', null); - $filterfieldsarray['user'] = getGETPOSTsettingvalue('filterlogentries_user', null); - $filterfieldsarray['ip_address'] = getGETPOSTsettingvalue('filterlogentries_ip_address', null); - $filterlogentries_qty = getGETPOSTsettingvalue('filterlogentries_qty', null); -} - - -# Manage Log - Code - -$specific_log = basename($logfile) . '_settings'; - -# All -$pconfig['cronorder'] = $config['syslog'][$specific_log]['cronorder']; -$pconfig['nentries'] = $config['syslog'][$specific_log]['nentries']; -$pconfig['logfilesize'] = $config['syslog'][$specific_log]['logfilesize']; -$pconfig['format'] = $config['syslog'][$specific_log]['format']; - -# System General (main) Specific -$pconfig['loglighttpd'] = !isset($config['syslog']['nologlighttpd']); - -$save_settings = getGETPOSTsettingvalue('save_settings', null); - -if ($save_settings) { - # All - $cronorder = getGETPOSTsettingvalue('cronorder', null); - $nentries = getGETPOSTsettingvalue('nentries', null); - $logfilesize = getGETPOSTsettingvalue('logfilesize', null); - $format = getGETPOSTsettingvalue('format', null); +// Manage Log Section - Code +manage_log_code(); - # System General (main) Specific - $loglighttpd = getGETPOSTsettingvalue('loglighttpd', null); - unset($input_errors); - $pconfig = $_POST; - - /* input validation */ - # All - if (isset($nentries) && (strlen($nentries) > 0)) { - if (!is_numeric($nentries) || ($nentries < 5) || ($nentries > 2000)) { - $input_errors[] = gettext("Number of log entries to show must be between 5 and 2000."); - } - } - - if (isset($logfilesize) && (strlen($logfilesize) > 0)) { - if (!is_numeric($logfilesize) || ($logfilesize < 100000)) { - $input_errors[] = gettext("Log file size must be numeric and greater than or equal to 100000."); - } - } - - if (!$input_errors) { - - # Clear out the specific log settings and leave only the applied settings to override the general logging options (global) settings. - unset($config['syslog'][$specific_log]); - - # All - if ($cronorder != '') { # if not using the general logging options setting (global) - $config['syslog'][$specific_log]['cronorder'] = $cronorder; - } - - if (isset($nentries) && (strlen($nentries) > 0)) { - $config['syslog'][$specific_log]['nentries'] = (int)$nentries; - } +// Status Logs Common - Code +status_logs_common_code(); - if (isset($logfilesize) && (strlen($logfilesize) > 0)) { - $config['syslog'][$specific_log]['logfilesize'] = (int)$logfilesize; - } - - if ($format != '') { # if not using the general logging options setting (global) - $config['syslog'][$specific_log]['format'] = $format; - } - - # System General (main) Specific - if ($logfile == 'system') { - $oldnologlighttpd = isset($config['syslog']['nologlighttpd']); - $config['syslog']['nologlighttpd'] = $loglighttpd ? false : true; - - if ($oldnologlighttpd !== $config['syslog']['nologlighttpd']) { - $logging_changed = $lighttpd_logging_changed = true; - } - } - - - // If any of the logging settings were changed then backup and sync (standard write_config). Otherwise only write config (don't backup, don't sync). - if ($logging_changed) { - write_config($desc = "Log Display Settings Saved: " . gettext($allowed_logs[$logfile]["name"]), $backup = true, $write_config_only = false); - $retval = 0; - $retval = system_syslogd_start(); - } else { - write_config($desc = "Log Display Settings Saved (no backup, no sync): " . gettext($allowed_logs[$logfile]["name"]), $backup = false, $write_config_only = true); - } - - $savemsg = gettext("The changes have been applied successfully."); - - # System General (main) Specific - if ($logfile == 'system') { - if ($lighttpd_logging_changed) { - ob_flush(); - flush(); - log_error(gettext("webConfigurator configuration has changed. Restarting webConfigurator.")); - send_event("service restart webgui"); - $savemsg .= "
" . gettext("WebGUI process is restarting."); - } - } - } -} - - -# Formatted/Raw Display -if ($config['syslog'][$specific_log]['format'] == 'formatted') { - $rawfilter = false; -} else if ($config['syslog'][$specific_log]['format'] == 'raw') { - $rawfilter = true; -} else { # Use the general logging options setting (global). - $rawfilter = isset($config['syslog']['rawfilter']); -} - - -isset($config['syslog'][$specific_log]['nentries']) ? $nentries = $config['syslog'][$specific_log]['nentries'] : $nentries = $config['syslog']['nentries']; - -# Override Display Quantity -if ($filterlogentries_qty) { - $nentries = $filterlogentries_qty; -} - -if (!$nentries || !is_numeric($nentries)) { - $nentries = 50; -} - -if ($_POST['clear']) { - clear_log_file($system_logfile); -} if ($filtertext) { $filtertextmeta="?filtertext=$filtertext"; } -/* Setup shortcuts if they exist */ - -if (!empty($allowed_logs[$logfile]["shortcut"])) { - $shortcut_section = $allowed_logs[$logfile]["shortcut"]; -} - - #$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN")); $pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"])); include("head.inc"); @@ -273,182 +126,14 @@ if (!$input_errors && $savemsg) { } -$tab_array = array(); -$tab_array[] = array(gettext("System"), ($logfile == 'system'), "status_logs.php"); -$tab_array[] = array(gettext("Firewall"), ($logfile == 'filter'), "status_logs_filter.php"); -$tab_array[] = array(gettext("DHCP"), ($logfile == 'dhcpd'), "status_logs.php?logfile=dhcpd"); -$tab_array[] = array(gettext("Portal Auth"), ($logfile == 'portalauth'), "status_logs.php?logfile=portalauth"); -$tab_array[] = array(gettext("IPsec"), ($logfile == 'ipsec'), "status_logs.php?logfile=ipsec"); -$tab_array[] = array(gettext("PPP"), ($logfile == 'ppp'), "status_logs.php?logfile=ppp"); -$tab_array[] = array(gettext("VPN"), ($logfile == 'vpn'), "status_logs_vpn.php"); -$tab_array[] = array(gettext("Load Balancer"), ($logfile == 'relayd'), "status_logs.php?logfile=relayd"); -$tab_array[] = array(gettext("OpenVPN"), ($logfile == 'openvpn'), "status_logs.php?logfile=openvpn"); -$tab_array[] = array(gettext("NTP"), ($logfile == 'ntpd'), "status_logs.php?logfile=ntpd"); -$tab_array[] = array(gettext("Settings"), false, "status_logs_settings.php"); -display_top_tabs($tab_array); - -$tab_array = array(); -$tab_array[] = array(gettext("PPPoE Logins"), - (($logfile == 'vpn') && ($vpntype == "poes")), - "/status_logs_vpn.php?logfile=vpn&vpntype=poes"); -$tab_array[] = array(gettext("PPPoE Service"), - (($logfile == 'poes') && ($vpntype == "poes")), - "/status_logs_vpn.php?logfile=poes&vpntype=poes"); -$tab_array[] = array(gettext("L2TP Logins"), - (($logfile == 'vpn') && ($vpntype == "l2tp")), - "/status_logs_vpn.php?logfile=vpn&vpntype=l2tp"); -$tab_array[] = array(gettext("L2TP Service"), - (($logfile == 'l2tps') && ($vpntype == "l2tp")), - "/status_logs_vpn.php?logfile=l2tps&vpntype=l2tp"); -display_top_tabs($tab_array, false, 'nav nav-tabs'); - - -if ($filter_active) { - $filter_state = SEC_OPEN; -} else { - $filter_state = SEC_CLOSED; -} - -if (!$rawfilter) { // Advanced log filter form - $form = new Form(false); - - $section = new Form_Section('Advanced Log Filter', 'adv-filter-panel', COLLAPSIBLE|$filter_state); - - if ($logfile == "vpn") { - $group = new Form_Group(''); - - $group->add(new Form_Input( - 'filterlogentries_time', - null, - 'text', - $filterfieldsarray['time'] - ))->setWidth(3)->setHelp('Time'); - - $group->add(new Form_Input( - 'filterlogentries_action', - null, - 'text', - $filterfieldsarray['action'] - ))->setWidth(3)->setHelp('Action'); - - $group->add(new Form_Input( - 'filterlogentries_qty', - null, - 'number', - $filterlogentries_qty, - ['placeholder' => $nentries] - ))->setWidth(2)->setHelp('Quantity'); - - $section->add($group); - - $group = new Form_Group(''); - - $group->add(new Form_Input( - 'filterlogentries_user', - null, - 'text', - $filterfieldsarray['user'] - ))->setWidth(3)->setHelp('User'); - - $group->add(new Form_Input( - 'filterlogentries_ip_address', - null, - 'text', - $filterfieldsarray['ip_address'] - ))->setWidth(4)->setHelp('IP Address'); - } else { - $group = new Form_Group(''); - - $group->add(new Form_Input( - 'filterlogentries_time', - null, - 'text', - $filterfieldsarray['time'] - ))->setWidth(3)->setHelp('Time'); - - $group->add(new Form_Input( - 'filterlogentries_type', - null, - 'text', - $filterfieldsarray['type'] - ))->setWidth(2)->setHelp('Type'); - - $group->add(new Form_Input( - 'filterlogentries_pid', - null, - 'text', - $filterfieldsarray['pid'] - ))->setWidth(2)->setHelp('PID'); - - $group->add(new Form_Input( - 'filterlogentries_qty', - null, - 'number', - $filterlogentries_qty, - ['placeholder' => $nentries] - ))->setWidth(2)->setHelp('Quantity'); - - $section->add($group); - - $group = new Form_Group(''); +// Tab Array +tab_array_logs_common(); - $group->add(new Form_Input( - 'filterlogentries_message', - null, - 'text', - $filterfieldsarray['message'] - ))->setWidth(7)->setHelp('Log Message'); - } - $btnsubmit = new Form_Button( - 'filterlogentries_submit', - ' ' . gettext('Apply Filter'), - null, - 'fa-filter' - ); -} else { // Simple log filter form - $form = new Form(false); - - $section = new Form_Section('Log Filter', 'basic-filter-panel', COLLAPSIBLE|$filter_state); - - $group = new Form_Group(''); - - $group->add(new Form_Input( - 'filtertext', - null, - 'text', - $filtertext - ))->setWidth(6)->setHelp('Filter Expression'); - - $group->add(new Form_Input( - 'filterlogentries_qty', - null, - 'number', - $filterlogentries_qty, - ['placeholder' => $nentries] - ))->setWidth(2)->setHelp('Quantity'); - - $btnsubmit = new Form_Button( - 'filtersubmit', - ' ' . gettext('Apply Filter'), - null, - 'fa-filter' - ); -} +// Filter Section/Form - VPN +filter_form_vpn(); -$btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm'); -$group->add(new Form_StaticText( - '', - $btnsubmit -)); - -$group->setHelp('' . gettext('Regular expression reference') . ' ' . gettext('Precede with exclamation (!) to exclude match.')); -$section->add($group); -$form->add($section); -if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. - print $form; -} // Now the forms are complete we can draw the log table and its controls if (!$rawfilter) { if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. @@ -590,161 +275,7 @@ if (!$rawfilter) { addInput(new Form_StaticText( - '', - 'These settings override the "General Logging Options" settings.' -)); - - -# All -$group = new Form_Group('Forward/Reverse Display'); - -$group->add(new Form_Checkbox( - 'cronorder', - null, - 'Forward', - ($pconfig['cronorder'] == 'forward') ? true : false, - 'forward' -))->displayAsRadio()->setHelp('(newest at bottom)'); - -$group->add(new Form_Checkbox( - 'cronorder', - null, - 'Reverse', - ($pconfig['cronorder'] == 'reverse') ? true : false, - 'reverse' -))->displayAsRadio()->setHelp('(newest at top)'); - -$group->add(new Form_Checkbox( - 'cronorder', - null, - 'General Logging Options Setting', - ($pconfig['cronorder'] == '') ? true : false, - '' -))->displayAsRadio(); - -$group->setHelp('Show log entries in forward or reverse order.'); -$section->add($group); - -$group = new Form_Group('GUI Log Entries'); - -# Use the general logging options setting (global) as placeholder. -$group->add(new Form_Input( - 'nentries', - 'GUI Log Entries', - 'number', - $pconfig['nentries'], - ['min' => 5, 'max' => 2000, 'placeholder' => $config['syslog']['nentries']] -))->setWidth(2); - -$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.'); -$section->add($group); - -$group = new Form_Group('Log file size (Bytes)'); - -# Use the general logging options setting (global) as placeholder. -$group->add(new Form_Input( - 'logfilesize', - 'Log file size (Bytes)', - 'number', - $pconfig['logfilesize'], - ['min' => 100000, 'placeholder' => $config['syslog']['logfilesize'] ? $config['syslog']['logfilesize'] : "511488"] -))->setWidth(2); -$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." . - '

' . - "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. "); -$section->add($group); - -$group = new Form_Group('Formatted/Raw Display'); - -$group->add(new Form_Checkbox( - 'format', - null, - 'Formatted', - ($pconfig['format'] == 'formatted') ? true : false, - 'formatted' -))->displayAsRadio(); - -$group->add(new Form_Checkbox( - 'format', - null, - 'Raw', - ($pconfig['format'] == 'raw') ? true : false, - 'raw' -))->displayAsRadio(); - -$group->add(new Form_Checkbox( - 'format', - null, - 'General Logging Options Setting', - ($pconfig['format'] == '') ? true : false, - '' -))->displayAsRadio(); - -$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.'); -$section->add($group); - - -# System General (main) Specific -if ($logfile == 'system') { - $section->addInput(new Form_Checkbox( - 'loglighttpd', - 'Web Server Log', - 'Log errors from the web server process', - $pconfig['loglighttpd'] - ))->setHelp('If this is checked, errors from the lighttpd web server process for the GUI or Captive Portal will appear in the system log.'); -} - - -$group = new Form_Group('Action'); - -$btnsavesettings = new Form_Button( - 'save_settings', - gettext('Save'), - null -); - -$btnsavesettings->addClass('btn-sm'); - -$group->add(new Form_StaticText( - '', - $btnsavesettings -))->setHelp('Saves changed settings.'); - - -$btnclear = new Form_Button( - 'clear', - ' ' . gettext('Clear log'), - null, - 'fa-trash' -); - -$btnclear->removeClass('btn-primary')->addClass('btn-danger')->addClass('btn-sm'); - -$group->add(new Form_StaticText( - '', - $btnclear -))->setHelp('Clears local log file and reinitializes it as an empty log. Save any settings changes first.'); - -$section->add($group); -$form->add($section); -print $form; +manage_log_section(); ?> - + +add(new Form_Input( + 'filterlogentries_time', + null, + 'text', + $filterfieldsarray['time'] + ))->setWidth(3)->setHelp('Time'); + + $group->add(new Form_Input( + 'filterlogentries_action', + null, + 'text', + $filterfieldsarray['action'] + ))->setWidth(3)->setHelp('Action'); + + $group->add(new Form_Input( + 'filterlogentries_qty', + null, + 'number', + $filterlogentries_qty, + ['placeholder' => $nentries] + ))->setWidth(2)->setHelp('Quantity'); + + $section->add($group); + + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_user', + null, + 'text', + $filterfieldsarray['user'] + ))->setWidth(3)->setHelp('User'); + + $group->add(new Form_Input( + 'filterlogentries_ip_address', + null, + 'text', + $filterfieldsarray['ip_address'] + ))->setWidth(4)->setHelp('IP Address'); + } else { + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_time', + null, + 'text', + $filterfieldsarray['time'] + ))->setWidth(3)->setHelp('Time'); + + $group->add(new Form_Input( + 'filterlogentries_type', + null, + 'text', + $filterfieldsarray['type'] + ))->setWidth(2)->setHelp('Type'); + + $group->add(new Form_Input( + 'filterlogentries_pid', + null, + 'text', + $filterfieldsarray['pid'] + ))->setWidth(2)->setHelp('PID'); + + $group->add(new Form_Input( + 'filterlogentries_qty', + null, + 'number', + $filterlogentries_qty, + ['placeholder' => $nentries] + ))->setWidth(2)->setHelp('Quantity'); + + $section->add($group); + + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filterlogentries_message', + null, + 'text', + $filterfieldsarray['message'] + ))->setWidth(7)->setHelp('Log Message'); + + } + $btnsubmit = new Form_Button( + 'filterlogentries_submit', + ' ' . gettext('Apply Filter'), + null, + 'fa-filter' + ); + } else { // Simple log filter form + $form = new Form(false); + + $section = new Form_Section('Log Filter', 'basic-filter-panel', COLLAPSIBLE|$filter_state); + + $group = new Form_Group(''); + + $group->add(new Form_Input( + 'filtertext', + null, + 'text', + $filtertext + ))->setWidth(6)->setHelp('Filter Expression'); + + $group->add(new Form_Input( + 'filterlogentries_qty', + null, + 'number', + $filterlogentries_qty, + ['placeholder' => $nentries] + ))->setWidth(2)->setHelp('Quantity'); + + $btnsubmit = new Form_Button( + 'filtersubmit', + ' ' . gettext('Apply Filter'), + null, + 'fa-filter' + ); + } + + $btnsubmit->removeClass('btn-primary')->addClass('btn-success')->addClass('btn-sm'); + + $group->add(new Form_StaticText( + '', + $btnsubmit + )); + + $group->setHelp('' . gettext('Regular expression reference') . ' ' . gettext('Precede with exclamation (!) to exclude match.')); + $section->add($group); + $form->add($section); + if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. + print $form; + } +} +?> + + -- cgit v1.1 From c407c84db57d361ce8d99f54125d38fbdd903836 Mon Sep 17 00:00:00 2001 From: NOYB Date: Wed, 6 Jan 2016 09:57:01 -0800 Subject: Fixed up for vpn.log filtering. --- src/etc/inc/filter_log.inc | 16 +++++----------- src/usr/local/www/status_logs_vpn.php | 33 +++++++++++---------------------- 2 files changed, 16 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/etc/inc/filter_log.inc b/src/etc/inc/filter_log.inc index cc8bd76..d216083 100644 --- a/src/etc/inc/filter_log.inc +++ b/src/etc/inc/filter_log.inc @@ -87,8 +87,7 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil else if ($logfile == "{$g['varlog_path']}/ipsec.log") { $logfile_type = "system"; } else if ($logfile == "{$g['varlog_path']}/ppp.log") { $logfile_type = "system"; } -# Needs to be tested with a vpn.log file before enabling. -# else if ($logfile == "{$g['varlog_path']}/vpn.log") { $logfile_type = "vpn_login"; } + else if ($logfile == "{$g['varlog_path']}/vpn.log") { $logfile_type = "vpn_login"; } else if ($logfile == "{$g['varlog_path']}/poes.log") { $logfile_type = "vpn_service"; } else if ($logfile == "{$g['varlog_path']}/l2tps.log") { $logfile_type = "vpn_service"; } @@ -124,16 +123,13 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil $pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $process_pid_pattern . "\ +" . $log_message_pattern . "$"; } -# Needs to be tested with a vpn.log file before enabling. -# These regex patterns are nearly certain to be incorrect. -/* else if ($logfile_type == 'vpn_login') { + else if ($logfile_type == 'vpn_login') { $action_pattern = "\(.*?\)"; $type_pattern = "\(.*?\)"; $ip_address_pattern = "\(.*?\)"; $user_pattern = "\(.*?\)"; - $pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $process_pid_pattern . "\ +" . $action_pattern . "\ +" . $type_pattern . "\ +" . $ip_address_pattern . "\ +" . $user_pattern . "$"; + $pattern = "^" . $date_pattern . "\ +" . $host_pattern . "\ +" . $process_pattern . "\ +" . $action_pattern . "\,\ *" . $type_pattern . "\,\ *" . $ip_address_pattern . "\,\ *" . $user_pattern . "$"; } -*/ else if ($logfile_type == 'vpn_service') { $type_pattern = "\(.*?\):"; $pid_pattern = "\(?:process\ +\([0-9:]*\)\)?"; @@ -170,8 +166,7 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil if ($logfile_type == 'firewall') { $flent = parse_firewall_log_line($logent); } else if ($logfile_type == 'system') { $flent = parse_system_log_line($logent); } -# Needs to be tested with a vpn.log file before enabling. -# else if ($logfile_type == 'vpn_login') { $flent = parse_vpn_login_log_line($logent); } + else if ($logfile_type == 'vpn_login') { $flent = parse_vpn_login_log_line($logent); } else if ($logfile_type == 'vpn_service') { $flent = parse_vpn_service_log_line($logent); } else if ($logfile_type == 'unknown') { $flent = parse_unknown_log_line($logent); } else { $flent = array(); } @@ -255,8 +250,7 @@ function parse_vpn_login_log_line($line) { if (!preg_match($pattern, $line, $log_split)) return ""; -# Needs to be tested with a vpn.log file before enabling. -# list($all, $flent['time'], $flent['host'], $flent['process'], $flent['pid'], $flent['action'], $flent['type'], $flent['ip_address'], $flent['user']) = $log_split; + list($all, $flent['time'], $flent['host'], $flent['process'], $flent['action'], $flent['type'], $flent['ip_address'], $flent['user']) = $log_split; /* If there is time, action, user, and IP address fields, then the line should be usable/good */ if (!( (trim($flent['time']) == "") && (trim($flent['action']) == "") && (trim($flent['user']) == "") && (trim($flent['ip_address']) == "") )) { diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 8c69998..17def8a 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -136,17 +136,14 @@ filter_form_vpn(); // Now the forms are complete we can draw the log table and its controls if (!$rawfilter) { - if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. - if ($filterlogentries_submit) { - $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filterfieldsarray); - } else { - $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filtertext); - } + if ($filterlogentries_submit) { + $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filterfieldsarray); + } else { + $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filtertext); } ?>
-

- -

-
@@ -179,8 +173,8 @@ if (!$rawfilter) { / tags - if ($rows > 0) $filterlog[0] = ''; - } + } + } // e-o-foreach ?> setHelp('' . gettext('Regular expression reference') . ' ' . gettext('Precede with exclamation (!) to exclude match.')); $section->add($group); $form->add($section); - if ($logfile != "vpn") { # Needs to be tested with a vpn.log file before enabling. - print $form; - } + print $form; } ?> -- cgit v1.1 From 9855a2013d442cf7d55b9d36b9c60c0a6fa8dc41 Mon Sep 17 00:00:00 2001 From: NOYB Date: Wed, 6 Jan 2016 13:26:37 -0800 Subject: Use the log file path provide from status_logs_common.inc Apply a better way of filtering the vpn type that also provides the count of only the selected type (unset record from the array). --- src/usr/local/www/status_logs_vpn.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 17def8a..4551883 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -97,8 +97,6 @@ if (!$_GET['logfile']) { if ($vpntype == 'poes') { $allowed_logs['vpn']['name'] = "PPPoE Logins"; } if ($vpntype == 'l2tp') { $allowed_logs['vpn']['name'] = "L2TP Logins"; } -$vpn_logfile = "{$g['varlog_path']}/" . basename($logfile) . ".log"; - // Log Filter Submit - VPN log_filter_form_vpn_submit(); @@ -137,9 +135,16 @@ filter_form_vpn(); // Now the forms are complete we can draw the log table and its controls if (!$rawfilter) { if ($filterlogentries_submit) { - $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filterfieldsarray); + $filterlog = conv_log_filter($logfile_path, $nentries, $nentries + 100, $filterfieldsarray); } else { - $filterlog = conv_log_filter($vpn_logfile, $nentries, $nentries + 100, $filtertext); + $filterlog = conv_log_filter($logfile_path, $nentries, $nentries + 100, $filtertext); + } + + // Remove those not of the selected vpn type (poes / l2tp). + foreach ($filterlog as $key => $filterent) { + if (!preg_match('/' . $vpntype . '/', $filterent['type'])) { + unset($filterlog[$key]); + } } ?> @@ -174,7 +179,6 @@ if (!$rawfilter) { @@ -251,7 +254,7 @@ if (!$rawfilter) {

Date: Wed, 6 Jan 2016 13:29:54 -0800 Subject: But only if vpn.log file. --- src/usr/local/www/status_logs_vpn.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 4551883..2d3c6a8 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -141,9 +141,11 @@ if (!$rawfilter) { } // Remove those not of the selected vpn type (poes / l2tp). - foreach ($filterlog as $key => $filterent) { - if (!preg_match('/' . $vpntype . '/', $filterent['type'])) { - unset($filterlog[$key]); + if ($logfile == "vpn") { + foreach ($filterlog as $key => $filterent) { + if (!preg_match('/' . $vpntype . '/', $filterent['type'])) { + unset($filterlog[$key]); + } } } ?> -- cgit v1.1 From f87304f7c0671e88b2f7ee34082989160f2d7b27 Mon Sep 17 00:00:00 2001 From: NOYB Date: Wed, 6 Jan 2016 14:14:25 -0800 Subject: If action is not 'login' or 'logout' then display text of action. Allow long action text to line wrap. Don't line wrap IP address. --- src/usr/local/www/status_logs_vpn.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 2d3c6a8..6844595 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -186,17 +186,19 @@ if (!$rawfilter) {
- - -- cgit v1.1 From 2c19274289a1e92c7750e3051052b928fedd9b8c Mon Sep 17 00:00:00 2001 From: NOYB Date: Wed, 6 Jan 2016 14:31:39 -0800 Subject: Remove unneeded old commented pgtitle var --- src/usr/local/www/status_logs_vpn.php | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/usr/local/www/status_logs_vpn.php b/src/usr/local/www/status_logs_vpn.php index 6844595..ca4e887 100644 --- a/src/usr/local/www/status_logs_vpn.php +++ b/src/usr/local/www/status_logs_vpn.php @@ -114,7 +114,6 @@ if ($filtertext) { $filtertextmeta="?filtertext=$filtertext"; } -#$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN")); $pgtitle = array(gettext("Status"), gettext("System logs"), gettext($allowed_logs[$logfile]["name"])); include("head.inc"); -- cgit v1.1
@@ -188,9 +182,9 @@ if (!$rawfilter) { - + - + @@ -201,11 +195,8 @@ if (!$rawfilter) {
@@ -195,7 +199,6 @@ if (!$rawfilter) {
+ - + + + +