X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Fajax%2Fajax_installer.php;h=108fd3e9135b6577fc0aac3d6bc6d359b0166e3b;hb=f2b603aed42bfdf7a94611d7bae71fe3a1048890;hp=ecdc4bdebb5ef2d6214a35ab6f0a8000ff9a09bb;hpb=5db6eec1f733feda6977091029680a8b12396560;p=mailer.git diff --git a/inc/ajax/ajax_installer.php b/inc/ajax/ajax_installer.php index ecdc4bdebb..108fd3e913 100644 --- a/inc/ajax/ajax_installer.php +++ b/inc/ajax/ajax_installer.php @@ -16,7 +16,7 @@ * $Author:: $ * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * - * Copyright (c) 2009 - 2012 by Mailer Developer Team * + * Copyright (c) 2009 - 2013 by Mailer Developer Team * * For more information visit: http://mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -37,7 +37,8 @@ // Some security stuff... if ((!defined('__SECURITY')) || (!isAjaxOutputMode()) || (!isInstallationPhase())) { - die(); + header('HTTP/1.1 403 Forbidden'); + die(json_encode(array('reply_content' => 'Access forbidden'), JSON_FORCE_OBJECT)); } // END - if //----------------------------------------------------------------------------- @@ -52,8 +53,11 @@ function establishAjaxInstallerDatabaseLink () { reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.'); } // END - if + // Remove any previous flag + unsetSqlLinkUp(__FUNCTION__, __LINE__); + // Establish link - $linkResource = SQL_CONNECT(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__); + $linkResource = sqlConnectToDatabase(getSession('mysql_host'), getSession('mysql_login'), getSession('mysql_password1'), __FUNCTION__, __LINE__); // Is this a link resource? if (!is_resource($linkResource)) { @@ -62,10 +66,10 @@ function establishAjaxInstallerDatabaseLink () { } // END - if // Does selecting the database work? - if (!SQL_SELECT_DB(getSession('mysql_dbase'), __FUNCTION__, __LINE__)) { + if (!sqlSelectDatabase(getSession('mysql_dbase'), __FUNCTION__, __LINE__)) { // Could not be selected reportBug(__FUNCTION__, __LINE__, 'Could not select database ' . getSession('mysql_dbase')); - } elseif ((!isFileReadable(getPath() . 'install/tables.sql')) || (!isFileReadable(getPath() . 'install/menu-'.getLanguage().'.sql'))) { + } elseif ((!isFileReadable(getSession('base_path') . 'install/tables.sql')) || (!isFileReadable(getSession('base_path') . 'install/menu-'.getLanguage().'.sql'))) { // Installation area not found reportBug(__FUNCTION__, __LINE__, 'SQL dumps not found. Please extract ALL files from the archive or checkout all files out from SVN.'); } elseif (ifFatalErrorsDetected()) { @@ -99,6 +103,7 @@ function doAjaxProcessInstall () { // Again we do a call-back, so generate a function name depending on 'do' $callbackName = 'doAjaxInstaller' . capitalizeUnderscoreString(postRequestElement('do')); + $GLOBALS['ajax_callback_function'] = $callbackName; // Is the call-back function there? if (!function_exists($callbackName)) { @@ -139,6 +144,7 @@ function doAjaxInstallerFooterNavigation () { case 'database_config': case 'smtp_config': case 'other_config': + case 'extensions': array_push($enabledNavigations, 'previous'); case 'welcome': // Only 'next' works for welcome page array_push($enabledNavigations, 'next'); @@ -225,7 +231,7 @@ function doAjaxInstallerRequestContent () { setHttpStatus('200 OK'); } else { // Set 404 error - setHttpStatus('404 NOT FOUND'); + setHttpStatus('404 Not Found'); } } // END - if } @@ -241,8 +247,14 @@ function doAjaxInstallerChangeWarning () { // "Walk" through all elements $OUT = '
    '; foreach (explode(':', postRequestElement('elements')) as $element) { - // Add row - $OUT .= '
  1. {--INSTALLER_CHANGED_ELEMENT_' . strtoupper($element) . '--}
  2. '; + // Is it an extension? + if (substr($element, 0, 4) == 'ext_') { + // Add row for extension + $OUT .= '
  3. {%message,INSTALLER_CHANGED_ELEMENT_EXTENSION=' . str_replace('_', '-', $element) . '%}
  4. '; + } else { + // Add generic row + $OUT .= '
  5. {--INSTALLER_CHANGED_ELEMENT_' . strtoupper($element) . '--}
  6. '; + } } // END - foreach $OUT .= '
'; @@ -277,7 +289,7 @@ function doAjaxInstallerSaveChanges () { $currentTab = postRequestElement('tab'); // Remove some elements which should not be saved - foreach (array('do', 'level') as $removedElement) { + foreach (array('tab', 'do', 'level') as $removedElement) { // Remove this element from POST data unsetPostRequestElement($removedElement); } // END - foreach @@ -297,6 +309,7 @@ function doAjaxInstallerSaveChanges () { // Now set all remaining data in session foreach (postRequestArray() as $key => $value) { // Set it, if it is valid, else it will be added to $saveStatus (call-by-reference) + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value[' . gettype($value) . '=' . $value); $saveStatus['is_saved'] = ( // Is the data valid? (isInstallerDataValid($saveStatus, $key, $value)) @@ -307,7 +320,7 @@ function doAjaxInstallerSaveChanges () { // Save the overall status for below final check $isAllSaved = (($isAllSaved === TRUE) && ($saveStatus['is_saved'] === TRUE)); - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value=' . $value . ',is_saved=' . intval($saveStatus['is_saved']) . ',isAllSaved=' . intval($isAllSaved)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',value[' . gettype($value) . '=' . $value . ',is_saved=' . intval($saveStatus['is_saved']) . ',isAllSaved=' . intval($isAllSaved)); } // END - foreach // 'is_saved' is still true? @@ -446,6 +459,21 @@ function doAjaxPrepareInstallerOtherConfig () { } // END - if } +// Prepare AJAX request 'extensions' +function doAjaxPrepareInstallerExtensions () { + // Is 'extensions' set? + if (!isSessionVariableSet('extensions')) { + /* + * At least ext-sql_patches and ext-task should be installed + *(ext-sql_patches is a must!) + */ + setSession('extensions', 'admins:sql_patches:task'); + } elseif (strpos(getSession('extensions'), 'sql_patches') === FALSE) { + // Add missing ext-sql_patches + setSession('extensions', getSession('extensions') . ':sql_patches'); + } +} + // Prepare AJAX request 'overview' function doAjaxPrepareInstallerOverview () { // 'tab' must always be set to create a post-check-callback @@ -548,6 +576,97 @@ function doAjaxInstallerStepImportTablesSql () { // Now run all queries through runFilterChain('run_sqls'); + + // Close SQL link + sqlCloseLink(__FUNCTION__, __LINE__); +} + +// Call-back function to import menu SQL file +function doAjaxInstallerStepImportMenuSql () { + // Establish database link + establishAjaxInstallerDatabaseLink(); + + // Init SQL array + initSqls(); + + // Import tables.sql + importInstallSqlDump('menu-' . getLanguage()); + + // Are some SQLs found? + if (countSqls() == 0) { + // Abort here + reportBug(__FUNCTION__, __LINE__, '{--INSTALLER_SQL_IMPORT_FAILED--}'); + } // END - if + + // Now run all queries through + runFilterChain('run_sqls'); + + // Close SQL link + sqlCloseLink(__FUNCTION__, __LINE__); +} + +// Call-back function to install some important extensions +function doAjaxInstallerStepInstallExtensions () { + // Only one element is required + if (!isSessionVariableSet('extensions')) { + // Some required session data is not set + reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.'); + } // END - if + + // Establish database link + establishAjaxInstallerDatabaseLink(); + + // Get all extensions + $extensions = explode(':', getSession('extensions')); + + // Make sure ext-sql_patches is first + array_unshift($extensions, 'sql_patches'); + + // "Walk" through all extensions + foreach ($extensions as $key => $ext_name) { + // Is ext-sql_patches not at key=0? + if (($key == 0) && ($ext_name == 'sql_patches')) { + // Then skip this entry + continue; + } elseif ((!loadExtension($ext_name, 'test', '0.0.0', TRUE)) || (!registerExtension($ext_name, NULL))) { + // Didn't work + reportBug(__FUNCTION__, __LINE__, 'Cannot load/register extension ' . $ext_name . '.'); + } // END - if + } // END - foreach +} + +// Call-back function to write local configuration file +function doAjaxInstallerStepWriteLocalConfig () { + // Is all set? + if (!isSessionDataSet(array('base_path', 'base_url', 'main_title', 'slogan', 'webmaster', 'mysql_host', 'mysql_dbase', 'mysql_prefix', 'mysql_login', 'mysql_password1', 'mysql_password2', 'mysql_engine', 'output_mode', 'warn_no_pass', 'write_footer', 'enable_backlink'))) { + // Some required session data is not set + reportBug(__FUNCTION__, __LINE__, 'Required session data for this step not found.'); + } // END - if + + // Write config file + if (!doInstallWriteLocalConfigurationFile( + getSession('base_path'), + getSession('base_url'), + getSession('main_title'), + getSession('slogan'), + getSession('webmaster'), + getSession('warn_no_pass'), + getSession('write_footer'), + getSession('enable_backlink'), + getSession('mysql_host'), + getSession('mysql_dbase'), + getSession('mysql_login'), + getSession('mysql_password1'), + getSession('mysql_prefix'), + getSession('mysql_engine'), + getSession('smtp_host'), + getSession('smtp_user'), + getSession('smtp_password1') + )) { + // Something bad went wrong + removeFile(getSession('base_path') . getCachePath() . 'config-local.php'); + reportBug(__FUNCTION__, __LINE__, 'Did not fully write config-local.php .'); + } } // [EOF]