Searches are loaded now from database as well. Changed minor things config functions

This commit is contained in:
Andre Lorbach 2008-07-17 14:50:19 +02:00
parent 324484c323
commit 2fabf173a9
4 changed files with 352 additions and 278 deletions

View File

@ -58,7 +58,7 @@ IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/admin.php' );
if ( !isset($_SESSION['SESSION_ISADMIN']) || $_SESSION['SESSION_ISADMIN'] == 0 )
DieWithFriendlyErrorMsg( $content['LN_ADMIN_ERROR_NOTALLOWED'] );
if ($_GET['miniop'] == "setisadmin")
if ( isset($_GET['miniop']) && $_GET['miniop'] == "setisadmin" )
{
if ( isset($_GET['id']) && isset($_GET['newval']) )
{

View File

@ -107,57 +107,6 @@ function InitUserSystemPhpLogCon()
}
}
function InitPhpLogConConfigFile($bHandleMissing = true)
{
// Needed to make global
global $CFG, $gl_root_path, $content;
if ( file_exists($gl_root_path . 'config.php') && GetFileLength($gl_root_path . 'config.php') > 0 )
{
// Include the main config
include_once($gl_root_path . 'config.php');
// Easier DB Access
define('DB_CONFIG', $CFG['UserDBPref'] . "config");
define('DB_GROUPS', $CFG['UserDBPref'] . "groups");
define('DB_GROUPMEMBERS', $CFG['UserDBPref'] . "groupmembers");
define('DB_SEARCHES', $CFG['UserDBPref'] . "searches");
define('DB_SOURCES', $CFG['UserDBPref'] . "sources");
define('DB_USERS', $CFG['UserDBPref'] . "users");
define('DB_VIEWS', $CFG['UserDBPref'] . "views");
// Legacy support for old columns definition format!
if ( isset($CFG['Columns']) && is_array($CFG['Columns']) )
AppendLegacyColumns();
// --- Now Copy all entries into content variable
foreach ($CFG as $key => $value )
$content[$key] = $value;
// ---
// For MiscShowPageRenderStats
if ( $CFG['MiscShowPageRenderStats'] == 1 )
{
$content['ShowPageRenderStats'] = "true";
InitPageRenderStats();
}
// return result
return true;
}
else
{
// if handled ourselfe, we die in CheckForInstallPhp.
if ( $bHandleMissing == true )
{
// Check for installscript!
CheckForInstallPhp();
}
else
return false;
}
}
function CheckForInstallPhp()
{
// Check for installscript!
@ -545,22 +494,29 @@ function InitConfigurationValues()
// Now we init the user session stuff
InitUserSession();
if ( isset($CFG["UserDBLoginRequired"]) && $CFG["UserDBLoginRequired"] == true )
// Check if user needs to be logged in
if ( isset($CFG["UserDBLoginRequired"]) && $CFG["UserDBLoginRequired"] == true )
{
if ( !$content['SESSION_LOGGEDIN'] )
{
if ( !$content['SESSION_LOGGEDIN'] )
{
// User needs to be logged in, redirect to login page
if ( !defined("IS_LOGINPAGE") )
RedirectToUserLogin();
}
// User needs to be logged in, redirect to login page
if ( !defined("IS_LOGINPAGE") )
RedirectToUserLogin();
}
else if ( defined('IS_ADMINPAGE') ) // Language System not initialized yet
DieWithFriendlyErrorMsg( "You need to be logged in in order to access the admin pages." );
}
else if ( defined('IS_ADMINPAGE') ) // Language System not initialized yet
DieWithFriendlyErrorMsg( "You need to be logged in in order to access the admin pages." );
// Load Configured Searches
LoadSearchesFromDatabase();
// Load Configured Views
// LoadViewsFromDatabase();
// Load Configured Sources
// LoadSourcesFromDatabase();
// General defaults
// // --- Language Handling
// if ( !isset($content['gen_lang']) ) { $content['gen_lang'] = $CFG['ViewDefaultLanguage'] /*"en"*/; }
// Database Version Checker!
if ( $content['database_internalversion'] > $content['database_installedversion'] )

View File

@ -1,246 +1,335 @@
<?php
/*
/*
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* Maintain and read Source Configurations *
* *
* -> Configuration need variables for the Database connection *
*
* 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.
*********************************************************************
* -> www.phplogcon.org <- *
* ----------------------------------------------------------------- *
* Maintain and read Source Configurations *
* *
* -> Configuration need variables for the Database connection *
*
* 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.
*********************************************************************
*/
*/
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Avoid directly accessing this file!
if ( !defined('IN_PHPLOGCON') )
{
die('Hacking attempt');
exit;
}
// ---
// --- Perform necessary includes
require_once($gl_root_path . 'classes/logstreamconfig.class.php');
// ---
// --- Perform necessary includes
require_once($gl_root_path . 'classes/logstreamconfig.class.php');
// ---
function InitSourceConfigs()
{
global $CFG, $content, $currentSourceID, $gl_root_path;
function InitSourceConfigs()
{
global $CFG, $content, $currentSourceID, $gl_root_path;
// Init Source Configs!
if ( isset($CFG['Sources']) )
{
$iCount = count($CFG['Sources']);
foreach( $CFG['Sources'] as &$mysource )
// Init Source Configs!
if ( isset($CFG['Sources']) )
{
$iCount = count($CFG['Sources']);
foreach( $CFG['Sources'] as &$mysource )
{
if ( isset($mysource['SourceType']) )
{
if ( isset($mysource['SourceType']) )
{
// Set Array Index, TODO: Check for invalid characters!
$iSourceID = $mysource['ID'];
// Copy general properties
// Set Array Index, TODO: Check for invalid characters!
$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!
if ( !isset($mysource['LogLineType']) )
$content['Sources'][$iSourceID]['LogLineType'] = "syslog";
// Set default if not set!
if ( !isset($mysource['LogLineType']) )
$content['Sources'][$iSourceID]['LogLineType'] = "syslog";
// Set different view if necessary
if ( isset($_SESSION[$iSourceID . "-View"]) )
{
// Overwrite configured view!
$content['Sources'][$iSourceID]['ViewID'] = $_SESSION[$iSourceID . "-View"];
}
// Set different view if necessary
if ( isset($_SESSION[$iSourceID . "-View"]) )
{
// Overwrite configured view!
$content['Sources'][$iSourceID]['ViewID'] = $_SESSION[$iSourceID . "-View"];
}
else
{
if ( isset($mysource['ViewID']) )
// Set to configured Source ViewID
$content['Sources'][$iSourceID]['ViewID'] = $mysource['ViewID'];
else
{
if ( isset($mysource['ViewID']) )
// Set to configured Source ViewID
$content['Sources'][$iSourceID]['ViewID'] = $mysource['ViewID'];
else
// Not configured, maybe old legacy cfg. Set default view.
$content['Sources'][$iSourceID]['ViewID'] = strlen($CFG['DefaultViewsID']) > 0 ? $CFG['DefaultViewsID'] : "SYSLOG";
// Not configured, maybe old legacy cfg. Set default view.
$content['Sources'][$iSourceID]['ViewID'] = strlen($CFG['DefaultViewsID']) > 0 ? $CFG['DefaultViewsID'] : "SYSLOG";
}
}
// Only for the display box
$content['Sources'][$iSourceID]['selected'] = "";
// Create Config instance!
if ( $mysource['SourceType'] == SOURCE_DISK )
{
// Perform necessary include
require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php');
// Only for the display box
$content['Sources'][$iSourceID]['selected'] = "";
// Create Config instance!
if ( $mysource['SourceType'] == SOURCE_DISK )
{
// Perform necessary include
require_once($gl_root_path . 'classes/logstreamconfigdisk.class.php');
$content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDisk();
$content['Sources'][$iSourceID]['ObjRef']->FileName = $mysource['DiskFile'];
$content['Sources'][$iSourceID]['ObjRef']->LineParserType = $mysource['LogLineType'];
}
else if ( $mysource['SourceType'] == SOURCE_DB )
{
// Perform necessary include
require_once($gl_root_path . 'classes/logstreamconfigdb.class.php');
$content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDisk();
$content['Sources'][$iSourceID]['ObjRef']->FileName = $mysource['DiskFile'];
$content['Sources'][$iSourceID]['ObjRef']->LineParserType = $mysource['LogLineType'];
}
else if ( $mysource['SourceType'] == SOURCE_DB )
{
// Perform necessary include
require_once($gl_root_path . 'classes/logstreamconfigdb.class.php');
$content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDB();
$content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
$content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
// Workaround a little bug from the installer script
if ( isset($mysource['DBType']) )
$content['Sources'][$iSourceID]['ObjRef']->DBType = $mysource['DBType'];
else
$content['Sources'][$iSourceID]['ObjRef']->DBType = DB_MYSQL;
$content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
// Legacy handling for tabletype!
if ( isset($mysource['DBTableType']) && strtolower($mysource['DBTableType']) == "winsyslog" )
$content['Sources'][$iSourceID]['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare!
else
$content['Sources'][$iSourceID]['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
// Optional parameters!
if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
if ( isset($mysource['DBEnableRowCounting']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting']; }
}
else if ( $mysource['SourceType'] == SOURCE_PDO )
{
// Perform necessary include
require_once($gl_root_path . 'classes/logstreamconfigpdo.class.php');
$content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigPDO();
$content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
$content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
$content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigDB();
$content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
$content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
// Workaround a little bug from the installer script
if ( isset($mysource['DBType']) )
$content['Sources'][$iSourceID]['ObjRef']->DBType = $mysource['DBType'];
$content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
else
$content['Sources'][$iSourceID]['ObjRef']->DBType = DB_MYSQL;
$content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
// Legacy handling for tabletype!
if ( isset($mysource['DBTableType']) && strtolower($mysource['DBTableType']) == "winsyslog" )
$content['Sources'][$iSourceID]['ObjRef']->DBTableType = "monitorware"; // Convert to MonitorWare!
else
$content['Sources'][$iSourceID]['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
// Optional parameters!
if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
if ( isset($mysource['DBEnableRowCounting']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting']; }
}
else
{
// UNKNOWN, remove config entry!
unset($content['Sources'][$iSourceID]);
// TODO: Output CONFIG WARNING
die( "Not supported yet!" );
}
// Set generic configuration options
$content['Sources'][$iSourceID]['ObjRef']->_pageCount = $CFG['ViewEntriesPerPage'];
// Set default SourceID here!
if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) )
$currentSourceID = $iSourceID;
// Optional parameters!
if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
if ( isset($mysource['DBEnableRowCounting']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting']; }
}
else if ( $mysource['SourceType'] == SOURCE_PDO )
{
// Perform necessary include
require_once($gl_root_path . 'classes/logstreamconfigpdo.class.php');
$content['Sources'][$iSourceID]['ObjRef'] = new LogStreamConfigPDO();
$content['Sources'][$iSourceID]['ObjRef']->DBServer = $mysource['DBServer'];
$content['Sources'][$iSourceID]['ObjRef']->DBName = $mysource['DBName'];
$content['Sources'][$iSourceID]['ObjRef']->DBType = $mysource['DBType'];
$content['Sources'][$iSourceID]['ObjRef']->DBTableName = $mysource['DBTableName'];
$content['Sources'][$iSourceID]['ObjRef']->DBTableType = strtolower($mysource['DBTableType']);
// Optional parameters!
if ( isset($mysource['DBPort']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPort = $mysource['DBPort']; }
if ( isset($mysource['DBUser']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBUser = $mysource['DBUser']; }
if ( isset($mysource['DBPassword']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBPassword = $mysource['DBPassword']; }
if ( isset($mysource['DBEnableRowCounting']) ) { $content['Sources'][$iSourceID]['ObjRef']->DBEnableRowCounting = $mysource['DBEnableRowCounting']; }
}
else
{
// UNKNOWN, remove config entry!
unset($content['Sources'][$iSourceID]);
// TODO: Output CONFIG WARNING
die( "Not supported yet!" );
}
// Set generic configuration options
$content['Sources'][$iSourceID]['ObjRef']->_pageCount = $CFG['ViewEntriesPerPage'];
// Set default SourceID here!
if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) )
$currentSourceID = $iSourceID;
}
}
}
// Read SourceID from GET Querystring
if ( isset($_GET['sourceid']) && isset($content['Sources'][$_GET['sourceid']]) )
{
$currentSourceID = $_GET['sourceid'];
$_SESSION['currentSourceID'] = $currentSourceID;
}
// Read SourceID from GET Querystring
if ( isset($_GET['sourceid']) && isset($content['Sources'][$_GET['sourceid']]) )
{
$currentSourceID = $_GET['sourceid'];
$_SESSION['currentSourceID'] = $currentSourceID;
}
else
{
// Set Source from session if available!
if ( isset($_SESSION['currentSourceID']) && isset($content['Sources'][$_SESSION['currentSourceID']]) )
$currentSourceID = $_SESSION['currentSourceID'];
else
{
// Set Source from session if available!
if ( isset($_SESSION['currentSourceID']) && isset($content['Sources'][$_SESSION['currentSourceID']]) )
$currentSourceID = $_SESSION['currentSourceID'];
if ( isset($CFG['DefaultSourceID']) && isset($content['Sources'][ $CFG['DefaultSourceID'] ]) )
// Set Source to preconfigured sourceID!
$_SESSION['currentSourceID'] = $CFG['DefaultSourceID'];
else
{
if ( isset($CFG['DefaultSourceID']) && isset($content['Sources'][ $CFG['DefaultSourceID'] ]) )
// Set Source to preconfigured sourceID!
$_SESSION['currentSourceID'] = $CFG['DefaultSourceID'];
else
// No Source stored in session, then to so now!
$_SESSION['currentSourceID'] = $currentSourceID;
}
// No Source stored in session, then to so now!
$_SESSION['currentSourceID'] = $currentSourceID;
}
}
// Set for the selection box in the header
$content['Sources'][$currentSourceID]['selected'] = "selected";
// --- Additional handling needed for the current view!
global $currentViewID;
$currentViewID = $content['Sources'][$currentSourceID]['ViewID'];
// Set selected state for correct View, for selection box ^^
$content['Views'][ $currentViewID ]['selected'] = "selected";
// If DEBUG Mode is enabled, we prepend the UID field into the col list!
if ( $CFG['MiscShowDebugMsg'] == 1 && isset($content['Views'][$currentViewID]) )
array_unshift( $content['Views'][$currentViewID]['Columns'], SYSLOG_UID);
// ---
}
/*
* This function Inits preconfigured Views.
*/
function InitViewConfigs()
{
global $CFG, $content, $currentViewID;
// Predefined phpLogCon Views
$CFG['Views']['SYSLOG']= array(
'ID' => "SYSLOG",
'DisplayName' =>"Syslog Fields",
'Columns' => array ( SYSLOG_DATE, SYSLOG_FACILITY, SYSLOG_SEVERITY, SYSLOG_HOST, SYSLOG_SYSLOGTAG, SYSLOG_PROCESSID, SYSLOG_MESSAGETYPE, SYSLOG_MESSAGE ),
);
$CFG['Views']['EVTRPT']= array(
'ID' => "EVTRPT",
'DisplayName' =>"EventLog Fields",
'Columns' => array ( SYSLOG_DATE, SYSLOG_HOST, SYSLOG_SEVERITY, SYSLOG_EVENT_LOGTYPE, SYSLOG_EVENT_SOURCE, SYSLOG_EVENT_ID, SYSLOG_EVENT_USER, SYSLOG_MESSAGE ),
);
// Set default of 'DefaultViewsID'
$CFG['DefaultViewsID'] = "SYSLOG";
// Loop through views now and copy into content array!
foreach ( $CFG['Views'] as $key => $view )
$content['Views'][$key] = $view;
}
/*
* This function Inits preconfigured Views.
*/
function AppendLegacyColumns()
{
global $CFG, $content;
// Init View from legacy Columns
$CFG['Views']['LEGACY']= array(
'ID' => "LEGACY",
'DisplayName' =>"Legacy Columns Configuration",
'Columns' => $CFG['Columns'],
);
// set default to legacy of no default view is specified!
if ( !isset($CFG['DefaultViewsID']) || strlen($CFG['DefaultViewsID']) <= 0 )
$CFG['DefaultViewsID'] = "LEGACY";
}
function InitPhpLogConConfigFile($bHandleMissing = true)
{
// Needed to make global
global $CFG, $gl_root_path, $content;
if ( file_exists($gl_root_path . 'config.php') && GetFileLength($gl_root_path . 'config.php') > 0 )
{
// Include the main config
include_once($gl_root_path . 'config.php');
// Easier DB Access
define('DB_CONFIG', $CFG['UserDBPref'] . "config");
define('DB_GROUPS', $CFG['UserDBPref'] . "groups");
define('DB_GROUPMEMBERS', $CFG['UserDBPref'] . "groupmembers");
define('DB_SEARCHES', $CFG['UserDBPref'] . "searches");
define('DB_SOURCES', $CFG['UserDBPref'] . "sources");
define('DB_USERS', $CFG['UserDBPref'] . "users");
define('DB_VIEWS', $CFG['UserDBPref'] . "views");
// Legacy support for old columns definition format!
if ( isset($CFG['Columns']) && is_array($CFG['Columns']) )
AppendLegacyColumns();
// --- Now Copy all entries into content variable
foreach ($CFG as $key => $value )
$content[$key] = $value;
// ---
// For MiscShowPageRenderStats
if ( $CFG['MiscShowPageRenderStats'] == 1 )
{
$content['ShowPageRenderStats'] = "true";
InitPageRenderStats();
}
// Set for the selection box in the header
$content['Sources'][$currentSourceID]['selected'] = "selected";
// --- Additional handling needed for the current view!
global $currentViewID;
$currentViewID = $content['Sources'][$currentSourceID]['ViewID'];
// Set selected state for correct View, for selection box ^^
$content['Views'][ $currentViewID ]['selected'] = "selected";
// If DEBUG Mode is enabled, we prepend the UID field into the col list!
if ( $CFG['MiscShowDebugMsg'] == 1 && isset($content['Views'][$currentViewID]) )
array_unshift( $content['Views'][$currentViewID]['Columns'], SYSLOG_UID);
// ---
// return result
return true;
}
/*
* This function Inits preconfigured Views.
*/
function InitViewConfigs()
else
{
global $CFG, $content, $currentViewID;
// Predefined phpLogCon Views
$CFG['Views']['SYSLOG']= array(
'ID' => "SYSLOG",
'DisplayName' =>"Syslog Fields",
'Columns' => array ( SYSLOG_DATE, SYSLOG_FACILITY, SYSLOG_SEVERITY, SYSLOG_HOST, SYSLOG_SYSLOGTAG, SYSLOG_PROCESSID, SYSLOG_MESSAGETYPE, SYSLOG_MESSAGE ),
);
$CFG['Views']['EVTRPT']= array(
'ID' => "EVTRPT",
'DisplayName' =>"EventLog Fields",
'Columns' => array ( SYSLOG_DATE, SYSLOG_HOST, SYSLOG_SEVERITY, SYSLOG_EVENT_LOGTYPE, SYSLOG_EVENT_SOURCE, SYSLOG_EVENT_ID, SYSLOG_EVENT_USER, SYSLOG_MESSAGE ),
);
// Set default of 'DefaultViewsID'
$CFG['DefaultViewsID'] = "SYSLOG";
// Loop through views now and copy into content array!
foreach ( $CFG['Views'] as $key => $view )
$content['Views'][$key] = $view;
// if handled ourselfe, we die in CheckForInstallPhp.
if ( $bHandleMissing == true )
{
// Check for installscript!
CheckForInstallPhp();
}
else
return false;
}
}
/*
* This function Inits preconfigured Views.
*/
function AppendLegacyColumns()
/*
* Helper function to load configured Searches from the database
*/
function LoadSearchesFromDatabase()
{
// 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_SEARCHES . ".userid = " . $content['SESSION_USERID'];
else
$szWhereUser = "";
if ( isset($content['SESSION_GROUPIDS']) )
$szGroupWhere = " OR " . DB_SEARCHES . ".groupid IN (" . $content['SESSION_GROUPIDS'] . ") ";
else
$szGroupWhere = "";
$sqlquery = " SELECT * " .
" FROM " . DB_SEARCHES .
" WHERE userid = NULL " .
$szWhereUser .
$szGroupWhere .
" ORDER BY " . DB_SEARCHES . ".DisplayName";
$result = DB_Query($sqlquery);
$myrows = DB_GetAllRows($result, true);
if ( isset($myrows ) && count($myrows) > 0 )
{
global $CFG, $content;
// Cleanup searches and fill / load from database
// Init View from legacy Columns
$CFG['Views']['LEGACY']= array(
'ID' => "LEGACY",
'DisplayName' =>"Legacy Columns Configuration",
'Columns' => $CFG['Columns'],
);
// set default to legacy of no default view is specified!
if ( !isset($CFG['DefaultViewsID']) || strlen($CFG['DefaultViewsID']) <= 0 )
$CFG['DefaultViewsID'] = "LEGACY";
}
}
?>

View File

@ -65,10 +65,13 @@ function InitUserSession()
}
else
{
// Copy variables from session!
$content['SESSION_LOGGEDIN'] = true;
$content['SESSION_USERNAME'] = $_SESSION['SESSION_USERNAME'];
$content['SESSION_USERID'] = $_SESSION['SESSION_USERID'];
$content['SESSION_ISADMIN'] = $_SESSION['SESSION_ISADMIN'];
if ( isset($_SESSION['SESSION_GROUPIDS']) )
$content['SESSION_GROUPIDS'] = $_SESSION['SESSION_GROUPIDS'];
// Successfully logged in
return true;
@ -122,11 +125,11 @@ function CheckUserLogin( $username, $password )
// TODO: SessionTime and AccessLevel check
$md5pass = md5($password);
$sqlselect = "SELECT * FROM " . DB_USERS . " WHERE username = '" . $username . "' and password = '" . $md5pass . "'";
$result = DB_Query($sqlselect);
$sqlquery = "SELECT * FROM " . DB_USERS . " WHERE username = '" . $username . "' and password = '" . $md5pass . "'";
$result = DB_Query($sqlquery);
$myrow = DB_GetSingleRow($result, true);
// The admin field must be set!
if ( isset($myrow['is_admin']) )
{
$_SESSION['SESSION_LOGGEDIN'] = true;
@ -139,7 +142,33 @@ function CheckUserLogin( $username, $password )
$content['SESSION_USERID'] = $_SESSION['SESSION_USERID'];
$content['SESSION_ISADMIN'] = $_SESSION['SESSION_ISADMIN'];
// TODO SET LAST LOGIN TIME!
// --- Read Groupmember ship for the user!
$sqlquery = "SELECT " .
DB_GROUPMEMBERS . ".groupid, " .
DB_GROUPMEMBERS . ".is_member " .
"FROM " . DB_GROUPMEMBERS . " WHERE userid = " . $content['SESSION_USERID'] . " AND " . DB_GROUPMEMBERS . ".is_member = 1";
$result = DB_Query($sqlquery);
$myrows = DB_GetAllRows($result, true);
if ( isset($myrows ) && count($myrows) > 0 )
{
for($i = 0; $i < count($myrows); $i++)
{
if ( isset($content['SESSION_GROUPIDS']) )
$content['SESSION_GROUPIDS'] .= ", " . $myrows[$i]['groupid'];
else
$content['SESSION_GROUPIDS'] .= $myrows[$i]['groupid'];
}
}
// Copy into session as well
$_SESSION['SESSION_GROUPIDS'] = $content['SESSION_GROUPIDS'];
// ---
// ---Set LASTLOGIN Time!
$result = DB_Query("UPDATE " . DB_USERS . " SET last_login = " . time() . " WHERE ID = " . $content['SESSION_USERID']);
DB_FreeQuery($result);
// ---
// Success !
return true;