From: Roland Häder Date: Sun, 5 Jul 2009 19:46:21 +0000 (+0000) Subject: Fixes for broken installation routine X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4ccc02299e123d24c043c917fb16208d0338f300;p=mailer.git Fixes for broken installation routine --- diff --git a/inc/install-inc.php b/inc/install-inc.php index d2fb295a77..9d68191e9e 100644 --- a/inc/install-inc.php +++ b/inc/install-inc.php @@ -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 .= "
  • ".$value."
  • \n"; + $OUT .= "
  • " . $value . "
  • \n"; } // END foreach define('__FATAL_ERROR_LI', $OUT); $OUT = ''; foreach ($mysql as $key => $value) { - $OUT .= " \n"; + $OUT .= " \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("
    {--WRONG_PAGE--}
    "); diff --git a/inc/mysql-connect.php b/inc/mysql-connect.php index 836da4cd53..20d19f4b36 100644 --- a/inc/mysql-connect.php +++ b/inc/mysql-connect.php @@ -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')) { diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 54ffb3db3a..5d27ca5826 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -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() + ) + ) ) ); } diff --git a/install.php b/install.php index b1ad8f1736..75638936e4 100644 --- a/install.php +++ b/install.php @@ -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'); // ?>