Renamed monilog report into eventsummary report

Also added function to read and list available reports from an online xml file
This commit is contained in:
Andre Lorbach 2010-01-07 16:38:58 +01:00
parent eabc43bc92
commit 89b277d3d4
11 changed files with 267 additions and 28 deletions

View File

@ -54,6 +54,10 @@ IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// --- BEGIN Custom Code
// Hardcoded settings
define('URL_ONLINEREPORTS', 'http://tools.adiscon.net/listreports.php');
$content['OPTIONAL_TITLE'] = "";
// Firts of all init List of Reports!
InitReportModules();
@ -480,6 +484,32 @@ if ( isset($_GET['op']) )
$content['ERROR_MSG'] = $content['LN_REPORTS_ERROR_INVALIDSAVEDREPORTID'];
}
}
else if ($_GET['op'] == "onlinelist")
{
// Set Mode to list Online Reports
$content['LISTONLINEREPORTS'] = "true";
$content['OPTIONAL_TITLE'] = " - " . $content['LN_REPORTMENU_ONLINELIST'];
if ( InitOnlineReports() )
{
$j = 0; // Help counter!
foreach ($content['ONLINEREPORTS'] as &$myOnlineReport )
{
// --- Set CSS Class
if ( $j % 2 == 0 )
$myOnlineReport['cssclass'] = "line1";
else
$myOnlineReport['cssclass'] = "line2";
$j++;
// ---
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_REPORTS_ERROR_ONLINELIST'];
}
}
}
@ -1010,6 +1040,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Searches
$content['LISTREPORTS'] = "true";
$content['OPTIONAL_TITLE'] = " - " . $content['LN_REPORTMENU_LIST'];
$i = 0; // Help counter!
foreach ($content['REPORTS'] as &$myReport )
@ -1060,7 +1091,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
$mySavedReport['srcssclass'] = "line1";
else
$mySavedReport['srcssclass'] = "line2";
$i++;
$j++;
// ---
}
}
@ -1213,6 +1244,167 @@ function CreateCronCommand( $myReportID, $mySavedReportID = null )
return $szCommand;
}
function InitOnlineReports()
{
global $content;
$xmlArray = xml2array( URL_ONLINEREPORTS );
if ( is_array($xmlArray) && isset($xmlArray['reports']['report']) && count($xmlArray['reports']['report']) > 0 )
{
foreach( $xmlArray['reports']['report'] as $myOnlineReport )
{
// Copy to OnlineReports Array
$content['ONLINEREPORTS'][] = $myOnlineReport;
}
// Success!
return true;
}
else
// Failure
return false;
}
// Helper function from php doc
function xml2array($url, $get_attributes = 1, $priority = 'tag')
{
$contents = "";
if (!function_exists('xml_parser_create'))
{
return false;
}
$parser = xml_parser_create('');
if (!($fp = @ fopen($url, 'rb')))
{
return false;
}
while (!feof($fp))
{
$contents .= fread($fp, 8192);
}
fclose($fp);
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, trim($contents), $xml_values);
xml_parser_free($parser);
if (!$xml_values)
return; //Hmm...
$xml_array = array ();
$parents = array ();
$opened_tags = array ();
$arr = array ();
$current = & $xml_array;
$repeated_tag_index = array ();
foreach ($xml_values as $data)
{
unset ($attributes, $value);
extract($data);
$result = array ();
$attributes_data = array ();
if (isset ($value))
{
if ($priority == 'tag')
$result = $value;
else
$result['value'] = $value;
}
if (isset ($attributes) and $get_attributes)
{
foreach ($attributes as $attr => $val)
{
if ($priority == 'tag')
$attributes_data[$attr] = $val;
else
$result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr'
}
}
if ($type == "open")
{
$parent[$level -1] = & $current;
if (!is_array($current) or (!in_array($tag, array_keys($current))))
{
$current[$tag] = $result;
if ($attributes_data)
$current[$tag . '_attr'] = $attributes_data;
$repeated_tag_index[$tag . '_' . $level] = 1;
$current = & $current[$tag];
}
else
{
if (isset ($current[$tag][0]))
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
$repeated_tag_index[$tag . '_' . $level]++;
}
else
{
$current[$tag] = array (
$current[$tag],
$result
);
$repeated_tag_index[$tag . '_' . $level] = 2;
if (isset ($current[$tag . '_attr']))
{
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
unset ($current[$tag . '_attr']);
}
}
$last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1;
$current = & $current[$tag][$last_item_index];
}
}
elseif ($type == "complete")
{
if (!isset ($current[$tag]))
{
$current[$tag] = $result;
$repeated_tag_index[$tag . '_' . $level] = 1;
if ($priority == 'tag' and $attributes_data)
$current[$tag . '_attr'] = $attributes_data;
}
else
{
if (isset ($current[$tag][0]) and is_array($current[$tag]))
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result;
if ($priority == 'tag' and $get_attributes and $attributes_data)
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
}
$repeated_tag_index[$tag . '_' . $level]++;
}
else
{
$current[$tag] = array (
$current[$tag],
$result
);
$repeated_tag_index[$tag . '_' . $level] = 1;
if ($priority == 'tag' and $get_attributes)
{
if (isset ($current[$tag . '_attr']))
{
$current[$tag]['0_attr'] = $current[$tag . '_attr'];
unset ($current[$tag . '_attr']);
}
if ($attributes_data)
{
$current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data;
}
}
$repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken
}
}
}
elseif ($type == 'close')
{
$current = & $parent[$level -1];
}
}
return ($xml_array);
}
// --- END Helper functions
?>

View File

@ -5,7 +5,7 @@
* ----------------------------------------------------------------- *
* Some constants *
* *
* Monilog Report is a basic report for EventLog and Syslog data
* Eventsummary Report is a basic report for EventLog
*
* \version 1.0.0 Init Version
* *
@ -45,13 +45,13 @@ if ( !defined('IN_PHPLOGCON') )
require_once($gl_root_path . 'classes/reports/report.class.php');
// ---
class Report_monilog extends Report {
class Report_eventsummary extends Report {
// Common Properties
public $_reportVersion = 1; // Internally Version of the ReportEngine
public $_reportID = "report.eventlog.monilog.class"; // ID for the report, needs to be unique!
public $_reportFileBasicName = "report.eventlog.monilog"; // Basic Filename for reportfiles
public $_reportTitle = "EventLog Summary Report"; // Display name for the report
public $_reportDescription = "This is a EventLog Summary Report based on Monilog";
public $_reportVersion = 1; // Internally Version of the ReportEngine
public $_reportID = "report.eventlog.eventsummary.class"; // ID for the report, needs to be unique!
public $_reportFileBasicName = "report.eventlog.eventsummary"; // Basic Filename for reportfiles
public $_reportTitle = "EventLog Summary Report"; // Display name for the report
public $_reportDescription = "This is a EventLog Summary Report";
public $_reportHelpArticle = "";
public $_reportNeedsInit = false; // True means that this report needs additional init stuff
public $_reportInitialized = false; // True means report is installed
@ -62,7 +62,7 @@ class Report_monilog extends Report {
private $_colorThreshold = 10; // Threshold for coloured display of Eventcounter
// Constructor
public function Report_monilog() {
public function Report_eventsummary() {
// $this->_logStreamConfigObj = $streamConfigObj;
// Fill fields we need for this report

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

View File

@ -691,6 +691,9 @@ function InitFrontEndVariables()
$content['MENU_TRASH'] = $content['BASEPATH'] . "images/icons/garbage_empty.png";
$content['MENU_REPORTS'] = $content['BASEPATH'] . "images/icons/document_chart.png";
$content['MENU_CHARTPRESENTATION'] = $content['BASEPATH'] . "images/icons/presentation_chart.png";
$content['MENU_NETDOWNLOAD'] = $content['BASEPATH'] . "images/icons/download.png";
$content['MENU_DOCUMENTLIST'] = $content['BASEPATH'] . "images/icons/documents.png";
$content['MENU_WINDOWLIST'] = $content['BASEPATH'] . "images/icons/windows.png";
$content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png";
$content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png";

View File

@ -437,6 +437,10 @@ $content['LN_REPORTS_ADVANCEDFILTERLIST'] = "List of advanced report filters";
$content['LN_REPORTS_OUTPUTTARGET_DETAILS'] = "Outputtarget Options";
$content['LN_REPORTS_OUTPUTTARGET_FILE'] = "Output Path and Filename";
$content['LN_REPORTS_CRONCMD'] = "Local Report command";
$content['LN_REPORTMENU_LIST'] = "List installed Reports";
$content['LN_REPORTMENU_ONLINELIST'] = "All Available Reports";
$content['LN_REPORTS_LINKS'] = "Related Links";
$content['LN_REPORTS_'] = "";
$content['LN_REPORTS_'] = "";
$content['LN_REPORTS_'] = "";
$content['LN_REPORTS_'] = "";

View File

@ -15,12 +15,21 @@
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
<tr>
<td colspan="3" class="title" nowrap><B>{LN_ADMINMENU_REEPORTSOPT}</B></td>
<td colspan="3" class="title" nowrap><B>{LN_ADMINMENU_REEPORTSOPT}{OPTIONAL_TITLE}</B></td>
</tr>
<tr>
<td align="center" class="line2">
<br><br>
<table border="0" cellpadding="2" cellspacing="0" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
<td class="topmenu2begin" nowrap align="center" width="16"><img align="left" src="{MENU_BULLET_YELLOW}" width="16" height="16" vspace="0"></td>
<td class="topmenu2" nowrap align="center" width="150"><a class="topmenu1_link" href="{BASEPATH}admin/reports.php" target="_top"><img align="left" src="{MENU_DOCUMENTLIST}" width="16" height="16" vspace="0">{LN_REPORTMENU_LIST}</a></td>
<td class="topmenu2" nowrap align="center" width="150"><a class="topmenu1_link" href="{BASEPATH}admin/reports.php?op=onlinelist" target="_top"><img align="left" src="{MENU_NETDOWNLOAD}" width="16" height="16" vspace="0">{LN_REPORTMENU_ONLINELIST}</a></td>
<td class="topmenu2end" nowrap align="center" width="max">&nbsp;</td>
</tr>
</table>
<!-- IF LISTREPORTS="true" -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
@ -71,34 +80,67 @@
</td>
</tr>
<!-- END SAVEDREPORTS -->
<!-- ENDIF HASSAVEDREPORTS="true" -->
<!-- END REPORTS -->
</table>
<!-- ENDIF LISTREPORTS="true" -->
<!-- IF ISSHOWDETAILS="true" -->
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<!-- IF LISTONLINEREPORTS="true" -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_REPORTS_DETAILS}</b></td>
<td align="center" width="100" class="cellmenu1"><b>{LN_REPORTS_ID}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_REPORTS_NAME}</b></td>
<td align="center" width="300" class="cellmenu1"><b>{LN_REPORTS_DESCRIPTION}</b></td>
<td align="center" width="125" class="cellmenu1" nowrap><b>{LN_REPORTS_LINKS}</b></td>
</tr>
<!-- BEGIN ONLINEREPORTS -->
<tr>
<td align="left" class="{cssclass}" valign="top"><b>{reportid}</b></td>
<td align="left" class="{cssclass}" valign="top"><a href="{BASEPATH}admin/reports.php?op=details&id={ID}">{reportname}</a></td>
<td align="left" class="{cssclass}" valign="top">{reportdescription}</td>
<td align="center" class="{cssclass}">
<a href="{BASEPATH}admin/reports.php?op=addsavedreport&id={ID}"><img src="{MENU_ADD}" width="16" title="{LN_REPORTS_ADDSAVEDREPORT}"></a>&nbsp;
<!-- IF ReportHelpEnabled="true" -->
<a href="{ReportHelpArticle}" target="_blank"><img src="{MENU_HELP}" width="16" title="{LN_REPORTS_HELP}"></a>&nbsp;&nbsp;
<!-- ENDIF ReportHelpEnabled="true" -->
<a href="{BASEPATH}admin/reports.php?op=details&id={ID}"><img src="{MENU_INFORMATION}" width="16" title="{LN_REPORTS_INFO}"></a>
<!-- IF EnableNeedsInit="true" -->
<!-- IF InitEnabled="true" -->
&nbsp;<a href="{BASEPATH}admin/reports.php?op=initreport&id={ID}"><img src="{MENU_PARSER_INIT}" width="16" title="{LN_REPORTS_INIT}"></a>
<!-- ENDIF InitEnabled="true" -->
<!-- IF DeleteEnabled="true" -->
&nbsp;<a href="{BASEPATH}admin/reports.php?op=removereport&id={ID}"><img src="{MENU_PARSER_DELETE}" width="16" title="{LN_REPORTS_REMOVE}"></a>
<!-- ENDIF DeleteEnabled="true" -->
<!-- ENDIF EnableNeedsInit="true" -->
</td>
</tr>
<!-- END ONLINEREPORTS -->
</table>
<!-- ENDIF LISTONLINEREPORTS="true" -->
<!-- IF ISSHOWDETAILS="true" -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="3"><b>{LN_REPORTS_DETAILS}</b></td>
</tr>
<tr>
<td align="left" class="cellmenu2" width="250"><b>{LN_REPORTS_ID}</b></td>
<td align="left" class="line1" width="350">{ReportID}</td>
<td align="left" class="line1" width="350" colspan="2">{ReportID}</td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_REPORTS_NAME}</b></td>
<td align="left" class="line2">{DisplayName}</td>
<td align="left" class="line2" colspan="2">{DisplayName}</td>
</tr>
<tr>
<td align="left" class="cellmenu2_naked" valign="top"><b>{LN_REPORTS_DESCRIPTION}</b></td>
<td align="left" class="line1">{Description}</td>
<td align="left" class="line1" colspan="2">{Description}</td>
</tr>
<!-- IF EnableHelpArticle="true" -->
<tr>
<td align="left" class="cellmenu2"><b>{LN_REPORTS_HELP}</b></td>
<td align="center" class="line2"><a href="{ReportHelpArticle}" target="_blank">{LN_REPORTS_HELP_CLICK}</a></td>
<td align="center" class="line2" colspan="2"><a href="{ReportHelpArticle}" target="_blank">{LN_REPORTS_HELP_CLICK}</a></td>
</tr>
<!-- ENDIF EnableHelpArticle="true" -->
<!-- IF EnableNeedsInit="true" -->
@ -113,12 +155,12 @@
</td>
</tr>
<!-- ENDIF EnableNeedsInit="true" -->
</table>
<!-- IF HASSAVEDREPORTS="true" -->
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr>
<td align="center" colspan="2" class="cellmenu2" valign="top">{LN_REPORTS_SAVEDREPORTS}</td>
<td align="center" rowspan="{SavedReportRowSpan}" class="cellmenu2_naked" valign="top">{LN_REPORTS_SAVEDREPORTS}</td>
<td align="left" class="line1" colspan="2">
</td>
</tr>
<!-- BEGIN SAVEDREPORTS -->
<tr>
@ -127,16 +169,14 @@
<a href="{BASEPATH}admin/reports.php?op=editsavedreport&id={ReportID}&savedreportid={SavedReportID}">{customTitle}</a>
</td>
<td align="center" class="{srcssclass}">
&nbsp;<a href="{BASEPATH}todo.php?op=runreport&savedreportid={SavedReportID}" target="_blank"><img src="{MENU_CHART_PREVIEW}" width="16" title="{LN_REPORTS_RUNNOW}"></a>
&nbsp;<a href="{BASEPATH}reportgenerator.php?op=runreport&id={ReportID}&savedreportid={SavedReportID}" target="_blank"><img src="{MENU_CHART_PREVIEW}" width="16" title="{LN_REPORTS_RUNNOW}"></a>
&nbsp;<a href="{BASEPATH}admin/reports.php?op=editsavedreport&id={ReportID}&savedreportid={SavedReportID}"><img src="{MENU_EDIT}" width="16" title="{LN_REPORTS_EDITSAVEDREPORT}"></a>
&nbsp;<a href="{BASEPATH}admin/reports.php?op=removesavedreport&savedreportid={SavedReportID}"><img src="{MENU_DELETE}" width="16" title="{LN_REPORTS_REMOVESAVEDREPORT}"></a>
</td>
</tr>
<!-- END SAVEDREPORTS -->
</table>
<!-- ENDIF HASSAVEDREPORTS="true" -->
</table>
<br><br>
<a href="javascript:history.back();" target="_top">{LN_GEN_ERRORRETURNPREV}</a>
@ -176,7 +216,7 @@
<input type="hidden" name="id" value="{ReportID}">
<input type="hidden" name="savedreportid" value="{SavedReportID}">
<!-- <input type="hidden" name="op" value="addsavedreport">-->
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="750" class="with_border_alternate">
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_REPORTS_ADDSAVEDREPORT}: '{DisplayName}'</b></td>
</tr>
@ -293,7 +333,7 @@
</table>
<div id="HiddenOutputFormatFile" class="HiddenContent">
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="750" class="with_border_alternate">
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
<td align="left" class="cellmenu2" width="150" valign="top" nowrap><b>{LN_REPORTS_OUTPUTTARGET_FILE}</b></td>
<td align="left" class="line1" width="100%">
@ -303,7 +343,7 @@
</table>
</div>
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="750" class="with_border_alternate">
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<!-- IF enableCronCommand="true" -->
<tr>
<td align="left" class="cellmenu2_naked" width="150" nowrap><b>{LN_REPORTS_CRONCMD}</b></td>