X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Finstall-inc.php;h=b1aeb83b02054f9accd16ad8604953a17712c9ca;hb=2e0f1bfd10fc3d9fe9b43d29cc3e32622b262c63;hp=6613994455a6a5085b056109ad1657c20656ac37;hpb=65ba529135f31dfd36b4471588f45f8687cc1aca;p=mailer.git diff --git a/inc/install-inc.php b/inc/install-inc.php index 6613994455..b1aeb83b02 100644 --- a/inc/install-inc.php +++ b/inc/install-inc.php @@ -41,6 +41,9 @@ if (!defined('__SECURITY')) { require($INC); } +// Load sql_patches here +LOAD_EXTENSION("sql_patches"); + // Init variables $mysql = ""; if ((REQUEST_ISSET_POST(('mysql'))) && (is_array(REQUEST_POST('mysql')))) $mysql = REQUEST_POST('mysql'); @@ -74,7 +77,7 @@ if ((REQUEST_ISSET_GET(('page')) && (REQUEST_GET('page') == 5))) { } // END - if // Is MXChange installed or no admin registered so far? -if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndTrue('admin_registered'))) +if ((!isInstalled()) || (!isAdminRegistered())) { // Set URL for FORM actions define('__BURL_ACTION', constant('URL')); @@ -264,9 +267,9 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT break; case "finalize": // Write captured data to files - if ((REQUEST_ISSET_POST(('finalize'))) && (!isBooleanConstantAndTrue('mxchange_installed'))) { - // You have submitted data then we have to reset the fatal messages - $SQLs = array(); + if ((REQUEST_ISSET_POST(('finalize'))) && (!isInstalled())) { + // You have submitted data then we have to reset the SQLs + INIT_SQLS(); // Connect to MySQL server SQL_CONNECT($mysql['host'], $mysql['login'], $mysql['pass1'], __FILE__, __LINE__); @@ -281,10 +284,15 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT $FQFN = secureString(REQUEST_POST('spath')) . "install/" . $dump; if (FILE_READABLE($FQFN)) { // Read the file - $SQLs = READ_FILE($FQFN, true); + $fileContent = READ_FILE($FQFN, true); + + // Replace the {!prefix!} with actual one + while (strpos($fileContent, "{!prefix!}") !== false) { + $fileContent = str_replace("{!prefix!}", $mysql['prefix'], $fileContent); + } // END - while // And split it up against ;\n ... - $SQLs = merge_array($SQLs, explode(";\n", $sql)); + SET_SQLS(merge_array(GET_SQLS(), explode(";\n", $fileContent))); } else { // Not readable! debug_report_bug(sprintf("SQL dump %s is not readable!", $dump)); @@ -292,23 +300,14 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT } // END - foreach // Are some SQLs found? - if (count($SQLs) == 0) { + if (COUNT_SQLS() == 0) { // Abort here - addFatalMessage(getMessage('INSTALL_SQL_IMPORT_FAILED')); + addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_SQL_IMPORT_FAILED')); return; } // END - if // Now run all queries through and try to keep out empty or comment queries - foreach ($SQLs as $sql) { - // Trim spaces away - $sql = trim($sql); - - // Is this query not empty and not a comment? - if ((!empty($sql)) && (substr($sql, 0, 2) != "--") && (substr($sql, 0, 1) != "#")) { - // Then run it! - SQL_QUERY($sql, __FILE__, __LINE__); - } // END - if - } // END - foreach + runFilterChain('run_sqls'); // Ok, all done. So we can write the config data to the php files if (REQUEST_POST('spath') != constant('PATH')) changeDataInFile(REQUEST_POST('spath')."inc/config.php", "SERVER-PATH", "define('PATH', \"", "\");", REQUEST_POST('spath'), 0); @@ -331,7 +330,7 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT changeDataInFile(REQUEST_POST('spath')."inc/config.php", "INSTALLED", "define('mxchange_installed', ", ");", "true", 0); } else { // Installation area not found! - addFatalMessage(getMessage('INSTALL_MISSING_DUMPS')); + addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_MISSING_DUMPS')); } } // END - if } // END - if @@ -360,12 +359,12 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT // Installation is done! LOAD_URL("install.php?page=finalize"); } - } elseif (isBooleanConstantAndTrue('mxchange_installed')) { + } elseif (isInstalled()) { // Redirection after writing data... :-) LOAD_TEMPLATE("install_finished"); } else { // Something goes wrong during installation! :-( - addFatalMessage(getMessage('INSTALL_FINALIZER_FAILED')); + addFatalMessage(__FILE__, __LINE__, getMessage('INSTALL_FINALIZER_FAILED')); LOAD_INC("inc/fatal_errors.php"); } break; @@ -377,7 +376,7 @@ if ((!isBooleanConstantAndTrue('mxchange_installed')) || (!isBooleanConstantAndT } } else { // Already installed! - addFatalMessage(getMessage('ALREADY_INSTALLED')); + addFatalMessage(__FILE__, __LINE__, getMessage('ALREADY_INSTALLED')); } //