PageRenderTime 63ms CodeModel.GetById 16ms app.highlight 39ms RepoModel.GetById 1ms app.codeStats 1ms

/install.php

https://github.com/AUTOPLANNING/SuiteCRM
PHP | 767 lines | 535 code | 104 blank | 128 comment | 144 complexity | 03c21fb71e02dae48b862e917d06e272 MD5 | raw file
  1<?php
  2 if(!defined('sugarEntry'))define('sugarEntry', true);
  3/*********************************************************************************
  4 * SugarCRM Community Edition is a customer relationship management program developed by
  5 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
  6
  7 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
  8 * Copyright (C) 2011 - 2014 Salesagility Ltd.
  9 *
 10 * This program is free software; you can redistribute it and/or modify it under
 11 * the terms of the GNU Affero General Public License version 3 as published by the
 12 * Free Software Foundation with the addition of the following permission added
 13 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
 14 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
 15 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
 16 *
 17 * This program is distributed in the hope that it will be useful, but WITHOUT
 18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 19 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
 20 * details.
 21 *
 22 * You should have received a copy of the GNU Affero General Public License along with
 23 * this program; if not, see http://www.gnu.org/licenses or write to the Free
 24 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 25 * 02110-1301 USA.
 26 *
 27 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
 28 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
 29 *
 30 * The interactive user interfaces in modified source and object code versions
 31 * of this program must display Appropriate Legal Notices, as required under
 32 * Section 5 of the GNU Affero General Public License version 3.
 33 *
 34 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
 35 * these Appropriate Legal Notices must retain the display of the "Powered by
 36 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
 37 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
 38 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
 39 ********************************************************************************/
 40 
 41@session_start();
 42if(isset($_REQUEST['clear_session']) || !empty($_SESSION['loginAttempts'])) {
 43	session_destroy();
 44	header('Location: install.php');
 45	echo 'session clean, page refresh...';
 46	exit;
 47}
 48 
 49//  recover smtp settings
 50if(isset($_POST['smtp_tab_selected'])) {
 51    $_POST = array_merge($_POST, $_POST[$_POST['smtp_tab_selected']]);
 52}
 53
 54//session_destroy();
 55if (version_compare(phpversion(),'5.2.0') < 0) {
 56	$msg = 'Minimum PHP version required is 5.2.0.  You are using PHP version  '. phpversion();
 57    die($msg);
 58}
 59$session_id = session_id();
 60if(empty($session_id)){
 61	@session_start();
 62}
 63$GLOBALS['installing'] = true;
 64define('SUGARCRM_IS_INSTALLING', $GLOBALS['installing']);
 65$GLOBALS['sql_queries'] = 0;
 66require_once('include/SugarLogger/LoggerManager.php');
 67require_once('sugar_version.php');
 68require_once('suitecrm_version.php');
 69require_once('include/utils.php');
 70require_once('install/install_utils.php');
 71require_once('install/install_defaults.php');
 72require_once('include/TimeDate.php');
 73require_once('include/Localization/Localization.php');
 74require_once('include/SugarTheme/SugarTheme.php');
 75require_once('include/utils/LogicHook.php');
 76require_once('data/SugarBean.php');
 77require_once('include/entryPoint.php');
 78//check to see if the script files need to be rebuilt, add needed variables to request array
 79$_REQUEST['root_directory'] = getcwd();
 80$_REQUEST['js_rebuild_concat'] = 'rebuild';
 81if(isset($_REQUEST['goto']) && $_REQUEST['goto'] != 'SilentInstall') {
 82    require_once('jssource/minify.php');
 83}
 84
 85$timedate = TimeDate::getInstance();
 86// cn: set php.ini settings at entry points
 87setPhpIniSettings();
 88$locale = new Localization();
 89
 90if(get_magic_quotes_gpc() == 1) {
 91   $_REQUEST = array_map("stripslashes_checkstrings", $_REQUEST);
 92   $_POST = array_map("stripslashes_checkstrings", $_POST);
 93   $_GET = array_map("stripslashes_checkstrings", $_GET);
 94}
 95
 96
 97$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
 98$setup_sugar_version = $suitecrm_version;
 99$install_script = true;
100
101///////////////////////////////////////////////////////////////////////////////
102//// INSTALL RESOURCE SETUP
103$css = 'install/install.css';
104$icon = 'include/images/sugar_icon.ico';
105$sugar_md = 'include/images/sugar_md_open.png';
106$loginImage = 'include/images/sugarcrm_login.png';
107$common = 'install/installCommon.js';
108
109///////////////////////////////////////////////////////////////////////////////
110////	INSTALLER LANGUAGE
111function getSupportedInstallLanguages(){
112	$supportedLanguages = array(
113	'en_us'	=> 'English (US)',
114	);
115	if(file_exists('install/lang.config.php')){
116		include('install/lang.config.php');
117		if(!empty($config['languages'])){
118
119			foreach($config['languages'] as $k=>$v){
120				if(file_exists('install/language/' . $k . '.lang.php')){
121					$supportedLanguages[$k] = $v;
122				}
123			}
124		}
125	}
126	return $supportedLanguages;
127}
128$supportedLanguages = getSupportedInstallLanguages();
129
130// after install language is selected, use that pack
131$default_lang = 'en_us';
132if(!isset($_POST['language']) && (!isset($_SESSION['language']) && empty($_SESSION['language']))) {
133	if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
134		$lang = parseAcceptLanguage();
135		if(isset($supportedLanguages[$lang])) {
136			$_POST['language'] = $lang;
137		} else {
138			$_POST['language'] = $default_lang;
139	    }
140	}
141}
142
143if(isset($_POST['language'])) {
144	$_SESSION['language'] = str_replace('-','_',$_POST['language']);
145}
146
147$current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
148
149if(file_exists("install/language/{$current_language}.lang.php")) {
150	require_once("install/language/{$current_language}.lang.php");
151} else {
152	require_once("install/language/{$default_lang}.lang.php");
153}
154
155if($current_language != 'en_us') {
156	$my_mod_strings = $mod_strings;
157	include('install/language/en_us.lang.php');
158	$mod_strings = sugarLangArrayMerge($mod_strings, $my_mod_strings);
159}
160
161$app_list_strings = return_app_list_strings_language($current_language);
162////	END INSTALLER LANGUAGE
163///////////////////////////////////////////////////////////////////////////////
164
165//get the url for the helper link
166$help_url = get_help_button_url();
167
168//if this license print, then redirect and exit,
169if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'licensePrint')
170{
171    include('install/licensePrint.php');
172    exit ();
173}
174
175if(isset($_REQUEST['sugar_body_only']) && $_REQUEST['sugar_body_only'] == "1") {
176    //if this is a system check, then just run the check and return,
177    //this is an ajax call and there is no need for further processing
178
179    if(isset($_REQUEST['uploadLogoFrame']) && ($_REQUEST['uploadLogoFrame'])){
180        echo 'I\'m an uploader iframe!';
181        return;
182    }
183
184        // upload company logo
185    if(isset($_REQUEST['uploadLogo']) && ($_REQUEST['uploadLogo'])){
186        $filepath = '';
187        $errors = array();
188
189        switch($_FILES['company_logo']['error']) {
190
191            case UPLOAD_ERR_OK:
192                $allowedTypes = array(IMAGETYPE_PNG, IMAGETYPE_JPEG/*, IMAGETYPE_GIF */);
193                $detectedType = exif_imagetype($_FILES['company_logo']['tmp_name']);
194                if(!in_array($detectedType, $allowedTypes)) {
195                    $errors[] = $mod_strings['ERR_UPLOAD_FILETYPE'];
196                }
197                else {
198                    // uploaded image stored in the /custom path instead of put into the original theme directory..
199
200                    mkdir_recursive('custom/' . SugarThemeRegistry::current()->getDefaultImagePath(), true);
201                    $tmpvar = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));
202                    $destFile = 'custom/' . $tmpvar[0];
203                    if (!move_uploaded_file($_FILES['company_logo']['tmp_name'], $destFile)) {
204                        $errors[] = $mod_strings['ERR_LANG_UPLOAD_1'];
205                    }
206                    else {
207                        $filepath = $destFile;
208                    }
209                }
210                break;
211
212            case UPLOAD_ERR_INI_SIZE:
213                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_INI_SIZE'];
214                break;
215
216            case UPLOAD_ERR_FORM_SIZE:
217                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_FORM_SIZE'];
218                break;
219
220            case UPLOAD_ERR_PARTIAL:
221                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_PARTIAL'];
222                break;
223
224            case UPLOAD_ERR_NO_FILE:
225                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_NO_FILE'];
226                break;
227
228            case UPLOAD_ERR_NO_TMP_DIR:
229                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_NO_TMP_DIR'];
230                break;
231
232            case UPLOAD_ERR_CANT_WRITE:
233                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_CANT_WRITE'];
234                break;
235
236            case UPLOAD_ERR_EXTENSION:
237                $errors[] = $mod_strings['ERR_UPLOAD_FILE_UPLOAD_ERR_EXTENSION'];
238                break;
239            default:
240                $errors[] = $mod_strings['ERR_LANG_UPLOAD_UNKNOWN'];
241                break;
242        }
243
244
245        $result['filepath'] = $filepath;
246        $result['errors'] = $errors ? $errors : false;
247
248        // TODO--low: validate file size & image width/height and save, show status result to client js
249
250        echo "<script>window.top.window.{$_REQUEST['callback']}(" . json_encode($result) . ");</script>";
251        return;
252    }
253
254    if(isset($_REQUEST['storeConfig']) && ($_REQUEST['storeConfig'])){
255        // store configuration by form to session
256        if(!isset($_SESSION)) session_start();
257        $_SESSION = array_merge($_SESSION, $_POST);
258
259        // TODO--low: don't forget the custom type install settings! validate here..
260//        if(count($validation_errors = validate_dbConfig('a')) > 0) {
261//            $si_errors = true;
262//        }
263//        else if(count($validation_errors = validate_siteConfig('a')) > 0) {
264//            $si_errors = true;
265//        }
266//        else if(count($validation_errors = validate_siteConfig('b')) > 0) {
267//            $si_errors = true;
268//        }
269
270        if(!empty($sugar_config['dbconfig'])) {
271            try {
272                $db = DBManagerFactory::getInstance();
273                $db->disconnect();
274            } catch (\Exception $e) {
275                $validation_errors[] = $mod_strings['LBL_DB_CONN_ERR'] . ': ' . $e->getMessage();
276            }
277        }
278
279        $errors = '';
280        if( isset($validation_errors) && is_array($validation_errors)){
281            if( count($validation_errors) > 0 ){
282               // $errors  = '<div id="errorMsgs">';
283                $errors .= '<p>'.$mod_strings['LBL_SITECFG_FIX_ERRORS'].'</p><ul>';
284                foreach( $validation_errors as $error ){
285                    $errors .= '<li class="error">' . $error . '</li>';
286                }
287                $errors .= '</ul>'; //</div>';
288            }
289        }
290
291        echo $errors;
292        return;
293    }
294
295    if(isset($_REQUEST['checkInstallSystem']) && ($_REQUEST['checkInstallSystem'])){
296        require_once('install/installSystemCheck.php');
297        echo runCheck($install_script, $mod_strings);
298        return;
299    }
300
301    //if this is a DB Settings check, then just run the check and return,
302    //this is an ajax call and there is no need for further processing
303    if(isset($_REQUEST['checkDBSettings']) && ($_REQUEST['checkDBSettings'])){
304        require_once('install/checkDBSettings.php');
305        echo checkDBSettings();
306        return;
307    }
308}
309
310//maintaining the install_type if earlier set to custom
311if(isset($_REQUEST['install_type']) && $_REQUEST['install_type'] == 'custom'){
312	$_SESSION['install_type'] = $_REQUEST['install_type'];
313}
314
315//set the default settings into session
316foreach($installer_defaults as $key =>$val){
317    if(!isset($_SESSION[$key])){
318        $_SESSION[$key] = $val;
319    }
320}
321
322// always perform
323clean_special_arguments();
324print_debug_comment();
325$next_clicked = false;
326$next_step = 0;
327
328// use a simple array to map out the steps of the installer page flow
329$workflow = array(  'welcome.php',
330                    'ready.php',
331
332                    // TODO-g: remove these files..
333                    //'license.php',
334                    //'installType.php',
335);
336$workflow[] = 'installConfig.php';
337//$workflow[] =  'systemOptions.php';
338//$workflow[] = 'dbConfig_a.php';
339//$workflow[] = 'dbConfig_b.php';
340
341//define web root, which will be used as default for site_url
342if($_SERVER['SERVER_PORT']=='80'){
343    $web_root = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
344}else{
345    $web_root = $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF'];
346}
347$web_root = str_replace("/install.php", "", $web_root);
348$web_root = "http://$web_root";
349
350if (!isset($_SESSION['oc_install']) || $_SESSION['oc_install'] == false) {
351    //$workflow[] = 'siteConfig_a.php';
352    if (isset($_SESSION['install_type']) && !empty($_SESSION['install_type']) &&
353         $_SESSION['install_type'] == 'custom') {
354            $workflow[] = 'siteConfig_b.php';
355    }
356} else {
357    if (is_readable('config.php')) {
358        require_once ('config.php');
359    }
360}
361
362if(empty($sugar_config['cache_dir']) && !empty($_SESSION['cache_dir'])) {
363    $sugar_config['cache_dir'] = $_SESSION['cache_dir'];
364}
365
366// set the form's php var to the loaded config's var else default to sane settings
367if(!isset($_SESSION['setup_site_url'])  || empty($_SESSION['setup_site_url'])) {
368    if(isset($sugar_config['site_url']) && !empty($sugar_config['site_url'])) {
369        $_SESSION['setup_site_url']= $sugar_config['site_url'];
370    } else {
371        $_SESSION['setup_site_url']= $web_root;
372    }
373}
374
375if (!isset($_SESSION['setup_system_name']) || empty($_SESSION['setup_system_name'])) {
376    $_SESSION['setup_system_name'] = 'SugarCRM';
377}
378if (!isset($_SESSION['setup_site_session_path']) || empty($_SESSION['setup_site_session_path'])) {
379    $_SESSION['setup_site_session_path'] = (isset($sugar_config['session_dir'])) ? $sugar_config['session_dir'] : '';
380}
381if (!isset($_SESSION['setup_site_log_dir']) || empty($_SESSION['setup_site_log_dir'])) {
382    $_SESSION['setup_site_log_dir'] = (isset($sugar_config['log_dir'])) ? $sugar_config['log_dir'] : '.';
383}
384if (!isset($_SESSION['setup_site_guid']) || empty($_SESSION['setup_site_guid'])) {
385    $_SESSION['setup_site_guid'] = (isset($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : '';
386}
387if (!isset($_SESSION['cache_dir']) || empty($_SESSION['cache_dir'])) {
388    $_SESSION['cache_dir'] = isset($sugar_config['cache_dir']) ? $sugar_config['cache_dir'] : 'cache/';
389}
390
391  //$workflow[] = 'confirmSettings.php';
392$workflow[] = 'performSetup.php';
393
394  if(!isset($_SESSION['oc_install']) ||  $_SESSION['oc_install'] == false){
395    if(isset($_SESSION['install_type'])  && !empty($_SESSION['install_type'])  && $_SESSION['install_type']=='custom'){
396        //$workflow[] = 'download_patches.php';
397        $workflow[] = 'download_modules.php';
398    }
399  }
400
401    //$workflow[] = 'register.php';
402    $workflow[] = 'complete_install.php';
403
404
405// increment/decrement the workflow pointer
406if(!empty($_REQUEST['goto'])) {
407    switch($_REQUEST['goto']) {
408        case $mod_strings['LBL_CHECKSYS_RECHECK']:
409            $next_step = $_REQUEST['current_step'];
410            break;
411        case $mod_strings['LBL_BACK']:
412            $next_step = $_REQUEST['current_step'] - 1;
413            break;
414        case 'resend':
415        case $mod_strings['LBL_NEXT']:
416        case $mod_strings['LBL_START']:
417            $next_step = $_REQUEST['current_step'] + 1;
418            $next_clicked = true;
419            break;
420        case 'SilentInstall':
421            $next_step = 9999;
422            break;
423		case 'oc_convert':
424            $next_step = 9191;
425            break;
426    }
427}
428// Add check here to see if a silent install config file exists; if so then launch silent installer
429elseif ( is_file('config_si.php') && empty($sugar_config['installer_locked'])) {
430
431$langHeader = get_language_header();
432
433    echo <<<EOHTML
434<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
435<html {$langHeader}>
436<head>
437   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
438   <meta http-equiv="Content-Style-Type" content="text/css">
439   <meta http-equiv="Refresh" content="1; url=install.php?goto=SilentInstall&cli=true">
440   <title>{$mod_strings['LBL_WIZARD_TITLE']} {$mod_strings['LBL_TITLE_WELCOME']} {$setup_sugar_version} {$mod_strings['LBL_WELCOME_SETUP_WIZARD']}</title>
441   <link REL="SHORTCUT ICON" HREF="{$icon}">
442   <link rel="stylesheet" href="{$css}" type="text/css">
443</head>
444<body>
445    <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
446    <tr>
447        <td colspan="2" id="help"><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a></td></tr>
448    <tr>
449      <th width="500">
450		<p>
451		<img src="{$sugar_md}" alt="SugarCRM" border="0">
452		</p>
453		{$mod_strings['LBL_TITLE_WELCOME']} {$setup_sugar_version} {$mod_strings['LBL_WELCOME_SETUP_WIZARD']}</th>
454
455      <th width="200" height="30" style="text-align: right;"><a href="http://www.sugarcrm.com" target="_blank"><IMG src="{$loginImage}" alt="SugarCRM" border="0"></a>
456      </th>
457    </tr>
458    <tr>
459      <td colspan="2"  id="ready_image"><IMG src="include/images/install_themes.jpg" width="698" height="247" alt="Sugar Themes" border="0"></td>
460    </tr>
461
462    <tr>
463      <td colspan="2" id="ready">{$mod_strings['LBL_LAUNCHING_SILENT_INSTALL']} </td>
464    </tr>
465    </table>
466</body>
467</html>
468EOHTML;
469    die();
470}
471
472
473
474    $exclude_files = array('complete_install.php','register.php','download_modules.php');
475
476if(isset($next_step) && isset($workflow[$next_step]) && !in_array($workflow[$next_step],$exclude_files) && isset($sugar_config['installer_locked']) && $sugar_config['installer_locked'] == true) {
477    $the_file = 'installDisabled.php';
478	$disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION'];
479	$disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2'];
480	$disabled_text =<<<EOQ
481		<p>{$mod_strings['LBL_DISABLED_DESCRIPTION']}</p>
482		<pre>
483			'installer_locked' => false,
484		</pre>
485		<p>{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}</p>
486
487		<p>{$mod_strings['LBL_DISABLED_HELP_1']} <a href="{$mod_strings['LBL_DISABLED_HELP_LNK']}" target="_blank">{$mod_strings['LBL_DISABLED_HELP_2']}</a>.</p>
488EOQ;
489}
490else{
491$validation_errors = array();
492// process the data posted
493if($next_clicked) {
494	// store the submitted data because the 'Next' button was clicked
495    switch($workflow[trim($_REQUEST['current_step'])]) {
496        case 'welcome.php':
497        	$_SESSION['language'] = $_REQUEST['language'];
498   			$_SESSION['setup_site_admin_user_name'] = 'admin';
499//        break;
500//      case 'license.php':
501                $_SESSION['setup_license_accept']   = get_boolean_from_request('setup_license_accept');
502                $_SESSION['license_submitted']      = true;
503
504
505           // eventually default all vars here, with overrides from config.php
506            if(is_readable('config.php')) {
507            	global $sugar_config;
508                include_once('config.php');
509            }
510
511            $default_db_type = 'mysql';
512
513            if(!isset($_SESSION['setup_db_type'])) {
514                $_SESSION['setup_db_type'] = empty($sugar_config['dbconfig']['db_type']) ? $default_db_type : $sugar_config['dbconfig']['db_type'];
515            }
516
517            break;
518        //TODO--low: add this functionality to installConfig.php
519        case 'installType.php':
520            $_SESSION['install_type']   = $_REQUEST['install_type'];
521            if(isset($_REQUEST['setup_license_key']) && !empty($_REQUEST['setup_license_key'])){
522                $_SESSION['setup_license_key']  = $_REQUEST['setup_license_key'];
523            }
524            $_SESSION['licenseKey_submitted']      = true;
525
526
527
528            break;
529
530        case 'installConfig.php':
531
532        //case 'systemOptions.php':
533            if(isset($_REQUEST['setup_db_type'])) {
534              $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
535            }
536            $validation_errors = validate_systemOptions();
537            if(count($validation_errors) > 0) {
538                $next_step--;
539            }
540            //break;
541
542        //case 'dbConfig_a.php':
543            //validation is now done through ajax call to checkDBSettings.php
544            if(isset($_REQUEST['setup_db_drop_tables'])){
545                $_SESSION['setup_db_drop_tables'] = $_REQUEST['setup_db_drop_tables'];
546                if($_SESSION['setup_db_drop_tables']=== true || $_SESSION['setup_db_drop_tables'] == 'true'){
547                    $_SESSION['setup_db_create_database'] = false;
548                }
549            }
550            //break;
551
552        //case 'siteConfig_a.php':
553            if(isset($_REQUEST['setup_site_url'])){$_SESSION['setup_site_url']          = $_REQUEST['setup_site_url'];}
554            if(isset($_REQUEST['setup_system_name'])){$_SESSION['setup_system_name']    = $_REQUEST['setup_system_name'];}
555            if(isset($_REQUEST['setup_db_collation'])) {
556                $_SESSION['setup_db_options']['collation'] = $_REQUEST['setup_db_collation'];
557            }
558            $_SESSION['setup_site_admin_user_name']             = $_REQUEST['setup_site_admin_user_name'];
559            $_SESSION['setup_site_admin_password']              = $_REQUEST['setup_site_admin_password'];
560            $_SESSION['setup_site_admin_password_retype']       = $_REQUEST['setup_site_admin_password_retype'];
561            $_SESSION['siteConfig_submitted']               = true;
562
563            $validation_errors = array();
564            $validation_errors = validate_siteConfig('a');
565            if(count($validation_errors) > 0 || $_REQUEST['goto'] == 'resend') {
566                $next_step--;
567            }
568            //break;
569            // add old custom install settings to new install form
570        //case 'siteConfig_b.php':
571            $_SESSION['setup_site_sugarbeet_automatic_checks'] = get_boolean_from_request('setup_site_sugarbeet_automatic_checks');
572
573            $_SESSION['setup_site_custom_session_path']     = get_boolean_from_request('setup_site_custom_session_path');
574            if($_SESSION['setup_site_custom_session_path']){
575                $_SESSION['setup_site_session_path']            = $_REQUEST['setup_site_session_path'];
576            }else{
577                $_SESSION['setup_site_session_path'] = '';
578            }
579
580            $_SESSION['setup_site_custom_log_dir']          = get_boolean_from_request('setup_site_custom_log_dir');
581            if($_SESSION['setup_site_custom_log_dir']){
582                $_SESSION['setup_site_log_dir']                 = $_REQUEST['setup_site_log_dir'];
583            }else{
584                $_SESSION['setup_site_log_dir'] = '.';
585            }
586
587            $_SESSION['setup_site_specify_guid']            = get_boolean_from_request('setup_site_specify_guid');
588            if($_SESSION['setup_site_specify_guid']){
589                $_SESSION['setup_site_guid']                    = $_REQUEST['setup_site_guid'];
590            }else{
591                $_SESSION['setup_site_guid'] = '';
592            }
593            $_SESSION['siteConfig_submitted']               = true;
594            if(isset($_REQUEST['setup_site_sugarbeet_anonymous_stats'])){
595                $_SESSION['setup_site_sugarbeet_anonymous_stats'] = get_boolean_from_request('setup_site_sugarbeet_anonymous_stats');
596            }else{
597                $_SESSION['setup_site_sugarbeet_anonymous_stats'] = 0;
598            }
599
600            $validation_errors = array();
601            $validation_errors = validate_siteConfig('b');
602            if(count($validation_errors) > 0) {
603                $next_step--;
604            }
605            break;
606}
607    }
608
609if($next_step == 9999) {
610    $the_file = 'SilentInstall';
611}else if($next_step == 9191) {
612	$_SESSION['oc_server_url']	= $_REQUEST['oc_server_url'];
613    $_SESSION['oc_username']    = $_REQUEST['oc_username'];
614    $_SESSION['oc_password']   	= $_REQUEST['oc_password'];
615    $the_file = 'oc_convert.php';
616}
617else{
618        $the_file = $workflow[$next_step];
619
620}
621
622switch($the_file) {
623    case 'welcome.php':
624    case 'license.php':
625			//
626			// Check to see if session variables are working properly
627			//
628			$_SESSION['test_session'] = 'sessions are available';
629        @session_write_close();
630			unset($_SESSION['test_session']);
631        @session_start();
632
633			if(!isset($_SESSION['test_session']))
634			{
635                $the_file = 'installDisabled.php';
636				// PHP.ini location -
637				$phpIniLocation = get_cfg_var("cfg_file_path");
638				$disabled_title = $mod_strings['LBL_SESSION_ERR_TITLE'];
639				$disabled_title_2 = $mod_strings['LBL_SESSION_ERR_TITLE'];
640				$disabled_text = $mod_strings['LBL_SESSION_ERR_DESCRIPTION']."<pre>{$phpIniLocation}</pre>";
641            break;
642			}
643        // check to see if installer has been disabled
644        if(is_readable('config.php') && (filesize('config.php') > 0)) {
645            include_once('config.php');
646
647            if(!isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == true) {
648                $the_file = 'installDisabled.php';
649				$disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION'];
650				$disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2'];
651				$disabled_text =<<<EOQ
652					<p>{$mod_strings['LBL_DISABLED_DESCRIPTION']}</p>
653					<pre>
654						'installer_locked' => false,
655					</pre>
656					<p>{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}</p>
657
658					<p>{$mod_strings['LBL_DISABLED_HELP_1']} <a href="{$mod_strings['LBL_DISABLED_HELP_LNK']}" target="_blank">{$mod_strings['LBL_DISABLED_HELP_2']}</a>.</p>
659EOQ;
660		             //if this is an offline client installation but the conversion did not succeed,
661		            //then try to convert again
662					if(isset($sugar_config['disc_client']) && $sugar_config['disc_client'] == true && isset($sugar_config['oc_converted']) && $sugar_config['oc_converted'] == false) {
663			          header('Location: index.php?entryPoint=oc_convert&first_time=true');
664						exit ();
665		            }
666            }
667        }
668        break;
669    case 'register.php':
670    case 'complete_install.php':
671        session_unset();
672        break;
673    case 'SilentInstall':
674        $si_errors = false;
675        pullSilentInstallVarsIntoSession();
676
677        /*
678         * Make sure we are using the correct unique_key. The logic
679         * to save a custom unique_key happens lower in the process.
680         * However because of the initial FTS check we are already
681         * relying on this value which will not get reinitialized
682         * when we actual need it during index creation because
683         * SilentInstaller runs in one single process.
684         */
685        if (!empty($_SESSION['setup_site_specify_guid']) && !empty($_SESSION['setup_site_guid'])) {
686            $sugar_config['unique_key'] = $_SESSION['setup_site_guid'];
687        } else {
688            $sugar_config['unique_key'] = md5(create_guid());
689        }
690
691        $validation_errors = validate_dbConfig('a');
692        if(count($validation_errors) > 0) {
693            $the_file = 'dbConfig_a.php';
694            $si_errors = true;
695        }
696        $validation_errors = validate_siteConfig('a');
697        if(count($validation_errors) > 0) {
698            $the_file = 'siteConfig_a.php';
699            $si_errors = true;
700        }
701        $validation_errors = validate_siteConfig('b');
702        if(count($validation_errors) > 0) {
703            $the_file = 'siteConfig_b.php';
704            $si_errors = true;
705        }
706
707        if(!$si_errors){
708            $the_file = 'performSetup.php';
709        }
710        require_once('jssource/minify.php');
711        //since this is a SilentInstall we still need to make sure that
712        //the appropriate files are writable
713        // config.php
714        make_writable('./config.php');
715
716        // custom dir
717        make_writable('./custom');
718
719        // modules dir
720        recursive_make_writable('./modules');
721
722        // cache dir
723        create_writable_dir(sugar_cached('custom_fields'));
724        create_writable_dir(sugar_cached('dyn_lay'));
725        create_writable_dir(sugar_cached('images'));
726        create_writable_dir(sugar_cached('modules'));
727        create_writable_dir(sugar_cached('layout'));
728        create_writable_dir(sugar_cached('pdf'));
729        create_writable_dir(sugar_cached('upload/import'));
730        create_writable_dir(sugar_cached('xml'));
731        create_writable_dir(sugar_cached('include/javascript'));
732        recursive_make_writable(sugar_cached('modules'));
733
734        // public dir
735        recursive_make_writable('./public');
736
737        // check whether we're getting this request from a command line tool
738        // we want to output brief messages if we're outputting to a command line tool
739        $cli_mode = false;
740        if(isset($_REQUEST['cli']) && ($_REQUEST['cli'] == 'true')) {
741            $_SESSION['cli'] = true;
742            // if we have errors, just shoot them back now
743            if(count($validation_errors) > 0) {
744                foreach($validation_errors as $error) {
745                    print($mod_strings['ERR_ERROR_GENERAL']."\n");
746                    print("    " . $error . "\n");
747                    print("Exit 1\n");
748                    exit(1);
749                }
750            }
751        }
752        break;
753	}
754}
755
756
757$the_file = clean_string($the_file, 'FILE');
758
759installerHook('pre_installFileRequire', array('the_file' => $the_file));
760
761// change to require to get a good file load error message if the file is not available.
762
763require('install/' . $the_file);
764
765installerHook('post_installFileRequire', array('the_file' => $the_file));
766
767?>