diff --git a/src/classes/reports/report.adiscon.monilog.class.php b/src/classes/reports/report.adiscon.monilog.class.php new file mode 100644 index 0000000..cab823c --- /dev/null +++ b/src/classes/reports/report.adiscon.monilog.class.php @@ -0,0 +1,164 @@ + www.phplogcon.org <- * + * ----------------------------------------------------------------- * + * Some constants * + * * + * Monilog Report is a basic report for EventLog and Syslog data + * + * \version 1.0.0 Init Version + * * + * All directives are explained within this file * + * + * Copyright (C) 2008-2009 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ + +// --- Avoid directly accessing this file! +if ( !defined('IN_PHPLOGCON') ) +{ + die('Hacking attempt'); + exit; +} +// --- + +// --- Required Includes! +require_once($gl_root_path . 'include/constants_errors.php'); +// --- + +class ReportMonilog extends Report { + // Common Properties + public $_reportVersion = 1; // Internally Version of the ReportEngine + public $_reportID = "report.adiscon.monilog.class"; // ID for the report, needs to be unique! + public $_reportTitle = "EventLog Summary Report"; // Display name for the report + public $_reportDescription = "This is a EventLog Summary Report based on Monilog" + + +/* private $_currentOffset = -1; + private $_currentStartPos = -1; + private $_fp = null; + private $_bEOS = false; + + const _BUFFER_length = 8192; + private $_buffer = false; + private $_buffer_length = 0; + private $_p_buffer = -1; +*/ + + // Constructor + public function ReportMonilog() { +// $this->_logStreamConfigObj = $streamConfigObj; + + + // Fill fields we need for this report + $this->_arrProperties[] = SYSLOG_UID; + $this->_arrProperties[] = SYSLOG_DATE; + $this->_arrProperties[] = SYSLOG_HOST; + $this->_arrProperties[] = SYSLOG_MESSAGETYPE; + $this->_arrProperties[] = SYSLOG_FACILITY; + $this->_arrProperties[] = SYSLOG_SEVERITY; + $this->_arrProperties[] = SYSLOG_EVENT_ID; + $this->_arrProperties[] = SYSLOG_EVENT_LOGTYPE; + $this->_arrProperties[] = SYSLOG_EVENT_SOURCE; + $this->_arrProperties[] = SYSLOG_EVENT_CATEGORY; + $this->_arrProperties[] = SYSLOG_EVENT_USER; + $this->_arrProperties[] = SYSLOG_MESSAGE; + + } + + /** + * startDataProcessing, analysing data + * + * @param arrProperties array in: Properties wish list. + * @return integer Error stat + */ + public function startDataProcessing() + { + // Verify Datasource first! + if ( $this->verifyDataSource() == SUCCESS ) + { + $res = $stream->Open( $this->_arrProperties, true ); + if ( $res == SUCCESS ) + { + // report logic + + } + + } + + // Return success! + return SUCCESS; + } + + + /** + * verifyDataSource, verifies if data is accessable and + * contains what we need + * + * @param arrProperties array in: Properties wish list. + * @return integer Error stat + */ + public function verifyDataSource() + { + if ( $this->_streamCfgObj == null ) + { + // Obtain and get the Config Object + $this->_streamCfgObj = $content['Sources'][$this->_mySourceID]['ObjRef']; + } + + if ( $this->_streamObj == null ) + { + // Create LogStream Object + $this->_streamObj = $this->_streamCfgObj ->LogStreamFactory($this->_streamCfgObj); + } + + // Success! + return SUCCESS; + } + + + + /** + * validateLicense, check license code + * + */ + public function validateLicense() + { + // This is a free report! + return SUCCESS; + } + + + // Private functions... +/* + private function ResetBuffer() { + $this->_bEOS = false; + $this->_buffer = false; + $this->_buffer_length = 0; + $this->_p_buffer = -1; + } +*/ + + +} + +?> \ No newline at end of file diff --git a/src/classes/reports/report.class.php b/src/classes/reports/report.class.php new file mode 100644 index 0000000..d599d1e --- /dev/null +++ b/src/classes/reports/report.class.php @@ -0,0 +1,168 @@ + www.phplogcon.org <- * + * ----------------------------------------------------------------- * + * The Report Class is the base class for all reports * + * * + * All directives are explained within this file * + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ + +// --- 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 . 'include/constants_errors.php'); +require_once($gl_root_path . 'include/constants_logstream.php'); +// --- + + +abstract class Report { + // Common Properties + public $_reportVersion = 1; // Internally Version of the ReportEngine + public $_reportID = "report.adiscon.base.class";// ID for the report, needs to be unique! + public $_reportTitle = "Base Report Class"; // Display name for the report + public $_reportDescription = "This is the base class for all reports" + + // Configuration Properties + protected $_filterString = ""; + protected $_advancedOptionsXml = ""; + protected $_outputType = REPORT_OUTPUT_HTML; // Default HTML Output + protected $_mySourceID = ""; + protected $_arrProperties = null; // List of properties we need for the main logstream query! + + // License properties + protected $_licenseName = ""; + protected $_licenseKey = ""; + + // Helper Objects + protected $_reportcontent = null; + protected $_baseFileName = ""; + public $_streamCfgObj = null; + public $_streamObj = null; + + // Begin Abstract Function definitions! + + + /** + * This function process the data + * Will return -1 on failure! + */ + public abstract function startDataProcessing(); + + + /** + * This function checks if the license is valid + * Will return -1 on failure! + */ + public abstract function validateLicense(); + + + /** + * This functions check if the data source is valid + * Will return -1 on failure! + */ + public abstract function verifyDataSource(); + + /** + * Helper function using the template parser to create the report + */ + public function CreateReportFromData() + { + // Create new template parser + $page = new Template(); + $page -> set_path ( $gl_root_path . "classes/reports/" ); + + // Run Parser + $page -> parser($this->_reportcontent, $this->_baseFileName); + + // Return result! + return $page -> result(); + } + + /* + * Helper function to set the OutputType + */ + public function SetOutputType($newOutputType) + { + // Set new Outputtype + $this->_outputType = $newOutputType; + + // Set Filebasename + $this->_baseFileName = $this->_reportID . ".template." . $this->_outputType; + } + + /* + * Helper function to set the FilterString + */ + public function SetFilterString($newFilterString) + { + // Set new Outputtype + $this->_filterString = $newFilterString; + } + + /* + * Helper function to set the FilterString + */ + public function SetAdvancedOptions($newAdvancedOptions) + { + // Set new Outputtype + $this->_advancedOptionsXml = $newAdvancedOptions; + } + + /* + * Helper function to set the FilterString + */ + public function SetSourceID($newSourceID) + { + global $content; + + // check if valid! + if ( isset($content['Sources'][$newSourceID]) ) + $this->_mySourceID = $newSourceID; + else + { + OutputDebugMessage("SetSourceID failed, ID '" . $newSourceID . "' is not a valid Logstream Source", DEBUG_ERROR); + return; + } + } + + + /* + * Helper function to trigger initialisation + */ + public function RunBasicInits() + { + $this->SetOutputType( REPORT_OUTPUT_HTML ); + } + + +} +?> \ No newline at end of file diff --git a/src/include/constants_logstream.php b/src/include/constants_logstream.php index 6bd9742..99bfcf1 100644 --- a/src/include/constants_logstream.php +++ b/src/include/constants_logstream.php @@ -82,6 +82,11 @@ define('ALIGN_CENTER', 'center'); define('ALIGN_LEFT', 'left'); define('ALIGN_RIGHT', 'right'); +// Defines for Report output types +define('REPORT_OUTPUT_HTML', 'html'); +define('REPORT_OUTPUT_PDF', 'pdf'); + + // --- Predefine fields array! $fields[SYSLOG_UID]['FieldID'] = SYSLOG_UID; $fields[SYSLOG_UID]['FieldDefine'] = 'SYSLOG_UID';