Example #1
0
$current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
if (file_exists("install/language/{$current_language}.lang.php")) {
    require_once "install/language/{$current_language}.lang.php";
} else {
    require_once "install/language/{$default_lang}.lang.php";
}
if ($current_language != 'en_us') {
    $my_mod_strings = $mod_strings;
    include 'install/language/en_us.lang.php';
    $mod_strings = sugarLangArrayMerge($mod_strings, $my_mod_strings);
}
$app_list_strings = return_app_list_strings_language($current_language);
////	END INSTALLER LANGUAGE
///////////////////////////////////////////////////////////////////////////////
//get the url for the helper link
$help_url = get_help_button_url();
//if this license print, then redirect and exit,
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'licensePrint') {
    include 'install/licensePrint.php';
    exit;
}
if (isset($_REQUEST['sugar_body_only']) && $_REQUEST['sugar_body_only'] == "1") {
    //if this is a system check, then just run the check and return,
    //this is an ajax call and there is no need for further processing
    if (isset($_REQUEST['uploadLogoFrame']) && $_REQUEST['uploadLogoFrame']) {
        echo 'I\'m an uploader iframe!';
        return;
    }
    // upload company logo
    if (isset($_REQUEST['uploadLogo']) && $_REQUEST['uploadLogo']) {
        $filepath = '';
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 IIS and FastCGI
    $server_software = $_SERVER["SERVER_SOFTWARE"];
    if (strpos($_SERVER["SERVER_SOFTWARE"], 'Microsoft-IIS') !== false && php_sapi_name() == 'cgi-fcgi' && ini_get('fastcgi.logging') != '0') {
        installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']);
        $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</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>';
    }
    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>';
            } else {
                if (ini_get('fastcgi.logging') != '0') {
                    installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING'] . ' ' . $iis_version);
                    $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</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 = '';
    // Removed php_sqlsrv install support until the driver support is out of beta status
    $supported_dbs = array("mysql_connect", "mysqli_connect", "mssql_connect", "sqlsrv_connect");
    $db_support_exists = false;
    foreach ($supported_dbs as $dbfunct) {
        if (function_exists($dbfunct)) {
            $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");
    }
    // zip
    if (!class_exists('ZipArchive')) {
        $zipStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_ZIP']}</font></b>";
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_ZIP']}");
    } else {
        installLog("ZIP 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>';
    }
    // 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';
    }
}
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 IIS and FastCGI
    $server_software = $_SERVER["SERVER_SOFTWARE"];
    if (strpos($_SERVER["SERVER_SOFTWARE"], 'Microsoft-IIS') !== false && php_sapi_name() == 'cgi-fcgi' && ini_get('fastcgi.logging') != '0') {
        installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']);
        $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</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>';
    }
    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>';
            } else {
                if (ini_get('fastcgi.logging') != '0') {
                    installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING'] . ' ' . $iis_version);
                    $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</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'];
    }
    $drivers = DBManagerFactory::getDbDrivers();
    if (empty($drivers)) {
        $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");
    }
    // zip
    if (!class_exists('ZipArchive')) {
        $zipStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_ZIP']}</font></b>";
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_ZIP']}");
    } else {
        installLog("ZIP 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>';
    }
    // config_override.php
    if (file_exists('./config_override.php') && (!make_writable('./config_override.php') || !is_writable('./config_override.php'))) {
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CONFIG_OVERRIDE_NOT_WRITABLE']}");
        $configStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CONFIG_OVERRIDE_NOT_WRITABLE']}</span></b>";
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_OVERRIDE_CONFIG'] . '</strong></td>
        <td class="error">' . $configStatus . '</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");
    }
    // cache dir
    $cache_files[] = '';
    $cache_files[] = 'images';
    $cache_files[] = 'layout';
    $cache_files[] = 'pdf';
    $cache_files[] = 'xml';
    $cache_files[] = 'include/javascript';
    $filelist = '';
    foreach ($cache_files as $c_file) {
        $dirname = sugar_cached($c_file);
        $ok = false;
        if (is_dir($dirname) || @sugar_mkdir($dirname, 0555)) {
            $ok = make_writable($dirname);
        }
        if (!$ok) {
            $filelist .= '<br>' . getcwd() . "/{$dirname}";
        }
    }
    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");
    }
    // check upload dir
    if (!make_writable('./upload')) {
        $uploadStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
        installLog("ERROR: Upload directory is not writable.");
        $error_found = true;
        $error_txt .= '
    <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_UPLOAD'] . '</strong></td>
        <td align="right" class="error">' . $uploadStatus . '</td>
    </tr>';
    } else {
        installLog("/upload directory check passed");
    }
    // check zip file support
    if (!class_exists("ZipArchive")) {
        $zipStatus = "<span class='stop'><b>{$mod_strings['ERR_CHECKSYS_ZIP']}</b></span>";
        installLog("ERROR: Zip support not found.");
        $error_found = true;
        $error_txt .= '
          <tr>
            <td><strong>' . $mod_strings['LBL_CHECKSYS_ZIP'] . '</strong></td>
            <td  align="right" class="error">' . $zipStatus . '</td>
          </tr>';
    } else {
        installLog("/zip check passed");
    }
    // check BCMATH support
    if (!function_exists("bcadd")) {
        $bcmathStatus = "<span class='stop'><b>{$mod_strings['ERR_CHECKSYS_BCMATH']}</b></span>";
        installLog("ERROR: BCMATH support not found.");
        $error_found = true;
        $error_txt .= '
      <tr>
        <td><strong>' . $mod_strings['LBL_CHECKSYS_BCMATH'] . '</strong></td>
        <td  align="right" class="error">' . $bcmathStatus . '</td>
      </tr>';
    } else {
        installLog("/BCMATH check passed");
    }
    // check htaccess & rewrite working
    if (empty($_SERVER["SERVER_SOFTWARE"]) || strpos($_SERVER["SERVER_SOFTWARE"], 'Microsoft-IIS') === false) {
        installLog("Testing .htaccess redirects");
        if (file_exists(".htaccess")) {
            $old_htaccess = file_get_contents(".htaccess");
        }
        $basePath = parse_url($_SESSION['setup_site_url'], PHP_URL_PATH);
        if (empty($basePath)) {
            $basePath = '/';
        }
        $htaccess_test = <<<EOT

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase {$basePath}
    RewriteRule ^itest.txt\$ install_test.txt [N,QSA]
</IfModule>
EOT;
        if (!empty($old_htaccess)) {
            $htaccess_test = $old_htaccess . $htaccess_test;
        }
        file_put_contents(".htaccess", $htaccess_test);
        file_put_contents("install_test.txt", "SUCCESS");
        $res = file_get_contents($_SESSION['setup_site_url'] . "/itest.txt");
        unlink("install_test.txt");
        if (!empty($old_htaccess)) {
            file_put_contents(".htaccess", $old_htaccess);
        } else {
            unlink(".htaccess");
        }
        if ($res != "SUCCESS") {
            $error_found = true;
            $error_txt .= '
          <tr>
            <td><strong>' . $mod_strings['LBL_CHECKSYS_HTACCESS'] . '</strong></td>
            <td  align="right" class="error"><span class="stop"><b>' . $mod_strings['ERR_CHECKSYS_HTACCESS'] . '</b></span></td>
          </tr>';
        } else {
            installLog("Passed .htaccess redirects check");
        }
    }
    // custom checks
    $customSystemChecks = installerHook('additionalCustomSystemChecks');
    if ($customSystemChecks != 'undefined') {
        if ($customSystemChecks['error_found'] == true) {
            $error_found = true;
        }
        if (!empty($customSystemChecks['error_txt'])) {
            $error_txt .= $customSystemChecks['error_txt'];
        }
    }
    // 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" 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="button_next2"/>
            </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';
    }
}
Example #4
0
    private function getFormItems($mod_strings, $app_list_strings, $sugarConfigDefaults, $drivers, $checked, $db, $errors, $supportedLanguages, $current_language, $customSession, $customLog, $customId, $customSessionHidden, $customLogHidden, $customIdHidden)
    {
        // ------------------------------
        //  DB Type and DB configuration
        // ---------------------------------->
        // database selection
        $out_dbtypesel = "\n    <div class=\"floatbox\" id=\"fb5\">\n        <h2>{$mod_strings['LBL_DBCONF_TITLE']}</h2>\n\n        <div class=\"form_section\">\n          <h3>{$mod_strings['LBL_SYSOPTS_DB']}</h3>";
        foreach ($drivers as $type => $driver) {
            $oci = $type == "oci8" ? "" : 'none';
            // hack for special oracle message
            $out_dbtypesel .= <<<EOQ
                <input type="radio" class="checkbox" name="setup_db_type" id="setup_db_type" value="{$type}" {$checked[$type]} onclick="onDBTypeClick(this);//document.getElementById('ociMsg').style.display='{$oci}'"/>{$mod_strings[$driver->label]}<br>
EOQ;
        }
        $out_dbtypesel .= <<<EOQ
        </div>
            <div name="ociMsg" id="ociMsg" style="display:none"></div>
    <!-- </div> -->
EOQ;
        $out2 = $out_dbtypesel;
        $out2 .= <<<EOQ2

        <!-- <div class="floatbox"> -->

            <div class="form_section starhook">
            <!-- <div class="required">{$mod_strings['LBL_REQUIRED']}</div> -->
            <h3>{$mod_strings['LBL_DBCONF_TITLE_NAME']}</h3>
EOQ2;
        $config_params = $db->installConfig();
        $form = '';
        foreach ($config_params as $group => $gdata) {
            $form .= "<div class='install_block'>";
            if ($mod_strings[$group . '_LABEL']) {
                $form .= "<label>{$mod_strings[$group . '_LABEL']}" . "<i> i <div class=\"tooltip\">{$mod_strings[$group]}</div></i></label>\n";
            }
            foreach ($gdata as $name => $value) {
                if (!empty($value)) {
                    if (!empty($value['required'])) {
                        $form .= "<span class=\"required\">*</span>";
                    } else {
                    }
                    if (!empty($_SESSION[$name])) {
                        $sessval = $_SESSION[$name];
                    } else {
                        $sessval = '';
                    }
                    if (!empty($value["type"])) {
                        $type = $value["type"];
                    } else {
                        $type = '';
                    }
                    $form .= <<<FORM
FORM;
                    //if the type is password, set a hidden field to capture the value.  This is so that we can properly encode special characters, which is a limitation with password fields
                    if ($type == 'password') {
                        $form .= "</div><div class=\"install_block\"><label>{$mod_strings['LBL_DBCONF_TITLE_PSWD_INFO_LABEL']}</label><span>&nbsp;</span><input type='{$type}' name='{$name}_entry' id='{$name}_entry' value='" . urldecode($sessval) . "'><input type='hidden' name='{$name}' id='{$name}' value='" . urldecode($sessval) . "'></div><div class=\"install_block\">";
                    } else {
                        $form .= "<input type='{$type}' name='{$name}' id='{$name}' value='{$sessval}'>";
                    }
                    $form .= <<<FORM
FORM;
                } else {
                    $form .= "<input name=\"{$name}\" id=\"{$name}\" value=\"\" type=\"hidden\">\n";
                }
            }
            $form .= "</div>";
        }
        $out2 .= $form;
        // ---------- user data set (dbConfig_a.php)
        //if we are installing in custom mode, include the following html
        if ($db->supports("create_user")) {
            // create / set db user dropdown
            $auto_select = '';
            $provide_select = '';
            $create_select = '';
            $same_select = '';
            if (isset($_SESSION['dbUSRData'])) {
                //    if($_SESSION['dbUSRData']=='auto')    {$auto_select ='selected';}
                if ($_SESSION['dbUSRData'] == 'provide') {
                    $provide_select = 'selected';
                }
                if (isset($_SESSION['install_type']) && !empty($_SESSION['install_type']) && strtolower($_SESSION['install_type']) == 'custom') {
                    if ($_SESSION['dbUSRData'] == 'create') {
                        $create_select = 'selected';
                    }
                }
                if ($_SESSION['dbUSRData'] == 'same') {
                    $same_select = 'selected';
                }
            } else {
                $same_select = 'selected';
            }
            $dbUSRDD = "<select name='dbUSRData' id='dbUSRData' onchange='toggleDBUser();'>";
            $dbUSRDD .= "<option value='provide' {$provide_select}>" . $mod_strings['LBL_DBCONFIG_PROVIDE_DD'] . "</option>";
            $dbUSRDD .= "<option value='create' {$create_select}>" . $mod_strings['LBL_DBCONFIG_CREATE_DD'] . "</option>";
            $dbUSRDD .= "<option value='same' {$same_select}>" . $mod_strings['LBL_DBCONFIG_SAME_DD'] . "</option>";
            $dbUSRDD .= "</select><br>&nbsp;";
            $setup_db_sugarsales_password = urldecode($_SESSION['setup_db_sugarsales_password']);
            $setup_db_sugarsales_user = urldecode($_SESSION['setup_db_sugarsales_user']);
            $setup_db_sugarsales_password_retype = urldecode($_SESSION['setup_db_sugarsales_password_retype']);
            $out2 .= <<<EOQ2
<br>
<div class='install_block'>
<!--
    <div class="ibmsg">{$mod_strings['LBL_DBCONFIG_SECURITY']}</div>
    -->
</div>
<div class='install_block'>
    <div class="formrow">
        <label>{$mod_strings['LBL_DBCONF_SUGAR_DB_USER']}<i> i <div class="tooltip">{$mod_strings['LBL_DBCONFIG_SECURITY']}</div></i></label>
        {$dbUSRDD}
    </div>
    <div class="clear"></div>
    <span id='connection_user_div' style="display:none">
        <div class="formrow">
            <label>{$mod_strings['LBL_DBCONF_SUGAR_DB_USER']} <span class="required">*</span></label>
            <input type="text" name="setup_db_sugarsales_user" maxlength="16" value="{$_SESSION['setup_db_sugarsales_user']}" />
        </div>
        <div class="clear"></div>
        <div class="formrow">
            <label>{$mod_strings['LBL_DBCONF_DB_PASSWORD']}</label>
            <input type="password" name="setup_db_sugarsales_password_entry" value="{$setup_db_sugarsales_password}" />
            <input type="hidden" name="setup_db_sugarsales_password" value="{$setup_db_sugarsales_password}" />
        </div>
        <div class="clear"></div>
        <div class="formrow">
            <label>{$mod_strings['LBL_DBCONF_DB_PASSWORD2']}</label>
            <input type="password" name="setup_db_sugarsales_password_retype_entry" value="{$setup_db_sugarsales_password_retype}"  />
            <input type="hidden" name="setup_db_sugarsales_password_retype" value="{$setup_db_sugarsales_password_retype}" />
        </div>
    </span>
</div>

EOQ2;
        }
        $out = $out2;
        // ------ siteConfig_a.php
        $out .= <<<EOQ
        </div>
    </div>
    <div class="floatbox" id="fb6">
                    <h2>{$mod_strings['LBL_SITECFG_TITLE']}</h2>
                    <div class="form_section">
                    <p>{$errors}</p>
                    <div class="required">{$mod_strings['LBL_REQUIRED']}</div>

                    <h3>{$mod_strings['LBL_SITECFG_TITLE2']}<div class="tooltip-toggle"><em> i </em><div class="tooltip">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</div></div></h3>
EOQ;
        //hide this in typical mode
        if (!empty($_SESSION['install_type']) && strtolower($_SESSION['install_type']) == 'custom') {
            $out .= <<<EOQ
<div class='install_block'>
    {$mod_strings['LBL_SITECFG_URL_MSG']}
    <span class="required">*</span>
    <label><b>{$mod_strings['LBL_SITECFG_URL']}</b></label>
    <input type="text" name="setup_site_url" value="{$_SESSION['setup_site_url']}" size="40" />
    <br>{$mod_strings['LBL_SITECFG_SYS_NAME_MSG']}
    <span class="required">*</span>
    <label><b>{$mod_strings['LBL_SYSTEM_NAME']}</b></label>
    <input type="text" name="setup_system_name" value="{$_SESSION['setup_system_name']}" size="40" /><br>
</div>
EOQ;
            $db = getDbConnection();
            if ($db->supports("collation")) {
                $collationOptions = $db->getCollationList();
            }
            if (!empty($collationOptions)) {
                if (isset($_SESSION['setup_db_options']['collation'])) {
                    $default = $_SESSION['setup_db_options']['collation'];
                } else {
                    $default = $db->getDefaultCollation();
                }
                $options = get_select_options_with_id(array_combine($collationOptions, $collationOptions), $default);
                $out .= <<<EOQ
     <div class='install_block'>
        <br>{$mod_strings['LBL_SITECFG_COLLATION_MSG']}
        <span class="required">*</span>
        <label><b>{$mod_strings['LBL_COLLATION']}</b></label>
        <select name="setup_db_collation" id="setup_db_collation">{$options}</select><br>
     </div>
EOQ;
            }
        }
        $help_url = get_help_button_url();
        if (!isset($_SESSION['email1'])) {
            $_SESSION['email1'] = null;
        }
        if (!isset($_SESSION['setup_site_admin_user_name'])) {
            $_SESSION['setup_site_admin_user_name'] = null;
        }
        $out .= <<<EOQ
<div class='install_block'>
    <!--
    <p class="ibmsg">{$mod_strings['LBL_SITECFG_PASSWORD_MSG']}</p>
    -->
    <div class="formrow big">
        <label>{$mod_strings['LBL_SITECFG_ADMIN_Name']} <span class="required">*</span></label>
        <input type="text" name="setup_site_admin_user_name" value="{$_SESSION['setup_site_admin_user_name']}" size="20" maxlength="60" />
    </div>

    <div class="clear"></div>

    <div class="formrow big">
        <label>{$mod_strings['LBL_SITECFG_ADMIN_PASS']} <span class="required">*</span></label>
        <input type="password" name="setup_site_admin_password" value="{$_SESSION['setup_site_admin_password']}" size="20" />
    </div>

    <div class="clear"></div>

    <div class="formrow big">
        <label>{$mod_strings['LBL_SITECFG_ADMIN_PASS_2']} <span class="required">*</span></label>
        <input type="password" name="setup_site_admin_password_retype" value="{$_SESSION['setup_site_admin_password_retype']}" size="20" />
    </div>

    <div class="clear"></div>

    <div class="formrow big">
        <label>{$mod_strings['LBL_SITECFG_URL']} <span class="required">*</span></label>
        <input type="text" name="setup_site_url" value="{$_SESSION['setup_site_url']}" size="40" />
    </div>

    <div class="clear"></div>


    <div class="formrow big">
        <label>{$mod_strings['LBL_EMAIL_ADDRESS']} <span class="required">*</span></label>
        <input type="email" name="email1" value="{$_SESSION['email1']}" size="40" />
    </div>

    <div class="clear"></div>


    <div class="clear"></div>
<!--
    <a href="javascript:;" onclick="\$('.security-block').toggle();">More..</a><br/><br/>
-->
EOQ;
        $out .= <<<EOQ
</div>
EOQ;
        $out .= <<<EOQ
EOQ;
        // ------------------
        //  Choose Demo Data
        // ------------------------->
        //demo data select
        $demoDD = "<select name='demoData' id='demoData' class='select'><option value='no' >" . $mod_strings['LBL_NO'] . "</option><option value='yes'>" . $mod_strings['LBL_YES'] . "</option>";
        $demoDD .= "</select>";
        $out .= <<<EOQ3
        </div>
        </div>

        <div class="floatbox full" id="fb0">
            <h2>{$mod_strings['LBL_MORE_OPTIONS_TITLE']}</h2>
        </div>

        <div class="floatbox full" id="fb1">
            <div class="install_block">
                <h3 onclick="\$(this).next().toggle();" class="toggler">&raquo; {$mod_strings['LBL_DBCONF_DEMO_DATA_TITLE']}</h3>

                <div class="form_section" style="display: none;">
                <div class="clear"></div>
                    <div class="formrow big">
                        <label>{$mod_strings['LBL_DBCONF_DEMO_DATA']}</label>
                        {$demoDD}
                    </div>
                </div>
            </div>
        </div>
EOQ3;
        // ------------------
        //  Choose Scenarios
        // ------------------------->
        $scenarioSelection = "<p class='ibmsg'>{$mod_strings['LBL_WIZARD_SCENARIO_EMPTY']}</p>";
        if (isset($_SESSION['installation_scenarios']) && !empty($_SESSION['installation_scenarios'])) {
            $scenarioSelection = "";
            foreach ($_SESSION['installation_scenarios'] as $scenario) {
                $key = $scenario['key'];
                $description = $scenario['description'];
                $scenarioModuleList = implode($scenario['modulesScenarioDisplayName'], ',');
                $title = $scenario['title'];
                $scenarioSelection .= "<input type='checkbox' name='scenarios[]' value='{$key}' checked><b>{$title}</b>.  {$description} ({$scenarioModuleList}).<br>";
            }
        }
        $out .= <<<EOQ

        <!-- Scenario Selection -->
        <div class="floatbox full" id="fb3">
            <h3 onclick="\$(this).next().toggle();" class="toggler">&raquo; {$mod_strings['LBL_WIZARD_SCENARIO_TITLE']}</h3>
            <div class="form_section" style="display: none;">
                <p class="ibmsg">{$mod_strings['LBL_WIZARD_SCENARIO_DESC']}</p>
                <div class="formrow">{$scenarioSelection}</div>
                <div class="clear"></div>
            </div>
        </div>

EOQ;
        //--End of scenarios
        //---------------
        // SMTP Settings
        //-------------------->
        // smtp
        // TODO-t: test it for all types
        $MAIL_SSL_OPTIONS_GMAIL = get_select_options_with_id($app_list_strings['email_settings_for_ssl'], '2');
        //$MAIL_SSL_OPTIONS_YAHOO = get_select_options_with_id($app_list_strings['email_settings_for_ssl'], '1');
        $MAIL_SSL_OPTIONS_EXCHG = get_select_options_with_id($app_list_strings['email_settings_for_ssl'], 'none');
        $MAIL_SSL_OPTIONS_OTHER = get_select_options_with_id($app_list_strings['email_settings_for_ssl'], 'none');
        // set default notify_allow_default_outbound checkbox value
        $notify_allow_default_outbound_checked = empty($_SESSION['notify_allow_default_outbound']) ? '' : ' checked="checked" ';
        // set default smtp toggle buttons selected value
        if (empty($_SESSION['smtp_tab_selected'])) {
            $_SESSION['smtp_tab_selected'] = 'smtp_tab_other';
        }
        $out .= <<<EOQ
        <div class="floatbox full" id="fb2">
            <!-- smtp settings -->
            <h3 onclick="\$(this).next().toggle();" class="toggler">&raquo; {$mod_strings['LBL_MAIL_SMTP_SETTINGS']}</h3>
            <div style="display: none;">

            <br>
            <!--
            <p>{$mod_strings['LBL_WIZARD_SMTP_DESC']}</p>
            -->

            <!-- smtp types toggler buttons -->

            <p style="display: inline;">{$mod_strings['LBL_CHOOSE_EMAIL_PROVIDER']} </p><div class="tooltip-toggle"> <em>i</em> <div class="tooltip">{$mod_strings['LBL_WIZARD_SMTP_DESC']}</div></div>
            <div class="clear"></div>
            <div>
                <input type="button" class="smtp_tab_toggler" id="smtp_tab_gmail_toggler" for="smtp_tab_gmail" value="{$mod_strings['LBL_SMTPTYPE_GMAIL']}" />
                <input type="button" class="smtp_tab_toggler" id="smtp_tab_yahoo_toggler" for="smtp_tab_yahoo" value="{$mod_strings['LBL_SMTPTYPE_YAHOO']}" />
                <input type="button" class="smtp_tab_toggler" id="smtp_tab_exchange_toggler" for="smtp_tab_exchange" value="{$mod_strings['LBL_SMTPTYPE_EXCHANGE']}" />
                <input type="button" class="smtp_tab_toggler selected" id="smtp_tab_other_toggler" for="smtp_tab_other" value="{$mod_strings['LBL_SMTPTYPE_OTHER']}" />
                <input type="hidden" name="smtp_tab_selected" value="{$_SESSION['smtp_tab_selected']}">
            </div>
            <!-- smtp / gmail tab -->

            <div class="form_section smtp_tab" id="smtp_tab_gmail">

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPSERVER']}</label>
                    <input type="text" name="smtp_tab_gmail[mail_smtpserver]" size="25" maxlength="64" value="smtp.gmail.com">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPPORT']}</label>
                    <input type="text" name="smtp_tab_gmail[mail_smtpport]" size="5" maxlength="5" value="587">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPAUTH_REQ']}</label>
                    <input type="checkbox" name="smtp_tab_gmail[mail_smtpauth_req]" id="smtp_tab_gmail__mail_smtpauth_req" value="1" checked="checked" onclick="toggleSMTPAuthSettings(this, 'toggleArea_1');">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_EMAIL_SMTP_SSL_OR_TLS']}</label>
                    <select name="smtp_tab_gmail[mail_smtpssl]">
                        {$MAIL_SSL_OPTIONS_GMAIL}
                    </select>
                </div>

                <div class="clear"></div>


                <div class="toggleArea" id="toggleArea_1">
                <div class="formrow">
                    <label>{$mod_strings['LBL_GMAIL_SMTPUSER']}</label>
                        <input type="text" name="smtp_tab_gmail[mail_smtpuser]" id="smtp_tab_gmail__mail_smtpuser" size="25" maxlength="64">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_GMAIL_SMTPPASS']}</label>
                        <input type="password" name="smtp_tab_gmail[mail_smtppass]" id="smtp_tab_gmail__mail_smtppass" size="25" maxlength="64" value="" tabindex="1">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION']} <i>i<div class="tooltip">{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION_HELP']}</div></i></label>
                        <input name="smtp_tab_gmail[notify_allow_default_outbound]" id="smtp_tab_gmail__notify_allow_default_outbound" value="2" tabindex="1" class="checkbox" type="checkbox" {$notify_allow_default_outbound_checked}>
                    </div>
                </div>

                <div class="clear"></div>
            </div>

            <!-- smtp / yahoo! mail tab -->

            <div class="form_section smtp_tab" id="smtp_tab_yahoo">

                <input type="hidden" name="smtp_tab_yahoo[mail_smtpserver]" size="25" maxlength="64" value="smtp.mail.yahoo.com">
                <input type="text" name="smtp_tab_yahoo[mail_smtpport]" size="5" maxlength="5" value="465">
                <input type="hidden" name="smtp_tab_yahoo[mail_smtpssl]" value="1">

                <div class="formrow">
                    <label>{$mod_strings['LBL_YAHOOMAIL_SMTPUSER']}</label>
                    <input type="text" name="smtp_tab_yahoo[mail_smtpuser]" size="25" maxlength="64">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_YAHOOMAIL_SMTPPASS']}</label>
                    <input type="password" name="smtp_tab_yahoo[mail_smtppass]" size="25" maxlength="64" value="" tabindex="1">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION']} <i>i<div class="tooltip">{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION_HELP']}</div></i></label>
                    <input name="smtp_tab_yahoo[notify_allow_default_outbound]" value="2" tabindex="1" class="checkbox" type="checkbox" {$notify_allow_default_outbound_checked}>
                </div>

                <div class="clear"></div>
            </div>

            <!-- smtp / ms-exchange tab -->

            <div class="form_section smtp_tab" id="smtp_tab_exchange">

                <div class="formrow">
                    <label>{$mod_strings['LBL_EXCHANGE_SMTPSERVER']}</label>
                    <input type="text" name="smtp_tab_exchange[mail_smtpserver]" size="25" maxlength="64" value="">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_EXCHANGE_SMTPPORT']}</label>
                    <input type="text" name="smtp_tab_exchange[mail_smtpport]" size="5" maxlength="5" value="25">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPAUTH_REQ']}</label>
                    <input type="checkbox" name="smtp_tab_exchange[mail_smtpauth_req]" id="smtp_tab_exchange__mail_smtpauth_req" value="1" checked="checked" onclick="toggleSMTPAuthSettings(this, 'toggleArea_2');">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_EMAIL_SMTP_SSL_OR_TLS']}</label>
                    <select name="smtp_tab_exchange[mail_smtpssl]" tabindex="501">
                        {$MAIL_SSL_OPTIONS_EXCHG}
                    </select>
                </div>

                <div class="clear"></div>

                <div class="toggleArea" id="toggleArea_2">
                <div class="formrow">
                    <label>{$mod_strings['LBL_EXCHANGE_SMTPUSER']}</label>
                        <input type="text" name="smtp_tab_exchange[mail_smtpuser]" id="smtp_tab_exchange__mail_smtpuser" size="25" maxlength="64">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_EXCHANGE_SMTPPASS']}</label>
                        <input type="password" name="smtp_tab_exchange[mail_smtppass]" id="smtp_tab_exchange__mail_smtppass" size="25" maxlength="64" value="" tabindex="1">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION']} <i>i<div class="tooltip">{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION_HELP']}</div></i></label>
                        <input name="smtp_tab_exchange[notify_allow_default_outbound]" id="smtp_tab_exchange__notify_allow_default_outbound" value="2" tabindex="1" class="checkbox" type="checkbox" {$notify_allow_default_outbound_checked}>
                    </div>
                </div>

                <div class="clear"></div>
            </div>

            <!-- smtp / other tab-->

            <div class="form_section smtp_tab" id="smtp_tab_other">

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPSERVER']}</label>
                    <input type="text" name="smtp_tab_other[mail_smtpserver]" size="25" maxlength="64" value="">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPPORT']}</label>
                    <input type="text" name="smtp_tab_other[mail_smtpport]" size="5" maxlength="5" value="25">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPAUTH_REQ']}</label>
                    <input type="hidden" name="smtp_tab_other[mail_smtpauth_req]" value="0">
                    <input type="checkbox" id="mail_smtpauth_req_chk" name="smtp_tab_other[mail_smtpauth_req]" value="1" checked="checked" onclick="toggleSMTPAuthSettings(this, 'toggleArea_3');">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_EMAIL_SMTP_SSL_OR_TLS']}</label>
                    <select name="smtp_tab_other[mail_smtpssl]" tabindex="501">
                        {$MAIL_SSL_OPTIONS_OTHER}
                    </select>
                </div>

                <div class="clear"></div>

                <div class="toggleArea" id="toggleArea_3">
                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPUSER']}</label>
                        <input type="text" name="smtp_tab_other[mail_smtpuser]" id="smtp_tab_other__mail_smtpuser" size="25" maxlength="64">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_MAIL_SMTPPASS']}</label>
                        <input type="password" name="smtp_tab_other[mail_smtppass]" id="smtp_tab_other__mail_smtppass" size="25" maxlength="64" value="" tabindex="1">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION']} <i>i<div class="tooltip">{$mod_strings['LBL_ALLOW_DEFAULT_SELECTION_HELP']}</div></i></label>
                    <input type="hidden" name="smtp_tab_other[notify_allow_default_outbound]" value="0">
                    <input id="notify_allow_default_outbound_chk" name="smtp_tab_other[notify_allow_default_outbound]" value="2" tabindex="1" class="checkbox" type="checkbox" {$notify_allow_default_outbound_checked}>
                </div>
                </div>

                <div class="clear"></div>
            <!-- </div> -->

            <!-- smtp default values & tabs toggler js & tooltip help -->

            <script>

                var toggleSMTPAuthFields = {
                    toggleArea_1 : {
                        user: '******',
                        pass: '******',
                        allow: 'smtp_tab_gmail__notify_allow_default_outbound'
                    },
                    toggleArea_2 : {
                        user: '******',
                        pass: '******',
                        allow: 'smtp_tab_exchange__notify_allow_default_outbound'
                    },
                    toggleArea_3 : {
                        user: '******',
                        pass: '******',
                        allow: 'notify_allow_default_outbound_chk'
                    }
                };

                var toggleSMTPAuthSettings = function(chkbox, elemID) {
                    if(\$(chkbox).prop('checked')) {
                        \$('#' + elemID).show();
                    }
                    else {
                        \$('#' + toggleSMTPAuthFields[elemID].user).val('');
                        \$('#' + toggleSMTPAuthFields[elemID].pass).val('');
                        \$('#' + toggleSMTPAuthFields[elemID].allow).prop('checked', false);
                        \$('#' + elemID).hide();
                    }
                };

                \$(function(){

                    \$('.smtp_tab_toggler').click(function(){
                        \$('.smtp_tab_toggler.selected').removeClass('selected');
                        \$(this).addClass('selected');
                        \$('.smtp_tab').hide();
                        \$('#'+\$(this).attr('for')).show();
                        \$('input[name="smtp_tab_selected"]').val(\$(this).attr('for'));
                    });

                    // save last selected tab and set as default when form (re)load
                    \$('#{$_SESSION['smtp_tab_selected']}_toggler').click();

                    \$('select[name="smtp_tab_gmail[mail_smtpssl]"] option').each(function(){
                        if(!\$(this).html()) {
                            \$(this).html('-none-');
                        }
                    });
                    \$('select[name="smtp_tab_yahoo[mail_smtpssl]"] option').each(function(){
                        if(!\$(this).html()) {
                            \$(this).html('-none-');
                        }
                    });
                    \$('select[name="smtp_tab_exchange[mail_smtpssl]"] option').each(function(){
                        if(!\$(this).html()) {
                            \$(this).html('-none-');
                        }
                    });
                    \$('select[name="smtp_tab_other[mail_smtpssl]"] option').each(function(){
                        if(!\$(this).html()) {
                            \$(this).html('-none-');
                        }
                    });


                    toggleSMTPAuthSettings(document.getElementById('smtp_tab_gmail__mail_smtpauth_req'), 'toggleArea_1');
                    toggleSMTPAuthSettings(document.getElementById('smtp_tab_exchange__mail_smtpauth_req'), 'toggleArea_2');
                    toggleSMTPAuthSettings(document.getElementById('mail_smtpauth_req_chk'), 'toggleArea_3');

                });
            </script>

            </div> <!-- toggle hidden box end -->
EOQ;
        // db setup (dbConfig_a.php)
        $out2 = <<<EOQ2
            <input type='hidden' name='setup_db_drop_tables' id='setup_db_drop_tables' value=''>
        </div>
EOQ2;
        // ----------
        //  Branding
        // ------------->
        // company logo
        $currentLogoLink = SugarThemeRegistry::current()->getImageURL('company_logo.png');
        // show logo if we have
        $hiddenLogo = '';
        if (!file_exists($currentLogoLink)) {
            $hiddenLogo = 'display:none;';
        }
        // TODO--low: check the tooltip text at the logo image!
        $out .= <<<EOQ

            <!-- Branding  -->
            </div>
        </div>
        <div class="floatbox full" id="fb3">
            <h3 onclick="\$(this).next().toggle();" class="toggler">&raquo; {$mod_strings['LBL_WIZARD_SYSTEM_TITLE']}</h3>

            <div class="form_section" style="display: none;">

                <p class="ibmsg">{$mod_strings['LBL_WIZARD_SYSTEM_DESC']}</p>

                <p class="ibmsg">{$mod_strings['LBL_SITECFG_SYS_NAME_MSG']}</p>

                <div class="formrow">
                    <label>{$mod_strings['SYSTEM_NAME_WIZARD']} <i>i<div class="tooltip">{$mod_strings['SYSTEM_NAME_HELP']}</div></i></label>
                    <input type="text" name="setup_system_name" size="25" maxlength="64" value="{$_SESSION['setup_system_name']}">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <!-- file upload -->
                    <label>{$mod_strings['NEW_LOGO']} <i>i<div class="tooltip">{$mod_strings['NEW_LOGO_HELP']}</div></i></label>
                    <input type="file" name="company_logo" id="company_logo">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>&nbsp;</label>
                    <input type="button" name="company_logo_upload_btn" value="{$mod_strings['COMPANY_LOGO_UPLOAD_BTN']}" onclick="onUploadImageClick(this);">
                </div>


                <div class="clear"></div>

                <div class="formrow" id="current_logo_row">
                    <label>{$mod_strings['CURRENT_LOGO']} <i>i<div class="tooltip">{$mod_strings['CURRENT_LOGO_HELP']}</div></i> </label>
                    <img height="100" src="{$currentLogoLink}" alt="Company Logo" style="max-height: 100px; max-width: 230px; float:left; {$hiddenLogo}" />
                </div>

                <div class="clear"></div>
            </div>

EOQ;
        // System location defaults
        // TODO--low: 1000s sep, Decimal Symb, Name Format
        $defaultDateFormatSelect = self::getSelect('default_date_format', $sugarConfigDefaults['date_formats'], empty($_SESSION['default_date_format']) ? $sugarConfigDefaults['default_date_format'] : $_SESSION['default_date_format']);
        $defaultTimeFormatSelect = self::getSelect('default_time_format', $sugarConfigDefaults['time_formats'], empty($_SESSION['default_time_format']) ? 'h:ia' : $_SESSION['default_time_format']);
        $timezoneSelect = self::getSelect('timezone', array_merge(array(TimeDate::guessTimezone() => TimeDate::guessTimezone()), TimeDate::getTimezoneList()), TimeDate::guessTimezone());
        //$defaultLanguageSelect = get_select_options_with_id($supportedLanguages, $current_language);
        $defaultLanguageSelect = self::getSelect('default_language', $supportedLanguages, $current_language);
        // example name formats (its are in the original language file so may this functionality was there in the original sugarcrm installer also)
        $nonDBLocalization = new NonDBLocalization();
        $sugarConfigDefaults['name_formats'] = $nonDBLocalization->getUsableLocaleNameOptions($sugarConfigDefaults['name_formats']);
        $defaultLocalNameFormatSelect = self::getSelect('default_locale_name_format', $sugarConfigDefaults['name_formats'], empty($_SESSION['default_locale_name_format']) ? $sugarConfigDefaults['default_locale_name_format'] : $_SESSION['default_locale_name_format']);
        $out .= <<<EOQ
        </div>
            <!-- System Local Settings  -->
            <!-- TODO--low: add the time-zone settings here!! -->
        <div class="floatbox full" id="fb4">
            <h3 onclick="\$(this).next().toggle();" class="toggler">&raquo; {$mod_strings['LBL_LOCALE_TITLE']}</h3>

            <div class="form_section" style="display: none;">

                <p class="ibmsg">{$mod_strings['LBL_WIZARD_LOCALE_DESC']}</p>

                <div class="formrow">
                    <label>{$mod_strings['LBL_DATE_FORMAT']}</label>
                    {$defaultDateFormatSelect}
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_TIME_FORMAT']}</label>
                    {$defaultTimeFormatSelect}
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_TIMEZONE']}</label>
                    {$timezoneSelect}
                </div>

                <div class="clear"></div>

                <div class="formrow" style="display: none;">
                    <label>{$mod_strings['LBL_LANGUAGE']}</label>
                    {$defaultLanguageSelect}
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_CURRENCY']}</label>
                    <input type="text" name="default_currency_name" value="{$sugarConfigDefaults['default_currency_name']}">
                </div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_CURRENCY_SYMBOL']}</label>
                    <input type="text" name="default_currency_symbol" size="4" value="{$sugarConfigDefaults['default_currency_symbol']}">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_CURRENCY_ISO4217']}</label>
                    <input type="text" name="default_currency_iso4217" size="4" value="{$sugarConfigDefaults['default_currency_iso4217']}">
                </div>

                <!--
                <div class="formrow">
                    <label>{$mod_strings['LBL_NUMBER_GROUPING_SEP']}</label>
                    <input type="text" name="default_number_grouping_seperator" size="3" maxlength="1" value="{$sugarConfigDefaults['default_number_grouping_seperator']}">
                </div>


                <div class="formrow">
                    <label>{$mod_strings['LBL_DECIMAL_SEP']}</label>
                    <input type="text" name="default_decimal_seperator" size="3" maxlength="1" value="{$sugarConfigDefaults['default_decimal_seperator']}">
                </div>

                <div class="clear"></div>

                <div class="formrow">
                    <label>{$mod_strings['LBL_NAME_FORMAT']}</label>
                    {$defaultLocalNameFormatSelect}
                </div>
                -->

                <div class="clear"></div>
            </div>
        </div>

EOQ;
        $out .= "<div class=\"floatbox full\">";
        $out .= "    <h3 onclick=\"\$(this).next().toggle();\" class=\"toggler\">&raquo; {$mod_strings['LBL_SITECFG_SECURITY_TITLE']}</h3>";
        $out .= <<<EOQ

<div class="security-block" style="display:none;">
<table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
      <tr><td colspan="2" id="help"><!-- <a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a> --></td></tr>
    <tr>
      <th width="500">
   </th>
   <th width="200" style="text-align: right;">&nbsp;</th>
   </tr>
<tr>
    <td colspan="2">
    {$errors}
   <div class="required">{$mod_strings['LBL_REQUIRED']}</div>
   <table width="100%" cellpadding="0" cellpadding="0" border="0" class="StyleDottedHr">
   <tr><th colspan="3" align="left">{$mod_strings['LBL_SITECFG_SITE_SECURITY']}</td></tr>

EOQ;
        $checked = '';
        //if(!empty($_SESSION['setup_site_sugarbeet_anonymous_stats'])) $checked = 'checked=""';
        $out .= "\n   <tr style='display:none'><td></td>\n       <td><input type='checkbox' class='checkbox' name='setup_site_sugarbeet_anonymous_stats' value='yes' {$checked} /></td>\n       <td><b>{$mod_strings['LBL_SITECFG_ANONSTATS']}</b><br><i>{$mod_strings['LBL_SITECFG_ANONSTATS_DIRECTIONS']}</i></td></tr>\n\n";
        $checked = '';
        //if(!empty($_SESSION['setup_site_sugarbeet_automatic_checks'])) $checked = 'checked=""';
        $out .= <<<EOQ
   <tr style='display:none'><td></td>
       <td><input type="checkbox" class="checkbox" name="setup_site_sugarbeet_automatic_checks" value="yes" /></td>
       <td><b>{$mod_strings['LBL_SITECFG_SUGAR_UP']}</b><br><i>{$mod_strings['LBL_SITECFG_SUGAR_UP_DIRECTIONS']}</i><br>&nbsp;</td></tr>
   <tbody id="setup_site_session_section_pre">
   <tr><td></td>
       <td><input type="checkbox" class="checkbox" name="setup_site_custom_session_path" value="yes" onclick="javascript:\$('#setup_site_session_section').toggle();" {$customSession} /></td>
       <td><b>{$mod_strings['LBL_SITECFG_CUSTOM_SESSION']}</b><br>
            <em>{$mod_strings['LBL_SITECFG_CUSTOM_SESSION_DIRECTIONS']}</em><br>&nbsp;</td>
   </tr>
   </tbody>
   <tbody id="setup_site_session_section" {$customSessionHidden}>
   <tr><td></td>
       <td style="text-align : right;"></td>
       <td align="left">
\t       <div><div style="width:200px;float:left">{$mod_strings['LBL_SITECFG_SESSION_PATH']} <span class="required">*</span></div>
\t               <input type="text" name="setup_site_session_path" size='40' value="{$_SESSION['setup_site_session_path']}" /></td>
\t       </div>
       </td>
   </tr>
   </tbody>
   <tbody id="setup_site_log_dir_pre">
   <tr><td></td>
       <td><input type="checkbox" class="checkbox" name="setup_site_custom_log_dir" value="yes" onclick="javascript:\$('#setup_site_log_dir').toggle();" {$customLog} /></td>
       <td><b>{$mod_strings['LBL_SITECFG_CUSTOM_LOG']}</b><br>
            <em>{$mod_strings['LBL_SITECFG_CUSTOM_LOG_DIRECTIONS']}</em><br>&nbsp;</td>
   </tr>
   </tbody>
   <tbody id="setup_site_log_dir" {$customLogHidden}>
   <tr><td></td>
       <td style="text-align : right;" ></td>
       <td align="left">
       <div><div style="width:200px;float:left">{$mod_strings['LBL_SITECFG_LOG_DIR']} <span class="required">*</span></div>
            <input type="text" name="setup_site_log_dir" size='30' value="{$_SESSION['setup_site_log_dir']}" />
       </div>
   </tr>
   </tbody>
   <tbody id="setup_site_guid_section_pre">
   <tr><td></td>
       <td><input type="checkbox" class="checkbox" name="setup_site_specify_guid" value="yes" onclick="javascript:\$('#setup_site_guid_section').toggle();" {$customId} /></td>
       <td><b>{$mod_strings['LBL_SITECFG_CUSTOM_ID']}</b><br>
            <em>{$mod_strings['LBL_SITECFG_CUSTOM_ID_DIRECTIONS']}</em><br>&nbsp;</td>
   </tr>
   </tbody>
   <tbody id="setup_site_guid_section" {$customIdHidden}>
   <tr><td></td>
       <td style="text-align : right;"></td>
       <td align="left">
\t       <div><div style="width:200px;float:left">{$mod_strings['LBL_SITECFG_APP_ID']} <span class="required">*</span></div>
\t               <input type="text" name="setup_site_guid" size='30' value="{$_SESSION['setup_site_guid']}" />
\t       </div>
       </td>
   </tr>
   </tbody>
</table>
</td>
</tr>
</table>
</div>
EOQ;
        $out .= "</div>";
        return $out;
    }
Example #5
0
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 IIS and FastCGI
    $server_software = $_SERVER["SERVER_SOFTWARE"];
    if (strpos($_SERVER["SERVER_SOFTWARE"], 'Microsoft-IIS') !== false && php_sapi_name() == 'cgi-fcgi' && ini_get('fastcgi.logging') != '0') {
        installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']);
        $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
        $error_found = true;
        $error_txt .= '
            <p><b>' . $mod_strings['LBL_CHECKSYS_FASTCGI'] . '</b></p>
            <p ><span class="error">' . $iisVersion . '</span></p>
    ';
    }
    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 .= '
            <p><b>' . $mod_strings['LBL_CHECKSYS_IISVER'] . '</b></p>
            <p><span class="error">' . $iisVersion . '</span></p>
        ';
        } 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 .= '
            <p><b>' . $mod_strings['LBL_CHECKSYS_FASTCGI'] . '</b></p>
            <p><span class="error">' . $iisVersion . '</span></p>
        ';
            } else {
                if (ini_get('fastcgi.logging') != '0') {
                    installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING'] . ' ' . $iis_version);
                    $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
                    $error_found = true;
                    $error_txt .= '
            <p><b>' . $mod_strings['LBL_CHECKSYS_FASTCGI'] . '</b></p>
            <p ><span class="error">' . $iisVersion . '</span></p>
        ';
                }
            }
        }
    }
    // 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 .= '
            <p><b>' . $mod_strings['LBL_CHECKSYS_PHPVER'] . '</b></p>
            <p><span class="error">' . $phpVersion . '</span></p>
        ';
    }
    //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>
        <p><b>Php Backward Compatibility</b></p>
        <p><span class="error">' . $phpCompatibility . '</span></p>
    ';
    }
    // database and connect
    if (!empty($_REQUEST['setup_db_type'])) {
        $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
    }
    $drivers = DBManagerFactory::getDbDrivers();
    if (empty($drivers)) {
        $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 .= '
        <p><strong>' . $db_name . '</strong></p>
        <p class="error">' . $dbStatus . '</p>
    ';
    }
    // 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 .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_XML'] . '</strong></p>
        <p class="error">' . $xmlStatus . '</p>
    ';
    } 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 .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_MBSTRING'] . '</strong></p>
        <p class="error">' . $mbstringStatus . '</p>
    ';
    } else {
        installLog("MBString Support Found");
    }
    // zip
    if (!class_exists('ZipArchive')) {
        $zipStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_ZIP']}</font></b>";
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_ZIP']}");
    } else {
        installLog("ZIP 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 .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_CONFIG'] . '</strong></p>
        <p class="error">' . $configStatus . '</p>
    ';
    }
    // config_override.php
    if (file_exists('./config_override.php') && (!make_writable('./config_override.php') || !is_writable('./config_override.php'))) {
        installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CONFIG_OVERRIDE_NOT_WRITABLE']}");
        $configStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CONFIG_OVERRIDE_NOT_WRITABLE']}</span></b>";
        $error_found = true;
        $error_txt .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_OVERRIDE_CONFIG'] . '</strong></p>
        <p class="error">' . $configStatus . '</p>
    ';
    }
    // 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 .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_CUSTOM'] . '</strong></p>
        <p class="error">' . $customStatus . '</p>
    ';
    } else {
        installLog("/custom directory and subdirectory check passed");
    }
    // cache dir
    $cache_files[] = '';
    $cache_files[] = 'images';
    $cache_files[] = 'layout';
    $cache_files[] = 'pdf';
    $cache_files[] = 'xml';
    $cache_files[] = 'include/javascript';
    $filelist = '';
    foreach ($cache_files as $c_file) {
        $dirname = sugar_cached($c_file);
        $ok = false;
        if (is_dir($dirname) || @sugar_mkdir($dirname, 0755, true)) {
            $ok = make_writable($dirname);
        }
        if (!$ok) {
            $filelist .= '<br>' . getcwd() . "/{$dirname}";
        }
    }
    if (strlen($filelist) > 0) {
        $error_found = true;
        installLog("ERROR:: Some subdirectories in cache subfolder were not read/writeable:");
        installLog($filelist);
        $error_txt .= '
        	<p><strong>' . $mod_strings['LBL_CHECKSYS_CACHE'] . '</strong></p>
        	<p align="right" class="error" class="error"><b><span class="stop">' . $mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE'] . '</span></b>

        	<p><b>' . $mod_strings['LBL_CHECKSYS_FIX_FILES'] . '</b>' . $filelist . '</p>
		';
    } 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 .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_MODULE'] . '</strong></p>
        <p align="right" class="error">' . $moduleStatus . '</p>
    ';
        //list which module directories are not writeable, if there are less than 10
        $error_txt .= '
            <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 .= '
        ';
    } else {
        installLog("/module  directory and subdirectory check passed");
    }
    // check upload dir
    if (!make_writable('./upload')) {
        $uploadStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
        installLog("ERROR: Upload directory is not writable.");
        $error_found = true;
        $error_txt .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_UPLOAD'] . '</strong></p>
        <p align="right" class="error">' . $uploadStatus . '</p>
    ';
    } else {
        installLog("/upload directory check passed");
    }
    // check zip file support
    if (!class_exists("ZipArchive")) {
        $zipStatus = "<span class='stop'><b>{$mod_strings['ERR_CHECKSYS_ZIP']}</b></span>";
        installLog("ERROR: Zip support not found.");
        $error_found = true;
        $error_txt .= '
            <p><strong>' . $mod_strings['LBL_CHECKSYS_ZIP'] . '</strong></p>
            <p  align="right" class="error">' . $zipStatus . '</p>
    ';
    } else {
        installLog("/zip check passed");
    }
    // check PCRE version
    if (defined('PCRE_VERSION')) {
        if (version_compare(PCRE_VERSION, '7.0') < 0) {
            installLog("ERROR: PCRE Version is less than 7.0.");
            $error_found = true;
            $pcreStatus = "<span class='stop'><b>{$mod_strings['ERR_CHECKSYS_PCRE_VER']}</b></span>";
            $error_txt .= '
            <p><strong>' . $mod_strings['LBL_CHECKSYS_PCRE'] . '</strong></p>
            <p  align="right" class="error">' . $pcreStatus . '</p>
        ';
        } else {
            installLog("PCRE version check passed");
        }
    } else {
        installLog("ERROR: PCRE not found.");
        $error_found = true;
        $pcreStatus = "<span class='stop'><b>{$mod_strings['ERR_CHECKSYS_PCRE']}</b></span>";
        $error_txt .= '
        <p><strong>' . $mod_strings['LBL_CHECKSYS_PCRE'] . '</strong></p>
        <p  align="right" class="error">' . $pcreStatus . '</p>
    ';
    }
    $customSystemChecks = installerHook('additionalCustomSystemChecks');
    if ($customSystemChecks != 'undefined') {
        if ($customSystemChecks['error_found'] == true) {
            $error_found = true;
        }
        if (!empty($customSystemChecks['error_txt'])) {
            $error_txt .= $customSystemChecks['error_txt'];
        }
    }
    // 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
    <h2>{$mod_strings['LBL_CHECKSYS_TITLE']}</h2>
      <div width="200" height="30" style="/*float: right;*/">
        <p>{$mod_strings['ERR_CHECKSYS']}</p>
        <hr>
      </div>
        <div id="errorheaders">
            <h2 style="float: right;">{$mod_strings['LBL_CHECKSYS_STATUS']}</h2>
            <h2 style="float: left;">{$mod_strings['LBL_CHECKSYS_COMPONENT']}</h2>
        </div>
        <div id="errormsg">
            <p>{$error_txt}</p>
        </div>
        <div align="center" style="margin: 5px;">
          <i>{$mod_strings['LBL_CHECKSYS_PHP_INI']}<br>{$phpIniLocation}</i>
        </div>
        <hr>
    <div id="installcontrols">
        <form action="install3.php" method="post" name="theForm" id="theForm">
            <input class="button" type="button" onclick="window.open('http://www.suitecrm.com/forum/index');" value="{$mod_strings['LBL_HELP']}" />
            <input class="button" type="button" name="Re-check" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}" onclick="callSysCheck();" id="button_next2"/>
        </form>
    </div>
EOQ;
        return $out;
    } else {
        installLog("Outputting HTML for System check");
        installLog("No Errors were found *************");
        return 'passed';
    }
}