mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
Next Milestone has been added, LogStream DB Driver
The DB Driver is almost finished and fully implemented. Currently it is fixed on MYSQL, but it will be easy to implement other database types later. Filtering for the DB Driver works 75%, Date filtering is missing only. I will work on this tomorrow. Another good thing is that we use DB Field mapping which means it will be easy to adapt other database schemas later.
This commit is contained in:
parent
a1e5033a43
commit
57199e473e
@ -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)
|
||||
{
|
||||
|
||||
|
97
src/classes/logstreamconfigdb.class.php
Normal file
97
src/classes/logstreamconfigdb.class.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*
|
||||
*********************************************************************
|
||||
* -> 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
// ---
|
||||
|
||||
class LogStreamConfigDB extends LogStreamConfig {
|
||||
public $DBServer = '127.0.0.1';
|
||||
public $DBPort = 3306;
|
||||
public $DBName = '';
|
||||
public $DBUser = '';
|
||||
public $DBPassword = '';
|
||||
public $DBType = DB_MYSQL; // Default = MYSQL!
|
||||
public $DBTableType = 'winsyslog'; // Default = WINSYSLOG DB Layout!
|
||||
public $DBTableName = 'systemevents'; // Default Tabelname from WINSYSLOG
|
||||
|
||||
// Runtime configuration variables
|
||||
public $RecordsPerQuery = 100; // This will determine how to limit sql statements
|
||||
public $IDsPerQuery = 5000; // When we query ID's, we read a lot more the datarecords at once!
|
||||
public $SortColumn = SYSLOG_UID; // Default sorting column
|
||||
|
||||
// public $FileName = '';
|
||||
// public $LineParserType = "syslog"; // Default = Syslog!
|
||||
// public $_lineParser = null;
|
||||
|
||||
public function LogStreamFactory($o)
|
||||
{
|
||||
// An instance is created, then include the logstreamdisk class as well!
|
||||
global $gl_root_path;
|
||||
require_once($gl_root_path . 'classes/logstreamdb.class.php');
|
||||
|
||||
// // Create and set LineParser Instance
|
||||
// $this->_lineParser = $this->CreateLineParser();
|
||||
|
||||
// return LogStreamDisk instance
|
||||
return new LogStreamDB($o);
|
||||
}
|
||||
/*
|
||||
private function CreateLineParser()
|
||||
{
|
||||
// We need to include Line Parser on demand!
|
||||
global $gl_root_path;
|
||||
require_once($gl_root_path . 'classes/logstreamlineparser.class.php');
|
||||
|
||||
// Probe if file exists then include it!
|
||||
$strIncludeFile = 'classes/logstreamlineparser' . $this->LineParserType . '.class.php';
|
||||
$strClassName = "LogStreamLineParser" . $this->LineParserType;
|
||||
|
||||
if ( is_file($strIncludeFile) )
|
||||
{
|
||||
require_once($strIncludeFile);
|
||||
|
||||
// TODO! Create Parser based on Source Config!
|
||||
|
||||
//return LineParser Instance
|
||||
return new $strClassName();
|
||||
}
|
||||
else
|
||||
DieWithErrorMsg("Couldn't locate LineParser include file '" . $strIncludeFile . "'");
|
||||
}
|
||||
*/
|
||||
}
|
||||
?>
|
641
src/classes/logstreamdb.class.php
Normal file
641
src/classes/logstreamdb.class.php
Normal file
@ -0,0 +1,641 @@
|
||||
<?php
|
||||
/*
|
||||
*********************************************************************
|
||||
* -> www.phplogcon.org <- *
|
||||
* ----------------------------------------------------------------- *
|
||||
* Some constants *
|
||||
* *
|
||||
* LogStreamDB provides access to the data in database. In the most
|
||||
* cases this will be plain text files. If we need access to e.g.
|
||||
* zipped files, this will be handled by a separate driver.
|
||||
*
|
||||
* \version 2.0.0 Init Version
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
// ---
|
||||
|
||||
// --- Required Includes!
|
||||
require_once($gl_root_path . 'include/constants_errors.php');
|
||||
// ---
|
||||
|
||||
class LogStreamDB extends LogStream {
|
||||
private $_dbhandle = null;
|
||||
|
||||
// Helper to store the database records
|
||||
private $bufferedRecords = null;
|
||||
private $_currentRecordStart = 0;
|
||||
private $_currentRecordNum = 0;
|
||||
private $_totalRecordCount = -1;
|
||||
|
||||
private $_SQLwhereClause = "";
|
||||
|
||||
/* private $_currentOffset = -1;
|
||||
private $_currentStartPos = -1;
|
||||
private $_fp = null;
|
||||
private $_bEOS = false;
|
||||
|
||||
const _BUFFER_length = 8192;
|
||||
private $_buffer = false;
|
||||
private $_buffer_length = 0;
|
||||
private $_p_buffer = -1;
|
||||
*/
|
||||
// Constructor
|
||||
public function LogStreamDB($streamConfigObj) {
|
||||
$this->_logStreamConfigObj = $streamConfigObj;
|
||||
|
||||
if ( $this->_logStreamConfigObj->DBType == DB_MYSQL )
|
||||
{
|
||||
// Probe if a function exists!
|
||||
if ( !function_exists("mysql_connect") )
|
||||
DieWithFriendlyErrorMsg("Error, MYSQL Extensions are not enabled! Function 'mysql_connect' does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open and verifies the database conncetion
|
||||
*
|
||||
* @param arrProperties array in: Properties wish list.
|
||||
* @return integer Error stat
|
||||
*/
|
||||
public function Open($arrProperties)
|
||||
{
|
||||
global $dbmapping;
|
||||
|
||||
// Try to connect to the database
|
||||
$this->_dbhandle = mysql_connect($this->_logStreamConfigObj->DBServer,$this->_logStreamConfigObj->DBUser,$this->_logStreamConfigObj->DBPassword);
|
||||
if (!$this->_dbhandle)
|
||||
return ERROR_DB_CONNECTFAILED;
|
||||
|
||||
$bRet = mysql_select_db($this->_logStreamConfigObj->DBName, $this->_dbhandle);
|
||||
if(!$bRet)
|
||||
return ERROR_DB_CANNOTSELECTDB;
|
||||
|
||||
// Copy the Property Array
|
||||
$this->_arrProperties = $arrProperties;
|
||||
|
||||
// Check if DB Mapping exists
|
||||
if ( !isset($dbmapping[ $this->_logStreamConfigObj->DBTableType ]) )
|
||||
return ERROR_DB_INVALIDDBMAPPING;
|
||||
|
||||
// Create SQL Where Clause first!
|
||||
$this->CreateSQLWhereClause();
|
||||
|
||||
// Obtain count of records
|
||||
$this->_totalRecordCount = $this->GetRowCountFromTable();
|
||||
|
||||
if ( $this->_totalRecordCount <= 0 )
|
||||
return ERROR_NOMORERECORDS;
|
||||
|
||||
// reached this point means success!
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the database connection.
|
||||
*
|
||||
* @return integer Error state
|
||||
*/
|
||||
public function Close()
|
||||
{
|
||||
mysql_close($this->_dbhandle);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the data from a specific uID which means in this
|
||||
* case beginning with from the Database ID
|
||||
*
|
||||
* @param uID integer in/out: unique id of the data row
|
||||
* @param arrProperitesOut array out: array filled with properties
|
||||
* @return integer Error state
|
||||
* @see ReadNext()
|
||||
*/
|
||||
public function Read($uID, &$arrProperitesOut)
|
||||
{
|
||||
// Seek the first uID!
|
||||
if ( $this->Sseek($uID, EnumSeek::UID, 0) == SUCCESS)
|
||||
{
|
||||
// Read the next record!
|
||||
$ret = $this->ReadNext($uID, $arrProperitesOut);
|
||||
}
|
||||
else
|
||||
$ret = ERROR_NOMORERECORDS;
|
||||
|
||||
// return result!
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next line from the file depending on the current
|
||||
* read direction.
|
||||
*
|
||||
* Hint: If the current stream becomes unavailable an error
|
||||
* stated is retuned. A typical case is if a log rotation
|
||||
* changed the original data source.
|
||||
*
|
||||
* @param uID integer out: uID is the offset of data row
|
||||
* @param arrProperitesOut array out: properties
|
||||
* @return integer Error state
|
||||
* @see ReadNext
|
||||
*/
|
||||
public function ReadNext(&$uID, &$arrProperitesOut)
|
||||
{
|
||||
// Helpers needed for DB Mapping
|
||||
global $dbmapping, $fields;
|
||||
$szTableType = $this->_logStreamConfigObj->DBTableType;
|
||||
|
||||
// define $ret
|
||||
$ret = SUCCESS;
|
||||
|
||||
// No buffer? then read from DB!
|
||||
if ( $this->bufferedRecords == null )
|
||||
$ret = $this->ReadNextRecordsFromDB($uID);
|
||||
|
||||
if ( $ret == SUCCESS )
|
||||
{
|
||||
// Init and set variables
|
||||
foreach ( $this->_arrProperties as $property )
|
||||
{
|
||||
// Copy property if available!
|
||||
$dbfieldname = $dbmapping[$szTableType][$property];
|
||||
if ( isset($this->bufferedRecords[$this->_currentRecordNum][$dbfieldname]) )
|
||||
{
|
||||
if ( isset($fields[$property]['FieldType']) && $fields[$property]['FieldType'] == FILTER_TYPE_DATE ) // Handle as date!
|
||||
$arrProperitesOut[$property] = GetEventTime( $this->bufferedRecords[$this->_currentRecordNum][$dbfieldname] );
|
||||
else
|
||||
$arrProperitesOut[$property] = $this->bufferedRecords[$this->_currentRecordNum][$dbfieldname];
|
||||
}
|
||||
else
|
||||
$arrProperitesOut[$property] = '';
|
||||
}
|
||||
|
||||
// Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum;
|
||||
$uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]];
|
||||
|
||||
// Increment $_currentRecordNum
|
||||
$this->_currentRecordNum++;
|
||||
|
||||
if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) )
|
||||
{
|
||||
// We need to load new records, so clear the old ones first!
|
||||
$this->ResetBufferedRecords();
|
||||
|
||||
// Set new Record start, will be used in the SQL Statement!
|
||||
$this->_currentRecordStart = $this->_currentRecordNum; // + 1;
|
||||
|
||||
// Now read new ones
|
||||
$ret = $this->ReadNextRecordsFromDB($uID);
|
||||
|
||||
// TODO Check and READ next record!
|
||||
// die ("omfg wtf ReadNext " . $this->_currentRecordNum);
|
||||
}
|
||||
}
|
||||
|
||||
// reached here means return result!
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of Seek
|
||||
*/
|
||||
public function Sseek(&$uID, $mode, $numrecs)
|
||||
{
|
||||
// predefine return value
|
||||
$ret = SUCCESS;
|
||||
|
||||
switch ($mode)
|
||||
{
|
||||
case EnumSeek::UID:
|
||||
if ( $uID == UID_UNKNOWN ) // set uID to first ID!
|
||||
{
|
||||
// No buffer? then read from DB!
|
||||
if ( $this->bufferedRecords == null )
|
||||
$ret = $this->ReadNextRecordsFromDB($uID);
|
||||
|
||||
if ( $ret == SUCCESS )
|
||||
{
|
||||
$this->_currentRecordNum = 0;
|
||||
$uID = $this->bufferedRecords[ $this->_currentRecordNum ];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Obtain fieldname for uID
|
||||
global $dbmapping;
|
||||
$uidfieldname = $dbmapping[$this->_logStreamConfigObj->DBTableType][SYSLOG_UID];
|
||||
|
||||
// Clear if necessary!
|
||||
if ( $this->bufferedRecords == null )
|
||||
$this->ResetBufferedRecords();
|
||||
|
||||
// Loop through all records for now, maybe optimized later!
|
||||
$bFound = false;
|
||||
$tmpuID = $uID;
|
||||
$ret = ERROR_NOMORERECORDS; // Set Default error code!
|
||||
while( $bFound == false && $this->ReadNextIDsFromDB() == SUCCESS )
|
||||
{
|
||||
foreach ( $this->bufferedRecords as $myRecord )
|
||||
{
|
||||
if ( $myRecord[$uidfieldname] == $uID )
|
||||
{
|
||||
$bFound = true;
|
||||
$ret = SUCCESS;
|
||||
break; // Break foreach loop!
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmpuID = $myRecord[$uidfieldname];
|
||||
// Only Increment $_currentRecordNum
|
||||
$this->_currentRecordNum++;
|
||||
}
|
||||
}
|
||||
|
||||
// We need to load new records, so clear the old ones first!
|
||||
$this->ResetBufferedRecords();
|
||||
|
||||
// Set new Record start, will be used in the SQL Statement!
|
||||
$this->_currentRecordStart = $this->_currentRecordNum;
|
||||
}
|
||||
|
||||
// Delete buffered records, then they will be read automatically in ReadNext()
|
||||
$this->ResetBufferedRecords();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Return result!
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* GetMessageCount will return the count of Message.
|
||||
* If this count is not available, the function will
|
||||
* return the default -1
|
||||
*/
|
||||
public function GetMessageCount()
|
||||
{
|
||||
return $this->_totalRecordCount;
|
||||
}
|
||||
|
||||
/*
|
||||
* GetSortOrderProperties is not implemented yet. So it always
|
||||
* return null.
|
||||
*/
|
||||
public function GetSortOrderProperties()
|
||||
{
|
||||
/*
|
||||
return null;
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* ============= Beginn of private functions =============
|
||||
*/
|
||||
|
||||
/*
|
||||
* This function expects the filters to already being set earlier.
|
||||
* Otherwise no usual WHERE Clause can be created!
|
||||
*/
|
||||
private function CreateSQLWhereClause()
|
||||
{
|
||||
if ( $this->_filters != null )
|
||||
{
|
||||
global $dbmapping;
|
||||
$szTableType = $this->_logStreamConfigObj->DBTableType;
|
||||
|
||||
// Reset WhereClause
|
||||
$this->_SQLwhereClause = "";
|
||||
|
||||
// Loop through all available properties
|
||||
foreach( $this->_arrProperties as $propertyname )
|
||||
{
|
||||
// If the property exists in the filter array, we have something to filter for ^^!
|
||||
if ( array_key_exists($propertyname, $this->_filters) )
|
||||
{
|
||||
// Process all filters
|
||||
foreach( $this->_filters[$propertyname] as $myfilter )
|
||||
{
|
||||
switch( $myfilter[FILTER_TYPE] )
|
||||
{
|
||||
case FILTER_TYPE_STRING:
|
||||
// Check if user wants to include or exclude!
|
||||
if ( $myfilter[FILTER_MODE] == FILTER_MODE_INCLUDE)
|
||||
$addnod = "";
|
||||
else
|
||||
$addnod = " NOT";
|
||||
|
||||
// If Syslog message, we have AND handling, otherwise OR!
|
||||
if ( $propertyname == SYSLOG_MESSAGE )
|
||||
$addor = " AND ";
|
||||
else
|
||||
$addor = " OR ";
|
||||
|
||||
|
||||
|
||||
if ( isset($tmpfilters[$propertyname]) )
|
||||
$tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType][$propertyname] . $addnod . " LIKE '%" . $myfilter[FILTER_VALUE] . "%'";
|
||||
else
|
||||
{
|
||||
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING;
|
||||
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . $addnod . " LIKE '%" . $myfilter[FILTER_VALUE] . "%'";
|
||||
}
|
||||
break;
|
||||
case FILTER_TYPE_NUMBER:
|
||||
if ( isset($tmpfilters[$propertyname]) )
|
||||
$tmpfilters[$propertyname][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE];
|
||||
else
|
||||
{
|
||||
$tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER;
|
||||
$tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType][$propertyname] . " IN (" . $myfilter[FILTER_VALUE];
|
||||
}
|
||||
break;
|
||||
case FILTER_TYPE_DATE:
|
||||
break;
|
||||
default:
|
||||
// Nothing to do!
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check and combine all filters now!
|
||||
if ( isset($tmpfilters) )
|
||||
{
|
||||
// Append filters
|
||||
foreach( $tmpfilters as $tmpfilter )
|
||||
{
|
||||
// Init WHERE or Append AND
|
||||
if ( strlen($this->_SQLwhereClause) > 0 )
|
||||
$this->_SQLwhereClause .= " AND ";
|
||||
else
|
||||
$this->_SQLwhereClause = " WHERE ";
|
||||
|
||||
switch( $tmpfilter[FILTER_TYPE] )
|
||||
{
|
||||
case FILTER_TYPE_STRING:
|
||||
$this->_SQLwhereClause .= "( " . $tmpfilter[FILTER_VALUE] . ") ";
|
||||
break;
|
||||
case FILTER_TYPE_NUMBER:
|
||||
$this->_SQLwhereClause .= $tmpfilter[FILTER_VALUE] . ") ";
|
||||
break;
|
||||
case FILTER_TYPE_DATE:
|
||||
break;
|
||||
default:
|
||||
// Nothing to do!
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//echo $this->_SQLwhereClause;
|
||||
//$dbmapping[$szTableType][SYSLOG_UID]
|
||||
|
||||
//$this->_SQLwhereClause;
|
||||
}
|
||||
else // No filters means nothing to do!
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function only reads the uID values from the database. Using this method,
|
||||
* it will be much faster to find the starting uID point we need when paging is used.
|
||||
*/
|
||||
private function ReadNextIDsFromDB()
|
||||
{
|
||||
global $querycount;
|
||||
|
||||
// Get SQL Statement
|
||||
$szSql = $this->CreateSQLStatement(-1, false);
|
||||
|
||||
// Append LIMIT clause
|
||||
$szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->IDsPerQuery;
|
||||
|
||||
// Perform Database Query
|
||||
$myquery = mysql_query($szSql, $this->_dbhandle);
|
||||
if ( !$myquery )
|
||||
{
|
||||
$this->PrintDebugError("Invalid SQL: ".$szSql);
|
||||
return ERROR_DB_QUERYFAILED;
|
||||
}
|
||||
|
||||
// Copy rows into the buffer!
|
||||
$iBegin = $this->_currentRecordNum;
|
||||
while ($myRow = mysql_fetch_array($myquery, MYSQL_ASSOC))
|
||||
{
|
||||
$this->bufferedRecords[$iBegin] = $myRow;
|
||||
$iBegin++;
|
||||
}
|
||||
|
||||
// Free Query ressources
|
||||
mysql_free_result ($myquery);
|
||||
|
||||
// Increment for the Footer Stats
|
||||
$querycount++;
|
||||
|
||||
// return success state if reached this point!
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* This helper function will read the next records into the buffer.
|
||||
*/
|
||||
private function ReadNextRecordsFromDB($uID)
|
||||
{
|
||||
global $querycount;
|
||||
|
||||
// Get SQL Statement
|
||||
$szSql = $this->CreateSQLStatement($uID);
|
||||
|
||||
// Append LIMIT clause
|
||||
$szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->RecordsPerQuery;
|
||||
|
||||
// Perform Database Query
|
||||
$myquery = mysql_query($szSql, $this->_dbhandle);
|
||||
if ( !$myquery )
|
||||
{
|
||||
$this->PrintDebugError("Invalid SQL: ".$szSql);
|
||||
return ERROR_DB_QUERYFAILED;
|
||||
}
|
||||
|
||||
// Copy rows into the buffer!
|
||||
$iBegin = $this->_currentRecordNum;
|
||||
while ($myRow = mysql_fetch_array($myquery, MYSQL_ASSOC))
|
||||
{
|
||||
$this->bufferedRecords[$iBegin] = $myRow;
|
||||
$iBegin++;
|
||||
}
|
||||
|
||||
// Free Query ressources
|
||||
mysql_free_result ($myquery);
|
||||
|
||||
// Increment for the Footer Stats
|
||||
$querycount++;
|
||||
|
||||
// return success state if reached this point!
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates the SQL Statement we are going to use!
|
||||
*/
|
||||
private function CreateSQLStatement($uID, $includeFields = true)
|
||||
{
|
||||
global $dbmapping;
|
||||
|
||||
// Copy helper variables, this is just for better readability
|
||||
$szTableType = $this->_logStreamConfigObj->DBTableType;
|
||||
$szSortColumn = $this->_logStreamConfigObj->SortColumn;
|
||||
|
||||
// Create SQL String
|
||||
$sqlString = "SELECT " . $dbmapping[$szTableType][SYSLOG_UID];
|
||||
if ( $includeFields && $this->_arrProperties != null )
|
||||
{
|
||||
// Loop through all requested fields
|
||||
foreach ( $this->_arrProperties as $myproperty )
|
||||
{
|
||||
// SYSLOG_UID already added!
|
||||
if ( $myproperty != SYSLOG_UID && isset($dbmapping[$szTableType][$myproperty]) )
|
||||
{
|
||||
// Append field!
|
||||
$sqlString .= ", " . $dbmapping[$szTableType][$myproperty];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append FROM 'table'!
|
||||
$sqlString .= " FROM " . $this->_logStreamConfigObj->DBTableName;
|
||||
|
||||
// Append precreated where clause
|
||||
$sqlString .= $this->_SQLwhereClause;
|
||||
|
||||
// Append ORDER clause
|
||||
if ( $this->_readDirection == EnumReadDirection::Forward )
|
||||
$sqlString .= " ORDER BY " . $dbmapping[$szTableType][$szSortColumn];
|
||||
else if ( $this->_readDirection == EnumReadDirection::Backward )
|
||||
$sqlString .= " ORDER BY " . $dbmapping[$szTableType][$szSortColumn] . " DESC";
|
||||
|
||||
// return SQL result string:
|
||||
return $sqlString;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset record buffer in this function!
|
||||
*/
|
||||
private function ResetBufferedRecords()
|
||||
{
|
||||
if ( isset($this->bufferedRecords) )
|
||||
{
|
||||
// Loop through all subrecords first!
|
||||
foreach ($this->bufferedRecords as $mykey => $myrecord)
|
||||
unset( $this->bufferedRecords[$mykey] );
|
||||
|
||||
// Set buffered records to NULL!
|
||||
$this->bufferedRecords = null;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to display SQL Errors for now!
|
||||
*/
|
||||
private function PrintDebugError($szErrorMsg)
|
||||
{
|
||||
global $CFG;
|
||||
|
||||
if ( isset($CFG['MiscShowDebugMsg']) && $CFG['MiscShowDebugMsg'] == 1 )
|
||||
{
|
||||
$errdesc = mysql_error();
|
||||
$errno = mysql_errno();
|
||||
|
||||
$errormsg="Database error: $szErrorMsg <br>";
|
||||
$errormsg.="mysql error: $errdesc <br>";
|
||||
$errormsg.="mysql error number: $errno <br>";
|
||||
$errormsg.="Date: ".date("d.m.Y @ H:i"). "<br>";
|
||||
$errormsg.="Script: ".getenv("REQUEST_URI"). "<br>";
|
||||
$errormsg.="Referer: ".getenv("HTTP_REFERER"). "<br>";
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -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]) . "<br>";
|
||||
// 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -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] . "' <br>");
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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";
|
||||
// ---
|
||||
?>
|
||||
|
@ -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);
|
||||
|
||||
?>
|
||||
|
@ -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" => "" );
|
||||
|
||||
?>
|
@ -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";
|
||||
// ---
|
||||
|
||||
?>
|
@ -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');
|
||||
|
@ -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]) . "<br>";
|
||||
// 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()
|
||||
{
|
||||
|
@ -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!
|
||||
|
@ -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
|
||||
|
@ -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') )
|
||||
|
344
src/index.php
344
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!
|
||||
|
@ -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";
|
||||
|
@ -89,6 +89,12 @@
|
||||
<tr>
|
||||
<td width="100%" valign="top">
|
||||
|
||||
<!-- IF syslogmessagesenabled="false" -->
|
||||
<center>
|
||||
<h3><br><br><font color="red">{LN_ERROR_NORECORDS}</font></h3>
|
||||
</center>
|
||||
<!-- ENDIF syslogmessagesenabled="false" -->
|
||||
|
||||
<!-- IF syslogmessagesenabled="true" -->
|
||||
<table width="100%" cellpadding="0" cellspacing="1" border="0" align="center" class="with_border_alternate">
|
||||
<tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user