Added new description field for logstream sources.

If the description field is used, it will be shown below the pager on
the main index site. A database field has also been added, the
database version has been incremented as well. During next login,
you will be prompted for a database update.
This commit is contained in:
Andre Lorbach 2008-09-25 16:28:08 +02:00
parent 918cdcbb69
commit 2ee4d65ff5
11 changed files with 53 additions and 9 deletions

View File

@ -65,6 +65,7 @@ if ( isset($_GET['op']) )
//PreInit these values
$content['Name'] = "";
$content['Description'] = "";
$content['SourceType'] = SOURCE_DISK;
CreateSourceTypesList($content['SourceType']);
$content['MsgParserList'] = "";
@ -132,6 +133,7 @@ if ( isset($_GET['op']) )
// Copy basic properties
$content['Name'] = $mysource['Name'];
$content['Description'] = $mysource['Description'];
$content['SourceType'] = $mysource['SourceType'];
CreateSourceTypesList($content['SourceType']);
$content['MsgParserList'] = $mysource['MsgParserList'];
@ -267,6 +269,7 @@ if ( isset($_POST['op']) )
// Read parameters first!
if ( isset($_POST['id']) ) { $content['SOURCEID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SOURCEID'] = -1; }
if ( isset($_POST['Name']) ) { $content['Name'] = DB_RemoveBadChars($_POST['Name']); } else {$content['Name'] = ""; }
if ( isset($_POST['Description']) ) { $content['Description'] = DB_RemoveBadChars($_POST['Description']); } else {$content['Description'] = ""; }
if ( isset($_POST['SourceType']) ) { $content['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); }
if ( isset($_POST['MsgParserList']) ) { $content['MsgParserList'] = DB_RemoveBadChars($_POST['MsgParserList']); }
if ( isset($_POST['MsgNormalize']) ) { $content['MsgNormalize'] = intval(DB_RemoveBadChars($_POST['MsgNormalize'])); } else {$content['MsgNormalize'] = 0; }
@ -419,6 +422,7 @@ if ( isset($_POST['op']) )
// First create a tmp source array
$tmpSource['ID'] = $content['SOURCEID'];
$tmpSource['Name'] = $content['Name'];
$tmpSource['Description'] = $content['Description'];
$tmpSource['SourceType'] = $content['SourceType'];
$tmpSource['MsgParserList'] = $content['MsgParserList'];
$tmpSource['MsgNormalize'] = $content['MsgNormalize'];
@ -469,8 +473,9 @@ if ( isset($_POST['op']) )
// Add custom search now!
if ( $content['SourceType'] == SOURCE_DISK )
{
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile, userid, groupid)
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile, userid, groupid)
VALUES ('" . $content['Name'] . "',
'" . $content['Description'] . "',
" . $content['SourceType'] . ",
'" . $content['MsgParserList'] . "',
" . $content['MsgNormalize'] . ",
@ -483,8 +488,9 @@ if ( isset($_POST['op']) )
}
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid)
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting, userid, groupid)
VALUES ('" . $content['Name'] . "',
'" . $content['Description'] . "',
" . $content['SourceType'] . ",
'" . $content['MsgParserList'] . "',
" . $content['MsgNormalize'] . ",
@ -524,6 +530,7 @@ if ( isset($_POST['op']) )
{
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
Description = '" . $content['Description'] . "',
SourceType = " . $content['SourceType'] . ",
MsgParserList = '" . $content['MsgParserList'] . "',
MsgNormalize = " . $content['MsgNormalize'] . ",
@ -538,6 +545,7 @@ if ( isset($_POST['op']) )
{
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
Description = '" . $content['Description'] . "',
SourceType = " . $content['SourceType'] . ",
MsgParserList = '" . $content['MsgParserList'] . "',
MsgNormalize = " . $content['MsgNormalize'] . ",

View File

@ -114,6 +114,7 @@ $CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHAR
/* Example for DiskType Source:
$CFG['Sources']['Source1']['ID'] = "Source1";
$CFG['Sources']['Source1']['Name'] = "Syslog Disk File";
$CFG['Sources']['Source1']['Description'] = "More details you want to see about this source";
$CFG['Sources']['Source1']['SourceType'] = SOURCE_DISK;
$CFG['Sources']['Source1']['LogLineType'] = "syslog";
$CFG['Sources']['Source1']['MsgParserList'] = "";
@ -123,6 +124,7 @@ $CFG['Charts'][] = array ( "DisplayName" => "Usage by Day", "chart_type" => CHAR
$CFG['Sources']['Source2']['ID'] = "Source5";
$CFG['Sources']['Source2']['Name'] = "WinSyslog DB";
$CFG['Sources']['Source1']['Description'] = "";
$CFG['Sources']['Source2']['SourceType'] = SOURCE_DB;
$CFG['Sources']['Source1']['MsgParserList'] = "";
$CFG['Sources']['Source2']['DBTableType'] = "winsyslog";

View File

@ -0,0 +1,6 @@
-- New Database Structure Updates
ALTER TABLE `logcon_sources` ADD `Description` TEXT NOT NULL AFTER `Name` ;
-- Insert data
-- Updated Data

View File

@ -79,6 +79,12 @@ function InitSource(&$mysource)
$CFG['Sources'][$iSourceID]['MsgNormalize'] = 0;
$content['Sources'][$iSourceID]['MsgNormalize'] = 0;
}
if ( !isset($mysource['Description']) )
{
$CFG['Sources'][$iSourceID]['Description'] = "";
$content['Sources'][$iSourceID]['Description'] = "";
}
// ---
// Set default view id to source
@ -230,6 +236,14 @@ function InitSourceConfigs()
// Set for the selection box in the header
$content['Sources'][$currentSourceID]['selected'] = "selected";
// Set Description properties!
if ( isset($content['Sources'][$currentSourceID]['Description']) && strlen($content['Sources'][$currentSourceID]['Description']) > 0 )
{
$content['SourceDescriptionEnabled'] = true;
$content['SourceDescription'] = $content['Sources'][$currentSourceID]['Description'];
}
// --- Additional handling needed for the current view!
global $currentViewID;
$currentViewID = $content['Sources'][$currentSourceID]['ViewID'];

View File

@ -45,7 +45,7 @@ $errdesc = "";
$errno = 0;
// --- Current Database Version, this is important for automated database Updates!
$content['database_internalversion'] = "3"; // Whenever incremented, a database upgrade is needed
$content['database_internalversion'] = "4"; // Whenever incremented, a database upgrade is needed
$content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database
// ---

View File

@ -192,8 +192,9 @@ function ConvertCustomSources()
// Add New Entry
if ( $mySource['SourceType'] == SOURCE_DISK )
{
$result = DB_Query("INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile) VALUES ( " .
$result = DB_Query("INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile) VALUES ( " .
"'" . PrepareValueForDB($mySource['Name']) . "', " .
"'" . PrepareValueForDB($mySource['Description']) . "', " .
" " . PrepareValueForDB($mySource['SourceType']) . " , " .
"'" . PrepareValueForDB($mySource['MsgParserList']) . "', " .
" " . PrepareValueForDB($mySource['MsgNormalize']) . " , " .
@ -213,8 +214,9 @@ function ConvertCustomSources()
$mySource['DBType'] = DB_MYSQL;
// Perform the insert
$result = DB_Query("INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting) VALUES ( " .
$result = DB_Query("INSERT INTO " . DB_SOURCES . " (Name, Description, SourceType, MsgParserList, MsgNormalize, ViewID, DBTableType, DBType, DBServer, DBName, DBUser, DBPassword, DBTableName, DBEnableRowCounting) VALUES ( " .
"'" . PrepareValueForDB($mySource['Name']) . "', " .
"'" . PrepareValueForDB($mySource['Description']) . "', " .
" " . PrepareValueForDB($mySource['SourceType']) . " , " .
"'" . PrepareValueForDB($mySource['MsgParserList']) . "', " .
" " . PrepareValueForDB($mySource['MsgNormalize']) . " , " .

View File

@ -220,7 +220,7 @@ $content['LN_SOURCES_HASBEENEDIT'] = "The Source '%1' has been successfully edit
$content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete the Source '%1'? This cannot be undone!";
$content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!";
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_'] = "";
$content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";

View File

@ -221,7 +221,7 @@ $content['LN_SOURCES_HASBEENEDIT'] = "The Source '%1' has been successfully edit
$content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete the Source '%1'? This cannot be undone!";
$content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!";
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_'] = "";
$content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";

View File

@ -220,7 +220,7 @@ $content['LN_SOURCES_HASBEENEDIT'] = "The Source '%1' has been successfully edit
$content['LN_SOURCES_WARNDELETESEARCH'] = "Are you sure that you want to delete the Source '%1'? This cannot be undone!";
$content['LN_SOURCES_ERROR_DELSOURCE'] = "Deleting of the Source with id '%1' failed!";
$content['LN_SOURCES_ERROR_HASBEENDEL'] = "The Source '%1' has been successfully deleted!";
$content['LN_SOURCES_'] = "";
$content['LN_SOURCES_DESCRIPTION'] = "Source Description (Optional)";
// Database Upgrade
$content['LN_DBUPGRADE_TITLE'] = "phpLogCon Database Update";

View File

@ -102,6 +102,11 @@
<td align="left" class="cellmenu2" width="250"><b>{LN_SOURCES_NAME}</b></td>
<td align="right" class="line1" width="350"><input type="text" name="Name" size="55" maxlength="255" value="{Name}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" width="250" valign="top"><b>{LN_SOURCES_DESCRIPTION}</b></td>
<td align="right" class="line1" width="350"><textarea name="Description" cols="50" rows="5">{Description}</textarea></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_SOURCES_TYPE}</b></td>
<td align="right" class="line1">

View File

@ -122,7 +122,6 @@
<table width="100%" align="center" border="0" cellpadding="1" cellspacing="1" class="with_border">
<tr>
<td nowrap width="100%" class="line2" align="left">
<!-- IF main_currentpagenumber_found="true" -->
{LN_GEN_PAGE} {main_currentpagenumber}
@ -218,6 +217,14 @@
</tr>
</table>
<!-- IF SourceDescriptionEnabled="true" -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td class="titleSecond" width="100%" align="left">{SourceDescription}</td>
</tr>
</table>
<!-- ENDIF SourceDescriptionEnabled="true" -->
<!-- IF syslogmessagesenabled="true" -->
<table width="100%" cellpadding="0" cellspacing="1" border="0" align="center" class="with_border_alternate">
<tr>