=0) {
$stop = true; // flag to show "next"
if(isset($_SESSION['files'])) {
unset($_SESSION['files']);
}
$errors = preflightCheck();
$php_version = constant('PHP_VERSION');
if(check_php($php_version) == -1)
{
$phpVersion = "{$mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} ";
$error_txt = ''.$phpVersion.'';
if(count($errors) == 0)
$errors[] = '';
$errors[] = $error_txt;
logThis($error_txt);
}
$diffs = '';
$schema = '';
$anyScriptChanges = '';
$db =& DBManagerFactory::getInstance();
//Quickcreatedefs on the basis of editviewdefs
if(substr($sugar_version,0,1) >= 5){
updateQuickCreateDefs();
}
upgradeSugarCache($_SESSION['install_file']);
if((count($errors) == 1)) { // only diffs
logThis('file preflight check passed successfully.');
$stop = false;
$out = $mod_strings['LBL_UW_PREFLIGHT_TESTS_PASSED']."
".$mod_strings['LBL_UW_PREFLIGHT_TESTS_PASSED3']."";
$stop = false;
$disableEmail = (empty($current_user->email1)) ? 'DISABLED' : 'CHECKED';
if(count($errors['manual']) > 0) {
$preserveFiles = array();
$diffs =<<
function preflightToggleAll(cb) {
var checkAll = false;
var form = document.getElementById('diffs');
if(cb.checked == true) {
checkAll = true;
}
for(i=0; i
";
$diffs .= "";
// list preserved files (templates, etc.)
$preserve = '';
foreach($preserveFiles as $pf) {
if(empty($preserve)) {
$preserve .= "";
$preserve .= $mod_strings['LBL_UW_PREFLIGHT_PRESERVE_FILES'];
$preserve .= " |
";
}
$preserve .= "".str_replace(getcwd(), '.', $pf)." |
";
}
if(!empty($preserve)) {
$preserve .= '
';
}
$diffs = $preserve.$diffs;
} else { // NO FILE DIFFS REQUIRED
$diffs = $mod_strings['LBL_UW_PREFLIGHT_NO_DIFFS'];
}
} else {
logThis('*** ERROR: found too many preflight errors - displaying errors and stopping execution.');
$out = "{$mod_strings['ERR_UW_PREFLIGHT_ERRORS']}:
";
$out .= "";
foreach($errors as $error) {
if(is_array($error)) { // manual diff files
continue;
} else {
$out .= "{$error}
";
}
}
$out .= "
";
}
$diffs ='';
///////////////////////////////////////////////////////////////////////////////
//// SCHEMA SCRIPT HANDLING
logThis('starting schema preflight check...');
//Check the current and target versions and store them in session variables
if(!isset($sugar_db_version) || empty($sugar_db_version)) {
include('./sugar_version.php');
}
if(!isset($manifest['version']) || empty($manifest['version'])) {
include($_SESSION['unzip_dir'].'/manifest.php');
}
$current_version = substr(preg_replace("#[^0-9]#", "", $sugar_db_version),0,3);
$targetVersion = substr(preg_replace("#[^0-9]#", "", $manifest['version']),0,3);
//save the versions as session variables
$_SESSION['current_db_version'] = $current_version;
$_SESSION['target_db_version'] = $targetVersion;
$_SESSION['upgrade_from_flavor'] = $manifest['name'];
// aw: BUG 10161: check flavor conversion sql files
$sqlFile = ''; // cn: bug
if($current_version == $targetVersion) {
if(preg_match('/(.*?)([^0])$/', $current_version, $matches))
{
$current_version = $matches[1].'0';
}
switch($manifest['name']){
case 'SugarCE to SugarPro':
$sqlFile = $current_version.'_ce_to_pro_'.$db->dbType;
break;
case 'SugarCE to SugarEnt':
$sqlFile = $current_version.'_ce_to_ent_'.$db->dbType;
break;
case 'SugarPro to SugarEnt':
$sqlFile = $current_version.'_pro_to_ent_'.$db->dbType;
break;
default:
break;
}
} else {
$sqlFile = $current_version.'_to_'.$targetVersion.'_'.$db->dbType;
}
$newTables = array();
if($db->dbType == 'oci8') {
} else {
$sqlScript = $_SESSION['unzip_dir'].'/scripts/'.$sqlFile.'.sql';
}
logThis('looking for schema script at: '.$sqlScript);
if(is_file($sqlScript)) {
logThis('found schema upgrade script: '.$sqlScript);
logThis('schema preflight using MySQL');
if(function_exists('sugar_fopen')){
$fp = sugar_fopen($sqlScript, 'r');
}
else{
$fp = fopen($sqlScript, 'r');
}
$contents = stream_get_contents($fp);
$anyScriptChanges =$contents;
// remove __uw_temp tables
//testCleanUp($db->dbType);
fclose($fp);
$customTables = getCustomTables($db->dbType);
if ( !empty($customTables) ) {
$_SESSION['alterCustomTableQueries'] = alterCustomTables($db->dbType, $customTables);
} else {
$_SESSION['alterCustomTableQueries'] = false;
}
$schema = "{$mod_strings['LBL_UW_SHOW_SCHEMA']}";
$schema .= "
";
$schema .= "";
$schema .= "
";
if(!empty($sqlErrors)) {
$stop = true;
$out = "{$mod_strings['ERR_UW_PREFLIGHT_ERRORS']}: ";
$out .= "{$mod_strings['LBL_UW_SHOW_SQL_ERRORS']}";
foreach($sqlErrors as $sqlError) {
$out .= "
{$sqlError}";
}
$out .= "
";
}
} else {
$customTableSchema = '';
logThis('no schema script found - all schema preflight skipped');
}
logThis('schema preflight done.');
//// END SCHEMA SCRIPT HANDLING
///////////////////////////////////////////////////////////////////////////////
//php 521 suggestion
$php_521 = '';
if(version_compare(phpversion(),'5.2.1') < 0){
$php_521=$mod_strings['LBL_CURRENT_PHP_VERSION'].phpversion().$mod_strings['LBL_RECOMMENDED_PHP_VERSION'];
}
if(empty($mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE'])){
$mod_strings['LBL_UPGRADE_TAKES_TIME_HAVE_PATIENCE'] = 'Upgrade may take some time';
}
$style_for_out = empty($out)?'style=\'display:none\'':'';
$style_for_dif = empty($diffs)?'style=\'display:none\'':'';
$style_for_schemaChange = empty($schema)?'style=\'display:none\'':'';
$final =<<
{$out}
|
{$mod_strings['LBL_UW_MANUAL_MERGE']}
|
{$diffs}
|
|
{$mod_strings['LBL_UW_SCHEMA_CHANGE']}
|
{$schema}
|
|
{$mod_strings['LBL_UW_DB_METHOD']}
{$mod_strings['LBL_UW_SQL_RUN']}
|
eoq;
$form5 =<<
eoq5;
$uwMain = $final.$form5;
//set the upgrade progress status.
set_upgrade_progress('preflight','done');
}
else{
$stop = true;
if(empty($mod_strings['LBL_INCOMPATIBLE_PHP_VERSION'])){
$mod_strings['LBL_INCOMPATIBLE_PHP_VERSION'] = 'Php version 5.2.1 or above is required.';
}
$php_verison_warning =<<
{$mod_strings['LBL_INCOMPATIBLE_PHP_VERSION']}
|
eoq;
$php_warnings = $php_verison_warning;
}
//Add the backward compatibility check as well.
//Php Backward compatibility checks
if(ini_get("zend.ze1_compatibility_mode")) {
$stop = true;
if(empty($mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'])){
$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'] = 'Php Backward Compatibility mode is turned on. Set zend.ze1_compatibility_mode to Off for proceeding further';
}
$php_compatibility_warning =<<
{$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON']}
|
eoq;
$php_warnings .= $php_compatibility_warning;
}
if($php_warnings != null){
$uwMain = $php_warnings;
}
$GLOBALS['top_message'] = "{$mod_strings['LBL_UW_PREFLIGHT_TESTS_PASSED2']}";
$showBack = false;
$showCancel = true;
$showRecheck = true;
$showNext = ($stop) ? false : true;
$stepBack = $_REQUEST['step'] - 1;
$stepNext = $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = ($stop) ? 'failed' : 'success';
?>