diff --git a/src/chartgenerator.php b/src/chartgenerator.php index 804a244..31130a0 100644 --- a/src/chartgenerator.php +++ b/src/chartgenerator.php @@ -151,7 +151,7 @@ if ( !$content['error_occured'] ) // $graph->title->SetColor("darkred"); // Setup the tab title - $graph->tabtitle->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaptionID'] ] . '"'); + $graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_COUNTBY'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) ); $graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10); @@ -207,7 +207,7 @@ if ( !$content['error_occured'] ) // Setup the tab title - $graph->tabtitle->Set('Messagecount sorted by "' . $content[ $fields[$content['chart_field']]['FieldCaptionID'] ] . '"'); + $graph->tabtitle->Set( GetAndReplaceLangStr($content['LN_STATS_COUNTBY'], $content[ $fields[$content['chart_field']]['FieldCaptionID'] ]) ); $graph->tabtitle->SetFont(FF_ARIAL,FS_BOLD,10); // Setup the X and Y grid diff --git a/src/classes/logstreamdisk.class.php b/src/classes/logstreamdisk.class.php index 6b8eae8..3cbe96e 100644 --- a/src/classes/logstreamdisk.class.php +++ b/src/classes/logstreamdisk.class.php @@ -583,11 +583,17 @@ class LogStreamDisk extends LogStream { */ public function GetCountSortedByField($szFieldId, $nFieldType, $nRecordLimit) { + global $content; + // We loop through all loglines! this may take a while! $uID = UID_UNKNOWN; $ret = $this->ReadNext($uID, $logArray); if ( $ret == SUCCESS ) { + // Initialize Array variable + $aResult = array(); + + // Loop through messages do { if ( isset($logArray[$szFieldId]) ) @@ -595,7 +601,20 @@ class LogStreamDisk extends LogStream { if ( isset($aResult[ $logArray[$szFieldId] ]) ) $aResult[ $logArray[$szFieldId] ]++; else - $aResult[ $logArray[$szFieldId] ] = 1; + { + // Initialize entry if we haven't exceeded the RecordLImit yet! + if ( count($aResult) < $nRecordLimit ) + $aResult[ $logArray[$szFieldId] ] = 1; + else + { + // Count record to others + if ( isset($aResult[ $content['LN_STATS_OTHERS'] ]) ) + $aResult[ $content['LN_STATS_OTHERS'] ]++; + else + $aResult[ $content['LN_STATS_OTHERS'] ] = 1; + } + + } /* if ( isset($aResult[ $logArray[$szFieldId] ][CHARTDATA_COUNT]) ) $aResult[ $logArray[$szFieldId] ][CHARTDATA_COUNT]++; @@ -611,6 +630,14 @@ class LogStreamDisk extends LogStream { // Sort Array, so the highest count comes first! array_multisort($aResult, SORT_NUMERIC, SORT_DESC); + if ( isset($aResult[ $content['LN_STATS_OTHERS'] ]) ) + { + // This will move the "Others" Element to the last position! + $arrEntryCopy = $aResult[ $content['LN_STATS_OTHERS'] ]; + unset($aResult[ $content['LN_STATS_OTHERS'] ]); + $aResult[ $content['LN_STATS_OTHERS'] ] = $arrEntryCopy; + } + // finally return result! return $aResult; } diff --git a/src/lang/de/main.php b/src/lang/de/main.php index ed1e9ce..e2d82e0 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -280,8 +280,7 @@ $content['LN_DETAIL_BACKTOLIST'] = "Back to Listview"; $content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version."; // Stats Site - $content['LN_STATS_COUNTBYSOURCE'] = "Messagecount by Source"; - $content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag"; + $content['LN_STATS_COUNTBY'] = "Messagecount by '%1'"; $content['LN_STATS_GRAPH'] = "Graph"; $content['LN_GEN_ERROR_INVALIDFIELD'] = "Invalid fieldname"; $content['LN_GEN_ERROR_MISSINGCHARTFIELD'] = "Missing fieldname"; diff --git a/src/lang/en/main.php b/src/lang/en/main.php index 7aab70a..e68ff17 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -280,8 +280,9 @@ $content['LN_CONVERT_PROCESS'] = "Conversion Progress:"; $content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version."; // Stats Site - $content['LN_STATS_COUNTBYSOURCE'] = "Messagecount by Source"; - $content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag"; + $content['LN_STATS_COUNTBY'] = "Messagecount by '%1'"; + $content['LN_STATS_OTHERS'] = "All Others"; +// $content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag"; $content['LN_STATS_GRAPH'] = "Graph"; $content['LN_GEN_ERROR_INVALIDFIELD'] = "Invalid fieldname"; $content['LN_GEN_ERROR_MISSINGCHARTFIELD'] = "Missing fieldname"; diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index ed1bc6f..a44268b 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -285,8 +285,7 @@ $content['LN_DETAIL_BACKTOLIST'] = "Voltar para a lista"; $content['LN_CONVERT_ERROR_SOURCEIMPORT'] = "Critical Error while importing the sources into the database, the SourceType '%1' is not supported by this phpLogCon Version."; // Stats Site - $content['LN_STATS_COUNTBYSOURCE'] = "Messagecount by Source"; - $content['LN_STATS_COUNTBYSYSLOGTAG'] = "Messagecount by SyslogTag"; + $content['LN_STATS_COUNTBY'] = "Messagecount by '%1'"; $content['LN_STATS_GRAPH'] = "Graph"; $content['LN_GEN_ERROR_INVALIDFIELD'] = "Invalid fieldname"; $content['LN_GEN_ERROR_MISSINGCHARTFIELD'] = "Missing fieldname"; diff --git a/src/templates/statistics.html b/src/templates/statistics.html index 0556294..1d955b3 100644 --- a/src/templates/statistics.html +++ b/src/templates/statistics.html @@ -22,7 +22,7 @@ - +
{LN_STATS_GRAPH}: {LN_STATS_COUNTBYSOURCE}


@@ -32,7 +32,7 @@ - +
{LN_STATS_GRAPH}: {LN_STATS_COUNTBYSYSLOGTAG}