More missing config entries added
[mailer.git] / inc / config-functions.php
index d261faecaa7a200c538dacbb876dfcc4098b5c29..db769c06e400bf795772b47c69c9b4e720b20702 100644 (file)
@@ -42,9 +42,28 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
-// Merges $GLOBALS['config'] with data in given array
-function mergeConfig ($newConfig) {
-       $GLOBALS['config'] = merge_array(getConfigArray(), $newConfig);
+// Init the config array
+function initConfig () {
+       // Init not if already found
+       if ((isset($GLOBALS['config'])) && (count($GLOBALS['config']) >= 3)) {
+               // Already initialized
+               trigger_error(sprintf("[%s:%s] Configuration is already initialized.", __FUNCTION__, __LINE__));
+       } // END - if
+
+       // Set a minimum dummy configuration
+       $GLOBALS['config'] = array(
+               'code_length'   => 0,
+               'patch_level'   => 0,
+               'last_update'   => time(),
+               'DEBUG_MODE'    => 'N',
+               'DEBUG_RESET'   => 'N',
+               'DEBUG_MONTHLY' => 'N',
+               'DEBUG_WEEKLY'  => 'N',
+               'DEBUG_REGEX'   => 'N',
+               'sql_count'     => 0,
+               'num_templates' => 0,
+               'default_theme' => 'default',
+       );
 }
 
 // Getter for $GLOBALS['config'] entries
@@ -53,13 +72,13 @@ function getConfig ($configEntry) {
        $value = null;
 
        // Is the entry there?
-       if (isConfigEntrySet($configEntry)) {
-               // Then use it
-               $value = $GLOBALS['config'][$configEntry];
+       if (!isConfigEntrySet($configEntry)) {
+               // Raise an error of missing entries
+               trigger_error(sprintf("[%s:%s] Configuration entry <em>%s</em> is missing.", __FUNCTION__, __LINE__, $configEntry));
        } // END - if
 
        // Return it
-       return $value;
+       return $GLOBALS['config'][$configEntry];
 }
 
 // Setter for $GLOBALS['config'] entries
@@ -82,6 +101,11 @@ function isConfigEntrySet ($configEntry) {
        return (isset($GLOBALS['config'][$configEntry]));
 }
 
+// Merges $GLOBALS['config'] with data in given array
+function mergeConfig ($newConfig) {
+       $GLOBALS['config'] = merge_array(getConfigArray(), $newConfig);
+}
+
 // Increment or init with given value or 1 as default the given config entry
 function incrementConfigEntry ($configEntry, $value=1) {
        // Increment it if set or init it with 1
@@ -98,22 +122,12 @@ function isConfigLoaded () {
        return ((isset($GLOBALS['config'])) && (is_array($GLOBALS['config'])) && (count($GLOBALS['config']) > 0));
 }
 
-// Init the config array
-function initConfig () {
-       // Set a minimum dummy configuration
-       $GLOBALS['config'] = array(
-               'code_length' => 0,
-               'patch_level' => 0,
-               'last_update' => time()
-       );
-}
-
 // Load configuration and return it as an arry
 function loadConfiguration ($no = '0') {
        // Check for cache extension, cache-array and if the requested configuration is in cache
        if ((isset($GLOBALS['cache_array'])) && (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])."<br />\n";
+               //* DEBUG: */ OUTPUT_HTML(gettype($GLOBALS['cache_array']['config'][$no])."<br />");
                foreach ($GLOBALS['cache_array']['config'][$no] as $key => $value) {
                        setConfigEntry($key, $value);
                } // END - foreach
@@ -216,7 +230,7 @@ function updateOldConfigFile () {
                        // Is the line found?
                        if ((substr($line, 0, strlen($old)) == $old) && (!isset($done[$old]))) {
                                // Entry found!
-                               //* DEBUG: */ print htmlentities($line) . " - FOUND!<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML(htmlentities($line) . " - FOUND!<br />");
 
                                // Eval the line...
                                eval($line);
@@ -247,9 +261,9 @@ function updateOldConfigFile () {
                                } // END - if
 
                                /// ... and write it to the new config
-                               //* DEBUG: */ print 'function=' . $function . ',new=' . $new . ',comment=' . $comment . "<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML('function=' . $function . ',new=' . $new . ',comment=' . $comment . "<br />");
                                changeDataInFile(constant('PATH') . 'inc/cache/config-local.php', $comment, $function . "('" . $oldNew . "', \"", "\");", constant($new), 0);
-                               //* DEBUG: */ print "CHANGED!<br />\n";
+                               //* DEBUG: */ OUTPUT_HTML("CHANGED!<br />");
 
                                // Mark it as done
                                $done[$old] = 1;
@@ -280,7 +294,7 @@ function updateOldConfigFile () {
                        }
 
                        // Debug output only
-                       //* DEBUG: */ print htmlentities($line) . " - MySQL!<br />\n";
+                       //* DEBUG: */ OUTPUT_HTML(htmlentities($line) . " - MySQL!<br />");
 
                        // Split parts so we can check them and prepare them
                        $parts = explode('=>', $line);