From 10e2ce19b35f4712cb61b00c996327a0554ef468 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Tue, 15 Apr 2008 17:49:48 +0200 Subject: [PATCH] - another milestone, fully implemented dynamic columns. This means columns can be dynamically chosen in the config.php file, and the view will be dynamically built based on the chosen columns. Multiple predefined views will be possible later. --- src/classes/logstreamdisk.class.php | 3 + src/config.php | 16 +- src/css/defaults.css | 2 +- src/include/constants_filters.php | 6 - src/include/constants_logstream.php | 66 +++++- src/include/functions_common.php | 9 +- src/include/functions_frontendhelpers.php | 11 +- src/index.php | 247 +++++++++++++++------- src/lang/en/main.php | 19 +- src/templates/index.html | 77 ++++--- 10 files changed, 321 insertions(+), 135 deletions(-) diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index d0ab195..c689374 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -185,6 +185,9 @@ class LogStreamDisk extends LogStream { // Line Parser Hook here $this->_logStreamConfigObj->_lineParser->ParseLine($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + // Set uID to the PropertiesOut! + $arrProperitesOut[SYSLOG_UID] = $uID; + // Loop until the filter applies, or another error occurs. } while ( $this->ApplyFilters($ret, $arrProperitesOut) != SUCCESS && $ret == SUCCESS ); diff --git a/src/config.php b/src/config.php index ed2a162..0a53893 100644 --- a/src/config.php +++ b/src/config.php @@ -48,19 +48,29 @@ $CFG['UserDBPass'] = ""; // --- // --- Misc Options -$CFG['MiscShowDebugMsg'] = 1; -$CFG["MiscShowPageRenderStats"] = 1; // If enabled, you will see Pagerender Settings +$CFG['MiscShowDebugMsg'] = 0; // if enabled, you will get additional output on certain places +$CFG["MiscShowPageRenderStats"] = 1; // If enabled, you will see Pagerender Settings // --- // --- Default Frontend Options $CFG['ViewUseTodayYesterday'] = 1; // If enabled, the date from today and yesterday is displayed as "today" and "yesterday" -$CFG['ViewMessageCharacterLimit'] = 100; // Default character limit for the message gets trunscated. +$CFG['ViewMessageCharacterLimit'] = 80; // Default character limit for the message gets trunscated. $CFG['ViewEntriesPerPage'] = 50; // Default number of syslog entries shown per page $CFG['ViewEnableDetailPopups'] = 1; // If enabled, you will see additional Details for each syslog message on mouse over. $CFG['SearchCustomButtonCaption'] = "I'd like to feel sad"; // Default caption for the custom fast search button $CFG['SearchCustomButtonSearch'] = "error"; // Default search string for the custom search button +// --- +// --- Define which fields you want to see +//$CFG['ShowMessage'] = true; // If enabled, the Message column will be appended to the columns list. +$CFG['Columns'][] = SYSLOG_DATE; +$CFG['Columns'][] = SYSLOG_FACILITY; +$CFG['Columns'][] = SYSLOG_SEVERITY; +$CFG['Columns'][] = SYSLOG_HOST; +$CFG['Columns'][] = SYSLOG_SYSLOGTAG; +$CFG['Columns'][] = SYSLOG_MESSAGETYPE; +$CFG['Columns'][] = SYSLOG_MESSAGE; // --- // --- Source Options diff --git a/src/css/defaults.css b/src/css/defaults.css index 6b1fc11..a6f98f6 100644 --- a/src/css/defaults.css +++ b/src/css/defaults.css @@ -22,7 +22,7 @@ display: none; } -.syslogdetails, a.syslogdetails, a.syslogdetails:link +.syslogdetails, a.syslogdetails, a.syslogdetails:link, a.syslogdetails:active, a.syslogdetails:visited { font-weight:normal; text-decoration:none; diff --git a/src/include/constants_filters.php b/src/include/constants_filters.php index 44ffe94..054e8e8 100644 --- a/src/include/constants_filters.php +++ b/src/include/constants_filters.php @@ -49,10 +49,4 @@ define('FILTER_MODE', 'filtermode'); define('FILTER_MODE_INCLUDE', 0); define('FILTER_MODE_EXCLUDE', 1); - -// Defines which kind of filters we have -define('FILTER_TYPE_STRING', 0); -define('FILTER_TYPE_NUMBER', 1); -define('FILTER_TYPE_DATE', 2); - ?> \ No newline at end of file diff --git a/src/include/constants_logstream.php b/src/include/constants_logstream.php index af6e92b..16c399a 100644 --- a/src/include/constants_logstream.php +++ b/src/include/constants_logstream.php @@ -24,7 +24,8 @@ if ( !defined('IN_PHPLOGCON') ) // --- Some custom defines -// Properties we need from the stream class +// Define properties names of all know fields +define('SYSLOG_UID', 'uID'); define('SYSLOG_DATE', 'timereported'); define('SYSLOG_DATE_FORMATED', 'timereported_formatted'); define('SYSLOG_FACILITY', 'syslogfacility'); @@ -38,6 +39,69 @@ define('SYSLOG_MESSAGETRUNSCATED', 'msgtrunscated'); define('SYSLOG_MESSAGETYPE', 'IUT'); define('SYSLOG_PROCESSID', 'procid'); +// Defines which kind of field types we have +define('FILTER_TYPE_STRING', 0); +define('FILTER_TYPE_NUMBER', 1); +define('FILTER_TYPE_DATE', 2); + +// Predefine fields array! + +$fields[SYSLOG_UID]['FieldID'] = SYSLOG_UID; +$fields[SYSLOG_UID]['FieldCaptionID'] = 'LN_FIELDS_UID'; +$fields[SYSLOG_UID]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[SYSLOG_UID]['Sortable'] = false; +$fields[SYSLOG_UID]['DefaultWidth'] = "50"; +$fields[SYSLOG_UID]['FieldAlign'] = "center"; +$fields[SYSLOG_DATE]['FieldID'] = SYSLOG_DATE; +$fields[SYSLOG_DATE]['FieldCaptionID'] = 'LN_FIELDS_DATE'; +$fields[SYSLOG_DATE]['FieldType'] = FILTER_TYPE_DATE; +$fields[SYSLOG_DATE]['Sortable'] = true; +$fields[SYSLOG_DATE]['DefaultWidth'] = "110"; +$fields[SYSLOG_DATE]['FieldAlign'] = "center"; +$fields[SYSLOG_FACILITY]['FieldID'] = SYSLOG_FACILITY; +$fields[SYSLOG_FACILITY]['FieldCaptionID'] = 'LN_FIELDS_FACILITY'; +$fields[SYSLOG_FACILITY]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[SYSLOG_FACILITY]['Sortable'] = true; +$fields[SYSLOG_FACILITY]['DefaultWidth'] = "50"; +$fields[SYSLOG_FACILITY]['FieldAlign'] = "center"; +$fields[SYSLOG_SEVERITY]['FieldID'] = SYSLOG_SEVERITY; +$fields[SYSLOG_SEVERITY]['FieldCaptionID'] = 'LN_FIELDS_SEVERITY'; +$fields[SYSLOG_SEVERITY]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[SYSLOG_SEVERITY]['Sortable'] = true; +$fields[SYSLOG_SEVERITY]['DefaultWidth'] = "50"; +$fields[SYSLOG_SEVERITY]['FieldAlign'] = "center"; +$fields[SYSLOG_HOST]['FieldID'] = SYSLOG_HOST; +$fields[SYSLOG_HOST]['FieldCaptionID'] = 'LN_FIELDS_HOST'; +$fields[SYSLOG_HOST]['FieldType'] = FILTER_TYPE_STRING; +$fields[SYSLOG_HOST]['Sortable'] = true; +$fields[SYSLOG_HOST]['DefaultWidth'] = "65"; +$fields[SYSLOG_HOST]['FieldAlign'] = "center"; +$fields[SYSLOG_SYSLOGTAG]['FieldID'] = SYSLOG_SYSLOGTAG; +$fields[SYSLOG_SYSLOGTAG]['FieldCaptionID'] = 'LN_FIELDS_SYSLOGTAG'; +$fields[SYSLOG_SYSLOGTAG]['FieldType'] = FILTER_TYPE_STRING; +$fields[SYSLOG_SYSLOGTAG]['Sortable'] = true; +$fields[SYSLOG_SYSLOGTAG]['DefaultWidth'] = "70"; +$fields[SYSLOG_SYSLOGTAG]['FieldAlign'] = "center"; +$fields[SYSLOG_MESSAGETYPE]['FieldID'] = SYSLOG_MESSAGETYPE; +$fields[SYSLOG_MESSAGETYPE]['FieldCaptionID'] = 'LN_FIELDS_MESSAGETYPE'; +$fields[SYSLOG_MESSAGETYPE]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[SYSLOG_MESSAGETYPE]['Sortable'] = true; +$fields[SYSLOG_MESSAGETYPE]['DefaultWidth'] = "90"; +$fields[SYSLOG_MESSAGETYPE]['FieldAlign'] = "center"; +$fields[SYSLOG_PROCESSID]['FieldID'] = SYSLOG_PROCESSID; +$fields[SYSLOG_PROCESSID]['FieldCaptionID'] = 'LN_FIELDS_PROCESSID'; +$fields[SYSLOG_PROCESSID]['FieldType'] = FILTER_TYPE_NUMBER; +$fields[SYSLOG_PROCESSID]['Sortable'] = true; +$fields[SYSLOG_PROCESSID]['DefaultWidth'] = "65"; +$fields[SYSLOG_PROCESSID]['FieldAlign'] = "center"; +$fields[SYSLOG_MESSAGE]['FieldID'] = SYSLOG_MESSAGE; +$fields[SYSLOG_MESSAGE]['FieldCaptionID'] = 'LN_FIELDS_MESSAGE'; +$fields[SYSLOG_MESSAGE]['FieldType'] = FILTER_TYPE_STRING; +$fields[SYSLOG_MESSAGE]['Sortable'] = false; +$fields[SYSLOG_MESSAGE]['DefaultWidth'] = "100%"; +$fields[SYSLOG_MESSAGE]['FieldAlign'] = "left"; + + // MonitorWare InfoUnit Defines define('IUT_Unknown', '0'); define('IUT_Syslog', '1'); diff --git a/src/include/functions_common.php b/src/include/functions_common.php index e3da01a..299384d 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -24,6 +24,7 @@ if ( !defined('IN_PHPLOGCON') ) // --- Basic Includes include($gl_root_path . 'include/constants_general.php'); +include($gl_root_path . 'include/constants_logstream.php'); include($gl_root_path . 'config.php'); include($gl_root_path . 'classes/class_template.php'); @@ -45,7 +46,7 @@ $LANG_EN = "en"; // Used for fallback $LANG = "en"; // Default language // Default Template vars -$content['BUILDNUMBER'] = "2.0.105"; +$content['BUILDNUMBER'] = "2.0.107"; $content['TITLE'] = "PhpLogCon - Release " . $content['BUILDNUMBER']; // Title of the Page $content['BASEPATH'] = $gl_root_path; $content['EXTRA_METATAGS'] = ""; @@ -84,7 +85,11 @@ function InitPhpLogConConfigFile() // Easier DB Access define('DB_CONFIG', $CFG['UserDBPref'] . "config"); - // Copy all entries into content variable + // If DEBUG Mode is enabled, we prepend the UID field into the col list! + if ( $CFG['MiscShowDebugMsg'] == 1 ) + array_unshift($CFG['Columns'], SYSLOG_UID); + + // Now Copy all entries into content variable foreach ($CFG as $key => $value ) $content[$key] = $value; diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php index a3ebfe9..ec74202 100644 --- a/src/include/functions_frontendhelpers.php +++ b/src/include/functions_frontendhelpers.php @@ -66,11 +66,14 @@ function CreateCurrentUrl() if ( strpos($queries[$i], "sourceid") === false ) { $tmpvars = explode ("=", $queries[$i]); - // 4Server Selector - $content['HIDDENVARS'][$counter]['varname'] = $tmpvars[0]; - $content['HIDDENVARS'][$counter]['varvalue'] = $tmpvars[1]; + if ( isset($tmpvars[1]) ) // Only if value param is set! + { + // 4Server Selector + $content['HIDDENVARS'][$counter]['varname'] = $tmpvars[0]; + $content['HIDDENVARS'][$counter]['varvalue'] = $tmpvars[1]; - $counter++; + $counter++; + } } } } diff --git a/src/index.php b/src/index.php index 0dffe66..55642be 100644 --- a/src/index.php +++ b/src/index.php @@ -34,25 +34,25 @@ // *** Default includes and procedures *** // define('IN_PHPLOGCON', true); $gl_root_path = './'; + +// Now include necessary include files! include($gl_root_path . 'include/functions_common.php'); include($gl_root_path . 'include/functions_frontendhelpers.php'); include($gl_root_path . 'include/functions_filters.php'); +// Init Langauge first! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); + // Include LogStream facility include($gl_root_path . 'classes/logstream.class.php'); InitPhpLogCon(); InitSourceConfigs(); InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! +// --- -// Init Langauge first! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); - -// Helpers for frontend filtering! -InitFilterHelpers(); -// *** *** // - -// --- Extra Stylesheet! +// --- Define Extra Stylesheet! $content['EXTRA_STYLESHEET'] = ''; // --- @@ -82,7 +82,23 @@ $content['EXPAND_HIGHLIGHT'] = "false"; //else $content['TITLE'] = "phpLogCon :: Home"; -// Read and process filters from search dialog! +// --- BEGIN Define Helper functions +function HighLightString($highlightArray, $strmsg) +{ + if ( isset($highlightArray) ) + { + // TODO OPTIMIZE - USING FONT TAG as SPAN is HIDDEN if MESSAGE POPUP is ENABNLED! + foreach( $highlightArray as $highlightword ) + $strmsg = preg_replace( "/(" . $highlightword['highlight'] . ")/i", '\\1', $strmsg ); + } + + // return result + return $strmsg; +} + +// --- + +// --- Read and process filters from search dialog! if ( (isset($_POST['search']) || isset($_GET['search'])) && (isset($_POST['filter']) || isset($_GET['filter'])) ) { // Copy search over @@ -231,21 +247,30 @@ if ( (isset($_POST['search']) || isset($_GET['search'])) && (isset($_POST['filte $content['EXPAND_HIGHLIGHT'] = "true"; } } - - - // --- // --- BEGIN Custom Code if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK ) { + // Preprocessing the fields we need + foreach($content['Columns'] as $mycolkey) + { + $content['fields'][$mycolkey]['FieldID'] = $mycolkey; + $content['fields'][$mycolkey]['FieldCaption'] = $content[ $fields[$mycolkey]['FieldCaptionID'] ]; + $content['fields'][$mycolkey]['FieldType'] = $fields[$mycolkey]['FieldType']; + $content['fields'][$mycolkey]['FieldSortable'] = $fields[$mycolkey]['Sortable']; + $content['fields'][$mycolkey]['DefaultWidth'] = $fields[$mycolkey]['DefaultWidth']; +// $content['fields'][$mycolkey]['FieldAlign'] = $fields[$mycolkey]['FieldAlign']; + } + // Obtain and get the Config Object $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; // Create LogStream Object $stream = $stream_config->LogStreamFactory($stream_config); $stream->SetFilter($content['searchstr']); - $stream->Open( array ( SYSLOG_DATE, SYSLOG_FACILITY, SYSLOG_FACILITY_TEXT, SYSLOG_SEVERITY, SYSLOG_SEVERITY_TEXT, SYSLOG_HOST, SYSLOG_SYSLOGTAG, SYSLOG_MESSAGE, SYSLOG_MESSAGETYPE ), true); + $stream->Open( $content['Columns'], true ); +// $stream->Open( array ( SYSLOG_DATE, SYSLOG_FACILITY, SYSLOG_FACILITY_TEXT, SYSLOG_SEVERITY, SYSLOG_SEVERITY_TEXT, SYSLOG_HOST, SYSLOG_SYSLOGTAG, SYSLOG_MESSAGE, SYSLOG_MESSAGETYPE ), true); $stream->SetReadDirection(EnumReadDirection::Backward); $uID = $currentUID; @@ -266,55 +291,7 @@ if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$curren do { // Copy Obtained array - $content['syslogmessages'][] = $logArray; - - // Copy UID - $content['syslogmessages'][$counter]['UID'] = $uID; - - // --- Popup Details - if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 ) - { - $content['syslogmessages'][$counter]['popupcaption'] = GetAndReplaceLangStr( $content['LN_GRID_POPUPDETAILS'], $content['syslogmessages'][$counter]['UID']); - $content['syslogmessages'][$counter]['popupdetails'] = "true"; - foreach($content['syslogmessages'][$counter] as $mykey => $myfield) - { - // Set key! - $content['syslogmessages'][$counter]['messagesdetails'][]['fieldtitle']= $mykey; - - // Get ArrayIndex - $myIndex = count($content['syslogmessages'][$counter]['messagesdetails']) - 1; - - // --- Set CSS Class - if ( $myIndex % 2 == 0 ) - $content['syslogmessages'][$counter]['messagesdetails'][$myIndex]['cssclass'] = "line1"; - else - $content['syslogmessages'][$counter]['messagesdetails'][$myIndex]['cssclass'] = "line2"; - // --- - - // Set field value - $content['syslogmessages'][$counter]['messagesdetails'][$myIndex]['fieldvalue']= $myfield; - } - } - else - $content['syslogmessages'][$counter]['popupdetails'] = "false"; - // --- - - // Set truncasted message for display - if ( isset($logArray[SYSLOG_MESSAGE]) ) - $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = GetStringWithHTMLCodes(strlen($logArray[SYSLOG_MESSAGE]) > $CFG['ViewMessageCharacterLimit'] ? substr($logArray[SYSLOG_MESSAGE], 0, $CFG['ViewMessageCharacterLimit'] ) . " ..." : $logArray[SYSLOG_MESSAGE]); - else - $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = ""; - - if ( isset($content['highlightwords']) ) - { - // We need to highlight some words ^^! - foreach( $content['highlightwords'] as $highlightword ) - $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = preg_replace( "/(" . $highlightword['highlight'] . ")/i", '\\1', $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] ); - } - - // --- Create Displayable DataStamp - $content['syslogmessages'][$counter][SYSLOG_DATE_FORMATED] = GetFormatedDate($content['syslogmessages'][$counter][SYSLOG_DATE]); - // --- +// $content['syslogmessages'][] = $logArray; // --- Set CSS Class if ( $counter % 2 == 0 ) @@ -323,32 +300,140 @@ if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$curren $content['syslogmessages'][$counter]['cssclass'] = "line2"; // --- - // --- Set Syslog severity and facility col colors - if ( isset($content['syslogmessages'][$counter][SYSLOG_SEVERITY]) && strlen($content['syslogmessages'][$counter][SYSLOG_SEVERITY]) > 0) + // --- Now we populate the values array! + foreach($content['Columns'] as $mycolkey) { - $content['syslogmessages'][$counter]['severity_color'] = $severity_colors[$content['syslogmessages'][$counter][SYSLOG_SEVERITY]]; - $content['syslogmessages'][$counter]['severity_cssclass'] = "lineColouredWhite"; - } - else - { - // Use default colour! - $content['syslogmessages'][$counter]['severity_color'] = $severity_colors[SYSLOG_INFO]; - $content['syslogmessages'][$counter]['severity_cssclass'] = $content['syslogmessages'][$counter]['cssclass']; - } + if ( isset($logArray[$mycolkey]) ) + { + // Set defaults + $content['syslogmessages'][$counter]['values'][$mycolkey]['FieldAlign'] = $fields[$mycolkey]['FieldAlign']; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = $content['syslogmessages'][$counter]['cssclass']; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = ""; + $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "false"; - if ( isset($content['syslogmessages'][$counter][SYSLOG_FACILITY]) && strlen($content['syslogmessages'][$counter][SYSLOG_FACILITY]) > 0) - { - $content['syslogmessages'][$counter]['facility_color'] = $facility_colors[$content['syslogmessages'][$counter][SYSLOG_FACILITY]]; - $content['syslogmessages'][$counter]['facility_cssclass'] = "lineColouredBlack"; + if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]); + } + else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; + + // Special style classes and colours for SYSLOG_FACILITY + if ( $mycolkey == SYSLOG_FACILITY ) + { + if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[ $logArray[SYSLOG_FACILITY] ] . '" '; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredBlack"; + + // Set Human readable Facility! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFacilityDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[SYSLOG_LOCAL0] . '" '; + } + } + else if ( $mycolkey == SYSLOG_SEVERITY ) + { + if ( isset($logArray[$mycolkey][SYSLOG_SEVERITY]) && strlen($logArray[$mycolkey][SYSLOG_SEVERITY]) > 0) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[ $logArray[SYSLOG_SEVERITY] ] . '" '; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredWhite"; + + // Set Human readable Facility! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[SYSLOG_INFO] . '" '; + } + } + else if ( $mycolkey == SYSLOG_MESSAGETYPE ) + { + } + } + else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING ) + { + // kindly copy! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; + + // Special Handling for the Syslog Message! + if ( $mycolkey == SYSLOG_MESSAGE ) + { + // Set truncasted message for display + if ( isset($logArray[SYSLOG_MESSAGE]) ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes(strlen($logArray[SYSLOG_MESSAGE]) > $CFG['ViewMessageCharacterLimit'] ? substr($logArray[SYSLOG_MESSAGE], 0, $CFG['ViewMessageCharacterLimit'] ) . " ..." : $logArray[SYSLOG_MESSAGE]); + } + else + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = ""; + + // If we need to highlight some words ^^! + if ( isset($content['highlightwords']) ) + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = HighLightString( $content['highlightwords'], $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] ); + + if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['popupcaption'] = GetAndReplaceLangStr( $content['LN_GRID_POPUPDETAILS'], $logArray[SYSLOG_UID]); + $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "true"; + + foreach($content['syslogmessages'][$counter]['values'] as $mykey => $myfield) + { + // Set Caption! + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][]['detailfieldtitle']= $content['fields'][$mykey]['FieldCaption']; + + // Get ArrayIndex + $myIndex = count($content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails']) - 1; + + // --- Set CSS Class + if ( $myIndex % 2 == 0 ) + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailscssclass'] = "line1"; + else + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailscssclass'] = "line2"; + // --- + + // If message field, we need to handle differently! + if ( $mykey == SYSLOG_MESSAGE ) + { + if ( isset($content['highlightwords']) ) + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = HighLightString( $content['highlightwords'],GetStringWithHTMLCodes($logArray[SYSLOG_MESSAGE]) ); + else + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = GetStringWithHTMLCodes($logArray[SYSLOG_MESSAGE]); + } + else // Just set field value + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = $myfield['fieldvalue']; + + } + } + + } + } + } } - else + // --- + + // --- Popup Details + if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 ) { - // Use default colour! - $content['syslogmessages'][$counter]['facility_color'] = $facility_colors[SYSLOG_LOCAL0]; - $content['syslogmessages'][$counter]['facility_cssclass'] = $content['syslogmessages'][$counter]['cssclass']; } +// else +// $content['syslogmessages'][$counter]['popupdetails'] = "false"; // --- +/* + // --- Prepare message if needed! + if ( $CFG['ShowMessage'] == 1 ) + { + + } + else + $content['syslogmessages'][$counter]['ShowMessage'] = "false"; + // --- +*/ // Increment Counter $counter++; } while ($stream->ReadNext($uID, $logArray) == SUCCESS && $counter <= $CFG['ViewEntriesPerPage']); diff --git a/src/lang/en/main.php b/src/lang/en/main.php index c52a6c8..4518a0e 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -16,13 +16,6 @@ $content['LN_GEN_PREVIOUSPAGE'] = "Previous Page"; $content['LN_ERROR_INSTALLFILEREMINDER'] = "Warning! You still have NOT removed the 'install.php' from your PhpLogCon main directory!"; $content['LN_TOP_NUM'] = "No."; $content['LN_TOP_UID'] = "uID"; -$content['LN_GRID_DATE'] = "Date"; -$content['LN_GRID_FACILITY'] = "Facility"; -$content['LN_GRID_SEVERITY'] = "Severity"; -$content['LN_GRID_SYSLOGTAG'] = "SyslogTag"; -$content['LN_GRID_INFOUNIT'] = "InfoUnit"; -$content['LN_GRID_HOST'] = "Source"; -$content['LN_GRID_MSG'] = "Message"; $content['LN_GRID_POPUPDETAILS'] = "Details for Syslogmessage with ID '%1'"; $content['LN_SEARCH_USETHISBLA'] = "Use the form below and your advanced search will appear here"; @@ -37,7 +30,6 @@ $content['LN_HIGHLIGHT'] = "Hightlight >>"; $content['LN_HIGHLIGHT_OFF'] = "Hightlight <<"; $content['LN_HIGHLIGHT_WORDS'] = "Hightlight words comma separated"; - // Filter Options $content['LN_FILTER_DATE'] = "Datetime Range"; $content['LN_FILTER_DATEMODE'] = "Select mode"; @@ -60,4 +52,15 @@ $content['LN_FILTER_MESSAGE'] = "Syslog Message"; $content['LN_FILTER_SYSLOGTAG'] = "Syslogtag"; $content['LN_FILTER_SOURCE'] = "Source (Hostname)"; +// Field Captions +$content['LN_FIELDS_DATE'] = "Date"; +$content['LN_FIELDS_FACILITY'] = "Facility"; +$content['LN_FIELDS_SEVERITY'] = "Severity"; +$content['LN_FIELDS_HOST'] = "Host"; +$content['LN_FIELDS_SYSLOGTAG'] = "Syslogtag"; +$content['LN_FIELDS_PROCESSID'] = "ProcessID"; +$content['LN_FIELDS_MESSAGETYPE'] = "Messagetype"; +$content['LN_FIELDS_UID'] = "uID"; +$content['LN_FIELDS_MESSAGE'] = "Message"; + ?> \ No newline at end of file diff --git a/src/templates/index.html b/src/templates/index.html index daa45d0..292eb49 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -92,47 +92,66 @@ - - - + + + + + + - - + + + + + + - {msgtrunscated} - -
{LN_TOP_UID}{LN_GRID_DATE}{LN_GRID_FACILITY} + + + + {FieldCaption} + + + +
{UID}{timereported_formatted} + + + {fieldvalue} + + + + {fieldvalue} + + + + + + + + + + + +
{popupcaption}
{detailfieldtitle}{detailfieldvalue}
+
+
+ +
- - - - - - - - - -
{popupcaption}
{fieldtitle}{fieldvalue}
- - - - - {msgtrunscated} - - +--> +