/**
  * Returns a reference to the DB object for instance $instanceName, or the default
  * instance if one is not specified
  *
  * @param  string $instanceName optional, name of the instance
  * @return object DBManager instance
  */
 public static function getInstance($instanceName = '')
 {
     global $sugar_config, $dbinstances;
     static $count, $old_count;
     $instanceName = 'db';
     $config = $sugar_config['dbconfig'];
     if (!isset($dbinstances)) {
         $dbinstances = array();
     }
     //fall back to the default instance name
     if (empty($sugar_config['db'][$instanceName])) {
         $instanceName = '';
     }
     if (!isset($dbinstances[$instanceName])) {
         $my_db_manager = 'MysqlManager';
         if ($config['db_type'] == "mysql") {
             if ((!isset($sugar_config['mysqli_disabled']) || $sugar_config['mysqli_disabled'] == false) && function_exists('mysqli_connect')) {
                 $my_db_manager = 'MysqliManager';
             }
         }
         if ($config['db_type'] == "oci8") {
         } elseif ($config['db_type'] == "mssql") {
             if (function_exists('sqlsrv_connect') && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) {
                 $my_db_manager = 'SqlsrvManager';
             } elseif (is_freetds() && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) {
                 $my_db_manager = 'FreeTDSManager';
             } else {
                 $my_db_manager = 'MssqlManager';
             }
         }
         if (isset($GLOBALS['log'])) {
             $GLOBALS['log']->info("using {$my_db_manager} DBManager backend");
         }
         if (!empty($config['db_manager'])) {
             $my_db_manager = $config['db_manager'];
         }
         require_once "include/database/{$my_db_manager}.php";
         $dbinstances[$instanceName] = new $my_db_manager();
         $dbinstances[$instanceName]->getHelper();
         $dbinstances[$instanceName]->connect($config, true);
         $dbinstances[$instanceName]->count_id = $count;
         $dbinstances[$instanceName]->references = 0;
         $dbinstances[$instanceName]->getHelper()->db = $dbinstances[$instanceName];
     } else {
         $old_count++;
         $dbinstances[$instanceName]->references = $old_count;
     }
     return $dbinstances[$instanceName];
 }
예제 #2
0
 @UWrebuild();
 ob_end_clean();
 logThis('UWrebuild() done.', $path);
 logThis('begin check default permissions .', $path);
 checkConfigForPermissions();
 logThis('end check default permissions .', $path);
 logThis('begin check logger settings .', $path);
 checkLoggerSettings();
 logThis('begin check logger settings .', $path);
 logThis('begin check resource settings .', $path);
 checkResourceSettings();
 logThis('begin check resource settings .', $path);
 require "sugar_version.php";
 require 'config.php';
 global $sugar_config;
 if ($origVersion < '550' && $sugar_config['dbconfig']['db_type'] == 'mssql' && !is_freetds()) {
     convertImageToText('import_maps', 'content');
     convertImageToText('import_maps', 'default_values');
 }
 if ($origVersion < '550' && $sugar_config['dbconfig']['db_type'] == 'mssql') {
     dropColumnConstraintForMSSQL("outbound_email", "mail_smtpssl");
     $GLOBALS['db']->query("ALTER TABLE outbound_email alter column mail_smtpssl int NULL");
 }
 // if
 if ($ce_to_pro_ent || $origVersion < '550') {
     if (!merge_passwordsetting($sugar_config, $sugar_version)) {
         logThis('*** ERROR: could not write config.php! - upgrade will fail!', $path);
         $errors[] = 'Could not write config.php!';
     }
 }
 if ($destVersion == $origVersion) {
예제 #3
0
 /**
  * Returns this instance's DBHelper
  *
  * @return object DBHelper instance
  */
 public function getHelper()
 {
     if (!$this->helper instanceof DBHelper) {
         global $sugar_config;
         switch ($sugar_config['dbconfig']['db_type']) {
             case "mysql":
                 $my_db_helper = 'MysqlHelper';
                 if ((!isset($sugar_config['mysqli_disabled']) || $sugar_config['mysqli_disabled'] == false) && function_exists('mysqli_connect')) {
                     $my_db_helper = 'MysqliHelper';
                 }
                 break;
             case "mssql":
                 if (function_exists('sqlsrv_connect') && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) {
                     $my_db_helper = 'SqlsrvHelper';
                 } elseif (is_freetds() && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) {
                     $my_db_helper = 'FreeTDSHelper';
                 } else {
                     $my_db_helper = 'MssqlHelper';
                 }
                 break;
             default:
                 $my_db_helper = 'MysqlHelper';
         }
         $GLOBALS['log']->info("using {$my_db_helper} DBHelper backend");
         require_once "include/database/{$my_db_helper}.php";
         $this->helper = new $my_db_helper();
         $this->helper->db = $this;
     }
     return $this->helper;
 }
function runCheck($install_script = false, $mod_strings)
{
    installLog("Begin System Check Process *************");
    if (!isset($install_script) || !$install_script) {
        installLog("Error:: " . $mod_strings['ERR_NO_DIRECT_SCRIPT']);
        die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
    }
    if (!defined('SUGARCRM_MIN_MEM')) {
        define('SUGARCRM_MIN_MEM', 40);
    }
    // for keeping track of whether to enable/disable the 'Next' button
    $error_found = false;
    $error_txt = '';
    //
    // Check to see if session variables are working properly
    //
    if (empty($_SESSION['test_session'])) {
        $_SESSION['test_session'] = 'sessions are available';
        session_write_close();
        unset($_SESSION['test_session']);
        session_start();
    }
    if (!isset($_SESSION['test_session'])) {
        installLog("ERROR:: " . $mod_strings['LBL_CHECKSYS_NO_SESSIONS']);
        die("<p><b><span class='error'>{$mod_strings['LBL_CHECKSYS_NO_SESSIONS']}</span></b></p>\n");
    }
    // check IIS and FastCGI
    $server_software = $_SERVER["SERVER_SOFTWARE"];
    if (strpos($server_software, 'Microsoft-IIS') !== false) {
        $iis_version = '';
        if (preg_match_all("/^.*\\/(\\d+\\.?\\d*)\$/", $server_software, $out)) {
            $iis_version = $out[1][0];
        }
        $check_iis_version_result = check_iis_version($iis_version);
        if ($check_iis_version_result == -1) {
            installLog($mod_strings['ERR_CHECKSYS_IIS_INVALID_VER'] . ' ' . $iis_version);
            $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_IIS_INVALID_VER']} {$iis_version}</span></b>";
            $error_found = true;
            $error_txt .= '
          <tr>
            <td><b>' . $mod_strings['LBL_CHECKSYS_IISVER'] . '</b></td>
            <td ><span class="error">' . $iisVersion . '</span></td>
          </tr>';
        } else {
            if (php_sapi_name() != 'cgi-fcgi') {
                installLog($mod_strings['ERR_CHECKSYS_FASTCGI'] . ' ' . $iis_version);
                $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI']}</span></b>";
                $error_found = true;
                $error_txt .= '
          <tr>
            <td><b>' . $mod_strings['LBL_CHECKSYS_FASTCGI'] . '</b></td>
            <td ><span class="error">' . $iisVersion . '</span></td>
          </tr>';
            }
        }
    }
    // PHP VERSION
    $php_version = constant('PHP_VERSION');
    $check_php_version_result = check_php_version($php_version);
    if ($check_php_version_result == -1) {
        installLog($mod_strings['ERR_CHECKSYS_PHP_INVALID_VER'] . '  ' . $php_version);
        $phpVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
        $error_found = true;
        $error_txt .= '
          <tr>
            <td><b>' . $mod_strings['LBL_CHECKSYS_PHPVER'] . '</b></td>
            <td ><span class="error">' . $phpVersion . '</span></td>
          </tr>';
    }
    //Php Backward compatibility checks
    if (ini_get("zend.ze1_compatibility_mode")) {
        installLog($mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'] . '  ' . 'Php Backward Compatibility');
        $phpCompatibility = "<b><span class=stop>{$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON']}</span></b>";
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><b>Php Backward Compatibility</b></td>
        <td ><span class="error">' . $phpCompatibility . '</span></td>
      </tr>';
    }
    // database and connect
    if (!empty($_REQUEST['setup_db_type'])) {
        $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
    }
    $mssqlStatus = '';
    $dbVersion = '';
    $supported_dbs = array("mysql_connect", "mysqli_connect", "mssql_connect", "sqlsrv_connect");
    $db_support_exists = false;
    foreach ($supported_dbs as $dbfunct) {
        if (function_exists($dbfunct)) {
            // Added to check if we are using the freetds driver vs the php_mssql one; don't allow new installs
            // with the php_mssql driver
            if ($dbfunct == 'mssql_connect' && !is_freetds()) {
                continue;
            }
            $db_support_exists = true;
            installLog("Found at least one supported DB Type");
            break;
        }
    }
    if (!$db_support_exists) {
        $db_name = $mod_strings['LBL_DB_UNAVAILABLE'];
        installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}");
        $dbStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}</span></b>";
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $db_name . '</strong></td>
        <td class="error">' . $dbStatus . '</td>
      </tr>';
    }
    // XML Parsing
    if (!function_exists('xml_parser_create')) {
        $xmlStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}</span></b>";
        installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}");
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_XML'] . '</strong></td>
        <td class="error">' . $xmlStatus . '</td>
      </tr>';
    } else {
        installLog("XML Parsing Support Found");
    }
    // mbstrings
    if (!function_exists('mb_strlen')) {
        $mbstringStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_MBSTRING']}</font></b>";
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_MBSTRING']}");
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_MBSTRING'] . '</strong></td>
        <td class="error">' . $mbstringStatus . '</td>
      </tr>';
    } else {
        installLog("MBString Support Found");
    }
    // config.php
    if (file_exists('./config.php') && (!make_writable('./config.php') || !is_writable('./config.php'))) {
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}");
        $configStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}</span></b>";
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_CONFIG'] . '</strong></td>
        <td class="error">' . $configStatus . '</td>
      </tr>';
    }
    // session save dir
    if (ini_get('session.save_handler') == 'files') {
        $session_save_path = session_save_path();
        if (strpos($session_save_path, ";") !== FALSE) {
            $session_save_path = substr($session_save_path, strpos($session_save_path, ";") + 1);
        }
        if (is_dir($session_save_path)) {
            if (is_writable($session_save_path)) {
                installLog("Session Save Path is " . $session_save_path);
            } else {
                $save_pathStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_WRITABLE']}</font></b>";
                installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_WRITABLE']}");
                $error_found = true;
                $error_txt .= '
              <tr>
                <td><strong>' . $mod_strings['LBL_CHECKSYS_SESSION_SAVE_PATH'] . '</strong></td>
                <td class="error">' . $save_pathStatus . '</td>
              </tr>';
            }
        } else {
            $save_pathStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_SET']}</font></b>";
            installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_SESSION_SAVE_PATH_NOT_SET']}");
            $error_found = true;
            $error_txt .= '
          <tr>
            <td><strong>' . $mod_strings['LBL_CHECKSYS_SESSION_SAVE_PATH'] . '</strong></td>
            <td class="error">' . $save_pathStatus . '</td>
          </tr>';
        }
    }
    // custom dir
    if (!make_writable('./custom')) {
        $customStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}</font></b>";
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}");
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_CUSTOM'] . '</strong></td>
        <td class="error">' . $customStatus . '</td>
      </tr>';
    } else {
        installLog("/custom directory and subdirectory check passed");
    }
    // data dir
    if (!make_writable('./data') || !make_writable('./data/upload')) {
        $dataStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE']}</span></b>";
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE']}");
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_DATA'] . '</strong></td>
        <td class="error">' . $dataStatus . '</td>
      </tr><tr>
       <td colspan="2">
            <b>' . $mod_strings['LBL_CHECKSYS_FIX_FILES'] . '</b>';
        if (!make_writable('./data')) {
            $error_txt .= '<br>' . getcwd() . '/data';
        }
        if (!make_writable('./data/upload')) {
            $error_txt .= '<br>' . getcwd() . '/data/upload';
        }
        $error_txt .= '</td>
      </tr>';
    } else {
        installLog("/data/upoad directory and subdirectory check passed");
    }
    // cache dir
    $cache_files[] = '/cache';
    $cache_files[] = '/cache/images';
    $cache_files[] = '/cache/import';
    $cache_files[] = '/cache/layout';
    $cache_files[] = '/cache/pdf';
    $cache_files[] = '/cache/upload';
    $cache_files[] = '/cache/xml';
    $filelist = '';
    foreach ($cache_files as $c_file) {
        $dirname = "." . $c_file;
        $ok = false;
        if (is_dir($dirname) || @sugar_mkdir($dirname, 0555)) {
            $ok = make_writable($dirname);
        }
        if (!$ok) {
            $filelist .= '<br>' . getcwd() . $c_file;
        }
    }
    if (strlen($filelist) > 0) {
        $error_found = true;
        installLog("ERROR:: Some subdirectories in cache subfolder were not read/writeable:");
        installLog($filelist);
        $error_txt .= '
		<tr>
        	<td><strong>' . $mod_strings['LBL_CHECKSYS_CACHE'] . '</strong></td>
        	<td align="right" class="error" class="error"><b><span class="stop">' . $mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE'] . '</span></b></td>
		</tr>
		<tr>
        	<td colspan="2"><b>' . $mod_strings['LBL_CHECKSYS_FIX_FILES'] . '</b>' . $filelist . '</td>
		</tr>';
    } else {
        installLog("/cache directory and subdirectory check passed");
    }
    // check modules dir
    $_SESSION['unwriteable_module_files'] = array();
    //if(!$writeableFiles['ret_val']) {
    $passed_write = recursive_make_writable('./modules');
    if (isset($_SESSION['unwriteable_module_files']['failed']) && $_SESSION['unwriteable_module_files']['failed']) {
        $passed_write = false;
    }
    if (!$passed_write) {
        $moduleStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
        installLog("ERROR:: Module directories and the files under them are not writeable.");
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_MODULE'] . '</strong></td>
        <td align="right" class="error">' . $moduleStatus . '</td>
      </tr>';
        //list which module directories are not writeable, if there are less than 10
        $error_txt .= '
          <tr>
            <td colspan="2">
            <b>' . $mod_strings['LBL_CHECKSYS_FIX_MODULE_FILES'] . '</b>';
        foreach ($_SESSION['unwriteable_module_files'] as $key => $file) {
            if ($key != '.' && $key != 'failed') {
                $error_txt .= '<br>' . $file;
            }
        }
        $error_txt .= '
            </td>
          </tr>';
    } else {
        installLog("/module  directory and subdirectory check passed");
    }
    // PHP.ini
    $phpIniLocation = get_cfg_var("cfg_file_path");
    installLog("php.ini location found. {$phpIniLocation}");
    // disable form if error found
    if ($error_found) {
        installLog("Outputting HTML for System check");
        installLog("Errors were found *************");
        $disabled = $error_found ? 'disabled="disabled"' : '';
        $help_url = get_help_button_url();
        ///////////////////////////////////////////////////////////////////////////////
        ////    BEGIN PAGE OUTPUT
        $out = <<<EOQ

  <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
    <tr>
      <th width="400">{$mod_strings['LBL_CHECKSYS_TITLE']}</th>
      <th width="200" height="30" style="text-align: right;"><a href="http://www.sugarcrm.com" target=
      "_blank"><IMG src="include/images/sugarcrm_login.png" width="145" height="30" alt="SugarCRM" border="0"></a>
       <br><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a>
       </th>
    </tr>

    <tr>
      <td colspan="2" width="600">
        <p>{$mod_strings['ERR_CHECKSYS']}</p>

        <table cellpadding="0" cellspacing="0" border="0" width="100%" class="StyleDottedHr">
          <tr>
            <th align="left">{$mod_strings['LBL_CHECKSYS_COMPONENT']}</th>
            <th style="text-align: right;">{$mod_strings['LBL_CHECKSYS_STATUS']}</th>
          </tr>
            {$error_txt}

        </table>

        <div align="center" style="margin: 5px;">
          <i>{$mod_strings['LBL_CHECKSYS_PHP_INI']}<br>{$phpIniLocation}</i>
        </div>
      </td>
    </tr>

    <tr>
      <td align="right" colspan="2">
        <hr>
        <form action="install3.php" method="post" name="theForm" id="theForm">

        <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
          <tr>
            <td><input class="button" type="button" onclick="window.open('http://www.sugarcrm.com/forums/');" value="{$mod_strings['LBL_HELP']}" /></td>
            <td>
                <input class="button" type="button" name="Re-check" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}" onclick="callSysCheck();" id="defaultFocus"/>
            </td>
          </tr>
        </table>
        </form>
      </td>
    </tr>
  </table><br>
EOQ;
        return $out;
    } else {
        installLog("Outputting HTML for System check");
        installLog("No Errors were found *************");
        return 'passed';
    }
}
예제 #5
0
파일: DBManager.php 프로젝트: congtt/pj.ntk
 /**
  * Returns this instance's DBHelper
  *
  * @return object DBHelper instance
  */
 public function getHelper()
 {
     if (!$this->helper instanceof DBHelper) {
         global $ts_config;
         switch ($ts_config['dbconfig']['db_type']) {
             case "mysql":
                 $my_db_helper = 'MysqlHelper';
                 if ((!isset($ts_config['mysqli_disabled']) || $ts_config['mysqli_disabled'] == false) && function_exists('mysqli_connect')) {
                     $my_db_helper = 'MysqliHelper';
                 }
                 break;
             case "mssql":
                 if (is_freetds() && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) {
                     $my_db_helper = 'FreeTDSHelper';
                 } elseif (function_exists('mssql_connect') && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'mssql')) {
                     $my_db_helper = 'MssqlHelper';
                 } else {
                     $my_db_helper = 'SqlsrvHelper';
                 }
                 break;
             default:
                 $my_db_helper = 'MysqlHelper';
         }
         require_once "include/db/{$my_db_helper}.php";
         $this->helper = new $my_db_helper();
     }
     return $this->helper;
 }
<tr><td colspan="3" align="left">{$mod_strings['LBL_SYSOPTS_2']}</td></tr>
<tr>
    <td>&nbsp;</td>
    <td align="left">
        <input type="radio" class="checkbox" name="setup_db_type" id="setup_db_type" value="mysql" {$mysql} onclick="document.getElementById('ociMsg').style.display='none'"/>{$mod_strings['LBL_MYSQL']}
EOQ;
//check to see if mysqli is enabled
if (function_exists('mysqli_connect')) {
    $_SESSION['mysql_type'] = 'mysqli';
    $out .= ' &nbsp;(MySQLi detected)<br>';
} else {
    $out .= '<br>';
}
// Updated to check if we are using the freetds driver vs the php_mssql one; don't allow new installs
// with the php_mssql driver
if (function_exists('mssql_connect') && is_freetds() || function_exists('sqlsrv_connect')) {
    $out .= <<<EOQ
\t\t<input type="radio" class="checkbox" name="setup_db_type" id="setup_db_type" value="mssql" {$mssql} onclick="document.getElementById('ociMsg').style.display='none'"/>{$mod_strings['LBL_MSSQL']}
EOQ;
}
//check to see if sqlsrv is enabled
if (function_exists('sqlsrv_connect')) {
    $_SESSION['mssql_type'] = 'sqlsrv';
    $out .= ' &nbsp;(Microsoft SQL Server Driver for PHP detected)<br>';
} else {
    $out .= '<br>';
}
$out .= <<<EOQ
    </td>
    <td width='350'nowrap>&nbsp;
    <div name="ociMsg" id="ociMsg" style="display:none">
예제 #7
0
 /**
  * @ticket 27781
  */
 public function testGetInstanceMssqlForceSqlsrvSelection()
 {
     if ($GLOBALS['db']->dbType != 'mssql' || !function_exists('sqlsrv_connect')) {
         $this->markTestSkipped('Only applies to SQL Server');
     }
     $GLOBALS['sugar_config']['db_mssql_force_driver'] = 'sqlsrv';
     $db =& DBManagerFactory::getInstance();
     if (is_freetds() && !function_exists('sqlsrv_connect')) {
         $this->assertTrue($db instanceof FreeTDSManager, "Should return a FreeTDSManager object");
     } elseif (function_exists('mssql_connect') && !function_exists('sqlsrv_connect')) {
         $this->assertTrue($db instanceof MssqlManager, "Should return a MssqlManager object");
     } else {
         $this->assertTrue($db instanceof SqlsrvManager, "Should return a SqlsrvManager object");
     }
 }
예제 #8
0
파일: end.php 프로젝트: aldridged/gtg-sugar
    if (isset($repairedTables[$tablename])) {
        continue;
    }
    $fielddefs = $meta['fields'];
    $indices = $meta['indices'];
    $sql = $GLOBALS['db']->repairTableParams($tablename, $fielddefs, $indices, true);
    logThis('Running sql:' . $sql, $path);
    $repairedTables[$tablename] = true;
}
$dictionary = $olddictionary;
logThis('database repaired', $path);
$ce_to_pro_ent = isset($_SESSION['upgrade_from_flavor']) && ($_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarPro' || $_SESSION['upgrade_from_flavor'] == 'SugarCE to SugarEnt');
if (isset($_SESSION['current_db_version']) && $_SESSION['current_db_version'] < '550') {
    include "install/seed_data/Advanced_Password_SeedData.php";
}
if (isset($_SESSION['current_db_version']) && $_SESSION['current_db_version'] < '550' && $sugar_config['dbconfig']['db_type'] == 'mssql' && !is_freetds()) {
    convertImageToText('import_maps', 'content');
    convertImageToText('import_maps', 'default_values');
}
logThis(" Start Rebuilding the config file again", $path);
//check and set the logger before rebuilding config
if (!isset($sugar_config['logger'])) {
    $sugar_config['logger'] = array('level' => 'fatal', 'file' => array('ext' => '.log', 'name' => 'sugarcrm', 'dateFormat' => '%c', 'maxSize' => '10MB', 'maxLogs' => 10, 'suffix' => '%m_%Y'));
}
if (!rebuildConfigFile($sugar_config, $sugar_version)) {
    logThis('*** WARNING: could not write config.php!', $path);
}
logThis(" Finish Rebuilding the config file again", $path);
set_upgrade_progress('end', 'in_progress');
if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version'])) {
    if ($_SESSION['current_db_version'] != $_SESSION['target_db_version']) {