diff --git a/src/include/config.sample.php b/src/include/config.sample.php index 7477c83..d2191a2 100644 --- a/src/include/config.sample.php +++ b/src/include/config.sample.php @@ -99,10 +99,10 @@ $CFG['Search'][] = array ( "DisplayName" => "All messages from last 31 days", "S // --- // --- Predefined Charts! -$CFG['Charts'][] = array ( "DisplayName" => "Top Hosts", "chart_type" => CHART_BARS_HORIZONTAL, "chart_width" => 400, "chart_field" => SYSLOG_HOST, "maxrecords" => 10, "showpercent" => 0 ); -$CFG['Charts'][] = array ( "DisplayName" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0 ); -$CFG['Charts'][] = array ( "DisplayName" => "Severity Occurences", "chart_type" => CHART_BARS_VERTICAL, "chart_width" => 400, "chart_field" => SYSLOG_SEVERITY, "maxrecords" => 10, "showpercent" => 1 ); -$CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1 ); +$CFG['Charts'][] = array ( "DisplayName" => "Top Hosts", "chart_type" => CHART_BARS_HORIZONTAL, "chart_width" => 400, "chart_field" => SYSLOG_HOST, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 ); +$CFG['Charts'][] = array ( "DisplayName" => "SyslogTags", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_SYSLOGTAG, "maxrecords" => 10, "showpercent" => 0, "chart_enabled" => 1 ); +$CFG['Charts'][] = array ( "DisplayName" => "Severity Occurences", "chart_type" => CHART_BARS_VERTICAL, "chart_width" => 400, "chart_field" => SYSLOG_SEVERITY, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 ); +$CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHART_CAKE, "chart_width" => 400, "chart_field" => SYSLOG_DATE, "maxrecords" => 10, "showpercent" => 1, "chart_enabled" => 1 ); // --- // --- Source Options diff --git a/src/include/db_template.txt b/src/include/db_template.txt index b5a9ea3..654615f 100644 --- a/src/include/db_template.txt +++ b/src/include/db_template.txt @@ -114,10 +114,10 @@ CREATE TABLE IF NOT EXISTS `logcon_views` ( -- Table structure for table `logcon_charts` -- -DROP TABLE IF EXISTS `logcon_charts`; CREATE TABLE IF NOT EXISTS `logcon_charts` ( `ID` int(11) NOT NULL auto_increment, `DisplayName` varchar(255) NOT NULL, + `chart_enabled` tinyint(1) NOT NULL default '1', `chart_type` int(11) NOT NULL, `chart_width` int(11) NOT NULL, `chart_field` varchar(255) NOT NULL, @@ -127,3 +127,4 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` ( `groupid` int(11) default NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ; + diff --git a/src/include/db_update_v3.txt b/src/include/db_update_v3.txt index 3c7ccac..5c2df9e 100644 --- a/src/include/db_update_v3.txt +++ b/src/include/db_update_v3.txt @@ -2,6 +2,7 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` ( `ID` int(11) NOT NULL auto_increment, `DisplayName` varchar(255) NOT NULL, + `chart_enabled` tinyint(1) NOT NULL default '1', `chart_type` int(11) NOT NULL, `chart_width` int(11) NOT NULL, `chart_field` varchar(255) NOT NULL, @@ -13,5 +14,9 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` ( ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='This table contains all configured charts' AUTO_INCREMENT=1 ; -- Insert data +INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (1, 'Top Hosts', 1, 3, 400, 'FROMHOST', 10, 0, NULL, NULL); +INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (2, 'SyslogTags', 1, 1, 400, 'syslogtag', 10, 0, NULL, NULL); +INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (3, 'Severity Occurences', 1, 2, 400, 'syslogseverity', 10, 1, NULL, NULL); +INSERT INTO `logcon_charts` (`ID`, `DisplayName`, `chart_enabled`, `chart_type`, `chart_width`, `chart_field`, `maxrecords`, `showpercent`, `userid`, `groupid`) VALUES (4, 'Usage by Day', 1, 1, 400, 'timereported', 10, 1, NULL, NULL); -- Updated Data diff --git a/src/include/functions_config.php b/src/include/functions_config.php index 3d00a18..25386ee 100644 --- a/src/include/functions_config.php +++ b/src/include/functions_config.php @@ -417,6 +417,7 @@ function LoadChartsFromDatabase() $sqlquery = " SELECT " . DB_CHARTS . ".ID, " . DB_CHARTS . ".DisplayName, " . + DB_CHARTS . ".chart_enabled, " . DB_CHARTS . ".chart_type, " . DB_CHARTS . ".chart_width, " . DB_CHARTS . ".chart_field, " . diff --git a/src/include/functions_installhelpers.php b/src/include/functions_installhelpers.php index 59768d2..5a0882c 100644 --- a/src/include/functions_installhelpers.php +++ b/src/include/functions_installhelpers.php @@ -116,14 +116,15 @@ function ConvertCustomCharts() foreach($CFG['Charts'] as $chartid => &$myChart) { // New Entry - $result = DB_Query("INSERT INTO " . DB_CHARTS . " (DisplayName, chart_type, chart_width, chart_field, maxrecords, showpercent) + $result = DB_Query("INSERT INTO " . DB_CHARTS . " (DisplayName, chart_enabled, chart_type, chart_width, chart_field, maxrecords, showpercent) VALUES ( '" . PrepareValueForDB($myChart['DisplayName']) . "', - " . intval($mySearch['chart_type']) . ", - " . intval($mySearch['chart_width']) . ", - '" . PrepareValueForDB($mySearch['chart_field']) . "', - " . intval($mySearch['maxrecords']) . ", - " . intval($mySearch['showpercent']) . " + " . intval($myChart['chart_enabled']) . ", + " . intval($myChart['chart_type']) . ", + " . intval($myChart['chart_width']) . ", + '" . PrepareValueForDB($myChart['chart_field']) . "', + " . intval($myChart['maxrecords']) . ", + " . intval($myChart['showpercent']) . " )"); $myChart['DBID'] = DB_ReturnLastInsertID($result); DB_FreeQuery($result); diff --git a/src/statistics.php b/src/statistics.php index 4fd6d39..0277423 100644 --- a/src/statistics.php +++ b/src/statistics.php @@ -63,53 +63,57 @@ if ( isset($content['Charts']) ) $i = 0; // Help counter! foreach ($content['Charts'] as &$myChart ) { - // --- Set display name for chart type - switch($myChart['chart_type']) + // Only process if chart is enabled + if ( isset($myChart['chart_enabled']) && $myChart['chart_enabled'] == 1 ) { - case CHART_CAKE: - $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_CAKE']; - break; - case CHART_BARS_VERTICAL: - $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_VERTICAL']; - break; - case CHART_BARS_HORIZONTAL: - $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_HORIZONTAL']; - break; - default: - $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_GEN_ERROR_INVALIDTYPE']; - break; - } - // --- + // --- Set display name for chart type + switch($myChart['chart_type']) + { + case CHART_CAKE: + $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_CAKE']; + break; + case CHART_BARS_VERTICAL: + $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_VERTICAL']; + break; + case CHART_BARS_HORIZONTAL: + $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_CHART_TYPE_BARS_HORIZONTAL']; + break; + default: + $myChart['CHART_TYPE_DISPLAYNAME'] = $content['LN_GEN_ERROR_INVALIDTYPE']; + break; + } + // --- - // --- Set display name for chart field - if ( isset($myChart['chart_field']) && isset($content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]) ) - $myChart['CHART_FIELD_DISPLAYNAME'] = $content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]; - else - $myChart['CHART_FIELD_DISPLAYNAME'] = $myChart['chart_field']; - // --- + // --- Set display name for chart field + if ( isset($myChart['chart_field']) && isset($content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]) ) + $myChart['CHART_FIELD_DISPLAYNAME'] = $content[ $fields[$myChart['chart_field']]['FieldCaptionID'] ]; + else + $myChart['CHART_FIELD_DISPLAYNAME'] = $myChart['chart_field']; + // --- - // --- Set showpercent display - if ( $myChart['showpercent'] == 1 ) - $myChart['showpercent_display'] = "Yes"; - else - $myChart['showpercent_display'] = "No"; - // --- + // --- Set showpercent display + if ( $myChart['showpercent'] == 1 ) + $myChart['showpercent_display'] = "Yes"; + else + $myChart['showpercent_display'] = "No"; + // --- - // --- Set CSS Class - if ( $i % 2 == 0 ) - { - $myChart['cssclass'] = "line1"; - $myChart['rowbegin'] = ''; - $myChart['rowend'] = ''; + // --- Set CSS Class + if ( $i % 2 == 0 ) + { + $myChart['cssclass'] = "line1"; + $myChart['rowbegin'] = ''; + $myChart['rowend'] = ''; + } + else + { + $myChart['cssclass'] = "line2"; + $myChart['rowbegin'] = ''; + $myChart['rowend'] = ''; + } + $i++; + // --- } - else - { - $myChart['cssclass'] = "line2"; - $myChart['rowbegin'] = ''; - $myChart['rowend'] = ''; - } - $i++; - // --- } } @@ -137,5 +141,7 @@ $page -> parser($content, "statistics.html"); $page -> output(); // --- +//include($gl_root_path . 'include/functions_installhelpers.php'); +//ConvertCustomCharts(); ?> \ No newline at end of file diff --git a/src/templates/statistics.html b/src/templates/statistics.html index 35cf859..ec067f5 100644 --- a/src/templates/statistics.html +++ b/src/templates/statistics.html @@ -24,6 +24,7 @@ + {rowbegin}

@@ -54,6 +55,7 @@


{rowend} +