/**
  * A Static method to Build the display for the package manager
  *
  * @param String form1 - the form to display for manual downloading
  * @param String hidden_fields - the hidden fields related to downloading a package
  * @param String form_action - the form_action to be used when downloading from the server
  * @param String types - the types of objects we will request from the server
  * @param String active_form - the form to display first
  * @return String - a string of html which will be used to display the forms
  */
 function buildPackageDisplay($form1, $hidden_fields, $form_action, $types = array('module'), $active_form = 'form1', $install = false)
 {
     global $current_language, $app_strings;
     $app_strings = return_application_language($current_language);
     $ss = new Sugar_Smarty();
     $ss->assign('APP_STRINGS', $app_strings);
     $ss->assign('FORM_1_PLACE_HOLDER', $form1);
     $ss->assign('form_action', $form_action);
     $ss->assign('hidden_fields', $hidden_fields);
     $result = PackageManagerDisplay::getHeader();
     $isAlive = $result['isAlive'];
     $mi = new ModuleInstaller();
     $mi_errors = $mi->getErrors();
     $error_html = "";
     if (!empty($mi_errors)) {
         $error_html = "<div style='margin:0px 10px 10px 10px;'>";
         foreach ($mi_errors as $error) {
             $error_html .= "<font color='red'>" . $error . "</font><br>";
         }
         $error_html .= "</div>";
     }
     $tree = PackageManagerDisplay::buildTreeView('treeview', $isAlive);
     $tree->tree_style = 'vendor/ytree/TreeView/css/check/tree.css';
     $ss->assign('TREEHEADER', $tree->generate_header());
     $ss->assign('installation', $install ? 'true' : 'false');
     $mod_strings = return_module_language($current_language, "Administration");
     $ss->assign('MOD', $mod_strings);
     $ss->assign('module_load', 'true');
     if (UploadStream::getSuhosinStatus() == false) {
         $ss->assign('ERR_SUHOSIN', true);
     } else {
         $ss->assign('scripts', PackageManagerDisplay::getDisplayScript($install));
     }
     $show_login = false;
     //hiding install from sugar
     $ss->assign('MODULE_SELECTOR', PackageManagerDisplay::buildGridOutput($tree, $mod_strings, $isAlive, $show_login));
     $ss->assign('INSTALL_ERRORS', $error_html);
     $ss->assign('MOD', $mod_strings);
     $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED'];
     $ss->assign('INSTALLED_PACKAGES_HOLDER', PackageManagerDisplay::buildInstalledGrid($mod_strings, $types));
     $str = $ss->fetch('ModuleInstall/PackageManager/tpls/PackageForm.tpl');
     return $str;
 }
Esempio n. 2
0
/**
 * checks system compliance for 4.5+ codebase
 * @return array Mixed values
 */
function checkSystemCompliance()
{
    global $sugar_config;
    global $current_language;
    global $db;
    global $mod_strings;
    global $app_strings;
    if (!defined('SUGARCRM_MIN_MEM')) {
        define('SUGARCRM_MIN_MEM', 40);
    }
    $installer_mod_strings = getModuleLanguagePack($current_language, './install');
    $ret = array();
    $ret['error_found'] = false;
    // PHP version
    $php_version = constant('PHP_VERSION');
    $check_php_version_result = check_php_version($php_version);
    switch ($check_php_version_result) {
        case -1:
            $ret['phpVersion'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
            $ret['error_found'] = true;
            break;
        case 0:
            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_PHP_UNSUPPORTED']} {$php_version} )</span></b>";
            break;
        case 1:
            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_PHP_OK']} {$php_version} )</span></b>";
            break;
    }
    // database and connect
    $canInstall = $db->canInstall();
    if ($canInstall !== true) {
        $ret['error_found'] = true;
        if (count($canInstall) == 1) {
            $ret['dbVersion'] = "<b><span class=stop>" . $installer_mod_strings[$canInstall[0]] . "</span></b>";
        } else {
            $ret['dbVersion'] = "<b><span class=stop>" . sprintf($installer_mod_strings[$canInstall[0]], $canInstall[1]) . "</span></b>";
        }
    }
    // XML Parsing
    if (function_exists('xml_parser_create')) {
        $ret['xmlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['xmlStatus'] = "<b><span class=stop>{$installer_mod_strings['LBL_CHECKSYS_NOT_AVAILABLE']}</span></b>";
        $ret['error_found'] = true;
    }
    // cURL
    if (function_exists('curl_init')) {
        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_CURL']}</span></b>";
        $ret['error_found'] = false;
    }
    // mbstrings
    if (function_exists('mb_strlen')) {
        $ret['mbstringStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['mbstringStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_MBSTRING']}</span></b>";
        $ret['error_found'] = true;
    }
    // imap
    if (function_exists('imap_open')) {
        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_IMAP']}</span></b>";
        $ret['error_found'] = false;
    }
    // safe mode
    if ('1' == ini_get('safe_mode')) {
        $ret['safeModeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_SAFE_MODE']}</span></b>";
        $ret['error_found'] = true;
    } else {
        $ret['safeModeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // call time pass by ref
    if ('1' == ini_get('allow_call_time_pass_reference')) {
        $ret['callTimeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_CALL_TIME']}</span></b>";
        //continue upgrading
    } else {
        $ret['callTimeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // memory limit
    $ret['memory_msg'] = "";
    $memory_limit = "-1";
    //ini_get('memory_limit');
    $sugarMinMem = constant('SUGARCRM_MIN_MEM');
    // logic based on: http://us2.php.net/manual/en/ini.core.php#ini.memory-limit
    if ($memory_limit == "") {
        // memory_limit disabled at compile time, no memory limit
        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_OK']}</span></b>";
    } elseif ($memory_limit == "-1") {
        // memory_limit enabled, but set to unlimited
        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_UNLIMITED']}</span></b>";
    } else {
        rtrim($memory_limit, 'M');
        $memory_limit_int = (int) $memory_limit;
        if ($memory_limit_int < constant('SUGARCRM_MIN_MEM')) {
            $ret['memory_msg'] = "<b><span class=\"stop\">{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_1']}" . constant('SUGARCRM_MIN_MEM') . "{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_2']}</span></b>";
            $ret['error_found'] = true;
        } else {
            $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']} ({$memory_limit})</span></b>";
        }
    }
    // zip support
    if (!class_exists("ZipArchive")) {
        $ret['ZipStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_ZIP']}</span></b>";
        $ret['error_found'] = true;
    } else {
        $ret['ZipStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // Suhosin allow to use upload://
    $ret['stream_msg'] = '';
    if (UploadStream::getSuhosinStatus() == true) {
        $ret['stream_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['stream_msg'] = "<b><span class=\"stop\">{$app_strings['ERR_SUHOSIN']}</span></b>";
        $ret['error_found'] = true;
    }
    /* mbstring.func_overload
    	$ret['mbstring.func_overload'] = '';
    	$mb = ini_get('mbstring.func_overload');
    
    	if($mb > 1) {
    		$ret['mbstring.func_overload'] = "<b><span class=\"stop\">{$mod_strings['ERR_UW_MBSTRING_FUNC_OVERLOAD']}</b>";
    		$ret['error_found'] = true;
    	}
    	*/
    return $ret;
}
 /**
  * A Static method to Build the display for the package manager
  *
  * @param String form1 - the form to display for manual downloading
  * @param String hidden_fields - the hidden fields related to downloading a package
  * @param String form_action - the form_action to be used when downloading from the server
  * @param String types - the types of objects we will request from the server
  * @param String active_form - the form to display first
  * @return String - a string of html which will be used to display the forms
  */
 static function buildPackageDisplay($form1, $hidden_fields, $form_action, $types = array('module'), $active_form = 'form1', $install = false)
 {
     global $current_language;
     $mod_strings = return_module_language($current_language, "Administration");
     global $app_strings;
     global $sugar_version, $sugar_config;
     $app_strings = return_application_language($current_language);
     $ss = new Sugar_Smarty();
     $ss->assign('APP_STRINGS', $app_strings);
     $ss->assign('FORM_1_PLACE_HOLDER', $form1);
     $ss->assign('form_action', $form_action);
     $ss->assign('hidden_fields', $hidden_fields);
     $result = PackageManagerDisplay::getHeader();
     $header_text = $result['text'];
     $isAlive = $result['isAlive'];
     $show_login = $result['show_login'];
     $mi_errors = ModuleInstaller::getErrors();
     $error_html = "";
     if (!empty($mi_errors)) {
         $error_html = "<tr><td><span>";
         foreach ($mi_errors as $error) {
             $error_html .= "<font color='red'>" . $error . "</font><br>";
         }
         $error_html .= "</span></td></tr>";
     }
     $form2 = "<table  class='tabForm' width='100%'  cellpadding='0' cellspacing='0' width='100%' border='0'>";
     $form2 .= $error_html;
     if (!$isAlive) {
         $form2 .= "<tr><td><span id='span_display_html'>" . $header_text . "</span></td></tr>";
     }
     $form2 .= "</table>";
     $tree = null;
     //if($isAlive){
     $tree = PackageManagerDisplay::buildTreeView('treeview', $isAlive);
     $tree->tree_style = 'include/ytree/TreeView/css/check/tree.css';
     $ss->assign('TREEHEADER', $tree->generate_header());
     //}
     //$form2 .= PackageManagerDisplay::buildLoginPanel($mod_strings);
     $form2 .= "<table  class='tabForm' cellpadding='0' cellspacing='0' width='100%' border='0'>";
     $form2 .= "<tr><td></td><td align='left'>";
     if ($isAlive) {
         $form2 .= "<input type='button' id='modifCredentialsBtn' class='button' onClick='PackageManager.showLoginDialog(true);' value='" . $mod_strings['LBL_MODIFY_CREDENTIALS'] . "'>";
     } else {
         $form2 .= "<input type='button' id='modifCredentialsBtn' class='button' onClick='PackageManager.showLoginDialog(true);' value='" . $mod_strings['LBL_MODIFY_CREDENTIALS'] . "'style='display:none;'>";
     }
     $form2 .= "</td><td align='left'><div id='workingStatusDiv' style='display:none;'>" . SugarThemeRegistry::current()->getImage("sqsWait", "border='0' align='bottom'", null, null, '.gif', "Loading") . "</div></td><td align='right'>";
     if ($isAlive) {
         $form2 .= "<slot><a class=\"listViewTdToolsS1\" id='href_animate' onClick=\"PackageManager.toggleDiv('span_animate_server_div', 'catview');\"><span id='span_animate_server_div'><img src='" . SugarThemeRegistry::current()->getImageURL('basic_search.gif') . "' width='8' height='8' border='0'>&nbsp;Collapse</span></a></slot>";
     } else {
         $form2 .= "<slot><a class=\"listViewTdToolsS1\" id='href_animate' onClick=\"PackageManager.toggleDiv('span_animate_server_div', 'catview');\"><span id='span_animate_server_div' style='display:none;'><img src='" . SugarThemeRegistry::current()->getImageURL('basic_search.gif') . "' width='8' height='8' border='0'>&nbsp;Collapse</span></a></slot>";
     }
     $form2 .= "</td></tr></table>";
     $form2 = '';
     //Commenting out the form as part of sugar depot hiding.
     $ss->assign('installation', $install ? 'true' : 'false');
     $mod_strings = return_module_language($current_language, "Administration");
     $ss->assign('MOD', $mod_strings);
     $ss->assign('module_load', 'true');
     if (UploadStream::getSuhosinStatus() == false) {
         $ss->assign('ERR_SUHOSIN', true);
     } else {
         $ss->assign('scripts', PackageManagerDisplay::getDisplayScript($install));
     }
     $show_login = false;
     //hiding install from sugar
     $ss->assign('MODULE_SELECTOR', PackageManagerDisplay::buildGridOutput($tree, $mod_strings, $isAlive, $show_login));
     $ss->assign('FORM_2_PLACE_HOLDER', $form2);
     $ss->assign('MOD', $mod_strings);
     $descItemsInstalled = $mod_strings['LBL_UW_DESC_MODULES_INSTALLED'];
     $ss->assign('INSTALLED_PACKAGES_HOLDER', PackageManagerDisplay::buildInstalledGrid($mod_strings, $types));
     $str = $ss->fetch('ModuleInstall/PackageManager/tpls/PackageForm.tpl');
     return $str;
 }
Esempio n. 4
0
}
if ($upload_max_filesize_bytes > constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
    $fileMaxStatus = "{$mod_strings['LBL_CHECKSYS_OK']}</font>";
} else {
    $fileMaxStatus = "<span class='stop'><b>{$mod_strings['ERR_UPLOAD_MAX_FILESIZE']}</font></b></span>";
}
$envString .= '<p><b>' . $mod_strings['LBL_UPLOAD_MAX_FILESIZE_TITLE'] . '</b> ' . $fileMaxStatus . '</p>';
//CHECK Sprite support
if (function_exists('imagecreatetruecolor')) {
    $spriteSupportStatus = "{$mod_strings['LBL_CHECKSYS_OK']}</font>";
} else {
    $spriteSupportStatus = "<span class='stop'><b>{$mod_strings['ERROR_SPRITE_SUPPORT']}</b></span>";
}
$envString .= '<p><b>' . $mod_strings['LBL_SPRITE_SUPPORT'] . '</b> ' . $spriteSupportStatus . '</p>';
// Suhosin allow to use upload://
if (UploadStream::getSuhosinStatus() == true || strpos(ini_get('suhosin.perdir'), 'e') !== false && strpos($_SERVER["SERVER_SOFTWARE"], 'Microsoft-IIS') === false) {
    $suhosinStatus = "{$mod_strings['LBL_CHECKSYS_OK']}";
} else {
    $suhosinStatus = "<span class='stop'><b>{$app_strings['ERR_SUHOSIN']}</b></span>";
}
$envString .= "<p><b>{$mod_strings['LBL_STREAM']} (" . UploadStream::STREAM_NAME . "://)</b> " . $suhosinStatus . "</p>";
// PHP.ini
$phpIniLocation = get_cfg_var("cfg_file_path");
$envString .= '<p><b>' . $mod_strings['LBL_CHECKSYS_PHP_INI'] . '</b> ' . $phpIniLocation . '</p>';
$out = <<<EOQ

<div id="syscred">

EOQ;
$out .= $envString;
$out .= <<<EOQ