[ Index ]
 

Code source de SugarCRM 5.0.0beta1

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> install.php (source)

   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 - 2007 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.

  10   * 

  11   * This program is distributed in the hope that it will be useful, but WITHOUT

  12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS

  13   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more

  14   * details.

  15   * 

  16   * You should have received a copy of the GNU General Public License along with

  17   * this program; if not, see http://www.gnu.org/licenses or write to the Free

  18   * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA

  19   * 02110-1301 USA.

  20   * 

  21   * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,

  22   * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.

  23   * 

  24   * The interactive user interfaces in modified source and object code versions

  25   * of this program must display Appropriate Legal Notices, as required under

  26   * Section 5 of the GNU General Public License version 3.

  27   * 

  28   * In accordance with Section 7(b) of the GNU General Public License version 3,

  29   * these Appropriate Legal Notices must retain the display of the "Powered by

  30   * SugarCRM" logo. If the display of the logo is not reasonably feasible for

  31   * technical reasons, the Appropriate Legal Notices must display the words

  32   * "Powered by SugarCRM".

  33   ********************************************************************************/
  34  session_start();
  35  //session_destroy();

  36  $GLOBALS['installing'] = true;
  37  require_once ('log4php/LoggerManager.php');
  38  require_once ('sugar_version.php');
  39  require_once ('include/utils.php');
  40  require_once ('install/install_utils.php');
  41  require_once ('install/install_defaults.php');
  42  require_once ('include/TimeDate.php');
  43  require_once ('include/Localization/Localization.php');
  44  
  45  
  46  //check to see if the script files need to be rebuilt, add needed variables to request array

  47      $_REQUEST['root_directory'] = getcwd();
  48      $_REQUEST['js_rebuild_concat'] = 'rebuild';
  49      require_once ('jssource/minify.php');
  50  
  51  $timedate = new TimeDate();
  52  // cn: set php.ini settings at entry points

  53  setPhpIniSettings();
  54  $locale = new Localization();
  55  
  56  if(get_magic_quotes_gpc() == 1) {
  57     $_REQUEST = array_map("stripslashes_checkstrings", $_REQUEST);
  58     $_POST = array_map("stripslashes_checkstrings", $_POST);
  59     $_GET = array_map("stripslashes_checkstrings", $_GET);
  60  }
  61  
  62  
  63  $GLOBALS['log'] = LoggerManager::getLogger('SugarCRM');
  64  $setup_sugar_version = $sugar_version;
  65  $install_script = true;
  66  
  67  ///////////////////////////////////////////////////////////////////////////////

  68  ////    INSTALLER LANGUAGE

  69  
  70  $supportedLanguages = array(
  71      'en_us'    => 'English (US)',
  72      'ja'    => 'Japanese - 日本語',
  73      'fr_fr'    => 'French - Français',
  74      'ge_ge'    => 'German - Deutch',
  75      'pt_br'    => 'Portuguese (Brazil)',
  76      'es_es'    => 'Spanish (Spain) - Español',
  77  );
  78  
  79  // after install language is selected, use that pack

  80  $default_lang = 'en_us';
  81  if(!isset($_POST['language']) && (!isset($_SESSION['language']) && empty($_SESSION['language']))) {
  82      if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
  83          $lang = parseAcceptLanguage();
  84          if(isset($supportedLanguages[$lang])) {
  85              $_POST['language'] = $lang;
  86          } else {
  87              $_POST['language'] = $default_lang;
  88          }
  89      }
  90  }
  91  
  92  if(isset($_POST['language'])) {
  93      $_SESSION['language'] = strtolower(str_replace('-','_',$_POST['language']));
  94  }
  95  
  96  $current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
  97  
  98  if(file_exists("install/language/{$current_language}.lang.php")) {
  99      require_once("install/language/{$current_language}.lang.php");
 100  } else {
 101      require_once("install/language/{$default_lang}.lang.php");
 102  }
 103  
 104  if($current_language != 'en_us') {
 105      $my_mod_strings = $mod_strings;
 106      include ('install/language/en_us.lang.php');
 107      $mod_strings = sugarArrayMerge($mod_strings, $my_mod_strings);
 108  }
 109  ////    END INSTALLER LANGUAGE

 110  ///////////////////////////////////////////////////////////////////////////////

 111  
 112  //get the url for the helper link

 113  $help_url = get_help_button_url();
 114  
 115  
 116  
 117  //if this license print, then redirect and exit, 

 118  if(isset($_REQUEST['page']) && $_REQUEST['page'] == 'licensePrint')
 119  {
 120      include ('install/licensePrint.php');
 121      exit ();
 122  }
 123  
 124  //if this is a system check, then just run the check and return, 

 125  //this is an ajax call and there is no need for further processing

 126  if(isset($_REQUEST['checkInstallSystem']) && ($_REQUEST['checkInstallSystem'])){
 127      require_once ('install/installSystemCheck.php');
 128      echo runCheck($install_script, $mod_strings);
 129      return;
 130  }
 131  
 132  //if this is a DB Settings check, then just run the check and return, 

 133  //this is an ajax call and there is no need for further processing

 134  if(isset($_REQUEST['checkDBSettings']) && ($_REQUEST['checkDBSettings'])){
 135      require_once ('install/checkDBSettings.php');
 136      echo checkDBSettings();
 137      return;
 138  }
 139  
 140  //set the default settings into session

 141  foreach($installer_defaults as $key =>$val){
 142      if(!isset($_SESSION[$key])){
 143          $_SESSION[$key] = $val;   
 144      }    
 145  }
 146  
 147  // always perform

 148  clean_special_arguments();
 149  print_debug_comment();
 150  $next_clicked = false;
 151  $next_step = 0;
 152  
 153  // use a simple array to map out the steps of the installer page flow

 154  $workflow = array(
 155                      'license.php',
 156                      'installType.php',
 157  );
 158  
 159  
 160  
 161  
 162  
 163  $workflow[] =  'systemOptions.php';
 164  $workflow[] = 'dbConfig_a.php';
 165  //$workflow[] = 'dbConfig_b.php';

 166  
 167  //define web root, which will be used as default for site_url

 168  $web_root = $_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'];
 169  $web_root = str_replace("/install.php", "", $web_root);
 170  $web_root = "http://$web_root";
 171  
 172   if(!isset($_SESSION['oc_install']) ||  $_SESSION['oc_install'] == false) {
 173      $workflow[] = 'siteConfig_a.php';
 174      if(isset($_SESSION['install_type'])  && !empty($_SESSION['install_type'])  && $_SESSION['install_type']=='custom'){
 175          $workflow[] = 'siteConfig_b.php';
 176      }
 177   } else {
 178  
 179      if(is_readable('config.php')) {
 180          require_once ('config.php');
 181      }
 182   }
 183     // set the form's php var to the loaded config's var else default to sane settings

 184      if(!isset($_SESSION['setup_site_url'])  || empty($_SESSION['setup_site_url'])){
 185          if(isset($sugar_config['site_url']) && !empty($sugar_config['site_url'])){
 186              $_SESSION['setup_site_url']= $sugar_config['site_url'];     
 187          }else{
 188           $_SESSION['setup_site_url']= $web_root;
 189          }
 190      }
 191      if(!isset($_SESSION['setup_system_name']) || empty($_SESSION['setup_system_name'])){$_SESSION['setup_system_name'] = 'SugarCRM';}    
 192      $_SESSION['setup_site_session_path']                = (isset($sugar_config['session_dir']))   ? $sugar_config['session_dir']  :  '';
 193      $_SESSION['setup_site_log_dir']                     = (isset($sugar_config['log_dir']))       ? $sugar_config['log_dir']      : '.';
 194      $_SESSION['setup_site_guid']                        = (isset($sugar_config['unique_key']))    ? $sugar_config['unique_key']   :  '';
 195  
 196   
 197   
 198  
 199  
 200  
 201  
 202  
 203  
 204  
 205  
 206  
 207  
 208  
 209  
 210  
 211  
 212    $workflow[] = 'localization.php';
 213    $workflow[] = 'confirmSettings.php';
 214    $workflow[] = 'performSetup.php';
 215  
 216    if(!isset($_SESSION['oc_install']) ||  $_SESSION['oc_install'] == false){
 217      if(isset($_SESSION['install_type'])  && !empty($_SESSION['install_type'])  && $_SESSION['install_type']=='custom'){
 218          $workflow[] = 'download_patches.php';
 219          $workflow[] = 'download_modules.php';
 220      }
 221    }
 222  
 223      $workflow[] = 'register.php';
 224  
 225    
 226  // increment/decrement the workflow pointer

 227  if(!empty($_REQUEST['goto'])) {
 228      switch($_REQUEST['goto']) {
 229          case $mod_strings['LBL_CHECKSYS_RECHECK']:
 230              $next_step = $_REQUEST['current_step'];
 231              break;
 232          case $mod_strings['LBL_BACK']:
 233              $next_step = $_REQUEST['current_step'] - 1;
 234              break;
 235          case $mod_strings['LBL_NEXT']:
 236          case $mod_strings['LBL_START']:
 237              $next_step = $_REQUEST['current_step'] + 1;
 238              $next_clicked = true;
 239              break;
 240          case 'SilentInstall':
 241              $next_step = 9999;
 242              break;
 243          case 'oc_convert':
 244              $next_step = 9191;
 245              break;
 246      }
 247  }
 248  
 249  $validation_errors = array();
 250  // process the data posted

 251  if($next_clicked) {
 252      // store the submitted data because the 'Next' button was clicked

 253      switch($workflow[trim($_REQUEST['current_step'])]) {
 254        case 'license.php':
 255                  $_SESSION['setup_license_accept']   = get_boolean_from_request('setup_license_accept');
 256                  $_SESSION['license_submitted']      = true;
 257                  $_SESSION['language']               = $_REQUEST['language'];
 258              
 259             // eventually default all vars here, with overrides from config.php

 260              if(is_readable('config.php')) {
 261                  global $sugar_config;
 262                  include_once ('config.php');
 263              }
 264  
 265              $default_db_type = 'mysql';
 266  
 267  
 268  
 269  
 270  
 271  
 272  
 273              if(!isset($_SESSION['setup_db_type'])) {
 274                  $_SESSION['setup_db_type'] = empty($sugar_config['dbconfig']['db_type']) ? $default_db_type : $sugar_config['dbconfig']['db_type'];
 275              }
 276              
 277              break;
 278          case 'installType.php':
 279              $_SESSION['install_type']   = $_REQUEST['install_type'];
 280              if(isset($_REQUEST['setup_license_key']) && !empty($_REQUEST['setup_license_key'])){
 281                  $_SESSION['setup_license_key']  = $_REQUEST['setup_license_key'];
 282              }
 283              $_SESSION['licenseKey_submitted']      = true;
 284  
 285  
 286  
 287  
 288  
 289  
 290  
 291  
 292  
 293  
 294  
 295              
 296              break;
 297  
 298          case 'systemOptions.php':
 299              $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
 300              $validation_errors = validate_systemOptions();
 301              if(count($validation_errors) > 0) {
 302                  $next_step--;
 303              }
 304              break;
 305  
 306          case 'dbConfig_a.php':
 307              //validation is now done through ajax call to checkDBSettings.php

 308              if(isset($_REQUEST['setup_db_drop_tables'])){
 309                  $_SESSION['setup_db_drop_tables'] = $_REQUEST['setup_db_drop_tables'];
 310                  if($_SESSION['setup_db_drop_tables']=== true || $_SESSION['setup_db_drop_tables'] == 'true'){
 311                      $_SESSION['setup_db_create_database'] = false;
 312                  }
 313              }
 314              break;
 315  
 316          case 'siteConfig_a.php':
 317              if(isset($_REQUEST['setup_site_url'])){$_SESSION['setup_site_url']          = $_REQUEST['setup_site_url'];}
 318              if(isset($_REQUEST['setup_system_name'])){$_SESSION['setup_system_name']    = $_REQUEST['setup_system_name'];}
 319              $_SESSION['setup_site_admin_password']              = $_REQUEST['setup_site_admin_password'];
 320              $_SESSION['setup_site_admin_password_retype']       = $_REQUEST['setup_site_admin_password_retype'];
 321              $_SESSION['siteConfig_submitted']               = true;
 322  
 323              $validation_errors = array();
 324              $validation_errors = validate_siteConfig('a');
 325              if(count($validation_errors) > 0) {
 326                  $next_step--;
 327              }
 328              break;
 329          case 'siteConfig_b.php':
 330              $_SESSION['setup_site_sugarbeet_automatic_checks'] = get_boolean_from_request('setup_site_sugarbeet_automatic_checks');
 331              $_SESSION['setup_site_custom_session_path']     = get_boolean_from_request('setup_site_custom_session_path');
 332              $_SESSION['setup_site_session_path']            = $_REQUEST['setup_site_session_path'];
 333              $_SESSION['setup_site_custom_log_dir']          = get_boolean_from_request('setup_site_custom_log_dir');
 334              $_SESSION['setup_site_log_dir']                 = $_REQUEST['setup_site_log_dir'];
 335              $_SESSION['setup_site_specify_guid']            = get_boolean_from_request('setup_site_specify_guid');
 336              $_SESSION['setup_site_guid']                    = $_REQUEST['setup_site_guid'];
 337              $_SESSION['siteConfig_submitted']               = true;
 338              if(isset($_REQUEST['setup_site_sugarbeet_anonymous_stats'])){
 339                  $_SESSION['setup_site_sugarbeet_anonymous_stats'] = get_boolean_from_request('setup_site_sugarbeet_anonymous_stats');
 340              }
 341  
 342              $validation_errors = array();  
 343              $validation_errors = validate_siteConfig('b');
 344              if(count($validation_errors) > 0) {
 345                  $next_step--;
 346              }
 347              break;                        
 348  
 349  
 350  
 351  
 352  
 353  
 354  
 355  
 356  
 357  
 358  
 359  
 360  
 361  
 362  
 363  
 364  
 365  
 366  
 367  
 368  
 369  
 370  
 371  
 372  
 373  
 374  
 375  
 376  
 377          case 'localization.php':
 378              $_SESSION['default_date_format'] = $_REQUEST['default_date_format'];
 379              $_SESSION['default_time_format'] = $_REQUEST['default_time_format'];
 380              if(isset($_REQUEST['default_language'])){$_SESSION['default_language'] = $_REQUEST['default_language'];}
 381              if(isset($_REQUEST['default_locale_name_format'])){$_SESSION['default_locale_name_format'] = $_REQUEST['default_locale_name_format'];}
 382              if(isset($_REQUEST['default_email_charset'])){$_SESSION['default_email_charset'] = $_REQUEST['default_email_charset'];}
 383              if(isset($_REQUEST['default_export_charset'])){$_SESSION['default_export_charset'] = $_REQUEST['default_export_charset'];}
 384              if(isset($_REQUEST['export_delimiter'])){$_SESSION['export_delimiter'] = $_REQUEST['export_delimiter'];}
 385              $_SESSION['default_currency_name'] = $_REQUEST['default_currency_name'];
 386              $_SESSION['default_currency_symbol'] = $_REQUEST['default_currency_symbol'];
 387              $_SESSION['default_currency_iso4217'] = $_REQUEST['default_currency_iso4217'];
 388              $_SESSION['default_currency_significant_digits'] = $_REQUEST['default_currency_significant_digits'];
 389              $_SESSION['default_number_grouping_seperator'] = $_REQUEST['default_number_grouping_seperator'];
 390              $_SESSION['default_decimal_seperator'] = $_REQUEST['default_decimal_seperator'];
 391              
 392              $validation_errors = validate_localization();
 393              $validation_errors = array();            
 394              if(count($validation_errors) > 0) {
 395                  $next_step--;
 396                  }
 397          break;
 398  }
 399      }
 400  
 401  if($next_step == 9999) {
 402      $the_file = 'SilentInstall';
 403  }else if($next_step == 9191) { 
 404      $_SESSION['oc_server_url']    = $_REQUEST['oc_server_url'];
 405      $_SESSION['oc_username']    = $_REQUEST['oc_username'];
 406      $_SESSION['oc_password']       = $_REQUEST['oc_password'];
 407      $the_file = 'oc_convert.php';
 408  }
 409  else{
 410          $the_file = $workflow[$next_step];
 411      
 412  }
 413  
 414  switch($the_file) {
 415      case 'license.php':
 416          // check to see if installer has been disabled

 417          if(is_readable('config.php') && (filesize('config.php') > 0)) {
 418              include_once ('config.php');
 419  
 420  
 421  
 422  
 423  
 424  
 425              //

 426              // Check to see if session variables are working properly

 427              //

 428              $_SESSION['test_session'] = 'sessions are available';
 429              session_write_close();
 430              unset($_SESSION['test_session']);
 431              session_start();
 432              
 433              if(!isset($_SESSION['test_session']))
 434              {
 435                  $the_file = 'installDisabled.php';
 436                  // PHP.ini location - 

 437                  $phpIniLocation = get_cfg_var("cfg_file_path");
 438                  $disabled_title = $mod_strings['LBL_SESSION_ERR_TITLE'];
 439                  $disabled_title_2 = $mod_strings['LBL_SESSION_ERR_TITLE'];
 440                  $disabled_text = $mod_strings['LBL_SESSION_ERR_DESCRIPTION']."<pre>{$phpIniLocation}</pre>";
 441              }
 442              elseif(!isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == true) {
 443                  $the_file = 'installDisabled.php';
 444                  $disabled_title = $mod_strings['LBL_DISABLED_DESCRIPTION'];
 445                  $disabled_title_2 = $mod_strings['LBL_DISABLED_TITLE_2'];
 446                  $disabled_text =<<<EOQ
 447                      <p>{$mod_strings['LBL_DISABLED_DESCRIPTION']}</p>
 448                      <pre>
 449                          'installer_locked' => false,
 450                      </pre>
 451                      <p>{$mod_strings['LBL_DISABLED_DESCRIPTION_2']}</p>
 452              
 453                      <p>{$mod_strings['LBL_DISABLED_HELP_1']} <a href="http://www.sugarcrm.com/forums/" target="_blank">{$mod_strings['LBL_DISABLED_HELP_2']}</a>.</p>
 454  EOQ;
 455                                  //if this is an offline client installation but the conversion did not succeed,

 456                  //then try to convert again

 457                  if(isset($sugar_config['disc_client']) && $sugar_config['disc_client'] == true && isset($sugar_config['oc_converted']) && $sugar_config['oc_converted'] == false) {
 458                       header('Location: oc_convert.php?first_time=true');
 459                      exit ();  
 460                  }
 461              }
 462          }
 463          break;
 464      case 'register.php':
 465          session_unset();
 466          break;
 467      case 'SilentInstall':
 468          $si_errors = false;
 469          pullSilentInstallVarsIntoSession();
 470          $validation_errors = validate_dbConfig('a');
 471          if(count($validation_errors) > 0) {
 472              $the_file = 'dbConfig_a.php';
 473              $si_errors = true;
 474          }
 475          $validation_errors = validate_siteConfig('a');
 476          if(count($validation_errors) > 0) {
 477              $the_file = 'siteConfig_a.php';
 478              $si_errors = true;
 479          }
 480          $validation_errors = validate_siteConfig('b');
 481          if(count($validation_errors) > 0) {
 482              $the_file = 'siteConfig_b.php';
 483              $si_errors = true;
 484          }        
 485  
 486          if(!$si_errors){
 487              $the_file = 'performSetup.php';
 488          }
 489          //since this is a SilentInstall we still need to make sure that 

 490          //the appropriate files are writable

 491          // config.php

 492          make_writable('./config.php');
 493          
 494          // custom dir

 495          make_writable('./custom');
 496  
 497          // modules dir

 498          recursive_make_writable('./modules');
 499          
 500          // data dir

 501          make_writable('./data');
 502          make_writable('./data/upload');
 503          
 504          // cache dir

 505          make_writable('./cache/custom_fields');
 506          make_writable('./cache/dyn_lay');
 507          make_writable('./cache/images');
 508          make_writable('./cache/import');
 509          make_writable('./cache/layout');
 510          make_writable('./cache/pdf');
 511          make_writable('./cache/upload');
 512          make_writable('./cache/xml');
 513  
 514          // check whether we're getting this request from a command line tool

 515          // we want to output brief messages if we're outputting to a command line tool

 516          $cli_mode = false;
 517          if(isset($_REQUEST['cli']) && ($_REQUEST['cli'] == 'true')) {
 518              $_SESSION['cli'] = true;
 519              // if we have errors, just shoot them back now

 520              if(count($validation_errors) > 0) {
 521                  foreach($validation_errors as $error) {
 522                      print($mod_strings['ERR_ERROR_GENERAL']."\n");
 523                      print("    " . $error . "\n");
 524                      print("Exit 1\n");
 525                      exit(1);
 526                  }
 527              }
 528          }
 529  
 530  
 531  
 532  
 533  
 534  
 535  
 536  
 537  
 538  
 539          break;
 540  }
 541  
 542  $the_file = clean_string($the_file, 'FILE');
 543  // change to require to get a good file load error message if the file is not available.

 544  require('install/' . $the_file);
 545  ?>


Généré le : Tue Sep 11 10:48:47 2007 par Balluche grâce à PHPXref 0.7