summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/filter_log.inc16
1 files changed, 15 insertions, 1 deletions
diff --git a/etc/inc/filter_log.inc b/etc/inc/filter_log.inc
index 3e06058..d989fa1 100644
--- a/etc/inc/filter_log.inc
+++ b/etc/inc/filter_log.inc
@@ -71,7 +71,8 @@ function conv_log_filter($logfile, $nentries, $tail = 50, $filtertext = "", $fil
$flent = parse_filter_line($logent);
if (!$filterinterface || ($filterinterface == $flent['interface']))
{
- if (($flent != "") && (match_filter_line($flent, $filtertext))) {
+ if ( ( ($flent != "") && (!is_array($filtertext)) && (match_filter_line ($flent, $filtertext))) ||
+ ( ($flent != "") && ( is_array($filtertext)) && (match_filter_field($flent, $filtertext)) ) ) {
$counter++;
$filterlog[] = $flent;
}
@@ -88,6 +89,19 @@ function match_filter_line($flent, $filtertext = "") {
return preg_match("/{$filtertext}/i", implode(" ", array_values($flent)));
}
+function match_filter_field($flent, $fields) {
+ foreach ($fields as $field) {
+ if ($fields[$field] == "All") continue;
+ if ( !(in_arrayi($flent[$field], explode(",", str_replace(" ", ",", $fields[$field]))) ) ) return false;
+ }
+ return true;
+}
+
+// Case Insensitive in_array function
+function in_arrayi($needle, $haystack) {
+ return in_array(strtolower($needle), array_map('strtolower', $haystack));
+}
+
function collapse_filter_lines($logarr) {
$lastline = "";
$collapsed = array();
OpenPOWER on IntegriCloud