]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - install/download_patches.php
Release 6.4.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'] = '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       = "upload://upgrades";
64     $base_tmp_upgrade_dir   = sugar_cached("upgrades/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'], $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 $langHeader = get_language_header();
165 $out =<<<EOQ
166 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
167 <html {$langHeader}>
168 <head>
169    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
170    <meta http-equiv="Content-Script-Type" content="text/javascript">
171    <meta http-equiv="Content-Style-Type" content="text/css">
172    <title>{$mod_strings['LBL_WIZARD_TITLE']} {$next_step}</title>
173    <link REL="SHORTCUT ICON" HREF="include/images/sugar_icon.ico">
174    <link rel="stylesheet" href="install/install.css" type="text/css">
175    <script type="text/javascript" src="install/installCommon.js"></script>
176    <link rel="stylesheet" type="text/css" media="all" href="jscalendar/calendar-win2k-cold-1.css?s={$sugar_version}&c={$js_custom_version}">
177    <script>jscal_today = 1161698116000; if(typeof app_strings == "undefined") app_strings = new Array();</script>
178    <script type="text/javascript" src="cache/include/javascript/sugar_grp1.js?s={$sugar_version}&c={$js_custom_version}"></script>
179    <script type="text/javascript" src="cache/include/javascript/sugar_grp1_yui.js?s={$sugar_version}&c={$js_custom_version}"></script>
180    <script type="text/javascript">
181     <!--
182     if ( YAHOO.env.ua )
183         UA = YAHOO.env.ua;
184     -->
185     </script>
186 </head>
187
188 <body onLoad="document.getElementById('button_next2').focus();">
189 {$fileMaxSize}
190   <table cellspacing="0" width="100%" cellpadding="0" border="0" align="center" class="shell">
191       <tr><td colspan="2" id="help"><a href="{$help_url}" target='_blank'>{$mod_strings['LBL_HELP']} </a></td></tr>
192     <tr>
193       <th width="500">
194                 <p>
195                 <img src="{$sugar_md}" alt="SugarCRM" border="0">
196                 </p>
197       {$mod_strings['LBL_PATCHES_TITLE']}</th>
198       <th width="200" style="text-align: right;"><a href="http://www.sugarcrm.com" target=
199       "_blank"><IMG src="include/images/sugarcrm_login.png" width="145" height="30" alt="SugarCRM" border="0"></a>
200         </th>
201     </tr>
202
203     <tr>
204         <td colspan="2">
205             <p>{$mod_strings['LBL_PATCH_1']}</p>
206             <table width="100%" cellspacing="0" cellpadding="0" border="0" align="center" class="StyleDottedHr">
207                 <tr>
208                     <th colspan="2" align="left">{$mod_strings['LBL_PATCH_TITLE']}</th>
209                 </tr>
210                 <tr>
211                     <td colspan="2">
212 EOQ;
213 $form =<<<EOQ1
214                     <form name="the_form" enctype="multipart/form-data"
215                         action="install.php" method="post">
216                         <input type="hidden" name="current_step" value="{$next_step}">
217                         <input type="hidden" name="goto" value="{$mod_strings['LBL_CHECKSYS_RECHECK']}">
218                         <input type="hidden" name="languagePackAction" value="upload">
219
220                     <table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
221                         <tr>
222                             <td>
223                                 <table width="450" border="0" cellspacing="0" cellpadding="0">
224                                     <tr>
225                                                                                 <td colspan='2'>
226                                                                                         {$mod_strings['LBL_PATCH_UPLOAD']}:
227                                                                                 </td>
228                                                                         </tr><tr>
229                                         <td>
230
231                                             <input type="file" name="language_pack" size="40" />
232                                         </td>
233                                         <td valign="bottom">
234                                             <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();"/>
235                                             <input type=hidden name="language_pack_escaped" value="" />
236                                         </td>
237                                     </tr>
238                                 </table>
239                             </td>
240                         </tr>
241                         <tr>
242                             <td>
243                                 {$uploadResult}
244                             </td>
245                         </tr>
246                     </table>
247                     </form>
248 EOQ1;
249 $out1 =<<<EOQ2
250                   </td>
251                 </tr>
252                 <tr>
253                     <td colspan=2>
254                         {$result}
255                     </td>
256                 </tr>
257
258                 <!--// Available Upgrades //-->
259                 <tr>
260                     <td align="left" colspan="2">
261                         <hr>
262                         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
263                             {$availablePatches}
264                         </table>
265                     </td>
266                 </tr>
267                  <tr>
268                     <td align="right" colspan="2">
269                         <hr>
270                         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
271                         <tr><td><form action='install.php' method='POST'>
272                                 <input type='hidden' name='current_step' value="{$next_step}">
273                                 <input type='hidden' name='goto' value="{$mod_strings['LBL_CHECKSYS_RECHECK']}">
274                                 <input type='hidden' name='languagePackAction' value='commit'>
275                                 <input type='submit' value="{$mod_strings['LBL_INSTALL']}" class='button'>
276                                 </form>
277                         </td></tr>
278                         </table>
279                     </td>
280                 </tr>
281                 <tr>
282                     <td align="right" colspan="2">
283                         <hr>
284                         <form name="the_form1" action="install.php" method="post">
285                         <input type="hidden" name="current_step" value="{$next_step}">
286                         <table cellspacing="0" cellpadding="0" border="0" class="stdTable">
287                             <tr>
288                                 <td>
289
290                                 </td>
291                                 <td>
292                                     <input class="button" type="submit" name="goto" value="{$mod_strings['LBL_NEXT']}" id="button_next2" {$disabled} />
293                                 </td>
294                             </tr>
295                         </table>
296                         </form>
297                     </td>
298                 </tr>
299             </table>
300         </td>
301     </tr>
302 </table>
303
304 </body>
305 </html>
306 EOQ2;
307 $hidden_fields =  "<input type=\"hidden\" name=\"current_step\" value=\"{$next_step}\">";
308 $hidden_fields .=  "<input type=\"hidden\" name=\"goto\" value=\"{$mod_strings['LBL_CHECKSYS_RECHECK']}\">";
309 $hidden_fields .=  "<input type=\"hidden\" name=\"languagePackAction\" value=\"upload\">";
310 $form2 = PackageManagerDisplay::buildPatchDisplay($form, $hidden_fields, 'install.php', array('patch'));
311
312 echo $out.$form2.$out1;
313
314 //unlinkTempFiles('','');
315 ////    END PAGEOUTPUT
316 ///////////////////////////////////////////////////////////////////////////////
317 ?>