iTx Technologies offre gratuitement
cet espace pour SugarCRM !

title

Body

[fermer]

/install/ -> installSystemCheck.php (source)

   1  <?php
   2  if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
   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  
  38  $_SESSION['setup_license_accept'] = true;
  39  
  40  function runCheck($install_script = false, $mod_strings){
  41  installLog("Begin System Check Process *************");
  42  
  43  if( !isset( $install_script ) || !$install_script ){
  44      installLog("Error:: ".$mod_strings['ERR_NO_DIRECT_SCRIPT']);
  45      die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
  46  }
  47  
  48  if(!defined('SUGARCRM_MIN_MEM')) {
  49      define('SUGARCRM_MIN_MEM', 40);
  50  }
  51  
  52  
  53  
  54  // for keeping track of whether to enable/disable the 'Next' button
  55  $error_found = false;
  56  $error_txt = '';
  57  //
  58  // Check to see if session variables are working properly
  59  //
  60  
  61  if (empty($_SESSION['test_session'])){
  62      $_SESSION['test_session'] = 'sessions are available';
  63      session_write_close();
  64      unset($_SESSION['test_session']);
  65      session_start();
  66  }
  67  if(!isset($_SESSION['test_session']))
  68  {
  69     installLog("ERROR:: ".$mod_strings['LBL_CHECKSYS_NO_SESSIONS']);
  70     die("<p><b><span class='error'>{$mod_strings['LBL_CHECKSYS_NO_SESSIONS']}</span></b></p>\n");
  71  }
  72  
  73  // check IIS and FastCGI
  74  $server_software = $_SERVER["SERVER_SOFTWARE"];
  75  if ((strpos($_SERVER["SERVER_SOFTWARE"],'Microsoft-IIS') !== false) 
  76      && php_sapi_name() == 'cgi-fcgi' 
  77      && ini_get('fastcgi.logging') != '0')
  78  {
  79      installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']);
  80      $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
  81      $error_found = true;
  82      $error_txt .= '
  83            <tr>
  84              <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
  85              <td ><span class="error">'.$iisVersion.'</span></td>
  86            </tr>';
  87  }
  88  
  89  if(strpos($server_software,'Microsoft-IIS') !== false)
  90  {
  91      $iis_version = '';
  92      if(preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out))
  93      $iis_version = $out[1][0];
  94  
  95      $check_iis_version_result = check_iis_version($iis_version);
  96      if($check_iis_version_result == -1) {
  97          installLog($mod_strings['ERR_CHECKSYS_IIS_INVALID_VER'].' '.$iis_version);
  98          $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_IIS_INVALID_VER']} {$iis_version}</span></b>";
  99          $error_found = true;
 100          $error_txt .= '
 101            <tr>
 102              <td><b>'.$mod_strings['LBL_CHECKSYS_IISVER'].'</b></td>
 103              <td ><span class="error">'.$iisVersion.'</span></td>
 104            </tr>';
 105      } else if(php_sapi_name() != 'cgi-fcgi')
 106      {
 107          installLog($mod_strings['ERR_CHECKSYS_FASTCGI'].' '.$iis_version);
 108          $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI']}</span></b>";
 109          $error_found = true;
 110          $error_txt .= '
 111            <tr>
 112              <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
 113              <td ><span class="error">'.$iisVersion.'</span></td>
 114            </tr>';
 115      } else if(ini_get('fastcgi.logging') != '0')
 116      {
 117          installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING'].' '.$iis_version);
 118          $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
 119          $error_found = true;
 120          $error_txt .= '
 121            <tr>
 122              <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
 123              <td ><span class="error">'.$iisVersion.'</span></td>
 124            </tr>';
 125      }
 126  }
 127          
 128  // PHP VERSION
 129  $php_version = constant('PHP_VERSION');
 130  $check_php_version_result = check_php_version($php_version);
 131  
 132  if($check_php_version_result == -1) {
 133          installLog($mod_strings['ERR_CHECKSYS_PHP_INVALID_VER'].'  '.$php_version);
 134          $phpVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
 135          $error_found = true;
 136          $error_txt .= '
 137            <tr>
 138              <td><b>'.$mod_strings['LBL_CHECKSYS_PHPVER'].'</b></td>
 139              <td ><span class="error">'.$phpVersion.'</span></td>
 140            </tr>';
 141  
 142  }
 143  
 144  //Php Backward compatibility checks
 145  if(ini_get("zend.ze1_compatibility_mode")) {
 146      installLog($mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'].'  '.'Php Backward Compatibility');
 147      $phpCompatibility = "<b><span class=stop>{$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON']}</span></b>";
 148      $error_found = true;
 149      $error_txt .= '
 150        <tr>
 151          <td><b>Php Backward Compatibility</b></td>
 152          <td ><span class="error">'.$phpCompatibility.'</span></td>
 153        </tr>';
 154  
 155  }
 156  
 157  
 158  // database and connect
 159  
 160  if (!empty($_REQUEST['setup_db_type']))
 161      $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
 162  
 163  $mssqlStatus = '';
 164  $dbVersion = '';
 165  // Removed php_sqlsrv install support until the driver support is out of beta status
 166  $supported_dbs = array("mysql_connect",
 167                         "mysqli_connect",
 168                         "mssql_connect",
 169                         //"sqlsrv_connect",
 170  
 171  
 172  
 173                        );
 174  $db_support_exists = false;
 175  
 176  foreach ($supported_dbs as $dbfunct){
 177  
 178      if( function_exists( $dbfunct) ){
 179          $db_support_exists = true;
 180          installLog("Found at least one supported DB Type");
 181          break;
 182      }
 183  }
 184  if( !$db_support_exists ){
 185      $db_name = $mod_strings['LBL_DB_UNAVAILABLE'];
 186      installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}");
 187      $dbStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}</span></b>";
 188      $error_found = true;
 189      $error_txt .= '
 190        <tr>
 191          <td><strong>'.$db_name.'</strong></td>
 192          <td class="error">'.$dbStatus.'</td>
 193        </tr>';
 194  }
 195  
 196  // XML Parsing
 197  if(!function_exists('xml_parser_create')) {
 198      $xmlStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}</span></b>";
 199      installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}");
 200      $error_found = true;
 201      $error_txt .= '
 202        <tr>
 203          <td><strong>'.$mod_strings['LBL_CHECKSYS_XML'].'</strong></td>
 204          <td class="error">'.$xmlStatus.'</td>
 205        </tr>';
 206  }else{
 207      installLog("XML Parsing Support Found");
 208  }
 209  
 210  
 211  // mbstrings
 212  if(!function_exists('mb_strlen')) {
 213      $mbstringStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_MBSTRING']}</font></b>";
 214      installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_MBSTRING']}");
 215      $error_found = true;
 216      $error_txt .= '
 217        <tr>
 218          <td><strong>'.$mod_strings['LBL_CHECKSYS_MBSTRING'].'</strong></td>
 219          <td class="error">'.$mbstringStatus.'</td>
 220        </tr>';
 221  }else{
 222      installLog("MBString Support Found");
 223  }
 224  
 225  // config.php
 226  if(file_exists('./config.php') && (!(make_writable('./config.php')) ||  !(is_writable('./config.php')))) {
 227      installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}");
 228      $configStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}</span></b>";
 229      $error_found = true;
 230      $error_txt .= '
 231        <tr>
 232          <td><strong>'.$mod_strings['LBL_CHECKSYS_CONFIG'].'</strong></td>
 233          <td class="error">'.$configStatus.'</td>
 234        </tr>';
 235  }
 236  
 237  
 238  
 239  // session save dir
 240  if(ini_get('session.save_handler') == 'files') {
 241      $session_save_path = session_save_path();
 242      if (strpos ($session_save_path, ";") !== FALSE)
 243          $session_save_path = substr ($session_save_path, strpos ($session_save_path, ";")+1);
 244      if(is_dir($session_save_path)){
 245          if(is_writable($session_save_path)){
 246              installLog("Session Save Path is ".$session_save_path);
 247          }else{
 248              $save_pathStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_WRITABLE']}</font></b>";
 249              installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_WRITABLE']}");
 250              $error_found = true;
 251              $error_txt .= '
 252                <tr>
 253                  <td><strong>'.$mod_strings['LBL_CHECKSYS_SESSION_SAVE_PATH'].'</strong></td>
 254                  <td class="error">'.$save_pathStatus.'</td>
 255                </tr>';
 256          }
 257      }else{
 258          $save_pathStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_SET']}</font></b>";
 259          installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_SET']}");
 260          $error_found = true;
 261          $error_txt .= '
 262            <tr>
 263              <td><strong>'.$mod_strings['LBL_CHECKSYS_SESSION_SAVE_PATH'].'</strong></td>
 264              <td class="error">'.$save_pathStatus.'</td>
 265            </tr>';
 266      }
 267  }
 268  
 269  // custom dir
 270  if(!make_writable('./custom')) {
 271      $customStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}</font></b>";
 272      installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}");
 273      $error_found = true;
 274      $error_txt .= '
 275        <tr>
 276          <td><strong>'.$mod_strings['LBL_CHECKSYS_CUSTOM'].'</strong></td>
 277          <td class="error">'.$customStatus.'</td>
 278        </tr>';
 279  }else{
 280   installLog("/custom directory and subdirectory check passed");
 281  }
 282  
 283  // data dir
 284  if(!make_writable('./data') || !make_writable('./data/upload')) {
 285      $dataStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE']}</span></b>";
 286      installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE']}");
 287      $error_found = true;
 288      $error_txt .= '
 289        <tr>
 290          <td><strong>'.$mod_strings['LBL_CHECKSYS_DATA'].'</strong></td>
 291          <td class="error">'.$dataStatus
 292          .'</td>
 293        </tr><tr>
 294         <td colspan="2">
 295              <b>'.$mod_strings['LBL_CHECKSYS_FIX_FILES'].'</b>';
 296          if(!make_writable('./data')) {
 297                  $error_txt .='<br>'.getcwd().'/data';
 298              }
 299          if(!make_writable('./data/upload')) {
 300                  $error_txt .='<br>'.getcwd().'/data/upload';
 301              }
 302          $error_txt .= '</td>
 303        </tr>';
 304  }else{
 305   installLog("/data/upoad directory and subdirectory check passed");
 306  }
 307  
 308  
 309  // cache dir
 310      $cache_files[] = '/cache';
 311      $cache_files[] = '/cache/images';
 312      $cache_files[] = '/cache/import';
 313      $cache_files[] = '/cache/layout';
 314      $cache_files[] = '/cache/pdf';
 315      $cache_files[] = '/cache/upload';
 316      $cache_files[] = '/cache/xml';
 317      $filelist = '';
 318  
 319      foreach($cache_files as $c_file)
 320      {
 321          $dirname = ".".$c_file;
 322          $ok = false;
 323          if ((is_dir($dirname)) || @sugar_mkdir($dirname,0555)) // set permissions to restrictive - use make_writable to change in a standard way to the required permissions
 324          {
 325              $ok = make_writable($dirname);
 326          }
 327          if (!$ok)
 328          {
 329              $filelist .= '<br>'.getcwd().$c_file;
 330  
 331          }
 332      }
 333      if (strlen($filelist)>0)
 334      {
 335          $error_found = true;
 336          installLog("ERROR:: Some subdirectories in cache subfolder were not read/writeable:");
 337          installLog($filelist);
 338          $error_txt .= '
 339          <tr>
 340              <td><strong>'.$mod_strings['LBL_CHECKSYS_CACHE'].'</strong></td>
 341              <td align="right" class="error" class="error"><b><span class="stop">'.$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE'].'</span></b></td>
 342          </tr>
 343          <tr>
 344              <td colspan="2"><b>'.$mod_strings['LBL_CHECKSYS_FIX_FILES'].'</b>'.$filelist. '</td>
 345          </tr>';
 346      }else{
 347       installLog("/cache directory and subdirectory check passed");
 348      }
 349  
 350  
 351  // check modules dir
 352  $_SESSION['unwriteable_module_files'] = array();
 353  //if(!$writeableFiles['ret_val']) {
 354  $passed_write = recursive_make_writable('./modules');
 355  if (isset($_SESSION['unwriteable_module_files']['failed']) && $_SESSION['unwriteable_module_files']['failed']){
 356      $passed_write = false;
 357  }
 358  
 359  if(!$passed_write) {
 360  
 361      $moduleStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
 362      installLog("ERROR:: Module directories and the files under them are not writeable.");
 363      $error_found = true;
 364      $error_txt .= '
 365        <tr>
 366          <td><strong>'.$mod_strings['LBL_CHECKSYS_MODULE'].'</strong></td>
 367          <td align="right" class="error">'.$moduleStatus.'</td>
 368        </tr>';
 369  
 370          //list which module directories are not writeable, if there are less than 10
 371          $error_txt .= '
 372            <tr>
 373              <td colspan="2">
 374              <b>'.$mod_strings['LBL_CHECKSYS_FIX_MODULE_FILES'].'</b>';
 375          foreach($_SESSION['unwriteable_module_files'] as $key=>$file){
 376              if($key !='.' && $key != 'failed'){
 377                  $error_txt .='<br>'.$file;
 378              }
 379          }
 380          $error_txt .= '
 381              </td>
 382            </tr>';
 383  
 384  }else{
 385   installLog("/module  directory and subdirectory check passed");
 386  }
 387  
 388  
 389  
 390  // PHP.ini
 391  $phpIniLocation = get_cfg_var("cfg_file_path");
 392  installLog("php.ini location found. {$phpIniLocation}");
 393  // disable form if error found
 394  
 395  if($error_found){
 396      installLog("Outputting HTML for System check");
 397      installLog("Errors were found *************");
 398      $disabled = $error_found ? 'disabled="disabled"' : '';
 399  
 400      $help_url = get_help_button_url();
 401  ///////////////////////////////////////////////////////////////////////////////
 402  ////    BEGIN PAGE OUTPUT
 403      $out =<<<EOQ
 404  
 405    <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
 406      <tr>
 407        <th width="400">{$mod_strings['LBL_CHECKSYS_TITLE']}</th>
 408        <th width="200" height="30" style="text-align: right;"><a href="http://www.sugarcrm.com" target=
 409        "_blank"><IMG src="include/images/sugarcrm_login.png" width="145" height="30" alt="SugarCRM" border="0"></a>
 410         <br><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a>
 411         </th>
 412      </tr>
 413  
 414      <tr>
 415        <td colspan="2" width="600">
 416          <p>{$mod_strings['ERR_CHECKSYS']}</p>
 417  
 418          <table cellpadding="0" cellspacing="0" border="0" width="100%" class="StyleDottedHr">
 419            <tr>
 420              <th align="left">{$mod_strings['LBL_CHECKSYS_COMPONENT']}</th>
 421              <th style="text-align: right;">{$mod_strings['LBL_CHECKSYS_STATUS']}</th>
 422            </tr>
 423              $error_txt
 424  
 425          </table>
 426  
 427          <div align="center" style="margin: 5px;">
 428            <i>{$mod_strings['LBL_CHECKSYS_PHP_INI']}<br>{$phpIniLocation}</i>
 429          </div>
 430        </td>
 431      </tr>
 432  
 433      <tr>
 434        <td align="right" colspan="2">
 435          <hr>
 436          <form action="install3.php" method="post" name="theForm" id="theForm">
 437  
 438          <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
 439            <tr>
 440              <td><input class="button" type="button" onclick="window.open('http://www.sugarcrm.com/forums/');" value="{$mod_strings['LBL_HELP']}" /></td>
 441              <td>
 442                  <input class="button" type="button" name="Re-check" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}" onclick="callSysCheck();" id="defaultFocus"/>
 443              </td>
 444            </tr>
 445          </table>
 446          </form>
 447        </td>
 448      </tr>
 449    </table><br>
 450  EOQ;
 451  return $out;
 452  }else{
 453      installLog("Outputting HTML for System check");
 454      installLog("No Errors were found *************");
 455   return 'passed';
 456  }
 457  
 458  }
 459  ////    END PAGEOUTPUT
 460  ///////////////////////////////////////////////////////////////////////////////
 461  ?>


Generé en: Thu Mar 4 09:44:50 2010 | Cross-referenced par PHPXref 0.7