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";