From acfef9f5f790a8fbdd4bafa8838ceedd227236be Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 21 Dec 2014 21:50:54 +0545 Subject: [PATCH] Standardise dynamic firewall log view to be like Firewall Log widget: 1) Display IPv6 address and port in [a:b::c]:123 format 2) Fix same issue with rows gradually disappearing each update, or when in reverse order, update lines not being put in the right place. 3) Update the processing of function format_log_line(row) to reflect the changed list of data items returned by handle_ajax() in filter_log.inc --- usr/local/www/diag_logs_filter_dynamic.php | 53 ++++++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/usr/local/www/diag_logs_filter_dynamic.php b/usr/local/www/diag_logs_filter_dynamic.php index d4722f01e6..2413bf2aeb 100755 --- a/usr/local/www/diag_logs_filter_dynamic.php +++ b/usr/local/www/diag_logs_filter_dynamic.php @@ -1,7 +1,7 @@ /* Called by the AJAX updater */ function format_log_line(row) { - var i = 0; - var line = '' + row[i++] + '<\/td>'; - while (i < 6) { - line += '' + row[i++] + '<\/td>'; + if ( row[8] == '6' ) { + srcIP = '[' + row[3] + ']'; + dstIP = '[' + row[5] + ']'; + } else { + srcIP = row[3]; + dstIP = row[5]; } + + if ( row[4] == '' ) + srcPort = ''; + else + srcPort = ':' + row[4]; + if ( row[6] == '' ) + dstPort = ''; + else + dstPort = ':' + row[6]; + + var line = '' + row[0] + '' + + '' + row[1] + '' + + '' + row[2] + '' + + '' + srcIP + srcPort + '' + + '' + dstIP + dstPort + '' + + '' + row[7] + ''; return line; } //]]> @@ -145,7 +163,25 @@ include("head.inc"); $rowIndex = 0; foreach ($filterlog as $filterent): $evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd"; - $rowIndex++;?> + $rowIndex++; + if ($filterent['version'] == '6') { + $srcIP = "[" . htmlspecialchars($filterent['srcip']) . "]"; + $dstIP = "[" . htmlspecialchars($filterent['dstip']) . "]"; + } else { + $srcIP = htmlspecialchars($filterent['srcip']); + $dstIP = htmlspecialchars($filterent['dstip']); + } + + if ($filterent['srcport']) + $srcPort = ":" . htmlspecialchars($filterent['srcport']); + else + $srcPort = ""; + + if ($filterent['dstport']) + $dstPort = ":" . htmlspecialchars($filterent['dstport']); + else + $dstPort = ""; + ?> ', outputrule);"> @@ -154,8 +190,8 @@ include("head.inc"); - - + + -