diff --git a/src/admin/reports.php b/src/admin/reports.php
index e345636..cc1e5cb 100644
--- a/src/admin/reports.php
+++ b/src/admin/reports.php
@@ -295,7 +295,10 @@ if ( isset($_GET['op']) )
$content['customTitle'] = $myReport['DisplayName'];
$content['customComment'] = "";
$content['filterString'] = "";
- $content['customFilters'] = "";
+
+ // Init Custom Filters
+ InitCustomFilterDefinitions($myReport, "");
+// $content['customFilters'] = "";
// Copy Sources array for further modifications
global $currentSourceID;
@@ -368,7 +371,10 @@ if ( isset($_GET['op']) )
$content['customTitle'] = $mySavedReport['customTitle'];
$content['customComment'] = $mySavedReport['customComment'];
$content['filterString'] = $mySavedReport['filterString'];
- $content['customFilters'] = $mySavedReport['customFilters'];
+
+ // Init Custom Filters
+ InitCustomFilterDefinitions($myReport, $mySavedReport['customFilters']);
+// $content['customFilters'] = $mySavedReport['customFilters'];
// Copy Sources array for further modifications
$content['SOURCES'] = $content['Sources'];
@@ -1027,4 +1033,49 @@ $page -> parser($content, "admin/admin_reports.html");
$page -> output();
// ---
+// --- BEGIN Helper functions
+
+function InitCustomFilterDefinitions($myReport, $CustomFilterValues)
+{
+ global $content;
+
+ // Get Objectreference to report
+ $myReportObj = $myReport["ObjRef"];
+
+ // Get Array of Custom filter Defs
+ $customFilterDefs = $myReportObj->GetCustomFiltersDefs();
+
+ // Include Custom language file if available
+ $myReportObj->InitReportLanguageFile( $myReportObj->GetReportIncludePath() );
+
+ // Loop through filters
+ $i = 0; // Help counter!
+ foreach( $customFilterDefs as $filterID => $tmpCustomFilter )
+ {
+ // TODO Check if value is available in $CustomFilterValues
+ $szDefaultValue = $tmpCustomFilter['DefaultValue'];
+
+ // TODO Check MIN and MAX value!
+
+ // --- Set CSS Class
+ if ( $i % 2 == 0 )
+ $szColcssclass = "line1";
+ else
+ $szColcssclass = "line2";
+ $i++;
+ // ---
+
+ $content['CUSTOMFILTERS'][] = array (
+ 'fieldname' => $filterID,
+ 'fieldcaption' => $content[ $tmpCustomFilter['DisplayLangID'] ],
+ 'fielddescription' => $content[ $tmpCustomFilter['DescriptLangID'] ],
+ 'filtertype' => $tmpCustomFilter['filtertype'],
+ 'fieldvalue' => $szDefaultValue,
+ 'colcssclass' => $szColcssclass,
+ );
+ }
+}
+
+// --- END Helper functions
+
?>
\ No newline at end of file
diff --git a/src/classes/class_template.php b/src/classes/class_template.php
index ead6d7c..40d1c1b 100644
--- a/src/classes/class_template.php
+++ b/src/classes/class_template.php
@@ -109,9 +109,9 @@ class Template {
$this->vars = $vars;
if (!isset($this->template)) {
$fname = $this->path . $this->filename . $this->extension;
- $this->template = load_file($fname);
+ $this->template = $this->load_file($fname);
}
- $this->page = template_parser( $this->template, $this->vars, $this->path, $this->extension );
+ $this->page = $this->template_parser( $this->template, $this->vars, $this->path, $this->extension );
}
@@ -133,135 +133,168 @@ class Template {
}
}
-}
-
-function load_file($fname)
-{
- if (@is_file($fname))
- return join('', file($fname));
- else
+ // Moved into Class
+ function load_file($fname)
{
-// BEGIN DELTA MOD
- DieWithErrorMsg( "Could not find the template ".$fname."");
-// END DELTA MOD
- }
-}
-
-function template_parser($template, $values, $path = '', $ext = '')
-{
- while (preg_match("", $template, $matches))
- $template = str_replace( "", load_file( $path . $matches[1] . $ext), $template );
-
- $template = template_parser_sub($template, $values);
- $template = str_replace("\t", " ", $template);
- $template = preg_replace("/ +/", " ", $template);
- return $template;
-}
-
-function template_parser_sub($template, $values)
-{
- if (is_array($values))
- {
- foreach ($values as $k => $v)
+ if (@is_file($fname))
+ return join('', file($fname));
+ else
{
- if (is_array($v))
+ // BEGIN DELTA MOD
+ DieWithErrorMsg( "Could not find the template ".$fname."");
+ // END DELTA MOD
+ }
+ }
+
+ function template_parser($template, $values, $path = '', $ext = '')
+ {
+ while (preg_match("", $template, $matches))
+ $template = str_replace( "", $this->load_file( $path . $matches[1] . $ext), $template );
+
+ $template = $this->template_parser_sub($template, $values);
+ $template = str_replace("\t", " ", $template);
+ $template = preg_replace("/ +/", " ", $template);
+ return $template;
+ }
+
+ function template_parser_sub($template, $values)
+ {
+ if (is_array($values))
+ {
+ foreach ($values as $k => $v)
{
- $len = strlen($k);
- $lp = strpos($template, "");
- if (is_int($lp))
+ if (is_array($v))
{
- if ($rp = strpos($template, ""))
+ $len = strlen($k);
+ $lp = strpos($template, "");
+ if (is_int($lp))
{
- $page = substr($template, 0, $lp);
- $iter = substr($template, $lp + 15 + $len, $rp - $lp - $len - 15);
- $rowcnt = 0;
- $zaehler = 1;
- foreach ($v as $subval)
+ if ($rp = strpos($template, ""))
{
- $subval['COUNTER'] = $rowcnt%2;
- $subval['ODDROW'] = $rowcnt%2;
- $subval['ROWCNT'] = $rowcnt++;
- $subval['ZAEHLER'] = $zaehler++;
- $page .= template_parser_sub($iter, $subval);
+ $page = substr($template, 0, $lp);
+ $iter = substr($template, $lp + 15 + $len, $rp - $lp - $len - 15);
+ $rowcnt = 0;
+ $zaehler = 1;
+ foreach ($v as $subval)
+ {
+ $subval['COUNTER'] = $rowcnt%2;
+ $subval['ODDROW'] = $rowcnt%2;
+ $subval['ROWCNT'] = $rowcnt++;
+ $subval['ZAEHLER'] = $zaehler++;
+ $page .= $this->template_parser_sub($iter, $subval);
+ }
+ $template = $page . substr($template, $rp + 13 + $len);
}
- $template = $page . substr($template, $rp + 13 + $len);
+ }
+ }
+ else
+ {
+ // FIXED BY ANDRE | Do not convert OBJECTS into strings!
+ if ( !is_object($k) && !is_object($v) )
+ $template = str_replace('{'.$k.'}', "$v", $template);
+ }
+ }
+ }
+
+
+ if (preg_match_all("", $template, $matches))
+ {
+ foreach ($matches[1] as $block)
+ {
+ if (isset($values[$block]))
+ {
+ $template = str_replace("", "", $template);
+ $template = str_replace("", "", $template);
+ }
+ else if ($blockend = strpos($template, "")) {
+ $blockbeg = strpos($template, "");
+ $template = substr($template, 0, $blockbeg) . substr($template, $blockend + 13 + strlen($block));
+ }
+ }
+ }
+ // else
+
+ if (preg_match_all( '', $template, $matches, PREG_SET_ORDER) )
+ {
+ // echo $matches[0][0];
+ // exit;
+
+ foreach ($matches as $block) {
+ $blockname = $block[1];
+ $not = $block[2];
+ $blockvalue = $block[3];
+ if ((@$values[$blockname] == $blockvalue && !$not) || (@$values[$blockname] != $blockvalue && $not))
+ {
+ $template = str_replace( "", "", $template );
+ $template = str_replace( "", "", $template );
+ }
+ else if ($blockend = strpos( $template, ""))
+ {
+ $blockbeg = strpos($template, "");
+ $template = substr($template, 0, $blockbeg) . substr($template, $blockend + 18 + strlen($blockname) + strlen($blockvalue) + strlen($not));
+ }
+ }
+ }
+
+ if (preg_match_all( '', $template, $matches, PREG_SET_ORDER) )
+ {
+ // echo $matches[0][1];
+ // echo $matches[0][2];
+ // echo $matches[0][3];
+ // exit;
+ foreach ($matches as $block)
+ {
+ $blockname = $block[1];
+ $cmp = $block[2];
+ $blockstrvalue = $block[3];
+
+ // If $ get from content variable!
+ if ( strpos($blockstrvalue, "$") !== false )
+ {
+ // Trunscate $
+ $szVarId = substr( $blockstrvalue, 1 );
+
+ if ( isset($this->vars[$szVarId]) )
+ $blockvalue = intval($this->vars[$szVarId]);
+ else
+ $blockvalue = intval($blockstrvalue);
+ }
+ else // Plain number value
+ $blockvalue = intval($blockstrvalue);
+
+ if ( isset($values[$blockname]) )
+ {
+//echo "$cmp == '>' && @$values[$blockname] > $blockvalue
";
+
+ // Perform comparison
+ if (
+ ($cmp == '>' && @$values[$blockname] > $blockvalue) ||
+ ($cmp == '>=' && @$values[$blockname] >= $blockvalue) ||
+ ($cmp == '<' && @$values[$blockname] < $blockvalue) ||
+ ($cmp == '<=' && @$values[$blockname] <= $blockvalue)
+ )
+ {
+ $template = str_replace( "", "", $template );
+ $template = str_replace( "", "", $template );
+ }
+ else if ($blockend = strpos( $template, ""))
+ {
+ $blockbeg = strpos($template, "");
+ $template = substr($template, 0, $blockbeg) . substr($template, $blockend + 18 + strlen($blockname) + strlen($blockstrvalue) + strlen($cmp));
}
}
- }
- else
- {
- // FIXED BY ANDRE | Do not convert OBJECTS into strings!
- if ( !is_object($k) && !is_object($v) )
- $template = str_replace('{'.$k.'}', "$v", $template);
+ else
+ {
+ $template = str_replace( "", "", $template );
+ $template = str_replace( "", "", $template );
+ }
}
}
- }
-
-
- if (preg_match_all("", $template, $matches))
- {
- foreach ($matches[1] as $block)
- {
- if (isset($values[$block]))
- {
- $template = str_replace("", "", $template);
- $template = str_replace("", "", $template);
- }
- else if ($blockend = strpos($template, "")) {
- $blockbeg = strpos($template, "");
- $template = substr($template, 0, $blockbeg) . substr($template, $blockend + 13 + strlen($block));
- }
- }
- }
-// else
-
- if (preg_match_all( '', $template, $matches, PREG_SET_ORDER) )
- {
-// echo $matches[0][0];
-// exit;
- foreach ($matches as $block) {
- $blockname = $block[1];
- $not = $block[2];
- $blockvalue = $block[3];
- if ((@$values[$blockname] == $blockvalue && !$not) || (@$values[$blockname] != $blockvalue && $not))
- {
- $template = str_replace( "", "", $template );
- $template = str_replace( "", "", $template );
- }
- else if ($blockend = strpos( $template, ""))
- {
- $blockbeg = strpos($template, "");
- $template = substr($template, 0, $blockbeg) . substr($template, $blockend + 18 + strlen($blockname) + strlen($blockvalue) + strlen($not));
- }
- }
+ // return processed template
+ return $template;
}
-
- if (preg_match_all( '', $template, $matches, PREG_SET_ORDER) )
- {
-// echo $matches[0][1];
-// echo $matches[0][2];
-// echo $matches[0][3];
-// exit;
-
- foreach ($matches as $block) {
- $blockname = $block[1];
- $cmp = $block[2];
- $blockvalue = $block[3];
- if ( ($cmp == '>' && @$values[$blockname] > $blockvalue) || ($cmp == '<' && @$values[$blockname] < $blockvalue) )
- {
- $template = str_replace( "", "", $template );
- $template = str_replace( "", "", $template );
- }
- else if ($blockend = strpos( $template, ""))
- {
- $blockbeg = strpos($template, "");
- $template = substr($template, 0, $blockbeg) . substr($template, $blockend + 18 + strlen($blockname) + strlen($blockvalue) + strlen($cmp));
- }
- }
- }
-
-
- return $template;
+
+
}
-?>
+?>
\ No newline at end of file
diff --git a/src/classes/reports/report.class.php b/src/classes/reports/report.class.php
index df63df6..cf7f191 100644
--- a/src/classes/reports/report.class.php
+++ b/src/classes/reports/report.class.php
@@ -62,8 +62,9 @@ abstract class Report {
// SavedReport Configuration Properties
protected $_customTitle = "";
protected $_customComment = "";
- protected $_filterString = "";
- protected $_customFilters = "";
+ protected $_filterString = ""; // Filterstring like used in the search view
+ protected $_arrCustomFilters = null; // Array contains list of available custom filters, used for admin interface!
+ protected $_customFilters = ""; // Xml Filterstring containing values for the custom filters
protected $_outputFormat = REPORT_OUTPUT_HTML; // Default HTML Output
protected $_outputTarget = "";
protected $_scheduleSettings = "";
@@ -233,6 +234,9 @@ abstract class Report {
{
// Set new Outputtype
$this->_customFilters = $newAdvancedOptions;
+
+ echo "TODO SetCustomFilters";
+ exit;
}
/*
@@ -429,6 +433,14 @@ abstract class Report {
return $this->_reportVersion;
}
+ /*
+ * Helper function to return the custom filter definitions
+ */
+ public function GetCustomFiltersDefs()
+ {
+ return $this->_arrCustomFilters;
+ }
+
/*
* Helper function to trigger initialisation
*/
@@ -455,6 +467,26 @@ abstract class Report {
$this->SetScheduleSettings( $mySavedReport["scheduleSettings"] );
}
-
+
+ /*
+ * Helper function to get the report include path
+ */
+ public function GetReportIncludePath()
+ {
+ global $gl_root_path;
+ return $gl_root_path . 'classes/reports/' . $this->_reportFileBasicName . "/";
+ }
+
+ /*
+ * Helper function to init custom language strings from report!
+ */
+ public function InitReportLanguageFile($szReportIncludePath)
+ {
+ // Include Custom language file if available
+ IncludeLanguageFile( $szReportIncludePath . $this->_reportFileBasicName . ".lang.en.php" );
+
+ }
+
+
}
?>
\ No newline at end of file
diff --git a/src/classes/reports/report.eventlog.monilog.class.php b/src/classes/reports/report.eventlog.monilog.class.php
index 91d2129..6eb2905 100644
--- a/src/classes/reports/report.eventlog.monilog.class.php
+++ b/src/classes/reports/report.eventlog.monilog.class.php
@@ -59,16 +59,7 @@ class Report_monilog extends Report {
// Advanced Report Options
private $_maxHosts = 20; // Threshold for maximum hosts to analyse!
private $_maxEventsPerHost = 100; // Threshold for maximum amount of events to analyse per host
-/* 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;
-*/
+ private $_colorThreshold = 10; // Threshold for coloured display of Eventcounter
// Constructor
public function Report_monilog() {
@@ -89,6 +80,36 @@ class Report_monilog extends Report {
$this->_arrProperties[] = SYSLOG_MESSAGE;
$this->_arrProperties[] = MISC_CHECKSUM;
+ // Init Customfilters Array
+ $this->_arrCustomFilters['_maxHosts'] = array ( 'InternalID' => '_maxHosts',
+ 'DisplayLangID' => 'ln_report_maxHosts_displayname',
+ 'DescriptLangID'=> 'ln_report_maxHosts_description',
+ FILTER_TYPE => FILTER_TYPE_NUMBER,
+ 'DefaultValue' => 20,
+ 'MinValue' => 0,
+ 'MaxValue' => 0,
+ );
+ $this->_arrCustomFilters['_maxEventsPerHost'] =
+ array ( 'InternalID' => '_maxEventsPerHost',
+ 'DisplayLangID' => 'ln_report_maxEventsPerHost_displayname',
+ 'DescriptLangID'=> 'ln_report_maxEventsPerHost_description',
+ FILTER_TYPE => FILTER_TYPE_NUMBER,
+ 'DefaultValue' => 100,
+ 'MinValue' => 0,
+ 'MaxValue' => 0,
+ );
+ $this->_arrCustomFilters['_colorThreshold'] =
+ array ( 'InternalID' => '_colorThreshold',
+ 'DisplayLangID' => 'ln_report_colorThreshold_displayname',
+ 'DescriptLangID'=> 'ln_report_colorThreshold_description',
+ FILTER_TYPE => FILTER_TYPE_NUMBER,
+ 'DefaultValue' => 10,
+ 'MinValue' => 0,
+ 'MaxValue' => 0,
+ );
+
+
+
}
/**
@@ -108,13 +129,12 @@ class Report_monilog extends Report {
$res = $this->_streamObj->Open( $this->_arrProperties, true );
if ( $res == SUCCESS )
{
-//
-// // Verify Datasource first!
-// if ( $this->verifyDataSource() == SUCCESS )
-// {
// Set to common content variables
$this->SetCommonContentVariables();
+ // Set report specific content variables
+ $content["_colorThreshold"] = $this->_colorThreshold;
+
// --- Report logic starts here
$content["report_rendertime"] = "";
diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.lang.en.php b/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.lang.en.php
index d5cec98..4e9a959 100644
--- a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.lang.en.php
+++ b/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.lang.en.php
@@ -40,6 +40,15 @@ $content['ln_report_severity'] = "Type";
$content['ln_report_eventid'] = "Event ID";
$content['ln_report_description'] = "Description";
$content['ln_report_count'] = "Count";
+$content['ln_report_maxHosts_displayname'] = "Max hosts";
+$content['ln_report_maxHosts_description'] = "The maximum number of hosts which will be displayed.";
+$content['ln_report_maxEventsPerHost_displayname'] = "Max Events per host";
+$content['ln_report_maxEventsPerHost_description'] = "The maximum number of events displayed per host.";
+$content['ln_report_colorThreshold_displayname'] = "Counter Threshold";
+$content['ln_report_colorThreshold_description'] = "If the amount of consolidated events is higher then this threshold, the countfield will be marked red.";
+$content['ln_report_'] = "";
+$content['ln_report_'] = "";
+$content['ln_report_'] = "";
$content['ln_report_'] = "";
$content['ln_report_'] = "";
$content['ln_report_'] = "";
diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html b/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html
index 10396cb..bc6ec04 100644
--- a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html
+++ b/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html
@@ -113,12 +113,12 @@
{LN_REPORTS_ADVANCEDFILTERLIST} | +|||
+ {fieldcaption} ({fielddescription}) + |
+ + + | +