Fixes for broken installation routine
authorRoland Häder <roland@mxchange.org>
Sun, 5 Jul 2009 19:46:21 +0000 (19:46 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 5 Jul 2009 19:46:21 +0000 (19:46 +0000)
inc/install-inc.php
inc/mysql-connect.php
inc/wrapper-functions.php
install.php

index d2fb295a77c7c02fc72edc60713ca5a9048b37d4..9d68191e9ef1de86caa3a3931a935162339fd058 100644 (file)
@@ -17,6 +17,8 @@
  * Needs to be in all Files and every File needs "svn propset           *
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
+ * @TODO Rewrite all constants in this include file                     *
+ * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
@@ -84,14 +86,12 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
        define('__BURL_ACTION', constant('URL'));
 
        // Output page for entered value
-       switch (REQUEST_GET('page'))
-       {
+       switch (REQUEST_GET('page')) {
                case 'welcome': // Welcome to the installation!
                        LOAD_TEMPLATE('install_welcome');
                        break;
 
                case '1': // Server path, base URL
-                       // @Profi-Concept: Hab meine Meinung doch geaendert! :-)
                        // Load template
                        LOAD_TEMPLATE('install_page1');
                        break;
@@ -260,7 +260,7 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                        break;
 
                case 'finalize': // Write captured data to files
-                       if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) {
+                       if ((REQUEST_ISSET_POST('finalize')) && (!isInstalled())) {
                                // You have submitted data then we have to reset the SQLs
                                INIT_SQLS();
 
@@ -270,7 +270,12 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                                        // Seems to work, also right database?
                                        if (SQL_SELECT_DB($mysql['dbase'], __FILE__, __LINE__) === true) {
                                                // Automatically run install.sql
-                                               if ((isFileReadable(REQUEST_POST('spath') . 'install/tables.sql')) && (isFileReadable(REQUEST_POST('spath') . 'install/menu-'.getLanguage().'.sql'))) {
+                                               if ((!isFileReadable(REQUEST_POST('spath') . 'install/tables.sql')) || (!isFileReadable(REQUEST_POST('spath') . 'install/menu-'.getLanguage().'.sql'))) {
+                                                       // Installation area not found!
+                                                       addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_MISSING_DUMPS'));
+                                               } // END - if
+
+                                               if (getTotalFatalErrors() == 0) {
                                                        // Both exists so import them
                                                        foreach (array('tables', 'menu-'.getLanguage()) as $dump) {
                                                                // Should be save here because file_exists() is there but we check it again. :)
@@ -337,22 +342,19 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
 
                                                        // Script is now installed
                                                        changeDataInFile(REQUEST_POST('spath') . 'inc/cache/config-local.php', "INSTALLED", "setConfigEntry('MXCHANGE_INSTALLED', \"", "\");", 'Y', 0);
-                                               } else {
-                                                       // Installation area not found!
-                                                       addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_MISSING_DUMPS'));
-                                               }
+                                               } // END - if
                                        } // END - if
                                } // END - if
 
                                if (getTotalFatalErrors() > 0) {
                                        $OUT = '';
                                        foreach (getFatalArray() as $value) {
-                                               $OUT .= "    <li>".$value."</li>\n";
+                                               $OUT .= "    <li>" . $value . "</li>\n";
                                        } // END foreach
                                        define('__FATAL_ERROR_LI', $OUT);
                                        $OUT = '';
                                        foreach ($mysql as $key => $value) {
-                                               $OUT .= "    <input type=\"hidden\" name=\"mysql[".$key."]\" value=\"".$value."\" />\n";
+                                               $OUT .= "    <input type=\"hidden\" name=\"mysql[" . $key . "]\" value=\"" . $value . "\" />\n";
                                        } // END foreach
                                        define('__MYSQL_DATA'   , $OUT);
                                        define('__SPATH_VALUE'  , REQUEST_POST('spath'));
@@ -366,11 +368,8 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                                        LOAD_TEMPLATE('install_fatal_errors');
                                } else {
                                        // Installation is done!
-                                       redirectToUrl('install.php?page=finalize');
+                                       redirectToUrl('install.php?page=finished');
                                }
-                       } elseif (isInstalled()) {
-                               // Redirection after writing data... :-)
-                               LOAD_TEMPLATE('install_finished');
                        } else {
                                // Something goes wrong during installation! :-(
                                addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_FINALIZER_FAILED'));
@@ -378,6 +377,16 @@ if ((!isInstalled()) || (!isAdminRegistered())) {
                        }
                        break;
 
+               case 'finished':
+                       if (isInstalled()) {
+                               // Load template that we are finished
+                               LOAD_TEMPLATE('install_finished');
+                       } else {
+                               // Not finished
+                               redirectToUrl('install.php');
+                       }
+                       break;
+
                default:
                        DEBUG_LOG(__FILE__, __LINE__, sprintf("Wrong page %s detected", REQUEST_GET('page')));
                        OUTPUT_HTML("    <div class=\"install_error\">{--WRONG_PAGE--}</div>");
index 836da4cd53fb39a44416fefbb3de087b2a8f6bd4..20d19f4b365de63b4a3f94801aa4fa46b7cfa14d 100644 (file)
@@ -226,6 +226,9 @@ if ((!isInstalling()) && (isInstalled())) {
 
        // Load extension 'sql_patches'
        LOAD_EXTENSION('sql_patches');
+
+       // Load configuration file(s) here
+       loadIncludeOnce('inc/load_config.php');
 }
 
 if ((getTotalFatalErrors() > 0) && (isInstalled()) && (!isInstalling()) && ($GLOBALS['output_mode'] != '1')) {
index 54ffb3db3a964ee5b116b7c122be951864ac4272..5d27ca58265e2582b7332ef9b2a41767e17dcd51 100644 (file)
@@ -286,24 +286,24 @@ function isInstalling () {
 function isInstalled () {
        return (
        (
-       // New config file found and loaded
-       getConfig('MXCHANGE_INSTALLED') == 'Y'
+               // New config file found and loaded
+               getConfig('MXCHANGE_INSTALLED') == 'Y'
        ) || (
-       // Fall-back!
-       isIncludeReadable('inc/config.php')
+               // Fall-back!
+               isIncludeReadable('inc/config.php')
        ) || (
-       (
-       // New config file found, but not yet read
-       isIncludeReadable('inc/cache/config-local.php')
-       ) && (
-       (
-       // Only new config file is found
-       !isIncludeReadable('inc/config.php')
-       ) || (
-       // Is installation mode
-       isInstalling()
-       )
-       )
+               (
+                       // New config file found, but not yet read
+                       isIncludeReadable('inc/cache/config-local.php')
+               ) && (
+                       (
+                               // Only new config file is found
+                               !isIncludeReadable('inc/config.php')
+                       ) || (
+                               // Is installation mode
+                               isInstalling()
+                       )
+               )
        )
        );
 }
index b1ad8f173626a96ce458bd4f54763af8368065a2..75638936e493b07f504ba0211c230a9ee6957e33 100644 (file)
@@ -65,37 +65,37 @@ $GLOBALS['module'] = 'install';
 // Load config file
 require('inc/config-global.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()) {
+if ((isInstalled()) && (REQUEST_GET('page' != 'finished'))) {
        // 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
+if (getTotalFatalErrors() > 0) {
+       // Output fatal messages
+       loadInclude('inc/fatal_errors.php');
+} // END - if
 
-       // Load header here
-       loadIncludeOnce('inc/header.php');
+// Load header here
+loadIncludeOnce('inc/header.php');
 
-       // Add main installation table
-       LOAD_TEMPLATE('install_header');
+// Add main installation table
+LOAD_TEMPLATE('install_header');
 
-       // Here start's our installtion stuff
-       loadIncludeOnce('inc/install-inc.php');
+// Here start's our installtion stuff
+loadIncludeOnce('inc/install-inc.php');
 
-       // Close main installation table
-       LOAD_TEMPLATE('install_footer');
+// Close main installation table
+LOAD_TEMPLATE('install_footer');
 
-       // Footer
-       loadIncludeOnce('inc/footer.php');
-} else {
-       // Output fatal messages
-       loadInclude('inc/fatal_errors.php');
-}
+// Footer
+loadIncludeOnce('inc/footer.php');
 
 //
 ?>