From 89b277d3d44162ebcc7f9a8d5b010919682ead4d Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Thu, 7 Jan 2010 16:38:58 +0100 Subject: [PATCH] Renamed monilog report into eventsummary report Also added function to read and list available reports from an online xml file --- src/admin/reports.php | 194 +++++++++++++++++- ...=> report.eventlog.eventsummary.class.php} | 16 +- .../report.eventlog.eventsummary.css} | 0 .../report.eventlog.eventsummary.lang.en.php} | 0 ...eport.eventlog.eventsummary.template.html} | 0 ...report.eventlog.eventsummary.template.pdf} | 0 src/images/icons/documents.png | Bin 0 -> 569 bytes src/images/icons/windows.png | Bin 0 -> 540 bytes src/include/functions_common.php | 3 + src/lang/en/admin.php | 4 + src/templates/admin/admin_reports.html | 78 +++++-- 11 files changed, 267 insertions(+), 28 deletions(-) rename src/classes/reports/{report.eventlog.monilog.class.php => report.eventlog.eventsummary.class.php} (96%) rename src/classes/reports/{report.eventlog.monilog/report.eventlog.monilog.css => report.eventlog.eventsummary/report.eventlog.eventsummary.css} (100%) rename src/classes/reports/{report.eventlog.monilog/report.eventlog.monilog.lang.en.php => report.eventlog.eventsummary/report.eventlog.eventsummary.lang.en.php} (100%) rename src/classes/reports/{report.eventlog.monilog/report.eventlog.monilog.template.html => report.eventlog.eventsummary/report.eventlog.eventsummary.template.html} (100%) rename src/classes/reports/{report.eventlog.monilog/report.eventlog.monilog.template.pdf => report.eventlog.eventsummary/report.eventlog.eventsummary.template.pdf} (100%) create mode 100644 src/images/icons/documents.png create mode 100644 src/images/icons/windows.png diff --git a/src/admin/reports.php b/src/admin/reports.php index 87fcef2..f2935f7 100644 --- a/src/admin/reports.php +++ b/src/admin/reports.php @@ -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 ?> \ No newline at end of file diff --git a/src/classes/reports/report.eventlog.monilog.class.php b/src/classes/reports/report.eventlog.eventsummary.class.php similarity index 96% rename from src/classes/reports/report.eventlog.monilog.class.php rename to src/classes/reports/report.eventlog.eventsummary.class.php index aaafec3..2163e89 100644 --- a/src/classes/reports/report.eventlog.monilog.class.php +++ b/src/classes/reports/report.eventlog.eventsummary.class.php @@ -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 diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.css b/src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.css similarity index 100% rename from src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.css rename to src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.css diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.lang.en.php b/src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.lang.en.php similarity index 100% rename from src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.lang.en.php rename to src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.lang.en.php diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html b/src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.template.html similarity index 100% rename from src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.html rename to src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.template.html diff --git a/src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.pdf b/src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.template.pdf similarity index 100% rename from src/classes/reports/report.eventlog.monilog/report.eventlog.monilog.template.pdf rename to src/classes/reports/report.eventlog.eventsummary/report.eventlog.eventsummary.template.pdf diff --git a/src/images/icons/documents.png b/src/images/icons/documents.png new file mode 100644 index 0000000000000000000000000000000000000000..dccd69c160541abd706db2f457ad5691e8af9ca3 GIT binary patch literal 569 zcmV-90>=G`P)WdKcYATc!{L3L*!GB7YTATcpIGch_bG$1Q5F)%RM{uz1z000McNliru z)&&<0F*%$asVx8i010qNS#tmY3h)2`3h)6!tTdPa000DMK}|sb0I`n?{9y$E00EIn zL_t(|+KrOCN&`U@hEI|WSeSS#ObXFTtWs$nKoAiu^#ue?6^T_8qJjx(Wg~)G1Un;I zD5S8m_93j)!dM2;z0UZby_pRe^}xS7J2U6Zf4KD51)aV}JO;W78Jyxc%`-x%}KdhSN}5S->#N z$OM9wp2|bRP^?2?Xe32=x`UyRUXjM_BV{sKsvb8hU{g`C(RhKwaHN~; z;NkdPl?(F`cN^6PO-|*`z-Hv3S--&4dt3<50iPZu3%L0&oA{S*gbqx|a)s}|*~~yg zT2R1-6Dd6gEEStnx}R*@ZF>MpYRM$g`flAj!?*9QrUrYmakxFVly@82No{ok?*l^K+jpy!%j|R1%8>p|NWdKBJAT%INa(W;#FfcP9FfckYG&(ReAS*C2FfiRo4vqi-00(qQO+^RR z1s4r84Zz;1-2eap32;bRa{vGe@Bjb`@Bu=sG?)MY00d`2O+f$vv5yPyuM6JX-GwA982$QhT7q_op+IN!AsT!-(KNdT4?mNC{XE zHhy~;MmrY}^!snv>be}lddz8p!5}T*y82QFGcl9M&L|YU zn@P+v6NejZ9+3L7u`iVc@};5?L#Zr5G@3kJr=o|nEXkZCWZ8~bgK<1rpOboUk^~#{ zT8ko0DrehCu1Y2`Ina8npXUzJLA6QiJ2z}(t`-Q@_>aq?bjDPie8*4E2Cya$p+c}R e-AEzySif&fCb(;=PCZWm0000 - {LN_ADMINMENU_REEPORTSOPT} + {LN_ADMINMENU_REEPORTSOPT}{OPTIONAL_TITLE}

+ + + + + + + +
{LN_REPORTMENU_LIST}{LN_REPORTMENU_ONLINELIST} 
+ @@ -71,34 +80,67 @@ -
- - + +
- + + + + + + + + + + + + + +
{LN_REPORTS_DETAILS}{LN_REPORTS_ID}{LN_REPORTS_NAME}{LN_REPORTS_DESCRIPTION}{LN_REPORTS_LINKS}
{reportid}{reportname}{reportdescription} +   + + +    + + + + +   + + +   + + +
+ + + + + + - + - + - + - + @@ -113,12 +155,12 @@ -
{LN_REPORTS_DETAILS}
{LN_REPORTS_ID}{ReportID}{ReportID}
{LN_REPORTS_NAME}{DisplayName}{DisplayName}
{LN_REPORTS_DESCRIPTION}{Description}{Description}
{LN_REPORTS_HELP}{LN_REPORTS_HELP_CLICK}{LN_REPORTS_HELP_CLICK}
- - + + @@ -127,16 +169,14 @@ {customTitle} -
{LN_REPORTS_SAVEDREPORTS}{LN_REPORTS_SAVEDREPORTS} +
-   +       -
- +

{LN_GEN_ERRORRETURNPREV} @@ -176,7 +216,7 @@ - +
@@ -293,7 +333,7 @@
{LN_REPORTS_ADDSAVEDREPORT}: '{DisplayName}'
- +
{LN_REPORTS_OUTPUTTARGET_FILE} @@ -303,7 +343,7 @@
- +
{LN_REPORTS_CRONCMD}