diff --git a/src/classes/class_template.php b/src/classes/class_template.php index c2b772c..64f0fb5 100644 --- a/src/classes/class_template.php +++ b/src/classes/class_template.php @@ -82,8 +82,8 @@ class Template { { // BEGIN DELTA MOD global $CFG; - // For ShowPageRenderStats - if ( $CFG['ShowPageRenderStats'] == 1 ) + // For MiscShowPageRenderStats + if ( $CFG['MiscShowPageRenderStats'] == 1 ) FinishPageRenderStats( $vars ); // END DELTA MOD diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index 8d7ea52..d0ab195 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -143,7 +143,6 @@ class LogStreamDisk extends LogStream { */ public function Read($uID, &$arrProperitesOut) { $this->Sseek($uID, EnumSeek::UID, 0); - $tmp = $this->_readDirection; $this->_readDirection = EnumReadDirection::Forward; $ret = $this->ReadNext($uID, $arrProperitesOut); @@ -188,7 +187,7 @@ class LogStreamDisk extends LogStream { // Loop until the filter applies, or another error occurs. } while ( $this->ApplyFilters($ret, $arrProperitesOut) != SUCCESS && $ret == SUCCESS ); - + // reached here means return result! return $ret; } @@ -211,17 +210,7 @@ class LogStreamDisk extends LogStream { $line = ''; foreach ( $this->_arrProperties as $property ) $arrProperitesOut[$property] = ''; -/* - $arrProperitesOut[SYSLOG_DATE] = ''; - $arrProperitesOut[SYSLOG_FACILITY] = ''; - $arrProperitesOut[SYSLOG_FACILITY_TEXT] = ''; - $arrProperitesOut[SYSLOG_SEVERITY] = ''; - $arrProperitesOut[SYSLOG_SEVERITY_TEXT] = ''; - $arrProperitesOut[SYSLOG_HOST] = ''; - $arrProperitesOut[SYSLOG_SYSLOGTAG] = ''; - $arrProperitesOut[SYSLOG_MESSAGE] = ''; - $arrProperitesOut[SYSLOG_MESSAGETYPE] = ''; -*/ + do { $pos = -1; if (($pos = strpos($this->_buffer, "\n", $this->_p_buffer)) !== false) { @@ -269,17 +258,6 @@ class LogStreamDisk extends LogStream { $line = ''; foreach ( $this->_arrProperties as $property ) $arrProperitesOut[$property] = ''; -/* - $arrProperitesOut[SYSLOG_DATE] = ''; - $arrProperitesOut[SYSLOG_FACILITY] = ''; - $arrProperitesOut[SYSLOG_FACILITY_TEXT] = ''; - $arrProperitesOut[SYSLOG_SEVERITY] = ''; - $arrProperitesOut[SYSLOG_SEVERITY_TEXT] = ''; - $arrProperitesOut[SYSLOG_HOST] = ''; - $arrProperitesOut[SYSLOG_SYSLOGTAG] = ''; - $arrProperitesOut[SYSLOG_MESSAGE] = ''; - $arrProperitesOut[SYSLOG_MESSAGETYPE] = ''; -*/ do { $pos = -1; diff --git a/src/classes/logstreamlineparsersyslog.class.php b/src/classes/logstreamlineparsersyslog.class.php index 1b60de4..f7e5fc6 100644 --- a/src/classes/logstreamlineparsersyslog.class.php +++ b/src/classes/logstreamlineparsersyslog.class.php @@ -93,7 +93,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser { if ( strlen($arrArguments[SYSLOG_MESSAGE]) > 0 ) { // TODO: Cannot Parse Syslog message with this pattern! - die ("wtf syslog - '" . $arrArguments[SYSLOG_MESSAGE] . "'"); + echo ("wtf syslog - '" . $arrArguments[SYSLOG_MESSAGE] . "'
"); } } diff --git a/src/config.php b/src/config.php index ce9b304..ed2a162 100644 --- a/src/config.php +++ b/src/config.php @@ -1,81 +1,91 @@ Configuration need variables for the Database connection - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution. - ********************************************************************* - */ +/* + ********************************************************************* + * phpLogCon - http://www.phplogcon.org + * ----------------------------------------------------------------- + * Main Configuration File + * + * -> Configuration need variables for the Database connection + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ - // --- Avoid directly accessing this file! - if ( !defined('IN_PHPLOGCON') ) - { - die('Hacking attempt'); - exit; - } - // --- +// --- Avoid directly accessing this file! +if ( !defined('IN_PHPLOGCON') ) +{ + die('Hacking attempt'); + exit; +} +// --- - // --- Database options - $CFG['UseDB'] = false; - $CFG['DBServer'] = "localhost"; - $CFG['Port'] = 3306; - $CFG['DBName'] = ""; - $CFG['TBPref'] = "logcon_"; - $CFG['User'] = "root"; - $CFG['Pass'] = ""; - // --- - - // --- Generic Options - $CFG['ShowDebugMsg'] = 1; - $CFG["ShowPageRenderStats"] = 1; // If enabled, you will see Pagerender Settings - // --- +// --- Database options +$CFG['UserDBEnabled'] = false; +$CFG['UserDBServer'] = "localhost"; +$CFG['UserDBPort'] = 3306; +$CFG['UserDBName'] = ""; +$CFG['UserDBPref'] = "logcon_"; +$CFG['UserDBUser'] = "root"; +$CFG['UserDBPass'] = ""; +// --- - // --- Default Frontend Options +// --- Misc Options +$CFG['MiscShowDebugMsg'] = 1; +$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['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. - // --- Source Options - $CFG['Sources'][0]['ID'] = "Source1"; - $CFG['Sources'][0]['Name'] = "Syslog Disk File"; - $CFG['Sources'][0]['SourceType'] = SOURCE_DISK; - $CFG['Sources'][0]['LogLineType'] = "syslog"; - $CFG['Sources'][0]['DiskFile'] = $gl_root_path . "samplelogs/syslog"; - $CFG['Sources'][1]['ID'] = "Source2"; - $CFG['Sources'][1]['Name'] = "Old Syslog Disk File"; - $CFG['Sources'][1]['SourceType'] = SOURCE_DISK; - $CFG['Sources'][1]['LogLineType'] = "syslog"; - $CFG['Sources'][1]['DiskFile'] = $gl_root_path . "samplelogs/syslog.0"; - $CFG['Sources'][2]['ID'] = "Source3"; - $CFG['Sources'][2]['Name'] = "RSyslog Disk File"; - $CFG['Sources'][2]['SourceType'] = SOURCE_DISK; - $CFG['Sources'][2]['LogLineType'] = "syslog"; - $CFG['Sources'][2]['DiskFile'] = $gl_root_path . "samplelogs/rsyslog"; - $CFG['Sources'][3]['ID'] = "Source4"; - $CFG['Sources'][3]['Name'] = "WinSyslog Disk File"; - $CFG['Sources'][3]['SourceType'] = SOURCE_DISK; - $CFG['Sources'][3]['LogLineType'] = "winsyslog"; - $CFG['Sources'][3]['DiskFile'] = $gl_root_path . "samplelogs/winsyslog"; - // --- +$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 + +// --- + +// --- Source Options +$CFG['Sources'][Source1]['ID'] = "Source1"; +$CFG['Sources'][Source1]['Name'] = "Syslog Disk File"; +$CFG['Sources'][Source1]['SourceType'] = SOURCE_DISK; +$CFG['Sources'][Source1]['LogLineType'] = "syslog"; +$CFG['Sources'][Source1]['DiskFile'] = $gl_root_path . "samplelogs/syslog"; + +$CFG['Sources'][Source2]['ID'] = "Source2"; +$CFG['Sources'][Source2]['Name'] = "Old Syslog Disk File"; +$CFG['Sources'][Source2]['SourceType'] = SOURCE_DISK; +$CFG['Sources'][Source2]['LogLineType'] = "syslog"; +$CFG['Sources'][Source2]['DiskFile'] = $gl_root_path . "samplelogs/syslog.0"; + +$CFG['Sources'][Source3]['ID'] = "Source3"; +$CFG['Sources'][Source3]['Name'] = "RSyslog Disk File"; +$CFG['Sources'][Source3]['SourceType'] = SOURCE_DISK; +$CFG['Sources'][Source3]['LogLineType'] = "syslog"; +$CFG['Sources'][Source3]['DiskFile'] = $gl_root_path . "samplelogs/rsyslog"; + +$CFG['Sources'][Source4]['ID'] = "Source4"; +$CFG['Sources'][Source4]['Name'] = "WinSyslog Disk File"; +$CFG['Sources'][Source4]['SourceType'] = SOURCE_DISK; +$CFG['Sources'][Source4]['LogLineType'] = "winsyslog"; +$CFG['Sources'][Source4]['DiskFile'] = $gl_root_path . "samplelogs/winsyslog"; +// --- ?> diff --git a/src/css/highlight.css b/src/css/highlight.css new file mode 100644 index 0000000..9d4adec --- /dev/null +++ b/src/css/highlight.css @@ -0,0 +1,82 @@ +/* Generic Style defintions */ +.highlight_1 +{ + color: #F61313; + background-color: #FFFFFF; +} +.highlight_2 +{ + color: #F66913; + background-color: #FFFFFF; +} +.highlight_3 +{ + color: #17911C; + background-color: #FFFFFF; +} +.highlight_4 +{ + color: #C01695; + background-color: #FFFFFF; +} +.highlight_5 +{ + color: #1D618B; + background-color: #FFFFFF; +} +.highlight_6 +{ + color: #6C9117; + background-color: #FFFFFF; +} +.highlight_7 +{ + color: #0F2B7F; + background-color: #FFFFFF; +} +.highlight_8 +{ + color: #541791; + background-color: #FFFFFF; +} +.highlight_9 +{ + color: #146043; + background-color: #FFFFFF; +} + +.highlight_10 +{ + color: #FF5451; + background-color: #333333; +} +.highlight_11 +{ + color: #F8C858; + background-color: #333333; +} +.highlight_12 +{ + color: #FCFF84; + background-color: #333333; +} +.highlight_13 +{ + color: #CEF07A; + background-color: #333333; +} +.highlight_14 +{ + color: #7AF0C2; + background-color: #333333; +} +.highlight_15 +{ + color: #84AFFF; + background-color: #333333; +} +.highlight_16 +{ + color: #A684FF; + background-color: #333333; +} \ No newline at end of file diff --git a/src/include/constants_general.php b/src/include/constants_general.php index 62ff5e9..0a0a1b0 100644 --- a/src/include/constants_general.php +++ b/src/include/constants_general.php @@ -68,6 +68,24 @@ define('SYSLOG_LOCAL4', 20); define('SYSLOG_LOCAL5', 21); define('SYSLOG_LOCAL6', 22); define('SYSLOG_LOCAL7', 23); +$facility_colors[SYSLOG_KERN] = "#F1BEA7"; +$facility_colors[SYSLOG_USER] = "#F1D0A7"; +$facility_colors[SYSLOG_MAIL] = "#F1E3A7"; +$facility_colors[SYSLOG_DAEMON] = "#E5F1A7"; +$facility_colors[SYSLOG_AUTH] = "#D3F1A7"; +$facility_colors[SYSLOG_SYSLOG] = "#C1F1A7"; +$facility_colors[SYSLOG_LPR] = "#A7F1D6"; +$facility_colors[SYSLOG_NEWS] = "#A7F1E8"; +$facility_colors[SYSLOG_UUCP] = "#A7E1F1"; +$facility_colors[SYSLOG_CRON] = "#A7C8F1"; +$facility_colors[SYSLOG_LOCAL0] = "#F2F2F2"; +$facility_colors[SYSLOG_LOCAL1] = "#E4E5E6"; +$facility_colors[SYSLOG_LOCAL2] = "#D6D9DA"; +$facility_colors[SYSLOG_LOCAL3] = "#C9CDCF"; +$facility_colors[SYSLOG_LOCAL4] = "#BEC2C4"; +$facility_colors[SYSLOG_LOCAL5] = "#B1B6B9"; +$facility_colors[SYSLOG_LOCAL6] = "#A3AAAD"; +$facility_colors[SYSLOG_LOCAL7] = "#969DA1"; define('SYSLOG_EMERG', 0); define('SYSLOG_ALERT', 1); @@ -77,6 +95,14 @@ define('SYSLOG_WARNING', 4); define('SYSLOG_NOTICE', 5); define('SYSLOG_INFO', 6); define('SYSLOG_DEBUG', 7); +$severity_colors[SYSLOG_EMERG] = "#840A15"; +$severity_colors[SYSLOG_ALERT] = "#BA0716"; +$severity_colors[SYSLOG_CRIT] = "#CE0819"; +$severity_colors[SYSLOG_ERR] = "#FF0A1F"; +$severity_colors[SYSLOG_WARNING] = "#EF8200"; +$severity_colors[SYSLOG_NOTICE] = "#14AD42"; +$severity_colors[SYSLOG_INFO] = "#0C9C91"; +$severity_colors[SYSLOG_DEBUG] = "#119BDE"; // --- ?> \ No newline at end of file diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 390aaf6..e3da01a 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -50,6 +50,7 @@ $content['TITLE'] = "PhpLogCon - Release " . $content['BUILDNUMBER']; // Title o $content['BASEPATH'] = $gl_root_path; $content['EXTRA_METATAGS'] = ""; $content['EXTRA_JAVASCRIPT'] = ""; +$content['EXTRA_STYLESHEET'] = ""; // --- function InitBasicPhpLogCon() @@ -81,10 +82,14 @@ function InitPhpLogConConfigFile() include_once($gl_root_path . 'config.php'); // Easier DB Access - define('DB_CONFIG', $CFG['TBPref'] . "config"); + define('DB_CONFIG', $CFG['UserDBPref'] . "config"); - // For ShowPageRenderStats - if ( $CFG['ShowPageRenderStats'] == 1 ) + // Copy all entries into content variable + foreach ($CFG as $key => $value ) + $content[$key] = $value; + + // For MiscShowPageRenderStats + if ( $CFG['MiscShowPageRenderStats'] == 1 ) { $content['ShowPageRenderStats'] = "true"; InitPageRenderStats(); @@ -127,7 +132,7 @@ function InitPhpLogCon() InitPhpLogConConfigFile(); // Establish DB Connection - if ( $CFG['UseDB'] ) + if ( $CFG['UserDBEnabled'] ) DB_Connect(); // Now load the Page configuration values @@ -233,7 +238,7 @@ function InitConfigurationValues() $rows = DB_GetAllRows($result, true, true); // If Database is enabled, try to read from database! - if ( $CFG['UseDB'] ) + if ( $CFG['UserDBEnabled'] ) { if ( isset($rows ) ) { @@ -527,7 +532,7 @@ function CheckUserLogin( $username, $password ) } else { - if ( $CFG['ShowDebugMsg'] == 1 ) + if ( $CFG['MiscShowDebugMsg'] == 1 ) DieWithFriendlyErrorMsg( "Debug Error: Could not login user '" . $username . "'

Sessionarray
" . var_export($_SESSION, true) . "

SQL Statement: " . $sqlselect ); // Default return false diff --git a/src/include/functions_config.php b/src/include/functions_config.php index ef9b937..725df53 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -33,56 +33,47 @@ if ( isset($CFG['Sources']) ) { $iCount = count($CFG['Sources']); - for ( $i = 0; $i< $iCount; $i++ ) + foreach( $CFG['Sources'] as &$mysource ) { - if ( isset($CFG['Sources'][$i]['SourceType']) ) + if ( isset($mysource['SourceType']) ) { // Set Array Index, TODO: Check for invalid characters! - $iSourceID = $CFG['Sources'][$i]['ID']; - if ( !isset($content['Sources'][$iSourceID]) ) + $iSourceID = $mysource['ID']; + // Copy general properties +// $content['Sources'][$iSourceID]['ID'] = $mysource['ID']; +// $content['Sources'][$iSourceID]['Name'] = $mysource['Name']; +// $content['Sources'][$iSourceID]['SourceType'] = $mysource['SourceType']; + + // Set default if not set! + if ( !isset($mysource['LogLineType']) ) + $content['Sources'][$iSourceID]['LogLineType'] = "syslog"; + + // Only for the display box + $content['Sources'][$iSourceID]['selected'] = ""; + + // Create Config instance! + if ( $mysource['SourceType'] == SOURCE_DISK ) { - // Copy general properties - $content['Sources'][$iSourceID]['ID'] = $CFG['Sources'][$i]['ID']; - $content['Sources'][$iSourceID]['Name'] = $CFG['Sources'][$i]['Name']; - $content['Sources'][$iSourceID]['SourceType'] = $CFG['Sources'][$i]['SourceType']; - - // Optional parameters - if ( isset($CFG['Sources'][$i]['LogLineType']) ) - $content['Sources'][$iSourceID]['LogLineType'] = $CFG['Sources'][$i]['LogLineType']; - else // Default = syslog - $content['Sources'][$iSourceID]['LogLineType'] = "syslog"; - - // Only for the display box - $content['Sources'][$iSourceID]['selected'] = ""; - - // Create Config instance! - if ( $CFG['Sources'][$i]['SourceType'] == SOURCE_DISK ) - { - $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDisk(); - $content['Sources'][$iSourceID]['ObjRef']->FileName = $CFG['Sources'][$i]['DiskFile']; - $content['Sources'][$iSourceID]['ObjRef']->LineParserType = $CFG['Sources'][$i]['LogLineType']; - } - else if ( $CFG['Sources'][$i]['SourceType'] == SOURCE_MYSQLDB ) - { - // TODO! - die( "Not supported yet!" ); - } - else - { - // UNKNOWN, remove config entry! - unset($content['Sources'][$iSourceID]); - - // TODO: Output CONFIG WARNING - } - - // Set default SourceID here! - if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) ) - $currentSourceID = $iSourceID; + $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDisk(); + $content['Sources'][$iSourceID]['ObjRef']->FileName = $mysource['DiskFile']; + $content['Sources'][$iSourceID]['ObjRef']->LineParserType = $mysource['LogLineType']; + } + else if ( $mysource['SourceType'] == SOURCE_MYSQLDB ) + { + // TODO! + die( "Not supported yet!" ); } else - { - // TODO: OUTPUT CONFIG WARNING - duplicated ID! + { + // UNKNOWN, remove config entry! + unset($content['Sources'][$iSourceID]); + + // TODO: Output CONFIG WARNING } + + // Set default SourceID here! + if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) ) + $currentSourceID = $iSourceID; } } } diff --git a/src/index.php b/src/index.php index e2c211d..5f0ecc5 100644 --- a/src/index.php +++ b/src/index.php @@ -52,6 +52,10 @@ IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); InitFilterHelpers(); // *** *** // +// --- Extra Stylesheet! +$content['EXTRA_STYLESHEET'] = ''; +// --- + // --- CONTENT Vars if ( isset($_GET['uid']) ) { @@ -69,6 +73,9 @@ $content['uid_last'] = UID_UNKNOWN; // Init Sorting variables $content['sorting'] = ""; $content['searchstr'] = ""; +$content['highlightstr'] = ""; +$content['EXPAND_HIGHLIGHT'] = "false"; + //if ( isset($content['myserver']) ) // $content['TITLE'] = "phpLogCon :: Home :: Server '" . $content['myserver']['Name'] . "'"; // Title of the Page @@ -76,9 +83,27 @@ $content['searchstr'] = ""; $content['TITLE'] = "phpLogCon :: Home"; // Read and process filters from search dialog! -if ( isset($_POST['search']) ) +if ( (isset($_POST['search']) || isset($_GET['search'])) && (isset($_POST['filter']) || isset($_GET['filter'])) ) { - if ( $_POST['search'] == $content['LN_SEARCH_PERFORMADVANCED']) + // Copy search over + if ( isset($_POST['search']) ) + $mysearch = $_POST['search']; + else + $mysearch = $_GET['search']; + + if ( isset($_POST['search']) ) + $myfilter = $_POST['filter']; + else + $myfilter = $_GET['filter']; + + // Optionally read highlight words + if ( isset($_POST['highlight']) ) + $content['highlightstr'] = $_POST['highlight']; + else if ( isset($_GET['highlight']) ) + $content['highlightstr'] = $_GET['highlight']; + + // Evaluate search now + if ( $mysearch == $content['LN_SEARCH_PERFORMADVANCED']) { if ( isset($_POST['filter_datemode']) ) { @@ -165,11 +190,41 @@ if ( isset($_POST['search']) ) $content['searchstr'] .= $_POST['filter_message']; } - else if ( $_POST['search'] == $content['LN_SEARCH']) + else if ( $mysearch == $content['LN_SEARCH']) { // Message is just appended - if ( isset($_POST['filter']) && strlen($_POST['filter']) > 0 ) - $content['searchstr'] = $_POST['filter']; + if ( isset($myfilter) && strlen($myfilter) > 0 ) + $content['searchstr'] = $myfilter; + } + + if ( strlen($content['highlightstr']) > 0 ) + { + // user also wants to highlight words! + if ( strpos($content['highlightstr'], ",") === false) + { + $content['highlightwords'][0]['highlight'] = $content['highlightstr']; + $content['highlightwords'][0]['cssclass'] = "highlight_1"; + $content['highlightwords'][0]['htmlcode'] = '' . $content['highlightwords'][0]['highlight']. ''; + } + else + { + // Split array into words + $tmparray = explode( ",", $content['highlightstr'] ); + foreach( $tmparray as $word ) + { + $content['highlightwords'][]['highlight'] = $word; + } + + // Assign CSS Class to highlight words + for ($i = 0; $i < count($content['highlightwords']); $i++) + { + $content['highlightwords'][$i]['cssclass'] = "highlight_" . ($i+1); + $content['highlightwords'][$i]['htmlcode'] = '' . $content['highlightwords'][$i]['highlight']. ''; + } + } + + // Default expand Highlight Arrea! + $content['EXPAND_HIGHLIGHT'] = "true"; } } @@ -188,36 +243,102 @@ if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$curren $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->SetReadDirection(EnumReadDirection::Backward); - + $uID = $currentUID; $counter = 0; - - while ($stream->ReadNext($uID, $logArray) == SUCCESS && $counter <= 30) + + if ($uID != UID_UNKNOWN) { - // Copy Obtained array - $content['syslogmessages'][] = $logArray; - - // Copy UID - $content['syslogmessages'][$counter]['UID'] = $uID; - - // Set truncasted message for display - if ( isset($logArray[SYSLOG_MESSAGE]) ) - $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = GetStringWithHTMLCodes(strlen($logArray[SYSLOG_MESSAGE]) > 100 ? substr($logArray[SYSLOG_MESSAGE], 0, 100 ) . " ..." : $logArray[SYSLOG_MESSAGE]); - else - $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = ""; - - // Create Displayable DataStamp - $content['syslogmessages'][$counter][SYSLOG_DATE_FORMATED] = GetFormatedDate($content['syslogmessages'][$counter][SYSLOG_DATE]); - - // Increment Counter - $counter++; + // First read will also set the start position of the Stream! + $ret = $stream->Read($uID, $logArray); } + else + $ret = $stream->ReadNext($uID, $logArray); - if ( $stream->ReadNext($uID, $logArray) == SUCCESS ) + + if ( $ret == SUCCESS ) { - $content['uid_next'] = $uID; - // Enable Player Pager - $content['main_pagerenabled'] = "true"; + //Loop through the messages! + do + { + // Copy Obtained array + $content['syslogmessages'][] = $logArray; + + // Copy UID + $content['syslogmessages'][$counter]['UID'] = $uID; + + // Set truncasted message for display + if ( isset($logArray[SYSLOG_MESSAGE]) ) + $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = GetStringWithHTMLCodes(strlen($logArray[SYSLOG_MESSAGE]) > 100 ? substr($logArray[SYSLOG_MESSAGE], 0, 100 ) . " ..." : $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] ); +// $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] = str_ireplace( $highlightword['highlight'], $highlightword['htmlcode'], $content['syslogmessages'][$counter][SYSLOG_MESSAGETRUNSCATED] ); + } + + // Create Displayable DataStamp + $content['syslogmessages'][$counter][SYSLOG_DATE_FORMATED] = GetFormatedDate($content['syslogmessages'][$counter][SYSLOG_DATE]); + + // --- Set CSS Class + if ( $counter % 2 == 0 ) + $content['syslogmessages'][$counter]['cssclass'] = "line1"; + else + $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) + { + $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($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"; + } + else + { + // Use default colour! + $content['syslogmessages'][$counter]['facility_color'] = $facility_colors[SYSLOG_LOCAL0]; + $content['syslogmessages'][$counter]['facility_cssclass'] = $content['syslogmessages'][$counter]['cssclass']; + } + + // --- + + // Increment Counter + $counter++; + } while ($stream->ReadNext($uID, $logArray) == SUCCESS && $counter <= $CFG['ViewEntriesPerPage']); + + if ( $stream->ReadNext($uID, $logArray) == SUCCESS ) + { + $content['uid_next'] = $uID; + // Enable Pager + $content['main_pagerenabled'] = "true"; + } + else if ( $currentUID != UID_UNKNOWN ) + { + // We can still go back, enable Pager + $content['main_pagerenabled'] = "true"; + } + + // This will enable to Main SyslogView + $content['syslogmessagesenabled'] = "true"; + } + else + { + // TODO DISPLAY MISSING LOGDATA! } // Close file! @@ -229,21 +350,6 @@ if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$curren //$content['syslogmessages'][0] = array ( SYSLOG_DATE => "Feb 7 17:56:24", SYSLOG_FACILITY => 0, SYSLOG_FACILITY_TEXT => "kernel", SYSLOG_SEVERITY => 5, SYSLOG_SEVERITY_TEXT => "notice", SYSLOG_HOST => "localhost", SYSLOG_SYSLOGTAG => "RSyslogTest", SYSLOG_MESSAGE => "Kernel log daemon terminating.", SYSLOG_MESSAGETYPE => IUT_Syslog, ); //$content['syslogmessages'][1] = array ( SYSLOG_DATE => "Feb 6 18:56:24", SYSLOG_FACILITY => 0, SYSLOG_FACILITY_TEXT => "kernel", SYSLOG_SEVERITY => 5, SYSLOG_SEVERITY_TEXT => "notice", SYSLOG_HOST => "localhost", SYSLOG_SYSLOGTAG => "RSyslogTest", SYSLOG_MESSAGE => "Kernel log daemon terminating.", SYSLOG_MESSAGETYPE => IUT_Syslog, ); -if ( isset($content['syslogmessages']) && count($content['syslogmessages']) > 0 ) -{ - // This will enable to Main SyslogView - $content['syslogmessagesenabled'] = "true"; - - for($i = 0; $i < count($content['syslogmessages']); $i++) - { - // --- Set CSS Class - if ( $i % 2 == 0 ) - $content['syslogmessages'][$i]['cssclass'] = "line1"; - else - $content['syslogmessages'][$i]['cssclass'] = "line2"; - // --- - } -} // --- // --- Parsen and Output diff --git a/src/js/common.js b/src/js/common.js index ccb4a36..c670df9 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -90,3 +90,29 @@ function hidevisibility(ElementNameToggle, ElementNameButton) toggle.style.visibility = "hidden"; toggle.style.display = "none"; } + +function ResetFormValues(formName) +{ + var myform = document.getElementById(formName); + var i = 0; + var iCount = myform.elements.length; + + // Loop through text fields + for(i = 0; i < iCount; i++) + { + if (myform.elements[i].type == "text" ) + { + // Reset textfield + myform.elements[i].value = ""; + } + } +} + +function SubmitForm(formName) +{ + var myform = document.getElementById(formName); + if (myform != null) + { + myform.submit(); + } +} \ No newline at end of file diff --git a/src/lang/en/main.php b/src/lang/en/main.php index 6924ec2..3ee6842 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -27,11 +27,15 @@ $content['LN_GRID_MSG'] = "Message"; $content['LN_SEARCH_USETHISBLA'] = "Use the form below and your advanced search will appear here"; $content['LN_SEARCH_FILTER'] = "Search (filter):"; $content['LN_SEARCH_ADVANCED'] = "Advanced Search"; -$content['LN_SEARCH_FEELSAD'] = "I'm feeling sad ..."; +//$content['LN_SEARCH_FEELSAD'] = "I'm feeling sad ..."; $content['LN_SEARCH'] = "Search"; $content['LN_SEARCH_RESET'] = "Reset search"; $content['LN_SEARCH_PERFORMADVANCED'] = "Perform Advanced Search"; +$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"; diff --git a/src/templates/include_header.html b/src/templates/include_header.html index 2160975..1164a50 100644 --- a/src/templates/include_header.html +++ b/src/templates/include_header.html @@ -3,9 +3,9 @@ {TITLE} {EXTRA_METATAGS} - + {EXTRA_STYLESHEET} {EXTRA_JAVASCRIPT} diff --git a/src/templates/index.html b/src/templates/index.html index a1df5c0..2c349d1 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,7 +1,7 @@ - + + + +
@@ -11,8 +11,9 @@
- - + + +
@@ -21,186 +22,47 @@ (sample: faciliy:local0 severity:warn)
+ + + + + + + + + + + + + +
+ {LN_HIGHLIGHT_WORDS}
+ + +
+ + + + + + +
{highlight}
+
+
+
-
- -
- - - - - - - - - - - - - - -
- - - - - - - - - -
- {LN_FILTER_DATE}
{LN_FILTER_DATEMODE} - -
- -
- - - - - - - - - -
{LN_FILTER_DATEFROM} - - - - - - - -
{LN_FILTER_DATETO} - - - - - - - -
-
- -
- - - - - -
{LN_FILTER_DATELASTX} - -
-
- - -
  - - - - - - - - - - - -
- {LN_FILTER_OTHERS}
{LN_FILTER_FACILITY} - - {LN_FILTER_SEVERITY} - -
-
- - - - - - - - -
- {LN_FILTER_MESSAGE}
- -
-
  - - - - - - - - - - -
{LN_FILTER_SYSLOGTAG} - -
{LN_FILTER_SOURCE} - -
-
-
- -
-
- -
-
- + + + @@ -244,8 +106,8 @@ - - + + diff --git a/src/themes/dark/main.css b/src/themes/dark/main.css index 3ec40eb..45f6c40 100644 --- a/src/themes/dark/main.css +++ b/src/themes/dark/main.css @@ -183,6 +183,16 @@ font background-color:#F9F9F9; background-image: url("images/dither.png"); } +.lineColouredWhite +{ + font-size: 8pt; + color: #FFFFFF; +} +.lineColouredBlack +{ + font-size: 8pt; + color: #000000; +} /* TOP Menu Classes */ .topmenu1 diff --git a/src/themes/default/main.css b/src/themes/default/main.css index facb6b7..a0b655c 100644 --- a/src/themes/default/main.css +++ b/src/themes/default/main.css @@ -183,6 +183,16 @@ font background-color:#F9F9F9; background-image: url("images/dither.png"); } +.lineColouredWhite +{ + font-size: 8pt; + color: #FFFFFF; +} +.lineColouredBlack +{ + font-size: 8pt; + color: #000000; +} /* TOP Menu Classes */ .topmenu1
{UID} {timereported_formatted}{syslogfacility-text}{syslogseverity-text}{syslogfacility-text}{syslogseverity-text} {syslogtag} {IUT} {FROMHOST}