diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php
index e550f5c..64845e0 100644
--- a/src/classes/logstream.class.php
+++ b/src/classes/logstream.class.php
@@ -99,14 +99,7 @@ abstract class LogStream {
*/
public abstract function Read($uID, &$arrProperitesOut);
- /**
- * Set the direction the stream should read data.
- *
- * @param enumReadDirectionfilter EnumReadDirection in: The new direction.
- * @return integer Error state
- */
- public abstract function SetReadDirection($enumReadDirection);
-
+
/**
* Sseek - a strange seek which has a skip capability
*
@@ -184,9 +177,23 @@ abstract class LogStream {
{
// Parse Filters from string
$this->ParseFilters($szFilters);
-
return SUCCESS;
}
+
+ /**
+ * Set the direction the stream should read data.
+ *
+ *
+ *
+ * @param enumReadDirectionfilter EnumReadDirection in: The new direction.
+ * @return integer Error state
+ */
+ public function SetReadDirection($enumReadDirection)
+ {
+ // Set the new read direction!
+ $this->_readDirection = $enumReadDirection;
+ return SUCCESS;
+ }
/**
* Helper function to parse filters into a useful filter array we can work with.
@@ -318,147 +325,9 @@ abstract class LogStream {
// print_r ($this->_filters);
}
- /**
- * Helper function to parse filters into a useful filter array we can work with.
+ /*
+ * Helpre function needed in ParseFilters
*/
- protected function ApplyFilters($myResults, &$arrProperitesOut)
- {
- // IF result was unsuccessfull, return success - nothing we can do here.
- if ( $myResults >= ERROR )
- return SUCCESS;
-
- if ( $this->_filters != null )
- {
- // Evaluation default for now is true
- $bEval = true;
-
- // Loop through set properties
- foreach( $arrProperitesOut as $propertyname => $propertyvalue )
- {
- // TODO: NOT SURE IF THIS WILL WORK ON NUMBERS AND OTHER TYPES RIGHT NOW
- if (
- array_key_exists($propertyname, $this->_filters) &&
- isset($propertyvalue) &&
- !(is_string($propertyvalue) && strlen($propertyvalue) <= 0 ) /* Negative because it only matters if the propvalure is a string*/
- )
- {
- // Extra var needed for number checks!
- $bIsOrFilter = false; // If enabled we need to check for numbereval later
- $bOrFilter = false;
-
- // Found something to filter, so do it!
- foreach( $this->_filters[$propertyname] as $myfilter )
- {
- switch( $myfilter[FILTER_TYPE] )
- {
- case FILTER_TYPE_STRING:
- // If Syslog message, we have AND handling!
- if ( $propertyname == SYSLOG_MESSAGE )
- {
- // Include Filter
- if ( $myfilter[FILTER_MODE] == FILTER_MODE_INCLUDE )
- {
- if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false )
- $bEval = false;
- }
- // Exclude Filter
- else if ( $myfilter[FILTER_MODE] == FILTER_MODE_EXCLUDE )
- {
- if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
- $bEval = false;
- }
- }
- // Otherwise we use OR Handling!
- else
- {
- $bIsOrFilter = true; // Set isOrFilter to true
- if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
- $bOrFilter = true;
- break;
- }
- break;
- case FILTER_TYPE_NUMBER:
- $bIsOrFilter = true; // Set to true in any case!
- if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] )
- $bOrFilter = true;
- break;
- case FILTER_TYPE_DATE:
- // Get Log TimeStamp
- $nLogTimeStamp = $arrProperitesOut[$propertyname][EVTIME_TIMESTAMP];
-
- if ( $myfilter[FILTER_DATEMODE] == DATEMODE_LASTX )
- {
- // Get current timestamp
- $nNowTimeStamp = time();
-
- if ( $myfilter[FILTER_VALUE] == DATE_LASTX_HOUR )
- $nLastXTime = 60 * 60; // One Hour!
- else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS )
- $nLastXTime = 60 * 60 * 12; // 12 Hours!
- else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS )
- $nLastXTime = 60 * 60 * 24; // 24 Hours!
- else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS )
- $nLastXTime = 60 * 60 * 24 * 7; // 7 days
- else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS )
- $nLastXTime = 60 * 60 * 24 * 31; // 31 days
- else
- // WTF default?
- $nLastXTime = 86400;
- // If Nowtime + LastX is higher then the log timestamp, the this logline is to old for us.
- if ( ($nNowTimeStamp - $nLastXTime) > $nLogTimeStamp )
- $bEval = false;
- }
- else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
- {
- // Get filter timestamp!
- $nFromTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]);
-
- // If logtime is smaller then FromTime, then the Event is outside of our scope!
- if ( $nLogTimeStamp < $nFromTimeStamp )
- $bEval = false;
- }
- else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
- {
- // Get filter timestamp!
-// echo $myfilter[FILTER_VALUE];
- $nToTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]);
-
- // If logtime is smaller then FromTime, then the Event is outside of our scope!
- if ( $nLogTimeStamp > $nToTimeStamp )
- $bEval = false;
- }
-
- break;
- default:
- // TODO!
- break;
- }
- }
-
- // If was number filter, we apply it the evaluation.
- if ( $bIsOrFilter )
- $bEval &= $bOrFilter;
-
- if ( !$bEval )
- {
- // unmatching filter, rest property array
- foreach ( $this->_arrProperties as $property )
- $arrProperitesOut[$property] = '';
-
- // return error!
- return ERROR_FILTER_NOT_MATCH;
- }
- }
- }
-
- // Reached this point means filters did match!
- return SUCCESS;
- }
- else // No filters at all means success!
- return SUCCESS;
- }
-
-
private function SetFilterIncludeMode(&$szValue)
{
diff --git a/src/classes/logstreamconfigdb.class.php b/src/classes/logstreamconfigdb.class.php
new file mode 100644
index 0000000..97e6c02
--- /dev/null
+++ b/src/classes/logstreamconfigdb.class.php
@@ -0,0 +1,97 @@
+ www.phplogcon.org <- *
+ * ----------------------------------------------------------------- *
+ * StreamConfig has the capability to create a specific LogStream *
+ * object depending on a configured LogStream*Config object. *
+ * *
+ * All directives are explained within this file *
+ *
+ * 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
";
+ $errormsg.="mysql error: $errdesc
";
+ $errormsg.="mysql error number: $errno
";
+ $errormsg.="Date: ".date("d.m.Y @ H:i"). "
";
+ $errormsg.="Script: ".getenv("REQUEST_URI"). "
";
+ $errormsg.="Referer: ".getenv("HTTP_REFERER"). "
";
+
+ //Output!
+ print( $errormsg );
+ }
+ }
+
+ /*
+ * Returns the number of possible records by using a query
+ */
+ private function GetRowCountByString($szQuery)
+ {
+ if ($myQuery = mysql_query($szQuery))
+ {
+ $num_rows = mysql_num_rows($myQuery);
+ mysql_free_result ($myQuery);
+ }
+ return $num_rows;
+ }
+
+ /*
+ * Returns the number of possible records by using an existing queryid
+ */
+ private function GetRowCountByQueryID($myQuery)
+ {
+ $num_rows = mysql_num_rows($myQuery);
+ return $num_rows;
+ }
+
+ /*
+ * Returns the number of possible records by using a select count statement!
+ */
+ private function GetRowCountFromTable()
+ {
+ global $dbmapping;
+ $szTableType = $this->_logStreamConfigObj->DBTableType;
+
+ // Create Statement and perform query!
+ $szQuery = "SELECT count(" . $dbmapping[$szTableType][SYSLOG_UID] . ") FROM " . $this->_logStreamConfigObj->DBTableName . $this->_SQLwhereClause;
+ if ($myQuery = mysql_query($szQuery))
+ {
+ // obtain first and only row
+ $myRow = mysql_fetch_row($myQuery);
+ $numRows = $myRow[0];
+
+ // Free query now
+ mysql_free_result ($myQuery);
+ }
+
+ // return result!
+ return $numRows;
+ }
+
+
+}
+
+?>
\ No newline at end of file
diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php
index 92ec476..caa37d9 100644
--- a/src/classes/logstreamdisk.class.php
+++ b/src/classes/logstreamdisk.class.php
@@ -438,7 +438,7 @@ class LogStreamDisk extends LogStream {
*
* @param enumReadDirectionfilter EnumReadDirection in: The new direction.
* @return integer Error state
- */
+ *
public function SetReadDirection($enumReadDirection) {
// only if the read direction change we have do do anything
@@ -448,6 +448,7 @@ class LogStreamDisk extends LogStream {
$this->_readDirection = $enumReadDirection;
return SUCCESS;
}
+ */
private function ResetBuffer() {
$this->_bEOS = false;
@@ -455,6 +456,149 @@ class LogStreamDisk extends LogStream {
$this->_buffer_length = 0;
$this->_p_buffer = -1;
}
+
+ /**
+ * Implementation of ApplyFilters in the LogSTreamDisk Class.
+ * This function performs a check on the filters and actually triggers the
+ * syslog parsers as well.
+ */
+ protected function ApplyFilters($myResults, &$arrProperitesOut)
+ {
+ // IF result was unsuccessfull, return success - nothing we can do here.
+ if ( $myResults >= ERROR )
+ return SUCCESS;
+
+ if ( $this->_filters != null )
+ {
+ // Evaluation default for now is true
+ $bEval = true;
+
+ // Loop through set properties
+ foreach( $arrProperitesOut as $propertyname => $propertyvalue )
+ {
+ // TODO: NOT SURE IF THIS WILL WORK ON NUMBERS AND OTHER TYPES RIGHT NOW
+ if (
+ array_key_exists($propertyname, $this->_filters) &&
+ isset($propertyvalue) &&
+ !(is_string($propertyvalue) && strlen($propertyvalue) <= 0 ) /* Negative because it only matters if the propvalure is a string*/
+ )
+ {
+ // Extra var needed for number checks!
+ $bIsOrFilter = false; // If enabled we need to check for numbereval later
+ $bOrFilter = false;
+
+ // Found something to filter, so do it!
+ foreach( $this->_filters[$propertyname] as $myfilter )
+ {
+ switch( $myfilter[FILTER_TYPE] )
+ {
+ case FILTER_TYPE_STRING:
+ // If Syslog message, we have AND handling!
+ if ( $propertyname == SYSLOG_MESSAGE )
+ {
+ // Include Filter
+ if ( $myfilter[FILTER_MODE] == FILTER_MODE_INCLUDE )
+ {
+ if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false )
+ $bEval = false;
+ }
+ // Exclude Filter
+ else if ( $myfilter[FILTER_MODE] == FILTER_MODE_EXCLUDE )
+ {
+ if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
+ $bEval = false;
+ }
+ }
+ // Otherwise we use OR Handling!
+ else
+ {
+ $bIsOrFilter = true; // Set isOrFilter to true
+ if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false )
+ $bOrFilter = true;
+ break;
+ }
+ break;
+ case FILTER_TYPE_NUMBER:
+ $bIsOrFilter = true; // Set to true in any case!
+ if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] )
+ $bOrFilter = true;
+ break;
+ case FILTER_TYPE_DATE:
+ // Get Log TimeStamp
+ $nLogTimeStamp = $arrProperitesOut[$propertyname][EVTIME_TIMESTAMP];
+
+ if ( $myfilter[FILTER_DATEMODE] == DATEMODE_LASTX )
+ {
+ // Get current timestamp
+ $nNowTimeStamp = time();
+
+ if ( $myfilter[FILTER_VALUE] == DATE_LASTX_HOUR )
+ $nLastXTime = 60 * 60; // One Hour!
+ else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS )
+ $nLastXTime = 60 * 60 * 12; // 12 Hours!
+ else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS )
+ $nLastXTime = 60 * 60 * 24; // 24 Hours!
+ else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS )
+ $nLastXTime = 60 * 60 * 24 * 7; // 7 days
+ else if ( $myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS )
+ $nLastXTime = 60 * 60 * 24 * 31; // 31 days
+ else
+ // WTF default?
+ $nLastXTime = 86400;
+ // If Nowtime + LastX is higher then the log timestamp, the this logline is to old for us.
+ if ( ($nNowTimeStamp - $nLastXTime) > $nLogTimeStamp )
+ $bEval = false;
+ }
+ else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM )
+ {
+ // Get filter timestamp!
+ $nFromTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]);
+
+ // If logtime is smaller then FromTime, then the Event is outside of our scope!
+ if ( $nLogTimeStamp < $nFromTimeStamp )
+ $bEval = false;
+ }
+ else if ( $myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO )
+ {
+ // Get filter timestamp!
+// echo $myfilter[FILTER_VALUE];
+ $nToTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]);
+
+ // If logtime is smaller then FromTime, then the Event is outside of our scope!
+ if ( $nLogTimeStamp > $nToTimeStamp )
+ $bEval = false;
+ }
+
+ break;
+ default:
+ // TODO!
+ break;
+ }
+ }
+
+ // If was number filter, we apply it the evaluation.
+ if ( $bIsOrFilter )
+ $bEval &= $bOrFilter;
+
+ if ( !$bEval )
+ {
+ // unmatching filter, rest property array
+ foreach ( $this->_arrProperties as $property )
+ $arrProperitesOut[$property] = '';
+
+ // return error!
+ return ERROR_FILTER_NOT_MATCH;
+ }
+ }
+ }
+
+ // Reached this point means filters did match!
+ return SUCCESS;
+ }
+ else // No filters at all means success!
+ return SUCCESS;
+ }
+
}
?>
diff --git a/src/classes/logstreamlineparser.class.php b/src/classes/logstreamlineparser.class.php
index 4342a00..ea1d4ce 100644
--- a/src/classes/logstreamlineparser.class.php
+++ b/src/classes/logstreamlineparser.class.php
@@ -55,98 +55,6 @@ abstract class LogStreamLineParser {
*/
public abstract function ParseLine($szLine, &$arrArguments);
- /*
- * GetEventTime
- *
- * Helper function to parse and obtain a valid EventTime Array from the input string.
- * Return value: EventTime Array!
- *
- */
- protected function GetEventTime($szTimStr)
- {
- // Sample: Mar 10 14:45:44
- if ( preg_match("/(...) ([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
- {
- // RFC 3164 typical timestamp
- $eventtime[EVTIME_TIMESTAMP] = mktime($out[3], $out[4], $out[5], $this->GetMonthFromString($out[1]), $out[2]);
- $eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO!
- $eventtime[EVTIME_MICROSECONDS] = 0;
-
-// echo gmdate(DATE_RFC822, $eventtime[EVTIME_TIMESTAMP]) . "
";
-// print_r ( $eventtime );
-// exit;
- }
- // Sample: 2008-04-02T11:12:32+02:00
- else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\+([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
- {
- // RFC 3164 typical timestamp
- $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
- $eventtime[EVTIME_TIMEZONE] = $out[7];
- $eventtime[EVTIME_MICROSECONDS] = 0;
- }
- // Sample: 2008-04-02T11:12:32.380449+02:00
- else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\.([0-9]{1,6})\+([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
- {
- // RFC 3164 typical timestamp
- $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
- $eventtime[EVTIME_TIMEZONE] = $out[8];
- $eventtime[EVTIME_MICROSECONDS] = $out[7];
- }
- // Sample: 2008-04-02,15:19:06
- else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2}),([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
- {
- // RFC 3164 typical timestamp
- $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
- $eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO!
- $eventtime[EVTIME_MICROSECONDS] = 0;
- }
- else
- {
- die ("wtf GetEventTime unparsable time - " . $szTimStr );
- }
-
- // return result!
- return $eventtime;
- }
-
- /*
- * GetMonthFromString
- *
- * Simple Helper function to obtain the numeric represantation of the month
- */
- private function GetMonthFromString($szMonth)
- {
- switch($szMonth)
- {
- case "Jan":
- return 1;
- case "Feb":
- return 2;
- case "Mar":
- return 3;
- case "Apr":
- return 4;
- case "May":
- return 5;
- case "Jun":
- return 6;
- case "Jul":
- return 7;
- case "Aug":
- return 8;
- case "Sep":
- return 9;
- case "Oct":
- return 10;
- case "Nov":
- return 11;
- case "Dez":
- return 12;
- }
-
- }
-
-
}
?>
diff --git a/src/classes/logstreamlineparsersyslog.class.php b/src/classes/logstreamlineparsersyslog.class.php
index 5bd0325..0de415f 100644
--- a/src/classes/logstreamlineparsersyslog.class.php
+++ b/src/classes/logstreamlineparsersyslog.class.php
@@ -60,11 +60,14 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
*/
public function ParseLine($szLine, &$arrArguments)
{
+ // Set IUT Property first!
+ $arrArguments[SYSLOG_MESSAGETYPE] = IUT_Syslog;
+
// Sample (Syslog): Mar 10 14:45:44 debandre anacron[3226]: Job `cron.daily' terminated (mailing output)
if ( preg_match("/(... [0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}) (.*?) (.*?)\[(.*?)\]:(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[2];
$arrArguments[SYSLOG_SYSLOGTAG] = $out[3];
$arrArguments[SYSLOG_PROCESSID] = $out[4];
@@ -74,7 +77,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
else if ( preg_match("/(... [0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}) (.*?) (.*?):(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[2];
$arrArguments[SYSLOG_SYSLOGTAG] = $out[3];
$arrArguments[SYSLOG_MESSAGE] = $out[4];
@@ -83,7 +86,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
else if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}T[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\+[0-9]{1,2}:[0-9]{1,2}) (.*?) (.*?):(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[2];
$arrArguments[SYSLOG_SYSLOGTAG] = $out[3];
$arrArguments[SYSLOG_MESSAGE] = $out[4];
@@ -92,7 +95,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
else if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2}T[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}\.[0-9]{1,6}\+[0-9]{1,2}:[0-9]{1,2}) (.*?) (.*?):(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[2];
$arrArguments[SYSLOG_SYSLOGTAG] = $out[3];
$arrArguments[SYSLOG_MESSAGE] = $out[4];
@@ -101,7 +104,7 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
{
// Some kind of debug message or something ...
// Sample: 2008-03-28T15:17:05.480876+01:00,**NO MATCH**
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_MESSAGE] = $out[2];
}
@@ -113,6 +116,13 @@ class LogStreamLineParsersyslog extends LogStreamLineParser {
echo ("wtf syslog - '" . $arrArguments[SYSLOG_MESSAGE] . "'
");
}
}
+
+ // If SyslogTag is set, we check for MessageType!
+ if ( isset($arrArguments[SYSLOG_SYSLOGTAG]) )
+ {
+ if ( strpos($arrArguments[SYSLOG_SYSLOGTAG], "EvntSLog" ) !== false )
+ $arrArguments[SYSLOG_MESSAGETYPE] = IUT_NT_EventReport;
+ }
// Return success!
return SUCCESS;
diff --git a/src/classes/logstreamlineparserwinsyslog.class.php b/src/classes/logstreamlineparserwinsyslog.class.php
index 0a21ecc..90bc72f 100644
--- a/src/classes/logstreamlineparserwinsyslog.class.php
+++ b/src/classes/logstreamlineparserwinsyslog.class.php
@@ -62,33 +62,36 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
{
global $content;
+ // Set IUT Property first!
+ $arrArguments[SYSLOG_MESSAGETYPE] = IUT_Syslog;
+
// Sample (WinSyslog/EventReporter): 2008-04-02,15:19:06,2008-04-02,15:19:06,127.0.0.1,16,5,EvntSLog: Performance counters for the RSVP (QoS RSVP) service were loaded successfully.
if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),(.*?),([0-9]{1,2}),([0-9]{1,2}),(.*?):(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[3];
$arrArguments[SYSLOG_FACILITY] = $out[4];
$arrArguments[SYSLOG_SEVERITY] = $out[5];
$arrArguments[SYSLOG_SYSLOGTAG] = $out[6];
$arrArguments[SYSLOG_MESSAGE] = $out[7];
- // Expand SYSLOG_FACILITY and SYSLOG_SEVERITY
- $arrArguments[SYSLOG_FACILITY_TEXT] = GetFacilityDisplayName( $arrArguments[SYSLOG_FACILITY] );
- $arrArguments[SYSLOG_SEVERITY_TEXT] = GetSeverityDisplayName( $arrArguments[SYSLOG_SEVERITY] );
+// // Expand SYSLOG_FACILITY and SYSLOG_SEVERITY
+// $arrArguments[SYSLOG_FACILITY_TEXT] = GetFacilityDisplayName( $arrArguments[SYSLOG_FACILITY] );
+// $arrArguments[SYSLOG_SEVERITY_TEXT] = GetSeverityDisplayName( $arrArguments[SYSLOG_SEVERITY] );
}
else if ( preg_match("/([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),([0-9]{4,4}-[0-9]{1,2}-[0-9]{1,2},[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}),(.*?),([0-9]{1,2}),([0-9]{1,2}),(.*?)$/", $szLine, $out ) )
{
// Copy parsed properties!
- $arrArguments[SYSLOG_DATE] = $this->GetEventTime($out[1]);
+ $arrArguments[SYSLOG_DATE] = GetEventTime($out[1]);
$arrArguments[SYSLOG_HOST] = $out[3];
$arrArguments[SYSLOG_FACILITY] = $out[4];
$arrArguments[SYSLOG_SEVERITY] = $out[5];
$arrArguments[SYSLOG_MESSAGE] = $out[6];
- // Expand SYSLOG_FACILITY and SYSLOG_SEVERITY
- $arrArguments[SYSLOG_FACILITY_TEXT] = GetFacilityDisplayName( $arrArguments[SYSLOG_FACILITY] );
- $arrArguments[SYSLOG_SEVERITY_TEXT] = GetSeverityDisplayName( $arrArguments[SYSLOG_SEVERITY] );
+// // Expand SYSLOG_FACILITY and SYSLOG_SEVERITY
+// $arrArguments[SYSLOG_FACILITY_TEXT] = GetFacilityDisplayName( $arrArguments[SYSLOG_FACILITY] );
+// $arrArguments[SYSLOG_SEVERITY_TEXT] = GetSeverityDisplayName( $arrArguments[SYSLOG_SEVERITY] );
}
else
{
@@ -99,6 +102,13 @@ class LogStreamLineParserwinsyslog extends LogStreamLineParser {
}
}
+ // If SyslogTag is set, we check for MessageType!
+ if ( isset($arrArguments[SYSLOG_SYSLOGTAG]) )
+ {
+ if ( strpos($arrArguments[SYSLOG_SYSLOGTAG], "EvntSLog" ) !== false )
+ $arrArguments[SYSLOG_MESSAGETYPE] = IUT_NT_EventReport;
+ }
+
// Return success!
return SUCCESS;
}
diff --git a/src/config.php b/src/config.php
index 0a53893..27884ff 100644
--- a/src/config.php
+++ b/src/config.php
@@ -48,7 +48,7 @@ $CFG['UserDBPass'] = "";
// ---
// --- Misc Options
-$CFG['MiscShowDebugMsg'] = 0; // if enabled, you will get additional output on certain places
+$CFG['MiscShowDebugMsg'] = 1; // if enabled, you will get additional output on certain places
$CFG["MiscShowPageRenderStats"] = 1; // If enabled, you will see Pagerender Settings
// ---
@@ -97,5 +97,16 @@ $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";
+
+$CFG['Sources'][Source5]['ID'] = "Source5";
+$CFG['Sources'][Source5]['Name'] = "WinSyslog DB";
+$CFG['Sources'][Source5]['SourceType'] = SOURCE_DB;
+$CFG['Sources'][Source5]['DBTableType'] = "winsyslog";
+$CFG['Sources'][Source5]['DBType'] = DB_MYSQL;
+$CFG['Sources'][Source5]['DBServer'] = "127.0.0.1";
+$CFG['Sources'][Source5]['DBName'] = "phplogcon";
+$CFG['Sources'][Source5]['DBUser'] = "root";
+$CFG['Sources'][Source5]['DBPassword'] = "";
+$CFG['Sources'][Source5]['DBTableName'] = "systemevents";
// ---
?>
diff --git a/src/include/constants_errors.php b/src/include/constants_errors.php
index 588f2c6..8e2efb9 100644
--- a/src/include/constants_errors.php
+++ b/src/include/constants_errors.php
@@ -49,4 +49,11 @@ define('ERROR_UNDEFINED', 6);
define('ERROR_EOS', 7);
define('ERROR_NOMORERECORDS', 8);
define('ERROR_FILTER_NOT_MATCH', 9);
+
+define('ERROR_DB_CONNECTFAILED', 10);
+define('ERROR_DB_CANNOTSELECTDB', 11);
+define('ERROR_DB_QUERYFAILED', 12);
+define('ERROR_DB_NOPROPERTIES', 13);
+define('ERROR_DB_INVALIDDBMAPPING', 14);
+
?>
diff --git a/src/include/constants_filters.php b/src/include/constants_filters.php
index adbc480..8199be8 100644
--- a/src/include/constants_filters.php
+++ b/src/include/constants_filters.php
@@ -66,4 +66,41 @@ define('FILTER_MODE', 'filtermode');
define('FILTER_MODE_INCLUDE', 0);
define('FILTER_MODE_EXCLUDE', 1);
+// --- Init Facility LIST
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_KERN, "DisplayName" => "KERN", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_USER, "DisplayName" => "USER", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_MAIL, "DisplayName" => "MAIL", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_DAEMON, "DisplayName" => "DAEMON", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_AUTH, "DisplayName" => "AUTH", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_SYSLOG, "DisplayName" => "SYSLOG", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LPR, "DisplayName" => "LPR", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_NEWS, "DisplayName" => "NEWS", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_UUCP, "DisplayName" => "UUCP", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_CRON, "DisplayName" => "CRON", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL0, "DisplayName" => "LOCAL0", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL1, "DisplayName" => "LOCAL1", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL2, "DisplayName" => "LOCAL2", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL3, "DisplayName" => "LOCAL3", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL4, "DisplayName" => "LOCAL4", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL5, "DisplayName" => "LOCAL5", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL6, "DisplayName" => "LOCAL6", "selected" => "" );
+$content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL7, "DisplayName" => "LOCAL7", "selected" => "" );
+// ---
+
+// Init Severity LIST
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_EMERG, "DisplayName" => "EMERG", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_ALERT, "DisplayName" => "ALERT", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_CRIT, "DisplayName" => "CRIT", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_ERR, "DisplayName" => "ERR", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_WARNING, "DisplayName" => "WARNING", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_NOTICE, "DisplayName" => "NOTICE", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_INFO, "DisplayName" => "INFO", "selected" => "" );
+$content['filter_severity_list'][] = array( "ID" => SYSLOG_DEBUG, "DisplayName" => "DEBUG", "selected" => "" );
+// ---
+
+// Init MessageType LIST
+$content['filter_messagetype_list'][] = array( "ID" => IUT_Unknown, "DisplayName" => "Unknown", "selected" => "" );
+$content['filter_messagetype_list'][] = array( "ID" => IUT_Syslog, "DisplayName" => "Syslog", "selected" => "" );
+$content['filter_messagetype_list'][] = array( "ID" => IUT_NT_EventReport, "DisplayName" => "EventReporter", "selected" => "" );
+
?>
\ No newline at end of file
diff --git a/src/include/constants_general.php b/src/include/constants_general.php
index ce77978..af929b8 100644
--- a/src/include/constants_general.php
+++ b/src/include/constants_general.php
@@ -59,7 +59,7 @@ define('STR_DEBUG_ERROR_WTF', "WTF OMFG");
// --- Source Type defines
define('SOURCE_DISK', '1');
-define('SOURCE_MYSQLDB', '2');
+define('SOURCE_DB', '2');
// ---
// ---
@@ -122,4 +122,51 @@ $severity_colors[SYSLOG_INFO] = "#0C9C91";
$severity_colors[SYSLOG_DEBUG] = "#119BDE";
// ---
-?>
+// --- MonitorWare InfoUnit Defines | Messagetypes
+define('IUT_Unknown', '0');
+define('IUT_Syslog', '1');
+define('IUT_Heartbeat', '2');
+define('IUT_NT_EventReport', '3');
+define('IUT_SNMP_Trap', '4');
+define('IUT_File_Monitor', '5');
+define('IUT_PingProbe', '8');
+define('IUT_Port_Probe', '9');
+define('IUT_NTService_Monitor', '10');
+define('IUT_DiskSpace_Monitor', '11');
+define('IUT_DB_Monitor', '12');
+define('IUT_Serial_Monitor', '13');
+define('IUT_CPU_Monitor', '14');
+define('IUT_AliveMonRequest', '16');
+define('IUT_SMTPProbe', '17');
+define('IUT_FTPProbe', '18');
+define('IUT_HTTPProbe', '19');
+define('IUT_POP3Probe', '20');
+define('IUT_IMAPProbe', '21');
+define('IUT_NNTPProbe', '22');
+define('IUT_WEVTMONV2', '23');
+define('IUT_SMTPLISTENER', '24');
+$msgtype_colors[IUT_Unknown] = "#D0FBDC";
+$msgtype_colors[IUT_Syslog] = "#D0FBF1";
+$msgtype_colors[IUT_Heartbeat] = "#D0EEFB";
+$msgtype_colors[IUT_NT_EventReport] = "#D0E5FB";
+$msgtype_colors[IUT_SNMP_Trap] = "#D0DBFB";
+$msgtype_colors[IUT_File_Monitor] = "#DAD0FB";
+$msgtype_colors[IUT_PingProbe] = "#E0D0FB";
+$msgtype_colors[IUT_Port_Probe] = "#F6D0FB";
+$msgtype_colors[IUT_NTService_Monitor] = "#FBD0E7";
+$msgtype_colors[IUT_DiskSpace_Monitor] = "#FBD0D3";
+$msgtype_colors[IUT_DB_Monitor] = "#FBD8D0";
+$msgtype_colors[IUT_Serial_Monitor] = "#FBE0D0";
+$msgtype_colors[IUT_CPU_Monitor] = "#FBEBD0";
+$msgtype_colors[IUT_AliveMonRequest] = "#FBF6D0";
+$msgtype_colors[IUT_SMTPProbe] = "#F5FBD0";
+$msgtype_colors[IUT_FTPProbe] = "#EBFBD0";
+$msgtype_colors[IUT_HTTPProbe] = "#E1FBD0";
+$msgtype_colors[IUT_POP3Probe] = "#D0FBD4";
+$msgtype_colors[IUT_IMAPProbe] = "#D0FBE8";
+$msgtype_colors[IUT_NNTPProbe] = "#D0F7FB";
+$msgtype_colors[IUT_WEVTMONV2] = "#CCE4D2";
+$msgtype_colors[IUT_SMTPLISTENER] = "#CCE4DE";
+// ---
+
+?>
\ No newline at end of file
diff --git a/src/include/constants_logstream.php b/src/include/constants_logstream.php
index 07a8183..9005f07 100644
--- a/src/include/constants_logstream.php
+++ b/src/include/constants_logstream.php
@@ -39,30 +39,42 @@ if ( !defined('IN_PHPLOGCON') )
}
// ---
-// --- Some custom defines
-
-// Define properties names of all know fields
+// --- 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');
-define('SYSLOG_FACILITY_TEXT', 'syslogfacility-text');
-define('SYSLOG_SEVERITY', 'syslogseverity');
-define('SYSLOG_SEVERITY_TEXT','syslogseverity-text');
define('SYSLOG_HOST', 'FROMHOST');
-define('SYSLOG_SYSLOGTAG', 'syslogtag');
-define('SYSLOG_MESSAGE', 'msg');
-define('SYSLOG_MESSAGETRUNSCATED', 'msgtrunscated');
define('SYSLOG_MESSAGETYPE', 'IUT');
+define('SYSLOG_MESSAGE', 'msg');
+
+// Syslog specific
+define('SYSLOG_FACILITY', 'syslogfacility');
+define('SYSLOG_SEVERITY', 'syslogseverity');
+define('SYSLOG_SYSLOGTAG', 'syslogtag');
define('SYSLOG_PROCESSID', 'procid');
+//define('SYSLOG_DATE_FORMATED', 'timereported_formatted');
+//define('SYSLOG_FACILITY_TEXT', 'syslogfacility-text');
+//define('SYSLOG_SEVERITY_TEXT','syslogseverity-text');
+//define('SYSLOG_MESSAGETRUNSCATED', 'msgtrunscated');
+
+// EventLog specific
+define('SYSLOG_EVENT_ID', 'id');
+define('SYSLOG_EVENT_LOGTYPE', 'NTEventLogType');
+define('SYSLOG_EVENT_SOURCE', 'sourceproc');
+define('SYSLOG_EVENT_CATEGORY', 'category');
+define('SYSLOG_EVENT_USER', 'user');
+// ---
// 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!
+// Define possible database types
+define('DB_MYSQL', 0);
+define('DB_MSSQL', 1);
+define('DB_ODBC', 2);
+// --- Predefine fields array!
$fields[SYSLOG_UID]['FieldID'] = SYSLOG_UID;
$fields[SYSLOG_UID]['FieldCaptionID'] = 'LN_FIELDS_UID';
$fields[SYSLOG_UID]['FieldType'] = FILTER_TYPE_NUMBER;
@@ -75,6 +87,26 @@ $fields[SYSLOG_DATE]['FieldType'] = FILTER_TYPE_DATE;
$fields[SYSLOG_DATE]['Sortable'] = true;
$fields[SYSLOG_DATE]['DefaultWidth'] = "110";
$fields[SYSLOG_DATE]['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_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_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";
+
+// Syslog specific
$fields[SYSLOG_FACILITY]['FieldID'] = SYSLOG_FACILITY;
$fields[SYSLOG_FACILITY]['FieldCaptionID'] = 'LN_FIELDS_FACILITY';
$fields[SYSLOG_FACILITY]['FieldType'] = FILTER_TYPE_NUMBER;
@@ -87,63 +119,46 @@ $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]['DefaultWidth'] = "85";
$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";
+// TODO! EventLog specific
-// MonitorWare InfoUnit Defines
-define('IUT_Unknown', '0');
-define('IUT_Syslog', '1');
-define('IUT_Heartbeat', '2');
-define('IUT_NT_EventReport', '3');
-define('IUT_SNMP_Trap', '4');
-define('IUT_File_Monitor', '5');
-define('IUT_PingProbe', '8');
-define('IUT_Port_Probe', '9');
-define('IUT_NTService_Monitor', '10');
-define('IUT_DiskSpace_Monitor', '11');
-define('IUT_DB_Monitor', '12');
-define('IUT_Serial_Monitor', '13');
-define('IUT_CPU_Monitor', '14');
-define('IUT_AliveMonRequest', '16');
-define('IUT_SMTPProbe', '17');
-define('IUT_FTPProbe', '18');
-define('IUT_HTTPProbe', '19');
-define('IUT_POP3Probe', '20');
-define('IUT_IMAPProbe', '21');
-define('IUT_NNTPProbe', '22');
-define('IUT_WEVTMONV2', '23');
-define('IUT_SMTPLISTENER', '24');
-define('IUT_AliveMonECHO', '1999998');
-define('IUT_MIAP_Receiver', '1999999');
+// ---
+
+// --- Define default Database field mappings!
+$dbmapping['winsyslog'][SYSLOG_UID] = "ID";
+$dbmapping['winsyslog'][SYSLOG_DATE] = "DeviceReportedTime";
+$dbmapping['winsyslog'][SYSLOG_HOST] = "FromHost";
+$dbmapping['winsyslog'][SYSLOG_MESSAGETYPE] = "InfoUnitID";
+$dbmapping['winsyslog'][SYSLOG_MESSAGE] = "Message";
+$dbmapping['winsyslog'][SYSLOG_FACILITY] = "Facility";
+$dbmapping['winsyslog'][SYSLOG_SEVERITY] = "Priority";
+$dbmapping['winsyslog'][SYSLOG_SYSLOGTAG] = "SysLogTag";
+$dbmapping['winsyslog'][SYSLOG_EVENT_ID] = "EventID";
+$dbmapping['winsyslog'][SYSLOG_EVENT_LOGTYPE] = "EventLogType";
+$dbmapping['winsyslog'][SYSLOG_EVENT_SOURCE] = "EventSource";
+$dbmapping['winsyslog'][SYSLOG_EVENT_CATEGORY] = "EventCategory";
+$dbmapping['winsyslog'][SYSLOG_EVENT_USER] = "EventUser";
+
+$dbmapping['syslogng'][SYSLOG_UID] = "seq";
+$dbmapping['syslogng'][SYSLOG_DATE] = "datetime";
+$dbmapping['syslogng'][SYSLOG_HOST] = "host";
+$dbmapping['syslogng'][SYSLOG_MESSAGE] = "msg";
+//TODO $dbmapping['syslogng'][SYSLOG_FACILITY] = "Facility";
+//TODO $dbmapping['syslogng'][SYSLOG_SEVERITY] = "Priority"
+$dbmapping['syslogng'][SYSLOG_SYSLOGTAG] = "tag";
+// ---
// EventTime Constants
define('EVTIME_TIMESTAMP', '0');
diff --git a/src/include/functions_common.php b/src/include/functions_common.php
index 0440651..196e310 100644
--- a/src/include/functions_common.php
+++ b/src/include/functions_common.php
@@ -463,6 +463,105 @@ function RedirectResult( $szMsg, $newpage )
exit;
}
+/*
+* GetEventTime
+*
+* Helper function to parse and obtain a valid EventTime Array from the input string.
+* Return value: EventTime Array!
+*
+*/
+function GetEventTime($szTimStr)
+{
+ // Sample: Mar 10 14:45:44
+ if ( preg_match("/(...) ([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
+ {
+ // RFC 3164 typical timestamp
+ $eventtime[EVTIME_TIMESTAMP] = mktime($out[3], $out[4], $out[5], GetMonthFromString($out[1]), $out[2]);
+ $eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO!
+ $eventtime[EVTIME_MICROSECONDS] = 0;
+
+// echo gmdate(DATE_RFC822, $eventtime[EVTIME_TIMESTAMP]) . "
";
+// print_r ( $eventtime );
+// exit;
+ }
+ // Sample: 2008-04-02T11:12:32+02:00
+ else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\+([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
+ {
+ // RFC 3164 typical timestamp
+ $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
+ $eventtime[EVTIME_TIMEZONE] = $out[7];
+ $eventtime[EVTIME_MICROSECONDS] = 0;
+ }
+ // Sample: 2008-04-02T11:12:32.380449+02:00
+ else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2})T([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})\.([0-9]{1,6})\+([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
+ {
+ // RFC 3164 typical timestamp
+ $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
+ $eventtime[EVTIME_TIMEZONE] = $out[8];
+ $eventtime[EVTIME_MICROSECONDS] = $out[7];
+ }
+ // Sample: 2008-04-02,15:19:06
+ else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2}),([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
+ {
+ // RFC 3164 typical timestamp
+ $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
+ $eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO!
+ $eventtime[EVTIME_MICROSECONDS] = 0;
+ }
+ // Sample: 2008-02-19 12:52:37
+ else if ( preg_match("/([0-9]{4,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $szTimStr, $out ) )
+ {
+ // RFC 3164 typical timestamp
+ $eventtime[EVTIME_TIMESTAMP] = mktime($out[4], $out[5], $out[6], $out[2], $out[3], $out[1]);
+ $eventtime[EVTIME_TIMEZONE] = date_default_timezone_get(); // WTF TODO!
+ $eventtime[EVTIME_MICROSECONDS] = 0;
+ }
+ else
+ {
+ die ("wtf GetEventTime unparsable time - " . $szTimStr );
+ }
+
+ // return result!
+ return $eventtime;
+}
+
+/*
+* GetMonthFromString
+*
+* Simple Helper function to obtain the numeric represantation of the month
+*/
+function GetMonthFromString($szMonth)
+{
+ switch($szMonth)
+ {
+ case "Jan":
+ return 1;
+ case "Feb":
+ return 2;
+ case "Mar":
+ return 3;
+ case "Apr":
+ return 4;
+ case "May":
+ return 5;
+ case "Jun":
+ return 6;
+ case "Jul":
+ return 7;
+ case "Aug":
+ return 8;
+ case "Sep":
+ return 9;
+ case "Oct":
+ return 10;
+ case "Nov":
+ return 11;
+ case "Dez":
+ return 12;
+ }
+}
+
+
// --- BEGIN Usermanagement Function ---
function StartPHPSession()
{
diff --git a/src/include/functions_config.php b/src/include/functions_config.php
index deb8bf8..fb7776c 100644
--- a/src/include/functions_config.php
+++ b/src/include/functions_config.php
@@ -39,12 +39,11 @@
// --- Perform necessary includes
require_once($gl_root_path . 'classes/logstreamconfig.class.php');
- require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php');
// ---
function InitSourceConfigs()
{
- global $CFG, $content, $currentSourceID;
+ global $CFG, $content, $currentSourceID, $gl_root_path;
// Init Source Configs!
if ( isset($CFG['Sources']) )
@@ -71,14 +70,29 @@
// Create Config instance!
if ( $mysource['SourceType'] == SOURCE_DISK )
{
+ // Perform necessary include
+ require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php');
+
$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 if ( $mysource['SourceType'] == SOURCE_DB )
+ {
+ // Perform necessary include
+ require_once($gl_root_path . 'classes/logstreamconfigdb.class.php');
+
+ $content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDB();
+ $content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBType = $mysource['DBType'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBTableType = $mysource['DBTableType'];
+ $content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
+
+ // Optional parameters!
+ if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
+ if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
+ if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
}
else
{
@@ -86,6 +100,7 @@
unset($content['Sources'][$iSourceID]);
// TODO: Output CONFIG WARNING
+ die( "Not supported yet!" );
}
// Set default SourceID here!
diff --git a/src/include/functions_filters.php b/src/include/functions_filters.php
index a8e90c8..a6f1a1f 100644
--- a/src/include/functions_filters.php
+++ b/src/include/functions_filters.php
@@ -157,29 +157,6 @@ function InitFilterHelpers()
$filters['filter_facility'] = array ( SYSLOG_KERN, SYSLOG_USER, SYSLOG_MAIL, SYSLOG_DAEMON, SYSLOG_AUTH, SYSLOG_SYSLOG, SYSLOG_LPR, SYSLOG_NEWS, SYSLOG_UUCP, SYSLOG_CRON, SYSLOG_LOCAL0, SYSLOG_LOCAL1, SYSLOG_LOCAL2, SYSLOG_LOCAL3, SYSLOG_LOCAL4, SYSLOG_LOCAL5, SYSLOG_LOCAL6, SYSLOG_LOCAL7 );
// $filters['filter_facility'] = SYSLOG_LOCAL0;
-
-
- // Init Facility LIST
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_KERN, "DisplayName" => "KERN", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_USER, "DisplayName" => "USER", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_MAIL, "DisplayName" => "MAIL", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_DAEMON, "DisplayName" => "DAEMON", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_AUTH, "DisplayName" => "AUTH", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_SYSLOG, "DisplayName" => "SYSLOG", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LPR, "DisplayName" => "LPR", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_NEWS, "DisplayName" => "NEWS", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_UUCP, "DisplayName" => "UUCP", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_CRON, "DisplayName" => "CRON", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL0, "DisplayName" => "LOCAL0", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL1, "DisplayName" => "LOCAL1", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL2, "DisplayName" => "LOCAL2", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL3, "DisplayName" => "LOCAL3", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL4, "DisplayName" => "LOCAL4", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL5, "DisplayName" => "LOCAL5", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL6, "DisplayName" => "LOCAL6", "selected" => "" );
- $content['filter_facility_list'][] = array( "ID" => SYSLOG_LOCAL7, "DisplayName" => "LOCAL7", "selected" => "" );
-
-
$iCount = count($content['filter_facility_list']);
for ( $i = 0; $i < $iCount; $i++ )
{
@@ -195,16 +172,6 @@ function InitFilterHelpers()
$filters['filter_severity'] = array ( SYSLOG_EMERG, SYSLOG_ALERT, SYSLOG_CRIT, SYSLOG_ERR, SYSLOG_WARNING, SYSLOG_NOTICE, SYSLOG_INFO, SYSLOG_DEBUG );
// $filters['filter_severity'] = SYSLOG_NOTICE;
- // Init Severity LIST
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_EMERG, "DisplayName" => "EMERG", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_ALERT, "DisplayName" => "ALERT", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_CRIT, "DisplayName" => "CRIT", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_ERR, "DisplayName" => "ERR", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_WARNING, "DisplayName" => "WARNING", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_NOTICE, "DisplayName" => "NOTICE", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_INFO, "DisplayName" => "INFO", "selected" => "" );
- $content['filter_severity_list'][] = array( "ID" => SYSLOG_DEBUG, "DisplayName" => "DEBUG", "selected" => "" );
-
$iCount = count($content['filter_severity_list']);
for ( $i = 0; $i < $iCount; $i++ )
{
@@ -257,6 +224,21 @@ function GetSeverityDisplayName( $nSeverityID )
return "Unknown Severity";
}
+function GetMessageTypeDisplayName( $nMsgTypeID )
+{
+ global $content;
+
+ foreach( $content['filter_messagetype_list'] as $mymsgtype )
+ {
+ if ( $mymsgtype['ID'] == $nMsgTypeID )
+ return $mymsgtype['DisplayName'];
+ }
+
+ // Default
+ return "Unknown";
+}
+
+
function GetTimeStampFromTimeString($szTimeString)
{
//Sample: 2008-4-1T00:00:00
diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php
index 4a13686..5d94758 100644
--- a/src/include/functions_frontendhelpers.php
+++ b/src/include/functions_frontendhelpers.php
@@ -103,6 +103,9 @@ function GetFormatedDate($evttimearray)
{
global $content, $CFG;
+ if ( !is_array($evttimearray) )
+ return $evttimearray;
+
if ( isset($CFG['ViewUseTodayYesterday']) && $CFG['ViewUseTodayYesterday'] == 1 )
{
if ( date('d', $evttimearray[EVTIME_TIMESTAMP]) == date('d') )
diff --git a/src/index.php b/src/index.php
index 55642be..668bdc8 100644
--- a/src/index.php
+++ b/src/index.php
@@ -99,17 +99,17 @@ function HighLightString($highlightArray, $strmsg)
// ---
// --- Read and process filters from search dialog!
-if ( (isset($_POST['search']) || isset($_GET['search'])) && (isset($_POST['filter']) || isset($_GET['filter'])) )
+if ( (isset($_POST['search']) || isset($_GET['search'])) || (isset($_POST['filter']) || isset($_GET['filter'])) )
{
// Copy search over
- if ( isset($_POST['search']) )
+ if ( isset($_POST['search']) )
$mysearch = $_POST['search'];
- else
+ else if ( isset($_GET['search']) )
$mysearch = $_GET['search'];
- if ( isset($_POST['search']) )
+ if ( isset($_POST['filter']) )
$myfilter = $_POST['filter'];
- else
+ else if ( isset($_GET['filter']) )
$myfilter = $_GET['filter'];
// Optionally read highlight words
@@ -250,7 +250,7 @@ if ( (isset($_POST['search']) || isset($_GET['search'])) && (isset($_POST['filte
// ---
// --- BEGIN Custom Code
-if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK )
+if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK )
{
// Preprocessing the fields we need
foreach($content['Columns'] as $mycolkey)
@@ -260,7 +260,6 @@ if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$curren
$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
@@ -269,193 +268,214 @@ if ( isset($content['Sources'][$currentSourceID]) && $content['Sources'][$curren
// Create LogStream Object
$stream = $stream_config->LogStreamFactory($stream_config);
$stream->SetFilter($content['searchstr']);
- $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;
- $counter = 0;
-
- if ($uID != UID_UNKNOWN)
+ $res = $stream->Open( $content['Columns'], true );
+ if ( $res == SUCCESS )
{
- // First read will also set the start position of the Stream!
- $ret = $stream->Read($uID, $logArray);
- }
- else
- $ret = $stream->ReadNext($uID, $logArray);
+ $stream->SetReadDirection(EnumReadDirection::Backward);
-
- if ( $ret == SUCCESS )
- {
- //Loop through the messages!
- do
+ $uID = $currentUID;
+ $counter = 0;
+
+ if ($uID != UID_UNKNOWN)
{
- // Copy Obtained array
-// $content['syslogmessages'][] = $logArray;
+ // echo "!1!";
+ // First read will also set the start position of the Stream!
+ $ret = $stream->Read($uID, $logArray);
+ }
+ else
+ {
+ // echo "!2!";
+ $ret = $stream->ReadNext($uID, $logArray);
+ }
- // --- Set CSS Class
- if ( $counter % 2 == 0 )
- $content['syslogmessages'][$counter]['cssclass'] = "line1";
- else
- $content['syslogmessages'][$counter]['cssclass'] = "line2";
- // ---
-
- // --- Now we populate the values array!
- foreach($content['Columns'] as $mycolkey)
+ if ( $ret == SUCCESS )
+ {
+ //Loop through the messages!
+ do
{
- if ( isset($logArray[$mycolkey]) )
+ // Copy Obtained array
+ // $content['syslogmessages'][] = $logArray;
+
+ // --- Set CSS Class
+ if ( $counter % 2 == 0 )
+ $content['syslogmessages'][$counter]['cssclass'] = "line1";
+ else
+ $content['syslogmessages'][$counter]['cssclass'] = "line2";
+ // ---
+
+ // --- Now we populate the values array!
+ foreach($content['Columns'] as $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 ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE )
+ if ( isset($logArray[$mycolkey]) )
{
- $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];
+ // 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";
- // Special style classes and colours for SYSLOG_FACILITY
- if ( $mycolkey == SYSLOG_FACILITY )
+ if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE )
{
- 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] . '" ';
- }
+ $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]);
}
- else if ( $mycolkey == SYSLOG_SEVERITY )
+ else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER )
{
- 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";
+ $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey];
- // Set Human readable Facility!
- $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] );
- }
- else
+ // Special style classes and colours for SYSLOG_FACILITY
+ if ( $mycolkey == SYSLOG_FACILITY )
{
- // 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)
+ if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0)
{
- // 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'];
+ $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 )
+ {
+ if ( isset($logArray[$mycolkey][SYSLOG_MESSAGETYPE]) )
+ {
+ $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[ $logArray[SYSLOG_MESSAGETYPE] ] . '" ';
+ $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredBlack";
+
+ // Set Human readable Facility!
+ $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetMessageTypeDisplayName( $logArray[$mycolkey] );
+ }
+ else
+ {
+ // Use default colour!
+ $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[IUT_Unknown] . '" ';
+ }
+
+ }
+ }
+ 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'];
+
+ }
+ }
+
+ }
}
}
}
- }
- // ---
+ // ---
- // --- Popup Details
- if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 )
+ // --- Popup Details
+ if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 )
+ {
+ }
+ // 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']);
+
+ if ( $stream->ReadNext($uID, $logArray) == SUCCESS )
{
+ $content['uid_next'] = $uID;
+ // Enable Pager
+ $content['main_pagerenabled'] = "true";
}
-// else
-// $content['syslogmessages'][$counter]['popupdetails'] = "false";
- // ---
-
-/*
- // --- Prepare message if needed!
- if ( $CFG['ShowMessage'] == 1 )
+ else if ( $currentUID != UID_UNKNOWN )
{
-
+ // We can still go back, enable Pager
+ $content['main_pagerenabled'] = "true";
}
- else
- $content['syslogmessages'][$counter]['ShowMessage'] = "false";
- // ---
-*/
- // 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";
+ // This will enable to Main SyslogView
+ $content['syslogmessagesenabled'] = "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!
+ // This will disable to Main SyslogView and show an error message
+ $content['syslogmessagesenabled'] = "false";
}
// Close file!
diff --git a/src/lang/en/main.php b/src/lang/en/main.php
index 7b9a393..cad3e2d 100644
--- a/src/lang/en/main.php
+++ b/src/lang/en/main.php
@@ -56,6 +56,9 @@ $content['LN_HIGHLIGHT'] = "Hightlight >>";
$content['LN_HIGHLIGHT_OFF'] = "Hightlight <<";
$content['LN_HIGHLIGHT_WORDS'] = "Hightlight words comma separated";
+$content['LN_ERROR_NORECORDS'] = "No syslog records found.";
+
+
// Filter Options
$content['LN_FILTER_DATE'] = "Datetime Range";
$content['LN_FILTER_DATEMODE'] = "Select mode";
diff --git a/src/templates/index.html b/src/templates/index.html
index 292eb49..4b65534 100644
--- a/src/templates/index.html
+++ b/src/templates/index.html
@@ -89,6 +89,12 @@