';
$msg .= 'Although the minimum PHP version required is ';
$msg .= constant('SUITECRM_PHP_MIN_VERSION').', ';
$msg .= 'is not recommended due to the large number of fixed bugs, including security fixes, ';
$msg .= 'released in the more modern versions.
';
$msg .= 'You are using PHP version '. constant('PHP_VERSION').', which is EOL: http://php.net/eol.php.
';
$msg .= 'Please consider upgrading your PHP version. Instructions on http://php.net/migration70. ';
die($msg);
}
$session_id = session_id();
if (empty($session_id)) {
@session_start();
}
$GLOBALS['installing'] = true;
define('SUGARCRM_IS_INSTALLING', $GLOBALS['installing']);
$GLOBALS['sql_queries'] = 0;
require_once('include/SugarLogger/LoggerManager.php');
require_once('sugar_version.php');
require_once('suitecrm_version.php');
require_once('install/install_utils.php');
require_once('install/install_defaults.php');
require_once('include/TimeDate.php');
require_once('include/Localization/Localization.php');
require_once('include/SugarTheme/SugarTheme.php');
require_once('include/utils/LogicHook.php');
require_once('data/SugarBean.php');
require_once('include/entryPoint.php');
//check to see if the script files need to be rebuilt, add needed variables to request array
$_REQUEST['root_directory'] = getcwd();
$_REQUEST['js_rebuild_concat'] = 'rebuild';
//Set whether the install is silent or not
global $silentInstall;
$silentInstall = true;
//Todo, check if there is an instance where goto is not set, but a silent install is in place
if (isset($_REQUEST['goto']) && $_REQUEST['goto'] != 'SilentInstall') {
require_once('jssource/minify.php');
$silentInstall = false;
}
global $timedate;
$timedate = TimeDate::getInstance();
// cn: set php.ini settings at entry points
setPhpIniSettings();
global $locale;
$locale = new Localization();
$GLOBALS['log'] = LoggerManager::getLogger();
global $setup_sugar_version;
$setup_sugar_version = $suitecrm_version;
global $install_script;
$install_script = true;
///////////////////////////////////////////////////////////////////////////////
//// INSTALL RESOURCE SETUP
$css = 'install/install.css';
$icon = 'include/images/sugar_icon.ico';
$sugar_md = 'include/images/sugar_md_open.png';
$loginImage = 'include/images/suitecrm_login.png';
$common = 'install/installCommon.js';
///////////////////////////////////////////////////////////////////////////////
//// INSTALLER LANGUAGE
function getSupportedInstallLanguages()
{
$supportedLanguages = array(
'en_us' => 'English (US)',
);
if (file_exists('install/lang.config.php')) {
include('install/lang.config.php');
if (!empty($config['languages'])) {
foreach ($config['languages'] as $k=>$v) {
if (file_exists('install/language/' . $k . '.lang.php')) {
$supportedLanguages[$k] = $v;
}
}
}
}
return $supportedLanguages;
}
global $supportedLanguages;
$supportedLanguages = getSupportedInstallLanguages();
// after install language is selected, use that pack
global $default_lang;
$default_lang = 'en_us';
if (!isset($_POST['language']) && (!isset($_SESSION['language']) && empty($_SESSION['language']))) {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang = parseAcceptLanguage();
if (isset($supportedLanguages[$lang])) {
$_POST['language'] = $lang;
} else {
$_POST['language'] = $default_lang;
}
}
}
if (isset($_POST['language'])) {
$_SESSION['language'] = str_replace('-', '_', $_POST['language']);
}
global $current_language;
$current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
if (file_exists("install/language/{$current_language}.lang.php")) {
require_once("install/language/{$current_language}.lang.php");
} else {
require_once("install/language/{$default_lang}.lang.php");
}
global $mod_strings;
if ($current_language != 'en_us') {
$my_mod_strings = $mod_strings;
include('install/language/en_us.lang.php');
$mod_strings = sugarLangArrayMerge($mod_strings, $my_mod_strings);
}
global $app_list_strings;
$app_list_strings = return_app_list_strings_language($current_language);
//// END INSTALLER LANGUAGE
///////////////////////////////////////////////////////////////////////////////
//get the url for the helper link
global $help_url;
$help_url = get_help_button_url();
if (isset($sugar_config['installer_locked']) && $sugar_config['installer_locked'] == true) {
if (!empty($_POST['current_step']) && $_POST['current_step'] === '3' && !empty($_POST['goto']) && $_POST['goto'] === $mod_strings['LBL_NEXT']) {
session_unset();
$the_file = 'complete_install.php';
} else {
$the_file = 'installDisabled.php';
$disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION'];
$disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2'];
$disabled_text = <<
'installer_locked' => false,
{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}
{$mod_strings['LBL_DISABLED_HELP_1']} {$mod_strings['LBL_DISABLED_HELP_2']}.
EOQ; } $the_file = 'install/' . clean_string($the_file, 'FILE'); if (is_file($the_file)) { installerHook('pre_installFileRequire', ['the_file' => $the_file]); require($the_file); die(); } LoggerManager::getLogger()->fatal('Install file not found: ' . $the_file); die('SuiteCRM Installation has been Disabled'); } //if this license print, then redirect and exit, if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'licensePrint') { include('install/licensePrint.php'); exit(); } if (isset($_REQUEST['sugar_body_only']) && $_REQUEST['sugar_body_only'] == "1") { //if this is a system check, then just run the check and return, //this is an ajax call and there is no need for further processing if (isset($_REQUEST['uploadLogoFrame']) && ($_REQUEST['uploadLogoFrame'])) { echo 'I\'m an uploader iframe!'; return; } // upload company logo if (isset($_REQUEST['uploadLogo']) && ($_REQUEST['uploadLogo'])) { $filepath = ''; $errors = array(); switch ($_FILES['company_logo']['error']) { case UPLOAD_ERR_OK: $allowedTypes = array(IMAGETYPE_PNG, IMAGETYPE_JPEG/*, IMAGETYPE_GIF */); $detectedType = exif_imagetype($_FILES['company_logo']['tmp_name']); if (!in_array($detectedType, $allowedTypes)) { $errors[] = $mod_strings['ERR_UPLOAD_FILETYPE']; } else { // uploaded image stored in the /custom path instead of put into the original theme directory.. mkdir_recursive('custom/' . SugarThemeRegistry::current()->getDefaultImagePath(), true); $tmpvar = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png')); $destFile = 'custom/' . $tmpvar[0]; if (!move_uploaded_file($_FILES['company_logo']['tmp_name'], $destFile)) { $errors[] = $mod_strings['ERR_LANG_UPLOAD_1']; } else { $filepath = $destFile; } } break; case UPLOAD_ERR_INI_SIZE: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_INI_SIZE']; break; case UPLOAD_ERR_FORM_SIZE: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_FORM_SIZE']; break; case UPLOAD_ERR_PARTIAL: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_PARTIAL']; break; case UPLOAD_ERR_NO_FILE: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_NO_FILE']; break; case UPLOAD_ERR_NO_TMP_DIR: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_NO_TMP_DIR']; break; case UPLOAD_ERR_CANT_WRITE: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_CANT_WRITE']; break; case UPLOAD_ERR_EXTENSION: $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_EXTENSION']; break; default: $errors[] = $mod_strings['ERR_LANG_UPLOAD_UNKNOWN']; break; } $result['filepath'] = $filepath; $result['errors'] = $errors ? $errors : false; // TODO--low: validate file size & image width/height and save, show status result to client js if (isset($_REQUEST['callback']) && $_REQUEST['callback'] === 'uploadLogoCallback') { echo ""; } return; } if (isset($_REQUEST['storeConfig']) && ($_REQUEST['storeConfig'])) { // store configuration by form to session if (!isset($_SESSION)) { session_start(); } $_SESSION = array_merge($_SESSION, $_POST); // TODO--low: don't forget the custom type install settings! validate here.. // if(count($validation_errors = validate_dbConfig('a')) > 0) { // $si_errors = true; // } // else if(count($validation_errors = validate_siteConfig('a')) > 0) { // $si_errors = true; // } // else if(count($validation_errors = validate_siteConfig('b')) > 0) { // $si_errors = true; // } if (!empty($sugar_config['dbconfig'])) { try { global $db; $db = DBManagerFactory::getInstance(); $db->disconnect(); } catch (\Exception $e) { $validation_errors[] = $mod_strings['LBL_DB_CONN_ERR'] . ': ' . $e->getMessage(); } } $errors = ''; if (isset($validation_errors) && is_array($validation_errors)) { if (count($validation_errors) > 0) { // $errors = ''.$mod_strings['LBL_SITECFG_FIX_ERRORS'].'
{$mod_strings['LBL_HELP']} | |
|
|
---|---|
![]() |
|
{$mod_strings['LBL_LAUNCHING_SILENT_INSTALL']} |
'installer_locked' => false,
{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}
{$mod_strings['LBL_DISABLED_HELP_1']} {$mod_strings['LBL_DISABLED_HELP_2']}.
EOQ; } else { $validation_errors = array(); // process the data posted if ($next_clicked) { // store the submitted data because the 'Next' button was clicked switch ($workflow[trim($_REQUEST['current_step'])]) { case 'old_php.php': $_SESSION['language'] = $_REQUEST['language']; $_SESSION['setup_old_php'] = get_boolean_from_request('setup_old_php'); break; case 'welcome.php': $_SESSION['language'] = $_REQUEST['language']; $_SESSION['setup_site_admin_user_name'] = 'admin'; // break; // case 'license.php': $_SESSION['setup_license_accept'] = get_boolean_from_request('setup_license_accept'); $_SESSION['license_submitted'] = true; // eventually default all vars here, with overrides from config.php if (is_readable('config.php')) { global $sugar_config; include_once('config.php'); } $default_db_type = 'mysql'; if (!isset($_SESSION['setup_db_type'])) { $_SESSION['setup_db_type'] = empty($sugar_config['dbconfig']['db_type']) ? $default_db_type : $sugar_config['dbconfig']['db_type']; } break; //TODO--low: add this functionality to installConfig.php case 'installType.php': $_SESSION['install_type'] = $_REQUEST['install_type']; if (isset($_REQUEST['setup_license_key']) && !empty($_REQUEST['setup_license_key'])) { $_SESSION['setup_license_key'] = $_REQUEST['setup_license_key']; } $_SESSION['licenseKey_submitted'] = true; break; case 'installConfig.php': //case 'systemOptions.php': if (isset($_REQUEST['setup_db_type'])) { $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type']; } $validation_errors = validate_systemOptions(); if (count($validation_errors) > 0) { $next_step--; } //break; //case 'dbConfig_a.php': //validation is now done through ajax call to checkDBSettings.php if (isset($_REQUEST['setup_db_drop_tables'])) { $_SESSION['setup_db_drop_tables'] = $_REQUEST['setup_db_drop_tables']; if ($_SESSION['setup_db_drop_tables']=== true || $_SESSION['setup_db_drop_tables'] == 'true') { $_SESSION['setup_db_create_database'] = false; } } //break; //case 'siteConfig_a.php': if (isset($_REQUEST['setup_site_url'])) { $_SESSION['setup_site_url'] = $_REQUEST['setup_site_url']; } if (isset($_REQUEST['setup_system_name'])) { $_SESSION['setup_system_name'] = $_REQUEST['setup_system_name']; } if (isset($_REQUEST['setup_db_collation'])) { $_SESSION['setup_db_options']['collation'] = $_REQUEST['setup_db_collation']; } if(isset($_REQUEST['setup_db_charset'])) { $_SESSION['setup_db_options']['charset'] = $_REQUEST['setup_db_charset']; } $_SESSION['setup_site_admin_user_name'] = $_REQUEST['setup_site_admin_user_name']; $_SESSION['setup_site_admin_password'] = $_REQUEST['setup_site_admin_password']; $_SESSION['setup_site_admin_password_retype'] = $_REQUEST['setup_site_admin_password_retype']; $_SESSION['siteConfig_submitted'] = true; $validation_errors = array(); $validation_errors = validate_siteConfig('a'); if (count($validation_errors) > 0 || $_REQUEST['goto'] == 'resend') { $next_step--; } //break; // add old custom install settings to new install form //case 'siteConfig_b.php': $_SESSION['setup_site_sugarbeet_automatic_checks'] = get_boolean_from_request('setup_site_sugarbeet_automatic_checks'); $_SESSION['setup_site_custom_session_path'] = get_boolean_from_request('setup_site_custom_session_path'); if ($_SESSION['setup_site_custom_session_path']) { $_SESSION['setup_site_session_path'] = $_REQUEST['setup_site_session_path']; } else { $_SESSION['setup_site_session_path'] = ''; } $_SESSION['setup_site_custom_log_dir'] = get_boolean_from_request('setup_site_custom_log_dir'); if ($_SESSION['setup_site_custom_log_dir']) { $_SESSION['setup_site_log_dir'] = $_REQUEST['setup_site_log_dir']; } else { $_SESSION['setup_site_log_dir'] = '.'; } $_SESSION['setup_site_specify_guid'] = get_boolean_from_request('setup_site_specify_guid'); if ($_SESSION['setup_site_specify_guid']) { $_SESSION['setup_site_guid'] = $_REQUEST['setup_site_guid']; } else { $_SESSION['setup_site_guid'] = ''; } $_SESSION['siteConfig_submitted'] = true; if (isset($_REQUEST['setup_site_sugarbeet_anonymous_stats'])) { $_SESSION['setup_site_sugarbeet_anonymous_stats'] = get_boolean_from_request('setup_site_sugarbeet_anonymous_stats'); } else { $_SESSION['setup_site_sugarbeet_anonymous_stats'] = 0; } $validation_errors = array(); $validation_errors = validate_siteConfig('b'); if (count($validation_errors) > 0) { $next_step--; } break; } } if ($next_step == 9999) { $the_file = 'SilentInstall'; } elseif ($next_step == 9191) { $_SESSION['oc_server_url'] = $_REQUEST['oc_server_url']; $_SESSION['oc_username'] = $_REQUEST['oc_username']; $_SESSION['oc_password'] = $_REQUEST['oc_password']; $the_file = 'oc_convert.php'; } elseif ($next_step === 9) { $the_file = $workflow[4]; } else { $the_file = $workflow[$next_step]; } switch ($the_file) { case 'old_php.php': case 'welcome.php': case 'license.php': // // Check to see if session variables are working properly // $_SESSION['test_session'] = 'sessions are available'; @session_write_close(); unset($_SESSION['test_session']); @session_start(); if (!isset($_SESSION['test_session'])) { $the_file = 'installDisabled.php'; // PHP.ini location - $phpIniLocation = get_cfg_var("cfg_file_path"); $disabled_title = $mod_strings['LBL_SESSION_ERR_TITLE']; $disabled_title_2 = $mod_strings['LBL_SESSION_ERR_TITLE']; $disabled_text = $mod_strings['LBL_SESSION_ERR_DESCRIPTION']."{$phpIniLocation}"; break; } // check to see if installer has been disabled if (is_readable('config.php') && (filesize('config.php') > 0)) { include_once('config.php'); if (!isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == true) { $the_file = 'installDisabled.php'; $disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION']; $disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2']; $disabled_text =<<
'installer_locked' => false,
{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}
{$mod_strings['LBL_DISABLED_HELP_1']} {$mod_strings['LBL_DISABLED_HELP_2']}.
EOQ; //if this is an offline client installation but the conversion did not succeed, //then try to convert again if (isset($sugar_config['disc_client']) && $sugar_config['disc_client'] == true && isset($sugar_config['oc_converted']) && $sugar_config['oc_converted'] == false) { header('Location: index.php?entryPoint=oc_convert&first_time=true'); exit(); } } } break; case 'register.php': case 'complete_install.php': session_unset(); break; case 'SilentInstall': $si_errors = false; pullSilentInstallVarsIntoSession(); /* * Make sure we are using the correct unique_key. The logic * to save a custom unique_key happens lower in the process. * However because of the initial FTS check we are already * relying on this value which will not get reinitialized * when we actual need it during index creation because * SilentInstaller runs in one single process. */ if (!empty($_SESSION['setup_site_specify_guid']) && !empty($_SESSION['setup_site_guid'])) { $sugar_config['unique_key'] = $_SESSION['setup_site_guid']; } else { $sugar_config['unique_key'] = md5(create_guid()); } $validation_errors = validate_dbConfig(); if (count($validation_errors) > 0) { $the_file = 'dbConfig_a.php'; $si_errors = true; } $validation_errors = validate_siteConfig('a'); if (count($validation_errors) > 0) { $the_file = 'siteConfig_a.php'; $si_errors = true; } $validation_errors = validate_siteConfig('b'); if (count($validation_errors) > 0) { $the_file = 'siteConfig_b.php'; $si_errors = true; } if (!$si_errors) { $the_file = 'performSetup.php'; } require_once('jssource/minify.php'); //since this is a SilentInstall we still need to make sure that //the appropriate files are writable // config.php make_writable('./config.php'); // custom dir make_writable('./custom'); // modules dir recursive_make_writable('./modules'); // cache dir create_writable_dir(sugar_cached('custom_fields')); create_writable_dir(sugar_cached('dyn_lay')); create_writable_dir(sugar_cached('images')); create_writable_dir(sugar_cached('modules')); create_writable_dir(sugar_cached('layout')); create_writable_dir(sugar_cached('pdf')); create_writable_dir(sugar_cached('upload/import')); create_writable_dir(sugar_cached('xml')); create_writable_dir(sugar_cached('include/javascript')); recursive_make_writable(sugar_cached('modules')); // public dir recursive_make_writable('./public'); // check whether we're getting this request from a command line tool // we want to output brief messages if we're outputting to a command line tool $cli_mode = false; if (isset($_REQUEST['cli']) && ($_REQUEST['cli'] == 'true')) { $_SESSION['cli'] = true; // if we have errors, just shoot them back now if (count($validation_errors) > 0) { foreach ($validation_errors as $error) { print($mod_strings['ERR_ERROR_GENERAL']."\n"); print(" " . $error . "\n"); print("Exit 1\n"); exit(1); } } } break; } } $the_file = 'install/' . clean_string($the_file, 'FILE'); if (is_file($the_file)) { installerHook('pre_installFileRequire', ['the_file' => $the_file]); require($the_file); installerHook('post_installFileRequire', ['the_file' => $the_file]); } else { LoggerManager::getLogger()->fatal('Install file not found: ' . $the_file); }