diff --git a/src/admin/sources.php b/src/admin/sources.php
index 080bd13..1b2e460 100644
--- a/src/admin/sources.php
+++ b/src/admin/sources.php
@@ -67,6 +67,7 @@ if ( isset($_GET['op']) )
$content['Name'] = "";
$content['SourceType'] = SOURCE_DISK;
CreateSourceTypesList($content['SourceType']);
+ $content['MsgParserList'] = "";
// Init View List!
$content['SourceViewID'] = 'SYSLOG';
@@ -131,6 +132,7 @@ if ( isset($_GET['op']) )
$content['Name'] = $mysource['Name'];
$content['SourceType'] = $mysource['SourceType'];
CreateSourceTypesList($content['SourceType']);
+ $content['MsgParserList'] = $mysource['MsgParserList'];
// Init View List!
$content['SourceViewID'] = $mysource['ViewID'];
@@ -259,6 +261,7 @@ if ( isset($_POST['op']) )
if ( isset($_POST['id']) ) { $content['SOURCEID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SOURCEID'] = -1; }
if ( isset($_POST['Name']) ) { $content['Name'] = DB_RemoveBadChars($_POST['Name']); } else {$content['Name'] = ""; }
if ( isset($_POST['SourceType']) ) { $content['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); }
+ if ( isset($_POST['MsgParserList']) ) { $content['MsgParserList'] = DB_RemoveBadChars($_POST['MsgParserList']); }
if ( isset($_POST['SourceViewID']) ) { $content['SourceViewID'] = DB_RemoveBadChars($_POST['SourceViewID']); }
if ( isset($content['SourceType']) )
@@ -408,6 +411,7 @@ if ( isset($_POST['op']) )
$tmpSource['ID'] = $content['SOURCEID'];
$tmpSource['Name'] = $content['Name'];
$tmpSource['SourceType']= $content['SourceType'];
+ $tmpSource['MsgParserList']= $content['MsgParserList'];
$tmpSource['ViewID'] = $content['SourceViewID'];
if ( $tmpSource['SourceType'] == SOURCE_DISK )
{
@@ -455,9 +459,10 @@ if ( isset($_POST['op']) )
// Add custom search now!
if ( $content['SourceType'] == SOURCE_DISK )
{
- $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, ViewID, LogLineType, DiskFile, userid, groupid)
+ $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, ViewID, LogLineType, DiskFile, userid, groupid)
VALUES ('" . $content['Name'] . "',
" . $content['SourceType'] . ",
+ '" . $content['MsgParserList'] . "',
'" . $content['SourceViewID'] . "',
'" . $content['SourceLogLineType'] . "',
'" . $content['SourceDiskFile'] . "',
@@ -467,9 +472,10 @@ if ( isset($_POST['op']) )
}
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
- $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid)
+ $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid)
VALUES ('" . $content['Name'] . "',
" . $content['SourceType'] . ",
+ '" . $content['MsgParserList'] . "',
'" . $content['SourceViewID'] . "',
'" . $content['SourceDBTableType'] . "',
" . $content['SourceDBType'] . ",
@@ -507,6 +513,7 @@ if ( isset($_POST['op']) )
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
SourceType = " . $content['SourceType'] . ",
+ MsgParserList = '" . $content['MsgParserList'] . "',
ViewID = '" . $content['SourceViewID'] . "',
LogLineType = '" . $content['SourceLogLineType'] . "',
DiskFile = '" . $content['SourceDiskFile'] . "',
@@ -519,6 +526,7 @@ if ( isset($_POST['op']) )
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
SourceType = " . $content['SourceType'] . ",
+ MsgParserList = '" . $content['MsgParserList'] . "',
ViewID = '" . $content['SourceViewID'] . "',
DBTableType = '" . $content['SourceDBTableType'] . "',
DBType = " . $content['SourceDBType'] . ",
@@ -625,6 +633,14 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
// ---
// print_r ( $content['SOURCES'] );
}
+
+/*
+* Helper function to read and init available msg parsers
+*/
+function ReadMsgParserList()
+{
+ global $gl_root_path, $content;
+}
// --- END Custom Code
// --- BEGIN CREATE TITLE
diff --git a/src/admin/upgrade.php b/src/admin/upgrade.php
new file mode 100644
index 0000000..a38e3c1
--- /dev/null
+++ b/src/admin/upgrade.php
@@ -0,0 +1,195 @@
+ Helps administrating phplogcon datasources
+ *
+ * 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 .
+ *
+ * A copy of the GPL can be found in the file "COPYING" in this
+ * distribution
+ *********************************************************************
+*/
+
+// *** Default includes and procedures *** //
+define('IN_PHPLOGCON', true);
+$gl_root_path = './../';
+
+// Now include necessary include files!
+include($gl_root_path . 'include/functions_common.php');
+include($gl_root_path . 'include/functions_frontendhelpers.php');
+//include($gl_root_path . 'include/functions_filters.php');
+
+// Set Upgrade Page!
+define('IS_UPRGADEPAGE', true);
+$content['IS_UPRGADEPAGE'] = true;
+
+// Set PAGE to be ADMINPAGE!
+define('IS_ADMINPAGE', true);
+$content['IS_ADMINPAGE'] = true;
+InitPhpLogCon();
+InitSourceConfigs();
+InitFrontEndDefaults(); // Only in WebFrontEnd
+
+// Init admin langauge file now!
+IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
+// *** *** //
+
+// --- BEGIN Custom Code
+if ( isset($content['database_forcedatabaseupdate']) && $content['database_forcedatabaseupdate'] == "yes" )
+{
+ if ( isset($_GET['op']) )
+ {
+ if ($_GET['op'] == "upgrade")
+ {
+ // Lets start the uodating!
+ $content['UPGRADE_RUNNING'] = "1";
+
+ $content['sql_sucess'] = 0;
+ $content['sql_failed'] = 0;
+ $totaldbdefs = "";
+
+ $tblPref = GetConfigSetting("UserDBPref", "logcon");
+
+ // +1 so we start at the right DB Version!
+ for( $i = $content['database_installedversion']+1; $i <= $content['database_internalversion']; $i++ )
+ {
+ $myfilename = "db_update_v" . $i . ".txt";
+
+ // Lets read the table definitions :)
+ $handle = @fopen($content['BASEPATH'] . "include/" . $myfilename, "r");
+ if ($handle === false)
+ {
+ $content['ISERROR'] = "true";
+ $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_DBUPGRADE_DBFILENOTFOUND'], $myfilename );
+ }
+ else
+ {
+ while (!feof($handle))
+ {
+ $buffer = fgets($handle, 4096);
+
+ $pos = strpos($buffer, "--");
+ if ($pos === false)
+ $totaldbdefs .= $buffer;
+ else if ( $pos > 2 && strlen( trim($buffer) ) > 1 )
+ $totaldbdefs .= $buffer;
+ }
+ fclose($handle);
+ }
+ }
+
+ if ( !isset($content['ISERROR']) )
+ {
+ if ( strlen($totaldbdefs) <= 0 )
+ {
+ $content['ISERROR'] = "true";
+ $content['ERROR_MSG'] = $content['LN_DBUPGRADE_DBDEFFILESHORT'];
+ }
+
+ // Replace stats_ with the custom one ;)
+ $totaldbdefs = str_replace( "`logcon_", "`" . $tblPref, $totaldbdefs );
+
+ // Now split by sql command
+ $mycommands = split( ";\r\n", $totaldbdefs );
+
+ // check for different linefeed
+ if ( count($mycommands) <= 1 )
+ $mycommands = split( ";\n", $totaldbdefs );
+
+ //Still only one? Abort
+ if ( count($mycommands) <= 1 )
+ {
+ $content['ISERROR'] = "true";
+ $content['ERROR_MSG'] = $content['LN_DBUPGRADE_DBDEFFILESHORT'];
+ }
+
+ if ( !isset($content['ISERROR']) )
+ {
+ // --- Now execute all commands
+ ini_set('error_reporting', E_WARNING); // Enable Warnings!
+
+ for($i = 0; $i < count($mycommands); $i++)
+ {
+ if ( strlen(trim($mycommands[$i])) > 1 )
+ {
+ $result = DB_Query( $mycommands[$i], false );
+ if ($result == FALSE)
+ {
+ $content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = DB_ReturnSimpleErrorMsg();
+ $content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = $mycommands[$i];
+
+ // --- Set CSS Class
+ if ( $content['sql_failed'] % 2 == 0 )
+ $content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line1";
+ else
+ $content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line2";
+ // ---
+
+ $content['sql_failed']++;
+ }
+ else
+ $content['sql_sucess']++;
+
+ // Free result
+ DB_FreeQuery($result);
+ }
+ }
+ // ---
+
+ // --- Upgrade Database Version in Config Table
+ $content['database_installedversion'] = $content['database_internalversion'];
+ WriteConfigValue( "database_installedversion", true );
+ // ---
+ }
+ }
+ }
+ else
+ $content['UPGRADE_DEFAULT'] = "1";
+ }
+ else
+ $content['UPGRADE_DEFAULT'] = "1";
+
+
+}
+else
+ $content['UPGRADE_DEFAULT'] = "0";
+
+
+// disable running to be save! ;)
+if ( isset($content['ISERROR']) )
+ $content['UPGRADE_RUNNING'] = "0";
+// --- END Custom Code
+
+// --- BEGIN CREATE TITLE
+$content['TITLE'] = InitPageTitle();
+$content['TITLE'] .= " :: " . $content['LN_DBUPGRADE_TITLE'];
+// --- END CREATE TITLE
+
+// --- Parsen and Output
+InitTemplateParser();
+$page -> parser($content, "admin/admin_upgrade.html");
+$page -> output();
+// ---
+
+?>
\ No newline at end of file
diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php
index 79f0115..a14c5c2 100644
--- a/src/classes/logstream.class.php
+++ b/src/classes/logstream.class.php
@@ -40,6 +40,7 @@ if ( !defined('IN_PHPLOGCON') )
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
+require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
@@ -204,6 +205,14 @@ abstract class LogStream {
*/
public abstract function IsPropertySortable($myProperty);
+ /*
+ * Helper functino to trigger initialisation of MsgParsers
+ */
+ public function RunBasicInits()
+ {
+ $this->_logStreamConfigObj->InitMsgParsers();
+ }
+
/**
* Set the filter for the current stream.
*
@@ -582,7 +591,6 @@ abstract class LogStream {
return -1;
}
-
}
-?>
+?>
\ No newline at end of file
diff --git a/src/classes/logstreamconfig.class.php b/src/classes/logstreamconfig.class.php
index e02cc2d..dce1a3b 100644
--- a/src/classes/logstreamconfig.class.php
+++ b/src/classes/logstreamconfig.class.php
@@ -48,8 +48,89 @@ abstract class LogStreamConfig {
protected $_logStreamName = '';
protected $_defaultFacility = '';
protected $_defaultSeverity = '';
-
+
+ // helpers properties for message parser list!
+ protected $_msgParserList = null; // Contains a string list of configure msg parsers
+ protected $_msgParserObjList = null; // Contains an object reference list to the msg parsers
+
+ // Constructor prototype
public abstract function LogStreamFactory($o);
+
+ /*
+ * Initialize Msg Parsers!
+ */
+ public function InitMsgParsers()
+ {
+ // Init parsers if available and not initialized already!
+ if ( $this->_msgParserList != null && $this->_msgParserObjList == null )
+ {
+ // Loop through parsers
+ foreach( $this->_msgParserList as $szParser )
+ {
+ // Set Classname
+ $szClassName = "MsgParser_" . $szParser;
+
+ // Create OBjectRef!
+ $this->_msgParserObjList[] = new $szClassName();
+ }
+ }
+ }
+
+ /*
+ *
+ */
+ public function SetMsgParserList( $szParsers )
+ {
+ global $gl_root_path;
+
+ // Check if we have at least something to check
+ if ( $szParsers == null || strlen($szParsers) <= 0 )
+ return;
+
+ // Set list of Parsers!
+ if ( strpos($szParsers, ",") )
+ $aParsers = explode( ",", $szParsers );
+ else
+ $aParsers[0] = $szParsers;
+
+ // Loop through parsers
+ foreach( $aParsers as $szParser )
+ {
+ // Remove whitespaces
+ $szParser = trim($szParser);
+
+ // Check if parser file include exists
+ $szIncludeFile = $gl_root_path . 'classes/msgparsers/msgparser.' . $szParser . '.class.php';
+ if ( file_exists($szIncludeFile) )
+ {
+ // Try to include
+ if ( @include_once($szIncludeFile) )
+ $this->_msgParserList[] = $szParser;
+ else
+ OutputDebugMessage("Error, MsgParser '" . $szParser . "' could not be included. ", DEBUG_ERROR);
+
+ }
+ }
+
+// print_r ( $this->_msgParserList );
+ }
+
+ public function ProcessMsgParsers($szMsg, &$arrArguments)
+ {
+ // Process if set!
+ if ( $this->_msgParserObjList != null )
+ {
+ foreach( $this->_msgParserObjList as $myMsgParser )
+ {
+ // Perform Parsing, and return if was successfull! Otherwise the next Parser will be called.
+ if ( $myMsgParser->ParseMsg($szMsg, $arrArguments) == SUCCESS )
+ return SUCCESS;
+ }
+ }
+
+ // reached this means all work is done!
+ return SUCCESS;
+ }
}
?>
diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php
index 4532141..3f21eea 100644
--- a/src/classes/logstreamdb.class.php
+++ b/src/classes/logstreamdb.class.php
@@ -84,6 +84,9 @@ class LogStreamDB extends LogStream {
{
global $dbmapping;
+ // Initialise Basic stuff within the Classs
+ $this->RunBasicInits();
+
// Verify database connection (This also opens the database!)
$res = $this->Verify();
if ( $res != SUCCESS )
diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php
index dbfed7e..c135df7 100644
--- a/src/classes/logstreamdisk.class.php
+++ b/src/classes/logstreamdisk.class.php
@@ -73,7 +73,10 @@ class LogStreamDisk extends LogStream {
* @param arrProperties array in: Properties wish list.
* @return integer Error stat
*/
- public function Open($arrProperties) {
+ public function Open($arrProperties)
+ {
+ // Initialise Basic stuff within the Classs
+ $this->RunBasicInits();
// Check if file exists!
$result = $this->Verify();
@@ -235,6 +238,9 @@ class LogStreamDisk extends LogStream {
{
// Line Parser Hook here
$this->_logStreamConfigObj->_lineParser->ParseLine($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
+
+ // Run optional Message Parsers now
+ $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut);
// Set uID to the PropertiesOut!
$arrProperitesOut[SYSLOG_UID] = $uID;
diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php
index e499ff4..8142c10 100644
--- a/src/classes/logstreampdo.class.php
+++ b/src/classes/logstreampdo.class.php
@@ -87,6 +87,9 @@ class LogStreamPDO extends LogStream {
{
global $dbmapping;
+ // Initialise Basic stuff within the Classs
+ $this->RunBasicInits();
+
// Verify database driver and connection (This also opens the database!)
$res = $this->Verify();
if ( $res != SUCCESS )
diff --git a/src/classes/msgparsers/msgparser.eventlog.class.php b/src/classes/msgparsers/msgparser.eventlog.class.php
index f3bd444..fa22d78 100644
--- a/src/classes/msgparsers/msgparser.eventlog.class.php
+++ b/src/classes/msgparsers/msgparser.eventlog.class.php
@@ -40,16 +40,16 @@ if ( !defined('IN_PHPLOGCON') )
// --- Basic Includes
require_once($gl_root_path . 'classes/enums.class.php');
+require_once($gl_root_path . 'classes/msgparser.class.php');
require_once($gl_root_path . 'include/constants_errors.php');
require_once($gl_root_path . 'include/constants_logstream.php');
// ---
-
-class MsgParserEventLog extends MsgParser {
+class MsgParser_eventlog extends MsgParser {
// protected $_arrProperties = null;
// Constructor
- public function LogStreamLineParserwinsyslog() {
+ public function MsgParser_eventlog() {
return; // Nothing
}
@@ -63,28 +63,28 @@ class MsgParserEventLog extends MsgParser {
{
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}),(.*?):(.*?)$/", $szMsg, $out ) )
+ // Sample (WinSyslog/EventReporter): 7035,XPVS2005\Administrator,Service Control Manager,System,[INF],0,The Adiscon EvntSLog service was successfully sent a start control.
+ // Source: %id%,%user%,%sourceproc%,%NTEventLogType%,%severity%,%category%,%msg%%$CRLF%
+ if ( preg_match("/([0-9]{1,12}),(.*?),(.*?),(.*?),(.*?),([0-9]{1,12}),(.*?)$/", $szMsg, $out ) )
{
// Copy parsed properties!
- $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_EVENT_ID] = $out[1];
+ $arrArguments[SYSLOG_EVENT_USER] = $out[2];
+ $arrArguments[SYSLOG_EVENT_SOURCE] = $out[3];
+ $arrArguments[SYSLOG_EVENT_LOGTYPE] = $out[4];
+/// $arrArguments[SYSLOG_SEVERITY] = $out[5];
+ $arrArguments[SYSLOG_EVENT_CATEGORY] = $out[6];
$arrArguments[SYSLOG_MESSAGE] = $out[7];
}
else
-*/
{
// return no match in this case!
return ERROR_MSG_NOMATCH;
}
+ // Set IUT Property if success!
+ $arrArguments[SYSLOG_MESSAGETYPE] = IUT_NT_EventReport;
+
// If we reached this position, return success!
return SUCCESS;
}
diff --git a/src/convert.php b/src/convert.php
index 09d46a2..c24a2d4 100644
--- a/src/convert.php
+++ b/src/convert.php
@@ -162,7 +162,7 @@ else if ( $content['CONVERT_STEP'] == 3 )
}
// Append INSERT Statement for Config Table to set the Database Version ^^!
- $mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)";
+ $mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', " . $content['database_internalversion'] . ")";
// --- Now execute all commands
ini_set('error_reporting', E_WARNING); // Enable Warnings!
diff --git a/src/include/config.sample.php b/src/include/config.sample.php
index 7fb20f2..34c7a93 100644
--- a/src/include/config.sample.php
+++ b/src/include/config.sample.php
@@ -104,12 +104,14 @@ $CFG['Search'][] = array ( "DisplayName" => "All messages from last 31 days", "S
$CFG['Sources']['Source1']['Name'] = "Syslog Disk File";
$CFG['Sources']['Source1']['SourceType'] = SOURCE_DISK;
$CFG['Sources']['Source1']['LogLineType'] = "syslog";
+ $CFG['Sources']['Source1']['MsgParserList'] = "";
$CFG['Sources']['Source1']['DiskFile'] = "/var/log/syslog";
$CFG['Sources']['Source1']['ViewID'] = "SYSLOG";
$CFG['Sources']['Source2']['ID'] = "Source5";
$CFG['Sources']['Source2']['Name'] = "WinSyslog DB";
$CFG['Sources']['Source2']['SourceType'] = SOURCE_DB;
+ $CFG['Sources']['Source1']['MsgParserList'] = "";
$CFG['Sources']['Source2']['DBTableType'] = "winsyslog";
$CFG['Sources']['Source2']['DBType'] = DB_MYSQL;
$CFG['Sources']['Source2']['DBServer'] = "localhost";
diff --git a/src/include/db_template.txt b/src/include/db_template.txt
index b146a33..79eb09b 100644
--- a/src/include/db_template.txt
+++ b/src/include/db_template.txt
@@ -60,10 +60,11 @@ CREATE TABLE IF NOT EXISTS `logcon_searches` (
--
DROP TABLE IF EXISTS `logcon_sources`;
-CREATE TABLE IF NOT EXISTS `logcon_sources` (
+CREATE TABLE `logcon_sources` (
`ID` int(11) NOT NULL auto_increment,
`Name` varchar(255) NOT NULL,
`SourceType` tinyint(4) NOT NULL,
+ `MsgParserList` varchar(255) NOT NULL,
`ViewID` varchar(64) NOT NULL,
`LogLineType` varchar(64) default NULL,
`DiskFile` varchar(255) default NULL,
diff --git a/src/include/db_update_v2.txt b/src/include/db_update_v2.txt
new file mode 100644
index 0000000..d84a18c
--- /dev/null
+++ b/src/include/db_update_v2.txt
@@ -0,0 +1,6 @@
+-- New Database Structure Updates
+ALTER TABLE `logcon_sources` ADD `MsgParserList` VARCHAR( 255 ) NOT NULL AFTER `SourceType` ;
+
+-- Insert data
+
+-- Updated Data
diff --git a/src/include/functions_common.php b/src/include/functions_common.php
index 7d4f1ac..94c11d8 100644
--- a/src/include/functions_common.php
+++ b/src/include/functions_common.php
@@ -40,13 +40,13 @@ if ( !defined('IN_PHPLOGCON') )
// ---
// --- Basic Includes
-include($gl_root_path . 'include/constants_general.php');
-include($gl_root_path . 'include/constants_logstream.php');
+include_once($gl_root_path . 'include/constants_general.php');
+include_once($gl_root_path . 'include/constants_logstream.php');
-include($gl_root_path . 'classes/class_template.php');
-include($gl_root_path . 'include/functions_themes.php');
-include($gl_root_path . 'include/functions_db.php');
-include($gl_root_path . 'include/functions_config.php');
+include_once($gl_root_path . 'classes/class_template.php');
+include_once($gl_root_path . 'include/functions_themes.php');
+include_once($gl_root_path . 'include/functions_db.php');
+include_once($gl_root_path . 'include/functions_config.php');
// ---
// --- Define Basic vars
@@ -551,6 +551,13 @@ function InitConfigurationValues()
else // Critical ERROR HERE!
DieWithFriendlyErrorMsg( "Critical Error occured while trying to access the database in table '" . DB_CONFIG . "'" );
+ // Database Version Checker!
+ if ( $content['database_internalversion'] > $content['database_installedversion'] )
+ {
+ // Database is out of date, we need to upgrade
+ $content['database_forcedatabaseupdate'] = "yes";
+ }
+
// Now we init the user session stuff
InitUserSession();
@@ -579,14 +586,6 @@ function InitConfigurationValues()
// Load Configured Sources
LoadSourcesFromDatabase();
-
-
- // Database Version Checker!
- if ( $content['database_internalversion'] > $content['database_installedversion'] )
- {
- // Database is out of date, we need to upgrade
- $content['database_forcedatabaseupdate'] = "yes";
- }
}
else
{
diff --git a/src/include/functions_config.php b/src/include/functions_config.php
index a6d71d5..0aa6fea 100644
--- a/src/include/functions_config.php
+++ b/src/include/functions_config.php
@@ -67,6 +67,12 @@ function InitSource(&$mysource)
$CFG['Sources'][$iSourceID]['groupid'] = null;
$content['Sources'][$iSourceID]['groupid'] = null;
}
+
+ if ( !isset($mysource['MsgParserList']) )
+ {
+ $CFG['Sources'][$iSourceID]['MsgParserList'] = null;
+ $content['Sources'][$iSourceID]['MsgParserList'] = null;
+ }
// ---
// Set default view id to source
@@ -165,6 +171,7 @@ function InitSource(&$mysource)
// Set generic configuration options
$mysource['ObjRef']->_pageCount = GetConfigSetting("ViewEntriesPerPage", 50);
+ $mysource['ObjRef']->SetMsgParserList( $mysource['MsgParserList'] );
// Set default SourceID here!
if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) )
diff --git a/src/include/functions_db.php b/src/include/functions_db.php
index 2bb2c17..ea3839d 100644
--- a/src/include/functions_db.php
+++ b/src/include/functions_db.php
@@ -45,7 +45,7 @@ $errdesc = "";
$errno = 0;
// --- Current Database Version, this is important for automated database Updates!
-$content['database_internalversion'] = "1"; // Whenever incremented, a database upgrade is needed
+$content['database_internalversion'] = "2"; // Whenever incremented, a database upgrade is needed
$content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database
// ---
diff --git a/src/include/functions_users.php b/src/include/functions_users.php
index 7597760..00be277 100644
--- a/src/include/functions_users.php
+++ b/src/include/functions_users.php
@@ -97,18 +97,15 @@ function InitUserSession()
else // Critical ERROR HERE!
DieWithFriendlyErrorMsg( "Critical Error occured while trying to access the database in table '" . DB_CONFIG . "'" );
// ---
+
+ // --- Extracheck for available database updates!
+ if ( isset($content['database_forcedatabaseupdate']) && $content['database_forcedatabaseupdate'] == "yes" && !defined('IS_UPRGADEPAGE') )
+ RedirectToDatabaseUpgrade();
+ // ---
// Successfully logged in
return true;
}
-/*
- // New, Check for database Version and may redirect to updatepage!
- if ( isset($content['database_forcedatabaseupdate']) &&
- $content['database_forcedatabaseupdate'] == "yes" &&
- $isUpgradePage == false
- )
- RedirectToDatabaseUpgrade();
-*/
}
else
{
@@ -189,12 +186,16 @@ function CheckUserLogin( $username, $password )
$_SESSION['SESSION_GROUPIDS'] = $content['SESSION_GROUPIDS'];
// ---
-
// ---Set LASTLOGIN Time!
$result = DB_Query("UPDATE " . DB_USERS . " SET last_login = " . time() . " WHERE ID = " . $content['SESSION_USERID']);
DB_FreeQuery($result);
// ---
+ // --- Extracheck for available database updates!
+ if ( isset($content['database_forcedatabaseupdate']) && $content['database_forcedatabaseupdate'] == "yes" && !defined('IS_UPRGADEPAGE') )
+ RedirectToDatabaseUpgrade();
+ // ---
+
// Success !
return true;
}
@@ -236,12 +237,14 @@ function RedirectToUserLogin()
function RedirectToDatabaseUpgrade()
{
+ global $content;
+
// build referer
$referer = $_SERVER['PHP_SELF'];
if ( isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0 )
$referer .= "?" . $_SERVER['QUERY_STRING'];
- header("Location: upgrade.php?referer=" . urlencode($referer) );
+ header("Location: " . $content['BASEPATH'] . "admin/upgrade.php?referer=" . urlencode($referer) );
exit;
}
// --- END Usermanagement Function ---
diff --git a/src/install.php b/src/install.php
index ffaffb4..f2e70bc 100644
--- a/src/install.php
+++ b/src/install.php
@@ -394,7 +394,7 @@ else if ( $content['INSTALL_STEP'] == 5 )
}
// Append INSERT Statement for Config Table to set the Database Version ^^!
- $mycommands[count($mycommands)] = "INSERT INTO `" . $_SESSION["UserDBPref"] . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)";
+ $mycommands[count($mycommands)] = "INSERT INTO `" . $_SESSION["UserDBPref"] . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', " . $content['database_internalversion'] . ")";
// --- Now execute all commands
ini_set('error_reporting', E_WARNING); // Enable Warnings!
diff --git a/src/lang/de/admin.php b/src/lang/de/admin.php
index 38a15dc..09322b0 100644
--- a/src/lang/de/admin.php
+++ b/src/lang/de/admin.php
@@ -166,7 +166,7 @@ $content['LN_SEARCH_ERROR_DELSEARCH'] = "Deleting of the Custom Search with id '
$content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been successfully deleted!";
$content['LN_SEARCH_'] = "";
-// Custom Searches center
+// Custom Views center
$content['LN_VIEWS_CENTER'] = "Views Options";
$content['LN_VIEWS_ID'] = "ID";
$content['LN_VIEWS_NAME'] = "View Name";
@@ -190,6 +190,7 @@ $content['LN_VIEWS_ERROR_NOCOLUMNS'] = "You need to add at least one column in o
$content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited.";
$content['LN_VIEWS_'] = "";
+// Custom Sources center
$content['LN_SOURCES_CENTER'] = "Sources Options";
$content['LN_SOURCES_EDIT'] = "Edit Source";
$content['LN_SOURCES_DELETE'] = "Delete Source";
@@ -217,5 +218,19 @@ $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' fa
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_'] = "";
+// Database Upgrade
+$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";
+$content['LN_DBUPGRADE_DBFILENOTFOUND'] = "The database upgrade file '%1' could not be found in the include folder! Please check if all files were successfully uploaded.";
+$content['LN_DBUPGRADE_DBDEFFILESHORT'] = "The database upgrade files where empty or did not contain any SQL Command! Please check if all files were successfully uploaded.";
+$content['LN_DBUPGRADE_WELCOME'] = "Welcome to the database upgrade";
+$content['LN_DBUPGRADE_BEFORESTART'] = "Before you start upgrading your database, you should create a FULL BACKUP OF YOUR DATABASE. Anything else will be done automatically by the upgrade Script.";
+$content['LN_DBUPGRADE_CURRENTINSTALLED'] = "Current Installed Database Version";
+$content['LN_DBUPGRADE_TOBEINSTALLED'] = "Do be Installed Database Version";
+$content['LN_DBUPGRADE_HASBEENDONE'] = "Database Update has been performed, see the results below";
+$content['LN_DBUPGRADE_SUCCESSEXEC'] = "Successfully executed statements";
+$content['LN_DBUPGRADE_FAILEDEXEC'] = "Failed statements";
+$content['LN_DBUPGRADE_ONESTATEMENTFAILED'] = "At least one statement failed, you may need to correct and fix this issue manually. See error details below";
+$content['LN_DBUPGRADE_ERRMSG'] = "Error Message";
+$content['LN_DBUPGRADE_ULTRASTATSDBVERSION'] = "phpLogCon Database Version";
?>
\ No newline at end of file
diff --git a/src/lang/de/main.php b/src/lang/de/main.php
index 19afd8f..80356cd 100644
--- a/src/lang/de/main.php
+++ b/src/lang/de/main.php
@@ -190,6 +190,7 @@ $content['LN_CFG_NAMEOFTHESOURCE'] = "Name der Quelle";
$content['LN_CFG_FIRSTSYSLOGSOURCE'] = "Erste Syslog Quelle";
$content['LN_CFG_VIEW'] = "Select View";
$content['LN_CFG_DBUSERLOGINREQUIRED'] = "Require user to be logged in";
+ $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)";
// Details page
$content['LN_DETAILS_FORSYSLOGMSG'] = "Details für syslog-Nachrichten mit der ID";
diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php
index 38a15dc..299c8ba 100644
--- a/src/lang/en/admin.php
+++ b/src/lang/en/admin.php
@@ -49,7 +49,6 @@ $content['LN_GEN_USERONLY_LONG'] = "For me only
(Only available to your user
$content['LN_GEN_GROUPONLY_LONG'] = "For this group
(Only available to the selected group)";
$content['LN_GEN_GROUPONLYNAME'] = "Group '%1'";
-
// General Options
$content['LN_ADMIN_GLOBFRONTEND'] = "Global frontend options";
$content['LN_ADMIN_USERFRONTEND'] = "User specific frontend options";
@@ -166,7 +165,7 @@ $content['LN_SEARCH_ERROR_DELSEARCH'] = "Deleting of the Custom Search with id '
$content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been successfully deleted!";
$content['LN_SEARCH_'] = "";
-// Custom Searches center
+// Custom Views center
$content['LN_VIEWS_CENTER'] = "Views Options";
$content['LN_VIEWS_ID'] = "ID";
$content['LN_VIEWS_NAME'] = "View Name";
@@ -190,6 +189,7 @@ $content['LN_VIEWS_ERROR_NOCOLUMNS'] = "You need to add at least one column in o
$content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited.";
$content['LN_VIEWS_'] = "";
+// Custom Sources center
$content['LN_SOURCES_CENTER'] = "Sources Options";
$content['LN_SOURCES_EDIT'] = "Edit Source";
$content['LN_SOURCES_DELETE'] = "Delete Source";
@@ -217,5 +217,21 @@ $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' fa
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_'] = "";
+// Database Upgrade
+$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";
+$content['LN_DBUPGRADE_DBFILENOTFOUND'] = "The database upgrade file '%1' could not be found in the include folder! Please check if all files were successfully uploaded.";
+$content['LN_DBUPGRADE_DBDEFFILESHORT'] = "The database upgrade files where empty or did not contain any SQL Command! Please check if all files were successfully uploaded.";
+$content['LN_DBUPGRADE_WELCOME'] = "Welcome to the database upgrade";
+$content['LN_DBUPGRADE_BEFORESTART'] = "Before you start upgrading your database, you should create a FULL BACKUP OF YOUR DATABASE. Anything else will be done automatically by the upgrade Script.";
+$content['LN_DBUPGRADE_CURRENTINSTALLED'] = "Current Installed Database Version";
+$content['LN_DBUPGRADE_TOBEINSTALLED'] = "Do be Installed Database Version";
+$content['LN_DBUPGRADE_HASBEENDONE'] = "Database Update has been performed, see the results below";
+$content['LN_DBUPGRADE_SUCCESSEXEC'] = "Successfully executed statements";
+$content['LN_DBUPGRADE_FAILEDEXEC'] = "Failed statements";
+$content['LN_DBUPGRADE_ONESTATEMENTFAILED'] = "At least one statement failed, you may need to correct and fix this issue manually. See error details below";
+$content['LN_DBUPGRADE_ERRMSG'] = "Error Message";
+$content['LN_DBUPGRADE_ULTRASTATSDBVERSION'] = "phpLogCon Database Version";
+
+
?>
\ No newline at end of file
diff --git a/src/lang/en/main.php b/src/lang/en/main.php
index a191238..4bb7129 100644
--- a/src/lang/en/main.php
+++ b/src/lang/en/main.php
@@ -190,6 +190,7 @@ $content['LN_CFG_FIRSTSYSLOGSOURCE'] = "First Syslog Source";
$content['LN_CFG_DBROWCOUNTING'] = "Enable Row Counting";
$content['LN_CFG_VIEW'] = "Select View";
$content['LN_CFG_DBUSERLOGINREQUIRED'] = "Require user to be logged in";
+$content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)";
// Details page
$content['LN_DETAILS_FORSYSLOGMSG'] = "Details for the syslog messages with id";
diff --git a/src/lang/pt_BR/admin.php b/src/lang/pt_BR/admin.php
index 451a150..bc7a549 100644
--- a/src/lang/pt_BR/admin.php
+++ b/src/lang/pt_BR/admin.php
@@ -165,7 +165,7 @@ $content['LN_SEARCH_ERROR_DELSEARCH'] = "Deleting of the Custom Search with id '
$content['LN_SEARCH_ERROR_HASBEENDEL'] = "The Custom Search '%1' has been successfully deleted!";
$content['LN_SEARCH_'] = "";
-// Custom Searches center
+// Custom Views center
$content['LN_VIEWS_CENTER'] = "Views Options";
$content['LN_VIEWS_ID'] = "ID";
$content['LN_VIEWS_NAME'] = "View Name";
@@ -189,6 +189,7 @@ $content['LN_VIEWS_ERROR_NOCOLUMNS'] = "You need to add at least one column in o
$content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully edited.";
$content['LN_VIEWS_'] = "";
+// Custom Sources center
$content['LN_SOURCES_CENTER'] = "Sources Options";
$content['LN_SOURCES_EDIT'] = "Edit Source";
$content['LN_SOURCES_DELETE'] = "Delete Source";
@@ -216,5 +217,19 @@ $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' fa
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_'] = "";
+// Database Upgrade
+$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";
+$content['LN_DBUPGRADE_DBFILENOTFOUND'] = "The database upgrade file '%1' could not be found in the include folder! Please check if all files were successfully uploaded.";
+$content['LN_DBUPGRADE_DBDEFFILESHORT'] = "The database upgrade files where empty or did not contain any SQL Command! Please check if all files were successfully uploaded.";
+$content['LN_DBUPGRADE_WELCOME'] = "Welcome to the database upgrade";
+$content['LN_DBUPGRADE_BEFORESTART'] = "Before you start upgrading your database, you should create a FULL BACKUP OF YOUR DATABASE. Anything else will be done automatically by the upgrade Script.";
+$content['LN_DBUPGRADE_CURRENTINSTALLED'] = "Current Installed Database Version";
+$content['LN_DBUPGRADE_TOBEINSTALLED'] = "Do be Installed Database Version";
+$content['LN_DBUPGRADE_HASBEENDONE'] = "Database Update has been performed, see the results below";
+$content['LN_DBUPGRADE_SUCCESSEXEC'] = "Successfully executed statements";
+$content['LN_DBUPGRADE_FAILEDEXEC'] = "Failed statements";
+$content['LN_DBUPGRADE_ONESTATEMENTFAILED'] = "At least one statement failed, you may need to correct and fix this issue manually. See error details below";
+$content['LN_DBUPGRADE_ERRMSG'] = "Error Message";
+$content['LN_DBUPGRADE_ULTRASTATSDBVERSION'] = "phpLogCon Database Version";
?>
\ No newline at end of file
diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php
index 219f341..dd46b5a 100644
--- a/src/lang/pt_BR/main.php
+++ b/src/lang/pt_BR/main.php
@@ -194,6 +194,8 @@ $content['LN_CFG_NAMEOFTHESOURCE'] = "Nome da origem";
$content['LN_CFG_FIRSTSYSLOGSOURCE'] = "Fonte primária Syslog";
$content['LN_CFG_DBROWCOUNTING'] = "Habilitar contagem de registro";
$content['LN_CFG_VIEW'] = "Selecione visão";
+ $content['LN_CFG_DBUSERLOGINREQUIRED'] = "Require user to be logged in";
+ $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)";
// Details page
$content['LN_DETAILS_FORSYSLOGMSG'] = "Detalhes para a mensagem com id";
diff --git a/src/templates/admin/admin_sources.html b/src/templates/admin/admin_sources.html
index ad835af..be9e2d1 100644
--- a/src/templates/admin/admin_sources.html
+++ b/src/templates/admin/admin_sources.html
@@ -122,6 +122,10 @@
+
+
+ |
+
|
diff --git a/src/templates/admin/admin_upgrade.html b/src/templates/admin/admin_upgrade.html
new file mode 100644
index 0000000..923d8bd
--- /dev/null
+++ b/src/templates/admin/admin_upgrade.html
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
{LN_GEN_ERRORDETAILS}
+
{ERROR_MSG}
+
+
+ {LN_GEN_ERRORRETURNPREV}
+
+
+
+
+
+
+ {LN_DBUPGRADE_TITLE} |
+
+
+
+
+
+
+
+
+
+
+ {LN_DBUPGRADE_WELCOME}
+ {LN_DBUPGRADE_BEFORESTART}
+ {LN_DBUPGRADE_CURRENTINSTALLED}: {database_installedversion}
+ {LN_DBUPGRADE_TOBEINSTALLED}: {database_internalversion}
+
+
+ Click on Upgrade to start!
+
+
+ |
+
+
+
+
+
+
+
+
+
+ {LN_DBUPGRADE_HASBEENDONE}:
+
+ {LN_DBUPGRADE_SUCCESSEXEC}: {sql_sucess}
+ {LN_DBUPGRADE_FAILEDEXEC}: {sql_failed}
+
+
+
+
+
+
+
+
+
+
+
+
+ {myerrmsg} |
+ {mystatement} |
+
+
+
+
+
+
+
+ {LN_DBUPGRADE_CURRENTINSTALLED}: {database_installedversion}
+ {LN_DBUPGRADE_TOBEINSTALLED}: {database_internalversion}
+
+
+ Click on here to return to the Admin Center
+
+
+ |
+
+
+
+
+
+
+
+
+
+ Welcome to the Database Upgrade
+ Your database is fully updated!
+ {LN_DBUPGRADE_CURRENTINSTALLED}: {database_installedversion}
+ {LN_DBUPGRADE_ULTRASTATSDBVERSION}: {database_internalversion}
+
+
+ Click on here to return to the Admin Center
+
+
+ |
+
+
+
+
+
+
+ |
+
+
+
+
\ No newline at end of file