Implemented further stuff for the admin panel of the reports

This commit is contained in:
Andre Lorbach 2009-08-19 11:58:54 +02:00
parent 7471eacedd
commit ff88bd8f8a
8 changed files with 116 additions and 82 deletions

View File

@ -5,7 +5,7 @@
* -----------------------------------------------------------------
* Search Admin File
*
* -> Helps administrating message parsers
* -> Helps administrating report modules
*
* All directives are explained within this file
*
@ -69,23 +69,24 @@ if ( isset($_GET['op']) )
if ( isset($_GET['id']) )
{
//PreInit these values
$content['ParserID'] = DB_RemoveBadChars($_GET['id']);
if ( isset($content['PARSERS'][ $content['ParserID'] ]) )
$content['ReportID'] = DB_RemoveBadChars($_GET['id']);
if ( isset($content['REPORTS'][ $content['ReportID'] ]) )
{
// Get Reference to parser!
$myParser = $content['PARSERS'][ $content['ParserID'] ];
$myReport = $content['REPORTS'][ $content['ReportID'] ];
$content['DisplayName'] = $myParser['DisplayName'];
$content['Description'] = $myParser['Description'];
$content['DisplayName'] = $myReport['DisplayName'];
$content['Description'] = $myReport['Description'];
if ( strlen($myParser['ParserHelpArticle']) > 0 )
if ( strlen($myReport['ReportHelpArticle']) > 0 )
{
$content['EnableHelpArticle'] = true;
$content['ParserHelpArticle'] = $myParser['ParserHelpArticle'];
$content['ReportHelpArticle'] = $myReport['ReportHelpArticle'];
}
/*
// check for custom fields
if ( isset($myParser['CustomFieldsList']) && count($myParser['CustomFieldsList']) > 0 )
if ( isset($myReport['CustomFieldsList']) && count($myReport['CustomFieldsList']) > 0 )
{
// Needs custom fields!
$content['EnableCustomField'] = true;
@ -106,13 +107,14 @@ if ( isset($_GET['op']) )
}
}
}
*/
}
else
{
$content['ISSHOWDETAILS'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_PARSERS_ERROR_IDNOTFOUND'], $content['ParserID'] );
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_REPORTS_ERROR_IDNOTFOUND'], $content['ReportID'] );
}
}
else
@ -246,20 +248,21 @@ if ( isset($_GET['op']) )
// Default mode!
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
if ( isset($content['PARSERS']) )
if ( isset($content['REPORTS']) )
{
// Default Mode = List Searches
$content['LISTPARSERS'] = "true";
$content['LISTREPORTS'] = "true";
$i = 0; // Help counter!
foreach ($content['PARSERS'] as &$myParser )
foreach ($content['REPORTS'] as &$myReport )
{
// Set if help link is enabled
if ( strlen($myParser['ParserHelpArticle']) > 0 )
$myParser['ParserHelpEnabled'] = true;
if ( strlen($myReport['ReportHelpArticle']) > 0 )
$myReport['ReportHelpEnabled'] = true;
else
$myParser['ParserHelpEnabled'] = false;
$myReport['ReportHelpEnabled'] = false;
/*
// Find out if we need to INIT something!
if ( isset($myParser['CustomFieldsList']) && count($myParser['CustomFieldsList']) > 0 )
{
@ -278,28 +281,29 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
}
}
}
*/
// --- Set CSS Class
if ( $i % 2 == 0 )
$myParser['cssclass'] = "line1";
$myReport['cssclass'] = "line1";
else
$myParser['cssclass'] = "line2";
$myReport['cssclass'] = "line2";
$i++;
// ---
}
}
else
{
$content['LISTPARSERS'] = "false";
$content['LISTREPORTS'] = "false";
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_PARSERS_ERROR_NOPARSERS'];
$content['ERROR_MSG'] = $content['LN_REPORTS_ERROR_NOREPORTS'];
}
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_MSGPARSERSOPT'];
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_REEPORTSOPT'];
// --- END CREATE TITLE
// --- Parsen and Output

View File

@ -49,7 +49,8 @@ abstract class Report {
public $_reportVersion = 1; // Internally Version of the ReportEngine
public $_reportID = "report.syslog.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"
public $_reportDescription = "This is the base class for all reports";
public $_reportHelpArticle = "http://";
// Configuration Properties
protected $_filterString = "";

View File

@ -41,8 +41,8 @@ if ( !defined('IN_PHPLOGCON') )
}
// ---
// --- Required Includes!
require_once($gl_root_path . 'include/constants_errors.php');
// --- Basic Includes!
require_once($gl_root_path . 'classes/reports/report.class.php');
// ---
class Report_monilog extends Report {
@ -50,8 +50,8 @@ class Report_monilog extends Report {
public $_reportVersion = 1; // Internally Version of the ReportEngine
public $_reportID = "report.eventlog.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"
public $_reportDescription = "This is a EventLog Summary Report based on Monilog";
public $_reportHelpArticle = "";
/* private $_currentOffset = -1;
private $_currentStartPos = -1;

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 910 B

View File

@ -233,7 +233,7 @@ function InitMessageParsers()
if ( file_exists($szIncludeFile) )
{
// Try to include
if ( @include_once($szIncludeFile) !== false )
if ( include_once($szIncludeFile) )
{
// Set ParserClassName
$szParserClass = "MsgParser_" . $myParserID;
@ -272,12 +272,13 @@ function InitMessageParsers()
else
{
// DEBUG ERROR
OutputDebugMessage("FATAL Error in InitMessageParsers while including report file '" . $szIncludeFile . "' with error: '" . $php_errormsg . "'", DEBUG_ERROR);
OutputDebugMessage("InitMessageParsers: Failed including msgparser file '" . $szIncludeFile . "' with error: '" . $php_errormsg . "'", DEBUG_ERROR);
}
}
else
{
// DEBUG ERROR
OutputDebugMessage("InitMessageParsers: MsgParserfile '" . $szIncludeFile . "' does not exist!", DEBUG_ERROR);
}
}
}
@ -304,28 +305,26 @@ function InitReportModules()
$myReportCat = $out[1];
$myReportID = $out[2];
// Check if parser file include exists
$szIncludeFile = $szDirectory . $myFile;
if ( file_exists($szIncludeFile) )
{
// Try to include
if ( @include_once($szIncludeFile) !== false )
if ( include_once($szIncludeFile) )
{
// Set ParserClassName
$szReportClass = "Report_" . $myReportID;
echo $szReportClass . "!<br>";
exit;
// Create Instance and get properties
$tmpParser = new $szParserClass(); // Create an instance
$szParserName = $tmpParser->_ClassName;
$szParserDescription = $tmpParser->_ClassDescription;
$szParserHelpArticle = $tmpParser->_ClassHelpArticle;
$tmpReport = new $szReportClass(); // Create an instance
$szReportName = $tmpReport->_reportTitle;
$szReportDescription = $tmpReport->_reportDescription;
$szReportVersion= $tmpReport->_reportVersion;
$szReportHelpArticle = $tmpReport->_reportHelpArticle;
/*
// check for required fields!
if ( $tmpParser->_ClassRequiredFields != null && count($tmpParser->_ClassRequiredFields) > 0 )
if ( $tmpReport->_ClassRequiredFields != null && count($tmpParser->_ClassRequiredFields) > 0 )
{
$bCustomFields = true;
$aCustomFieldList = $tmpParser->_ClassRequiredFields;
@ -336,31 +335,39 @@ function InitReportModules()
$bCustomFields = false;
$aCustomFieldList = null;
}
*/
// Add entry to msg parser list!
$content['PARSERS'][$myParserID] = array (
"ID" => $myParserID,
"DisplayName" => $szParserName,
"Description" => $szParserDescription,
"CustomFields" => $bCustomFields,
"CustomFieldsList" => $aCustomFieldList,
"ParserHelpArticle" => $szParserHelpArticle,
// Add entry to report modules list!
$content['REPORTS'][$myReportID] = array (
"ID" => $myReportID,
"DisplayName" => $szReportName,
"Description" => $szReportDescription,
"ReportVersion" => $szReportVersion,
"ReportHelpArticle" => $szReportHelpArticle,
// "CustomFields" => $bCustomFields,
// "CustomFieldsList" => $aCustomFieldList,
);
}
else
{
// DEBUG ERROR
OutputDebugMessage("FATAL Error in InitReportModules while including report file '" . $szIncludeFile . "' with error: '" . $php_errormsg . "'", DEBUG_ERROR);
OutputDebugMessage("InitReportModules: Failed including report file '" . $szIncludeFile . "' with error: '" . $php_errormsg . "'", DEBUG_ERROR);
}
}
else
{
// DEBUG ERROR
OutputDebugMessage("InitReportModules: Reportfile '" . $szIncludeFile . "' does not exist!", DEBUG_ERROR);
}
}
}
}
// TODO: compare update report modules registered in database
}
/*

View File

@ -385,4 +385,26 @@ $content['LN_CMD_DELETINGOLDERTHEN'] = "Performing deletion of data entries olde
$content['LN_CMD_DELETEDROWS'] = "Successfully Deleted '%1' rows in the logstream source.'";
$content['LN_CMD_'] = "";
// Report Options
$content['LN_REPORTS_EDIT'] = "Edit Report";
$content['LN_REPORTS_DELETE'] = "Remove Report";
$content['LN_REPORTS_ID'] = "Report ID";
$content['LN_REPORTS_NAME'] = "Report Name";
$content['LN_REPORTS_DESCRIPTION'] = "Report Description";
$content['LN_REPORTS_ERROR_NOREPORTS'] = "There were no valid reports found in your installation.";
$content['LN_REPORTS_HELP'] = "Help";
$content['LN_REPORTS_HELP_CLICK'] = "Click here for more help";
$content['LN_REPORTS_INFO'] = "Show more Information for this report module.";
$content['LN_REPORTS_INIT'] = "Initialize settings for this report module.";
$content['LN_REPORTS_REMOVE'] = "Remove settings for this report module.";
$content['LN_REPORTS_ERROR_IDNOTFOUND'] = "There was no report with ID '%1' found.";
$content['LN_REPORTS_ERROR_INVALIDID'] = "Invalid report id.";
$content['LN_REPORTS_DETAILS'] = "Details for this report";
$content['LN_REPORTS_WARNREMOVE'] = "You are about to remove the custom settings needed by the '%1' report. However you can add these settings again if you change your mind.";
$content['LN_REPORTS_ERROR_HASBEENREMOVED'] = "All settings for the report '%1' have been removed.";
$content['LN_REPORTS_ERROR_HASBEENADDED'] = "All required settings for the report '%1' have been added.";
$content['LN_REPORTS_ERROR_NOFIELDS'] = "The report '%1' does not have any custom settings which can be added.";
$content['LN_REPORTS_'] = "";
?>

View File

@ -21,60 +21,60 @@
<td align="center" class="line2">
<br><br>
<!-- IF LISTPARSERS="true" -->
<!-- IF LISTREPORTS="true" -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="775" class="with_border_alternate">
<tr>
<td align="center" width="100" class="cellmenu1"><b>{LN_PARSERS_ID}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_PARSERS_NAME}</b></td>
<td align="center" width="300" class="cellmenu1"><b>{LN_PARSERS_DESCRIPTION}</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" colspan="3" nowrap><b>{LN_GEN_ACTIONS}</b></td>
</tr>
<!-- BEGIN PARSERS -->
<!-- BEGIN REPORTS -->
<tr>
<td align="left" class="{cssclass}" valign="top"><b>{ID}</b></td>
<td align="left" class="{cssclass}" valign="top"><a href="{BASEPATH}admin/parsers.php?op=details&id={ID}">{DisplayName}</a></td>
<td align="left" class="{cssclass}" valign="top"><a href="{BASEPATH}admin/reports.php?op=details&id={ID}">{DisplayName}</a></td>
<td align="left" class="{cssclass}" valign="top">{Description}</td>
<td align="center" class="{cssclass}">
<!-- IF ParserHelpEnabled="true" -->
<a href="{ParserHelpArticle}" target="_blank"><img src="{MENU_HELP}" width="16" title="{LN_PARSERS_HELP}"></a>
<!-- ENDIF ParserHelpEnabled="true" -->
<!-- IF ReportHelpEnabled="true" -->
<a href="{ReportHelpArticle}" target="_blank"><img src="{MENU_HELP}" width="16" title="{LN_REPORTS_HELP}"></a>
<!-- ENDIF ReportHelpEnabled="true" -->
</td>
<td align="center" class="{cssclass}">
<a href="{BASEPATH}admin/parsers.php?op=details&id={ID}"><img src="{MENU_INFORMATION}" width="16" title="{LN_PARSERS_INFO}"></a>
<a href="{BASEPATH}admin/reports.php?op=details&id={ID}"><img src="{MENU_INFORMATION}" width="16" title="{LN_REPORTS_INFO}"></a>
</td>
<td align="center" class="{cssclass}">
<!-- IF ParserInitEnabled="true" -->
&nbsp;<a href="{BASEPATH}admin/parsers.php?op=initparser&id={ID}"><img src="{MENU_PARSER_INIT}" width="16" title="{LN_PARSERS_INIT}"></a>
<!-- ENDIF ParserInitEnabled="true" -->
<!-- IF ParserDeleteEnabled="true" -->
&nbsp;<a href="{BASEPATH}admin/parsers.php?op=removeparser&id={ID}"><img src="{MENU_PARSER_DELETE}" width="16" title="{LN_PARSERS_REMOVE}"></a>
<!-- ENDIF ParserDeleteEnabled="true" -->
<!-- IF ReportInitEnabled="true" -->
&nbsp;<a href="{BASEPATH}admin/reports.php?op=initreport&id={ID}"><img src="{MENU_REPORT_INIT}" width="16" title="{LN_REPORTS_INIT}"></a>
<!-- ENDIF ReportInitEnabled="true" -->
<!-- IF ReportDeleteEnabled="true" -->
&nbsp;<a href="{BASEPATH}admin/reports.php?op=removereport&id={ID}"><img src="{MENU_REPORT_DELETE}" width="16" title="{LN_REPORTS_REMOVE}"></a>
<!-- ENDIF ReportDeleteEnabled="true" -->
</td>
</tr>
<!-- END PARSERS -->
<!-- END REPORTS -->
</table>
<!-- ENDIF LISTPARSERS="true" -->
<!-- ENDIF LISTREPORTS="true" -->
<!-- IF ISSHOWDETAILS="true" -->
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_PARSERS_DETAILS}</b></td>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_REPORTS_DETAILS}</b></td>
</tr>
<tr>
<td align="left" class="cellmenu2" width="250"><b>{LN_PARSERS_ID}</b></td>
<td align="left" class="line1" width="350">{ParserID}</td>
<td align="left" class="cellmenu2" width="250"><b>{LN_REPORTS_ID}</b></td>
<td align="left" class="line1" width="350">{ReportID}</td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_PARSERS_NAME}</b></td>
<td align="left" class="cellmenu2"><b>{LN_REPORTS_NAME}</b></td>
<td align="left" class="line2">{DisplayName}</td>
</tr>
<tr>
<td align="left" class="cellmenu2_naked" valign="top"><b>{LN_PARSERS_DESCRIPTION}</b></td>
<td align="left" class="cellmenu2_naked" valign="top"><b>{LN_REPORTS_DESCRIPTION}</b></td>
<td align="left" class="line1">{Description}</td>
</tr>
<!-- IF EnableCustomField="true" -->
<!-- IF EnableCustomSettings="true" -->
<tr>
<td align="left" class="cellmenu2_naked" valign="top"><b>{LN_PARSERS_CUSTOMFIELDS}</b></td>
<td align="left" class="cellmenu2_naked" valign="top"><b>{LN_REPORTS_CUSTOMSETTINGS}</b></td>
<td align="left" class="line1">
<!-- BEGIN CustomFieldsList -->
<br><B>{FieldCaption}</B> ({FieldDefine})
@ -82,21 +82,21 @@
<br><br>
</td>
</tr>
<!-- ENDIF EnableCustomField="true" -->
<!-- ENDIF EnableCustomSettings="true" -->
<!-- IF EnableHelpArticle="true" -->
<tr>
<td align="left" class="cellmenu2"><b>{LN_PARSERS_HELP}</b></td>
<td align="center" class="line2"><a href="{ParserHelpArticle}" target="_blank">{LN_PARSERS_HELP_CLICK}</a></td>
<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>
</tr>
<!-- ENDIF EnableHelpArticle="true" -->
<tr>
<td align="center" class="tableBackground" colspan="2">
<!-- IF ParserInitEnabled="true" -->
<a href="{BASEPATH}admin/parsers.php?op=initparser&id={ParserID}"><img src="{MENU_PARSER_INIT}" width="16" title="{LN_PARSERS_INIT}"> {LN_PARSERS_INIT}</a>
<!-- ENDIF ParserInitEnabled="true" -->
<!-- IF ParserDeleteEnabled="true" -->
<a href="{BASEPATH}admin/parsers.php?op=removeparser&id={ParserID}"><img src="{MENU_PARSER_DELETE}" width="16" title="{LN_PARSERS_REMOVE}"> {LN_PARSERS_REMOVE}</a>
<!-- ENDIF ParserDeleteEnabled="true" -->
<!-- IF ReportInitEnabled="true" -->
<a href="{BASEPATH}admin/reports.php?op=initreport&id={ReportID}"><img src="{MENU_PARSER_INIT}" width="16" title="{LN_REPORTS_INIT}"> {LN_REPORTS_INIT}</a>
<!-- ENDIF ReportInitEnabled="true" -->
<!-- IF ReportDeleteEnabled="true" -->
<a href="{BASEPATH}admin/reports.php?op=removereport&id={ReportID}"><img src="{MENU_PARSER_DELETE}" width="16" title="{LN_REPORTS_REMOVE}"> {LN_REPORTS_REMOVE}</a>
<!-- ENDIF ReportDeleteEnabled="true" -->
</td>
</tr>
</table>