mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Added source admin pages and implemented listing of sources.
Adding/edit and delete will be added in the next step
This commit is contained in:
parent
8d5cdd844a
commit
88f6233778
@ -3,7 +3,7 @@
|
|||||||
*********************************************************************
|
*********************************************************************
|
||||||
* phpLogCon - http://www.phplogcon.org
|
* phpLogCon - http://www.phplogcon.org
|
||||||
* -----------------------------------------------------------------
|
* -----------------------------------------------------------------
|
||||||
* User Admin File
|
* Search Admin File
|
||||||
*
|
*
|
||||||
* -> Helps administrating custom searches
|
* -> Helps administrating custom searches
|
||||||
*
|
*
|
||||||
|
402
src/admin/sources.php
Normal file
402
src/admin/sources.php
Normal file
@ -0,0 +1,402 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
*********************************************************************
|
||||||
|
* phpLogCon - http://www.phplogcon.org
|
||||||
|
* -----------------------------------------------------------------
|
||||||
|
* Sources Admin File
|
||||||
|
*
|
||||||
|
* -> Helps administrating phplogcon datasources
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
// Only if the user is an admin!
|
||||||
|
//if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
|
||||||
|
// DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] );
|
||||||
|
|
||||||
|
if ( isset($_GET['op']) )
|
||||||
|
{
|
||||||
|
if ($_GET['op'] == "add")
|
||||||
|
{
|
||||||
|
// Set Mode to add
|
||||||
|
$content['ISEDITORNEWSEARCH'] = "true";
|
||||||
|
$content['SEARCH_FORMACTION'] = "addnewsearch";
|
||||||
|
$content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_ADD'];
|
||||||
|
|
||||||
|
//PreInit these values
|
||||||
|
$content['DisplayName'] = "";
|
||||||
|
$content['SearchQuery'] = "";
|
||||||
|
$content['userid'] = null;
|
||||||
|
$content['CHECKED_ISUSERONLY'] = "";
|
||||||
|
$content['SEARCHID'] = "";
|
||||||
|
|
||||||
|
// --- Check if groups are available
|
||||||
|
$content['SUBGROUPS'] = GetGroupsForSelectfield();
|
||||||
|
if ( is_array($content['SUBGROUPS']) )
|
||||||
|
$content['ISGROUPSAVAILABLE'] = true;
|
||||||
|
else
|
||||||
|
$content['ISGROUPSAVAILABLE'] = false;
|
||||||
|
|
||||||
|
/*
|
||||||
|
$sqlquery = "SELECT " .
|
||||||
|
DB_GROUPS . ".ID as mygroupid, " .
|
||||||
|
DB_GROUPS . ".groupname " .
|
||||||
|
"FROM " . DB_GROUPS .
|
||||||
|
" ORDER BY " . DB_GROUPS . ".groupname";
|
||||||
|
$result = DB_Query($sqlquery);
|
||||||
|
$content['SUBGROUPS'] = DB_GetAllRows($result, true);
|
||||||
|
if ( isset($content['SUBGROUPS']) && count($content['SUBGROUPS']) > 0 )
|
||||||
|
{
|
||||||
|
// Process All Groups
|
||||||
|
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
|
||||||
|
$content['SUBGROUPS'][$i]['group_selected'] = "";
|
||||||
|
|
||||||
|
// Enable Group Selection
|
||||||
|
$content['ISGROUPSAVAILABLE'] = true;
|
||||||
|
array_unshift( $content['SUBGROUPS'], array ("mygroupid" => -1, "groupname" => $content['LN_SEARCH_SELGROUPENABLE'], "group_selected" => "") );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$content['ISGROUPSAVAILABLE'] = false;*/
|
||||||
|
// ---
|
||||||
|
}
|
||||||
|
else if ($_GET['op'] == "edit")
|
||||||
|
{
|
||||||
|
// Set Mode to edit
|
||||||
|
$content['ISEDITORNEWSEARCH'] = "true";
|
||||||
|
$content['SEARCH_FORMACTION'] = "editsearch";
|
||||||
|
$content['SEARCH_SENDBUTTON'] = $content['LN_SEARCH_EDIT'];
|
||||||
|
|
||||||
|
if ( isset($_GET['id']) )
|
||||||
|
{
|
||||||
|
//PreInit these values
|
||||||
|
$content['SEARCHID'] = DB_RemoveBadChars($_GET['id']);
|
||||||
|
|
||||||
|
$sqlquery = "SELECT * " .
|
||||||
|
" FROM " . DB_SEARCHES .
|
||||||
|
" WHERE ID = " . $content['SEARCHID'];
|
||||||
|
|
||||||
|
$result = DB_Query($sqlquery);
|
||||||
|
$mysearch = DB_GetSingleRow($result, true);
|
||||||
|
if ( isset($mysearch['DisplayName']) )
|
||||||
|
{
|
||||||
|
$content['SEARCHID'] = $mysearch['ID'];
|
||||||
|
$content['DisplayName'] = $mysearch['DisplayName'];
|
||||||
|
$content['SearchQuery'] = $mysearch['SearchQuery'];
|
||||||
|
if ( $mysearch['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 ( $mysearch['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysearch['groupid'] )
|
||||||
|
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
|
||||||
|
else
|
||||||
|
$content['SUBGROUPS'][$i]['group_selected'] = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable Group Selection
|
||||||
|
$content['ISGROUPSAVAILABLE'] = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$content['ISGROUPSAVAILABLE'] = false;
|
||||||
|
// ---
|
||||||
|
/*
|
||||||
|
// --- Check if groups are available
|
||||||
|
$sqlquery = "SELECT " .
|
||||||
|
DB_GROUPS . ".ID as mygroupid, " .
|
||||||
|
DB_GROUPS . ".groupname " .
|
||||||
|
"FROM " . DB_GROUPS .
|
||||||
|
" ORDER BY " . DB_GROUPS . ".groupname";
|
||||||
|
$result = DB_Query($sqlquery);
|
||||||
|
$content['SUBGROUPS'] = DB_GetAllRows($result, true);
|
||||||
|
if ( isset($content['SUBGROUPS']) && count($content['SUBGROUPS']) > 0 )
|
||||||
|
{
|
||||||
|
// Process All Groups
|
||||||
|
for($i = 0; $i < count($content['SUBGROUPS']); $i++)
|
||||||
|
{
|
||||||
|
if ( $mysearch['groupid'] != null && $content['SUBGROUPS'][$i]['mygroupid'] == $mysearch['groupid'] )
|
||||||
|
$content['SUBGROUPS'][$i]['group_selected'] = "selected";
|
||||||
|
else
|
||||||
|
$content['SUBGROUPS'][$i]['group_selected'] = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable Group Selection
|
||||||
|
$content['ISGROUPSAVAILABLE'] = true;
|
||||||
|
array_unshift( $content['SUBGROUPS'], array ("mygroupid" => -1, "groupname" => $content['LN_SEARCH_SELGROUPENABLE'], "group_selected" => "") );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$content['ISGROUPSAVAILABLE'] = false;
|
||||||
|
// ---
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$content['ISEDITORNEWSEARCH'] = false;
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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['SEARCHID'] = DB_RemoveBadChars($_GET['id']);
|
||||||
|
|
||||||
|
// Get UserInfo
|
||||||
|
$result = DB_Query("SELECT DisplayName FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] );
|
||||||
|
$myrow = DB_GetSingleRow($result, true);
|
||||||
|
if ( !isset($myrow['DisplayName']) )
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] );
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- 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_SEARCH_WARNDELETESEARCH'], $myrow['DisplayName'] ), $content['LN_DELETEYES'], $content['LN_DELETENO'] );
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
|
// do the delete!
|
||||||
|
$result = DB_Query( "DELETE FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID'] );
|
||||||
|
if ($result == FALSE)
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_DELSEARCH'], $content['SEARCHID'] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
DB_FreeQuery($result);
|
||||||
|
|
||||||
|
// Do the final redirect
|
||||||
|
RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_HASBEENDEL'], $myrow['DisplayName'] ) , "searches.php" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_INVALIDID'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset($_POST['op']) )
|
||||||
|
{
|
||||||
|
if ( isset ($_POST['id']) ) { $content['SEARCHID'] = intval(DB_RemoveBadChars($_POST['id'])); } else {$content['SEARCHID'] = -1; }
|
||||||
|
if ( isset ($_POST['DisplayName']) ) { $content['DisplayName'] = DB_RemoveBadChars($_POST['DisplayName']); } else {$content['DisplayName'] = ""; }
|
||||||
|
if ( isset ($_POST['SearchQuery']) ) { $content['SearchQuery'] = DB_RemoveBadChars($_POST['SearchQuery']); } else {$content['SearchQuery'] = ""; }
|
||||||
|
|
||||||
|
// 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['DisplayName'] == "" )
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_DISPLAYNAMEEMPTY'];
|
||||||
|
}
|
||||||
|
else if ( $content['SearchQuery'] == "" )
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = $content['LN_SEARCH_ERROR_SEARCHQUERYEMPTY'];
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
|
if ( !isset($content['ISERROR']) )
|
||||||
|
{
|
||||||
|
// Everything was alright, so we go to the next step!
|
||||||
|
if ( $_POST['op'] == "addnewsearch" )
|
||||||
|
{
|
||||||
|
// Add custom search now!
|
||||||
|
$sqlquery = "INSERT INTO " . DB_SEARCHES . " (DisplayName, SearchQuery, userid, groupid)
|
||||||
|
VALUES ('" . $content['DisplayName'] . "',
|
||||||
|
'" . $content['SearchQuery'] . "',
|
||||||
|
" . $content['userid'] . ",
|
||||||
|
" . $content['groupid'] . "
|
||||||
|
)";
|
||||||
|
$result = DB_Query($sqlquery);
|
||||||
|
DB_FreeQuery($result);
|
||||||
|
|
||||||
|
// Do the final redirect
|
||||||
|
RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENADDED'], $content['DisplayName'] ) , "searches.php" );
|
||||||
|
}
|
||||||
|
else if ( $_POST['op'] == "editsearch" )
|
||||||
|
{
|
||||||
|
$result = DB_Query("SELECT ID FROM " . DB_SEARCHES . " WHERE ID = " . $content['SEARCHID']);
|
||||||
|
$myrow = DB_GetSingleRow($result, true);
|
||||||
|
if ( !isset($myrow['ID']) )
|
||||||
|
{
|
||||||
|
$content['ISERROR'] = true;
|
||||||
|
$content['ERROR_MSG'] = GetAndReplaceLangStr( $content['LN_SEARCH_ERROR_IDNOTFOUND'], $content['SEARCHID'] );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Edit the Search Entry now!
|
||||||
|
$result = DB_Query("UPDATE " . DB_SEARCHES . " SET
|
||||||
|
DisplayName = '" . $content['DisplayName'] . "',
|
||||||
|
SearchQuery = '" . $content['SearchQuery'] . "',
|
||||||
|
userid = " . $content['userid'] . ",
|
||||||
|
groupid = " . $content['groupid'] . "
|
||||||
|
WHERE ID = " . $content['SEARCHID']);
|
||||||
|
DB_FreeQuery($result);
|
||||||
|
|
||||||
|
// Done redirect!
|
||||||
|
RedirectResult( GetAndReplaceLangStr( $content['LN_SEARCH_HASBEENEDIT'], $content['DisplayName']) , "searches.php" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($_POST['op']) && !isset($_GET['op']) )
|
||||||
|
{
|
||||||
|
// Default Mode = List Searches
|
||||||
|
$content['LISTSOURCES'] = "true";
|
||||||
|
|
||||||
|
// Copy Views array for further modifications
|
||||||
|
$content['SOURCES'] = $content['Sources'];
|
||||||
|
|
||||||
|
// --- Process Sources
|
||||||
|
$i = 0; // Help counter!
|
||||||
|
foreach ($content['SOURCES'] as &$mySource )
|
||||||
|
{
|
||||||
|
// --- Set Image for Type
|
||||||
|
// NonNUMERIC are config files Sources, can not be editied
|
||||||
|
if ( is_numeric($mySource['ID']) )
|
||||||
|
{
|
||||||
|
if ( $mySource['userid'] != null )
|
||||||
|
{
|
||||||
|
$mySource['SourcesAssignedToImage'] = $content["MENU_ADMINUSERS"];
|
||||||
|
$mySource['SourcesAssignedToText'] = $content["LN_GEN_USERONLY"];
|
||||||
|
}
|
||||||
|
else if ( $mySource['groupid'] != null )
|
||||||
|
{
|
||||||
|
$mySource['SourcesAssignedToImage'] = $content["MENU_ADMINGROUPS"];
|
||||||
|
$mySource['SourcesAssignedToText'] = $content["LN_GEN_GROUPONLY"];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mySource['SourcesAssignedToImage'] = $content["MENU_GLOBAL"];
|
||||||
|
$mySource['SourcesAssignedToText'] = $content["LN_GEN_GLOBAL"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mySource['SourcesAssignedToImage'] = $content["MENU_INTERNAL"];
|
||||||
|
$mySource['SourcesAssignedToText'] = $content["LN_GEN_CONFIGFILE"];
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
|
// --- Set SourceType
|
||||||
|
if ( $mySource['SourceType'] == SOURCE_DISK )
|
||||||
|
{
|
||||||
|
$mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DISK"];
|
||||||
|
$mySource['SourcesTypeText'] = $content["LN_SOURCES_DISK"];
|
||||||
|
}
|
||||||
|
else if ( $mySource['SourceType'] == SOURCE_DB )
|
||||||
|
{
|
||||||
|
$mySource['SourcesTypeImage'] = $content["MENU_SOURCE_DB"];
|
||||||
|
$mySource['SourcesTypeText'] = $content["LN_SOURCES_DB"];
|
||||||
|
}
|
||||||
|
else if ( $mySource['SourceType'] == SOURCE_PDO )
|
||||||
|
{
|
||||||
|
$mySource['SourcesTypeImage'] = $content["MENU_SOURCE_PDO"];
|
||||||
|
$mySource['SourcesTypeText'] = $content["LN_SOURCES_PDO"];
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
|
// --- Set CSS Class
|
||||||
|
if ( $i % 2 == 0 )
|
||||||
|
$mySource['cssclass'] = "line1";
|
||||||
|
else
|
||||||
|
$mySource['cssclass'] = "line2";
|
||||||
|
$i++;
|
||||||
|
// ---
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
// print_r ( $content['SOURCES'] );
|
||||||
|
|
||||||
|
}
|
||||||
|
// --- END Custom Code
|
||||||
|
|
||||||
|
// --- BEGIN CREATE TITLE
|
||||||
|
$content['TITLE'] = InitPageTitle();
|
||||||
|
$content['TITLE'] .= " :: " . $content['LN_ADMINMENU_SOURCEOPT'];
|
||||||
|
// --- END CREATE TITLE
|
||||||
|
|
||||||
|
// --- Parsen and Output
|
||||||
|
InitTemplateParser();
|
||||||
|
$page -> parser($content, "admin/admin_sources.html");
|
||||||
|
$page -> output();
|
||||||
|
// ---
|
||||||
|
|
||||||
|
?>
|
@ -3,7 +3,7 @@
|
|||||||
*********************************************************************
|
*********************************************************************
|
||||||
* phpLogCon - http://www.phplogcon.org
|
* phpLogCon - http://www.phplogcon.org
|
||||||
* -----------------------------------------------------------------
|
* -----------------------------------------------------------------
|
||||||
* User Admin File
|
* Views Admin File
|
||||||
*
|
*
|
||||||
* -> Helps administrating custom user views
|
* -> Helps administrating custom user views
|
||||||
*
|
*
|
||||||
@ -543,7 +543,7 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
|
|||||||
// Copy Views array for further modifications
|
// Copy Views array for further modifications
|
||||||
$content['VIEWS'] = $content['Views'];
|
$content['VIEWS'] = $content['Views'];
|
||||||
|
|
||||||
// --- Process Users
|
// --- Process Views
|
||||||
$i = 0; // Help counter!
|
$i = 0; // Help counter!
|
||||||
foreach ($content['VIEWS'] as &$myView )
|
foreach ($content['VIEWS'] as &$myView )
|
||||||
{
|
{
|
||||||
|
BIN
src/images/icons/data_gear.png
Normal file
BIN
src/images/icons/data_gear.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 885 B |
BIN
src/images/icons/data_table.png
Normal file
BIN
src/images/icons/data_table.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 788 B |
BIN
src/images/icons/document_text.png
Normal file
BIN
src/images/icons/document_text.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 601 B |
@ -437,6 +437,9 @@ function InitFrontEndVariables()
|
|||||||
$content['MENU_DELETE_DISABLED'] = $content['BASEPATH'] . "images/icons/delete_disabled.png";
|
$content['MENU_DELETE_DISABLED'] = $content['BASEPATH'] . "images/icons/delete_disabled.png";
|
||||||
$content['MENU_MOVE_UP'] = $content['BASEPATH'] . "images/icons/nav_up_blue.png";
|
$content['MENU_MOVE_UP'] = $content['BASEPATH'] . "images/icons/nav_up_blue.png";
|
||||||
$content['MENU_MOVE_DOWN'] = $content['BASEPATH'] . "images/icons/nav_down_blue.png";
|
$content['MENU_MOVE_DOWN'] = $content['BASEPATH'] . "images/icons/nav_down_blue.png";
|
||||||
|
$content['MENU_SOURCE_DISK'] = $content['BASEPATH'] . "images/icons/document_text.png";
|
||||||
|
$content['MENU_SOURCE_DB'] = $content['BASEPATH'] . "images/icons/data_table.png";
|
||||||
|
$content['MENU_SOURCE_PDO'] = $content['BASEPATH'] . "images/icons/data_gear.png";
|
||||||
|
|
||||||
$content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png";
|
$content['MENU_PAGER_BEGIN'] = $content['BASEPATH'] . "images/icons/media_beginning.png";
|
||||||
$content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png";
|
$content['MENU_PAGER_PREVIOUS'] = $content['BASEPATH'] . "images/icons/media_rewind.png";
|
||||||
@ -521,7 +524,7 @@ function InitConfigurationValues()
|
|||||||
LoadViewsFromDatabase();
|
LoadViewsFromDatabase();
|
||||||
|
|
||||||
// Load Configured Sources
|
// Load Configured Sources
|
||||||
// LoadSourcesFromDatabase();
|
LoadSourcesFromDatabase();
|
||||||
|
|
||||||
|
|
||||||
// Database Version Checker!
|
// Database Version Checker!
|
||||||
|
@ -55,14 +55,25 @@ function InitSourceConfigs()
|
|||||||
{
|
{
|
||||||
// Set Array Index, TODO: Check for invalid characters!
|
// Set Array Index, TODO: Check for invalid characters!
|
||||||
$iSourceID = $mysource['ID'];
|
$iSourceID = $mysource['ID'];
|
||||||
// Copy general properties
|
|
||||||
// $content['Sources'][$iSourceID]['ID'] = $mysource['ID'];
|
|
||||||
// $content['Sources'][$iSourceID]['Name'] = $mysource['Name'];
|
|
||||||
// $content['Sources'][$iSourceID]['SourceType'] = $mysource['SourceType'];
|
|
||||||
|
|
||||||
// Set default if not set!
|
// --- Set defaults if not set!
|
||||||
if ( !isset($mysource['LogLineType']) )
|
if ( !isset($mysource['LogLineType']) )
|
||||||
|
{
|
||||||
|
$CFG['Sources'][$iSourceID]['LogLineType'] = "syslog";
|
||||||
$content['Sources'][$iSourceID]['LogLineType'] = "syslog";
|
$content['Sources'][$iSourceID]['LogLineType'] = "syslog";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !isset($mysource['userid']) )
|
||||||
|
{
|
||||||
|
$CFG['Sources'][$iSourceID]['userid'] = null;
|
||||||
|
$content['Sources'][$iSourceID]['userid'] = null;
|
||||||
|
}
|
||||||
|
if ( !isset($mysource['groupid']) )
|
||||||
|
{
|
||||||
|
$CFG['Sources'][$iSourceID]['groupid'] = null;
|
||||||
|
$content['Sources'][$iSourceID]['groupid'] = null;
|
||||||
|
}
|
||||||
|
// ---
|
||||||
|
|
||||||
// Set different view if necessary
|
// Set different view if necessary
|
||||||
if ( isset($_SESSION[$iSourceID . "-View"]) )
|
if ( isset($_SESSION[$iSourceID . "-View"]) )
|
||||||
@ -404,6 +415,58 @@ function LoadViewsFromDatabase()
|
|||||||
// $CFG['Views'] = array_merge ( $CFG['Views'], $myrows );
|
// $CFG['Views'] = array_merge ( $CFG['Views'], $myrows );
|
||||||
$content['Views'] = $CFG['Views'];
|
$content['Views'] = $CFG['Views'];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function LoadSourcesFromDatabase()
|
||||||
|
{
|
||||||
|
// Needed to make global
|
||||||
|
global $CFG, $content;
|
||||||
|
|
||||||
|
// --- Create SQL Query
|
||||||
|
// Create Where for USERID
|
||||||
|
if ( isset($content['SESSION_LOGGEDIN']) && $content['SESSION_LOGGEDIN'] )
|
||||||
|
$szWhereUser = " OR " . DB_SOURCES . ".userid = " . $content['SESSION_USERID'] . " ";
|
||||||
|
else
|
||||||
|
$szWhereUser = "";
|
||||||
|
|
||||||
|
if ( isset($content['SESSION_GROUPIDS']) )
|
||||||
|
$szGroupWhere = " OR " . DB_SOURCES . ".groupid IN (" . $content['SESSION_GROUPIDS'] . ")";
|
||||||
|
else
|
||||||
|
$szGroupWhere = "";
|
||||||
|
$sqlquery = " SELECT " .
|
||||||
|
DB_SOURCES . ".*, " .
|
||||||
|
DB_USERS . ".username, " .
|
||||||
|
DB_GROUPS . ".groupname " .
|
||||||
|
" FROM " . DB_SOURCES .
|
||||||
|
" LEFT OUTER JOIN (" . DB_USERS . ", " . DB_GROUPS .
|
||||||
|
") ON (" .
|
||||||
|
DB_SOURCES . ".userid=" . DB_USERS . ".ID AND " .
|
||||||
|
DB_SOURCES . ".groupid=" . DB_GROUPS . ".ID " .
|
||||||
|
") " .
|
||||||
|
" WHERE (" . DB_SOURCES . ".userid IS NULL AND " . DB_SOURCES . ".groupid IS NULL) " .
|
||||||
|
$szWhereUser .
|
||||||
|
$szGroupWhere .
|
||||||
|
" ORDER BY " . DB_SOURCES . ".userid, " . DB_SOURCES . ".groupid, " . DB_SOURCES . ".DisplayName";
|
||||||
|
// ---
|
||||||
|
|
||||||
|
// Get Sources from DB now!
|
||||||
|
$result = DB_Query($sqlquery);
|
||||||
|
$myrows = DB_GetAllRows($result, true);
|
||||||
|
if ( isset($myrows) && count($myrows) > 0 )
|
||||||
|
{
|
||||||
|
// Overwrite existing Views array
|
||||||
|
unset($CFG['Sources']);
|
||||||
|
|
||||||
|
// Unpack the Columns and append to Views Array
|
||||||
|
foreach ($myrows as &$mySource )
|
||||||
|
{
|
||||||
|
// Append to Views Array
|
||||||
|
$CFG['Sources'][ $mySource['ID'] ] = $mySource['ID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy to content array!
|
||||||
|
$content['Sources'] = $CFG['Sources'];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ $content['LN_GEN_CUSTBTNSRCH'] = "Custom search string";
|
|||||||
$content['LN_GEN_SUCCESSFULLYSAVED'] = "The configuration Values have been successfully saved";
|
$content['LN_GEN_SUCCESSFULLYSAVED'] = "The configuration Values have been successfully saved";
|
||||||
$content['LN_GEN_INTERNAL'] = "Internal";
|
$content['LN_GEN_INTERNAL'] = "Internal";
|
||||||
$content['LN_GEN_DISABLED'] = "Function disabled";
|
$content['LN_GEN_DISABLED'] = "Function disabled";
|
||||||
|
$content['LN_GEN_CONFIGFILE'] = "Configuration File";
|
||||||
$content['LN_GEN_'] = "";
|
$content['LN_GEN_'] = "";
|
||||||
|
|
||||||
// User Center
|
// User Center
|
||||||
@ -178,5 +179,21 @@ $content['LN_VIEWS_HASBEENEDIT'] = "The Custom Search '%1' has been successfully
|
|||||||
$content['LN_VIEWS_'] = "";
|
$content['LN_VIEWS_'] = "";
|
||||||
$content['LN_VIEWS_'] = "";
|
$content['LN_VIEWS_'] = "";
|
||||||
|
|
||||||
|
$content['LN_SOURCES_CENTER'] = "Sources Options";
|
||||||
|
$content['LN_SOURCES_EDIT'] = "Edit Source";
|
||||||
|
$content['LN_SOURCES_DELETE'] = "Delete Source";
|
||||||
|
$content['LN_SOURCES_ID'] = "ID";
|
||||||
|
$content['LN_SOURCES_NAME'] = "Source Name";
|
||||||
|
$content['LN_SOURCES_TYPE'] = "Source Type";
|
||||||
|
$content['LN_SOURCES_ASSIGNTO'] = "Assigned To";
|
||||||
|
$content['LN_SOURCES_DISK'] = "Diskfile";
|
||||||
|
$content['LN_SOURCES_DB'] = "MySQL Database";
|
||||||
|
$content['LN_SOURCES_PDO'] = "PDO Datasource";
|
||||||
|
$content['LN_SOURCES_ADD'] = "Add new Source";
|
||||||
|
$content['LN_SOURCES_'] = "";
|
||||||
|
$content['LN_SOURCES_'] = "";
|
||||||
|
$content['LN_SOURCES_'] = "";
|
||||||
|
$content['LN_SOURCES_'] = "";
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
97
src/templates/admin/admin_sources.html
Normal file
97
src/templates/admin/admin_sources.html
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
<!-- INCLUDE include_header.html -->
|
||||||
|
|
||||||
|
<!-- IF ISERROR="true" -->
|
||||||
|
<center>
|
||||||
|
<h3><font color="red">{ERROR_MSG}</font></h3>
|
||||||
|
</center>
|
||||||
|
<!-- 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_SOURCES_CENTER}</B></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" class="line2">
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<!-- IF LISTSOURCES="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="150" class="cellmenu1"><b>{LN_SOURCES_ASSIGNTO}</b></td>
|
||||||
|
<td align="center" width="200" class="cellmenu1"><b>{LN_GEN_ACTIONS}</b></td>
|
||||||
|
</tr>
|
||||||
|
<!-- BEGIN SOURCES -->
|
||||||
|
<tr>
|
||||||
|
<td align="center" class="{cssclass}"><b>{ID}</b></td>
|
||||||
|
<td align="left" class="{cssclass}"><a href="{BASEPATH}admin/sources.php?op=edit&id={ID}">{Name}</a></td>
|
||||||
|
<td align="left" class="{cssclass}"><img src="{SourcesTypeImage}" width="16" align="left"> <b>{SourcesTypeText}</b></td>
|
||||||
|
<td align="left" class="{cssclass}"><img src="{SourcesAssignedToImage}" width="16" align="left"> <b>{SourcesAssignedToText}</b></td>
|
||||||
|
<td align="center" class="{cssclass}">
|
||||||
|
<!-- IF ActionsAllowed="true" -->
|
||||||
|
<a href="{BASEPATH}admin/sources.php?op=edit&id={ID}"><img src="{MENU_EDIT}" width="16" title="{LN_SOURCES_EDIT}"></a>
|
||||||
|
<a href="{BASEPATH}admin/sources.php?op=delete&id={ID}"><img src="{MENU_DELETE}" width="16" title="{LN_SOURCES_DELETE}"></a>
|
||||||
|
<!-- ENDIF ActionsAllowed="true" -->
|
||||||
|
<!-- IF ActionsAllowed!="true" -->
|
||||||
|
<img src="{MENU_EDIT_DISABLED}" width="16" title="{LN_GEN_DISABLED}">
|
||||||
|
<img src="{MENU_DELETE_DISABLED}" width="16" title="{LN_GEN_DISABLED}">
|
||||||
|
<!-- ENDIF ActionsAllowed!="true" -->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!-- END SOURCES -->
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="5" class="line0"><b><a href="{BASEPATH}admin/sources.php?op=add"><img src="{MENU_ADD}" title="{LN_SOURCES_ADD}"> {LN_SOURCES_ADD}</a></b></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<!-- ENDIF LISTSOURCES="true" -->
|
||||||
|
|
||||||
|
<!-- IF ISEDITORNEWSEARCH="true" -->
|
||||||
|
<form action="{BASEPATH}admin/searches.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_SEARCH_ADDEDIT}</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left" class="cellmenu2" width="250"><b>{LN_SEARCH_NAME}</b></td>
|
||||||
|
<td align="right" class="line1" width="350"><input type="text" name="DisplayName" size="55" maxlength="255" value="{DisplayName}"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left" class="cellmenu2"><b>{LN_GEN_USERONLY}</b></td>
|
||||||
|
<td align="right" class="line2"><input type="text" name="SearchQuery" size="55" maxlength="1024" value="{SearchQuery}"></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_SEARCH_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" -->
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<input type="submit" value="{SEARCH_SENDBUTTON}">
|
||||||
|
<input type="hidden" name="op" value="{SEARCH_FORMACTION}">
|
||||||
|
<input type="hidden" name="id" value="{SEARCHID}">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<!-- ENDIF ISEDITORNEWSEARCH="true" -->
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- INCLUDE include_footer.html -->
|
Loading…
x
Reference in New Issue
Block a user