[ Index ] |
|
Code source de SugarCRM 5.0.0beta1 |
1 <?php 2 if(!defined('sugarEntry'))define('sugarEntry', true); 3 /********************************************************************************* 4 * SugarCRM is a customer relationship management program developed by 5 * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc. 6 * 7 * This program is free software; you can redistribute it and/or modify it under 8 * the terms of the GNU General Public License version 3 as published by the 9 * Free Software Foundation. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 * details. 15 * 16 * You should have received a copy of the GNU General Public License along with 17 * this program; if not, see http://www.gnu.org/licenses or write to the Free 18 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 * 02110-1301 USA. 20 * 21 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, 22 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. 23 * 24 * The interactive user interfaces in modified source and object code versions 25 * of this program must display Appropriate Legal Notices, as required under 26 * Section 5 of the GNU General Public License version 3. 27 * 28 * In accordance with Section 7(b) of the GNU General Public License version 3, 29 * these Appropriate Legal Notices must retain the display of the "Powered by 30 * SugarCRM" logo. If the display of the logo is not reasonably feasible for 31 * technical reasons, the Appropriate Legal Notices must display the words 32 * "Powered by SugarCRM". 33 ********************************************************************************/ 34 require_once ('include/entryPoint.php'); 35 global $sugar_config; 36 global $locale; 37 38 session_cache_limiter('public'); 39 session_start(); 40 41 if(empty($_REQUEST['id']) || empty($_REQUEST['type']) || !isset($_SESSION['authenticated_user_id'])) { 42 die("Not a Valid Entry Point"); 43 } else { 44 // cn: bug 8753: current_user's preferred export charset not being honored 45 $current_user->retrieve($_SESSION['authenticated_user_id']); 46 $current_language = $_SESSION['authenticated_user_language']; 47 $app_strings = return_application_language($current_language); 48 $local_location = (isset($_REQUEST['isTempFile'])) ? "{$sugar_config['cache_dir']}/modules/Emails/{$_REQUEST['ieId']}/attachments/{$_REQUEST['id']}" 49 : $sugar_config['upload_dir']."/".$_REQUEST['id']; 50 51 52 if(!file_exists( $local_location )) { 53 die($app_strings['ERR_INVALID_FILE_REFERENCE']); 54 } elseif(strpos($local_location, "../") || strpos($local_location, "..\\") ) { 55 die($app_strings['ERR_INVALID_FILE_REFERENCE']); 56 } else { 57 $doQuery = true; 58 59 if(strtolower($_REQUEST['type']) == 'documents') { 60 // cn: bug 9674 document_revisions table has no 'name' column. 61 $query = "SELECT filename name FROM document_revisions WHERE id = '" . $_REQUEST['id'] ."'"; 62 } elseif(strtolower($_REQUEST['type']) == 'notes') { 63 $query = "SELECT filename name FROM notes WHERE id = '" . $_REQUEST['id'] ."'"; 64 } elseif(strtolower($_REQUEST['type']) == 'temp') { 65 $doQuery = false; 66 } 67 68 if($doQuery) { 69 $rs = $db->query($query); 70 $row = $db->fetchByAssoc($rs); 71 72 if(empty($row)){ 73 die($app_strings['ERR_INVALID_FILE_REFERENCE']); 74 } 75 76 // cn: leave name charset translation to the browsers - they will handle it better than 2nd guessing. 77 $emailStrings = return_module_language($current_language, 'Emails'); 78 $name = urldecode(str_replace($emailStrings['LBL_EMAIL_ATTACHMENT'].': ', '', $row['name'])); 79 80 if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) { 81 // cn: bug 7870 IE cannot handle MBCS in filenames gracefully. set $name var to filename 82 $name = str_replace("+", "_", $row['name']); 83 $name = $locale->translateCharset($name, 'UTF-8', $locale->getOutboundEmailCharset()); 84 } else { 85 // ff 1.5+ 86 $name = mb_encode_mimeheader($name, $locale->getOutboundEmailCharset(), 'Q'); 87 } 88 89 90 91 92 $download_location = $sugar_config['upload_dir']."/".$_REQUEST['id']; 93 } else { 94 // downloading a temp file (email 2.0) 95 $name = $_REQUEST['tempName']; 96 $download_location = $local_location; 97 if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) { 98 // cn: bug 7870 IE cannot handle MBCS in filenames gracefully. set $name var to filename 99 $name = str_replace("+", "_", $name); 100 $name = $locale->translateCharset($name, 'UTF-8', $locale->getOutboundEmailCharset()); 101 } else { 102 // ff 1.5+ 103 $name = mb_encode_mimeheader($name, $locale->getOutboundEmailCharset(), 'Q'); 104 } 105 } 106 107 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 108 header("Content-type: application/force-download"); 109 header("Content-Length: " . filesize($local_location)); 110 header("Content-disposition: attachment; filename=\"".$name."\";"); 111 // header("Pragma: "); 112 header("Expires: 0"); 113 set_time_limit(0); 114 115 @ob_end_clean(); 116 ob_start(); 117 if(filesize($local_location) < 2097152) { 118 readfile($download_location); 119 } else { 120 readfile_chunked($download_location); 121 } 122 @ob_flush(); 123 } 124 } 125 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Sep 11 10:48:47 2007 | par Balluche grâce à PHPXref 0.7 |