From 3c4befc73a79ad7f13463ea30b522d54562400f9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 8 May 2018 14:07:24 -0400 Subject: [PATCH] improve Name and Source filtering. Default to case insensitive text search. --- web/skins/classic/views/_monitor_filters.php | 37 +++++++++----------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/web/skins/classic/views/_monitor_filters.php b/web/skins/classic/views/_monitor_filters.php index 3ab6312af..c32cea01a 100644 --- a/web/skins/classic/views/_monitor_filters.php +++ b/web/skins/classic/views/_monitor_filters.php @@ -195,16 +195,15 @@ $html .= htmlSelect( 'Status[]', $status_options, $Monitor = new Monitor($monitors[$i]); ini_set('track_errors', 'on'); $php_errormsg = ''; - @preg_match($_SESSION['MonitorName'], ''); - if ( !$php_errormsg ) { -# regexp is valid - if ( !preg_match($_SESSION['MonitorName'], $Monitor->Name()) ) { - continue; - } - } else { - if ( ! strstr($Monitor->Name(), $_SESSION['MonitorName']) ) { - continue; - } + $regexp = $_SESSION['MonitorName']; + + @preg_match($regexp, ''); + if ( $php_errormsg ) { + $regexp = '/'.preg_quote($regexp,'/').'/i'; + } + + if ( !preg_match($regexp, $Monitor->Name()) ) { + continue; } } @@ -212,16 +211,14 @@ $html .= htmlSelect( 'Status[]', $status_options, $Monitor = new Monitor($monitors[$i]); ini_set('track_errors', 'on'); $php_errormsg = ''; - @preg_match($_SESSION['Source'], ''); - if ( !$php_errormsg ) { -# regexp is valid - if ( !preg_match($_SESSION['Source'], $Monitor->Source()) ) { - continue; - } - } else { - if ( ! strstr($Monitor->Source(), $_SESSION['Source']) ) { - continue; - } + $regexp = $_SESSION['Source']; + + @preg_match($regexp, ''); + if ( $php_errormsg ) { + $regexp = '/'.preg_quote($regexp,'/').'/i'; + } + if ( !preg_match($regexp, $Monitor->Source()) ) { + continue; } }