diff --git a/src/classes/class_template.php b/src/classes/class_template.php
index 9cce45d..e7b4bcf 100644
--- a/src/classes/class_template.php
+++ b/src/classes/class_template.php
@@ -98,9 +98,8 @@ class Template {
function parser ($vars = '', $filename = '')
{
// BEGIN DELTA MOD
- global $CFG;
// For MiscShowPageRenderStats
- if ( $CFG['MiscShowPageRenderStats'] == 1 )
+ if ( GetConfigSetting("MiscShowPageRenderStats", 1, CFGLEVEL_USER) == 1 )
FinishPageRenderStats( $vars );
// END DELTA MOD
diff --git a/src/classes/logstreamdb.class.php b/src/classes/logstreamdb.class.php
index afd2015..af1375c 100644
--- a/src/classes/logstreamdb.class.php
+++ b/src/classes/logstreamdb.class.php
@@ -772,9 +772,7 @@ class LogStreamDB extends LogStream {
*/
private function PrintDebugError($szErrorMsg)
{
- global $CFG;
-
- if ( isset($CFG['MiscShowDebugMsg']) && $CFG['MiscShowDebugMsg'] == 1 )
+ if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
{
$errdesc = mysql_error();
$errno = mysql_errno();
diff --git a/src/classes/logstreampdo.class.php b/src/classes/logstreampdo.class.php
index ef8eeb4..5354cb6 100644
--- a/src/classes/logstreampdo.class.php
+++ b/src/classes/logstreampdo.class.php
@@ -788,8 +788,7 @@ class LogStreamPDO extends LogStream {
*/
private function PrintDebugError($szErrorMsg)
{
- global $CFG;
- if ( isset($CFG['MiscShowDebugMsg']) && $CFG['MiscShowDebugMsg'] == 1 )
+ if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
{
$errdesc = $this->_dbhandle == null ? "" : implode( ";", $this->_dbhandle->errorInfo() );
$errno = $this->_dbhandle == null ? "" : $this->_dbhandle->errorCode();
diff --git a/src/convert.php b/src/convert.php
index c3631e8..09d46a2 100644
--- a/src/convert.php
+++ b/src/convert.php
@@ -52,8 +52,9 @@ InitFrontEndDefaults(); // Only in WebFrontEnd
// --- PreCheck if conversion is allowed!
if (
- (isset($CFG['UserDBEnabled']) && $CFG['UserDBEnabled']) &&
- (isset($CFG['UserDBConvertAllowed']) && $CFG['UserDBConvertAllowed'])
+
+ GetConfigSetting("UserDBEnabled", false) &&
+ GetConfigSetting("UserDBConvertAllowed", false)
)
{
// Setup static values
@@ -113,16 +114,14 @@ $content['LN_CONVERT_TITLETOP'] = GetAndReplaceLangStr( $content['LN_CONVERT_TIT
if ( $content['CONVERT_STEP'] == 2 )
{
// Check the database connect
- $link_id = mysql_connect( $CFG['UserDBServer'], $CFG['UserDBUser'], $CFG['UserDBPass']);
+ $link_id = mysql_connect( GetConfigSetting("UserDBServer"), GetConfigSetting("UserDBUser"), GetConfigSetting("UserDBPass") );
if (!$link_id)
- RevertOneStep( $content['CONVERT_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORCONNECTFAILED'], $CFG['UserDBServer']) . "
" . DB_ReturnSimpleErrorMsg() );
+ RevertOneStep( $content['CONVERT_STEP']-1, GetAndReplaceLangStr( $content['LN_INSTALL_ERRORCONNECTFAILED'], GetConfigSetting("UserDBServer") . "
" . DB_ReturnSimpleErrorMsg() ) );
// Try to select the DB!
- $db_selected = mysql_select_db($CFG['UserDBName'], $link_id);
+ $db_selected = mysql_select_db(GetConfigSetting("UserDBName"), $link_id);
if(!$db_selected)
- RevertOneStep( $content['CONVERT_STEP']-1,GetAndReplaceLangStr( $content['LN_INSTALL_ERRORACCESSDENIED'], $CFG['UserDBName']) . "
" . DB_ReturnSimpleErrorMsg());
-
-
+ RevertOneStep( $content['CONVERT_STEP']-1,GetAndReplaceLangStr( $content['LN_INSTALL_ERRORACCESSDENIED'], GetConfigSetting("UserDBName") . "
" . DB_ReturnSimpleErrorMsg() ) );
}
else if ( $content['CONVERT_STEP'] == 3 )
{
@@ -145,7 +144,7 @@ else if ( $content['CONVERT_STEP'] == 3 )
}
// Replace stats_ with the custom one ;)
- $totaldbdefs = str_replace( "`logcon_", "`" . $CFG["UserDBPref"], $totaldbdefs );
+ $totaldbdefs = str_replace( "`logcon_", "`" . GetConfigSetting("UserDBPref"), $totaldbdefs );
// Now split by sql command
$mycommands = split( ";\n", $totaldbdefs );
@@ -163,7 +162,7 @@ else if ( $content['CONVERT_STEP'] == 3 )
}
// Append INSERT Statement for Config Table to set the Database Version ^^!
- $mycommands[count($mycommands)] = "INSERT INTO `" . $CFG["UserDBPref"] . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)";
+ $mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)";
// --- Now execute all commands
ini_set('error_reporting', E_WARNING); // Enable Warnings!
diff --git a/src/include/constants_general.php b/src/include/constants_general.php
index f0c737f..aa71f89 100644
--- a/src/include/constants_general.php
+++ b/src/include/constants_general.php
@@ -57,6 +57,12 @@ define('STR_DEBUG_WARN', "Warning");
define('STR_DEBUG_ERROR', "Error");
define('STR_DEBUG_ERROR_WTF', "WTF OMFG");
+// --- Config Level defines
+define('CFGLEVEL_GLOBAL', 0);
+define('CFGLEVEL_GROUP', 1);
+define('CFGLEVEL_USER', 2);
+// ---
+
// --- Source Type defines
define('SOURCE_DISK', '1');
define('SOURCE_DB', '2');
diff --git a/src/include/functions_common.php b/src/include/functions_common.php
index 6e53166..bb0a209 100644
--- a/src/include/functions_common.php
+++ b/src/include/functions_common.php
@@ -81,7 +81,7 @@ if ( $myPhpVerArray[0] < 5 )
function InitBasicPhpLogCon()
{
// Needed to make global
- global $CFG, $gl_root_path, $content;
+ global $gl_root_path, $content;
// Check RunMode first!
CheckAndSetRunMode();
@@ -99,9 +99,9 @@ function InitBasicPhpLogCon()
function InitUserSystemPhpLogCon()
{
// global vars needed
- global $CFG, $gl_root_path, $content;
+ global $gl_root_path, $content;
- if ( isset($CFG['UserDBEnabled']) && $CFG['UserDBEnabled'] )
+ if ( GetConfigSetting("UserDBEnabled", false) )
{
// Include User Functions
include($gl_root_path . 'include/functions_users.php');
@@ -135,7 +135,7 @@ function GetFileLength($szFileName)
function InitPhpLogCon()
{
// Needed to make global
- global $CFG, $gl_root_path, $content;
+ global $gl_root_path, $content;
// Init Basics which do not need a database
InitBasicPhpLogCon();
@@ -150,7 +150,7 @@ function InitPhpLogCon()
InitRuntimeInformations();
// Establish DB Connection
- if ( $CFG['UserDBEnabled'] )
+ if ( GetConfigSetting("UserDBEnabled", false) )
DB_Connect();
// Now load the Page configuration values
@@ -272,10 +272,11 @@ function CreateDBTypesList( $selectedDBType )
function CreatePagesizesList()
{
- global $CFG, $content;
+ global $content;
+ $tmpViewsPerPage = GetConfigSetting("ViewEntriesPerPage", 50, CFGLEVEL_USER);
$iCounter = 0;
- $content['pagesizes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => $content['LN_GEN_PRECONFIGURED'] . " (" . $CFG['ViewEntriesPerPage'] . ")", "Value" => $CFG['ViewEntriesPerPage'] ); $iCounter++;
+ $content['pagesizes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => $content['LN_GEN_PRECONFIGURED'] . " (" . $tmpViewsPerPage . ")", "Value" => $tmpViewsPerPage ); $iCounter++;
$content['pagesizes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => " 25 " . $content['LN_GEN_RECORDSPERPAGE'], "Value" => 25 ); $iCounter++;
$content['pagesizes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => " 50 " . $content['LN_GEN_RECORDSPERPAGE'], "Value" => 50 ); $iCounter++;
$content['pagesizes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => " 75 " . $content['LN_GEN_RECORDSPERPAGE'], "Value" => 75 ); $iCounter++;
@@ -292,14 +293,15 @@ function CreatePagesizesList()
function CreateReloadTimesList()
{
- global $CFG, $content;
+ global $content;
-// $CFG['ViewEnableAutoReloadSeconds']
$iCounter = 0;
$content['reloadtimes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => $content['LN_AUTORELOAD_DISABLED'], "Value" => 0 ); $iCounter++;
- if ( isset($CFG['ViewEnableAutoReloadSeconds']) && $CFG['ViewEnableAutoReloadSeconds'] > 0 )
+
+ $tmpReloadSeconds = GetConfigSetting("ViewEnableAutoReloadSeconds", "", CFGLEVEL_USER);
+ if ( $tmpReloadSeconds > 0 )
{
- $content['reloadtimes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => $content['LN_AUTORELOAD_PRECONFIGURED'] . " (" . $CFG['ViewEnableAutoReloadSeconds'] . " " . $content['LN_AUTORELOAD_SECONDS'] . ") ", "Value" => $CFG['ViewEnableAutoReloadSeconds'] ); $iCounter++;
+ $content['reloadtimes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => $content['LN_AUTORELOAD_PRECONFIGURED'] . " (" . $tmpReloadSeconds . " " . $content['LN_AUTORELOAD_SECONDS'] . ") ", "Value" => $tmpReloadSeconds ); $iCounter++;
}
$content['reloadtimes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => " 5 " . $content['LN_AUTORELOAD_SECONDS'], "Value" => 5 ); $iCounter++;
$content['reloadtimes'][$iCounter] = array( "ID" => $iCounter, "Selected" => "", "DisplayName" => " 10 " . $content['LN_AUTORELOAD_SECONDS'], "Value" => 10 ); $iCounter++;
@@ -349,10 +351,10 @@ function CreatePredefinedSearches()
function InitPhpDebugMode()
{
- global $content, $CFG;
+ global $content;
// --- Set Global DEBUG Level!
- if ( $CFG['MiscShowDebugMsg'] == 1 )
+ if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
ini_set( "error_reporting", E_ALL ); // ALL PHP MESSAGES!
else
ini_set( "error_reporting", E_ERROR ); // ONLY PHP ERROR'S!
@@ -372,12 +374,12 @@ function CheckAndSetRunMode()
function InitRuntimeInformations()
{
- global $content, $CFG;
+ global $content;
// TODO| maybe not needed!
// Enable GZIP Compression if enabled!
- if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && (isset($CFG['MiscEnableGzipCompression']) && $CFG['MiscEnableGzipCompression'] == 1) )
+ if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && GetConfigSetting("MiscEnableGzipCompression", 1, CFGLEVEL_USER) == 1 )
{
// This starts gzip compression!
ob_start("ob_gzhandler");
@@ -491,7 +493,7 @@ function InitConfigurationValues()
if ( !defined('IN_PHPLOGCON_CONVERT') )
{
// If Database is enabled, try to read from database!
- if ( $CFG['UserDBEnabled'] )
+ if ( GetConfigSetting("UserDBEnabled", false) )
{
// Get configuration variables
$result = DB_Query("SELECT * FROM " . DB_CONFIG . " WHERE is_global = true");
@@ -519,7 +521,7 @@ function InitConfigurationValues()
{
// Check if user needs to be logged in
- if ( isset($CFG["UserDBLoginRequired"]) && $CFG["UserDBLoginRequired"] == true )
+ if ( GetConfigSetting("UserDBLoginRequired", false) )
{
// User needs to be logged in, redirect to login page
if ( !defined("IS_NOLOGINPAGE") )
@@ -569,7 +571,7 @@ function InitConfigurationValues()
}
else // Failsave!
{
- $content['user_lang'] = $CFG['ViewDefaultLanguage'] /*"en"*/;
+ $content['user_lang'] = GetConfigSetting("ViewDefaultLanguage", "en", CFGLEVEL_USER) /*"en"*/;
$LANG = $content['user_lang'];
$content['gen_lang'] = $content['user_lang'];
}
@@ -585,14 +587,14 @@ function InitConfigurationValues()
// Auto reload handling!
if ( !isset($_SESSION['AUTORELOAD_ID']) )
{
- if ( isset($CFG['ViewEnableAutoReloadSeconds']) && $CFG['ViewEnableAutoReloadSeconds'] > 0 )
+ if ( GetConfigSetting("ViewEnableAutoReloadSeconds", 0, CFGLEVEL_USER) > 0 )
$_SESSION['AUTORELOAD_ID'] = 1; // Autoreload ID will be the first item!
else // Default is 0, which means auto reload disabled
$_SESSION['AUTORELOAD_ID'] = 0;
}
// Theme Handling
- if ( !isset($content['web_theme']) ) { $content['web_theme'] = $CFG['ViewDefaultTheme'] /*"default"*/; }
+ if ( !isset($content['web_theme']) ) { $content['web_theme'] = GetConfigSetting("ViewDefaultTheme", "default", CFGLEVEL_USER); }
if ( isset($_SESSION['CUSTOM_THEME']) && VerifyTheme($_SESSION['CUSTOM_THEME']) )
$content['user_theme'] = $_SESSION['CUSTOM_THEME'];
else
@@ -700,10 +702,11 @@ function DieWithFriendlyErrorMsg( $szerrmsg )
*/
function InitPageTitle()
{
- global $content, $CFG, $currentSourceID;
+ global $content, $currentSourceID;
- if ( isset($CFG['PrependTitle']) && strlen($CFG['PrependTitle']) > 0 )
- $szReturn = $CFG['PrependTitle'] . " :: ";
+ $tmpTitle = GetConfigSetting("PrependTitle", "");
+ if ( strlen($tmpTitle) > 0 )
+ $szReturn = $tmpTitle . " :: ";
else
$szReturn = "";
@@ -885,10 +888,10 @@ function GetMonthFromString($szMonth)
*/
function AddContextLinks(&$sourceTxt)
{
- global $szTLDDomains, $CFG;
+ global $szTLDDomains;
// Return if not enabled!
- if ( !isset($CFG['EnableIPAddressResolve']) || $CFG['EnableIPAddressResolve'] == 1 )
+ if ( GetConfigSetting("EnableIPAddressResolve", 0, CFGLEVEL_USER) == 1 )
{
// Search for IP's and Add Reverse Lookup first!
$sourceTxt = preg_replace( '/([^\[])\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/e', "'\\1\\2.\\3.\\4.\\5' . ReverseResolveIP('\\2.\\3.\\4.\\5', ' {', '} ')", $sourceTxt );
@@ -1076,4 +1079,23 @@ function SaveGeneralSettingsIntoDB()
WriteConfigValue( "DefaultSourceID", true );
}
+function GetConfigSetting($szSettingName, $szDefaultValue = "", $DesiredConfigLevel = CFGLEVEL_GLOBAL)
+{
+ global $content, $CFG;
+
+ if ( isset($CFG['UserDBEnabled']) && $CFG['UserDBEnabled'] )
+ {
+ if ( $DesiredConfigLevel == CFGLEVEL_USER )
+ {
+ // TODO!
+ }
+ }
+
+ // Either UserDB disabled, or global setting wanted - easier handling
+ if ( isset($CFG[$szSettingName]) )
+ return $CFG[$szSettingName];
+ else
+ return $szDefaultValue;
+}
+
?>
\ No newline at end of file
diff --git a/src/include/functions_config.php b/src/include/functions_config.php
index a77179f..d884c12 100644
--- a/src/include/functions_config.php
+++ b/src/include/functions_config.php
@@ -76,7 +76,8 @@ function InitSourceConfigs()
// ---
// Set default view id to source
- $szDefaultViewID = isset($CFG['DefaultViewsID']) && strlen($CFG['DefaultViewsID']) > 0 ? $CFG['DefaultViewsID'] : "SYSLOG";
+ $tmpVar = GetConfigSetting("DefaultViewsID", "", CFGLEVEL_USER);
+ $szDefaultViewID = strlen($tmpVar) > 0 ? $tmpVar : "SYSLOG";
if ( isset($_SESSION[$iSourceID . "-View"]) )
{
@@ -169,7 +170,7 @@ function InitSourceConfigs()
}
// Set generic configuration options
- $content['Sources'][$iSourceID]['ObjRef']->_pageCount = $CFG['ViewEntriesPerPage'];
+ $content['Sources'][$iSourceID]['ObjRef']->_pageCount = GetConfigSetting("ViewEntriesPerPage", 50);
// Set default SourceID here!
if ( isset($content['Sources'][$iSourceID]) && !isset($currentSourceID) )
@@ -191,9 +192,10 @@ function InitSourceConfigs()
$currentSourceID = $_SESSION['currentSourceID'];
else
{
- if ( isset($CFG['DefaultSourceID']) && isset($content['Sources'][ $CFG['DefaultSourceID'] ]) )
+ $tmpVar = GetConfigSetting("DefaultSourceID", "", CFGLEVEL_USER);
+ if ( isset($content['Sources'][ $tmpVar ]) )
// Set Source to preconfigured sourceID!
- $_SESSION['currentSourceID'] = $CFG['DefaultSourceID'];
+ $_SESSION['currentSourceID'] = $tmpVar;
else
// No Source stored in session, then to so now!
$_SESSION['currentSourceID'] = $currentSourceID;
@@ -211,7 +213,8 @@ function InitSourceConfigs()
$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]) )
+
+ if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 && isset($content['Views'][$currentViewID]) )
array_unshift( $content['Views'][$currentViewID]['Columns'], SYSLOG_UID);
// ---
}
@@ -262,7 +265,8 @@ function AppendLegacyColumns()
);
// set default to legacy of no default view is specified!
- if ( !isset($CFG['DefaultViewsID']) || strlen($CFG['DefaultViewsID']) <= 0 )
+ $tmpVar = GetConfigSetting("DefaultViewsID", "", CFGLEVEL_USER);
+ if ( strlen($tmpVar) <= 0 )
$CFG['DefaultViewsID'] = "LEGACY";
}
@@ -277,13 +281,14 @@ function InitPhpLogConConfigFile($bHandleMissing = true)
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");
+ $tblPref = GetConfigSetting("UserDBPref", "logcon");
+ define('DB_CONFIG', $tblPref . "config");
+ define('DB_GROUPS', $tblPref . "groups");
+ define('DB_GROUPMEMBERS', $tblPref . "groupmembers");
+ define('DB_SEARCHES', $tblPref . "searches");
+ define('DB_SOURCES', $tblPref . "sources");
+ define('DB_USERS', $tblPref . "users");
+ define('DB_VIEWS', $tblPref . "views");
// Legacy support for old columns definition format!
if ( isset($CFG['Columns']) && is_array($CFG['Columns']) )
@@ -295,7 +300,7 @@ function InitPhpLogConConfigFile($bHandleMissing = true)
// ---
// For MiscShowPageRenderStats
- if ( $CFG['MiscShowPageRenderStats'] == 1 )
+ if ( GetConfigSetting("MiscShowPageRenderStats", 1) )
{
$content['ShowPageRenderStats'] = "true";
InitPageRenderStats();
diff --git a/src/include/functions_db.php b/src/include/functions_db.php
index 7aad19f..5b4a383 100644
--- a/src/include/functions_db.php
+++ b/src/include/functions_db.php
@@ -51,16 +51,16 @@ $content['database_installedversion'] = "0"; // 0 is default which means Prior V
function DB_Connect()
{
- global $userdbconn, $CFG;
+ global $userdbconn;
// Avoid if already OPEN
if ($userdbconn)
return;
//TODO: Check variables first
- $userdbconn = mysql_connect($CFG['UserDBServer'],$CFG['UserDBUser'],$CFG['UserDBPass']);
+ $userdbconn = mysql_connect( GetConfigSetting("UserDBServer"), GetConfigSetting("UserDBUser"), GetConfigSetting("UserDBPass"));
if (!$userdbconn)
- DB_PrintError("Link-ID == false, connect to ".$CFG['UserDBServer']." failed", true);
+ DB_PrintError("Link-ID == false, connect to " . GetConfigSetting("UserDBServer") . " failed", true);
// --- Now, check Mysql DB Version!
$strmysqlver = mysql_get_server_info();
@@ -82,9 +82,9 @@ function DB_Connect()
}
// ---
- $db_selected = mysql_select_db($CFG['UserDBName'], $userdbconn);
+ $db_selected = mysql_select_db( GetConfigSetting("UserDBName"), $userdbconn );
if(!$db_selected)
- DB_PrintError("Cannot use database '" . $CFG['UserDBName'] . "'", true);
+ DB_PrintError("Cannot use database '" .GetConfigSetting("UserDBName") . "'", true);
// :D Success connecting to db
// TODO Do some more validating on the database
@@ -99,8 +99,7 @@ function DB_Disconnect()
function DB_Query($query_string, $bProcessError = true, $bCritical = false)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -118,8 +117,7 @@ function DB_Query($query_string, $bProcessError = true, $bCritical = false)
function DB_FreeQuery($query_id)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -130,8 +128,7 @@ function DB_FreeQuery($query_id)
function DB_GetRow($query_id)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -143,8 +140,7 @@ function DB_GetRow($query_id)
function DB_GetSingleRow($query_id, $bClose)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -165,8 +161,7 @@ function DB_GetSingleRow($query_id, $bClose)
function DB_GetAllRows($query_id, $bClose)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -191,8 +186,7 @@ function DB_GetAllRows($query_id, $bClose)
function DB_GetMysqlStats()
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -209,7 +203,7 @@ function DB_ReturnSimpleErrorMsg()
function DB_PrintError($MyErrorMsg, $DieOrNot)
{
- global $n,$HTTP_COOKIE_VARS, $errdesc, $errno, $linesep, $CFG;
+ global $n,$HTTP_COOKIE_VARS, $errdesc, $errno, $linesep;
$errdesc = mysql_error();
$errno = mysql_errno();
@@ -260,8 +254,7 @@ function DB_StripSlahes($myString)
function DB_ReturnLastInsertID($myResult = false)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -272,8 +265,7 @@ function DB_ReturnLastInsertID($myResult = false)
function DB_GetRowCount($query)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -288,8 +280,7 @@ function DB_GetRowCount($query)
function DB_GetRowCountByResult($myresult)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -300,8 +291,7 @@ function DB_GetRowCountByResult($myresult)
function DB_Exec($query)
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -323,9 +313,10 @@ function PrepareValueForDB($szValue)
function WriteConfigValue($szPropName, $is_global = true, $userid = false, $groupid = false)
{
+ global $content;
+
// --- Abort in this case!
- global $CFG, $content;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -366,8 +357,7 @@ function WriteConfigValue($szPropName, $is_global = true, $userid = false, $grou
function GetSingleDBEntryOnly( $myqry )
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
@@ -384,8 +374,7 @@ function GetSingleDBEntryOnly( $myqry )
function GetRowsAffected()
{
// --- Abort in this case!
- global $CFG;
- if ( $CFG['UserDBEnabled'] == false )
+ if ( GetConfigSetting("UserDBEnabled", false) == false )
return;
// ---
diff --git a/src/include/functions_filters.php b/src/include/functions_filters.php
index 66ad2e6..810b2dd 100644
--- a/src/include/functions_filters.php
+++ b/src/include/functions_filters.php
@@ -41,7 +41,7 @@ require_once($gl_root_path . 'include/constants_filters.php');
function InitFilterHelpers()
{
- global $CFG, $content, $filters;
+ global $content, $filters;
// Init Default DateMode from SESSION!
if ( isset($_SESSION['filter_datemode']) )
@@ -196,7 +196,7 @@ function InitFilterHelpers()
function FillDateRangeArray($sourcearray, $szArrayListName, $szFilterName) // $content['years'], "filter_daterange_from_year_list", "filter_daterange_from_year")
{
- global $CFG, $content, $filters;
+ global $content, $filters;
$iCount = count($sourcearray);
for ( $i = 0; $i < $iCount; $i++)
diff --git a/src/include/functions_frontendhelpers.php b/src/include/functions_frontendhelpers.php
index df02f8b..e357369 100644
--- a/src/include/functions_frontendhelpers.php
+++ b/src/include/functions_frontendhelpers.php
@@ -117,7 +117,7 @@ function GetAdditionalUrl($skipParam, $appendParam = "")
function CreateCurrentUrl()
{
- global $content, $CFG;
+ global $content;
$content['CURRENTURL'] = $_SERVER['PHP_SELF']; // . "?" . $_SERVER['QUERY_STRING']
// Init additional_url helper variable
@@ -131,11 +131,12 @@ function CreateCurrentUrl()
$hvCounter = 0;
// Append SourceID into everything!
- if ( (isset($CFG['DefaultSourceID']) && isset($content['Sources'][ $CFG['DefaultSourceID'] ])) && isset($_SESSION['currentSourceID']) )
+ $tmpDefSourceID = GetConfigSetting("DefaultSourceID", "", CFGLEVEL_USER);
+ if ( isset($content['Sources'][ $tmpDefSourceID ]) && isset($_SESSION['currentSourceID']) )
{
// If the DefaultSourceID differes from the SourceID in our Session, we will append the sourceid within all URL's!
- if ( $CFG['DefaultSourceID'] != $_SESSION['currentSourceID'] )
+ if ( $tmpDefSourceID != $_SESSION['currentSourceID'] )
{
// $content['additional_url'] .= "&sourceid=" . $_SESSION['currentSourceID'];
$content['additional_url_uidonly'] = "&sourceid=" . $_SESSION['currentSourceID'];
@@ -210,13 +211,13 @@ function CreateCurrentUrl()
function GetFormatedDate($evttimearray)
{
- global $content, $CFG;
+ global $content;
if ( !is_array($evttimearray) )
return $evttimearray;
if (
- ( isset($CFG['ViewUseTodayYesterday']) && $CFG['ViewUseTodayYesterday'] == 1 )
+ GetConfigSetting("ViewUseTodayYesterday", 0, CFGLEVEL_USER) == 1
&&
( date('m', $evttimearray[EVTIME_TIMESTAMP]) == date('m') && date('Y', $evttimearray[EVTIME_TIMESTAMP]) == date('Y') )
)
@@ -233,9 +234,7 @@ function GetFormatedDate($evttimearray)
function OutputDebugMessage($szDbg)
{
- global $CFG;
-
- if ( $CFG['MiscShowDebugMsg'] == 1 )
+ if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
{
print("
Debugmessage: | "); diff --git a/src/include/functions_users.php b/src/include/functions_users.php index 79a2933..ab801e4 100644 --- a/src/include/functions_users.php +++ b/src/include/functions_users.php @@ -125,7 +125,7 @@ function CreateUserName( $username, $password, $is_admin ) function CheckUserLogin( $username, $password ) { - global $content, $CFG; + global $content; // TODO: SessionTime and AccessLevel check @@ -180,7 +180,7 @@ function CheckUserLogin( $username, $password ) } else { - if ( $CFG['DebugUserLogin'] == 1 ) + if ( GetConfigSetting("DebugUserLogin", 0) == 1 ) DieWithFriendlyErrorMsg( "Debug Error: Could not login user '" . $username . "'