]> git.mxchange.org Git - mailer.git/commitdiff
Migration of stelzi's commit 1022 with some changes so we have a nicer code. See...
authorRoland Häder <roland@mxchange.org>
Tue, 7 Apr 2009 21:08:15 +0000 (21:08 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Apr 2009 21:08:15 +0000 (21:08 +0000)
13 files changed:
birthday_confirm.php
css.php
doubler.php
inc/fatal_errors.php
inc/functions.php
inc/header.php
inc/load_config.php
inc/mysql-connect.php
inc/wrapper-functions.php
index.php
install.php
lead-confirm.php
show_bonus.php

index 24c46fcc56a945922d8907ba713932cf565b98a0..efbb4a55cbc773ad9fdf72c0eedfc1692e22a0c7 100644 (file)
@@ -120,7 +120,7 @@ WHERE b.userid=%s AND b.chk_value='%s' LIMIT 1",
        $GLOBALS['module'] = 'birthday_confirm';
 
        // Include header
-       loadInclude('inc/header.php');
+       loadIncludeOnce('inc/header.php');
 
        // Load birthday header template (for your banners, e.g.?)
        $content['header'] =  LOAD_TEMPLATE('birthday_header', true);
@@ -132,7 +132,7 @@ WHERE b.userid=%s AND b.chk_value='%s' LIMIT 1",
        LOAD_TEMPLATE('birthday_confirm', false, $content);
 
        // Include footer
-       loadInclude('inc/footer.php');
+       loadIncludeOnce('inc/footer.php');
 } else {
        // You have to install first!
        redirectToUrl('install.php');
diff --git a/css.php b/css.php
index 714848650a4749470773d05efef9998abfd43b89..45ad87d9543b2230d700e8ee62fa50a856965471 100644 (file)
--- a/css.php
+++ b/css.php
@@ -57,13 +57,13 @@ require('inc/config-global.php');
 sendHeader('Content-type: text/css');
 
 // Load header
-loadInclude('inc/header.php');
+loadIncludeOnce('inc/header.php');
 
 // Load CSS code
 loadInclude('inc/stylesheet.php');
 
 // Load footer
-loadInclude('inc/footer.php');
+loadIncludeOnce('inc/footer.php');
 
 //
 ?>
index 9a6354783170f111ac9641a081c022b837417457..6920cd155320bd1c71b312ebaf670453b781c553 100644 (file)
@@ -211,7 +211,7 @@ if (isInstalled()) {
        if (getConfig('doubler_send_mode') == 'DIRECT') loadInclude('inc/doubler_send.php');
 
        // Output header
-       loadInclude('inc/header.php');
+       loadIncludeOnce('inc/header.php');
 
        // Banner in text
        define('__DOUBLER_BANNER', LOAD_TEMPLATE('doubler_banner', true));
@@ -272,7 +272,7 @@ if (isInstalled()) {
        LOAD_TEMPLATE('doubler_index');
 
        // Output footer
-       loadInclude('inc/footer.php');
+       loadIncludeOnce('inc/footer.php');
 } else {
        // You have to install first!
        redirectToUrl('install.php');
index 3d4a97a7fc8e03ce4be84eda8e61fef787669f59..3ff6ec562ebf971879cc27dba211697d83f89d38 100644 (file)
@@ -43,8 +43,11 @@ if (!defined('__SECURITY')) {
 }
 
 if (getTotalFatalErrors() > 0) {
+       // Load config here
+       loadIncludeOnce('inc/load_config.php');
+
        // Main div container
-       LOAD_TEMPLATE("fatal_header");
+       LOAD_TEMPLATE('fatal_header');
 
        // Set unset variable
        if (empty($check)) $check = '';
@@ -59,11 +62,11 @@ if (getTotalFatalErrors() > 0) {
                        );
 
                        // Load row template
-                       $OUT .= LOAD_TEMPLATE("install_fatal_row", true, $content);
+                       $OUT .= LOAD_TEMPLATE('install_fatal_row', true, $content);
                }
 
                // Load main template
-               LOAD_TEMPLATE("install_fatal_table", false, $OUT);
+               LOAD_TEMPLATE('install_fatal_table', false, $OUT);
        } elseif (isInstalled()) {
                // Display all runtime fatal errors
                $OUT = '';
@@ -75,11 +78,11 @@ if (getTotalFatalErrors() > 0) {
                        );
 
                        // Load row template
-                       $OUT .= LOAD_TEMPLATE("runtime_fatal_row", true, $content);
+                       $OUT .= LOAD_TEMPLATE('runtime_fatal_row', true, $content);
                }
 
                // Load main template
-               LOAD_TEMPLATE("runtime_fatal_table", false, $OUT);
+               LOAD_TEMPLATE('runtime_fatal_table', false, $OUT);
 
                // Abort here
                shutdown();
@@ -94,7 +97,7 @@ if (getTotalFatalErrors() > 0) {
        } // END - if
 
        // Load footer template
-       LOAD_TEMPLATE("fatal_footer", false, $CORR);
+       LOAD_TEMPLATE('fatal_footer', false, $CORR);
 }
 
 //
index 64e185bdec56a990499f7ae4018c482ea523da91..b9decbaac6d40711fb02e40b93b2ed486c0f5837 100644 (file)
@@ -79,7 +79,6 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
 
                default:
                        // Huh, something goes wrong or maybe you have edited config.php ???
-                       DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", getConfig('OUTPUT_MODE')));
                        app_die(__FUNCTION__, __LINE__, "<strong>{--FATAL_ERROR--}:</strong> {--LANG_NO_RENDER_DIRECT--}");
                        break;
                }
@@ -2248,20 +2247,29 @@ function fixDeletedCookies ($cookies) {
 
 // Output error messages in a fasioned way and die...
 function app_die ($F, $L, $msg) {
-       // Load header
-       loadIncludeOnce('inc/header.php');
+       // Check if Script is already dieing and not let it kill itself another 1000 times
+       if (!isset($GLOBALS['app_died'])) {
+               // Make sure, that the script realy realy diese here and now
+               $GLOBALS['app_died'] = true;
 
-       // Prepare message for output
-       $msg = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $msg);
+               // Load header
+               loadIncludeOnce('inc/header.php');
 
-       // Load the message template
-       LOAD_TEMPLATE('admin_settings_saved', false, $msg);
+               // Prepare message for output
+               $msg = sprintf(getMessage('MXCHANGE_HAS_DIED'), basename($F), $L, $msg);
 
-       // Load footer
-       loadIncludeOnce('inc/footer.php');
+               // Load the message template
+               LOAD_TEMPLATE('admin_settings_saved', false, $msg);
 
-       // Exit explicitly
-       shutdown();
+               // Load footer
+               loadIncludeOnce('inc/footer.php');
+
+               // Exit explicitly
+               shutdown();
+       } else {
+               // Script tried to kill itself twice
+               debug_report_bug('Script wanted to kill itself more than once! Raw message=' . $msg . ', file/function=' . $F . ', line=' . $L);
+       }
 }
 
 // Display parsing time and number of SQL queries in footer
index 9afbe993d24e72c7a1b70be2020d6e0afef68b12..bd4c3e3075fe9c6bd8e311130f07cbceeb91dd36 100644 (file)
@@ -54,7 +54,7 @@ if (($GLOBALS['header_sent'] != '1') && ($GLOBALS['header_sent'] != '2')) {
                // Add title decorations? (left)
                if (!defined('__PAGE_TITLE')) {
                        // Config and database connection valid?
-                       if ((isConfigLoaded()) && (SQL_IS_LINK_UP())) {
+                       if ((isConfigLocalLoaded()) && (isConfigLoaded()) && (SQL_IS_LINK_UP())) {
                                // Title decoration enabled?
                                if ((getConfig('enable_title_deco') == 'Y') && (getConfig('title_left') != '')) $TITLE .= trim(getConfig('title_left'))." ";
 
index 26d35e68c86a03e63b95fd4b253d9d7d30a209f9..f0b36d146a2bf9c54075b714d6c1706bf0aee696 100644 (file)
@@ -47,20 +47,45 @@ setConfigEntry('OUTPUT_MODE' , 'render');
 setConfigEntry('WRITE_FOOTER', 'Y');
 setConfigEntry('_DB_TYPE'    , 'mysql3');
 
+// Mark configuration as NOT loaded which is the default
+$GLOBALS['config_local_loaded'] = false;
+
 // Is the local configuration there?
 if (isIncludeReadable('inc/cache/config-local.php')) {
        // Then load it
        loadIncludeOnce('inc/cache/config-local.php');
+
+       // Mark configuration as loaded
+       $GLOBALS['config_local_loaded'] = true;
 } elseif (isInstalling()) {
        // Set some essential constants
        // @TODO Rewrite them to avoid this else block
        define('MAIN_TITLE', 'Your mail-exchanger title');
        define('SLOGAN'    , 'Your cool slogan here');
        define('WEBMASTER' , 'you@some-hoster.tld.invalid');
+
+       // Set output mode here
+       setConfigEntry('OUTPUT_MODE', 'render');
 } else {
        // Problem in application detected
        debug_report_bug('Wether we are not installing nor config-local.php is created!');
 }
 
+// Check if the user setups his MySQL stuff...
+if ((empty($GLOBALS['mysql']['login'])) && (!isInstalling()) && (!REQUEST_ISSET_GET('installing')) && (isInstalled())) {
+       // No login entered and outside installation mode
+       OUTPUT_HTML('<strong>{--LANG_WARNING--}:</strong> ');
+       if (isInstalled()) {
+               // You have changed my configuration file!
+               app_die(__FILE__, __LINE__, '{--DIE_CONFIG_CHANGED_YOU--}');
+       } else {
+               // Please run the installation script (maybe again)
+               app_die(__FILE__, __LINE__, '{--DIE_RUN_INSTALL_MYSQL--}');
+       }
+} elseif ((!isInstalling()) && (empty($GLOBALS['mysql']['password'])) && (getConfig('WARN_NO_PASS') == 'Y')) {
+       // No database password entered!!!
+       OUTPUT_HTML('<div>{--LANG_WARNING--}:</div> {--WARN_NULL_PASSWORD--}');
+}
+
 //
 ?>
index 8693a51c6b33fac51b5028e2b12f7dc643401cc0..f4e1d42d3a81aaec36f3cb735d57b32964f77b14 100644 (file)
@@ -57,33 +57,17 @@ foreach (array('request-functions', 'session-functions', 'config-functions', 'co
 // Set error handler
 set_error_handler('__errorHandler');
 
-// Load configuration file(s) here
-loadIncludeOnce('inc/load_config.php');
-
 // Set important header_sent
 $GLOBALS['header_sent'] = 0;
 
-// Check if the user setups his MySQL stuff...
-if ((empty($GLOBALS['mysql']['login'])) && (!isInstalling()) && (!REQUEST_ISSET_GET('installing')) && (isInstalled())) {
-       // No login entered and outside installation mode
-       OUTPUT_HTML('<strong>{--LANG_WARNING--}:</strong> ');
-       if (isInstalled()) {
-               // You have changed my configuration file!
-               app_die(__FILE__, __LINE__, '{--DIE_CONFIG_CHANGED_YOU--}');
-       } else {
-               // Please run the installation script (maybe again)
-               app_die(__FILE__, __LINE__, '{--DIE_RUN_INSTALL_MYSQL--}');
-       }
-} elseif ((!isInstalling()) && (empty($GLOBALS['mysql']['password'])) && (getConfig('WARN_NO_PASS') == 'Y')) {
-       // No database password entered!!!
-       OUTPUT_HTML('<div>{--LANG_WARNING--}:</div> {--WARN_NULL_PASSWORD--}');
-}
-
 // Init fatal messages
 initFatalMessages();
 
 // Check if this file is writeable or read-only and warn the user
 if ((!isInstalling()) && (isInstalled())) {
+       // Load configuration file(s) here
+       loadIncludeOnce('inc/load_config.php');
+
        // Check for write-permission for config.php and inc directory
        if (empty($GLOBALS['module'])) $GLOBALS['module'] = REQUEST_GET('module');
        if (empty($GLOBALS['module'])) $GLOBALS['module'] = 'index';
index 6803dfc37810eee46a9a9f38a5763230f3fb4365..b3c3c1359075475571a31c68efae5c3145b8cdb1 100644 (file)
@@ -125,11 +125,11 @@ function loadInclude ($INC) {
 function loadIncludeOnce ($INC) {
        // Is it not loaded?
        if (!isset($GLOBALS['load_once'][$INC])) {
+               // Mark it as loaded
+               $GLOBALS['load_once'][$INC] = "loaded";
+
                // Then try to load it
                loadInclude($INC);
-
-               // And mark it as loaded
-               $GLOBALS['load_once'][$INC] = "loaded";
        } // END - if
 }
 
@@ -278,7 +278,7 @@ function isInstalling () {
 
 // Check wether this script is installed
 function isInstalled () {
-       return (getConfig('MXCHANGE_INSTALLED') == 'Y');
+       return ((getConfig('MXCHANGE_INSTALLED') == 'Y') || (isIncludeReadable('inc/cache/config-local.php')));
 }
 
 // Check wether an admin is registered
@@ -372,5 +372,10 @@ function countPostSelection () {
        return countSelection(REQUEST_POST('sel'));
 }
 
+// Checks wether the config-local.php is loaded
+function isConfigLocalLoaded () {
+       return ((isset($GLOBALS['config_local_loaded'])) && ($GLOBALS['config_local_loaded'] === true));
+}
+
 // [EOF]
 ?>
index 04c39262426a79035faf6639b1af1532b08543c3..8b38b1e2e352f7d2b731d572a9e1f8007dc2f6b3 100644 (file)
--- a/index.php
+++ b/index.php
@@ -56,7 +56,7 @@ require('inc/config-global.php');
 // Is the script installed?
 if (isInstalled()) {
        // Header
-       loadInclude('inc/header.php');
+       loadIncludeOnce('inc/header.php');
 
        // Fix missing array elements here
        if (!isConfigEntrySet('index_delay'))  setConfigEntry('index_delay' , 0);
@@ -89,7 +89,7 @@ if (isInstalled()) {
        }
 
        // Footer
-       loadInclude('inc/footer.php');
+       loadIncludeOnce('inc/footer.php');
 } else {
        // You have to install first!
        redirectToUrl('install.php');
index d632be4e43ead547dd2e729d3660306079fab085..b1ad8f173626a96ce458bd4f54763af8368065a2 100644 (file)
@@ -65,22 +65,22 @@ $GLOBALS['module'] = 'install';
 // Load config file
 require('inc/config-global.php');
 
-// Header
-loadInclude('inc/header.php');
-
-// Reload page to page=welcome when it is not specified
-if (!REQUEST_ISSET_GET('page')) {
-       redirectToUrl('install.php?page=welcome');
-} // END - if
-
 // Already installed?
-if ((isInstalled()) && (isAdminRegistered())) {
+if (isInstalled()) {
        // Add fatal message
        addFatalMessage(__FILE__, __LINE__, getMessage('ALREADY_INSTALLED'));
 } // END - if
 
 // Does something goes wrong?
 if (getTotalFatalErrors() == 0) {
+       // Reload page to page=welcome when it is not specified
+       if (!REQUEST_ISSET_GET('page')) {
+               redirectToUrl('install.php?page=welcome');
+       } // END - if
+
+       // Load header here
+       loadIncludeOnce('inc/header.php');
+
        // Add main installation table
        LOAD_TEMPLATE('install_header');
 
@@ -89,10 +89,13 @@ if (getTotalFatalErrors() == 0) {
 
        // Close main installation table
        LOAD_TEMPLATE('install_footer');
-}
 
-// Footer
-loadInclude('inc/footer.php');
+       // Footer
+       loadIncludeOnce('inc/footer.php');
+} else {
+       // Output fatal messages
+       loadInclude('inc/fatal_errors.php');
+}
 
 //
 ?>
index 3078aa5b47e7bc33869c4e14d79385810e94910c..e21f4f6070ebf6cc7b200ef7e78dba70134f5d5d 100644 (file)
@@ -56,7 +56,7 @@ require('inc/config-global.php');
 // Is the script installed?
 if (isInstalled()) {
        // Header
-       loadInclude('inc/header.php');
+       loadIncludeOnce('inc/header.php');
 
        // Initialize the array for the template
        $content = array(
@@ -91,7 +91,7 @@ if (isInstalled()) {
        LOAD_TEMPLATE('lead_code', false, $content);
 
        // Footer
-       loadInclude('inc/footer.php');
+       loadIncludeOnce('inc/footer.php');
 } else {
        // You have to install first!
        redirectToUrl('install.php');
index d8dc4bf7d087b3a92311196fb4c420541315b90f..6f2e4bffb65b77f40c473b58344c00ae9542368b 100644 (file)
@@ -57,7 +57,7 @@ redirectOnUninstalledExtension('bonus');
 // List only rankings when script is installed
 if (isInstalled()) {
        // Include header
-       loadInclude('inc/header.php');
+       loadIncludeOnce('inc/header.php');
 
        if ((REQUEST_GET('uid') > 0) && (REQUEST_GET('d') > 0) && (REQUEST_ISSET_GET(('t')))) {
                // Set row name
@@ -132,7 +132,7 @@ LIMIT 1",
        LOAD_TEMPLATE('show_bonus', false, $content);
 
        // Include footer
-       loadInclude('inc/footer.php');
+       loadIncludeOnce('inc/footer.php');
 } else {
        // You have to install first!
        redirectToUrl('install.php');