PageRenderTime 84ms CodeModel.GetById 44ms RepoModel.GetById 3ms app.codeStats 0ms

/install.php

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