2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
39 $_SESSION['setup_license_accept'] = true;
41 function runCheck($install_script = false, $mod_strings){
42 installLog("Begin System Check Process *************");
44 if( !isset( $install_script ) || !$install_script ){
45 installLog("Error:: ".$mod_strings['ERR_NO_DIRECT_SCRIPT']);
46 die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
49 if(!defined('SUGARCRM_MIN_MEM')) {
50 define('SUGARCRM_MIN_MEM', 40);
55 // for keeping track of whether to enable/disable the 'Next' button
60 // check IIS and FastCGI
61 $server_software = $_SERVER["SERVER_SOFTWARE"];
62 if ((strpos($_SERVER["SERVER_SOFTWARE"],'Microsoft-IIS') !== false)
63 && php_sapi_name() == 'cgi-fcgi'
64 && ini_get('fastcgi.logging') != '0')
66 installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']);
67 $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
71 <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
72 <td ><span class="error">'.$iisVersion.'</span></td>
76 if(strpos($server_software,'Microsoft-IIS') !== false)
79 if(preg_match_all("/^.*\/(\d+\.?\d*)$/", $server_software, $out))
80 $iis_version = $out[1][0];
82 $check_iis_version_result = check_iis_version($iis_version);
83 if($check_iis_version_result == -1) {
84 installLog($mod_strings['ERR_CHECKSYS_IIS_INVALID_VER'].' '.$iis_version);
85 $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_IIS_INVALID_VER']} {$iis_version}</span></b>";
89 <td><b>'.$mod_strings['LBL_CHECKSYS_IISVER'].'</b></td>
90 <td ><span class="error">'.$iisVersion.'</span></td>
92 } else if(php_sapi_name() != 'cgi-fcgi')
94 installLog($mod_strings['ERR_CHECKSYS_FASTCGI'].' '.$iis_version);
95 $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI']}</span></b>";
99 <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
100 <td ><span class="error">'.$iisVersion.'</span></td>
102 } else if(ini_get('fastcgi.logging') != '0')
104 installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING'].' '.$iis_version);
105 $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
109 <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
110 <td ><span class="error">'.$iisVersion.'</span></td>
116 $php_version = constant('PHP_VERSION');
117 $check_php_version_result = check_php_version($php_version);
119 if($check_php_version_result == -1) {
120 installLog($mod_strings['ERR_CHECKSYS_PHP_INVALID_VER'].' '.$php_version);
121 $phpVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
125 <td><b>'.$mod_strings['LBL_CHECKSYS_PHPVER'].'</b></td>
126 <td ><span class="error">'.$phpVersion.'</span></td>
131 //Php Backward compatibility checks
132 if(ini_get("zend.ze1_compatibility_mode")) {
133 installLog($mod_strings['LBL_BACKWARD_COMPATIBILITY_ON'].' '.'Php Backward Compatibility');
134 $phpCompatibility = "<b><span class=stop>{$mod_strings['LBL_BACKWARD_COMPATIBILITY_ON']}</span></b>";
138 <td><b>Php Backward Compatibility</b></td>
139 <td ><span class="error">'.$phpCompatibility.'</span></td>
144 // database and connect
146 if (!empty($_REQUEST['setup_db_type']))
147 $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
149 $drivers = DBManagerFactory::getDbDrivers();
151 if( empty($drivers) ){
152 $db_name = $mod_strings['LBL_DB_UNAVAILABLE'];
153 installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}");
154 $dbStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}</span></b>";
158 <td><strong>'.$db_name.'</strong></td>
159 <td class="error">'.$dbStatus.'</td>
164 if(!function_exists('xml_parser_create')) {
165 $xmlStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}</span></b>";
166 installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}");
170 <td><strong>'.$mod_strings['LBL_CHECKSYS_XML'].'</strong></td>
171 <td class="error">'.$xmlStatus.'</td>
174 installLog("XML Parsing Support Found");
179 if(!function_exists('mb_strlen')) {
180 $mbstringStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_MBSTRING']}</font></b>";
181 installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_MBSTRING']}");
185 <td><strong>'.$mod_strings['LBL_CHECKSYS_MBSTRING'].'</strong></td>
186 <td class="error">'.$mbstringStatus.'</td>
189 installLog("MBString Support Found");
193 if(!class_exists('ZipArchive')) {
194 $zipStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_ZIP']}</font></b>";
195 installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_ZIP']}");
197 installLog("ZIP Support Found");
201 if(file_exists('./config.php') && (!(make_writable('./config.php')) || !(is_writable('./config.php')))) {
202 installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}");
203 $configStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}</span></b>";
207 <td><strong>'.$mod_strings['LBL_CHECKSYS_CONFIG'].'</strong></td>
208 <td class="error">'.$configStatus.'</td>
213 if(!make_writable('./custom')) {
214 $customStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}</font></b>";
215 installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}");
219 <td><strong>'.$mod_strings['LBL_CHECKSYS_CUSTOM'].'</strong></td>
220 <td class="error">'.$customStatus.'</td>
223 installLog("/custom directory and subdirectory check passed");
229 $cache_files[] = 'images';
230 $cache_files[] = 'layout';
231 $cache_files[] = 'pdf';
232 $cache_files[] = 'xml';
233 $cache_files[] = 'include/javascript';
236 foreach($cache_files as $c_file)
238 $dirname = sugar_cached($c_file);
240 if ((is_dir($dirname)) || @sugar_mkdir($dirname,0555)) // set permissions to restrictive - use make_writable to change in a standard way to the required permissions
242 $ok = make_writable($dirname);
246 $filelist .= '<br>'.getcwd()."/$dirname";
250 if (strlen($filelist)>0)
253 installLog("ERROR:: Some subdirectories in cache subfolder were not read/writeable:");
254 installLog($filelist);
257 <td><strong>'.$mod_strings['LBL_CHECKSYS_CACHE'].'</strong></td>
258 <td align="right" class="error" class="error"><b><span class="stop">'.$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE'].'</span></b></td>
261 <td colspan="2"><b>'.$mod_strings['LBL_CHECKSYS_FIX_FILES'].'</b>'.$filelist. '</td>
264 installLog("cache directory and subdirectory check passed");
269 $_SESSION['unwriteable_module_files'] = array();
270 //if(!$writeableFiles['ret_val']) {
271 $passed_write = recursive_make_writable('./modules');
272 if (isset($_SESSION['unwriteable_module_files']['failed']) && $_SESSION['unwriteable_module_files']['failed']){
273 $passed_write = false;
278 $moduleStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
279 installLog("ERROR:: Module directories and the files under them are not writeable.");
283 <td><strong>'.$mod_strings['LBL_CHECKSYS_MODULE'].'</strong></td>
284 <td align="right" class="error">'.$moduleStatus.'</td>
287 //list which module directories are not writeable, if there are less than 10
291 <b>'.$mod_strings['LBL_CHECKSYS_FIX_MODULE_FILES'].'</b>';
292 foreach($_SESSION['unwriteable_module_files'] as $key=>$file){
293 if($key !='.' && $key != 'failed'){
294 $error_txt .='<br>'.$file;
302 installLog("/module directory and subdirectory check passed");
306 if (!make_writable('./upload'))
308 $uploadStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
309 installLog("ERROR: Upload directory is not writable.");
313 <td><strong>'.$mod_strings['LBL_CHECKSYS_UPLOAD'].'</strong></td>
314 <td align="right" class="error">'.$uploadStatus.'</td>
317 installLog("/upload directory check passed");
320 // check zip file support
321 if (!class_exists("ZipArchive"))
323 $zipStatus = "<span class='stop'><b>{$mod_strings['ERR_CHECKSYS_ZIP']}</b></span>";
325 installLog("ERROR: Zip support not found.");
329 <td><strong>'.$mod_strings['LBL_CHECKSYS_ZIP'].'</strong></td>
330 <td align="right" class="error">'.$zipStatus.'</td>
333 installLog("/zip check passed");
339 $customSystemChecks = installerHook('additionalCustomSystemChecks');
340 if($customSystemChecks != 'undefined'){
341 if($customSystemChecks['error_found'] == true){
344 if(!empty($customSystemChecks['error_txt'])){
345 $error_txt .= $customSystemChecks['error_txt'];
350 $phpIniLocation = get_cfg_var("cfg_file_path");
351 installLog("php.ini location found. {$phpIniLocation}");
352 // disable form if error found
355 installLog("Outputting HTML for System check");
356 installLog("Errors were found *************");
357 $disabled = $error_found ? 'disabled="disabled"' : '';
359 $help_url = get_help_button_url();
360 ///////////////////////////////////////////////////////////////////////////////
361 //// BEGIN PAGE OUTPUT
364 <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
366 <th width="400">{$mod_strings['LBL_CHECKSYS_TITLE']}</th>
367 <th width="200" height="30" style="text-align: right;"><a href="http://www.sugarcrm.com" target=
368 "_blank"><IMG src="include/images/sugarcrm_login.png" width="145" height="30" alt="SugarCRM" border="0"></a>
369 <br><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a>
374 <td colspan="2" width="600">
375 <p>{$mod_strings['ERR_CHECKSYS']}</p>
377 <table cellpadding="0" cellspacing="0" border="0" width="100%" class="StyleDottedHr">
379 <th align="left">{$mod_strings['LBL_CHECKSYS_COMPONENT']}</th>
380 <th style="text-align: right;">{$mod_strings['LBL_CHECKSYS_STATUS']}</th>
386 <div align="center" style="margin: 5px;">
387 <i>{$mod_strings['LBL_CHECKSYS_PHP_INI']}<br>{$phpIniLocation}</i>
393 <td align="right" colspan="2">
395 <form action="install3.php" method="post" name="theForm" id="theForm">
397 <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
399 <td><input class="button" type="button" onclick="window.open('http://www.sugarcrm.com/forums/');" value="{$mod_strings['LBL_HELP']}" /></td>
401 <input class="button" type="button" name="Re-check" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}" onclick="callSysCheck();" id="button_next2"/>
412 installLog("Outputting HTML for System check");
413 installLog("No Errors were found *************");
419 ///////////////////////////////////////////////////////////////////////////////