X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fconfig-functions.php;h=3288e72904f2a796d6bcd606cbd48c5a8d9bd4a1;hp=95a6fb2cac1d5932399ee5a4f2ff5735f270af7f;hb=5deec33be1baf2135eefc2bbb0d1b63c6cbd2f9a;hpb=af0d7727246bdfb13ab844727ac75750ad5d21b7 diff --git a/inc/config-functions.php b/inc/config-functions.php index 95a6fb2cac..3288e72904 100644 --- a/inc/config-functions.php +++ b/inc/config-functions.php @@ -109,5 +109,40 @@ function initConfig () { ); } +// 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; + } +} + // [EOF] ?>