diff --git a/src/admin/sources.php b/src/admin/sources.php
index b1539ec..fd251fb 100644
--- a/src/admin/sources.php
+++ b/src/admin/sources.php
@@ -290,9 +290,57 @@ if ( isset($_GET['op']) )
}
else
{
+ // Include LogStream facility
+ include($gl_root_path . 'classes/logstream.class.php');
+
+ // --- Init the source
+ $tmpSource = $content['Sources'][ $content['SOURCEID'] ];
+ // Copy some default properties
+ $content['DisplayName'] = $tmpSource['Name'];
+ $content['SourceType'] = $tmpSource['SourceType'];
+ CreateSourceTypesList($content['SourceType']);
+ $content['SourceTypeName'] = $content['SOURCETYPES'][ $content['SourceType'] ]['DisplayName'];
+ // Fix Filename manually for FILE LOGSTREAM!
+ if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
+ {
+ // Create LogStream Object
+ $stream = $tmpSource['ObjRef']->LogStreamFactory($tmpSource['ObjRef']);
+ $res = $stream->Verify();
+ if ( $res != SUCCESS )
+ {
+ $content['ISERROR'] = true;
+ $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_WITHINSOURCE'], $tmpSource['Name'], GetErrorMessage($res) );
+ if ( isset($extraErrorDescription) )
+ $content['ERROR_MSG'] .= "
" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
+ }
+ else
+ {
+ // Display Stats
+ $content['ISCLEARDATA'] = true;
+ // Gather Database Stats
+ $content['ROWCOUNT'] = $stream->GetLogStreamTotalRowCount();
+ if ( isset($content['ROWCOUNT']) )
+ {
+ // Allow Deleting by Date
+ $content['DELETE_ALLOWDETAIL'] = true;
+
+ // Create Lists
+ CreateOlderThanList( 3600 );
+ CreateOlderDateFields();
+
+ }
+ else
+ $content['ROWCOUNT'] = "Unknown";
+ }
+ }
+ else
+ {
+ $content['ISERROR'] = true;
+ $content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_NOCLEARSUPPORT'], $content['SOURCEID'] );
+ }
}
}
else if ($_GET['op'] == "dbstats")
@@ -347,6 +395,7 @@ if ( isset($_GET['op']) )
$content['STATS'] = $stream->GetLogStreamStats();
if ( isset($content['STATS']) )
{
+ // Display Stats
$content['ISSTATS'] = true;
foreach( $content['STATS'] as &$myStats )
@@ -791,6 +840,65 @@ function ReadMsgParserList()
{
global $gl_root_path, $content;
}
+
+/*
+* Helper function to create a OlderThan Listbox
+*/
+function CreateOlderThanList( $nDefaultSeconds )
+{
+ global $content;
+
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "1 minute", 'OlderThanSeconds' => 60 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "5 minutes", 'OlderThanSeconds' => 300 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "15 minutes", 'OlderThanSeconds' => 900 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "30 minutes", 'OlderThanSeconds' => 1800 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "1 hour", 'OlderThanSeconds' => 3600 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "12 hours", 'OlderThanSeconds' => 43200 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "1 day", 'OlderThanSeconds' => 86400 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "7 days", 'OlderThanSeconds' => 604800 );
+ $content['OLDERTHAN'][] = array( 'OlderThanDisplayName' => "31 days", 'OlderThanSeconds' => 2678400 );
+
+ foreach ( $content['OLDERTHAN'] as &$myTime )
+ {
+ if ( $nDefaultSeconds == $myTime['OlderThanSeconds'] )
+ $myTime['selected'] = "selected";
+ else
+ $myTime['selected'] = "";
+ }
+}
+
+/*
+* Helper function to create a OlderThan Listbox
+*/
+function CreateOlderDateFields()
+{
+ global $content;
+
+ $currentTime = time();
+ $currentDay = date("d", $currentTime);
+ $currentMonth = date("m", $currentTime);
+ $currentYear = date("Y", $currentTime);
+
+ // Init Year, month and day array!
+ for ( $i = $currentYear-5; $i <= $currentYear+5; $i++ )
+ {
+ $content['olderdate_years'][$i]['value'] = $i;
+ if ( $i == $currentYear ) { $content['olderdate_years'][$i]['selected'] = "selected"; } else { $content['olderdate_years'][$i]['selected'] = ""; }
+ }
+ for ( $i = 1; $i <= 12; $i++ )
+ {
+ $content['olderdate_months'][$i]['value'] = $i;
+ if ( $i == $currentMonth ) { $content['olderdate_months'][$i]['selected'] = "selected"; } else { $content['olderdate_months'][$i]['selected'] = ""; }
+ }
+ for ( $i = 1; $i <= 31; $i++ )
+ {
+ $content['olderdate_days'][$i]['value'] = $i;
+ if ( $i == $currentDay ) { $content['olderdate_days'][$i]['selected'] = "selected"; } else { $content['olderdate_days'][$i]['selected'] = ""; }
+ }
+
+
+}
+
// --- END Custom Code
// --- BEGIN CREATE TITLE
diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php
index 4a0c704..9b439ac 100644
--- a/src/classes/logstream.class.php
+++ b/src/classes/logstream.class.php
@@ -219,6 +219,11 @@ abstract class LogStream {
public abstract function GetLogStreamStats();
+ /**
+ * This returns just the count of records of the main data source
+ */
+ public abstract function GetLogStreamTotalRowCount();
+
/*
* Helper functino to trigger initialisation of MsgParsers
*/
diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php
index f2faea1..270a09b 100644
--- a/src/classes/logstreamdb.class.php
+++ b/src/classes/logstreamdb.class.php
@@ -597,6 +597,44 @@ class LogStreamDB extends LogStream {
}
+ /**
+ * Implementation of GetLogStreamTotalRowCount
+ *
+ * Returns the total amount of rows in the main datatable
+ */
+ public function GetLogStreamTotalRowCount()
+ {
+ global $querycount, $dbmapping;
+ $szTableType = $this->_logStreamConfigObj->DBTableType;
+
+ // Set default rowcount
+ $rowcount = null;
+
+ // Perform if Connection is true!
+ if ( $this->_dbhandle != null )
+ {
+ // SHOW TABLE STATUS FROM
+ $szSql = "SELECT count(" . $dbmapping[$szTableType][SYSLOG_UID] . ") as Counter FROM " . $this->_logStreamConfigObj->DBTableName;
+ $myQuery = mysql_query($szSql, $this->_dbhandle);
+ if ($myQuery)
+ {
+ // Obtain RowCount!
+ $myRow = mysql_fetch_row($myQuery);
+ $rowcount = $myRow[0];
+
+ // Free query now
+ mysql_free_result ($myQuery);
+
+ // Increment for the Footer Stats
+ $querycount++;
+ }
+ }
+
+ //return result
+ return $rowcount;
+ }
+
+
/**
* Implementation of GetCountSortedByField
*
diff --git a/src/lang/de/admin.php b/src/lang/de/admin.php
index c1bb8a6..84ea314 100644
--- a/src/lang/de/admin.php
+++ b/src/lang/de/admin.php
@@ -235,6 +235,12 @@ $content['LN_SOURCES_STATSVALUE'] = "Value";
$content['LN_SOURCES_DETAILS'] = "Details for this logstream source";
$content['LN_SOURCES_STATSDETAILS'] = "Statistic details for this logstream source";
$content['LN_SOURCES_ERROR_NOSTATSDATA'] = "Could not find or obtain any stats related information for this logstream source.";
+$content['LN_SOURCES_ERROR_NOCLEARSUPPORT'] = "This logstream source does not support deleting data.";
+$content['LN_SOURCES_ROWCOUNT'] = "Total Rowcount";
+$content['LN_SOURCES_CLEAR_HELPTEXT'] = "Attention! Be carefull with deleting data, any action performed here can not be undone!";
+$content['LN_SOURCES_CLEARSINCE'] = "Clear all data older than ... ";
+$content['LN_SOURCES_CLEARDATE'] = "Clear all data which is older than ... ";
+$content['LN_SOURCES_CLEARDATA_SEND'] = "Clear selected data range";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";
diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php
index 1eabfd0..311618f 100644
--- a/src/lang/en/admin.php
+++ b/src/lang/en/admin.php
@@ -237,7 +237,15 @@ $content['LN_SOURCES_STATSVALUE'] = "Value";
$content['LN_SOURCES_DETAILS'] = "Details for this logstream source";
$content['LN_SOURCES_STATSDETAILS'] = "Statistic details for this logstream source";
$content['LN_SOURCES_ERROR_NOSTATSDATA'] = "Could not find or obtain any stats related information for this logstream source.";
-
+$content['LN_SOURCES_ERROR_NOCLEARSUPPORT'] = "This logstream source does not support deleting data.";
+$content['LN_SOURCES_ROWCOUNT'] = "Total Rowcount";
+$content['LN_SOURCES_CLEARDATA'] = "The following database maintenance Options are available";
+$content['LN_SOURCES_CLEAROPTIONS'] = "Select how you want to clear data.";
+$content['LN_SOURCES_CLEARALL'] = "Clear (Delete) all data.";
+$content['LN_SOURCES_CLEAR_HELPTEXT'] = "Attention! Be carefull with deleting data, any action performed here can not be undone!";
+$content['LN_SOURCES_CLEARSINCE'] = "Clear all data older than ... ";
+$content['LN_SOURCES_CLEARDATE'] = "Clear all data which is older than ... ";
+$content['LN_SOURCES_CLEARDATA_SEND'] = "Clear selected data range";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";
diff --git a/src/lang/pt_BR/admin.php b/src/lang/pt_BR/admin.php
index c1bb8a6..84ea314 100644
--- a/src/lang/pt_BR/admin.php
+++ b/src/lang/pt_BR/admin.php
@@ -235,6 +235,12 @@ $content['LN_SOURCES_STATSVALUE'] = "Value";
$content['LN_SOURCES_DETAILS'] = "Details for this logstream source";
$content['LN_SOURCES_STATSDETAILS'] = "Statistic details for this logstream source";
$content['LN_SOURCES_ERROR_NOSTATSDATA'] = "Could not find or obtain any stats related information for this logstream source.";
+$content['LN_SOURCES_ERROR_NOCLEARSUPPORT'] = "This logstream source does not support deleting data.";
+$content['LN_SOURCES_ROWCOUNT'] = "Total Rowcount";
+$content['LN_SOURCES_CLEAR_HELPTEXT'] = "Attention! Be carefull with deleting data, any action performed here can not be undone!";
+$content['LN_SOURCES_CLEARSINCE'] = "Clear all data older than ... ";
+$content['LN_SOURCES_CLEARDATE'] = "Clear all data which is older than ... ";
+$content['LN_SOURCES_CLEARDATA_SEND'] = "Clear selected data range";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";
diff --git a/src/templates/admin/admin_sources.html b/src/templates/admin/admin_sources.html
index e7a80b7..24a0be1 100644
--- a/src/templates/admin/admin_sources.html
+++ b/src/templates/admin/admin_sources.html
@@ -100,8 +100,90 @@
-
+
+
+
+
+
+
+
+ {SOURCEID} |
+
+
+
+ {DisplayName} |
+
+
+
+ {SourceTypeName} |
+
+
+
+ {ROWCOUNT} |
+
+
+
+
+
+
+ {LN_GEN_ERRORRETURNPREV}
+
+
+