From f849a29fa2fc855ab4bb72ede2d2828b11efac51 Mon Sep 17 00:00:00 2001 From: sbeaver Date: Wed, 6 May 2015 11:05:37 -0400 Subject: [PATCH] diag_logs_filter_dynamic.php conversion complete Ready for review Table can be popularized both on initial load and at timed intervals, hence the button needed to be specified in both files. --- etc/inc/filter_log.inc | 24 +-- usr/local/www/diag_logs_filter_dynamic.php | 191 +++++++++++---------- 2 files changed, 109 insertions(+), 106 deletions(-) diff --git a/etc/inc/filter_log.inc b/etc/inc/filter_log.inc index f4d9841625..11ee6de5c6 100644 --- a/etc/inc/filter_log.inc +++ b/etc/inc/filter_log.inc @@ -31,7 +31,7 @@ */ /* pfSense_BUILDER_BINARIES: /usr/sbin/fifolog_reader /usr/bin/tail /usr/local/sbin/clog - pfSense_MODULE: filter + pfSense_MODULE: filter */ require 'config.inc'; @@ -74,7 +74,7 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil $flent = parse_filter_line($logent); if (!$filterinterface || ($filterinterface == $flent['interface'])) { if ((($flent != "") && (!is_array($filtertext)) && (match_filter_line ($flent, $filtertext))) || - (($flent != "") && ( is_array($filtertext)) && (match_filter_field($flent, $filtertext)))) { + (($flent != "") && ( is_array($filtertext)) && (match_filter_field($flent, $filtertext)))) { $counter++; $filterlog[] = $flent; } @@ -86,7 +86,7 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil function escape_filter_regex($filtertext) { /* If the caller (user) has not already put a backslash before a slash, to escape it in the regex, */ - /* then this will do it. Take out any "\/" already there, then turn all ordinary "/" into "\/". */ + /* then this will do it. Take out any "\/" already there, then turn all ordinary "/" into "\/". */ return str_replace('/', '\/', str_replace('\/', '/', $filtertext)); } @@ -156,7 +156,7 @@ function parse_filter_line($line) { $flent['anchor'] = $rule_data[$field++]; $flent['tracker'] = $rule_data[$field++]; $flent['realint'] = $rule_data[$field++]; - $flent['interface'] = convert_real_interface_to_friendly_descr($flent['realint']); + $flent['interface'] = convert_real_interface_to_friendly_descr($flent['realint']); $flent['reason'] = $rule_data[$field++]; $flent['act'] = $rule_data[$field++]; $flent['direction'] = $rule_data[$field++]; @@ -261,7 +261,7 @@ function parse_filter_line($line) { } } else { if ($g['debug']) { - log_error(sprintf(gettext("There was a error parsing rule number: %s. Please report to mailing list or forum."), $flent['rulenum'])); + log_error(sprintf(gettext("There was a error parsing rule number: %s. Please report to mailing list or forum."), $flent['rulenum'])); } return ""; } @@ -271,7 +271,7 @@ function parse_filter_line($line) { return $flent; } else { if ($g['debug']) { - log_error(sprintf(gettext("There was a error parsing rule: %s. Please report to mailing list or forum."), $errline)); + log_error(sprintf(gettext("There was a error parsing rule: %s. Please report to mailing list or forum."), $errline)); } return ""; } @@ -379,7 +379,7 @@ function find_rule_by_number_buffer($rulenum, $trackernum, $type) { $lookup_key = $trackernum; } - if ($type == "rdr") { + if ($type == "rdr") { $ruleString = $buffer_rules_rdr[$lookup_key]; //TODO: get the correct 'description' part of a RDR log line. currently just first 30 characters.. $rulename = substr($ruleString,0,30); @@ -413,9 +413,9 @@ function handle_ajax($nentries, $tail = 50) { if ($_POST['lastsawtime']) { $lastsawtime = $_POST['lastsawtime']; } - /* compare lastsawrule's time stamp to filter logs. - * afterwards return the newer records so that client - * can update AJAX interface screen. + /* compare lastsawrule's time stamp to filter logs. + * afterwards return the newer records so that client + * can update AJAX interface screen. */ $new_rules = ""; $filterlog = conv_log_filter($filter_logfile, $nentries, $tail); @@ -429,8 +429,8 @@ function handle_ajax($nentries, $tail = 50) { $log_row['proto'] .= ":{$log_row['tcpflags']}"; } - $img = "{$img}"; - $new_rules .= "{$img}||{$log_row['time']}||{$log_row['interface']}||{$log_row['srcip']}||{$log_row['srcport']}||{$log_row['dstip']}||{$log_row['dstport']}||{$log_row['proto']}||{$log_row['version']}||" . time() . "||\n"; + $btn = "" . gettext("Block") . " "; + $new_rules .= "{$btn}||{$log_row['time']}||{$log_row['interface']}||{$log_row['srcip']}||{$log_row['srcport']}||{$log_row['dstip']}||{$log_row['dstport']}||{$log_row['proto']}||{$log_row['version']}||" . time() . "||\n"; } } echo $new_rules; diff --git a/usr/local/www/diag_logs_filter_dynamic.php b/usr/local/www/diag_logs_filter_dynamic.php index 4a828bff6d..d2994bdd15 100755 --- a/usr/local/www/diag_logs_filter_dynamic.php +++ b/usr/local/www/diag_logs_filter_dynamic.php @@ -32,8 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. */ -/* - pfSense_MODULE: filter +/* + pfSense_MODULE: filter */ ##|+PRIV @@ -54,7 +54,7 @@ $nentries = 50; /* AJAX related routines */ handle_ajax($nentries, $nentries + 20); -if ($_POST['clear']) +if ($_POST['clear']) clear_log_file($filter_logfile); $filterlog = conv_log_filter($filter_logfile, $nentries, $nentries + 100); @@ -64,17 +64,16 @@ $shortcut_section = "firewall"; include("head.inc"); ?> - - + - - - - - - - -
+ -
- -
-
- - - - - - - - - - - - - - - - - if ($filterent['dstport']) - $dstPort = ":" . htmlspecialchars($filterent['dstport']); - else - $dstPort = ""; - ?> - - - - - - - - - - - -
- ; -
- ', outputrule);"> - <?php echo $filterent['act'];?> - -
+
+
+
-
-

: F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, C - CWR

- - - +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ ', outputrule);"> + + +
+
+
+ + 0) + print_info_box('' . + gettext("TCP Flags") . ': F - FIN, S - SYN, A or . - ACK, R - RST, P - PSH, U - URG, E - ECE, C - CWR'); +?> + +