From 24b5846c1e1d31745be5a83dc8310f7925bfc45e Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Tue, 5 Aug 2008 15:14:14 +0200 Subject: [PATCH] Extended SubMenu Buttons, Filters / Searches can now be extended by each click. This makes searching and finding special events much easier and more powerfull then before. --- src/classes/logstream.class.php | 4 ++ src/classes/logstreampdo.class.php | 1 + src/index.php | 112 ++++++++++++++++++++++++++--- src/lang/en/main.php | 2 + 4 files changed, 111 insertions(+), 8 deletions(-) diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php index 42e6304..79f0115 100644 --- a/src/classes/logstream.class.php +++ b/src/classes/logstream.class.php @@ -457,6 +457,10 @@ abstract class LogStream { // Set Filter value! $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = $tmpArray[FILTER_TMP_VALUE]; } + + // Replace + with spaces + $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE] = str_replace( '+', ' ', $this->_filters[$tmpKeyName][$iNum][FILTER_VALUE]); + // --- } diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php index 5bd8f3a..a7b02b7 100644 --- a/src/classes/logstreampdo.class.php +++ b/src/classes/logstreampdo.class.php @@ -101,6 +101,7 @@ class LogStreamPDO extends LogStream { // Create SQL Where Clause first! $this->CreateSQLWhereClause(); +//debug echo $this->_SQLwhereClause; // Only obtain rowcount if enabled and not done before if ( $this->_logStreamConfigObj->DBEnableRowCounting && $this->_totalRecordCount == -1 ) diff --git a/src/index.php b/src/index.php index 4594f65..20ca1b4 100644 --- a/src/index.php +++ b/src/index.php @@ -374,9 +374,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) // Set OnClick Menu for SYSLOG_FACILITY $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+facility%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], GetFacilityDisplayName($logArray[$mycolkey]) ), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=facility%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . GetFacilityDisplayName( $logArray[$mycolkey] ). "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], GetFacilityDisplayName($logArray[$mycolkey]) ), 'IconSource' => $content['MENU_BULLET_BLUE'] ); $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( @@ -403,9 +415,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) // Set OnClick Menu for SYSLOG_SEVERITY $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+severity%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], GetSeverityDisplayName($logArray[$mycolkey]) ), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=severity%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . GetSeverityDisplayName( $logArray[$mycolkey] ). "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], GetSeverityDisplayName($logArray[$mycolkey]) ), 'IconSource' => $content['MENU_BULLET_BLUE'] ); $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( @@ -432,9 +456,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) // Set OnClick Menu for SYSLOG_MESSAGETYPE $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+messagetype%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], GetMessageTypeDisplayName($logArray[$mycolkey]) ), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=messagetype%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . GetMessageTypeDisplayName( $logArray[$mycolkey] ). "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], GetMessageTypeDisplayName($logArray[$mycolkey]) ), 'IconSource' => $content['MENU_BULLET_BLUE'] ); } @@ -443,9 +479,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) { // Set OnClick Menu for SYSLOG_EVENT_ID $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+eventid%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $logArray[$mycolkey]), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=eventid%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . $logArray[$mycolkey] . "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), 'IconSource' => $content['MENU_BULLET_BLUE'] ); $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( @@ -544,9 +592,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) { // Set OnClick Menu for SYSLOG_SYSLOGTAG $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+syslogtag%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $logArray[$mycolkey]), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=syslogtag%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . $logArray[$mycolkey] . "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), 'IconSource' => $content['MENU_BULLET_BLUE'] ); $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( @@ -559,9 +619,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) { // Set OnClick Menu for SYSLOG_HOST $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+source%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $logArray[$mycolkey]), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=source%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . $logArray[$mycolkey] . "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), 'IconSource' => $content['MENU_BULLET_BLUE'] ); } @@ -570,9 +642,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) { // Set OnClick Menu for SYSLOG_EVENT_LOGTYPE $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+eventlogtype%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $logArray[$mycolkey]), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=eventlogtype%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . $logArray[$mycolkey] . "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), 'IconSource' => $content['MENU_BULLET_BLUE'] ); $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( @@ -585,9 +669,21 @@ if ( isset($content['Sources'][$currentSourceID]) ) { // Set OnClick Menu for SYSLOG_EVENT_SOURCE $content['syslogmessages'][$counter]['values'][$mycolkey]['hasbuttons'] = true; + + // Menu Option to append filter + if ( strlen($content['searchstr']) > 0 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+eventlogsource%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $logArray[$mycolkey]), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); + } + + // More Menu entries $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( 'ButtonUrl' => '?filter=eventlogsource%3A%3D' . urlencode($logArray[$mycolkey]) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => $content['LN_VIEW_FILTERFOR'] . "'" . $logArray[$mycolkey] . "'", + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), 'IconSource' => $content['MENU_BULLET_BLUE'] ); $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( diff --git a/src/lang/en/main.php b/src/lang/en/main.php index fd83cde..a191238 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -117,6 +117,8 @@ $content['LN_VIEW_FILTERFOR'] = "Filter message for "; $content['LN_VIEW_SEARCHFOR'] = "Search online for "; $content['LN_VIEW_SEARCHFORGOOGLE'] = "Search Google for "; $content['LN_GEN_MESSAGEDETAILS'] = "Message Details"; + $content['LN_VIEW_ADDTOFILTER'] = "Add '%1' to filterset"; + $content['LN_VIEW_FILTERFORONLY'] = "Filter for '%1' only"; $content['LN_HIGHLIGHT'] = "Hightlight >>"; $content['LN_HIGHLIGHT_OFF'] = "Hightlight <<";