source: trunk/install.php

Last change on this file was 1, checked in by george, 15 years ago
  • Přidáno: Základní struktura složek.
  • Přidáno: SugarCRM 5.2.0a.
File size: 21.2 KB
Line 
1<?php
2 if(!defined('sugarEntry'))define('sugarEntry', true);
3/*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004 - 2009 SugarCRM Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 *
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301 USA.
23 *
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 *
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU General Public License version 3.
30 *
31 * In accordance with Section 7(b) of the GNU General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
37//session_destroy();
38if (version_compare(phpversion(),'5.1.0') < 0) {
39 $msg = 'Minimum PHP version required is 5.1.0. You are using PHP version '. phpversion();
40 die($msg);
41}
42session_start();
43$GLOBALS['installing'] = true;
44define('SUGARCRM_IS_INSTALLING', $GLOBALS['installing']);
45$GLOBALS['sql_queries'] = 0;
46require_once('include/SugarLogger/LoggerManager.php');
47require_once('sugar_version.php');
48require_once('include/utils.php');
49require_once('install/install_utils.php');
50require_once('install/install_defaults.php');
51require_once('include/TimeDate.php');
52require_once('include/Localization/Localization.php');
53
54//check to see if the script files need to be rebuilt, add needed variables to request array
55 $_REQUEST['root_directory'] = getcwd();
56 $_REQUEST['js_rebuild_concat'] = 'rebuild';
57 require_once('jssource/minify.php');
58
59$timedate = new TimeDate();
60// cn: set php.ini settings at entry points
61setPhpIniSettings();
62$locale = new Localization();
63
64if(get_magic_quotes_gpc() == 1) {
65 $_REQUEST = array_map("stripslashes_checkstrings", $_REQUEST);
66 $_POST = array_map("stripslashes_checkstrings", $_POST);
67 $_GET = array_map("stripslashes_checkstrings", $_GET);
68}
69
70
71$GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
72$setup_sugar_version = $sugar_version;
73$install_script = true;
74
75///////////////////////////////////////////////////////////////////////////////
76//// INSTALLER LANGUAGE
77
78$supportedLanguages = array(
79 'en_us' => 'English (US)',
80 'ja' => 'Japanese - 日本語',
81 'fr_fr' => 'French - Français',
82// 'ge_ge' => 'German - Deutch',
83// 'pt_br' => 'Portuguese (Brazil)',
84// 'es_es' => 'Spanish (Spain) - Español',
85);
86
87// after install language is selected, use that pack
88$default_lang = 'en_us';
89if(!isset($_POST['language']) && (!isset($_SESSION['language']) && empty($_SESSION['language']))) {
90 if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
91 $lang = parseAcceptLanguage();
92 if(isset($supportedLanguages[$lang])) {
93 $_POST['language'] = $lang;
94 } else {
95 $_POST['language'] = $default_lang;
96 }
97 }
98}
99
100if(isset($_POST['language'])) {
101 $_SESSION['language'] = strtolower(str_replace('-','_',$_POST['language']));
102}
103
104$current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
105
106if(file_exists("install/language/{$current_language}.lang.php")) {
107 require_once("install/language/{$current_language}.lang.php");
108} else {
109 require_once("install/language/{$default_lang}.lang.php");
110}
111
112if($current_language != 'en_us') {
113 $my_mod_strings = $mod_strings;
114 include('install/language/en_us.lang.php');
115 $mod_strings = sugarArrayMerge($mod_strings, $my_mod_strings);
116}
117//// END INSTALLER LANGUAGE
118///////////////////////////////////////////////////////////////////////////////
119
120//get the url for the helper link
121$help_url = get_help_button_url();
122
123
124
125//if this license print, then redirect and exit,
126if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'licensePrint')
127{
128 include('install/licensePrint.php');
129 exit ();
130}
131
132//check to see if mysqli is enabled
133if(function_exists('mysqli_connect')){
134 $_SESSION['mysql_type'] = 'mysqli';
135}
136
137//if this is a system check, then just run the check and return,
138//this is an ajax call and there is no need for further processing
139if(isset($_REQUEST['checkInstallSystem']) && ($_REQUEST['checkInstallSystem'])){
140 require_once('install/installSystemCheck.php');
141 echo runCheck($install_script, $mod_strings);
142 return;
143}
144
145//if this is a DB Settings check, then just run the check and return,
146//this is an ajax call and there is no need for further processing
147if(isset($_REQUEST['checkDBSettings']) && ($_REQUEST['checkDBSettings'])){
148 require_once('install/checkDBSettings.php');
149 echo checkDBSettings();
150 return;
151}
152
153//maintaining the install_type if earlier set to custom
154if(isset($_REQUEST['install_type']) && $_REQUEST['install_type'] == 'custom'){
155 $_SESSION['install_type'] = $_REQUEST['install_type'];
156}
157
158//set the default settings into session
159foreach($installer_defaults as $key =>$val){
160 if(!isset($_SESSION[$key])){
161 $_SESSION[$key] = $val;
162 }
163}
164
165// always perform
166clean_special_arguments();
167print_debug_comment();
168$next_clicked = false;
169$next_step = 0;
170
171// use a simple array to map out the steps of the installer page flow
172$workflow = array( 'welcome.php',
173 'license.php',
174 'installType.php',
175);
176
177
178
179
180
181$workflow[] = 'systemOptions.php';
182$workflow[] = 'dbConfig_a.php';
183//$workflow[] = 'dbConfig_b.php';
184
185//define web root, which will be used as default for site_url
186if($_SERVER['SERVER_PORT']=='80'){
187 $web_root = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
188}else{
189 $web_root = $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['PHP_SELF'];
190}
191$web_root = str_replace("/install.php", "", $web_root);
192$web_root = "http://$web_root";
193
194 if(!isset($_SESSION['oc_install']) || $_SESSION['oc_install'] == false) {
195 $workflow[] = 'siteConfig_a.php';
196 if(isset($_SESSION['install_type']) && !empty($_SESSION['install_type']) && $_SESSION['install_type']=='custom'){
197 $workflow[] = 'siteConfig_b.php';
198 }
199 } else {
200 if(is_readable('config.php')) {
201 require_once('config.php');
202
203
204
205
206
207
208
209
210
211
212
213
214 }
215 }
216
217 // set the form's php var to the loaded config's var else default to sane settings
218 if(!isset($_SESSION['setup_site_url']) || empty($_SESSION['setup_site_url'])){
219 if(isset($sugar_config['site_url']) && !empty($sugar_config['site_url'])){
220 $_SESSION['setup_site_url']= $sugar_config['site_url'];
221 }else{
222 $_SESSION['setup_site_url']= $web_root;
223 }
224 }
225 if(!isset($_SESSION['setup_system_name']) || empty($_SESSION['setup_system_name'])){$_SESSION['setup_system_name'] = 'SugarCRM';}
226 if(!isset($_SESSION['setup_site_session_path']) || empty($_SESSION['setup_site_session_path'])){$_SESSION['setup_site_session_path'] = (isset($sugar_config['session_dir'])) ? $sugar_config['session_dir'] : '';}
227 if(!isset($_SESSION['setup_site_log_dir']) || empty($_SESSION['setup_site_log_dir'])){$_SESSION['setup_site_log_dir'] = (isset($sugar_config['log_dir'])) ? $sugar_config['log_dir'] : '.';}
228 if(!isset($_SESSION['setup_site_guid']) || empty($_SESSION['setup_site_guid'])){$_SESSION['setup_site_guid'] = (isset($sugar_config['unique_key'])) ? $sugar_config['unique_key'] : '';}
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246 $workflow[] = 'localization.php';
247 $workflow[] = 'confirmSettings.php';
248 $workflow[] = 'performSetup.php';
249
250 if(!isset($_SESSION['oc_install']) || $_SESSION['oc_install'] == false){
251 if(isset($_SESSION['install_type']) && !empty($_SESSION['install_type']) && $_SESSION['install_type']=='custom'){
252 //$workflow[] = 'download_patches.php';
253 $workflow[] = 'download_modules.php';
254 }
255 }
256
257 $workflow[] = 'register.php';
258
259
260// increment/decrement the workflow pointer
261if(!empty($_REQUEST['goto'])) {
262 switch($_REQUEST['goto']) {
263 case $mod_strings['LBL_CHECKSYS_RECHECK']:
264 $next_step = $_REQUEST['current_step'];
265 break;
266 case $mod_strings['LBL_BACK']:
267 $next_step = $_REQUEST['current_step'] - 1;
268 break;
269 case $mod_strings['LBL_NEXT']:
270 case $mod_strings['LBL_START']:
271 $next_step = $_REQUEST['current_step'] + 1;
272 $next_clicked = true;
273 break;
274 case 'SilentInstall':
275 $next_step = 9999;
276 break;
277 case 'oc_convert':
278 $next_step = 9191;
279 break;
280 }
281}
282
283
284
285
286
287
288
289$exclude_files = array('register.php','download_modules.php');
290if(isset($next_step) && !in_array($workflow[$next_step],$exclude_files) && isset($sugar_config['installer_locked']) && $sugar_config['installer_locked'] == true) {
291 $the_file = 'installDisabled.php';
292 $disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION'];
293 $disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2'];
294 $disabled_text =<<<EOQ
295 <p>{$mod_strings['LBL_DISABLED_DESCRIPTION']}</p>
296 <pre>
297 'installer_locked' => false,
298 </pre>
299 <p>{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}</p>
300
301 <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>
302EOQ;
303}
304else{
305$validation_errors = array();
306// process the data posted
307if($next_clicked) {
308 // store the submitted data because the 'Next' button was clicked
309 switch($workflow[trim($_REQUEST['current_step'])]) {
310 case 'welcome.php':
311 break;
312 case 'license.php':
313 $_SESSION['setup_license_accept'] = get_boolean_from_request('setup_license_accept');
314 $_SESSION['license_submitted'] = true;
315 $_SESSION['language'] = $_REQUEST['language'];
316
317 // eventually default all vars here, with overrides from config.php
318 if(is_readable('config.php')) {
319 global $sugar_config;
320 include_once('config.php');
321 }
322
323 $default_db_type = 'mysql';
324
325
326
327
328
329
330
331 if(!isset($_SESSION['setup_db_type'])) {
332 $_SESSION['setup_db_type'] = empty($sugar_config['dbconfig']['db_type']) ? $default_db_type : $sugar_config['dbconfig']['db_type'];
333 }
334
335 break;
336 case 'installType.php':
337 $_SESSION['install_type'] = $_REQUEST['install_type'];
338 if(isset($_REQUEST['setup_license_key']) && !empty($_REQUEST['setup_license_key'])){
339 $_SESSION['setup_license_key'] = $_REQUEST['setup_license_key'];
340 }
341 $_SESSION['licenseKey_submitted'] = true;
342
343
344
345
346
347
348
349
350
351
352
353
354 break;
355
356 case 'systemOptions.php':
357 $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
358 $validation_errors = validate_systemOptions();
359 if(count($validation_errors) > 0) {
360 $next_step--;
361 }
362 break;
363
364 case 'dbConfig_a.php':
365 //validation is now done through ajax call to checkDBSettings.php
366 if(isset($_REQUEST['setup_db_drop_tables'])){
367 $_SESSION['setup_db_drop_tables'] = $_REQUEST['setup_db_drop_tables'];
368 if($_SESSION['setup_db_drop_tables']=== true || $_SESSION['setup_db_drop_tables'] == 'true'){
369 $_SESSION['setup_db_create_database'] = false;
370 }
371 }
372 break;
373
374 case 'siteConfig_a.php':
375 if(isset($_REQUEST['setup_site_url'])){$_SESSION['setup_site_url'] = $_REQUEST['setup_site_url'];}
376 if(isset($_REQUEST['setup_system_name'])){$_SESSION['setup_system_name'] = $_REQUEST['setup_system_name'];}
377 $_SESSION['setup_site_admin_password'] = $_REQUEST['setup_site_admin_password'];
378 $_SESSION['setup_site_admin_password_retype'] = $_REQUEST['setup_site_admin_password_retype'];
379 $_SESSION['siteConfig_submitted'] = true;
380
381 $validation_errors = array();
382 $validation_errors = validate_siteConfig('a');
383 if(count($validation_errors) > 0) {
384 $next_step--;
385 }
386 break;
387 case 'siteConfig_b.php':
388 $_SESSION['setup_site_sugarbeet_automatic_checks'] = get_boolean_from_request('setup_site_sugarbeet_automatic_checks');
389
390 $_SESSION['setup_site_custom_session_path'] = get_boolean_from_request('setup_site_custom_session_path');
391 if($_SESSION['setup_site_custom_session_path']){
392 $_SESSION['setup_site_session_path'] = $_REQUEST['setup_site_session_path'];
393 }else{
394 $_SESSION['setup_site_session_path'] = '';
395 }
396
397 $_SESSION['setup_site_custom_log_dir'] = get_boolean_from_request('setup_site_custom_log_dir');
398 if($_SESSION['setup_site_custom_log_dir']){
399 $_SESSION['setup_site_log_dir'] = $_REQUEST['setup_site_log_dir'];
400 }else{
401 $_SESSION['setup_site_log_dir'] = '.';
402 }
403
404 $_SESSION['setup_site_specify_guid'] = get_boolean_from_request('setup_site_specify_guid');
405 if($_SESSION['setup_site_specify_guid']){
406 $_SESSION['setup_site_guid'] = $_REQUEST['setup_site_guid'];
407 }else{
408 $_SESSION['setup_site_guid'] = '';
409 }
410 $_SESSION['siteConfig_submitted'] = true;
411 if(isset($_REQUEST['setup_site_sugarbeet_anonymous_stats'])){
412 $_SESSION['setup_site_sugarbeet_anonymous_stats'] = get_boolean_from_request('setup_site_sugarbeet_anonymous_stats');
413 }else{
414 $_SESSION['setup_site_sugarbeet_anonymous_stats'] = 0;
415 }
416
417 $validation_errors = array();
418 $validation_errors = validate_siteConfig('b');
419 if(count($validation_errors) > 0) {
420 $next_step--;
421 }
422 break;
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452 case 'localization.php':
453 $_SESSION['default_date_format'] = $_REQUEST['default_date_format'];
454 $_SESSION['default_time_format'] = $_REQUEST['default_time_format'];
455 if(isset($_REQUEST['default_language'])){$_SESSION['default_language'] = $_REQUEST['default_language'];}
456 if(isset($_REQUEST['default_locale_name_format'])){$_SESSION['default_locale_name_format'] = $_REQUEST['default_locale_name_format'];}
457 if(isset($_REQUEST['default_email_charset'])){$_SESSION['default_email_charset'] = $_REQUEST['default_email_charset'];}
458 if(isset($_REQUEST['default_export_charset'])){$_SESSION['default_export_charset'] = $_REQUEST['default_export_charset'];}
459 if(isset($_REQUEST['export_delimiter'])){$_SESSION['export_delimiter'] = $_REQUEST['export_delimiter'];}
460 $_SESSION['default_currency_name'] = $_REQUEST['default_currency_name'];
461 $_SESSION['default_currency_symbol'] = $_REQUEST['default_currency_symbol'];
462 $_SESSION['default_currency_iso4217'] = $_REQUEST['default_currency_iso4217'];
463 $_SESSION['default_currency_significant_digits'] = $_REQUEST['default_currency_significant_digits'];
464 $_SESSION['default_number_grouping_seperator'] = $_REQUEST['default_number_grouping_seperator'];
465 $_SESSION['default_decimal_seperator'] = $_REQUEST['default_decimal_seperator'];
466
467 $validation_errors = validate_localization();
468 $validation_errors = array();
469 if(count($validation_errors) > 0) {
470 $next_step--;
471 }
472 break;
473}
474 }
475
476if($next_step == 9999) {
477 $the_file = 'SilentInstall';
478}else if($next_step == 9191) {
479 $_SESSION['oc_server_url'] = $_REQUEST['oc_server_url'];
480 $_SESSION['oc_username'] = $_REQUEST['oc_username'];
481 $_SESSION['oc_password'] = $_REQUEST['oc_password'];
482 $the_file = 'oc_convert.php';
483}
484else{
485 $the_file = $workflow[$next_step];
486
487}
488
489switch($the_file) {
490 case 'welcome.php':
491 case 'license.php':
492 // check to see if installer has been disabled
493 if(is_readable('config.php') && (filesize('config.php') > 0)) {
494 include_once('config.php');
495
496 //
497 // Check to see if session variables are working properly
498 //
499 $_SESSION['test_session'] = 'sessions are available';
500 session_write_close();
501 unset($_SESSION['test_session']);
502 session_start();
503
504 if(!isset($_SESSION['test_session']))
505 {
506 $the_file = 'installDisabled.php';
507 // PHP.ini location -
508 $phpIniLocation = get_cfg_var("cfg_file_path");
509 $disabled_title = $mod_strings['LBL_SESSION_ERR_TITLE'];
510 $disabled_title_2 = $mod_strings['LBL_SESSION_ERR_TITLE'];
511 $disabled_text = $mod_strings['LBL_SESSION_ERR_DESCRIPTION']."<pre>{$phpIniLocation}</pre>";
512 }
513 elseif(!isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == true) {
514 $the_file = 'installDisabled.php';
515 $disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION'];
516 $disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2'];
517 $disabled_text =<<<EOQ
518 <p>{$mod_strings['LBL_DISABLED_DESCRIPTION']}</p>
519 <pre>
520 'installer_locked' => false,
521 </pre>
522 <p>{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}</p>
523
524 <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>
525EOQ;
526 //if this is an offline client installation but the conversion did not succeed,
527 //then try to convert again
528 if(isset($sugar_config['disc_client']) && $sugar_config['disc_client'] == true && isset($sugar_config['oc_converted']) && $sugar_config['oc_converted'] == false) {
529 header('Location: index.php?entryPoint=oc_convert&first_time=true');
530 exit ();
531 }
532 }
533 }
534 break;
535 case 'register.php':
536 session_unset();
537 break;
538 case 'SilentInstall':
539 $si_errors = false;
540 pullSilentInstallVarsIntoSession();
541 $validation_errors = validate_dbConfig('a');
542 if(count($validation_errors) > 0) {
543 $the_file = 'dbConfig_a.php';
544 $si_errors = true;
545 }
546 $validation_errors = validate_siteConfig('a');
547 if(count($validation_errors) > 0) {
548 $the_file = 'siteConfig_a.php';
549 $si_errors = true;
550 }
551 $validation_errors = validate_siteConfig('b');
552 if(count($validation_errors) > 0) {
553 $the_file = 'siteConfig_b.php';
554 $si_errors = true;
555 }
556
557 if(!$si_errors){
558 $the_file = 'performSetup.php';
559 }
560 //since this is a SilentInstall we still need to make sure that
561 //the appropriate files are writable
562 // config.php
563 make_writable('./config.php');
564
565 // custom dir
566 make_writable('./custom');
567
568 // modules dir
569 recursive_make_writable('./modules');
570
571 // data dir
572 make_writable('./data');
573 make_writable('./data/upload');
574
575 // cache dir
576 make_writable('./cache/custom_fields');
577 make_writable('./cache/dyn_lay');
578 make_writable('./cache/images');
579 make_writable('./cache/import');
580 make_writable('./cache/layout');
581 make_writable('./cache/pdf');
582 make_writable('./cache/upload');
583 make_writable('./cache/xml');
584
585 // check whether we're getting this request from a command line tool
586 // we want to output brief messages if we're outputting to a command line tool
587 $cli_mode = false;
588 if(isset($_REQUEST['cli']) && ($_REQUEST['cli'] == 'true')) {
589 $_SESSION['cli'] = true;
590 // if we have errors, just shoot them back now
591 if(count($validation_errors) > 0) {
592 foreach($validation_errors as $error) {
593 print($mod_strings['ERR_ERROR_GENERAL']."\n");
594 print(" " . $error . "\n");
595 print("Exit 1\n");
596 exit(1);
597 }
598 }
599 }
600
601
602
603
604
605
606
607
608
609
610 break;
611 }
612}
613
614$the_file = clean_string($the_file, 'FILE');
615// change to require to get a good file load error message if the file is not available.
616$css = 'install/install.css';
617$icon = 'include/images/sugar_icon.ico';
618$sugar_md = 'include/images/sugar_md.png';
619$loginImage = 'include/images/sugarcrm_login.png';
620$common = 'install/installCommon.js';
621require('install/' . $the_file);
622
623?>
Note: See TracBrowser for help on using the repository browser.