X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fconfig-functions.php;h=3fd823f6c75bc63c95776fd5428e8d1e1073ac65;hb=2714aab2a0f605af103dad95555bd888a3380e27;hp=49d99272cc6e68dd26a44a7ed3972c334135f944;hpb=b8c86fa12322603c24a88ea2b0fd3dbeba612752;p=mailer.git diff --git a/inc/config-functions.php b/inc/config-functions.php index 49d99272cc..3fd823f6c7 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -10,7 +10,12 @@ * -------------------------------------------------------------------- * * Kurzbeschreibung : Viele Nicht-MySQL-Funktionen (auch Dateizugriff) * * -------------------------------------------------------------------- * - * * + * $Revision:: $ * + * $Date:: $ * + * $Tag:: 0.2.1-FINAL $ * + * $Author:: $ * + * Needs to be in all Files and every File needs "svn propset * + * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2008 by Roland Haeder * * For more information visit: http://www.mxchange.org * @@ -33,7 +38,7 @@ // Some security stuff... if (!defined('__SECURITY')) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php"; + $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); } @@ -97,5 +102,60 @@ function isConfigLoaded () { return ((isset($_CONFIG)) && (is_array($_CONFIG)) && (count($_CONFIG) > 0)); } +// Init the config array +function initConfig () { + global $_CONFIG; + + // Set a minimum dummy configuration + $_CONFIG = array( + 'code_length' => 0, + 'patch_level' => 0, + 'last_update' => time() + ); +} + +// Load configuration and return it as an arry +function loadConfiguration ($no="0") { + global $_CONFIG; + + // Check for cache extension, cache-array and if the requested configuration is in cache + if ((is_array($GLOBALS['cache_array'])) && (isset($GLOBALS['cache_array']['config'][$no])) && (is_array($GLOBALS['cache_array']['config'][$no]))) { + // Load config from cache + //* DEBUG: */ echo gettype($GLOBALS['cache_array']['config'][$no])."
\n"; + foreach ($GLOBALS['cache_array']['config'][$no] as $key => $value) { + $_CONFIG[$key] = $value; + } // END - foreach + + // Count cache hits if exists + if ((isset($_CONFIG['cache_hits'])) && (EXT_IS_ACTIVE('cache'))) { + $_CONFIG['cache_hits']++; + } // END - if + } elseif ((!EXT_IS_ACTIVE('cache')) || (!isset($GLOBALS['cache_array']['config'][$no]))) { + // Load config from DB + $result_config = SQL_QUERY_ESC("SELECT * FROM `{!_MYSQL_PREFIX!}_config` WHERE config=%d LIMIT 1", + array(bigintval($no)), __FUNCTION__, __LINE__); + + // Is the config there? + if (SQL_NUMROWS($result_config) == 1) { + // Get config from database + $_CONFIG = SQL_FETCHARRAY($result_config); + } // END - if + + // Free result + SQL_FREERESULT($result_config); + + // Remember this config in the array + $GLOBALS['cache_array']['config'][$no] = $_CONFIG; + } +} + +// Getter for whole $_CONFIG array +function getConfigArray () { + global $_CONFIG; + + // Return it + return $_CONFIG; +} + // [EOF] ?>