diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index 0fdd2dd..359a0af 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -598,21 +598,34 @@ class LogStreamDB extends LogStream { switch( $myfilter[FILTER_TYPE] ) { case FILTER_TYPE_STRING: - // --- Check if user wants to include or exclude! - if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) - $addnod = ""; - else - $addnod = " NOT"; - // --- - // --- Either make a LIKE or a equal query! if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) { - $szSearchBegin = " = '"; - $szSearchEnd = "' "; + // Set addnot to nothing + $addnod = ""; + + // --- Check if user wants to include or exclude! + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) + { + $szSearchBegin = " = '"; + $szSearchEnd = "' "; + } + else + { + $szSearchBegin = " <> '"; + $szSearchEnd = "' "; + } + // --- } else { + // --- Check if user wants to include or exclude! + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) + $addnod = ""; + else + $addnod = " NOT"; + // --- + $szSearchBegin = " LIKE '%"; $szSearchEnd = "%' "; } @@ -622,7 +635,13 @@ class LogStreamDB extends LogStream { if ( $propertyname == SYSLOG_MESSAGE ) $addor = " AND "; else - $addor = " OR "; + { + // If we exclude filters, we need to combine with AND + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) + $addor = " OR "; + else + $addor = " AND "; + } // --- // Now Create LIKE Filters diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index 625c420..b46fe83 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -758,11 +758,13 @@ class LogStreamDisk extends LogStream { // Otherwise we use OR Handling! else { - $bIsOrFilter = true; // Set isOrFilter to true - // Include Filter if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE ) { + + // Set isOrFilter to true in this case + $bIsOrFilter = true; + if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) { if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) ) @@ -774,18 +776,20 @@ class LogStreamDisk extends LogStream { $bOrFilter = true; } } - // Exclude Filter + // Exclude Filter - handeled with AND filtering! else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE ) { if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) { - if ( strtolower($propertyvalue) != strtolower($myfilter[FILTER_VALUE]) ) - $bOrFilter = true; +// if ( strtolower($propertyvalue) != strtolower($myfilter[FILTER_VALUE]) ) + if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) ) + $bEval = false; } else { - if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false ) - $bOrFilter = true; +// if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false ) + if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false ) + $bEval = false; } } break; diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php index 4abb3d6..e017340 100644 --- a/src/classes/logstreampdo.class.php +++ b/src/classes/logstreampdo.class.php @@ -628,21 +628,34 @@ class LogStreamPDO extends LogStream { switch( $myfilter[FILTER_TYPE] ) { case FILTER_TYPE_STRING: - // --- Check if user wants to include or exclude! - if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) - $addnod = ""; - else - $addnod = " NOT"; - // --- - // --- Either make a LIKE or a equal query! if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) { - $szSearchBegin = " = '"; - $szSearchEnd = "' "; + // Set addnot to nothing + $addnod = ""; + + // --- Check if user wants to include or exclude! + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) + { + $szSearchBegin = " = '"; + $szSearchEnd = "' "; + } + else + { + $szSearchBegin = " <> '"; + $szSearchEnd = "' "; + } + // --- } else { + // --- Check if user wants to include or exclude! + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) + $addnod = ""; + else + $addnod = " NOT"; + // --- + $szSearchBegin = " LIKE '%"; $szSearchEnd = "%' "; } @@ -652,16 +665,22 @@ class LogStreamPDO extends LogStream { if ( $propertyname == SYSLOG_MESSAGE ) $addor = " AND "; else - $addor = " OR "; + { + // If we exclude filters, we need to combine with AND + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) + $addor = " OR "; + else + $addor = " AND "; + } // --- // Not create LIKE Filters if ( isset($tmpfilters[$propertyname]) ) - $tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE]) . $szSearchEnd; + $tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType) . $szSearchEnd; else { $tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING; - $tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE]) . $szSearchEnd; + $tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType) . $szSearchEnd; } break; case FILTER_TYPE_NUMBER: @@ -675,7 +694,7 @@ class LogStreamPDO extends LogStream { else { $tmpfilters[$szArrayKey][FILTER_TYPE] = FILTER_TYPE_NUMBER; - $tmpfilters[$szArrayKey][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " NOT IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE]); + $tmpfilters[$szArrayKey][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " NOT IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType); } } else @@ -686,7 +705,7 @@ class LogStreamPDO extends LogStream { else { $tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER; - $tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE]); + $tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType); } } // --- diff --git a/src/include/constants_general.php b/src/include/constants_general.php index 821339c..8004da9 100644 --- a/src/include/constants_general.php +++ b/src/include/constants_general.php @@ -87,6 +87,18 @@ define('CHARTDATA_COUNT', 'COUNT'); define('UID_UNKNOWN', -1); // --- +// --- Define possible database types +define('DB_MYSQL', 0); +define('DB_MSSQL', 1); +define('DB_ODBC', 2); +define('DB_PGSQL', 3); +define('DB_OCI', 4); +define('DB_DB2', 5); +define('DB_FIREBIRD', 6); +define('DB_INFORMIX', 7); +define('DB_SQLITE', 8); +// --- + // --- Syslog specific defines! define('SYSLOG_KERN', 0); define('SYSLOG_USER', 1); diff --git a/src/include/constants_logstream.php b/src/include/constants_logstream.php index 81af7da..cd454ea 100644 --- a/src/include/constants_logstream.php +++ b/src/include/constants_logstream.php @@ -77,18 +77,6 @@ define('FILTER_TYPE_NUMBER', 1); define('FILTER_TYPE_DATE', 2); define('FILTER_TYPE_UNKNOWN', 99); -// Define possible database types -define('DB_MYSQL', 0); -define('DB_MSSQL', 1); -define('DB_ODBC', 2); -define('DB_PGSQL', 3); -define('DB_OCI', 4); -define('DB_DB2', 5); -define('DB_FIREBIRD', 6); -define('DB_INFORMIX', 7); -define('DB_SQLITE', 8); - - // --- Predefine fields array! $fields[SYSLOG_UID]['FieldID'] = SYSLOG_UID; $fields[SYSLOG_UID]['FieldCaptionID'] = 'LN_FIELDS_UID'; diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 00938c7..5f167d9 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -236,13 +236,23 @@ function DB_RemoveParserSpecialBadChars($myString) return $returnstr; } -function DB_RemoveBadChars($myString) +function DB_RemoveBadChars($myString, $dbEngine = DB_MYSQL) { - // Replace with internal PHP Functions! - if ( !get_magic_quotes_runtime() ) - return addslashes($myString); + if ( $dbEngine == DB_MSSQL ) + { + // MSSQL needs special treatment -.- + return str_replace("'","''",$myString); + } else - return $myString; + { + // Replace with internal PHP Functions! + if ( !get_magic_quotes_runtime() ) + return addslashes($myString); + // return addcslashes($myString, "'"); + else + return $myString; + } + /* $returnstr = str_replace("\\","\\\\",$myString); $returnstr = str_replace("'","\\'",$returnstr); diff --git a/src/index.php b/src/index.php index 543927d..7301ae1 100644 --- a/src/index.php +++ b/src/index.php @@ -375,30 +375,8 @@ if ( isset($content['Sources'][$currentSourceID]) ) $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[SYSLOG_LOCAL0] . '" '; } - // 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' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], GetFacilityDisplayName($logArray[$mycolkey]) ), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); - $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . SYSLOG_FACILITY . '&q=' . GetFacilityDisplayName($logArray[$mycolkey]), - 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content['LN_FIELDS_FACILITY'] . " '" . GetFacilityDisplayName($logArray[$mycolkey]) . "'", - 'IconSource' => $content['MENU_NETWORK'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_NUMBER, SYSLOG_FACILITY, 'LN_FIELDS_FACILITY', true); } else if ( $mycolkey == SYSLOG_SEVERITY ) { @@ -416,30 +394,8 @@ if ( isset($content['Sources'][$currentSourceID]) ) $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[SYSLOG_INFO] . '" '; } - // 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' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], GetSeverityDisplayName($logArray[$mycolkey]) ), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); - $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . SYSLOG_SEVERITY . '&q=' . GetSeverityDisplayName($logArray[$mycolkey]), - 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content['LN_FIELDS_SEVERITY'] . " '" . GetSeverityDisplayName($logArray[$mycolkey]) . "'", - 'IconSource' => $content['MENU_NETWORK'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_NUMBER, SYSLOG_SEVERITY, 'LN_FIELDS_SEVERITY', true); } else if ( $mycolkey == SYSLOG_MESSAGETYPE ) { @@ -457,97 +413,24 @@ if ( isset($content['Sources'][$currentSourceID]) ) $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[IUT_Unknown] . '" '; } - // 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' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], GetMessageTypeDisplayName($logArray[$mycolkey]) ), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_NUMBER, SYSLOG_MESSAGETYPE, 'LN_FIELDS_MESSAGETYPE', false); } else if ( $mycolkey == SYSLOG_PROCESSID ) { - // 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']) . '+processid%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=processid%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_NUMBER, SYSLOG_PROCESSID, 'LN_FIELDS_PROCESSID', false); } /* Eventlog based fields */ else if ( $mycolkey == SYSLOG_EVENT_ID ) { - // 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' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); - $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . SYSLOG_EVENT_ID . '&q=' . $logArray[$mycolkey], - 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content['LN_FIELDS_EVENTID'] . " '" . $logArray[$mycolkey] . "'", - 'IconSource' => $content['MENU_NETWORK'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_NUMBER, SYSLOG_EVENT_ID, 'LN_FIELDS_EVENTID', true); } else if ( $mycolkey == SYSLOG_EVENT_CATEGORY ) { - // 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']) . '+eventcategory%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=eventcategory%3A' . $logArray[$mycolkey] . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_NUMBER, SYSLOG_EVENT_CATEGORY, 'LN_FIELDS_EVENTCATEGORY', false); } // WebServer Type fields else if ( $mycolkey == SYSLOG_WEBLOG_STATUS ) @@ -567,7 +450,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) if ( $mycolkey != SYSLOG_MESSAGE ) { if ( $myStrCharLimit > 0 ) - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes(strlen($logArray[$mycolkey]) > $myStrCharLimit ? substr($logArray[$mycolkey], 0, $myStrCharLimit) . " ..." : $logArray[$mycolkey]); + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes(strlen($logArray[$mycolkey]) > $myStrCharLimit ? substr($logArray[$mycolkey], 0, $myStrCharLimit) . "..." : $logArray[$mycolkey]); } // --- @@ -657,129 +540,29 @@ if ( isset($content['Sources'][$currentSourceID]) ) } else if ( $mycolkey == SYSLOG_SYSLOGTAG ) { - // 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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); - $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . SYSLOG_SYSLOGTAG . '&q=' . $logArray[$mycolkey], - 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content['LN_FIELDS_SYSLOGTAG'] . " '" . $logArray[$mycolkey] . "'", - 'IconSource' => $content['MENU_NETWORK'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_STRING, SYSLOG_SYSLOGTAG, 'LN_FIELDS_SYSLOGTAG', true); } else if ( $mycolkey == SYSLOG_HOST ) { - // 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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_STRING, SYSLOG_HOST, 'LN_FIELDS_HOST', false); } /* Eventlog based fields */ else if ( $mycolkey == SYSLOG_EVENT_LOGTYPE ) { - // 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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); - $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . SYSLOG_EVENT_LOGTYPE . '&q=' . $logArray[$mycolkey], - 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content['LN_FIELDS_EVENTLOGTYPE'] . " '" . $logArray[$mycolkey] . "'", - 'IconSource' => $content['MENU_NETWORK'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_STRING, SYSLOG_EVENT_LOGTYPE, 'LN_FIELDS_EVENTLOGTYPE', true); } else if ( $mycolkey == SYSLOG_EVENT_SOURCE ) { - // 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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&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($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); - $content['syslogmessages'][$counter]['values'][$mycolkey]['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . SYSLOG_EVENT_SOURCE . '&q=' . $logArray[$mycolkey], - 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content['LN_FIELDS_EVENTSOURCE'] . " '" . $logArray[$mycolkey] . "'", - 'IconSource' => $content['MENU_NETWORK'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_STRING, SYSLOG_EVENT_SOURCE, 'LN_FIELDS_EVENTSOURCE', true); } else if ( $mycolkey == SYSLOG_EVENT_USER ) { - // Set OnClick Menu for SYSLOG_EVENT_USER - $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']) . '+eventuser%3A%3D' . urlencode($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&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=eventuser%3A%3D' . urlencode($content['syslogmessages'][$counter]['values'][$mycolkey]['encodedfieldvalue']) . '&search=Search' . $content['additional_url_sourceonly'], - 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $logArray[$mycolkey]), - 'IconSource' => $content['MENU_BULLET_BLUE'] - ); + // Add context menu + AddOnClickMenu( $content['syslogmessages'][$counter]['values'][$mycolkey], FILTER_TYPE_STRING, SYSLOG_EVENT_USER, 'LN_FIELDS_EVENTUSER', false); } // WebServer Type fields else if ( $mycolkey == SYSLOG_WEBLOG_USER ) @@ -986,9 +769,9 @@ function PrepareStringForSearch($myString) return str_replace($searchArray, $replaceArray, $myString); } -function AddOnClickMenu(&$fieldGridItem, $fieldType, $szSearchFieldName, $szFieldDisplayNameID, $searchOnline = false) +function AddOnClickMenu(&$fieldGridItem, $fieldType, $FieldID, $szFieldDisplayNameID, $searchOnline = false) { - global $content; + global $content, $fields, $myStrCharLimit; // Set OnClick Menu for SYSLOG_SYSLOGTAG $fieldGridItem['hasbuttons'] = true; @@ -999,32 +782,71 @@ function AddOnClickMenu(&$fieldGridItem, $fieldType, $szSearchFieldName, $szFie else $szEncodedFieldValue = $fieldGridItem['fieldvalue']; + // Set FieldSearchName + if ( isset($fields[$FieldID]['SearchField']) ) + $szSearchFieldName = $fields[$FieldID]['SearchField']; + else + $szSearchFieldName = $FieldID; + // Menu Option to append filter if ( strlen($content['searchstr']) > 0 ) { $fieldGridItem['buttons'][] = array( 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+' . $szSearchFieldName . '%3A%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], + 'ButtonTarget' => '_top', + 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_GREEN'] ); + $fieldGridItem['buttons'][] = array( + 'ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+' . $szSearchFieldName . '%3A-%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], + 'ButtonTarget' => '_top', + 'ButtonAppendUrl' => true, + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_EXCLUDEFILTER'], $fieldGridItem['fieldvalue']), + 'IconSource' => $content['MENU_BULLET_GREEN'] + ); } // More Menu entries $fieldGridItem['buttons'][] = array( 'ButtonUrl' => '?filter=' . $szSearchFieldName . '%3A%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], + 'ButtonTarget' => '_top', + 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_BLUE'] ); + $fieldGridItem['buttons'][] = array( + 'ButtonUrl' => '?filter=' . $szSearchFieldName . '%3A-%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], + 'ButtonTarget' => '_top', + 'ButtonAppendUrl' => true, + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_SHOWALLBUT'], $fieldGridItem['fieldvalue']), + 'IconSource' => $content['MENU_BULLET_BLUE'] + ); // Add Online Search Button if ( $searchOnline ) { $fieldGridItem['buttons'][] = array( - 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . $szSearchFieldName . '&q=' . $szEncodedFieldValue, + 'ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . $FieldID . '&q=' . $szEncodedFieldValue, + 'ButtonTarget' => '_top', + 'ButtonAppendUrl' => true, 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $content[$szFieldDisplayNameID] . " '" . $fieldGridItem['fieldvalue'] . "'", 'IconSource' => $content['MENU_NETWORK'] ); } + + // Search for links within the fieldcontent! + if ( $fieldType == FILTER_TYPE_STRING && preg_match("#([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", $fieldGridItem['rawfieldvalue'], $szLink) >= 1 ) + { + $fieldGridItem['buttons'][] = array( + 'ButtonUrl' => $szLink[0], + 'ButtonTarget' => '_blank', + 'ButtonAppendUrl' => false, + 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_VISITLINK'], strlen($szLink[0]) > $myStrCharLimit ? substr($szLink[0], 0, $myStrCharLimit) . "..." : $szLink[0] ), + 'IconSource' => $content['MENU_NETWORK'] + ); + } + } // --- diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 7b5b51f..a6e10aa 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -129,7 +129,10 @@ $content['LN_SEARCH_PERFORMADVANCED'] = "Erweiterte Suche starten"; $content['LN_VIEW_SEARCHFORGOOGLE'] = "Search Google for "; $content['LN_GEN_MESSAGEDETAILS'] = "Message Details"; $content['LN_VIEW_ADDTOFILTER'] = "Add '%1' to filterset"; + $content['LN_VIEW_EXCLUDEFILTER'] = "Exclude '%1' from filterset"; $content['LN_VIEW_FILTERFORONLY'] = "Filter for '%1' only"; + $content['LN_VIEW_SHOWALLBUT'] = "Show all except '%1'"; + $content['LN_VIEW_VISITLINK'] = "Open Link '%1' in new window"; $content['LN_HIGHLIGHT'] = "Hightlight >>"; $content['LN_HIGHLIGHT_OFF'] = "Hightlight <<"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index e2d50e4..5401330 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -130,7 +130,10 @@ $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_EXCLUDEFILTER'] = "Exclude '%1' from filterset"; $content['LN_VIEW_FILTERFORONLY'] = "Filter for '%1' only"; + $content['LN_VIEW_SHOWALLBUT'] = "Show all except '%1'"; + $content['LN_VIEW_VISITLINK'] = "Open Link '%1' in new window"; $content['LN_HIGHLIGHT'] = "Hightlight >>"; $content['LN_HIGHLIGHT_OFF'] = "Hightlight <<"; diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index 3d385fb..e54adba 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -132,7 +132,10 @@ $content['LN_VIEW_SEARCHFOR'] = "Busca online por "; $content['LN_VIEW_SEARCHFORGOOGLE'] = "Busca no Google por "; $content['LN_GEN_MESSAGEDETAILS'] = "Detalhes da Mensagem"; $content['LN_VIEW_ADDTOFILTER'] = "Add '%1' to filterset"; + $content['LN_VIEW_EXCLUDEFILTER'] = "Exclude '%1' from filterset"; $content['LN_VIEW_FILTERFORONLY'] = "Filter for '%1' only"; + $content['LN_VIEW_SHOWALLBUT'] = "Show all except '%1'"; + $content['LN_VIEW_VISITLINK'] = "Open Link '%1' in new window"; $content['LN_HIGHLIGHT'] = "Destacar >>"; $content['LN_HIGHLIGHT_OFF'] = "Destacar <<"; diff --git a/src/templates/index.html b/src/templates/index.html index 35d7cd9..4e86f58 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -263,7 +263,7 @@

{LN_GEN_AVAILABLESEARCHES}

  • - {DisplayName} + {additional_url_sourceonly}" target="{ButtonTarget}" OnClick="ToggleDisplayOffTypeById('menu_{FieldColumn}_{uid}');">{DisplayName}