Started implementing charts admin

This commit is contained in:
unknown 2008-09-12 12:33:04 +02:00
parent fb242ca286
commit ccd5a640c3
10 changed files with 924 additions and 0 deletions

662
src/admin/charts.php Normal file
View File

@ -0,0 +1,662 @@
<?php
/*
*********************************************************************
* phpLogCon - http://www.phplogcon.org
* -----------------------------------------------------------------
* Charts Admin File
*
* -> Helps administrating phplogcon charts & graphics
*
* 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 <http://www.gnu.org/licenses/>.
*
* 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');
// Set PAGE to be ADMINPAGE!
define('IS_ADMINPAGE', true);
$content['IS_ADMINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults(); // Only in WebFrontEnd
InitFilterHelpers(); // Helpers for frontend filtering!
// Init admin langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
// ---
// --- BEGIN Custom Code
if ( isset($_GET['op']) )
{
if ($_GET['op'] == "add")
{
// Set Mode to add
$content['ISEDITORNEWSOURCE'] = "true";
$content['SOURCE_FORMACTION'] = "addnewsource";
$content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_ADD'];
//PreInit these values
$content['Name'] = "";
$content['SourceType'] = SOURCE_DISK;
CreateSourceTypesList($content['SourceType']);
$content['MsgParserList'] = "";
$content['MsgNormalize'] = 0;
$content['CHECKED_ISNORMALIZEMSG'] = "";
// Init View List!
$content['SourceViewID'] = 'SYSLOG';
$content['VIEWS'] = $content['Views'];
foreach ( $content['VIEWS'] as $myView )
{
if ( $myView['ID'] == $content['SourceViewID'] )
$content['VIEWS'][ $myView['ID'] ]['selected'] = "selected";
else
$content['VIEWS'][ $myView['ID'] ]['selected'] = "";
}
// SOURCE_DISK specific
$content['SourceLogLineType'] = "";
CreateLogLineTypesList($content['SourceLogLineType']);
$content['SourceDiskFile'] = "/var/log/syslog";
// SOURCE_DB specific
$content['SourceDBType'] = DB_MYSQL;
CreateDBTypesList($content['SourceDBType']);
$content['SourceDBName'] = "phplogcon";
$content['SourceDBTableType'] = "monitorware";
$content['SourceDBServer'] = "localhost";
$content['SourceDBTableName'] = "systemevents";
$content['SourceDBUser'] = "user";
$content['SourceDBPassword'] = "";
$content['SourceDBEnableRowCounting'] = "false";
$content['SourceDBEnableRowCounting_true'] = "";
$content['SourceDBEnableRowCounting_false'] = "checked";
// General stuff
$content['userid'] = null;
$content['CHECKED_ISUSERONLY'] = "";
$content['SOURCEID'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
$content['ISGROUPSAVAILABLE'] = true;
else
$content['ISGROUPSAVAILABLE'] = false;
}
else if ($_GET['op'] == "edit")
{
// Set Mode to edit
$content['ISEDITORNEWSOURCE'] = "true";
$content['SOURCE_FORMACTION'] = "editsource";
$content['SOURCE_SENDBUTTON'] = $content['LN_SOURCES_EDIT'];
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
// Check if exists
if ( is_numeric($content['SOURCEID']) && isset($content['Sources'][ $content['SOURCEID'] ]) )
{
// Get Source reference
$mysource = $content['Sources'][ $content['SOURCEID'] ];
// Copy basic properties
$content['Name'] = $mysource['Name'];
$content['SourceType'] = $mysource['SourceType'];
CreateSourceTypesList($content['SourceType']);
$content['MsgParserList'] = $mysource['MsgParserList'];
$content['MsgNormalize'] = $mysource['MsgNormalize'];
if ( $mysource['MsgNormalize'] == 1 )
$content['CHECKED_ISNORMALIZEMSG'] = "checked";
else
$content['CHECKED_ISNORMALIZEMSG'] = "";
// Init View List!
$content['SourceViewID'] = $mysource['ViewID'];
$content['VIEWS'] = $content['Views'];
foreach ( $content['VIEWS'] as $myView )
{
if ( $myView['ID'] == $content['SourceViewID'] )
$content['VIEWS'][ $myView['ID'] ]['selected'] = "selected";
else
$content['VIEWS'][ $myView['ID'] ]['selected'] = "";
}
// SOURCE_DISK specific
$content['SourceLogLineType'] = $mysource['LogLineType'];
CreateLogLineTypesList($content['SourceLogLineType']);
$content['SourceDiskFile'] = $mysource['DiskFile'];
// SOURCE_DB specific
$content['SourceDBType'] = $mysource['DBType'];
CreateDBTypesList($content['SourceDBType']);
$content['SourceDBName'] = $mysource['DBName'];
$content['SourceDBTableType'] = $mysource['DBTableType'];
$content['SourceDBServer'] = $mysource['DBServer'];
$content['SourceDBTableName'] = $mysource['DBTableName'];
$content['SourceDBUser'] = $mysource['DBUser'];
$content['SourceDBPassword'] = $mysource['DBPassword'];
$content['SourceDBEnableRowCounting'] = $mysource['DBEnableRowCounting'];
if ( $content['SourceDBEnableRowCounting'] == 1 )
{
$content['SourceDBEnableRowCounting_true'] = "checked";
$content['SourceDBEnableRowCounting_false'] = "";
}
else
{
$content['SourceDBEnableRowCounting_true'] = "";
$content['SourceDBEnableRowCounting_false'] = "checked";
}
if ( $mysource['userid'] != null )
$content['CHECKED_ISUSERONLY'] = "checked";
else
$content['CHECKED_ISUSERONLY'] = "";
// --- Check if groups are available
$content['SUBGROUPS'] = GetGroupsForSelectfield();
if ( is_array($content['SUBGROUPS']) )
{
// Process All Groups
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
{
if ( $mysource['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysource['groupid'] )
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
else
$content['SUBGROUPS'][$i]['group_selected'] = "";
}
// Enable Group Selection
$content['ISGROUPSAVAILABLE'] = true;
}
else
$content['ISGROUPSAVAILABLE'] = false;
// ---
}
else
{
$content['ISEDITORNEWSOURCE'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'];
}
}
else
{
$content['ISEDITORNEWSEARCH'] = false;
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID'];
}
}
else if ($_GET['op'] == "delete")
{
if ( isset($_GET['id']) )
{
//PreInit these values
$content['SOURCEID'] = DB_RemoveBadChars($_GET['id']);
// Get UserInfo
$result = DB_Query("SELECT Name FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] );
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['Name']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] );
}
// --- Ask for deletion first!
if ( (!isset($_GET['verify']) || $_GET['verify'] != "yes") )
{
// This will print an additional secure check which the user needs to confirm and exit the script execution.
PrintSecureUserCheck( GetAndReplaceLangStr( $content['LN_SOURCES_WARNDELETESEARCH'], $myrow['Name'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
}
// ---
// do the delete!
$result = DB_Query( "DELETE FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID'] );
if ($result == FALSE)
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_DELSOURCE'], $content['SOURCEID'] );
}
else
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_HASBEENDEL'], $myrow['Name'] ) , "sources.php" );
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = $content['LN_SOURCES_ERROR_INVALIDORNOTFOUNDID'];
}
}
}
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['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; }
if ( isset($_POST['SourceViewID']) ) { $content['SourceViewID'] = DB_RemoveBadChars($_POST['SourceViewID']); }
if ( isset($content['SourceType']) )
{
// Disk Params
if ( $content['SourceType'] == SOURCE_DISK )
{
if ( isset($_POST['SourceLogLineType']) ) { $content['SourceLogLineType'] = DB_RemoveBadChars($_POST['SourceLogLineType']); }
if ( isset($_POST['SourceDiskFile']) ) { $content['SourceDiskFile'] = DB_RemoveBadChars($_POST['SourceDiskFile']); }
}
// DB Params
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
if ( isset($_POST['SourceDBType']) ) { $content['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); }
if ( isset($_POST['SourceDBName']) ) { $content['SourceDBName'] = DB_RemoveBadChars($_POST['SourceDBName']); }
if ( isset($_POST['SourceDBTableType']) ) { $content['SourceDBTableType'] = DB_RemoveBadChars($_POST['SourceDBTableType']); }
if ( isset($_POST['SourceDBServer']) ) { $content['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); }
if ( isset($_POST['SourceDBTableName']) ) { $content['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); }
if ( isset($_POST['SourceDBUser']) ) { $content['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); }
if ( isset($_POST['SourceDBPassword']) ) { $content['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); } else {$content['SourceDBPassword'] = ""; }
if ( isset($_POST['SourceDBEnableRowCounting']) ) { $content['SourceDBEnableRowCounting'] = DB_RemoveBadChars($_POST['SourceDBEnableRowCounting']); }
// Extra Check for this property
if ( $content['SourceDBEnableRowCounting'] != "true" )
$content['SourceDBEnableRowCounting'] = "false";
}
}
// User & Group handeled specially
if ( isset ($_POST['isuseronly']) )
{
$content['userid'] = $content['SESSION_USERID'];
$content['groupid'] = "null"; // Either user or group not both!
}
else
{
$content['userid'] = "null";
if ( isset ($_POST['groupid']) && $_POST['groupid'] != -1 )
$content['groupid'] = intval($_POST['groupid']);
else
$content['groupid'] = "null";
}
// --- Check mandotary values
if ( $content['Name'] == "" )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_NAMEOFTHESOURCE'] );
}
else if ( !isset($content['SourceType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SOURCETYPE'] );
}
else if ( !isset($content['SourceViewID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_VIEW'] );
}
else
{
// Disk Params
if ( $content['SourceType'] == SOURCE_DISK )
{
if ( !isset($content['SourceLogLineType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_LOGLINETYPE'] );
}
else if ( !isset($content['SourceDiskFile']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_SYSLOGFILE'] );
}
// Check if file is accessable!
else
{
// Get plain filename for testing!
$content['SourceDiskFileTesting'] = DB_StripSlahes($content['SourceDiskFile']);
// Take as it is if rootpath!
if (
( ($pos = strpos($content['SourceDiskFileTesting'], "/")) !== FALSE && $pos == 0) ||
( ($pos = strpos($content['SourceDiskFileTesting'], "\\\\")) !== FALSE && $pos == 0) ||
( ($pos = strpos($content['SourceDiskFileTesting'], ":\\")) !== FALSE ) ||
( ($pos = strpos($content['SourceDiskFileTesting'], ":/")) !== FALSE )
)
{
// Nothing really todo
true;
}
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
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
if ( !isset($content['SourceDBType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DATABASETYPEOPTIONS'] );
}
else if ( !isset($content['SourceDBName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBNAME'] );
}
else if ( !isset($content['SourceDBTableType']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLETYPE'] );
}
else if ( !isset($content['SourceDBServer']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBSERVER'] );
}
else if ( !isset($content['SourceDBTableName']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBTABLENAME'] );
}
else if ( !isset($content['SourceDBUser']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_MISSINGPARAM'], $content['LN_CFG_DBUSER'] );
}
}
else
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_UNKNOWNSOURCE'], $content['SourceDBType'] );
}
// --- Verify the Source and report and error if needed!
// Include LogStream facility
include($gl_root_path . 'classes/logstream.class.php');
// First create a tmp source array
$tmpSource['ID'] = $content['SOURCEID'];
$tmpSource['Name'] = $content['Name'];
$tmpSource['SourceType'] = $content['SourceType'];
$tmpSource['MsgParserList'] = $content['MsgParserList'];
$tmpSource['MsgNormalize'] = $content['MsgNormalize'];
$tmpSource['ViewID'] = $content['SourceViewID'];
if ( $tmpSource['SourceType'] == SOURCE_DISK )
{
$tmpSource['LogLineType'] = $content['SourceLogLineType'];
$tmpSource['DiskFile'] = $content['SourceDiskFileTesting']; // use SourceDiskFileTesting rather then SourceDiskFile as it is corrected
}
// DB Params
else if ( $tmpSource['SourceType'] == SOURCE_DB || $tmpSource['SourceType'] == SOURCE_PDO )
{
$tmpSource['DBType'] = $content['SourceDBType'];
$tmpSource['DBName'] = $content['SourceDBName'];
$tmpSource['DBTableType'] = $content['SourceDBTableType'];
$tmpSource['DBServer'] = $content['SourceDBServer'];
$tmpSource['DBTableName'] = $content['SourceDBTableName'];
$tmpSource['DBUser'] = $content['SourceDBUser'];
$tmpSource['DBPassword'] = $content['SourceDBPassword'];
$tmpSource['DBEnableRowCounting'] = $content['SourceDBEnableRowCounting'];
$tmpSource['userid'] = $content['userid'];
$tmpSource['groupid'] = $content['groupid'];
}
// Init the source
InitSource($tmpSource);
// 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);
}
// ---
}
// --- Now ADD/EDIT do the processing!
if ( !isset($content['ISERROR']) )
{
// Everything was alright, so we go to the next step!
if ( $_POST['op'] == "addnewsource" )
{
// Add custom search now!
if ( $content['SourceType'] == SOURCE_DISK )
{
$sqlquery = "INSERT INTO " . DB_SOURCES . " (Name, SourceType, MsgParserList, MsgNormalize, ViewID, LogLineType, DiskFile, userid, groupid)
VALUES ('" . $content['Name'] . "',
" . $content['SourceType'] . ",
'" . $content['MsgParserList'] . "',
" . $content['MsgNormalize'] . ",
'" . $content['SourceViewID'] . "',
'" . $content['SourceLogLineType'] . "',
'" . $content['SourceDiskFile'] . "',
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
}
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)
VALUES ('" . $content['Name'] . "',
" . $content['SourceType'] . ",
'" . $content['MsgParserList'] . "',
" . $content['MsgNormalize'] . ",
'" . $content['SourceViewID'] . "',
'" . $content['SourceDBTableType'] . "',
" . $content['SourceDBType'] . ",
'" . $content['SourceDBServer'] . "',
'" . $content['SourceDBName'] . "',
'" . $content['SourceDBUser'] . "',
'" . $content['SourceDBPassword'] . "',
'" . $content['SourceDBTableName'] . "',
" . $content['SourceDBEnableRowCounting'] . ",
" . $content['userid'] . ",
" . $content['groupid'] . "
)";
}
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Do the final redirect
RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCE_HASBEENADDED'], $content['Name'] ) , "sources.php" );
}
else if ( $_POST['op'] == "editsource" )
{
$result = DB_Query("SELECT ID FROM " . DB_SOURCES . " WHERE ID = " . $content['SOURCEID']);
$myrow = DB_GetSingleRow($result, true);
if ( !isset($myrow['ID']) )
{
$content['ISERROR'] = true;
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SOURCES_ERROR_IDNOTFOUND'], $content['SOURCEID'] );
}
else
{
// Edit the Search Entry now!
if ( $content['SourceType'] == SOURCE_DISK )
{
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
SourceType = " . $content['SourceType'] . ",
MsgParserList = '" . $content['MsgParserList'] . "',
MsgNormalize = " . $content['MsgNormalize'] . ",
ViewID = '" . $content['SourceViewID'] . "',
LogLineType = '" . $content['SourceLogLineType'] . "',
DiskFile = '" . $content['SourceDiskFile'] . "',
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['SOURCEID'];
}
else if ( $content['SourceType'] == SOURCE_DB || $content['SourceType'] == SOURCE_PDO )
{
$sqlquery = "UPDATE " . DB_SOURCES . " SET
Name = '" . $content['Name'] . "',
SourceType = " . $content['SourceType'] . ",
MsgParserList = '" . $content['MsgParserList'] . "',
MsgNormalize = " . $content['MsgNormalize'] . ",
ViewID = '" . $content['SourceViewID'] . "',
DBTableType = '" . $content['SourceDBTableType'] . "',
DBType = " . $content['SourceDBType'] . ",
DBServer = '" . $content['SourceDBServer'] . "',
DBName = '" . $content['SourceDBName'] . "',
DBUser = '" . $content['SourceDBUser'] . "',
DBPassword = '" . $content['SourceDBPassword'] . "',
DBTableName = '" . $content['SourceDBTableName'] . "',
DBEnableRowCounting = " . $content['SourceDBEnableRowCounting'] . ",
userid = " . $content['userid'] . ",
groupid = " . $content['groupid'] . "
WHERE ID = " . $content['SOURCEID'];
}
$result = DB_Query($sqlquery);
DB_FreeQuery($result);
// Done redirect!
RedirectResult( GetAndReplaceLangStr( $content['LN_SOURCES_HASBEENEDIT'], $content['Name']) , "sources.php" );
}
}
}
}
if ( !isset($_POST['op']) && !isset($_GET['op']) )
{
// Default Mode = List Searches
$content['LISTCHARTS'] = "true";
// Copy Sources array for further modifications
$content['CHARTS'] = $content['Charts'];
// --- Process Sources
$i = 0; // Help counter!
foreach ($content['CHARTS'] as &$myChart )
{
// --- Set Image for Type
// NonNUMERIC are config files Sources, can not be editied
if ( is_numeric($myChart['ID']) )
{
// Allow EDIT
$myChart['ActionsAllowed'] = true;
if ( $myChart['userid'] != null )
{
$myChart['ChartAssignedToImage'] = $content["MENU_ADMINUSERS"];
$myChart['ChartAssignedToText'] = $content["LN_GEN_USERONLY"];
}
else if ( $myChart['groupid'] != null )
{
$myChart['ChartAssignedToImage'] = $content["MENU_ADMINGROUPS"];
$myChart['ChartAssignedToText'] = GetAndReplaceLangStr( $content["LN_GEN_GROUPONLYNAME"], $myChart['groupname'] );
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$myChart['ActionsAllowed'] = false;
}
else
{
$myChart['ChartAssignedToImage'] = $content["MENU_GLOBAL"];
$myChart['ChartAssignedToText'] = $content["LN_GEN_GLOBAL"];
// Check if is ADMIN User, deny if normal user!
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
$myChart['ActionsAllowed'] = false;
}
}
else
{
// Disallow EDIT
$myChart['ActionsAllowed'] = false;
$myChart['ChartAssignedToImage'] = $content["MENU_INTERNAL"];
$myChart['ChartAssignedToText'] = $content["LN_GEN_CONFIGFILE"];
}
// ---
// --- Set SourceType
if ( $myChart['chart_type'] == CHART_CAKE )
{
$myChart['ChartTypeImage'] = $content["MENU_CHART_CAKE"];
$myChart['ChartTypeText'] = $content["LN_CHART_TYPE_CAKE"];
}
else if ( $myChart['chart_type'] == CHART_BARS_VERTICAL )
{
$myChart['ChartTypeImage'] = $content["MENU_CHART_BARSVERT"];
$myChart['ChartTypeText'] = $content["LN_CHART_TYPE_BARS_VERTICAL"];
}
else if ( $myChart['chart_type'] == CHART_BARS_HORIZONTAL )
{
$myChart['ChartTypeImage'] = $content["MENU_CHART_BARSHORI"];
$myChart['ChartTypeText'] = $content["LN_CHART_TYPE_BARS_HORIZONTAL"];
}
// ---
// --- Set CSS Class
if ( $i % 2 == 0 )
$myChart['cssclass'] = "line1";
else
$myChart['cssclass'] = "line2";
$i++;
// ---
}
// ---
}
// --- END Custom Code
// --- BEGIN CREATE TITLE
$content['TITLE'] = InitPageTitle();
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_CHARTOPT'];
// --- END CREATE TITLE
// --- Parsen and Output
InitTemplateParser();
$page -> parser($content, "admin/admin_charts.html");
$page -> output();
// ---
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

View File

@ -483,6 +483,9 @@ function InitFrontEndVariables()
$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_CHART_CAKE'] = $content['BASEPATH'] . "images/icons/pie-chart.png";
$content['MENU_CHART_BARSVERT'] = $content['BASEPATH'] . "images/icons/column-chart.png";
$content['MENU_CHART_BARSHORI'] = $content['BASEPATH'] . "images/icons/column-chart-hori.png";
$content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png";
$content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png";

View File

@ -35,6 +35,7 @@ $content['LN_ADMINMENU_VIEWSOPT'] = "Views Options";
$content['LN_ADMINMENU_SEARCHOPT'] = "Search Options";
$content['LN_ADMINMENU_USEROPT'] = "User Options";
$content['LN_ADMINMENU_GROUPOPT'] = "Group Options";
$content['LN_ADMINMENU_CHARTOPT'] = "Chart Options";
$content['LN_ADMIN_CENTER'] = "Admin center";
$content['LN_ADMIN_UNKNOWNSTATE'] = "Unknown State";
$content['LN_ADMIN_ERROR_NOTALLOWED'] = "You are not allowed to access this page with your user level.";

View File

@ -35,6 +35,7 @@ $content['LN_ADMINMENU_VIEWSOPT'] = "Views Options";
$content['LN_ADMINMENU_SEARCHOPT'] = "Search Options";
$content['LN_ADMINMENU_USEROPT'] = "User Options";
$content['LN_ADMINMENU_GROUPOPT'] = "Group Options";
$content['LN_ADMINMENU_CHARTOPT'] = "Chart Options";
$content['LN_ADMIN_CENTER'] = "Admin center";
$content['LN_ADMIN_UNKNOWNSTATE'] = "Unknown State";
$content['LN_ADMIN_ERROR_NOTALLOWED'] = "You are not allowed to access this page with your user level.";
@ -232,6 +233,11 @@ $content['LN_DBUPGRADE_ONESTATEMENTFAILED'] = "At least one statement failed, yo
$content['LN_DBUPGRADE_ERRMSG'] = "Error Message";
$content['LN_DBUPGRADE_ULTRASTATSDBVERSION'] = "phpLogCon Database Version";
// Charts Options
$content['LN_CHARTS_CENTER'] = "Charts Options";
$content['LN_CHARTS_EDIT'] = "Edit Chart";
$content['LN_CHARTS_DELETE'] = "Delete Chart";
$content['LN_CHARTS_ADD'] = "Add new Chart";
?>

View File

@ -35,6 +35,7 @@ $content['LN_ADMINMENU_VIEWSOPT'] = "Views Options";
$content['LN_ADMINMENU_SEARCHOPT'] = "Search Options";
$content['LN_ADMINMENU_USEROPT'] = "User Options";
$content['LN_ADMINMENU_GROUPOPT'] = "Group Options";
$content['LN_ADMINMENU_CHARTOPT'] = "Chart Options";
$content['LN_ADMIN_CENTER'] = "Admin center";
$content['LN_ADMIN_UNKNOWNSTATE'] = "Unknown State";
$content['LN_ADMIN_ERROR_NOTALLOWED'] = "You are not allowed to access this page with your user level.";

View File

@ -0,0 +1,250 @@
<!-- INCLUDE include_header.html -->
<script language="javascript">
/*
* Helper function to show and hide areas of the filterview
*/
function toggleSourceTypeVisibility(FormFieldName)
{
var myfield = document.getElementById(FormFieldName);
if (myfield.value == 1)
{
showvisibility("HiddenDiskTypeOptions");
hidevisibility("HiddenDatabaseTypeOptions");
}
else if (myfield.value == 2)
{
showvisibility("HiddenDatabaseTypeOptions");
hidevisibility("HiddenDiskTypeOptions");
hidevisibility("HiddenDBTypesOptions");
}
else if (myfield.value == 3)
{
showvisibility("HiddenDatabaseTypeOptions");
hidevisibility("HiddenDiskTypeOptions");
showvisibility("HiddenDBTypesOptions");
}
}
</script>
<!-- IF ISERROR="true" -->
<br><br>
<center>
<div class="table_with_border_second ErrorMsg" style="width:600px">
<div class="PriorityError">{LN_GEN_ERRORDETAILS}</div>
<p>{ERROR_MSG}</p>
</div>
<br><br>
<a href="javascript:history.back();" target="_top">{LN_GEN_ERRORRETURNPREV}</a>
</center>
<br><br>
<!-- ENDIF ISERROR="true" -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" align="center" class="with_border">
<tr>
<td colspan="3" class="title" nowrap><B>{LN_CHARTS_CENTER}</B></td>
</tr>
<tr>
<td align="center" class="line2">
<br><br>
<!-- IF LISTCHARTS="true" -->
<table border="0" cellpadding="2" cellspacing="1" bgcolor="#DDDDDD" width="750" class="with_border_alternate">
<tr>
<td align="center" width="50" class="cellmenu1"><b>{LN_SOURCES_ID}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_SOURCES_NAME}</b></td>
<td align="center" width="150" class="cellmenu1"><b>{LN_SOURCES_TYPE}</b></td>
<td align="center" width="200" class="cellmenu1"><b>{LN_SOURCES_ASSIGNTO}</b></td>
<td align="center" width="150" class="cellmenu1"><b>{LN_GEN_ACTIONS}</b></td>
</tr>
<!-- BEGIN CHARTS -->
<tr>
<td align="center" class="{cssclass}"><b>{ID}</b></td>
<td align="left" class="{cssclass}">
<!-- IF ActionsAllowed="true" -->
<a href="{BASEPATH}admin/charts.php?op=edit&id={ID}">{DisplayName}</a>
<!-- ENDIF ActionsAllowed="true" -->
<!-- IF ActionsAllowed!="true" -->
<b>{DisplayName}</b>
<!-- ENDIF ActionsAllowed!="true" -->
</td>
<td align="left" class="{cssclass}"><img src="{ChartTypeImage}" width="16" align="left"> <b>{ChartTypeText}</b></td>
<td align="left" class="{cssclass}"><img src="{ChartAssignedToImage}" width="16" align="left"> <b>{ChartAssignedToText}</b></td>
<td align="center" class="{cssclass}">
<!-- IF ActionsAllowed="true" -->
&nbsp;<a href="{BASEPATH}admin/charts.php?op=edit&id={ID}"><img src="{MENU_EDIT}" width="16" title="{LN_CHARTS_EDIT}"></a>
&nbsp;<a href="{BASEPATH}admin/charts.php?op=delete&id={ID}"><img src="{MENU_DELETE}" width="16" title="{LN_CHARTS_DELETE}"></a>
<!-- ENDIF ActionsAllowed="true" -->
<!-- IF ActionsAllowed!="true" -->
&nbsp;<img src="{MENU_EDIT_DISABLED}" width="16" title="{LN_GEN_DISABLED}">
&nbsp;<img src="{MENU_DELETE_DISABLED}" width="16" title="{LN_GEN_DISABLED}">
<!-- ENDIF ActionsAllowed!="true" -->
</td>
</tr>
<!-- END CHARTS -->
<tr>
<td align="center" colspan="5" class="line0"><b><a href="{BASEPATH}admin/charts.php?op=add"><img src="{MENU_ADD}" title="{LN_CHARTS_ADD}">&nbsp;{LN_CHARTS_ADD}</a></b></td>
</tr>
</table>
<!-- ENDIF LISTCHARTS="true" -->
<!-- IF ISEDITORNEWSOURCE="true" -->
<form action="{BASEPATH}admin/sources.php" method="post">
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr>
<td align="center" class="cellmenu1" colspan="2"><b>{LN_SOURCES_ADDEDIT}</b></td>
</tr>
<tr>
<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" nowrap><b>{LN_SOURCES_TYPE}</b></td>
<td align="right" class="line1">
<select id="SourceType" name="SourceType" size="1" OnChange="toggleSourceTypeVisibility('SourceType');">
<!-- BEGIN SOURCETYPES -->
<option {selected} value="{type}">{DisplayName}</option>
<!-- END SOURCETYPES -->
</select>
</td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_VIEW}</b></td>
<td align="right" class="line1">
<select id="SourceViewID" name="SourceViewID" size="1">
<!-- BEGIN VIEWS -->
<option {selected} value="{ID}">{DisplayName}</option>
<!-- END VIEWS -->
</select>
</td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_MSGPARSERS}</b></td>
<td align="right" class="line1"><input type="text" name="MsgParserList" size="55" maxlength="255" value="{MsgParserList}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_NORMALIZEMSG}</b></td>
<td align="right" class="line1"><input type="checkbox" name="MsgNormalize" value="1" {CHECKED_ISNORMALIZEMSG}></td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_GEN_USERONLY}</b></td>
<td align="right" class="line1"><input type="checkbox" name="isuseronly" value="{userid}" {CHECKED_ISUSERONLY}></td>
</tr>
<!-- IF ISGROUPSAVAILABLE="true" -->
<tr>
<td align="left" class="cellmenu2"><b>{LN_GEN_GROUPONLY}</b></td>
<td align="right" class="line2">
<select name="groupid" size="1" STYLE="width: 300px">
<!-- BEGIN SUBGROUPS -->
<option value="{mygroupid}" {group_selected}>{groupname}</option>
<!-- END SUBGROUPS -->
</select>
</td>
</tr>
<!-- ENDIF ISGROUPSAVAILABLE="true" -->
</table>
<br>
<div id="HiddenDiskTypeOptions" class="ShownContent">
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr><td align="center" class="cellmenu1" colspan="2"><b>{LN_SOURCES_DISKTYPEOPTIONS}</b></td></tr>
<tr>
<td align="left" class="cellmenu2" width="250" nowrap><b>{LN_CFG_LOGLINETYPE}</b></td>
<td align="right" class="line0" width="350">
<select name="SourceLogLineType" size="1">
<!-- BEGIN LOGLINETYPES -->
<option {selected} value="{type}">{DisplayName}</option>
<!-- END LOGLINETYPES -->
</select>
</td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_SYSLOGFILE}</b></td>
<td align="right" class="line1"><input type="text" name="SourceDiskFile" size="50" maxlength="255" value="{SourceDiskFile}"></td>
</tr>
</table>
</div>
<div id="HiddenDatabaseTypeOptions" class="ShownContent">
<table border="0" cellpadding="1" cellspacing="1" width="600" align="center" class="with_border">
<tr><td align="center" class="cellmenu1" colspan="2"><b>{LN_CFG_DATABASETYPEOPTIONS}</b></td></tr>
</table>
<div id="HiddenDBTypesOptions" class="ShownContent">
<table border="0" cellpadding="1" cellspacing="1" width="600" align="center" class="with_border">
<tr>
<td align="left" class="cellmenu2" width="250" nowrap><b>{LN_CFG_DBSTORAGEENGINE}</b></td>
<td align="right" class="line1" width="350">
<select name="SourceDBType" size="1">
<!-- BEGIN DBTYPES -->
<option {selected} value="{type}">{DisplayName}</option>
<!-- END DBTYPES -->
</select>
</td>
</tr>
</table>
</div>
<table border="0" cellpadding="1" cellspacing="1" width="600" align="center" class="with_border">
<tr>
<td align="left" class="cellmenu2" width="250" nowrap><b>{LN_CFG_DBTABLETYPE}</b></td>
<td align="right" class="line0" width="350"><input type="text" name="SourceDBTableType" size="40" maxlength="255" value="{SourceDBTableType}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_DBSERVER}</b></td>
<td align="right" class="line0"><input type="text" name="SourceDBServer" size="40" maxlength="255" value="{SourceDBServer}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_DBNAME}</b></td>
<td align="right" class="line1"><input type="text" name="SourceDBName" size="40" maxlength="255" value="{SourceDBName}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_DBTABLENAME}</b></td>
<td align="right" class="line0"><input type="text" name="SourceDBTableName" size="40" maxlength="255" value="{SourceDBTableName}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_DBUSER}</b></td>
<td align="right" class="line1"><input type="text" name="SourceDBUser" size="40" maxlength="255" value="{SourceDBUser}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_DBPASSWORD}</b></td>
<td align="right" class="line0"><input type="password" name="SourceDBPassword" size="40" maxlength="255" value="{SourceDBPassword}"></td>
</tr>
<tr>
<td align="left" class="cellmenu2" nowrap><b>{LN_CFG_DBROWCOUNTING}</b></td>
<td align="right" class="line1" width="100%">
<input type="radio" name="SourceDBEnableRowCounting" value="true" {SourceDBEnableRowCounting_true}> Yes <input type="radio" name="SourceDBEnableRowCounting" value="false" {SourceDBEnableRowCounting_false}> No
</td>
</tr>
</table>
</div>
<table border="0" cellpadding="1" cellspacing="1" bgcolor="#DDDDDD" width="600" class="with_border_alternate">
<tr>
<td align="center" colspan="2">
<input type="submit" value="{SOURCE_SENDBUTTON}">
<input type="hidden" name="op" value="{SOURCE_FORMACTION}">
<input type="hidden" name="id" value="{SOURCEID}">
</td>
</tr>
</table>
</form>
<script language="javascript">
// Manually perform initial Javascript Calls
toggleSourceTypeVisibility('SourceType');
</script>
<!-- ENDIF ISEDITORNEWSOURCE="true" -->
<br><br>
</td>
</tr>
</table>
<!-- INCLUDE include_footer.html -->

View File

@ -7,6 +7,7 @@
<td class="topmenu2" nowrap align="center" width="125"><a class="topmenu1_link" href="{BASEPATH}admin/sources.php" target="_top"><img align="left" src="{MENU_DATAEDIT}" width="16" height="16" vspace="0">{LN_ADMINMENU_SOURCEOPT}</a></td>
<td class="topmenu2" nowrap align="center" width="110"><a class="topmenu1_link" href="{BASEPATH}admin/views.php" target="_top"><img align="left" src="{MENU_DOCUMENTVIEW}" width="16" height="16" vspace="0">{LN_ADMINMENU_VIEWSOPT}</a></td>
<td class="topmenu2" nowrap align="center" width="125"><a class="topmenu1_link" href="{BASEPATH}admin/searches.php" target="_top"><img align="left" src="{MENU_TEXT_FIND}" width="16" height="16" vspace="0">{LN_ADMINMENU_SEARCHOPT}</a></td>
<td class="topmenu2" nowrap align="center" width="125"><a class="topmenu1_link" href="{BASEPATH}admin/charts.php" target="_top"><img align="left" src="{MENU_CHARTS}" width="16" height="16" vspace="0">{LN_ADMINMENU_CHARTOPT}</a></td>
<!-- IF SESSION_ISADMIN="1" -->
<td class="topmenu2" nowrap align="center" width="110"><a class="topmenu1_link" href="{BASEPATH}admin/users.php" target="_top"><img align="left" src="{MENU_ADMINUSERS}" width="16" height="16" vspace="0">{LN_ADMINMENU_USEROPT}</a></td>