Added option to use a custom phpLogCon logo in the header.

Also implemented the stats view in the source admin
This commit is contained in:
Andre Lorbach 2008-11-11 15:20:48 +01:00
parent a026804a36
commit c516c72391
13 changed files with 367 additions and 15 deletions

View File

@ -153,6 +153,7 @@ if ( isset($_POST['op']) )
if ( isset ($_POST['InjectHtmlHeader']) ) { $content['InjectHtmlHeader'] = $_POST['InjectHtmlHeader']; }
if ( isset ($_POST['InjectBodyHeader']) ) { $content['InjectBodyHeader'] = $_POST['InjectBodyHeader']; }
if ( isset ($_POST['InjectBodyFooter']) ) { $content['InjectBodyFooter'] = $_POST['InjectBodyFooter']; }
if ( isset ($_POST['PhplogconLogoUrl']) ) { $content['PhplogconLogoUrl'] = $_POST['PhplogconLogoUrl']; }
// Save configuration variables now
SaveGeneralSettingsIntoDB();

View File

@ -238,7 +238,7 @@ if ( isset($_GET['op']) )
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
// Get UserInfo
// Get SourceInfo
$result = DB_Query("SELECT Name FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['Name']) )
@ -274,6 +274,107 @@ if ( isset($_GET['op']) )
$content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'];
}
}
else if ($_GET['op'] == "cleardata")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
}
// Check If source is available
if ( !isset($content['Sources'][ $content['SOURCEID'] ]) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] );
}
else
{
}
}
else if ($_GET['op'] == "dbstats")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
}
// Check If source is available
if ( !isset($content['Sources'][ $content['SOURCEID'] ]) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] );
}
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['Description'] = $tmpSource['Description'];
$content['SourceType'] = $tmpSource['SourceType'];
CreateSourceTypesList($content['SourceType']);
$content['SourceTypeName'] = $content['SOURCETYPES'][ $content['SourceType'] ]['DisplayName'];
// Fix Filename manually for FILE LOGSTREAM!
if ( $content['SourceType'] == SOURCE_DISK )
{
$tmpSource['DiskFile'] = CheckAndPrependRootPath(DB_StripSlahes($tmpSource['DiskFile']));
$tmpSource['ObjRef']->FileName = $tmpSource['DiskFile'];
}
// 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'] .= "<br><br>" . GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
}
else
{
// Gather Database Stats
$content['STATS'] = $stream->GetLogStreamStats();
if ( isset($content['STATS']) )
{
$content['ISSTATS'] = true;
foreach( $content['STATS'] as &$myStats )
{
$i = 0;
foreach( $myStats['STATSDATA'] as &$myStatsData )
{
// --- Set CSS Class
if ( $i % 2 == 0 )
$myStatsData['cssclass'] = "line1";
else
$myStatsData['cssclass'] = "line2";
$i++;
// ---
}
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_NOSTATSDATA'], $content['SOURCEID'] );
}
// print_r ( $content['STATS'] );
}
// ---
}
}
}
if ( isset($_POST['op']) )
@ -364,8 +465,8 @@ if ( isset($_POST['op']) )
else
{
// Get plain filename for testing!
$content['SourceDiskFileTesting'] = DB_StripSlahes($content['SourceDiskFile']);
$content['SourceDiskFileTesting'] = CheckAndPrependRootPath(DB_StripSlahes($content['SourceDiskFile']));
/*
// Take as it is if rootpath!
if (
( ($pos = strpos($content['SourceDiskFileTesting'], "/")) !== FALSE && $pos == 0) ||
@ -379,13 +480,7 @@ if ( isset($_POST['op']) )
}
else // prepend basepath!
$content['SourceDiskFileTesting'] = $gl_root_path . $content['SourceDiskFileTesting'];
/*
if ( !is_file($content['SourceDiskFileTesting']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_NOTAVALIDFILE'], $szFileName );
}
*/
*/
}
}
// DB Params

View File

@ -212,6 +212,13 @@ abstract class LogStream {
*/
public abstract function IsPropertySortable($myProperty);
/**
* This returns an Array of useful statsdata for this logstream source
*/
public abstract function GetLogStreamStats();
/*
* Helper functino to trigger initialisation of MsgParsers
*/

View File

@ -538,6 +538,65 @@ class LogStreamDB extends LogStream {
return false;
}
/**
* Implementation of GetLogStreamStats
*
* Returns an Array og logstream statsdata
* Count of Data Items
* Total Filesize
*/
public function GetLogStreamStats()
{
global $querycount, $dbmapping;
$szTableType = $this->_logStreamConfigObj->DBTableType;
// Perform if Connection is true!
if ( $this->_dbhandle != null )
{
// Obtain Stats data for this table!
$szSql = "SHOW TABLE STATUS FROM " . $this->_logStreamConfigObj->DBName;
$myQuery = mysql_query($szSql, $this->_dbhandle);
if ($myQuery)
{
// Loop through results
while ($myRow = mysql_fetch_array($myQuery, MYSQL_ASSOC))
{
// Set tablename!
$tableName = $myRow['Name'];
$myStats = null;
$myStats[] = array( 'StatsDisplayName' => 'Table name', 'StatsValue' => $tableName );
// copy usefull statsdata
if ( isset($myRow['Engine']) )
$myStats[] = array( 'StatsDisplayName' => 'Table engine', 'StatsValue' => $myRow['Engine'] );
if ( isset($myRow['Rows']) )
$myStats[] = array( 'StatsDisplayName' => 'Rowcount', 'StatsValue' => $myRow['Rows'] );
if ( isset($myRow['Data_length']) )
$myStats[] = array( 'StatsDisplayName' => 'Table filesize (bytes)', 'StatsValue' => $myRow['Data_length'] );
if ( isset($myRow['Collation']) )
$myStats[] = array( 'StatsDisplayName' => 'Collation', 'StatsValue' => $myRow['Collation'] );
if ( isset($myRow['Comment']) )
$myStats[] = array( 'StatsDisplayName' => 'Comment', 'StatsValue' => $myRow['Comment'] );
$stats[]['STATSDATA'] = $myStats;
}
// Free query now
mysql_free_result ($myQuery);
// Increment for the Footer Stats
$querycount++;
}
// return results!
return $stats;
}
else
return null;
}
/**
* Implementation of GetCountSortedByField
*

View File

@ -598,6 +598,28 @@ class LogStreamDisk extends LogStream {
return false;
}
/**
* Implementation of GetLogStreamStats
*
* Returns an Array og logstream statsdata
* Count of Data Items
* Total Filesize
*/
public function GetLogStreamStats()
{
// Get some file data!
/*
// return results!
return $stats;
}
else
*/
// NOT IMPLEMENTED YET!
return null;
}
/**
* Implementation of GetCountSortedByField
*

View File

@ -534,6 +534,55 @@ class LogStreamPDO extends LogStream {
return false;
}
/**
* Implementation of GetLogStreamStats
*
* Returns an Array og logstream statsdata
* Count of Data Items
* Total Filesize
*/
public function GetLogStreamStats()
{
global $querycount, $dbmapping;
$szTableType = $this->_logStreamConfigObj->DBTableType;
// Perform if Connection is true!
if ( $this->_dbhandle != null )
{
$tableName = $this->_logStreamConfigObj->DBTableName;
// SHOW TABLE STATUS FROM
$stats = NULL;
$szSql = "SELECT count(" . $dbmapping[$szTableType][SYSLOG_UID] . ") as Counter FROM " . $this->_logStreamConfigObj->DBTableName;
$myQuery = $this->_dbhandle->query($szSql);
if ( $myQuery )
{
// Set tablename!
$tableName = $this->_logStreamConfigObj->DBTableName;
$myStats[] = array( 'StatsDisplayName' => 'TableName', 'StatsValue' => $tableName );
// obtain first and only row
$myRow = $myQuery->fetchColumn();
$myStats[] = array( 'StatsDisplayName' => 'Rows', 'StatsValue' => $myRow );
$stats[]['STATSDATA'] = $myStats;
// Free query now
$myQuery->closeCursor();
// Increment for the Footer Stats
$querycount++;
}
// return results!
return $stats;
}
else
return null;
}
/**
* Implementation of GetCountSortedByField
*

View File

@ -72,6 +72,7 @@ $content['BASEPATH'] = $gl_root_path;
$content['SHOW_DONATEBUTTON'] = true; // Default = true!
// PreInit overall user variables
$content['EXTRA_PHPLOGCON_LOGO'] = $content['BASEPATH'] . "images/main/Header-Logo.png";
$content['EXTRA_METATAGS'] = "";
$content['EXTRA_JAVASCRIPT'] = "";
$content['EXTRA_STYLESHEET'] = "";
@ -814,6 +815,13 @@ function InitConfigurationValues()
$content['InjectBodyFooter'] = ""; // Init Option
// ---
// --- Handle Optional Logo URL!
if ( strlen(GetConfigSetting("PhplogconLogoUrl", false)) > 0 )
$content['EXTRA_PHPLOGCON_LOGO'] = $CFG['PhplogconLogoUrl'];
else
$content['PhplogconLogoUrl'] = ""; // Init Option
// ---
// Init main langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' );
@ -1387,6 +1395,7 @@ function SaveGeneralSettingsIntoDB($bForceStripSlahes = false)
WriteConfigValue( "InjectHtmlHeader", true, null, null,$bForceStripSlahes );
WriteConfigValue( "InjectBodyHeader", true, null, null,$bForceStripSlahes );
WriteConfigValue( "InjectBodyFooter", true, null, null ,$bForceStripSlahes );
WriteConfigValue( "PhplogconLogoUrl", true, null, null ,$bForceStripSlahes );
}
function SaveUserGeneralSettingsIntoDB()
@ -1515,6 +1524,36 @@ function list_files($directory, $failOnError = true)
}
}
/*
* Helper function to prepend the current global root path if necessary!
*/
function CheckAndPrependRootPath( $szFileName)
{
global $gl_root_path;
// Get plain filename for testing!
$szNewFileName = $szFileName;
// Take as it is if rootpath!
if (
( ($pos = strpos($szFileName, "/")) !== FALSE && $pos == 0) ||
( ($pos = strpos($szFileName, "\\\\")) !== FALSE && $pos == 0) ||
( ($pos = strpos($szFileName, ":\\")) !== FALSE ) ||
( ($pos = strpos($szFileName, ":/")) !== FALSE )
)
{
// Nothing really todo
true;
}
else // prepend basepath!
$szNewFileName = $gl_root_path . $szFileName;
// return result
return $szNewFileName;
}
/*
* Helper function to flush html output to avoid redirects if errors happen!
*/

View File

@ -93,6 +93,10 @@ $content['LN_ADMIN_GLOBALONLY'] = "Global Options Only";
$content['LN_GEN_DEBUGTOSYSLOG'] = "Send Debug to local syslog server";
$content['LN_GEN_POPUPMENUTIMEOUT'] = "Popupmenu Timeout in milli seconds";
$content['LN_ADMIN_SCRIPTTIMEOUT'] = "PHP Script Timeout in seconds";
$content['LN_GEN_INJECTHTMLHEADER'] = "Inject this html code into the &lt;head&gt; area.";
$content['LN_GEN_INJECTBODYHEADER'] = "Inject this html code at the beginning of the &lt;body&gt; area.";
$content['LN_GEN_INJECTBODYFOOTER'] = "Inject this html code at the end &lt;body&gt; area.";
$content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optional phpLogCon Logo URL. Leave empty to use the default one.";
// User Center
$content['LN_USER_CENTER'] = "User Options";
@ -226,6 +230,11 @@ $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' fa
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)";
$content['LN_SOURCES_ERROR_INVALIDVALUE'] = "Invalid value for the paramater '%1'.";
$content['LN_SOURCES_STATSNAME'] = "Name";
$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.";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";

View File

@ -98,6 +98,7 @@ $content['LN_ADMIN_SCRIPTTIMEOUT'] = "PHP Script Timeout in seconds";
$content['LN_GEN_INJECTHTMLHEADER'] = "Inject this html code into the &lt;head&gt; area.";
$content['LN_GEN_INJECTBODYHEADER'] = "Inject this html code at the beginning of the &lt;body&gt; area.";
$content['LN_GEN_INJECTBODYFOOTER'] = "Inject this html code at the end &lt;body&gt; area.";
$content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optional phpLogCon Logo URL. Leave empty to use the default one.";
// User Center
$content['LN_USER_CENTER'] = "User Options";
@ -231,6 +232,12 @@ $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' fa
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)";
$content['LN_SOURCES_ERROR_INVALIDVALUE'] = "Invalid value for the paramater '%1'.";
$content['LN_SOURCES_STATSNAME'] = "Name";
$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.";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";

View File

@ -93,6 +93,10 @@ $content['LN_ADMIN_GLOBALONLY'] = "Global Options Only";
$content['LN_GEN_DEBUGTOSYSLOG'] = "Send Debug to local syslog server";
$content['LN_GEN_POPUPMENUTIMEOUT'] = "Popupmenu Timeout in milli seconds";
$content['LN_ADMIN_SCRIPTTIMEOUT'] = "PHP Script Timeout in seconds";
$content['LN_GEN_INJECTHTMLHEADER'] = "Inject this html code into the &lt;head&gt; area.";
$content['LN_GEN_INJECTBODYHEADER'] = "Inject this html code at the beginning of the &lt;body&gt; area.";
$content['LN_GEN_INJECTBODYFOOTER'] = "Inject this html code at the end &lt;body&gt; area.";
$content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optional phpLogCon Logo URL. Leave empty to use the default one.";
// User Center
$content['LN_USER_CENTER'] = "User Options";
@ -226,6 +230,11 @@ $content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' fa
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)";
$content['LN_SOURCES_ERROR_INVALIDVALUE'] = "Invalid value for the paramater '%1'.";
$content['LN_SOURCES_STATSNAME'] = "Name";
$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.";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";

View File

@ -238,18 +238,22 @@
<strong>{LN_ADMIN_GLOBALONLY}</strong></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_ADMIN_SCRIPTTIMEOUT}</b></td>
<td align="left" class="cellmenu2"><b>{LN_ADMIN_SCRIPTTIMEOUT}</b></td>
<td align="right" class="line1" colspan="2"><input type="text" name="MiscMaxExecutionTime" size="16" maxlength="12" value="{MiscMaxExecutionTime}" {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_GEN_DEBUGUSERLOGIN}</b></td>
<td align="left" class="cellmenu2_naked"><b>{LN_ADMIN_PHPLOGCON_LOGOURL}</b></td>
<td align="right" class="line1" colspan="2"><input type="text" name="PhplogconLogoUrl" size="85" maxlength="255" value="{PhplogconLogoUrl}" {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_GEN_DEBUGUSERLOGIN}</b></td>
<td align="right" class="line2" colspan="2"><input type="checkbox" name="DebugUserLogin" value="yes" {DebugUserLogin_checked} {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_GEN_DEBUGTOSYSLOG}</b></td>
<td align="left" class="cellmenu2"><b>{LN_GEN_DEBUGTOSYSLOG}</b></td>
<td align="right" class="line1" colspan="2"><input type="checkbox" name="MiscDebugToSyslog" value="yes" {MiscDebugToSyslog_checked} {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
</tr>
<tr>
<td align="left" class="cellmenu2_naked" valign="_top"><b>{LN_GEN_INJECTHTMLHEADER}</b></td>
<td align="right" class="line2" colspan="2"><textarea name="InjectHtmlHeader" cols="85" rows="3" {DISABLE_GLOBALEDIT_FORMCONTROL}>{InjectHtmlHeader}</textarea></td>

View File

@ -100,6 +100,57 @@
</table>
<!-- ENDIF LISTSOURCES="true" -->
<!-- IF ISSTATS="true" -->
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="500" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_SOURCES_DETAILS}</b></td>
</tr>
<tr>
<td align="left" class="cellmenu2" width="200"><b>{LN_SOURCES_ID}</b></td>
<td align="left" class="line1" width="300">{SOURCEID}</td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_SOURCES_NAME}</b></td>
<td align="left" class="line2">{DisplayName}</td>
</tr>
<tr>
<td align="left" class="cellmenu2" valign="top"><b>{LN_SOURCES_TYPE}</b></td>
<td align="left" class="line1">{SourceTypeName}</td>
</tr>
<tr>
<td align="left" class="cellmenu2_naked" valign="top"><b>{LN_SOURCES_DESCRIPTION}</b></td>
<td align="left" class="line1">{Description}</td>
</tr>
</table>
<br />
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="500" class="with_border_alternate">
<tr>
<td class="cellmenu1" nowrap><B>{LN_SOURCES_STATSDETAILS}</B></td>
</tr>
</table>
<!-- BEGIN STATS -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="500" class="with_border_alternate">
<tr>
<td align="center" width="200" class="cellmenu2"><b>{LN_SOURCES_STATSNAME}</b></td>
<td align="center" width="300" class="cellmenu2"><b>{LN_SOURCES_STATSVALUE}</b></td>
</tr>
<!-- BEGIN STATSDATA -->
<tr>
<td align="left" width="200" class="{cssclass}"><b>{StatsDisplayName}</b></td>
<td align="left" width="300" class="{cssclass}">{StatsValue}</td>
</tr>
<!-- END STATSDATA -->
</table>
<!-- END STATS -->
<br><br>
<a href="javascript:history.back();" target="_top">{LN_GEN_ERRORRETURNPREV}</a>
<!-- ENDIF ISSTATS="true" -->
<!-- IF ISEDITORNEWSOURCE="true" -->
<form action="{BASEPATH}admin/sources.php" method="post">

View File

@ -20,7 +20,7 @@
<!-- IF MAXIMIZED!="true" -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="mainheader">
<tr>
<td rowspan="4" width="500" align="left" valign="top"><a href="{BASEPATH}index.php"><img src="{BASEPATH}images/main/Header-Logo.png" width="500" height="79" name="HeaderLogo"></a></td>
<td rowspan="4" width="500" align="left" valign="top"><a href="{BASEPATH}index.php"><img src="{EXTRA_PHPLOGCON_LOGO}" width="500" height="79" name="HeaderLogo"></a></td>
<td rowspan="4" width="100%" align="center" nowrap>
<!-- IF SHOW_DONATEBUTTON="true" -->
<b>Satisfied with phpLogCon?</b><br>