]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - install/download_patches.php
Release 6.2.0
[Github/sugarcrm.git] / install / download_patches.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 global $sugar_version, $js_custom_version;
39 require_once('ModuleInstall/PackageManager/PackageManagerDisplay.php');
40 if( !isset( $install_script ) || !$install_script ){
41     die($mod_strings['ERR_NO_DIRECT_SCRIPT']);
42 }
43 ///////////////////////////////////////////////////////////////////////////////
44 ////    PREFILL $sugar_config VARS
45 if(empty($sugar_config['upload_dir'])) {
46     $sugar_config['upload_dir'] = 'cache/upload/';
47 }
48 if(empty($sugar_config['upload_maxsize'])) {
49     $sugar_config['upload_maxsize'] = 8192000;
50 }
51 if(empty($sugar_config['upload_badext'])) {
52     $sugar_config['upload_badext'] = array('php', 'php3', 'php4', 'php5', 'pl', 'cgi', 'py', 'asp', 'cfm', 'js', 'vbs', 'html', 'htm');
53 }
54 ////    END PREFILL $sugar_config VARS
55 ///////////////////////////////////////////////////////////////////////////////
56 require_once('include/utils/zip_utils.php');
57
58 require_once('include/upload_file.php');
59
60
61 ///////////////////////////////////////////////////////////////////////////////
62 ////    PREP VARS FOR LANG PACK
63     $base_upgrade_dir       = $sugar_config['upload_dir'] . "upgrades";
64     $base_tmp_upgrade_dir   = $base_upgrade_dir."/temp";
65 ///////////////////////////////////////////////////////////////////////////////    
66
67 ///////////////////////////////////////////////////////////////////////////////
68 ////    HANDLE FILE UPLOAD AND PROCESSING
69 $errors = array();
70 $uploadResult = '';
71 if(isset($_REQUEST['languagePackAction']) && !empty($_REQUEST['languagePackAction'])) {
72     switch($_REQUEST['languagePackAction']) {
73         case 'upload':
74         $perform = false;
75         $tempFile = '';
76         if(isset($_REQUEST['release_id']) && $_REQUEST['release_id'] != ""){
77             require_once('ModuleInstall/PackageManager/PackageManager.php');
78             $pm = new PackageManager();
79             $tempFile = $pm->download('3', '3', $_REQUEST['release_id'], getcwd().'/'.$sugar_config['upload_dir']);    
80             $perform = true;
81             //$base_filename = urldecode($tempFile);
82         }else{
83             $file = new UploadFile('language_pack');
84             if($file->confirm_upload())
85             $perform = true; 
86              if(strpos($file->mime_type, 'zip') !== false) { // only .zip files
87                     if(langPackFinalMove($file)) {
88                         $perform = true; 
89                     }
90                     else {
91                         $errors[] = $mod_strings['ERR_LANG_UPLOAD_3'];   
92                     }
93                 } else {
94                     $errors[] = $mod_strings['ERR_LANG_UPLOAD_2'];
95                 }   
96         }
97             
98     
99             if($perform) { // check for a real file               
100                         $uploadResult = $mod_strings['LBL_LANG_SUCCESS'];
101                         $result = langPackUnpack('patch', $tempFile);                   
102             } else {
103                 $errors[] = $mod_strings['ERR_LANG_UPLOAD_1'];
104             }
105             
106             if(count($errors) > 0) {
107                 foreach($errors as $error) {
108                     $uploadResult .= $error."<br />";
109                 }
110             }        
111             break; // end 'validate'
112         case 'commit':
113             $sugar_config = commitPatch();
114             break;
115         case 'remove':
116             removeLanguagePack();
117             break;
118         default:
119             break;                   
120     }
121 }
122 ////    END HANDLE FILE UPLOAD AND PROCESSING
123 ///////////////////////////////////////////////////////////////////////////////
124
125
126 ///////////////////////////////////////////////////////////////////////////////
127 ////    PRELOAD DISPLAY DATA
128 $upload_max_filesize = ini_get('upload_max_filesize');
129 $upload_max_filesize_bytes = return_bytes($upload_max_filesize);
130 $fileMaxSize ='';
131 if(!defined('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')){
132     define('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES', 6 * 1024 * 1024);
133 }
134 if($upload_max_filesize_bytes < constant('SUGARCRM_MIN_UPLOAD_MAX_FILESIZE_BYTES')) {
135     $GLOBALS['log']->debug("detected upload_max_filesize: $upload_max_filesize");
136     $fileMaxSize = '<p class="error">'.$mod_strings['ERR_UPLOAD_MAX_FILESIZE']."</p>\n";
137 }
138 $availablePatches = getLangPacks(false, array('patch'), $mod_strings['LBL_PATCH_READY']);
139
140 $errs = '';
141 if(isset($validation_errors)) {
142     if(count($validation_errors) > 0) {
143         $errs  = '<div id="errorMsgs">';
144         $errs .= "<p>{$mod_strings['LBL_SYSOPTS_ERRS_TITLE']}</p>";
145         $errs .= '<ul>';
146
147         foreach($validation_errors as $error) {
148             $errs .= '<li>' . $error . '</li>';
149         }
150
151         $errs .= '</ul>';
152         $errs .= '</div>';
153     }
154 }
155
156 ////    PRELOAD DISPLAY DATA
157 ///////////////////////////////////////////////////////////////////////////////
158
159
160 ///////////////////////////////////////////////////////////////////////////////
161 ////    BEING PAGE OUTPUT
162 $disabled = "";
163 $result = "";
164 $out =<<<EOQ
165 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
166 <html>
167 <head>
168    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
169    <meta http-equiv="Content-Script-Type" content="text/javascript">
170    <meta http-equiv="Content-Style-Type" content="text/css">
171    <title>{$mod_strings['LBL_WIZARD_TITLE']} {$next_step}</title>
172    <link REL="SHORTCUT ICON" HREF="include/images/sugar_icon.ico">
173    <link rel="stylesheet" href="install/install.css" type="text/css">
174    <script type="text/javascript" src="install/installCommon.js"></script>
175    <link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css?s={$sugar_version}&c={$js_custom_version}">
176    <script>jscal_today = 1161698116000; if(typeof app_strings == "undefined") app_strings = new Array();</script>
177    <script type="text/javascript" src="include/javascript/sugar_grp1.js?s={$sugar_version}&c={$js_custom_version}"></script>
178    <script type="text/javascript" src="include/javascript/sugar_grp1_yui.js?s={$sugar_version}&c={$js_custom_version}"></script>
179    <script type="text/javascript">
180     <!--
181     if ( YAHOO.env.ua )
182         UA = YAHOO.env.ua;
183     -->
184     </script>
185 </head>
186
187 <body onLoad="document.getElementById('defaultFocus').focus();">
188 {$fileMaxSize}
189   <table cellspacing="0" width="100%" cellpadding="0" border="0" align="center" class="shell">
190       <tr><td colspan="2" id="help"><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a></td></tr>
191     <tr>
192       <th width="500">
193                 <p>
194                 <img src="{$sugar_md}" alt="SugarCRM" border="0">
195                 </p>
196       {$mod_strings['LBL_PATCHES_TITLE']}</th>
197       <th width="200" style="text-align: right;"><a href="http://www.sugarcrm.com" target=
198       "_blank"><IMG src="include/images/sugarcrm_login.png" width="145" height="30" alt="SugarCRM" border="0"></a>
199         </th>
200     </tr>
201
202     <tr>
203         <td colspan="2">
204             <p>{$mod_strings['LBL_PATCH_1']}</p>
205             <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" class="StyleDottedHr">
206                 <tr>
207                     <th colspan="2" align="left">{$mod_strings['LBL_PATCH_TITLE']}</th>
208                 </tr>
209                 <tr>
210                     <td colspan="2">
211 EOQ;
212 $form =<<<EOQ1
213                     <form name="the_form" enctype="multipart/form-data" 
214                         action="install.php" method="post">
215                         <input type="hidden" name="current_step" value="{$next_step}">
216                         <input type="hidden" name="goto" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}">
217                         <input type="hidden" name="languagePackAction" value="upload">
218                     
219                     <table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
220                         <tr>
221                             <td>
222                                 <table width="450" border="0" cellspacing="0" cellpadding="0">
223                                     <tr>
224                                                                                 <td colspan='2'>
225                                                                                         {$mod_strings['LBL_PATCH_UPLOAD']}:
226                                                                                 </td>
227                                                                         </tr><tr>
228                                         <td>
229                                             
230                                             <input type="file" name="language_pack" size="40" />
231                                         </td>
232                                         <td valign="bottom">
233                                             <input class='button' type=button value="{$mod_strings['LBL_LANG_BUTTON_UPLOAD']}"  onClick="document.the_form.language_pack_escaped.value = escape( document.the_form.language_pack.value ); document.the_form.submit();"/>
234                                             <input type=hidden name="language_pack_escaped" value="" />
235                                         </td>
236                                     </tr>
237                                 </table>
238                             </td>
239                         </tr>
240                         <tr>
241                             <td>
242                                 {$uploadResult}
243                             </td>
244                         </tr>
245                     </table>
246                     </form>
247 EOQ1;
248 $out1 =<<<EOQ2
249                   </td>
250                 </tr>
251                 <tr>
252                     <td colspan=2>
253                         {$result}
254                     </td>
255                 </tr>
256                
257                 <!--// Available Upgrades //-->
258                 <tr>
259                     <td align="left" colspan="2">
260                         <hr>
261                         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
262                             {$availablePatches}
263                         </table>
264                     </td>
265                 </tr>
266                  <tr>
267                     <td align="right" colspan="2">
268                         <hr>
269                         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
270                         <tr><td><form action='install.php' method='POST'>
271                                 <input type='hidden' name='current_step' value="{$next_step}">
272                                 <input type='hidden' name='goto' value="{$mod_strings['LBL_CHECKSYS_RECHECK']}">
273                                 <input type='hidden' name='languagePackAction' value='commit'> 
274                                 <input type='submit' value="{$mod_strings['LBL_INSTALL']}" class='button'>
275                                 </form>
276                         </td></tr>
277                         </table>
278                     </td>
279                 </tr>
280                 <tr>
281                     <td align="right" colspan="2">
282                         <hr>
283                         <form name="the_form1" action="install.php" method="post">
284                         <input type="hidden" name="current_step" value="{$next_step}">
285                         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
286                             <tr>
287                                 <td>
288                                   
289                                 </td>
290                                 <td>
291                                     <input class="button" type="submit" name="goto" value="{$mod_strings['LBL_NEXT']}" id="defaultFocus" {$disabled} />
292                                 </td>
293                             </tr>
294                         </table>
295                         </form>
296                     </td>
297                 </tr>
298             </table>
299         </td>
300     </tr>
301 </table>
302
303 </body>
304 </html>
305 EOQ2;
306 $hidden_fields =  "<input type=\"hidden\" name=\"current_step\" value=\"{$next_step}\">";
307 $hidden_fields .=  "<input type=\"hidden\" name=\"goto\" value=\"{$mod_strings['LBL_CHECKSYS_RECHECK']}\">";
308 $hidden_fields .=  "<input type=\"hidden\" name=\"languagePackAction\" value=\"upload\">";
309 $form2 = PackageManagerDisplay::buildPatchDisplay($form, $hidden_fields, 'install.php', array('patch'));
310
311 echo $out.$form2.$out1;
312
313 //unlinkTempFiles('','');
314 ////    END PAGEOUTPUT
315 ///////////////////////////////////////////////////////////////////////////////
316 ?>