]> git.mxchange.org Git - mailer.git/blobdiff - inc/config-functions.php
Better only check on daily reset
[mailer.git] / inc / config-functions.php
index 41505b26dd2b17220a4ef6dd05aadb78f285361e..25f80bc98908ac444cb917908579426931318a17 100644 (file)
@@ -55,7 +55,8 @@ function initConfig () {
                'num_templates'       => 0,
                // 'DEFAULT_SALT_LENGTH' => 40,
                // 'DEBUG_MODE'          => 'N',
-               // 'DEBUG_RESET'         => 'N',
+               // 'DEBUG_HOURLY'        => 'N',
+               // 'DEBUG_DAILY'         => 'N',
                // 'DEBUG_MONTHLY'       => 'N',
                // 'DEBUG_WEEKLY'        => 'N',
                // 'DEBUG_REGEX'         => 'N',
@@ -86,6 +87,18 @@ function getConfig ($configEntry) {
 function setConfigEntry ($configEntry, $value) {
        // Just set it (unsecured won't hurt?)
        $GLOBALS['config'][$configEntry] = $value;
+
+       // Remove cache
+       removeGlobalCache($configEntry);
+}
+
+// Removes entry in $GLOBALS
+function removeGlobalCache ($configEntry) {
+       // Generate key
+       $key = 'get' . capitalizeUnderscoreString($configEntry);
+
+       // Remove it
+       unset($GLOBALS[$key]);
 }
 
 // Checks whether the given config entry is set
@@ -136,37 +149,37 @@ function updateOldConfigFile () {
        // Watch out for these lines and execute them as single command
        // @TODO Make this all better... :-/
        $watchLines = array(
-               'SITE_KEY'           => 'SITE_KEY',
-               'DEFAULT_LANG'       => 'DEFAULT_LANG',
-               'warn_no_pass'       => 'WARN_NO_PASS',
-               'WRITE_FOOTER'       => 'WRITE_FOOTER',
-               'OUTPUT_MODE'        => 'OUTPUT_MODE',
-               'MAIN_TITLE'         => 'MAIN_TITLE',
-               'SLOGAN'             => 'SLOGAN',
-               'WEBMASTER'          => 'WEBMASTER',
-               'mxchange_installed' => 'MXCHANGE_INSTALLED',
-               'admin_registered'   => 'ADMIN_REGISTERED',
-               '_MYSQL_PREFIX'      => '_MYSQL_PREFIX',
-               '_TABLE_TYPE'        => '_TABLE_TYPE',
-               '_DB_TYPE'           => '_DB_TYPE',
-               'SMTP_HOSTNAME'      => 'SMTP_HOSTNAME',
-               'SMTP_USER'          => 'SMTP_USER',
-               'SMTP_PASSWORD'      => 'SMTP_PASSWORD',
-               'ENABLE_BACKLINK'    => 'ENABLE_BACKLINK',
-               'MAIN_TITLE'         => 'MAIN_TITLE',
-               'SLOGAN'             => 'SLOGAN',
-               'WEBMASTER'          => 'WEBMASTER',
-               'PATH'               => 'PATH',
-               'URL'                => 'URL',
+               'SITE_KEY'         => 'SITE_KEY',
+               'DEFAULT_LANG'     => 'DEFAULT_LANG',
+               'warn_no_pass'     => 'WARN_NO_PASS',
+               'WRITE_FOOTER'     => 'WRITE_FOOTER',
+               'OUTPUT_MODE'      => 'OUTPUT_MODE',
+               'MAIN_TITLE'       => 'MAIN_TITLE',
+               'SLOGAN'           => 'SLOGAN',
+               'WEBMASTER'        => 'WEBMASTER',
+               'mailer_installed' => 'MAILER_INSTALLED',
+               'admin_registered' => 'ADMIN_REGISTERED',
+               '_MYSQL_PREFIX'    => '_MYSQL_PREFIX',
+               '_TABLE_TYPE'      => '_TABLE_TYPE',
+               '_DB_TYPE'         => '_DB_TYPE',
+               'SMTP_HOSTNAME'    => 'SMTP_HOSTNAME',
+               'SMTP_USER'        => 'SMTP_USER',
+               'SMTP_PASSWORD'    => 'SMTP_PASSWORD',
+               'ENABLE_BACKLINK'  => 'ENABLE_BACKLINK',
+               'MAIN_TITLE'       => 'MAIN_TITLE',
+               'SLOGAN'           => 'SLOGAN',
+               'WEBMASTER'        => 'WEBMASTER',
+               'PATH'             => 'PATH',
+               'URL'              => 'URL',
        );
 
        // Make these lower-case! (damn stupid code...)
-       $lowerCase = array('WARN_NO_PASS', 'MXCHANGE_INSTALLED', 'ADMIN_REGISTERED');
+       $lowerCase = array('WARN_NO_PASS', 'MAILER_INSTALLED', 'ADMIN_REGISTERED');
 
        // Special comments...
        $comments = array(
                'WARN_NO_PASS'       => 'NULLPASS-WARNING',
-               'MXCHANGE_INSTALLED' => 'INSTALLED',
+               'MAILER_INSTALLED  ' => 'INSTALLED',
                'ADMIN_REGISTERED'   => 'ADMIN-SETUP',
                '_MYSQL_PREFIX'      => 'MYSQL-PREFIX',
                '_TABLE_TYPE'        => 'TABLE-TYPE',
@@ -182,7 +195,7 @@ function updateOldConfigFile () {
        copyFileVerified(getPath() . 'inc/config-local.php.dist', getCachePath() . 'config-local.php', 0644);
 
        // First of all, load the old one!
-       $oldConfig = explode(chr(10), readFromFile(getPath() . 'inc/config.php'));
+       $oldConfig = explode(PHP_EOL, readFromFile(getPath() . 'inc/config.php'));
 
        // Now, analyze every entry
        $done = array();
@@ -372,6 +385,12 @@ function updateConfiguration ($entries, $values, $updateMode = '', $config = '0'
 
 // Filter for loading configuration
 function FILTER_LOAD_CONFIGURATION ($no = '0') {
+       // Is installation phase?
+       if (isInstallationPhase()) {
+               // Then don't load any configuration
+               return;
+       } // END - if
+
        // Is the value null, it comes from the 'init' filter chain
        if (is_null($no)) {
                $no = '0';
@@ -403,5 +422,37 @@ function FILTER_LOAD_CONFIGURATION ($no = '0') {
        }
 }
 
+// "Getter" for "checked" configuration entries
+function getCheckedConfig ($configEntries) {
+       // Add entries
+       $content = getConfigEntries($configEntries, ' checked="checked"');
+
+       // Return it
+       return $content;
+}
+
+// "Getter" for "selected" configuration entries
+function getSelectedConfig ($configEntries) {
+       // Add entries
+       $content = getConfigEntries($configEntries, ' selected="selected"');
+
+       // Return it
+       return $content;
+}
+
+// "Getter" for configuration entries
+function getConfigEntries ($configEntries, $value) {
+       // Init content
+       $content = array();
+
+       // "Walk" through all entries
+       foreach ($configEntries as $entry) {
+               $content[$entry . '_' . strtolower(getConfig($entry))] = $value;
+       } // END - foreach
+
+       // Return it
+       return $content;
+}
+
 // [EOF]
 ?>