]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - install/installSystemCheck.php
Release 6.2.0
[Github/sugarcrm.git] / install / installSystemCheck.php
1 <?php
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-2011 SugarCRM Inc.
6  * 
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.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
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  ********************************************************************************/
37
38
39 $_SESSION['setup_license_accept'] = true;
40
41 function runCheck($install_script = false, $mod_strings){
42 installLog("Begin System Check Process *************");
43
44 if( !isset( $install_script ) || !$install_script ){
45     installLog("Error:: ".$mod_strings['ERR_NO_DIRECT_SCRIPT']);
46     die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
47 }
48
49 if(!defined('SUGARCRM_MIN_MEM')) {
50     define('SUGARCRM_MIN_MEM', 40);
51 }
52
53
54
55 // for keeping track of whether to enable/disable the 'Next' button
56 $error_found = false;
57 $error_txt = '';
58
59
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')
65 {
66     installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']);
67     $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
68     $error_found = true;
69     $error_txt .= '
70           <tr>
71             <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
72             <td ><span class="error">'.$iisVersion.'</span></td>
73           </tr>';
74 }
75
76 if(strpos($server_software,'Microsoft-IIS') !== false)
77 {
78         $iis_version = '';
79         if(preg_match_all("/^.*\/(\d+\.?\d*)$/",  $server_software, $out))
80         $iis_version = $out[1][0];
81
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>";
86                 $error_found = true;
87         $error_txt .= '
88           <tr>
89             <td><b>'.$mod_strings['LBL_CHECKSYS_IISVER'].'</b></td>
90             <td ><span class="error">'.$iisVersion.'</span></td>
91           </tr>';
92         } else if(php_sapi_name() != 'cgi-fcgi')
93         {
94                 installLog($mod_strings['ERR_CHECKSYS_FASTCGI'].' '.$iis_version);
95                 $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI']}</span></b>";
96                 $error_found = true;
97         $error_txt .= '
98           <tr>
99             <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
100             <td ><span class="error">'.$iisVersion.'</span></td>
101           </tr>';
102         } else if(ini_get('fastcgi.logging') != '0')
103     {
104         installLog($mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING'].' '.$iis_version);
105                 $iisVersion = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_FASTCGI_LOGGING']}</span></b>";
106                 $error_found = true;
107         $error_txt .= '
108           <tr>
109             <td><b>'.$mod_strings['LBL_CHECKSYS_FASTCGI'].'</b></td>
110             <td ><span class="error">'.$iisVersion.'</span></td>
111           </tr>';
112     }
113 }
114
115 // PHP VERSION
116 $php_version = constant('PHP_VERSION');
117 $check_php_version_result = check_php_version($php_version);
118
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>";
122         $error_found = true;
123         $error_txt .= '
124           <tr>
125             <td><b>'.$mod_strings['LBL_CHECKSYS_PHPVER'].'</b></td>
126             <td ><span class="error">'.$phpVersion.'</span></td>
127           </tr>';
128
129 }
130
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>";
135     $error_found = true;
136     $error_txt .= '
137       <tr>
138         <td><b>Php Backward Compatibility</b></td>
139         <td ><span class="error">'.$phpCompatibility.'</span></td>
140       </tr>';
141
142 }
143
144 // database and connect
145
146 if (!empty($_REQUEST['setup_db_type']))
147     $_SESSION['setup_db_type'] = $_REQUEST['setup_db_type'];
148
149 $mssqlStatus = '';
150 $dbVersion = '';
151 // Removed php_sqlsrv install support until the driver support is out of beta status
152 $supported_dbs = array("mysql_connect",
153                        "mysqli_connect",
154                        "mssql_connect",
155
156                        "sqlsrv_connect",
157                       );
158 $db_support_exists = false;
159
160 foreach ($supported_dbs as $dbfunct){
161
162     if( function_exists( $dbfunct) ){
163         $db_support_exists = true;
164         installLog("Found at least one supported DB Type");
165         break;
166     }
167 }
168 if( !$db_support_exists ){
169     $db_name = $mod_strings['LBL_DB_UNAVAILABLE'];
170     installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}");
171     $dbStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_DB_SUPPORT_NOT_AVAILABLE']}</span></b>";
172     $error_found = true;
173     $error_txt .= '
174       <tr>
175         <td><strong>'.$db_name.'</strong></td>
176         <td class="error">'.$dbStatus.'</td>
177       </tr>';
178 }
179
180 // XML Parsing
181 if(!function_exists('xml_parser_create')) {
182     $xmlStatus = "<b><span class=stop>{$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}</span></b>";
183     installLog("ERROR:: {$mod_strings['LBL_CHECKSYS_XML_NOT_AVAILABLE']}");
184     $error_found = true;
185     $error_txt .= '
186       <tr>
187         <td><strong>'.$mod_strings['LBL_CHECKSYS_XML'].'</strong></td>
188         <td class="error">'.$xmlStatus.'</td>
189       </tr>';
190 }else{
191     installLog("XML Parsing Support Found");
192 }
193
194
195 // mbstrings
196 if(!function_exists('mb_strlen')) {
197     $mbstringStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_MBSTRING']}</font></b>";
198     installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_MBSTRING']}");
199     $error_found = true;
200     $error_txt .= '
201       <tr>
202         <td><strong>'.$mod_strings['LBL_CHECKSYS_MBSTRING'].'</strong></td>
203         <td class="error">'.$mbstringStatus.'</td>
204       </tr>';
205 }else{
206     installLog("MBString Support Found");
207 }
208
209 // zip
210 if(!class_exists('ZipArchive')) {
211     $zipStatus = "<b><span class=stop>{$mod_strings['ERR_CHECKSYS_ZIP']}</font></b>";
212     installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_ZIP']}");
213 }else{
214     installLog("ZIP Support Found");
215 }
216
217 // config.php
218 if(file_exists('./config.php') && (!(make_writable('./config.php')) ||  !(is_writable('./config.php')))) {
219     installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}");
220     $configStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CONFIG_NOT_WRITABLE']}</span></b>";
221     $error_found = true;
222     $error_txt .= '
223       <tr>
224         <td><strong>'.$mod_strings['LBL_CHECKSYS_CONFIG'].'</strong></td>
225         <td class="error">'.$configStatus.'</td>
226       </tr>';
227 }
228
229 // custom dir
230 if(!make_writable('./custom')) {
231     $customStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}</font></b>";
232     installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_CUSTOM_NOT_WRITABLE']}");
233     $error_found = true;
234     $error_txt .= '
235       <tr>
236         <td><strong>'.$mod_strings['LBL_CHECKSYS_CUSTOM'].'</strong></td>
237         <td class="error">'.$customStatus.'</td>
238       </tr>';
239 }else{
240  installLog("/custom directory and subdirectory check passed");
241 }
242
243 // data dir
244 if(!make_writable('./data') || !make_writable('./data/upload')) {
245     $dataStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE']}</span></b>";
246     installLog("ERROR:: {$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE']}");
247     $error_found = true;
248     $error_txt .= '
249       <tr>
250         <td><strong>'.$mod_strings['LBL_CHECKSYS_DATA'].'</strong></td>
251         <td class="error">'.$dataStatus
252         .'</td>
253       </tr><tr>
254        <td colspan="2">
255             <b>'.$mod_strings['LBL_CHECKSYS_FIX_FILES'].'</b>';
256         if(!make_writable('./data')) {
257                 $error_txt .='<br>'.getcwd().'/data';
258             }
259         if(!make_writable('./data/upload')) {
260                 $error_txt .='<br>'.getcwd().'/data/upload';
261             }
262         $error_txt .= '</td>
263       </tr>';
264 }else{
265  installLog("/data/upoad directory and subdirectory check passed");
266 }
267
268
269 // cache dir
270     $cache_files[] = '/cache';
271     $cache_files[] = '/cache/images';
272     $cache_files[] = '/cache/import';
273     $cache_files[] = '/cache/layout';
274     $cache_files[] = '/cache/pdf';
275     $cache_files[] = '/cache/upload';
276     $cache_files[] = '/cache/xml';
277         $filelist = '';
278
279         foreach($cache_files as $c_file)
280         {
281                 $dirname = ".".$c_file;
282                 $ok = false;
283                 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
284                 {
285                         $ok = make_writable($dirname);
286                 }
287                 if (!$ok)
288                 {
289                         $filelist .= '<br>'.getcwd().$c_file;
290
291                 }
292         }
293         if (strlen($filelist)>0)
294         {
295             $error_found = true;
296         installLog("ERROR:: Some subdirectories in cache subfolder were not read/writeable:");
297         installLog($filelist);
298             $error_txt .= '
299                 <tr>
300                 <td><strong>'.$mod_strings['LBL_CHECKSYS_CACHE'].'</strong></td>
301                 <td align="right" class="error" class="error"><b><span class="stop">'.$mod_strings['ERR_CHECKSYS_FILES_NOT_WRITABLE'].'</span></b></td>
302                 </tr>
303                 <tr>
304                 <td colspan="2"><b>'.$mod_strings['LBL_CHECKSYS_FIX_FILES'].'</b>'.$filelist. '</td>
305                 </tr>';
306         }else{
307      installLog("/cache directory and subdirectory check passed");
308     }
309
310
311 // check modules dir
312 $_SESSION['unwriteable_module_files'] = array();
313 //if(!$writeableFiles['ret_val']) {
314 $passed_write = recursive_make_writable('./modules');
315 if (isset($_SESSION['unwriteable_module_files']['failed']) && $_SESSION['unwriteable_module_files']['failed']){
316     $passed_write = false;
317 }
318
319 if(!$passed_write) {
320
321     $moduleStatus = "<b><span class='stop'>{$mod_strings['ERR_CHECKSYS_NOT_WRITABLE']}</span></b>";
322     installLog("ERROR:: Module directories and the files under them are not writeable.");
323     $error_found = true;
324     $error_txt .= '
325       <tr>
326         <td><strong>'.$mod_strings['LBL_CHECKSYS_MODULE'].'</strong></td>
327         <td align="right" class="error">'.$moduleStatus.'</td>
328       </tr>';
329
330         //list which module directories are not writeable, if there are less than 10
331         $error_txt .= '
332           <tr>
333             <td colspan="2">
334             <b>'.$mod_strings['LBL_CHECKSYS_FIX_MODULE_FILES'].'</b>';
335         foreach($_SESSION['unwriteable_module_files'] as $key=>$file){
336             if($key !='.' && $key != 'failed'){
337                 $error_txt .='<br>'.$file;
338             }
339         }
340         $error_txt .= '
341             </td>
342           </tr>';
343
344 }else{
345  installLog("/module  directory and subdirectory check passed");
346 }
347
348
349
350 // PHP.ini
351 $phpIniLocation = get_cfg_var("cfg_file_path");
352 installLog("php.ini location found. {$phpIniLocation}");
353 // disable form if error found
354
355 if($error_found){
356     installLog("Outputting HTML for System check");
357     installLog("Errors were found *************");
358     $disabled = $error_found ? 'disabled="disabled"' : '';
359
360     $help_url = get_help_button_url();
361 ///////////////////////////////////////////////////////////////////////////////
362 ////    BEGIN PAGE OUTPUT
363     $out =<<<EOQ
364
365   <table cellspacing="0" cellpadding="0" border="0" align="center" class="shell">
366     <tr>
367       <th width="400">{$mod_strings['LBL_CHECKSYS_TITLE']}</th>
368       <th width="200" height="30" style="text-align: right;"><a href="http://www.sugarcrm.com" target=
369       "_blank"><IMG src="include/images/sugarcrm_login.png" width="145" height="30" alt="SugarCRM" border="0"></a>
370        <br><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a>
371        </th>
372     </tr>
373
374     <tr>
375       <td colspan="2" width="600">
376         <p>{$mod_strings['ERR_CHECKSYS']}</p>
377
378         <table cellpadding="0" cellspacing="0" border="0" width="100%" class="StyleDottedHr">
379           <tr>
380             <th align="left">{$mod_strings['LBL_CHECKSYS_COMPONENT']}</th>
381             <th style="text-align: right;">{$mod_strings['LBL_CHECKSYS_STATUS']}</th>
382           </tr>
383             $error_txt
384
385         </table>
386
387         <div align="center" style="margin: 5px;">
388           <i>{$mod_strings['LBL_CHECKSYS_PHP_INI']}<br>{$phpIniLocation}</i>
389         </div>
390       </td>
391     </tr>
392
393     <tr>
394       <td align="right" colspan="2">
395         <hr>
396         <form action="install3.php" method="post" name="theForm" id="theForm">
397
398         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
399           <tr>
400             <td><input class="button" type="button" onclick="window.open('http://www.sugarcrm.com/forums/');" value="{$mod_strings['LBL_HELP']}" /></td>
401             <td>
402                 <input class="button" type="button" name="Re-check" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}" onclick="callSysCheck();" id="defaultFocus"/>
403             </td>
404           </tr>
405         </table>
406         </form>
407       </td>
408     </tr>
409   </table><br>
410 EOQ;
411 return $out;
412 }else{
413     installLog("Outputting HTML for System check");
414     installLog("No Errors were found *************");
415  return 'passed';
416 }
417
418 }
419 ////    END PAGEOUTPUT
420 ///////////////////////////////////////////////////////////////////////////////
421 ?>