diff --git a/src/chartgenerator.php b/src/chartgenerator.php new file mode 100644 index 0000000..a1dd9b8 --- /dev/null +++ b/src/chartgenerator.php @@ -0,0 +1,230 @@ + This file will create gfx of charts, and handle image caching + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Include LogStream facility +include($gl_root_path . 'classes/logstream.class.php'); + +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! +// --- + +// --- READ CONTENT Vars +if ( isset($_GET['type']) ) + $content['chart_type'] = intval($_GET['type']); +else + $content['chart_type'] = CHART_CAKE; + +if ( isset($_GET['width']) ) + $content['chart_width'] = intval($_GET['width']); +else + $content['chart_width'] = 100; + +if ( isset($_GET['byfield']) ) + $content['chart_field'] = $_GET['byfield']; +else +{ + $content['error_occured'] = true; + $content['error_details'] = $content['LN_GEN_ERROR_MISSINGCHARTFIELD']; +} +// --- + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); +// --- END CREATE TITLE + +// --- BEGIN Custom Code +if ( !$content['error_occured'] ) +{ + if ( isset($content['Sources'][$currentSourceID]) ) + { + // Obtain and get the Config Object + $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; + + // Create LogStream Object + $stream = $stream_config->LogStreamFactory($stream_config); + + $res = $stream->Open( $content['Columns'], true ); + if ( $res == SUCCESS ) + { + + + + } + else + { + // This will disable to Main SyslogView and show an error message + $content['error_occured'] = true; + $content['error_details'] = GetErrorMessage($res); + if ( isset($extraErrorDescription) ) + $content['error_details'] .= "

" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription); + } + + // Close file! + $stream->Close(); + } + else + { + $content['error_occured'] = true; + $content['error_details'] = GetAndReplaceLangStr( $content['LN_GEN_ERROR_SOURCENOTFOUND'], $currentSourceID); + } +} +// --- + +// --- Convert and Output +if ( $content['error_occured'] ) +{ + // TODO PRINT ERROR ON PICTURE STREAM! + +// InitTemplateParser(); +// $page -> parser($content, "export.html"); +// $page -> output(); +} +else +{ + // Create ChartDiagram! + + exit; + + // Create a CVS File! + $szOutputContent = ""; + $szOutputMimeType = "text/plain"; + $szOutputCharset = ""; + + $szOutputFileName = "ExportMessages"; + $szOutputFileExtension = ".txt"; + if ( $content['exportformat'] == EXPORT_CVS ) + { + // Set MIME TYPE and File Extension + $szOutputMimeType = "text/csv"; + $szOutputFileExtension = ".csv"; + + // Set Column line in cvs file! + foreach($content['Columns'] as $mycolkey) + { + if ( isset($fields[$mycolkey]) ) + { + // Prepend Comma if needed + if (strlen($szOutputContent) > 0) + $szOutputContent .= ","; + + // Append column name + $szOutputContent .= $content[ $fields[$mycolkey]['FieldCaptionID'] ]; + } + } + + // Append line break + $szOutputContent .= "\n"; + + // Append messages into output + foreach ( $content['syslogmessages'] as $myIndex => $mySyslogMessage ) + { + $szLine = ""; + + // --- Process columns + foreach($mySyslogMessage as $myColkey => $mySyslogField) + { + // Prepend Comma if needed + if (strlen($szLine) > 0) + $szLine .= ","; + + // Append field contents + $szLine .= '"' . str_replace('"', '\\"', $mySyslogField['fieldvalue']) . '"'; + } + // --- + + // Append line! + $szOutputContent .= $szLine . "\n"; + } + } + else if ( $content['exportformat'] == EXPORT_XML ) + { + // Set MIME TYPE and File Extension + $szOutputMimeType = "application/xml"; + $szOutputFileExtension = ".xml"; + $szOutputCharset = "charset=UTF-8"; + + // Create XML Header and first node!! + $szOutputContent .= "\xef\xbb\xbf"; + $szOutputContent .= "\n"; + $szOutputContent .= "\n"; + + // Append messages into output + foreach ( $content['syslogmessages'] as $myIndex => $mySyslogMessage ) + { + $szXmlLine = "\t\n"; + + // --- Process columns + foreach($mySyslogMessage as $myColkey => $mySyslogField) + { + +// if ( isset($content[ $fields[$mycolkey]['FieldCaptionID'] ]) ) +// $szNodeTitle = $content[ $fields[$mycolkey]['FieldCaptionID'] ]; +// else + + // Append field content | first run htmlentities,tnen utf8 encoding!! + $szXmlLine .= "\t\t<" . $myColkey . ">" . utf8_encode( htmlentities($mySyslogField['fieldvalue']) ) . "\n"; + } + // --- + + $szXmlLine .= "\t\n"; + + // Append line! + $szOutputContent .= $szXmlLine; + } + + // End first XML Node + $szOutputContent .= ""; + } + + // Set needed Header properties + header('Content-type: ' . $szOutputMimeType . "; " . $szOutputCharset); + header("Content-Length: " . strlen($szOutputContent) ); + header('Content-Disposition: attachment; filename="' . $szOutputFileName . $szOutputFileExtension . '"'); + + // Output Content! + print( $szOutputContent ); +} +// --- + +?> \ No newline at end of file diff --git a/src/details.php b/src/details.php index 737e086..aca7f12 100644 --- a/src/details.php +++ b/src/details.php @@ -348,12 +348,11 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current' $content['error_code'] = $ret; if ( $ret == ERROR_FILE_NOT_FOUND ) - $content['detailederror'] = "Syslog file could not be found."; + $content['detailederror'] = $content['LN_ERROR_FILE_NOT_FOUND']; else if ( $ret == ERROR_FILE_NOT_READABLE ) - $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; + $content['detailederror'] = $content['LN_ERROR_FILE_NOT_READABLE']; else - $content['detailederror'] = "Unknown or unhandeled error occured."; - + $content['detailederror'] = $content['LN_ERROR_UNKNOWN']; } // Close file! diff --git a/src/include/constants_general.php b/src/include/constants_general.php index 9ce4070..3421475 100644 --- a/src/include/constants_general.php +++ b/src/include/constants_general.php @@ -74,6 +74,12 @@ define('EXPORT_CVS', 'CVS'); define('EXPORT_XML', 'XML'); // --- +// --- GFX Chart Types +define('CHART_CAKE', 1); +define('CHART_BARS_VERTICAL', 2); +define('CHART_BARS_HORIZONTAL', 3); +// --- + // --- define('UID_UNKNOWN', -1); // --- diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 7750d07..809654d 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -482,6 +482,7 @@ function InitFrontEndVariables() $content['MENU_NORMAL'] = $content['BASEPATH'] . "images/icons/table_selection_block.png"; $content['MENU_USEROPTIONS'] = $content['BASEPATH'] . "images/icons/businessman_preferences.png"; $content['MENU_EXPORT'] = $content['BASEPATH'] . "images/icons/export1.png"; + $content['MENU_CHARTS'] = $content['BASEPATH'] . "images/icons/line-chart.png"; $content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png"; $content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png"; diff --git a/src/lang/de/main.php b/src/lang/de/main.php index 65925fd..423cb00 100644 --- a/src/lang/de/main.php +++ b/src/lang/de/main.php @@ -98,6 +98,7 @@ $content['LN_MENU_LOGOFF'] = "Logoff"; $content['LN_MENU_LOGGEDINAS'] = "Logged in as"; $content['LN_MENU_MAXVIEW'] = "Maximize View"; $content['LN_MENU_NORMALVIEW'] = "Normalize View"; + $content['LN_MENU_STATISTICS'] = "Statistics"; // Index Site diff --git a/src/lang/en/main.php b/src/lang/en/main.php index 5294703..888645b 100644 --- a/src/lang/en/main.php +++ b/src/lang/en/main.php @@ -98,6 +98,7 @@ $content['LN_MENU_LOGOFF'] = "Logoff"; $content['LN_MENU_LOGGEDINAS'] = "Logged in as"; $content['LN_MENU_MAXVIEW'] = "Maximize View"; $content['LN_MENU_NORMALVIEW'] = "Normalize View"; + $content['LN_MENU_STATISTICS'] = "Statistics"; // Main Index Site $content['LN_ERROR_INSTALLFILEREMINDER'] = "Warning! You still have NOT removed the 'install.php' from your phpLogCon main directory!"; @@ -278,5 +279,9 @@ $content['LN_CONVERT_STEP6_TEXT'] = 'Congratulations! You have successfully conv $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_GRAPH'] = "Graph"; + ?> \ No newline at end of file diff --git a/src/lang/pt_BR/main.php b/src/lang/pt_BR/main.php index 69680c7..4300dac 100644 --- a/src/lang/pt_BR/main.php +++ b/src/lang/pt_BR/main.php @@ -103,6 +103,7 @@ $content['LN_ERROR_NORECORDS'] = "Sem mensagens encontradas."; $content['LN_MENU_LOGGEDINAS'] = "Logged in as"; $content['LN_MENU_MAXVIEW'] = "Maximize View"; $content['LN_MENU_NORMALVIEW'] = "Normalize View"; + $content['LN_MENU_STATISTICS'] = "Statistics"; // Main Index Site $content['LN_ERROR_INSTALLFILEREMINDER'] = "Atenção! Você ainda NÃO removeu o arquivo 'install.php' do diretório de seu phpLogCon!"; diff --git a/src/statistics.php b/src/statistics.php new file mode 100644 index 0000000..3de9ebc --- /dev/null +++ b/src/statistics.php @@ -0,0 +1,109 @@ + Shows Statistic, Charts and more + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +// Include LogStream facility +include($gl_root_path . 'classes/logstream.class.php'); + +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! +// --- + +// --- CONTENT Vars +// --- + +// --- BEGIN Custom Code +/*if ( isset($content['Sources'][$currentSourceID]) ) +{ + // Obtain and get the Config Object + $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; + + // Create LogStream Object + $stream = $stream_config->LogStreamFactory($stream_config); + $res = $stream->Open( $content['AllColumns'], true ); + if ( $res == SUCCESS ) + { + // This will enable to Stats View + $content['statsenabled'] = "true"; + + + + } + else + { + // This will disable to Stats View and show an error message + $content['statsenabled'] = "false"; + + // Set error code + $content['error_code'] = $ret; + + if ( $ret == ERROR_FILE_NOT_FOUND ) + $content['detailederror'] = $content['LN_ERROR_FILE_NOT_FOUND']; + else if ( $ret == ERROR_FILE_NOT_READABLE ) + $content['detailederror'] = $content['LN_ERROR_FILE_NOT_READABLE']; + else + $content['detailederror'] = $content['LN_ERROR_UNKNOWN']; + } + + // Close file! + $stream->Close(); +} +*/ + +// --- + +// --- BEGIN CREATE TITLE +$content['TITLE'] = InitPageTitle(); + +// Append custom title part! +$content['TITLE'] .= " :: " . $content['LN_MENU_STATISTICS']; +// --- END CREATE TITLE + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "statistics.html"); +$page -> output(); +// --- + + +?> \ No newline at end of file diff --git a/src/templates/include_menu.html b/src/templates/include_menu.html index 25cc2dd..409b5bb 100644 --- a/src/templates/include_menu.html +++ b/src/templates/include_menu.html @@ -1,13 +1,14 @@ - + + - + diff --git a/src/templates/statistics.html b/src/templates/statistics.html new file mode 100644 index 0000000..8a0be3b --- /dev/null +++ b/src/templates/statistics.html @@ -0,0 +1,37 @@ + + + +

+
+
+
{LN_GEN_ERRORDETAILS}
+

{ERROR_MSG}

+
+

+
+

+ + +
{LN_MENU_SEARCH}{LN_MENU_SEARCH} {LN_MENU_SHOWEVENTS}{LN_MENU_STATISTICS} {LN_MENU_HELP}{LN_MENU_HELP} {LN_MENU_SEARCHINKB}
+ + + + + + + +
{LN_MENU_STATISTICS}
+

+ + + + +
{LN_STATS_GRAPH}: {LN_STATS_COUNTBYSOURCE}
+ + +

+
+ +
+ + \ No newline at end of file