From 3b49279a8adbca76e3a677b47e7a78273c4736df Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 24 Oct 2008 15:14:58 +0200 Subject: [PATCH 1/9] Fixed a problem when adding a mysql logstream source. Due a problem of how php mysql_connect function handels second conenctions, the Verify of a newly added logstream source could cause the first database connection to be overwritten. The following error is, that the wrong database was used for the UserDB after the new logstream was verified. Also added a check into the redirect function to STOP redirecting if an error happened in the UserDB before. --- src/classes/logstreamdb.class.php | 6 +- .../msgparsers/msgparser.wireless.class.php | 379 ++++++++++-------- src/include/functions_common.php | 38 +- src/include/functions_db.php | 3 + src/lang/de/main.php | 1 + src/lang/en/main.php | 1 + src/lang/pt_BR/main.php | 1 + 7 files changed, 260 insertions(+), 169 deletions(-) diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index 359a0af..a72a411 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -118,7 +118,8 @@ class LogStreamDB extends LogStream { */ public function Close() { - mysql_close($this->_dbhandle); + if ($this->_dbhandle) + mysql_close($this->_dbhandle); return SUCCESS; } @@ -131,7 +132,8 @@ class LogStreamDB extends LogStream { // Try to connect to the database if ( $this->_dbhandle == null ) { - $this->_dbhandle = @mysql_connect($this->_logStreamConfigObj->DBServer,$this->_logStreamConfigObj->DBUser,$this->_logStreamConfigObj->DBPassword); + // Forces to open a new link in all cases! + $this->_dbhandle = @mysql_connect($this->_logStreamConfigObj->DBServer,$this->_logStreamConfigObj->DBUser,$this->_logStreamConfigObj->DBPassword, true); if (!$this->_dbhandle) { if ( isset($php_errormsg) ) diff --git a/src/classes/msgparsers/msgparser.wireless.class.php b/src/classes/msgparsers/msgparser.wireless.class.php index 76c1b89..c784002 100644 --- a/src/classes/msgparsers/msgparser.wireless.class.php +++ b/src/classes/msgparsers/msgparser.wireless.class.php @@ -1,160 +1,221 @@ - www.phplogcon.org <- * - * ----------------------------------------------------------------- * - * Apache Logfile Parser used to split WebLog fields if - * found in the msg. - * - * This Parser is for custom wireless access point logformat - * * - * All directives are explained within this file * - * - * Copyright (C) 2008 Adiscon GmbH - ********************************************************************* -*/ - -// --- Avoid directly accessing this file! -if ( !defined('IN_PHPLOGCON') ) -{ - die('Hacking attempt'); - exit; -} -// --- - -// --- 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 MsgParser_wireless extends MsgParser { - - // Public Information properties - public $_ClassName = 'Custom Wireless Logfiles'; - public $_ClassDescription = 'Custom logfile parser for wireless access points.'; - public $_ClassHelpArticle = ""; - public $_ClassRequiredFields = array ( - "net_bytesrecieved" => array ( "FieldID" => "net_bytesrecieved", "FieldDefine" => "SYSLOG_NET_BYTESRECIEVED", "FieldCaption" => "Bytes recieved", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_bytesrecieved", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_bytessend" => array (", ", "FieldID" => "net_bytessend", "FieldDefine" => "SYSLOG_NET_BYTESSEND", "FieldCaption" => "Bytes send", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_bytessend", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0 ), - "net_interface" => array (", ", "FieldID" => "net_interface", "FieldDefine" => "SYSLOG_NET_INTERFACE", "FieldCaption" => "Interface", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_interface", "DefaultWidth" => 75, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_lastactivity" => array (", ", "FieldID" => "net_lastactivity", "FieldDefine" => "SYSLOG_NET_LASTACTIVITY", "FieldCaption" => "Last Activity", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_lastactivity", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_lastip" => array (", ", "FieldID" => "net_lastip", "FieldDefine" => "SYSLOG_NET_LASTIP", "FieldCaption" => "Last IP Address", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_lastip", "DefaultWidth" => 100, "SearchOnline" => 1, "Trunscate" => 0, "Sortable" => 0), - "net_mac_address" => array (", ", "FieldID" => "net_mac_address", "FieldDefine" => "SYSLOG_NET_MAC_ADDRESS", "FieldCaption" => "Mac Address", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_mac_address", "DefaultWidth" => 120, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_packetsrecieved" => array (", ", "FieldID" => "net_packetsrecieved", "FieldDefine" => "SYSLOG_NET_PACKETSRECIEVED", "FieldCaption" => "Packets recieved", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_packetsrecieved", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_packetssend" => array (", ", "FieldID" => "net_packetssend", "FieldDefine" => "SYSLOG_NET_PACKETSSEND", "FieldCaption" => "Packets send", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_packetssend", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_rxrate" => array (", ", "FieldID" => "net_rxrate", "FieldDefine" => "SYSLOG_NET_RXRATE", "FieldCaption" => "RX Rate", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_rxrate", "DefaultWidth" => 65, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_signalstrength" => array (", ", "FieldID" => "net_signalstrength", "FieldDefine" => "SYSLOG_NET_SIGNALSTRENGTH", "FieldCaption" => "Signal strength", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_signalstrength", "DefaultWidth" => 110, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_signaltonoise" => array (", ", "FieldID" => "net_signaltonoise", "FieldDefine" => "SYSLOG_NET_SIGNALTONOISE", "FieldCaption" => "Signal to noise", "FieldType" => 1, "FieldAlign" => "center", "SearchField" => "net_signaltonoise", "DefaultWidth" => 85, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_uptime" => array (", ", "FieldID" => "net_uptime", "FieldDefine" => "SYSLOG_NET_UPTIME", "FieldCaption" => "System Uptime", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_uptime", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_txccq" => array (", ", "FieldID" => "net_txccq", "FieldDefine" => "SYSLOG_NET_TXCCQ", "FieldCaption" => "TX CCQ", "FieldType" => 1, "FieldAlign" => "center", "SearchField" => "net_txccq", "DefaultWidth" => 50, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), - "net_txrate" => array (", ", "FieldID" => "net_txrate", "FieldDefine" => "SYSLOG_NET_TXRATE", "FieldCaption" => "TX Rate", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_txrate", "DefaultWidth" => 75, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0) - ); - - // Constructor - public function MsgParser_wireless() { - -// TODO AUTOMATICALLY PERFORM FIELD INSERTS! - - return; // Nothing - } - - /** - * ParseLine - * - * @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them. - * @return integer Error stat - */ - public function ParseMsg($szMsg, &$arrArguments) - { - global $content, $fields; - - //trim the msg first to remove spaces from begin and end - $szMsg = trim($szMsg); -//return ERROR_MSG_NOMATCH; - - // Sample: Oct 14 21:05:52 script,info INICIO; Madrid-arturosoria ;wlan1 ;00:1F:3A:66:70:09 ;192.168.10.117 ;24Mbps ;36Mbps ;15:50:56 ;00:00:00.080 ;-80dBm@1Mbps ;21 ;78 ;43351,126437 ;2959,377 - if ( preg_match('/(...)(?:.|..)([0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}) (.*?),(.*?) (.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?)$/', $szMsg, $out) ) - { - -//print_r ( $out ); -//exit; - - // Set generic properties - $arrArguments[SYSLOG_DATE] = GetEventTime($out[1] . " " . $out[2]); - $arrArguments[SYSLOG_HOST] = $out[6]; -// $arrArguments[SYSLOG_DATE] = GetEventTime($out[4]); - - // Set wlan log specific properties! - $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[7]); - $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[8]); - $arrArguments[SYSLOG_NET_LASTIP] = trim($out[9]); - $arrArguments[SYSLOG_NET_RXRATE] = trim($out[10]); - $arrArguments[SYSLOG_NET_TXRATE] = trim($out[11]); - $arrArguments[SYSLOG_NET_UPTIME] = trim($out[12]); - $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[13]); - $arrArguments[SYSLOG_NET_SIGNALSTRENGTH] = trim($out[14]); - - // Number based fields - $arrArguments[SYSLOG_NET_SIGNALTONOISE] = $out[15]; - $arrArguments[SYSLOG_NET_TXCCQ] = $out[16]; - - // Set msg to whole logline - $arrArguments[SYSLOG_MESSAGE] = $out[0]; - - // Get additional parameters! - if ( preg_match('/(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?);(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?)$/', $out[17], $out2) ) - { - $arrArguments[SYSLOG_NET_BYTESRECIEVED] = $out2[1]; - $arrArguments[SYSLOG_NET_BYTESSEND] = $out2[2]; - $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = $out2[3]; - $arrArguments[SYSLOG_NET_PACKETSSEND] = $out2[4]; - } - else - { - $arrArguments[SYSLOG_NET_BYTESRECIEVED] = ""; - $arrArguments[SYSLOG_NET_BYTESSEND] = ""; - $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = ""; - $arrArguments[SYSLOG_NET_PACKETSSEND] = ""; - } - - if ( $this->_MsgNormalize == 1 ) - { - //Init tmp msg - $szTmpMsg = ""; - - // Create Field Array to prepend into msg! Reverse Order here - $myFields = array( SYSLOG_NET_PACKETSSEND, SYSLOG_NET_PACKETSRECIEVED, SYSLOG_NET_BYTESSEND, SYSLOG_NET_BYTESRECIEVED, SYSLOG_NET_TXCCQ, SYSLOG_NET_SIGNALTONOISE, SYSLOG_NET_UPTIME, SYSLOG_NET_SIGNALSTRENGTH, SYSLOG_NET_LASTACTIVITY, SYSLOG_NET_TXRATE, SYSLOG_NET_RXRATE, SYSLOG_NET_LASTIP, SYSLOG_NET_MAC_ADDRESS, SYSLOG_NET_INTERFACE, SYSLOG_HOST ); - - foreach ( $myFields as $myField ) - { - // Set Field Caption - if ( isset($fields[$myField]['FieldCaption']) ) - $szFieldName = $fields[$myField]['FieldCaption']; - else - $szFieldName = $myField; - - // Append Field into msg - $szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg; - } - - // copy finished MSG back! - $arrArguments[SYSLOG_MESSAGE] = $szTmpMsg; - } - } - else - { - // return no match in this case! - return ERROR_MSG_NOMATCH; - } - - // Set IUT Property if success! - $arrArguments[SYSLOG_MESSAGETYPE] = IUT_Syslog; - - // If we reached this position, return success! - return SUCCESS; - } -} - + www.phplogcon.org <- * + * ----------------------------------------------------------------- * + * Apache Logfile Parser used to split WebLog fields if + * found in the msg. + * + * This Parser is for custom wireless access point logformat + * * + * All directives are explained within this file * + * + * Copyright (C) 2008 Adiscon GmbH + ********************************************************************* +*/ + +// --- Avoid directly accessing this file! +if ( !defined('IN_PHPLOGCON') ) +{ + die('Hacking attempt'); + exit; +} +// --- + +// --- 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 MsgParser_wireless extends MsgParser { + + // Public Information properties + public $_ClassName = 'Custom Wireless Logfiles'; + public $_ClassDescription = 'Custom logfile parser for wireless access points.'; + public $_ClassHelpArticle = ""; + public $_ClassRequiredFields = array ( + "net_bytesrecieved" => array ( "FieldID" => "net_bytesrecieved", "FieldDefine" => "SYSLOG_NET_BYTESRECIEVED", "FieldCaption" => "Bytes recieved", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_bytesrecieved", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_bytessend" => array (", ", "FieldID" => "net_bytessend", "FieldDefine" => "SYSLOG_NET_BYTESSEND", "FieldCaption" => "Bytes send", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_bytessend", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0 ), + "net_interface" => array (", ", "FieldID" => "net_interface", "FieldDefine" => "SYSLOG_NET_INTERFACE", "FieldCaption" => "Interface", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_interface", "DefaultWidth" => 75, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_lastactivity" => array (", ", "FieldID" => "net_lastactivity", "FieldDefine" => "SYSLOG_NET_LASTACTIVITY", "FieldCaption" => "Last Activity", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_lastactivity", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_lastip" => array (", ", "FieldID" => "net_lastip", "FieldDefine" => "SYSLOG_NET_LASTIP", "FieldCaption" => "Last IP Address", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_lastip", "DefaultWidth" => 100, "SearchOnline" => 1, "Trunscate" => 0, "Sortable" => 0), + "net_mac_address" => array (", ", "FieldID" => "net_mac_address", "FieldDefine" => "SYSLOG_NET_MAC_ADDRESS", "FieldCaption" => "Mac Address", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_mac_address", "DefaultWidth" => 120, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_packetsrecieved" => array (", ", "FieldID" => "net_packetsrecieved", "FieldDefine" => "SYSLOG_NET_PACKETSRECIEVED", "FieldCaption" => "Packets recieved", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_packetsrecieved", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_packetssend" => array (", ", "FieldID" => "net_packetssend", "FieldDefine" => "SYSLOG_NET_PACKETSSEND", "FieldCaption" => "Packets send", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_packetssend", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_rxrate" => array (", ", "FieldID" => "net_rxrate", "FieldDefine" => "SYSLOG_NET_RXRATE", "FieldCaption" => "RX Rate", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_rxrate", "DefaultWidth" => 65, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_signalstrength" => array (", ", "FieldID" => "net_signalstrength", "FieldDefine" => "SYSLOG_NET_SIGNALSTRENGTH", "FieldCaption" => "Signal strength", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_signalstrength", "DefaultWidth" => 110, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_signaltonoise" => array (", ", "FieldID" => "net_signaltonoise", "FieldDefine" => "SYSLOG_NET_SIGNALTONOISE", "FieldCaption" => "Signal to noise", "FieldType" => 1, "FieldAlign" => "center", "SearchField" => "net_signaltonoise", "DefaultWidth" => 85, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_uptime" => array (", ", "FieldID" => "net_uptime", "FieldDefine" => "SYSLOG_NET_UPTIME", "FieldCaption" => "System Uptime", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_uptime", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_txccq" => array (", ", "FieldID" => "net_txccq", "FieldDefine" => "SYSLOG_NET_TXCCQ", "FieldCaption" => "TX CCQ", "FieldType" => 1, "FieldAlign" => "center", "SearchField" => "net_txccq", "DefaultWidth" => 50, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), + "net_txrate" => array (", ", "FieldID" => "net_txrate", "FieldDefine" => "SYSLOG_NET_TXRATE", "FieldCaption" => "TX Rate", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_txrate", "DefaultWidth" => 75, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0) + ); + + // Constructor + public function MsgParser_wireless() { + +// TODO AUTOMATICALLY PERFORM FIELD INSERTS! + + return; // Nothing + } + + /** + * ParseLine + * + * @param arrArguments array in&out: properties of interest. There can be no guarantee the logstream can actually deliver them. + * @return integer Error stat + */ + public function ParseMsg($szMsg, &$arrArguments) + { + global $content, $fields; + + //trim the msg first to remove spaces from begin and end + $szMsg = trim($szMsg); + + // Sample: Oct 14 21:05:52 script,info INICIO; Madrid-arturosoria ;wlan1 ;00:1F:3A:66:70:09 ;192.168.10.117 ;24Mbps ;36Mbps ;15:50:56 ;00:00:00.080 ;-80dBm@1Mbps ;21 ;78 ;43351,126437 ;2959,377 + if ( preg_match('/(.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?)$/', $szMsg, $out) ) + { + $arrArguments[SYSLOG_HOST] = $out[1]; + + // Set wlan log specific properties! + $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[2]); + $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[3]); + $arrArguments[SYSLOG_NET_LASTIP] = trim($out[4]); + $arrArguments[SYSLOG_NET_RXRATE] = trim($out[5]); + $arrArguments[SYSLOG_NET_TXRATE] = trim($out[6]); + $arrArguments[SYSLOG_NET_UPTIME] = trim($out[7]); + $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[8]); + $arrArguments[SYSLOG_NET_SIGNALSTRENGTH] = trim($out[9]); + + // Number based fields + $arrArguments[SYSLOG_NET_SIGNALTONOISE] = $out[10]; + $arrArguments[SYSLOG_NET_TXCCQ] = $out[11]; + + // Set msg to whole logline + $arrArguments[SYSLOG_MESSAGE] = $out[0]; + + // Get additional parameters! + if ( preg_match('/(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?);(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?)$/', $out[12], $out2) ) + { + $arrArguments[SYSLOG_NET_BYTESRECIEVED] = $out2[1]; + $arrArguments[SYSLOG_NET_BYTESSEND] = $out2[2]; + $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = $out2[3]; + $arrArguments[SYSLOG_NET_PACKETSSEND] = $out2[4]; + } + else + { + $arrArguments[SYSLOG_NET_BYTESRECIEVED] = ""; + $arrArguments[SYSLOG_NET_BYTESSEND] = ""; + $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = ""; + $arrArguments[SYSLOG_NET_PACKETSSEND] = ""; + } + + if ( $this->_MsgNormalize == 1 ) + { + //Init tmp msg + $szTmpMsg = ""; + + // Create Field Array to prepend into msg! Reverse Order here + $myFields = array( SYSLOG_NET_PACKETSSEND, SYSLOG_NET_PACKETSRECIEVED, SYSLOG_NET_BYTESSEND, SYSLOG_NET_BYTESRECIEVED, SYSLOG_NET_TXCCQ, SYSLOG_NET_SIGNALTONOISE, SYSLOG_NET_UPTIME, SYSLOG_NET_SIGNALSTRENGTH, SYSLOG_NET_LASTACTIVITY, SYSLOG_NET_TXRATE, SYSLOG_NET_RXRATE, SYSLOG_NET_LASTIP, SYSLOG_NET_MAC_ADDRESS, SYSLOG_NET_INTERFACE, SYSLOG_HOST ); + + foreach ( $myFields as $myField ) + { + // Set Field Caption + if ( isset($fields[$myField]['FieldCaption']) ) + $szFieldName = $fields[$myField]['FieldCaption']; + else + $szFieldName = $myField; + + // Append Field into msg + $szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg; + } + + // copy finished MSG back! + $arrArguments[SYSLOG_MESSAGE] = $szTmpMsg; + } + } + // Sample: Madrid-arturosoria ;wlan1 ;00:1F:3A:66:70:09 ;192.168.10.117 ;24Mbps ;36Mbps ;15:50:56 ;00:00:00.080 ;-80dBm@1Mbps ;21 ;78 ;43351,126437 ;2959,377 + else if ( preg_match('/(...)(?:.|..)([0-9]{1,2} [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}) (.*?),(.*?) (.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?)$/', $szMsg, $out) ) + { + +//print_r ( $out ); +//exit; + + // Set generic properties + $arrArguments[SYSLOG_DATE] = GetEventTime($out[1] . " " . $out[2]); + $arrArguments[SYSLOG_HOST] = $out[6]; +// $arrArguments[SYSLOG_DATE] = GetEventTime($out[4]); + + // Set wlan log specific properties! + $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[7]); + $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[8]); + $arrArguments[SYSLOG_NET_LASTIP] = trim($out[9]); + $arrArguments[SYSLOG_NET_RXRATE] = trim($out[10]); + $arrArguments[SYSLOG_NET_TXRATE] = trim($out[11]); + $arrArguments[SYSLOG_NET_UPTIME] = trim($out[12]); + $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[13]); + $arrArguments[SYSLOG_NET_SIGNALSTRENGTH] = trim($out[14]); + + // Number based fields + $arrArguments[SYSLOG_NET_SIGNALTONOISE] = $out[15]; + $arrArguments[SYSLOG_NET_TXCCQ] = $out[16]; + + // Set msg to whole logline + $arrArguments[SYSLOG_MESSAGE] = $out[0]; + + // Get additional parameters! + if ( preg_match('/(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?);(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?)$/', $out[17], $out2) ) + { + $arrArguments[SYSLOG_NET_BYTESRECIEVED] = $out2[1]; + $arrArguments[SYSLOG_NET_BYTESSEND] = $out2[2]; + $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = $out2[3]; + $arrArguments[SYSLOG_NET_PACKETSSEND] = $out2[4]; + } + else + { + $arrArguments[SYSLOG_NET_BYTESRECIEVED] = ""; + $arrArguments[SYSLOG_NET_BYTESSEND] = ""; + $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = ""; + $arrArguments[SYSLOG_NET_PACKETSSEND] = ""; + } + + if ( $this->_MsgNormalize == 1 ) + { + //Init tmp msg + $szTmpMsg = ""; + + // Create Field Array to prepend into msg! Reverse Order here + $myFields = array( SYSLOG_NET_PACKETSSEND, SYSLOG_NET_PACKETSRECIEVED, SYSLOG_NET_BYTESSEND, SYSLOG_NET_BYTESRECIEVED, SYSLOG_NET_TXCCQ, SYSLOG_NET_SIGNALTONOISE, SYSLOG_NET_UPTIME, SYSLOG_NET_SIGNALSTRENGTH, SYSLOG_NET_LASTACTIVITY, SYSLOG_NET_TXRATE, SYSLOG_NET_RXRATE, SYSLOG_NET_LASTIP, SYSLOG_NET_MAC_ADDRESS, SYSLOG_NET_INTERFACE, SYSLOG_HOST ); + + foreach ( $myFields as $myField ) + { + // Set Field Caption + if ( isset($fields[$myField]['FieldCaption']) ) + $szFieldName = $fields[$myField]['FieldCaption']; + else + $szFieldName = $myField; + + // Append Field into msg + $szTmpMsg = $szFieldName . ": '" . $arrArguments[$myField] . "'\n" . $szTmpMsg; + } + + // copy finished MSG back! + $arrArguments[SYSLOG_MESSAGE] = $szTmpMsg; + } + } + else + { + // return no match in this case! + return ERROR_MSG_NOMATCH; + } + + // Set IUT Property if success! + $arrArguments[SYSLOG_MESSAGETYPE] = IUT_Syslog; + + // If we reached this position, return success! + return SUCCESS; + } +} + ?> \ No newline at end of file diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 36f3e28..877f49c 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -892,14 +892,14 @@ function DieWithErrorMsg( $szerrmsg ) echo "phpLogCon :: Critical Error occured" . "

" . - "". + "
". "" . - "" . - "" . + "
" . "

Critical Error occured

" . "
Errordetails:" . + "
Errordetails:
" . $szerrmsg . - "
" . + "

" . ""; exit; } @@ -910,14 +910,14 @@ function DieWithFriendlyErrorMsg( $szerrmsg ) echo "phpLogCon :: Error occured" . "

" . - "". + "
". "" . - "" . - "" . + "
" . "

Error occured

" . "
Errordetails:" . + "
Errordetails:
" . $szerrmsg . - "
" . + "

" . ""; exit; } @@ -1005,6 +1005,12 @@ function RedirectPage( $newpage ) function RedirectResult( $szMsg, $newpage ) { + global $content; + + if ( defined('PHPLOGCON_INERROR') ) + DieWithErrorMsg( GetAndReplaceLangStr($content["LN_ERROR_REDIRECTABORTED"], $newpage) ); + + // Perform redirect! header("Location: result.php?msg=" . urlencode($szMsg) . "&redir=" . urlencode($newpage)); exit; } @@ -1507,6 +1513,22 @@ function list_files($directory, $failOnError = true) } } +/* +* Helper function to flush html output to avoid redirects if errors happen! +*/ +function FlushHtmlOutput() +{ + global $RUNMODE; + + // not needed in console mode + if ( $RUNMODE == RUNMODE_COMMANDLINE ) + return; + + //Flush php output + @flush(); + @ob_flush(); +} + /* * Helper function to get the errorCode */ diff --git a/src/include/functions_db.php b/src/include/functions_db.php index d70302b..26e2d03 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -216,6 +216,9 @@ function DB_PrintError($MyErrorMsg, $DieOrNot) $errdesc = mysql_error(); $errno = mysql_errno(); + // Define global variable so we know an error has occured! + define('PHPLOGCON_INERROR', true); + $errormsg="Database error: $MyErrorMsg $linesep"; $errormsg.="mysql error: $errdesc $linesep"; $errormsg.="mysql error number: $errno $linesep"; diff --git a/src/lang/de/main.php b/src/lang/de/main.php index de2b657..051cad3 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -97,6 +97,7 @@ $content['LN_ERROR_NORECORDS'] = "Es wurden keine syslog-Einträge gefunden. $content['LN_WARNING_LOGSTREAMDISK_TIMEOUT'] = "While reading the logstream, the php script timeout forced me to abort at this point.

If you want to avoid this, please increase the phpLogCon script timeout in your config.php. If the user system is installed, you can do that in Admin center."; $content['LN_WARNING_DBUPGRADE'] = "Database Upgrade required"; $content['LN_WARNING_DBUPGRADE_TEXT'] = "The current installed database version is '%1'.
An update to version '%2' is available."; + $content['LN_ERROR_REDIRECTABORTED'] = 'Automatic redirect to the page was aborted, as an internal error occured. Please see the error details above and contact our support forums if you need assistance.'; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Suchen"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index 9157725..b1153bf 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -99,6 +99,7 @@ $content['LN_ERROR_DB_DBFIELDNOTFOUND'] = "Database Field mapping for at least o $content['LN_ERROR_FILE_NOMORETIME'] = "No more time for processing left"; $content['LN_WARNING_DBUPGRADE'] = "Database Upgrade required"; $content['LN_WARNING_DBUPGRADE_TEXT'] = "The current installed database version is '%1'.
An update to version '%2' is available."; + $content['LN_ERROR_REDIRECTABORTED'] = 'Automatic redirect to the page was aborted, as an internal error occured. Please see the error details above and contact our support forums if you need assistance.'; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Search"; diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index 6ef5ad4..ebe4583 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -101,6 +101,7 @@ $content['LN_ERROR_NORECORDS'] = "Sem mensagens encontradas."; $content['LN_WARNING_LOGSTREAMDISK_TIMEOUT'] = "While reading the logstream, the php script timeout forced me to abort at this point.

If you want to avoid this, please increase the phpLogCon script timeout in your config.php. If the user system is installed, you can do that in Admin center."; $content['LN_WARNING_DBUPGRADE'] = "Database Upgrade required"; $content['LN_WARNING_DBUPGRADE_TEXT'] = "The current installed database version is '%1'.
An update to version '%2' is available."; + $content['LN_ERROR_REDIRECTABORTED'] = 'Automatic redirect to the page was aborted, as an internal error occured. Please see the error details above and contact our support forums if you need assistance.'; // Topmenu Entries $content['LN_MENU_SEARCH'] = "Search"; From f8d2306fa76f3438f6dd9034082f454513c8d739 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 24 Oct 2008 15:22:14 +0200 Subject: [PATCH 2/9] Fixed minor annoyance when magic_quotes_gpc was enabled in the result messages within the admin center --- src/admin/result.php | 2 +- src/include/functions_db.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/admin/result.php b/src/admin/result.php index adf271f..10977e7 100644 --- a/src/admin/result.php +++ b/src/admin/result.php @@ -71,7 +71,7 @@ else } if ( isset($_GET['msg']) ) - $content['SZMSG'] = urldecode($_GET['msg']); + $content['SZMSG'] = DB_StripSlahes($_GET['msg']); else $content['SZMSG'] = $content["LN_ADMIN_UNKNOWNSTATE"]; diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 26e2d03..2629e98 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -266,7 +266,7 @@ function DB_RemoveBadChars($myString, $dbEngine = DB_MYSQL) function DB_StripSlahes($myString) { // Replace with internal PHP Functions! - if ( !get_magic_quotes_gpc() ) + if ( get_magic_quotes_gpc() ) return stripslashes($myString); else return $myString; From 2368febba91979758e5fd4b7f714229826bbd8ef Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 24 Oct 2008 16:02:40 +0200 Subject: [PATCH 3/9] Fixed lots of minor issues handling form input (backslahes getting added and so on). --- src/admin/charts.php | 4 +- src/admin/fields.php | 4 +- src/admin/groups.php | 4 +- src/admin/searches.php | 4 +- src/admin/sources.php | 4 +- src/admin/users.php | 4 +- src/admin/views.php | 15 +++++-- src/convert.php | 2 +- src/include/functions_common.php | 56 ++++++++++++------------ src/include/functions_db.php | 21 ++++----- src/include/functions_installhelpers.php | 2 +- src/templates/admin/admin_searches.html | 2 +- 12 files changed, 64 insertions(+), 58 deletions(-) diff --git a/src/admin/charts.php b/src/admin/charts.php index 91415bf..f43ff69 100644 --- a/src/admin/charts.php +++ b/src/admin/charts.php @@ -280,7 +280,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_HASBEENADDED'], $content['Name'] ) , "charts.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_HASBEENADDED'], DB_StripSlahes($content['Name']) ) , "charts.php" ); } else if ( $_POST['op'] == "editchart" ) { @@ -309,7 +309,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_HASBEENEDIT'], $content['Name']) , "charts.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_CHARTS_HASBEENEDIT'], DB_StripSlahes($content['Name']) ) , "charts.php" ); } } } diff --git a/src/admin/fields.php b/src/admin/fields.php index db91fc3..23f1ffe 100644 --- a/src/admin/fields.php +++ b/src/admin/fields.php @@ -249,7 +249,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_FIELDS_HASBEENADDED'], $content['FieldCaption'] ) , "fields.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_FIELDS_HASBEENADDED'], DB_StripSlahes($content['FieldCaption']) ) , "fields.php" ); } else { @@ -267,7 +267,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_FIELDS_HASBEENEDIT'], $content['FieldCaption']) , "fields.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_FIELDS_HASBEENEDIT'], DB_StripSlahes($content['FieldCaption']) ) , "fields.php" ); } } } diff --git a/src/admin/groups.php b/src/admin/groups.php index 18c45e5..7623d30 100644 --- a/src/admin/groups.php +++ b/src/admin/groups.php @@ -322,7 +322,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_HASBEENADDED'], $content['groupname'] ) , "groups.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_HASBEENADDED'], DB_StripSlahes($content['groupname']) ) , "groups.php" ); } } else if ( $_POST['op'] == "editgroup" ) @@ -344,7 +344,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENEDIT'], $content['groupname']) , "groups.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_GROUP_ERROR_HASBEENEDIT'], DB_StripSlahes($content['groupname']) ) , "groups.php" ); } } else if ( $_POST['op'] == "adduser" ) diff --git a/src/admin/searches.php b/src/admin/searches.php index 90fdd54..f8bd39d 100644 --- a/src/admin/searches.php +++ b/src/admin/searches.php @@ -235,7 +235,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], $content['DisplayName'] ) , "searches.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], DB_StripSlahes($content['DisplayName']) ) , "searches.php" ); } else if ( $_POST['op'] == "editsearch" ) { @@ -258,7 +258,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], $content['DisplayName']) , "searches.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], DB_StripSlahes($content['DisplayName']) ) , "searches.php" ); } } } diff --git a/src/admin/sources.php b/src/admin/sources.php index 335da6c..490562d 100644 --- a/src/admin/sources.php +++ b/src/admin/sources.php @@ -512,7 +512,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCE_HASBEENADDED'], $content['Name'] ) , "sources.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCE_HASBEENADDED'], DB_StripSlahes($content['Name']) ) , "sources.php" ); } else if ( $_POST['op'] == "editsource" ) { @@ -567,7 +567,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_HASBEENEDIT'], $content['Name']) , "sources.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_HASBEENEDIT'], DB_StripSlahes($content['Name']) ) , "sources.php" ); } } } diff --git a/src/admin/users.php b/src/admin/users.php index 20f91a1..09a760a 100644 --- a/src/admin/users.php +++ b/src/admin/users.php @@ -272,7 +272,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENADDED'], $content['USERNAME'] ) , "users.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENADDED'], DB_StripSlahes($content['USERNAME']) ) , "users.php" ); } } } @@ -322,7 +322,7 @@ if ( isset($_POST['op']) ) } // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENEDIT'], $content['USERNAME']) , "users.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_USER_ERROR_HASBEENEDIT'], DB_StripSlahes($content['USERNAME']) ) , "users.php" ); } } } diff --git a/src/admin/views.php b/src/admin/views.php index 2f1cffd..243e8f5 100644 --- a/src/admin/views.php +++ b/src/admin/views.php @@ -275,7 +275,7 @@ if ( isset($content['ISEDITORNEWVIEW']) && $content['ISEDITORNEWVIEW'] ) if ( isset($_POST['op']) ) { if ( isset ($_POST['id']) ) { $content['VIEWID'] = DB_RemoveBadChars($_POST['id']); } else {$content['VIEWID'] = ""; } - if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } + if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_StripSlahes($_POST['DisplayName']); } else {$content['DisplayName'] = ""; } // User & Group handeled specially if ( isset ($_POST['isuseronly']) ) @@ -316,6 +316,9 @@ if ( isset($_POST['op']) ) // Add New entry into columnlist $content['SUBCOLUMNS'][$szColId]['ColFieldID'] = $szColId; + // Set Internal FieldID + $content['SUBCOLUMNS'][$szColId]['ColInternalID'] = $fields[$szColId]['FieldDefine']; + // Set Fieldcaption if ( isset($fields[$szColId]['FieldCaption']) ) $content['SUBCOLUMNS'][$szColId]['ColCaption'] = $fields[$szColId]['FieldCaption']; @@ -411,6 +414,9 @@ if ( isset($_POST['op']) ) } else // Now SUBOP means normal processing! { + // Now we convert fr DB insert! + $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); + // Everything was alright, so we go to the next step! if ( $_POST['op'] == "addnewview" ) { @@ -437,7 +443,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Do the final redirect - RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENADDED'], $content['DisplayName'] ) , "views.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENADDED'], DB_StripSlahes($content['DisplayName']) ) , "views.php" ); } else { @@ -447,6 +453,9 @@ if ( isset($_POST['op']) ) } else if ( $_POST['op'] == "editview" ) { + // Now we convert fr DB insert! + $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); + $result = DB_Query("SELECT ID FROM " . DB_VIEWS . " WHERE ID = " . $content['VIEWID']); $myrow = DB_GetSingleRow($result, true); if ( !isset($myrow['ID']) ) @@ -480,7 +489,7 @@ if ( isset($_POST['op']) ) DB_FreeQuery($result); // Done redirect! - RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENEDIT'], $content['DisplayName']) , "views.php" ); + RedirectResult( GetAndReplaceLangStr( $content['LN_VIEWS_HASBEENEDIT'], DB_StripSlahes($content['DisplayName']) ) , "views.php" ); } else { diff --git a/src/convert.php b/src/convert.php index 4f77e15..c20e989 100644 --- a/src/convert.php +++ b/src/convert.php @@ -211,7 +211,7 @@ else if ( $content['CONVERT_STEP'] == 4 ) if ( isset($_GET['errormsg']) ) { $content['iserror'] = "true"; - $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); + $content['errormsg'] = DB_StripSlahes( urldecode($_GET['errormsg']) ); } } else if ( $content['CONVERT_STEP'] == 5 ) diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 877f49c..6aa7942 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -1347,44 +1347,44 @@ function PrintSecureUserCheck( $warningtext, $yesmsg, $nomsg ) exit; } -function SaveGeneralSettingsIntoDB() +function SaveGeneralSettingsIntoDB($bForceStripSlahes = false) { - WriteConfigValue( "ViewDefaultLanguage", true ); - WriteConfigValue( "ViewDefaultTheme", true ); + WriteConfigValue( "ViewDefaultLanguage", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "ViewDefaultTheme", true, null, null,$bForceStripSlahes ); - WriteConfigValue( "ViewUseTodayYesterday", true ); - WriteConfigValue( "ViewEnableDetailPopups", true ); - WriteConfigValue( "EnableIPAddressResolve", true ); - WriteConfigValue( "MiscShowDebugMsg", true ); - WriteConfigValue( "MiscShowDebugGridCounter", true ); - WriteConfigValue( "MiscShowPageRenderStats", true ); - WriteConfigValue( "MiscEnableGzipCompression", true ); - WriteConfigValue( "SuppressDuplicatedMessages", true ); - WriteConfigValue( "TreatNotFoundFiltersAsTrue", true ); + WriteConfigValue( "ViewUseTodayYesterday", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "ViewEnableDetailPopups", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "EnableIPAddressResolve", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "MiscShowDebugMsg", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "MiscShowDebugGridCounter", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "MiscShowPageRenderStats", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "MiscEnableGzipCompression", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "SuppressDuplicatedMessages", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "TreatNotFoundFiltersAsTrue", true, null, null,$bForceStripSlahes ); - WriteConfigValue( "ViewMessageCharacterLimit", true ); - WriteConfigValue( "ViewStringCharacterLimit", true ); - WriteConfigValue( "ViewEntriesPerPage", true ); - WriteConfigValue( "ViewEnableAutoReloadSeconds", true ); - WriteConfigValue( "PopupMenuTimeout", true ); + WriteConfigValue( "ViewMessageCharacterLimit", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "ViewStringCharacterLimit", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "ViewEntriesPerPage", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "ViewEnableAutoReloadSeconds", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "PopupMenuTimeout", true, null, null,$bForceStripSlahes ); - WriteConfigValue( "PrependTitle", true ); - WriteConfigValue( "SearchCustomButtonCaption", true ); - WriteConfigValue( "SearchCustomButtonSearch", true ); + WriteConfigValue( "PrependTitle", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "SearchCustomButtonCaption", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "SearchCustomButtonSearch", true, null, null,$bForceStripSlahes ); // Extra Fields - WriteConfigValue( "DefaultViewsID", true ); - WriteConfigValue( "DefaultSourceID", true ); + WriteConfigValue( "DefaultViewsID", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "DefaultSourceID", true, null, null,$bForceStripSlahes ); // GLOBAL ONLY - WriteConfigValue( "DebugUserLogin", true ); - WriteConfigValue( "MiscDebugToSyslog", true ); - WriteConfigValue( "MiscMaxExecutionTime", true ); + WriteConfigValue( "DebugUserLogin", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "MiscDebugToSyslog", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "MiscMaxExecutionTime", true, null, null,$bForceStripSlahes ); // Custom HTML Code - WriteConfigValue( "InjectHtmlHeader", true ); - WriteConfigValue( "InjectBodyHeader", true ); - WriteConfigValue( "InjectBodyFooter", true ); + WriteConfigValue( "InjectHtmlHeader", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "InjectBodyHeader", true, null, null,$bForceStripSlahes ); + WriteConfigValue( "InjectBodyFooter", true, null, null ,$bForceStripSlahes ); } function SaveUserGeneralSettingsIntoDB() diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 2629e98..49db4a0 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -239,17 +239,18 @@ function DB_RemoveParserSpecialBadChars($myString) return $returnstr; } -function DB_RemoveBadChars($myString, $dbEngine = DB_MYSQL) +function DB_RemoveBadChars($myString, $dbEngine = DB_MYSQL, $bForceStripSlahes = false) { if ( $dbEngine == DB_MSSQL ) { +//TODO STRIP SLASHES ?! // MSSQL needs special treatment -.- return str_replace("'","''",$myString); } else { // Replace with internal PHP Functions! - if ( !get_magic_quotes_gpc() ) + if ( !get_magic_quotes_gpc() || $bForceStripSlahes ) return addslashes($myString); // return addcslashes($myString, "'"); else @@ -322,17 +323,13 @@ function DB_Exec($query) return false; } -function PrepareValueForDB($szValue) +function PrepareValueForDB($szValue, $bForceStripSlahes = false) { -//echo "
" . $szValue . "
!" . preg_match("/[^\\\\]['\\\\][^'\\\\]/e", $szValue, $matches) . "
"; - // Copy value for DB and check for BadDB Chars! -// if ( preg_match("/(? - {LN_GEN_USERONLY} + {LN_SEARCH_QUERY} From 2d089f1c94a81fec515dff7a1708544bdee181cd Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 24 Oct 2008 17:35:57 +0200 Subject: [PATCH 4/9] Fixed a bug in the convert.php script which inserted the wrong database version number This caused phpLogCon to force an database upgrade which is not needed at all. --- src/convert.php | 2 +- src/install.php | 6 +++--- src/templates/convert.html | 2 +- src/templates/install.html | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/convert.php b/src/convert.php index c20e989..cc35057 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'] . "', " . $content['database_internalversion'] . ")"; + $mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)"; // --- Now execute all commands ini_set('error_reporting', E_WARNING); // Enable Warnings! diff --git a/src/install.php b/src/install.php index d307665..e99e6c3 100644 --- a/src/install.php +++ b/src/install.php @@ -260,7 +260,7 @@ else if ( $content['INSTALL_STEP'] == 3 ) if ( isset($_GET['errormsg']) ) { $content['iserror'] = "true"; - $content['errormsg'] = urldecode($_GET['errormsg']); + $content['errormsg'] = urldecode( DB_StripSlahes($_GET['errormsg']) ); } } else if ( $content['INSTALL_STEP'] == 4 ) @@ -461,7 +461,7 @@ else if ( $content['INSTALL_STEP'] == 6 ) if ( isset($_GET['errormsg']) ) { $content['iserror'] = "true"; - $content['errormsg'] = urldecode($_GET['errormsg']); + $content['errormsg'] = urldecode( DB_StripSlahes($_GET['errormsg']) ); } } else // NO Database means NO user management, so next step! @@ -553,7 +553,7 @@ else if ( $content['INSTALL_STEP'] == 7 ) if ( isset($_GET['errormsg']) ) { $content['iserror'] = "true"; - $content['errormsg'] = urldecode($_GET['errormsg']); + $content['errormsg'] = urldecode( DB_StripSlahes($_GET['errormsg']) ); } } else if ( $content['INSTALL_STEP'] == 8 ) diff --git a/src/templates/convert.html b/src/templates/convert.html index d4030a2..3912540 100644 --- a/src/templates/convert.html +++ b/src/templates/convert.html @@ -27,7 +27,7 @@
-

{LN_CONVERT_TITLETOP}

+

{LN_CONVERT_TITLETOP}

diff --git a/src/templates/install.html b/src/templates/install.html index db4cf5b..50faee6 100644 --- a/src/templates/install.html +++ b/src/templates/install.html @@ -56,7 +56,7 @@
-

{INSTALL_TITLETOP}

+

{INSTALL_TITLETOP}

From 5faad8d2fdd4967b616839fa1fb402b2d9a0b6cd Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Fri, 24 Oct 2008 17:39:06 +0200 Subject: [PATCH 5/9] Added dummy db update scripts, so the db upgrade script won't fail in future. This is for the case when the db version is not correctly or missing in the user database. --- src/include/db_update_v0.txt | 5 +++++ src/include/db_update_v1.txt | 5 +++++ src/include/db_update_v7.txt | 5 +++++ 3 files changed, 15 insertions(+) create mode 100644 src/include/db_update_v0.txt create mode 100644 src/include/db_update_v1.txt create mode 100644 src/include/db_update_v7.txt diff --git a/src/include/db_update_v0.txt b/src/include/db_update_v0.txt new file mode 100644 index 0000000..9feb4b4 --- /dev/null +++ b/src/include/db_update_v0.txt @@ -0,0 +1,5 @@ +-- New Database Structure Updates + +-- Insert data + +-- Updated Data diff --git a/src/include/db_update_v1.txt b/src/include/db_update_v1.txt new file mode 100644 index 0000000..9feb4b4 --- /dev/null +++ b/src/include/db_update_v1.txt @@ -0,0 +1,5 @@ +-- New Database Structure Updates + +-- Insert data + +-- Updated Data diff --git a/src/include/db_update_v7.txt b/src/include/db_update_v7.txt new file mode 100644 index 0000000..9feb4b4 --- /dev/null +++ b/src/include/db_update_v7.txt @@ -0,0 +1,5 @@ +-- New Database Structure Updates + +-- Insert data + +-- Updated Data From c4a8889a095ff98804d38128b3197bf08920a5d4 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 27 Oct 2008 14:42:21 +0100 Subject: [PATCH 6/9] Added support to filter for dynamic fields within the logstream database sources. This was not possible yet. The filtering also has a secure end timer, which avoids that the timelimit hits the script. --- src/classes/logstream.class.php | 216 +++++++++++++++++- src/classes/logstreamdb.class.php | 102 +++++---- src/classes/logstreamdisk.class.php | 212 +---------------- src/classes/logstreampdo.class.php | 106 +++++---- .../msgparsers/msgparser.wireless.class.php | 66 +++--- 5 files changed, 371 insertions(+), 331 deletions(-) diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php index e7efde4..e08773e 100644 --- a/src/classes/logstream.class.php +++ b/src/classes/logstream.class.php @@ -258,6 +258,219 @@ abstract class LogStream { $this->_sortOrder = $newSortOrder; return SUCCESS; } + + /** + * Implementation of ApplyFilters which can be used by all LogStream Classes! + * This function performs a check on the filters and actually triggers the + * syslog parsers as well. + */ + public function ApplyFilters($myResults, &$arrProperitesOut) + { + // IF result was unsuccessfull, return success - nothing we can do here. + if ( $myResults >= ERROR ) + return SUCCESS; + + // Process all filters + 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: + // Only filter if value is non zero + if ( strlen($propertyvalue) > 0 && strlen($myfilter[FILTER_VALUE]) > 0 ) + { + // 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 + { + // Include Filter + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE ) + { + + // Set isOrFilter to true in this case + $bIsOrFilter = true; + + if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) + { + if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) ) + $bOrFilter = true; + } + else + { + if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false ) + $bOrFilter = true; + } + } + // Exclude Filter - handeled with AND filtering! + else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE ) + { + if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) + { +// if ( strtolower($propertyvalue) != strtolower($myfilter[FILTER_VALUE]) ) + if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) ) + $bEval = false; + } + else + { +// if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false ) + if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false ) + $bEval = false; + } + } + break; + } + } + else + { + // Either filter value or property value was empty! + // This means we have no match + $bEval = false; + } + + break; + case FILTER_TYPE_NUMBER: + $bIsOrFilter = true; // Default is set to TRUE + if ( is_numeric($arrProperitesOut[$propertyname]) ) + { + if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE ) + { + if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] ) + $bOrFilter = true; + else + $bOrFilter = false; + } + else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE ) + { + if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] ) + $bOrFilter = false; + else + $bOrFilter = true; + } + } + else + { + // If wanted, we treat this filter as a success! + if ( GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 1 ) + $bOrFilter = true; + else + $bOrFilter = false; + } + 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, reset 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; + } + + /* + * --- PIRVATE HELPERS! + */ /** * Helper function to parse filters into a useful filter array we can work with. @@ -815,7 +1028,8 @@ abstract class LogStream { // reached here means we failed to convert the facility! return -1; } + + } - ?> \ No newline at end of file diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index a72a411..3f11031 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -210,67 +210,85 @@ class LogStreamDB extends LogStream { public function ReadNext(&$uID, &$arrProperitesOut, $bParseMessage = true) { // Helpers needed for DB Mapping + global $content, $gl_starttime; 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); - else + do { - 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 + // No buffer? then read from DB! + if ( $this->bufferedRecords == null ) $ret = $this->ReadNextRecordsFromDB($uID); - - if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) - $ret = ERROR_NOMORERECORDS; - } - } - - if ( $ret == SUCCESS ) - { - // Init and set variables - foreach ( $this->_arrProperties as $property ) + else { - // Check if mapping exists - if ( isset($dbmapping[$szTableType][$property]) ) + if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) { - // Copy property if available! - $dbfieldname = $dbmapping[$szTableType][$property]; - if ( isset($this->bufferedRecords[$this->_currentRecordNum][$dbfieldname]) ) + // 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); + + if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) + $ret = ERROR_NOMORERECORDS; + } + } + if ( $ret == SUCCESS ) + { + // Init and set variables + foreach ( $this->_arrProperties as $property ) + { + // Check if mapping exists + if ( isset($dbmapping[$szTableType][$property]) ) { - if ( isset($fields[$property]['FieldType']) && $fields[$property]['FieldType'] == FILTER_TYPE_DATE ) // Handle as date! - $arrProperitesOut[$property] = GetEventTime( $this->bufferedRecords[$this->_currentRecordNum][$dbfieldname] ); + // 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] = $this->bufferedRecords[$this->_currentRecordNum][$dbfieldname]; + $arrProperitesOut[$property] = ''; } else $arrProperitesOut[$property] = ''; } - else - $arrProperitesOut[$property] = ''; + + // Run optional Message Parsers now + if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) ) + $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + + // Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum; + $uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]]; + + // Increment $_currentRecordNum + $this->_currentRecordNum++; } - // Run optional Message Parsers now - if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) ) - $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + // Check how long we are running. If only two seconds of execution time are left, we abort further reading! + $scriptruntime = intval(microtime_float() - $gl_starttime); + if ( $scriptruntime > ($content['MaxExecutionTime']-2) ) + { + // This may display a warning message, so the user knows we stopped reading records because of the script timeout. + $content['logstream_warning'] = "false"; + $content['logstream_warning_details'] = $content['LN_WARNING_LOGSTREAMDISK_TIMEOUT']; + $content['logstream_warning_code'] = ERROR_FILE_NOMORETIME; + + // Return error code + return ERROR_FILE_NOMORETIME; + } - // Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum; - $uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]]; - - // Increment $_currentRecordNum - $this->_currentRecordNum++; - } + // This additional filter check will take care on dynamic fields from the message parser! + } while ( $this->ApplyFilters($ret, $arrProperitesOut) != SUCCESS && $ret == SUCCESS ); // reached here means return result! return $ret; diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index b46fe83..d773769 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -699,215 +699,5 @@ class LogStreamDisk extends LogStream { $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; - - // Process all filters - 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: - // Only filter if value is non zero - if ( strlen($propertyvalue) > 0 && strlen($myfilter[FILTER_VALUE]) > 0 ) - { - // 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 - { - // Include Filter - if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE ) - { - - // Set isOrFilter to true in this case - $bIsOrFilter = true; - - if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) - { - if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) ) - $bOrFilter = true; - } - else - { - if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false ) - $bOrFilter = true; - } - } - // Exclude Filter - handeled with AND filtering! - else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE ) - { - if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL ) - { -// if ( strtolower($propertyvalue) != strtolower($myfilter[FILTER_VALUE]) ) - if ( strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE]) ) - $bEval = false; - } - else - { -// if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false ) - if ( stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false ) - $bEval = false; - } - } - break; - } - } - else - { - // Either filter value or property value was empty! - // This means we have no match - $bEval = false; - } - - break; - case FILTER_TYPE_NUMBER: - $bIsOrFilter = true; // Default is set to TRUE - if ( is_numeric($arrProperitesOut[$propertyname]) ) - { - if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE ) - { - if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] ) - $bOrFilter = true; - else - $bOrFilter = false; - } - else if ( $myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE ) - { - if ( $myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname] ) - $bOrFilter = false; - else - $bOrFilter = true; - } - } - else - { - // If wanted, we treat this filter as a success! - if ( GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 1 ) - $bOrFilter = true; - else - $bOrFilter = false; - } - 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, reset 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; - } - } - -?> +?> \ No newline at end of file diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php index e017340..b9d198a 100644 --- a/src/classes/logstreampdo.class.php +++ b/src/classes/logstreampdo.class.php @@ -240,69 +240,87 @@ class LogStreamPDO extends LogStream { public function ReadNext(&$uID, &$arrProperitesOut, $bParseMessage = true) { // Helpers needed for DB Mapping + global $content, $gl_starttime; 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); - else + do { - 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 + // No buffer? then read from DB! + if ( $this->bufferedRecords == null ) $ret = $this->ReadNextRecordsFromDB($uID); -//echo "!" . $ret . " " . $this->_currentRecordStart . "=" . $this->_currentRecordNum; - - // Check if we found more records - if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) - $ret = ERROR_NOMORERECORDS; - } - } - - if ( $ret == SUCCESS ) - { - // Init and set variables - foreach ( $this->_arrProperties as $property ) + else { - // Check if mapping exists - if ( isset($dbmapping[$szTableType][$property]) ) + if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) { - // Copy property if available! - $dbfieldname = $dbmapping[$szTableType][$property]; - if ( isset($this->bufferedRecords[$this->_currentRecordNum][$dbfieldname]) ) + // 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); + + // Check if we found more records + if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) + $ret = ERROR_NOMORERECORDS; + } + } + + if ( $ret == SUCCESS ) + { + // Init and set variables + foreach ( $this->_arrProperties as $property ) + { + // Check if mapping exists + if ( isset($dbmapping[$szTableType][$property]) ) { - if ( isset($fields[$property]['FieldType']) && $fields[$property]['FieldType'] == FILTER_TYPE_DATE ) // Handle as date! - $arrProperitesOut[$property] = GetEventTime( $this->bufferedRecords[$this->_currentRecordNum][$dbfieldname] ); + // 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] = $this->bufferedRecords[$this->_currentRecordNum][$dbfieldname]; + $arrProperitesOut[$property] = ''; } else $arrProperitesOut[$property] = ''; } - else - $arrProperitesOut[$property] = ''; + + // Run optional Message Parsers now + if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) ) + $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + + // Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum; + $uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]]; + + // Increment $_currentRecordNum + $this->_currentRecordNum++; } - // Run optional Message Parsers now - if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) ) - $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + // Check how long we are running. If only two seconds of execution time are left, we abort further reading! + $scriptruntime = intval(microtime_float() - $gl_starttime); + if ( $scriptruntime > ($content['MaxExecutionTime']-2) ) + { + // This may display a warning message, so the user knows we stopped reading records because of the script timeout. + $content['logstream_warning'] = "false"; + $content['logstream_warning_details'] = $content['LN_WARNING_LOGSTREAMDISK_TIMEOUT']; + $content['logstream_warning_code'] = ERROR_FILE_NOMORETIME; + + // Return error code + return ERROR_FILE_NOMORETIME; + } - // Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum; - $uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]]; - - // Increment $_currentRecordNum - $this->_currentRecordNum++; - } + // This additional filter check will take care on dynamic fields from the message parser! + } while ( $this->ApplyFilters($ret, $arrProperitesOut) != SUCCESS && $ret == SUCCESS ); // reached here means return result! return $ret; diff --git a/src/classes/msgparsers/msgparser.wireless.class.php b/src/classes/msgparsers/msgparser.wireless.class.php index c784002..c5a1da5 100644 --- a/src/classes/msgparsers/msgparser.wireless.class.php +++ b/src/classes/msgparsers/msgparser.wireless.class.php @@ -36,6 +36,7 @@ class MsgParser_wireless extends MsgParser { public $_ClassDescription = 'Custom logfile parser for wireless access points.'; public $_ClassHelpArticle = ""; public $_ClassRequiredFields = array ( + "net_host" => array (", ", "FieldID" => "net_host", "FieldDefine" => "SYSLOG_NET_HOST", "FieldCaption" => "Hostname", "FieldType" => 0, "FieldAlign" => "left", "SearchField" => "net_host", "DefaultWidth" => 100, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), "net_bytesrecieved" => array ( "FieldID" => "net_bytesrecieved", "FieldDefine" => "SYSLOG_NET_BYTESRECIEVED", "FieldCaption" => "Bytes recieved", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_bytesrecieved", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), "net_bytessend" => array (", ", "FieldID" => "net_bytessend", "FieldDefine" => "SYSLOG_NET_BYTESSEND", "FieldCaption" => "Bytes send", "FieldType" => 1, "FieldAlign" => "left", "SearchField" => "net_bytessend", "DefaultWidth" => 80, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0 ), "net_interface" => array (", ", "FieldID" => "net_interface", "FieldDefine" => "SYSLOG_NET_INTERFACE", "FieldCaption" => "Interface", "FieldType" => 0, "FieldAlign" => "center", "SearchField" => "net_interface", "DefaultWidth" => 75, "SearchOnline" => 0, "Trunscate" => 0, "Sortable" => 0), @@ -76,32 +77,32 @@ class MsgParser_wireless extends MsgParser { // Sample: Oct 14 21:05:52 script,info INICIO; Madrid-arturosoria ;wlan1 ;00:1F:3A:66:70:09 ;192.168.10.117 ;24Mbps ;36Mbps ;15:50:56 ;00:00:00.080 ;-80dBm@1Mbps ;21 ;78 ;43351,126437 ;2959,377 if ( preg_match('/(.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?);(.|.*?)$/', $szMsg, $out) ) { - $arrArguments[SYSLOG_HOST] = $out[1]; + $arrArguments[SYSLOG_NET_HOST] = trim($out[1]); // Set wlan log specific properties! - $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[2]); - $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[3]); - $arrArguments[SYSLOG_NET_LASTIP] = trim($out[4]); - $arrArguments[SYSLOG_NET_RXRATE] = trim($out[5]); - $arrArguments[SYSLOG_NET_TXRATE] = trim($out[6]); - $arrArguments[SYSLOG_NET_UPTIME] = trim($out[7]); - $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[8]); - $arrArguments[SYSLOG_NET_SIGNALSTRENGTH] = trim($out[9]); + $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[2]); + $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[3]); + $arrArguments[SYSLOG_NET_LASTIP] = trim($out[4]); + $arrArguments[SYSLOG_NET_RXRATE] = trim($out[5]); + $arrArguments[SYSLOG_NET_TXRATE] = trim($out[6]); + $arrArguments[SYSLOG_NET_UPTIME] = trim($out[7]); + $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[8]); + $arrArguments[SYSLOG_NET_SIGNALSTRENGTH]= trim($out[9]); // Number based fields - $arrArguments[SYSLOG_NET_SIGNALTONOISE] = $out[10]; - $arrArguments[SYSLOG_NET_TXCCQ] = $out[11]; + $arrArguments[SYSLOG_NET_SIGNALTONOISE] = trim($out[10]); + $arrArguments[SYSLOG_NET_TXCCQ] = trim($out[11]); // Set msg to whole logline - $arrArguments[SYSLOG_MESSAGE] = $out[0]; + $arrArguments[SYSLOG_MESSAGE] = trim($out[0]); // Get additional parameters! if ( preg_match('/(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?);(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?)$/', $out[12], $out2) ) { - $arrArguments[SYSLOG_NET_BYTESRECIEVED] = $out2[1]; - $arrArguments[SYSLOG_NET_BYTESSEND] = $out2[2]; - $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = $out2[3]; - $arrArguments[SYSLOG_NET_PACKETSSEND] = $out2[4]; + $arrArguments[SYSLOG_NET_BYTESRECIEVED] = trim($out2[1]); + $arrArguments[SYSLOG_NET_BYTESSEND] = trim($out2[2]); + $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = trim($out2[3]); + $arrArguments[SYSLOG_NET_PACKETSSEND] = trim($out2[4]); } else { @@ -144,33 +145,32 @@ class MsgParser_wireless extends MsgParser { // Set generic properties $arrArguments[SYSLOG_DATE] = GetEventTime($out[1] . " " . $out[2]); - $arrArguments[SYSLOG_HOST] = $out[6]; -// $arrArguments[SYSLOG_DATE] = GetEventTime($out[4]); + $arrArguments[SYSLOG_NET_HOST] = trim($out[6]); // Set wlan log specific properties! - $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[7]); - $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[8]); - $arrArguments[SYSLOG_NET_LASTIP] = trim($out[9]); - $arrArguments[SYSLOG_NET_RXRATE] = trim($out[10]); - $arrArguments[SYSLOG_NET_TXRATE] = trim($out[11]); - $arrArguments[SYSLOG_NET_UPTIME] = trim($out[12]); - $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[13]); - $arrArguments[SYSLOG_NET_SIGNALSTRENGTH] = trim($out[14]); + $arrArguments[SYSLOG_NET_INTERFACE] = trim($out[7]); + $arrArguments[SYSLOG_NET_MAC_ADDRESS] = trim($out[8]); + $arrArguments[SYSLOG_NET_LASTIP] = trim($out[9]); + $arrArguments[SYSLOG_NET_RXRATE] = trim($out[10]); + $arrArguments[SYSLOG_NET_TXRATE] = trim($out[11]); + $arrArguments[SYSLOG_NET_UPTIME] = trim($out[12]); + $arrArguments[SYSLOG_NET_LASTACTIVITY] = trim($out[13]); + $arrArguments[SYSLOG_NET_SIGNALSTRENGTH]= trim($out[14]); // Number based fields - $arrArguments[SYSLOG_NET_SIGNALTONOISE] = $out[15]; - $arrArguments[SYSLOG_NET_TXCCQ] = $out[16]; + $arrArguments[SYSLOG_NET_SIGNALTONOISE] = trim($out[15]); + $arrArguments[SYSLOG_NET_TXCCQ] = trim($out[16]); // Set msg to whole logline - $arrArguments[SYSLOG_MESSAGE] = $out[0]; + $arrArguments[SYSLOG_MESSAGE] = trim($out[0]); // Get additional parameters! if ( preg_match('/(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?);(.|.*?[0-9]{1,12}.*?),(.|.*?[0-9]{1,12}.*?)$/', $out[17], $out2) ) { - $arrArguments[SYSLOG_NET_BYTESRECIEVED] = $out2[1]; - $arrArguments[SYSLOG_NET_BYTESSEND] = $out2[2]; - $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = $out2[3]; - $arrArguments[SYSLOG_NET_PACKETSSEND] = $out2[4]; + $arrArguments[SYSLOG_NET_BYTESRECIEVED] = trim($out2[1]); + $arrArguments[SYSLOG_NET_BYTESSEND] = trim($out2[2]); + $arrArguments[SYSLOG_NET_PACKETSRECIEVED] = trim($out2[3]); + $arrArguments[SYSLOG_NET_PACKETSSEND] = trim($out2[4]); } else { From 5a228435518e75b9709b2a01ab32a1bb367e6ce2 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 27 Oct 2008 16:18:42 +0100 Subject: [PATCH 7/9] Added support to suppress unparseable messages when using msgparsers. This enhances useability if you have mixed data sources, and want to filter out unusefull messages. --- src/admin/sources.php | 33 ++++++++++++----- src/classes/logstreamconfig.class.php | 18 +++++++++- src/classes/logstreamdb.class.php | 49 +++++++++++++++++--------- src/classes/logstreamdisk.class.php | 2 +- src/classes/logstreampdo.class.php | 8 ++++- src/include/db_update_v7.txt | 1 + src/include/functions_config.php | 7 ++++ src/include/functions_db.php | 2 +- src/index.php | 21 +++++++++-- src/lang/de/main.php | 1 + src/lang/en/main.php | 1 + src/lang/pt_BR/main.php | 1 + src/templates/admin/admin_sources.html | 4 +++ 13 files changed, 117 insertions(+), 31 deletions(-) diff --git a/src/admin/sources.php b/src/admin/sources.php index 490562d..01bdcf3 100644 --- a/src/admin/sources.php +++ b/src/admin/sources.php @@ -70,7 +70,9 @@ if ( isset($_GET['op']) ) CreateSourceTypesList($content['SourceType']); $content['MsgParserList'] = ""; $content['MsgNormalize'] = 0; + $content['MsgSkipUnparseable'] = 0; $content['CHECKED_ISNORMALIZEMSG'] = ""; + $content['CHECKED_ISSKIPUNPARSEABLE'] = ""; // Init View List! $content['SourceViewID'] = 'SYSLOG'; @@ -143,6 +145,13 @@ if ( isset($_GET['op']) ) else $content['CHECKED_ISNORMALIZEMSG'] = ""; + $content['MsgSkipUnparseable'] = $mysource['MsgSkipUnparseable']; + if ( $mysource['MsgSkipUnparseable'] == 1 ) + $content['CHECKED_ISSKIPUNPARSEABLE'] = "checked"; + else + $content['CHECKED_ISSKIPUNPARSEABLE'] = ""; + + // Init View List! $content['SourceViewID'] = $mysource['ViewID']; $content['VIEWS'] = $content['Views']; @@ -273,6 +282,7 @@ if ( isset($_POST['op']) ) if ( isset($_POST['SourceType']) ) { $content['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); } if ( isset($_POST['MsgParserList']) ) { $content['MsgParserList'] = DB_RemoveBadChars($_POST['MsgParserList']); } if ( isset($_POST['MsgNormalize']) ) { $content['MsgNormalize'] = intval(DB_RemoveBadChars($_POST['MsgNormalize'])); } else {$content['MsgNormalize'] = 0; } + if ( isset($_POST['MsgSkipUnparseable']) ) { $content['MsgSkipUnparseable'] = intval(DB_RemoveBadChars($_POST['MsgSkipUnparseable'])); } else {$content['MsgSkipUnparseable'] = 0; } if ( isset($_POST['SourceViewID']) ) { $content['SourceViewID'] = DB_RemoveBadChars($_POST['SourceViewID']); } if ( isset($content['SourceType']) ) @@ -420,13 +430,14 @@ if ( isset($_POST['op']) ) include($gl_root_path . 'classes/logstream.class.php'); // First create a tmp source array - $tmpSource['ID'] = $content['SOURCEID']; - $tmpSource['Name'] = $content['Name']; - $tmpSource['Description'] = $content['Description']; - $tmpSource['SourceType'] = $content['SourceType']; - $tmpSource['MsgParserList'] = $content['MsgParserList']; - $tmpSource['MsgNormalize'] = $content['MsgNormalize']; - $tmpSource['ViewID'] = $content['SourceViewID']; + $tmpSource['ID'] = $content['SOURCEID']; + $tmpSource['Name'] = $content['Name']; + $tmpSource['Description'] = $content['Description']; + $tmpSource['SourceType'] = $content['SourceType']; + $tmpSource['MsgParserList'] = $content['MsgParserList']; + $tmpSource['MsgNormalize'] = $content['MsgNormalize']; + $tmpSource['MsgSkipUnparseable']= $content['MsgSkipUnparseable']; + $tmpSource['ViewID'] = $content['SourceViewID']; if ( $tmpSource['SourceType'] == SOURCE_DISK ) { $tmpSource['LogLineType'] = $content['SourceLogLineType']; @@ -473,12 +484,13 @@ if ( isset($_POST['op']) ) // Add custom search now! if ( $content['SourceType'] == SOURCE_DISK ) { - $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile, userid, groupid) + $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, MsgSkipUnparseable, ViewID, LogLineType, DiskFile, userid, groupid) VALUES ('" . $content['Name'] . "', '" . $content['Description'] . "', " . $content['SourceType'] . ", '" . $content['MsgParserList'] . "', " . $content['MsgNormalize'] . ", + " . $content['MsgSkipUnparseable'] . ", '" . $content['SourceViewID'] . "', '" . $content['SourceLogLineType'] . "', '" . $content['SourceDiskFile'] . "', @@ -488,12 +500,13 @@ if ( isset($_POST['op']) ) } else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) { - $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid) + $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, MsgSkipUnparseable, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid) VALUES ('" . $content['Name'] . "', '" . $content['Description'] . "', " . $content['SourceType'] . ", '" . $content['MsgParserList'] . "', " . $content['MsgNormalize'] . ", + " . $content['MsgSkipUnparseable'] . ", '" . $content['SourceViewID'] . "', '" . $content['SourceDBTableType'] . "', " . $content['SourceDBType'] . ", @@ -534,6 +547,7 @@ if ( isset($_POST['op']) ) SourceType = " . $content['SourceType'] . ", MsgParserList = '" . $content['MsgParserList'] . "', MsgNormalize = " . $content['MsgNormalize'] . ", + MsgSkipUnparseable = " . $content['MsgSkipUnparseable'] . ", ViewID = '" . $content['SourceViewID'] . "', LogLineType = '" . $content['SourceLogLineType'] . "', DiskFile = '" . $content['SourceDiskFile'] . "', @@ -549,6 +563,7 @@ if ( isset($_POST['op']) ) SourceType = " . $content['SourceType'] . ", MsgParserList = '" . $content['MsgParserList'] . "', MsgNormalize = " . $content['MsgNormalize'] . ", + MsgSkipUnparseable = " . $content['MsgSkipUnparseable'] . ", ViewID = '" . $content['SourceViewID'] . "', DBTableType = '" . $content['SourceDBTableType'] . "', DBType = " . $content['SourceDBType'] . ", diff --git a/src/classes/logstreamconfig.class.php b/src/classes/logstreamconfig.class.php index e8cf61c..a9a2f7d 100644 --- a/src/classes/logstreamconfig.class.php +++ b/src/classes/logstreamconfig.class.php @@ -53,7 +53,8 @@ abstract class LogStreamConfig { protected $_msgParserList = null; // Contains a string list of configure msg parsers protected $_msgParserObjList = null; // Contains an object reference list to the msg parsers protected $_MsgNormalize = 0; // If set to one, the msg will be reconstructed if successfully parsed before - + public $_SkipUnparseable = 0; // If set to one, all unparseable message will be ignored! This of course only applies if a msg parser is used + // Constructor prototype public abstract function LogStreamFactory($o); @@ -79,6 +80,17 @@ abstract class LogStreamConfig { } } + /* + * Helper function to init Parserlist + */ + public function SetSkipUnparseable( $nNewVal ) + { + if ( $nNewVal == 0 ) + $this->_SkipUnparseable = 0; + else + $this->_SkipUnparseable = 1; + } + /* * Helper function to init Parserlist */ @@ -147,6 +159,10 @@ abstract class LogStreamConfig { $ret = $myMsgParser->ParseMsg($szMsg, $arrArguments); if ( $ret == SUCCESS || $ret == ERROR_MSG_SKIPMESSAGE ) return $ret; + + // Extra check, if user wants to, we SKIP the message! + if ( $this->_SkipUnparseable == 1 && $ret == ERROR_MSG_NOMATCH ) + return ERROR_MSG_SKIPMESSAGE; } } diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index 3f11031..bb06c14 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -235,10 +235,12 @@ class LogStreamDB extends LogStream { // Now read new ones $ret = $this->ReadNextRecordsFromDB($uID); + // Check if we found more records if ( !isset($this->bufferedRecords[$this->_currentRecordNum] ) ) $ret = ERROR_NOMORERECORDS; } } + if ( $ret == SUCCESS ) { // Init and set variables @@ -265,7 +267,13 @@ class LogStreamDB extends LogStream { // Run optional Message Parsers now if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) ) - $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + { + $retParser = $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + + // Check if we have to skip the message! + if ( $retParser == ERROR_MSG_SKIPMESSAGE ) + $ret = $retParser; + } // Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum; $uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]]; @@ -340,24 +348,33 @@ class LogStreamDB extends LogStream { while( $bFound == false && $this->ReadNextIDsFromDB() == SUCCESS ) { - foreach ( $this->bufferedRecords as $myRecord ) + if ( isset($this->bufferedRecords) ) { - if ( $myRecord[$uidfieldname] == $uID ) + foreach ( $this->bufferedRecords as $myRecord ) { - $bFound = true; - $ret = SUCCESS; - break; // Break foreach loop! + if ( $myRecord[$uidfieldname] == $uID ) + { + $bFound = true; + $ret = SUCCESS; + break; // Break foreach loop! + } + else + { + $tmpuID = $myRecord[$uidfieldname]; + // Only Increment $_currentRecordNum + $this->_currentRecordNum++; + } + + // Increment our Pagenumber if needed! + if ( $this->_currentRecordNum % $this->_logStreamConfigObj->_pageCount == 0 ) + $this->_currentPageNumber++; } - else - { - $tmpuID = $myRecord[$uidfieldname]; - // Only Increment $_currentRecordNum - $this->_currentRecordNum++; - } - - // Increment our Pagenumber if needed! - if ( $this->_currentRecordNum % $this->_logStreamConfigObj->_pageCount == 0 ) - $this->_currentPageNumber++; + } + else + { + // Return error code in this case! + $this->ResetBufferedRecords(); + $ret = ERROR_NOMORERECORDS; } if ( $this->_currentPageNumber > 1 && $this->_readDirection == EnumReadDirection::Forward) diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index d773769..148c1aa 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -247,7 +247,7 @@ class LogStreamDisk extends LogStream { // Check if we have to skip the message! if ( $retParser == ERROR_MSG_SKIPMESSAGE ) $ret = $retParser; - + // Set uID to the PropertiesOut! $arrProperitesOut[SYSLOG_UID] = $uID; } diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php index b9d198a..9760317 100644 --- a/src/classes/logstreampdo.class.php +++ b/src/classes/logstreampdo.class.php @@ -297,7 +297,13 @@ class LogStreamPDO extends LogStream { // Run optional Message Parsers now if ( isset($arrProperitesOut[SYSLOG_MESSAGE]) ) - $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + { + $retParser = $this->_logStreamConfigObj->ProcessMsgParsers($arrProperitesOut[SYSLOG_MESSAGE], $arrProperitesOut); + + // Check if we have to skip the message! + if ( $retParser == ERROR_MSG_SKIPMESSAGE ) + $ret = $retParser; + } // Set uID to the PropertiesOut! //DEBUG -> $this->_currentRecordNum; $uID = $arrProperitesOut[SYSLOG_UID] = $this->bufferedRecords[$this->_currentRecordNum][$dbmapping[$szTableType][SYSLOG_UID]]; diff --git a/src/include/db_update_v7.txt b/src/include/db_update_v7.txt index 9feb4b4..5f52953 100644 --- a/src/include/db_update_v7.txt +++ b/src/include/db_update_v7.txt @@ -1,4 +1,5 @@ -- New Database Structure Updates +ALTER TABLE `logcon_sources` ADD `MsgSkipUnparseable` BOOL NOT NULL DEFAULT '0' AFTER `MsgNormalize` ; -- Insert data diff --git a/src/include/functions_config.php b/src/include/functions_config.php index 4c74d6c..1be09e1 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -80,6 +80,12 @@ function InitSource(&$mysource) $content['Sources'][$iSourceID]['MsgNormalize'] = 0; } + if ( !isset($mysource['MsgSkipUnparseable']) ) + { + $CFG['Sources'][$iSourceID]['MsgSkipUnparseable'] = 0; + $content['Sources'][$iSourceID]['MsgSkipUnparseable'] = 0; + } + if ( !isset($mysource['Description']) ) { $CFG['Sources'][$iSourceID]['Description'] = ""; @@ -185,6 +191,7 @@ function InitSource(&$mysource) $mysource['ObjRef']->_pageCount = GetConfigSetting("ViewEntriesPerPage", 50); $mysource['ObjRef']->SetMsgParserList( $mysource['MsgParserList'] ); $mysource['ObjRef']->SetMsgNormalize( $mysource['MsgNormalize'] ); + $mysource['ObjRef']->SetSkipUnparseable( $mysource['MsgSkipUnparseable'] ); // 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 49db4a0..30c8f89 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'] = "6"; // Whenever incremented, a database upgrade is needed +$content['database_internalversion'] = "7"; // Whenever incremented, a database upgrade is needed $content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database // --- diff --git a/src/index.php b/src/index.php index e3d3198..aee347d 100644 --- a/src/index.php +++ b/src/index.php @@ -267,7 +267,17 @@ if ( isset($content['Sources'][$currentSourceID]) ) } } } - else + else if ( $ret == ERROR_MSG_SKIPMESSAGE ) + { + do + { + // Skip until we find a suitable entry + $ret = $stream->ReadNext($uID, $logArray); + } while ($ret == ERROR_MSG_SKIPMESSAGE); + } + + // check for error return state! + if ( $ret != SUCCESS ) { // This will disable to Main SyslogView and show an error message $content['syslogmessagesenabled'] = "false"; @@ -625,7 +635,14 @@ if ( isset($content['Sources'][$currentSourceID]) ) // Increment Counter $counter++; - } while ($counter < $content['CurrentViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); + + // --- Extra Loop to get the next entry! + do + { + $ret = $stream->ReadNext($uID, $logArray); + } while ( $ret == ERROR_MSG_SKIPMESSAGE ); + // --- + } while ( $counter < $content['CurrentViewEntriesPerPage'] && ($ret == SUCCESS) ); //print_r ( $content['syslogmessages'] ); // Move below processing - Read First and LAST UID's before start reading the stream! diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 051cad3..574597a 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -192,6 +192,7 @@ $content['LN_CFG_FIRSTSYSLOGSOURCE'] = "Erste Syslog Quelle"; $content['LN_CFG_DBUSERLOGINREQUIRED'] = "Require user to be logged in"; $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)"; $content['LN_CFG_NORMALIZEMSG'] = "Normalize Message within Parsers"; + $content['LN_CFG_SKIPUNPARSEABLE'] = "Skip unparseable messages (Only works if msgparsers are configured!)"; // Details page $content['LN_DETAILS_FORSYSLOGMSG'] = "Details für syslog-Nachrichten mit der ID"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index b1153bf..87ac132 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -194,6 +194,7 @@ $content['LN_CFG_VIEW'] = "Select View"; $content['LN_CFG_DBUSERLOGINREQUIRED'] = "Require user to be logged in"; $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)"; $content['LN_CFG_NORMALIZEMSG'] = "Normalize Message within Parsers"; +$content['LN_CFG_SKIPUNPARSEABLE'] = "Skip unparseable messages (Only works if msgparsers are configured!)"; // Details page $content['LN_DETAILS_FORSYSLOGMSG'] = "Details for the syslog messages with id"; diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index ebe4583..ce47da1 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -196,6 +196,7 @@ $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)"; $content['LN_CFG_NORMALIZEMSG'] = "Normalize Message within Parsers"; + $content['LN_CFG_SKIPUNPARSEABLE'] = "Skip unparseable messages (Only works if msgparsers are configured!)"; // 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 852f595..145ab72 100644 --- a/src/templates/admin/admin_sources.html +++ b/src/templates/admin/admin_sources.html @@ -135,6 +135,10 @@ {LN_CFG_NORMALIZEMSG} + + {LN_CFG_SKIPUNPARSEABLE} + + {LN_GEN_USERONLY} From 4daa93225d77d9a0b85e1032e205481188a4cb8a Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 27 Oct 2008 17:14:32 +0100 Subject: [PATCH 8/9] Added new setting for MYSQL logstream sources to control the amount of data per query. This value can be used to tweak MYSQL performance for your environment. For example when filtering for fields which are generated by a message parser, highering the value does improve the database performance. Default is 100. --- src/admin/sources.php | 16 ++++++++++++++-- src/classes/logstreamdb.class.php | 2 +- src/include/db_update_v7.txt | 1 + src/include/functions_config.php | 1 + src/lang/de/admin.php | 1 + src/lang/de/main.php | 1 + src/lang/en/admin.php | 1 + src/lang/en/main.php | 1 + src/lang/pt_BR/admin.php | 1 + src/lang/pt_BR/main.php | 1 + src/templates/admin/admin_sources.html | 19 +++++++++++++++---- 11 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/admin/sources.php b/src/admin/sources.php index 01bdcf3..a31853f 100644 --- a/src/admin/sources.php +++ b/src/admin/sources.php @@ -102,6 +102,7 @@ if ( isset($_GET['op']) ) $content['SourceDBEnableRowCounting'] = "false"; $content['SourceDBEnableRowCounting_true'] = ""; $content['SourceDBEnableRowCounting_false'] = "checked"; + $content['SourceDBRecordsPerQuery'] = "100"; // General stuff $content['userid'] = null; @@ -188,6 +189,8 @@ if ( isset($_GET['op']) ) $content['SourceDBEnableRowCounting_true'] = ""; $content['SourceDBEnableRowCounting_false'] = "checked"; } + $content['SourceDBRecordsPerQuery'] = $mysource['DBRecordsPerQuery']; + if ( $mysource['userid'] != null ) $content['CHECKED_ISUSERONLY'] = "checked"; @@ -302,6 +305,7 @@ if ( isset($_POST['op']) ) if ( isset($_POST['SourceDBServer']) ) { $content['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); } if ( isset($_POST['SourceDBTableName']) ) { $content['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); } if ( isset($_POST['SourceDBUser']) ) { $content['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); } + if ( isset($_POST['SourceDBRecordsPerQuery']) ) { $content['SourceDBRecordsPerQuery'] = DB_RemoveBadChars($_POST['SourceDBRecordsPerQuery']); } if ( isset($_POST['SourceDBPassword']) ) { $content['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); } else {$content['SourceDBPassword'] = ""; } if ( isset($_POST['SourceDBEnableRowCounting']) ) { $content['SourceDBEnableRowCounting'] = DB_RemoveBadChars($_POST['SourceDBEnableRowCounting']); } // Extra Check for this property @@ -417,6 +421,11 @@ if ( isset($_POST['op']) ) $content['ISERROR'] = true; $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBUSER'] ); } + else if ( !is_numeric($content['SourceDBRecordsPerQuery']) ) + { + $content['ISERROR'] = true; + $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_INVALIDVALUE'], $content['LN_CFG_DBRECORDSPERQUERY'] ); + } } else { @@ -453,7 +462,8 @@ if ( isset($_POST['op']) ) $tmpSource['DBTableName'] = $content['SourceDBTableName']; $tmpSource['DBUser'] = $content['SourceDBUser']; $tmpSource['DBPassword'] = $content['SourceDBPassword']; - $tmpSource['DBEnableRowCounting'] = $content['SourceDBEnableRowCounting']; + $tmpSource['DBEnableRowCounting'] = $content['SourceDBEnableRowCounting']; + $tmpSource['DBRecordsPerQuery'] = $content['SourceDBRecordsPerQuery']; $tmpSource['userid'] = $content['userid']; $tmpSource['groupid'] = $content['groupid']; } @@ -500,7 +510,7 @@ if ( isset($_POST['op']) ) } else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO ) { - $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, MsgSkipUnparseable, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid) + $sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, MsgSkipUnparseable, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, SourceDBRecordsPerQuery, userid, groupid) VALUES ('" . $content['Name'] . "', '" . $content['Description'] . "', " . $content['SourceType'] . ", @@ -516,6 +526,7 @@ if ( isset($_POST['op']) ) '" . $content['SourceDBPassword'] . "', '" . $content['SourceDBTableName'] . "', " . $content['SourceDBEnableRowCounting'] . ", + " . $content['SourceDBRecordsPerQuery'] . ", " . $content['userid'] . ", " . $content['groupid'] . " )"; @@ -573,6 +584,7 @@ if ( isset($_POST['op']) ) DBPassword = '" . $content['SourceDBPassword'] . "', DBTableName = '" . $content['SourceDBTableName'] . "', DBEnableRowCounting = " . $content['SourceDBEnableRowCounting'] . ", + DBRecordsPerQuery = " . $content['SourceDBRecordsPerQuery'] . ", userid = " . $content['userid'] . ", groupid = " . $content['groupid'] . " WHERE ID = " . $content['SOURCEID']; diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php index bb06c14..2c9bfe7 100644 --- a/src/classes/logstreamdb.class.php +++ b/src/classes/logstreamdb.class.php @@ -878,7 +878,7 @@ class LogStreamDB extends LogStream { // Get SQL Statement $szSql = $this->CreateSQLStatement($uID); - + // Append LIMIT clause $szSql .= " LIMIT " . $this->_currentRecordStart . ", " . $this->_logStreamConfigObj->RecordsPerQuery; //echo $szSql . "
"; diff --git a/src/include/db_update_v7.txt b/src/include/db_update_v7.txt index 5f52953..e9026a8 100644 --- a/src/include/db_update_v7.txt +++ b/src/include/db_update_v7.txt @@ -1,5 +1,6 @@ -- New Database Structure Updates ALTER TABLE `logcon_sources` ADD `MsgSkipUnparseable` BOOL NOT NULL DEFAULT '0' AFTER `MsgNormalize` ; +ALTER TABLE `logcon_sources` ADD `DBRecordsPerQuery` INT NOT NULL DEFAULT '100' AFTER `DBEnableRowCounting` ; -- Insert data diff --git a/src/include/functions_config.php b/src/include/functions_config.php index 1be09e1..6db76b8 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -159,6 +159,7 @@ function InitSource(&$mysource) if ( isset($mysource['DBUser']) ) { $mysource['ObjRef']->DBUser = $mysource['DBUser']; } if ( isset($mysource['DBPassword']) ) { $mysource['ObjRef']->DBPassword = $mysource['DBPassword']; } if ( isset($mysource['DBEnableRowCounting']) ) { $mysource['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting']; } + if ( isset($mysource['DBRecordsPerQuery']) ) { $mysource['ObjRef']->RecordsPerQuery = $mysource['DBRecordsPerQuery']; } } else if ( $mysource['SourceType'] == SOURCE_PDO ) { diff --git a/src/lang/de/admin.php b/src/lang/de/admin.php index 4905f71..e153c17 100644 --- a/src/lang/de/admin.php +++ b/src/lang/de/admin.php @@ -223,6 +223,7 @@ $content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!"; $content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!"; $content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)"; +$content['LN_SOURCES_ERROR_INVALIDVALUE'] = "Invalid value for the paramater '%1'."; // Database Upgrade $content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update"; diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 574597a..a466c69 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -193,6 +193,7 @@ $content['LN_CFG_FIRSTSYSLOGSOURCE'] = "Erste Syslog Quelle"; $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)"; $content['LN_CFG_NORMALIZEMSG'] = "Normalize Message within Parsers"; $content['LN_CFG_SKIPUNPARSEABLE'] = "Skip unparseable messages (Only works if msgparsers are configured!)"; + $content['LN_CFG_DBRECORDSPERQUERY'] = "Recordcount for database queries"; // 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 ec035e7..da98e03 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -227,6 +227,7 @@ $content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!"; $content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!"; $content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)"; +$content['LN_SOURCES_ERROR_INVALIDVALUE'] = "Invalid value for the paramater '%1'."; // Database Upgrade $content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index 87ac132..cc5ad57 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -195,6 +195,7 @@ $content['LN_CFG_DBUSERLOGINREQUIRED'] = "Require user to be logged in"; $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)"; $content['LN_CFG_NORMALIZEMSG'] = "Normalize Message within Parsers"; $content['LN_CFG_SKIPUNPARSEABLE'] = "Skip unparseable messages (Only works if msgparsers are configured!)"; +$content['LN_CFG_DBRECORDSPERQUERY'] = "Recordcount for database queries"; // 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 4905f71..e153c17 100644 --- a/src/lang/pt_BR/admin.php +++ b/src/lang/pt_BR/admin.php @@ -223,6 +223,7 @@ $content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!"; $content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!"; $content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)"; +$content['LN_SOURCES_ERROR_INVALIDVALUE'] = "Invalid value for the paramater '%1'."; // Database Upgrade $content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update"; diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index ce47da1..5e7064e 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -197,6 +197,7 @@ $content['LN_CFG_VIEW'] = "Selecione visão"; $content['LN_CFG_MSGPARSERS'] = "Message Parsers (comma seperated)"; $content['LN_CFG_NORMALIZEMSG'] = "Normalize Message within Parsers"; $content['LN_CFG_SKIPUNPARSEABLE'] = "Skip unparseable messages (Only works if msgparsers are configured!)"; + $content['LN_CFG_DBRECORDSPERQUERY'] = "Recordcount for database queries"; // 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 145ab72..2e19195 100644 --- a/src/templates/admin/admin_sources.html +++ b/src/templates/admin/admin_sources.html @@ -17,14 +17,16 @@ showvisibility("HiddenDatabaseTypeOptions"); hidevisibility("HiddenDiskTypeOptions"); - hidevisibility("HiddenDBTypesOptions"); + showvisibility("HiddenMYSQLSourceOptions"); + hidevisibility("HiddenPDOSourceOptions"); } else if (myfield.value == 3) { showvisibility("HiddenDatabaseTypeOptions"); hidevisibility("HiddenDiskTypeOptions"); - showvisibility("HiddenDBTypesOptions"); + showvisibility("HiddenPDOSourceOptions"); + hidevisibility("HiddenMYSQLSourceOptions"); } } @@ -136,7 +138,7 @@ - {LN_CFG_SKIPUNPARSEABLE} + {LN_CFG_SKIPUNPARSEABLE} @@ -184,7 +186,7 @@ {LN_CFG_DATABASETYPEOPTIONS} -
+
@@ -233,6 +235,15 @@
{LN_CFG_DBSTORAGEENGINE}
+
+ + + + + +
{LN_CFG_DBRECORDSPERQUERY}
+
+
From 4a1fbf511494eaea9eaae4f9b18827e54fd92542 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 27 Oct 2008 17:22:37 +0100 Subject: [PATCH 9/9] Added changelog entry --- ChangeLog | 29 +++++++++++++++++++++++++++++ src/include/functions_common.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a06c1f3..c36977d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,33 @@ --------------------------------------------------------------------------- +Version 2.5.16 (beta), 2008-10-27 +- Fixed a problem when adding a mysql logstream source. Due a problem of + how php mysql_connect function handels second conenctions, the Verify + of a newly added logstream source could cause the first database + connection to be overwritten. The following error is, that the wrong + database was used for the UserDB after the new logstream was verified. +- Added a check into the redirect function to STOP redirecting if an + error happens in the UserDB. +- Fixed minor issues handling form input which happened when + magic_quotes_gpc was enabled. +- Fixed a bug in the convert.php script which inserted the wrong + database version number. This caused phpLogCon to force an database + upgrade which is not needed at all. +- Added dummy db update scripts, so the db upgrade script won't fail + in future. This is for the case when the db version is not correctly + or missing in the user database. +- Added support to filter for dynamic fields within the logstream + database sources. This was not possible yet. The filtering also has a + secure end timer, which avoids that the timelimit hits the script. +- Added support to suppress unparseable messages when using msgparsers. + This enhances useability if you have mixed data sources, and want to + filter out unparseable messages. +- Added new setting for MYSQL logstream sources to control the amount + of data per query. This value can be used to tweak the MYSQL + performance. For example when filtering for fields which are generated + by a message parser, highering the value does improve the database + performance. The default value is 100, and should only be changed if + you know what you are doing. +--------------------------------------------------------------------------- Version 2.5.15 (beta), 2008-10-22 - Corrected the check for magic_quotes_gpc which is important when saving configuration values are saved into the UserDB. This also fixes a diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 6aa7942..40e69f7 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -66,7 +66,7 @@ $LANG_EN = "en"; // Used for fallback $LANG = "en"; // Default language // Default Template vars -$content['BUILDNUMBER'] = "2.5.15"; +$content['BUILDNUMBER'] = "2.5.16"; $content['TITLE'] = "phpLogCon :: Release " . $content['BUILDNUMBER']; // Default page title $content['BASEPATH'] = $gl_root_path; $content['SHOW_DONATEBUTTON'] = true; // Default = true!