function migrate($migrationInfo) { global $installationStrings; $completed = false; set_time_limit(0); //ADDED TO AVOID UNEXPECTED TIME OUT WHILE MIGRATING global $dbconfig; require $migrationInfo['root_directory'] . '/config.inc.php'; $dbtype = $dbconfig['db_type']; $host = $dbconfig['db_server'] . $dbconfig['db_port']; $dbname = $dbconfig['db_name']; $username = $dbconfig['db_username']; $passwd = $dbconfig['db_password']; global $adb, $migrationlog; $adb = new PearDatabase($dbtype, $host, $dbname, $username, $passwd); $query = " ALTER DATABASE " . $adb->escapeDbName($dbname) . " DEFAULT CHARACTER SET utf8"; $adb->query($query); $source_directory = $migrationInfo['source_directory']; if (file_exists($source_directory . 'user_privileges/CustomInvoiceNo.php')) { require_once $source_directory . 'user_privileges/CustomInvoiceNo.php'; } $migrationlog =& LoggerManager::getLogger('MIGRATION'); if (isset($migrationInfo['old_version'])) { $source_version = $migrationInfo['old_version']; } if (!isset($source_version) || empty($source_version)) { //If source version is not set then we cannot proceed echo "<br> " . $installationStrings['LBL_SOURCE_VERSION_NOT_SET']; exit; } $reach = 0; include $migrationInfo['root_directory'] . "/modules/Migration/versions.php"; foreach ($versions as $version => $label) { if ($version == $source_version || $reach == 1) { $reach = 1; $temp[] = $version; } } $temp[] = $current_version; global $adb, $dbname; $_SESSION['adodb_current_object'] = $adb; @ini_set('zlib.output_compression', 0); @ini_set('output_buffering', 'off'); ob_implicit_flush(true); echo '<table width="98%" border="1px" cellpadding="3" cellspacing="0" height="100%">'; if (is_array($_SESSION['migration_info']['user_messages'])) { foreach ($_SESSION['migration_info']['user_messages'] as $infoMap) { echo "<tr><td>" . $infoMap['status'] . "</td><td>" . $infoMap['msg'] . "</td></tr>"; } } echo "<tr><td colspan='2'><b>{$installationStrings['LBL_GOING_TO_APPLY_DB_CHANGES']}...</b></td></tr>"; for ($patch_count = 0; $patch_count < count($temp); $patch_count++) { //Here we have to include all the files (all db differences for each release will be included) $filename = "modules/Migration/DBChanges/" . $temp[$patch_count] . "_to_" . $temp[$patch_count + 1] . ".php"; $empty_tag = "<tr><td colspan='2'> </td></tr>"; $start_tag = "<tr><td colspan='2'><b><font color='red'> "; $end_tag = "</font></b></td></tr>"; if (is_file($filename)) { echo $empty_tag . $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_STARTS'] . "." . $end_tag; include $filename; //include the file which contains the corresponding db changes echo $start_tag . $temp[$patch_count] . " ==> " . $temp[$patch_count + 1] . " " . $installationStrings['LBL_DATABASE_CHANGES'] . " -- " . $installationStrings['LBL_ENDS'] . "." . $end_tag; } } /* Install Vtlib Compliant Modules */ Common_Install_Wizard_Utils::installMandatoryModules(); Migration_Utils::installOptionalModules($migrationInfo['selected_optional_modules'], $migrationInfo['source_directory'], $migrationInfo['root_directory']); Migration_utils::copyLanguageFiles($migrationInfo['source_directory'], $migrationInfo['root_directory']); //Here we have to update the version in table. so that when we do migration next time we will get the version $res = $adb->query('SELECT * FROM vtiger_version'); global $vtiger_current_version; require $migrationInfo['root_directory'] . '/vtigerversion.php'; if ($adb->num_rows($res)) { $res = ExecuteQuery("UPDATE vtiger_version SET old_version='{$versions[$source_version]}',current_version='{$vtiger_current_version}'"); $completed = true; } else { ExecuteQuery("INSERT INTO vtiger_version (id, old_version, current_version) values (" . $adb->getUniqueID('vtiger_version') . ", '{$versions[$source_version]}', '{$vtiger_current_version}');"); $completed = true; } echo '</table><br><br>'; create_tab_data_file(); create_parenttab_data_file(); return $completed; }
} if (isset($_SESSION['installation_info']['currency_code'])) { $currency_code = $_SESSION['installation_info']['currency_code']; } if (isset($_SESSION['installation_info']['currency_symbol'])) { $currency_symbol = $_SESSION['installation_info']['currency_symbol']; } if (isset($_SESSION['installation_info']['selected_optional_modules'])) { $selected_optional_modules = $_SESSION['installation_info']['selected_optional_modules']; } if (isset($_SESSION['installation_info']['db_populate'])) { $db_populate = $_SESSION['installation_info']['db_populate']; } require_once 'install/CreateTables.inc.php'; // Install Vtlib Compliant Modules Common_Install_Wizard_Utils::installMandatoryModules(); Installation_Utils::installOptionalModules($selected_optional_modules); // Unset all of the session variables. $_SESSION = array(); // If it's desired to kill the session, also delete the session cookie. // Note: This will destroy the session, and not just the session data! if (isset($_COOKIE[session_name()])) { setcookie(session_name(), '', time() - 42000, '/'); } // Finally, destroy the session. session_destroy(); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">