Fixes for broken order page and themes
[mailer.git] / inc / load_config.php
index 26d35e68c86a03e63b95fd4b253d9d7d30a209f9..e38c041606ca08402fd2d1b2964afeae9c5662da 100644 (file)
@@ -17,7 +17,7 @@
  * 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                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -38,8 +38,7 @@
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
-       require($INC);
+       die();
 } // END - if
 
 // Set some config entries which is required for installation phase
@@ -47,19 +46,59 @@ 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')) {
+if ((isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')) && (isIncludeReadable('inc/config.php'))) {
+       // We are better in installation mode
+       $GLOBALS['mxchange_installing'] = true;
+
+       // Define default main_title here
+       setConfigEntry('MAIN_TITLE', 'Your mail-exchange title');
+
+       // Set output mode here
+       setConfigEntry('OUTPUT_MODE', 'render');
+
+       // Both exist! This is bad and should be avoided by the admin
+       app_die(__FILE__, __LINE__, 'You have uploaded or kept an out-dated file at <strong>inc/config.php</strong> along with the new file <strong>'.getConfig('CACHE_PATH').'config-local.php</strong>. Please remove <strong>inc/config.php</strong> to avoid incompatiblity issues. Thank you.');
+} elseif (isIncludeReadable(getConfig('CACHE_PATH') . 'config-local.php')) {
        // Then load it
-       loadIncludeOnce('inc/cache/config-local.php');
+       loadIncludeOnce(getConfig('CACHE_PATH') . 'config-local.php');
+
+       // Mark configuration as loaded
+       $GLOBALS['config_local_loaded'] = true;
+} elseif (isIncludeReadable('inc/config.php')) {
+       // Out-dated inc/config.php found, falling back to load and "wrap" it
+       updateOldConfigFile();
 } 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');
+       setConfigEntry('MAIN_TITLE', 'Your mail-exchanger title');
+       setConfigEntry('SLOGAN'    , 'Your cool slogan here');
+       setConfigEntry('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!');
+       // Redirect to install.php
+       redirectToUrl('install.php');
+}
+
+// Check if the user setups his MySQL stuff...
+if ((empty($GLOBALS['mysql']['login'])) && (!isInstalling()) && (!isGetRequestElementSet('installing')) && (isInstalled())) {
+       // No login entered and outside installation mode
+       outputHtml('<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!!!
+       outputHtml('<div>{--LANG_WARNING--}:</div> {--WARN_NULL_PASSWORD--}');
 }
 
 //