SuiteCRM-Core/public/legacy/download.php

306 lines
14 KiB
PHP
Raw Normal View History

<?php
/**
*
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd.
* Copyright (C) 2011 - 2018 SalesAgility Ltd.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
* reasonably feasible for technical reasons, the Appropriate Legal Notices must
* display the words "Powered by SugarCRM" and "Supercharged by SuiteCRM".
*/
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
$db = DBManagerFactory::getInstance();
if ((!isset($_REQUEST['isProfile']) && empty($_REQUEST['id'])) || empty($_REQUEST['type']) || !isset($_SESSION['authenticated_user_id'])) {
die("Not a Valid Entry Point");
}
require_once("data/BeanFactory.php");
$file_type = ''; // bug 45896
require_once("data/BeanFactory.php");
ini_set(
'zlib.output_compression',
'Off'
);//bug 27089, if use gzip here, the Content-Length in header may be incorrect.
// cn: bug 8753: current_user's preferred export charset not being honored
$GLOBALS['current_user']->retrieve($_SESSION['authenticated_user_id']);
$GLOBALS['current_language'] = $_SESSION['authenticated_user_language'];
$app_strings = return_application_language($GLOBALS['current_language']);
$mod_strings = return_module_language($GLOBALS['current_language'], 'ACL');
$file_type = strtolower($_REQUEST['type']);
if (!isset($_REQUEST['isTempFile'])) {
//Custom modules may have capitalizations anywhere in their names. We should check the passed in format first.
require('include/modules.php');
$module = $db->quote($_REQUEST['type']);
if (empty($beanList[$module])) {
//start guessing at a module name
$module = ucfirst($file_type);
if (empty($beanList[$module])) {
die($app_strings['ERROR_TYPE_NOT_VALID']);
}
}
$bean_name = $beanList[$module];
if ($bean_name == 'aCase') {
$bean_name = 'Case';
}
Squashed 'public/legacy/' changes from e565a5751d..bf2afc2d9d bf2afc2d9d SuiteCRM 7.14.2 Release 563386fd5d Fix #9435 - Dropdown doesn't return empty selected value 8bcf240f81 Fix #9898 Invalid cookie domain when using non-standard HTTP Port. 58b599f236 Fix #9898 Invalid cookie domain when using non-standard HTTP Port. ac5b01f8bc Fix #9537 Activity subpanel isn't working in a module with a parent_type / flex relate field dfc2a95c2a Fix #10252 Google Maps Geocoded Counts not displaying properly 31cce5b118 Fix #10028 - Allow workflow to send plain text emails f81a52996f Fix #9412 - Wrong email value displayed when aborting an inline edition bb6267e605 Fix #9456 - choose email provider does not populate SMTP settings 6ab5229080 Fix #9440 - Forcing default null value for numeric core fields. 69868f8401 Fix #9880 - Error when importing currency fields with a decimal separator set to a comma af0ca19977 Fix #8980 - Check beanFiles for class path cd073ccc57 Fix #10027 - Respect wildcard in front when searching a full name in basic search 8db5ba4ad7 Fix #10049 - Relationship::delete expects a string 19a0c2ea27 Fix #10114 - Parameter userTime fcdb5ba2f9 Fix #10115 - Calculate Field Workflow action broken under PHP8 f13df9ac32 Fix #10141 - Orphaned Case Attachments bug 0649c48831 Update ready.php change checking of upload max filesize from > to >= 3521250d14 Fix #10159 - Accounts - Not able to search by fax on 'Any Phone' search field b8dfb45d80 Fix #9950 editing Email settings drops TLS SSL selection 9723f0b740 Fix #10205 - Compatibility hotfix for PHP 8 in ActivitiesRelationship.php d24147590e Declared sugarWidgetFieldID as property 1e54952636 Fix #10199 - PHP Fatal error: Uncaught Error: Non-static method SugarWidgetReportField::_get_column_select() 7326bd4b53 Fix #10220 - Add Email Filtering type criteria 0ede477f75 Fix #10220 - Add Email Filtering Body Type 414dd78b18 Fix #10246 - Outbound Email not showing link for non-admins 3cda70c50e Fix #10246 - Rename email account access function git-subtree-dir: public/legacy git-subtree-split: bf2afc2d9d060b31d4ece1309b8bbe98171e144f
2023-11-06 15:57:39 +00:00
global $beanFiles;
if (!file_exists($beanFiles[$bean_name])){
die($app_strings['ERROR_TYPE_NOT_VALID']);
}
$focus = BeanFactory::newBean($module);
$focus->retrieve($_REQUEST['id']);
if (!$focus->ACLAccess('view')) {
die($mod_strings['LBL_NO_ACCESS']);
} // if
// Pull up the document revision, if it's of type Document
if (isset($focus->object_name) && $focus->object_name == 'Document') {
// It's a document, get the revision that really stores this file
$focusRevision = BeanFactory::newBean('DocumentRevisions');
$focusRevision->retrieve($_REQUEST['id']);
if (empty($focusRevision->id)) {
// This wasn't a document revision id, it's probably actually a document id,
// we need to grab the latest revision and use that
$focusRevision->retrieve($focus->document_revision_id);
if (!empty($focusRevision->id)) {
$_REQUEST['id'] = $focusRevision->id;
}
}
}
// See if it is a remote file, if so, send them that direction
if (isset($focus->doc_url) && !empty($focus->doc_url)) {
header('Location: ' . $focus->doc_url);
sugar_die("Remote file detected, location header sent.");
}
if (isset($focusRevision) && isset($focusRevision->doc_url) && !empty($focusRevision->doc_url)) {
header('Location: ' . $focusRevision->doc_url);
sugar_die("Remote file detected, location header sent.");
}
} // if
// id here is really id_field. But since both "id" and "field" can also have underscores in them,
// we'll try out parts starting from the end, checking if we get a valid field name.
// Some edge cases might be impossible to untangle (ids that contain field names,
// and field names that partially contain others, e.g. name and first_name).
// TODO: drop this ugly scheme of passing ids together with field names - just pass them in separately...
$image_field = null;
$image_id = $_REQUEST['id'];
$parts = explode('_', $image_id);
$index = count($parts) - 1;
while ($index) {
$possible_field = implode('_', array_slice($parts, $index)); // final parts, from index to end
if (isset($focus->field_defs[$possible_field])) {
$image_field = $possible_field;
$image_id = implode('_', array_slice($parts, 0, $index)); // initial parts, up to index
break;
}
$index--;
}
if (isset($_REQUEST['ieId']) && isset($_REQUEST['isTempFile'])) {
$local_location = sugar_cached("modules/Emails/{$_REQUEST['ieId']}/attachments/{$_REQUEST['id']}");
} elseif (isset($_REQUEST['isTempFile']) && $file_type == "import") {
$local_location = "upload://import/{$_REQUEST['tempName']}";
} else {
$local_location = "upload://{$_REQUEST['id']}";
}
if (isset($_REQUEST['isTempFile']) && ($_REQUEST['type'] == "SugarFieldImage")) {
$local_location = "upload://{$_REQUEST['id']}";
}
if (isset($_REQUEST['isTempFile']) && ($_REQUEST['type'] == "SugarFieldImage") && (isset($_REQUEST['isProfile'])) && empty($_REQUEST['id'])) {
$local_location = "include/images/default-profile.png";
}
Squashed 'public/legacy/' changes from f7552f5bda..8814fa0715 8814fa0715 Fix install issues on php82 57aade8739 SuiteCRM 7.14 Alpha Build 714db79c16 PHP 8.2 - Fix Events acceptance tests cdbc9377bc PHP 8.2 - Fix Meetings EditView reminders panel d6c38694d4 PHP 8.2 - Skip some Emails acceptance tests 5ae1aa0ef0 PHP 8.2 - Fix Meetings acceptance tests d1f912a2af PHP 8.2 - Fix funtion.sugarvar access to vardef 8f8be198f7 PHP 8.2 - Fix SugarFieldFile a46d5dcd2f PHP 8.2 - Fix Accounts acceptance tests 2650ec8c5d PHP 8.2 - Fix ModuleBuilder Acceptance tests 96a96691eb PHP 8.2 - Fix User's acceptance tests ff6bd8365d PHP 8.2 - Fix CampaignsWizard 9bd6429d30 PHP 8.2 - Fix ModuleBuilder 01a77e10f3 PHP 8.2 - Fix Leads 601b0d876b PHP 8.2 - Fix InlineEdit 0873a99106 PHP 8.2 - Fix Emails DetailView 8e261a27ff PHP 8.2 - Fix User metadata a1e4e362a8 PHP 8.2 - Fix CaseUpdates 5d83ca6715 PHP 8.2 - Fix CaseEvents 2e1e610a5a PHP 8.2 - Fix Workflow d4df25fffc PHP 8.2 - Fix vCard 9c9fdea3c2 PHP 8.2 - Fix Markers c555bc5fbc PHP 8.2 - Fix sugar_button tpl calls b83a708b5a PHP 8.2 - Fix unit tests b52e10ed97 PHP 8.2 - Fix SecurityGroups dc06f62afa PHP 8.2 - Fix DetailView 8a2f316ff1 PHP 8.2 - Fix search 586dedf7c9 PHP 8.2 - Fix SugarBean 802d762dbe PHP 8.2 - Fix SugarView 4c52b30e0f PHP 8.2 - Fix Workflow module c650c08e01 PHP 8.2 - Fix DB Connector 178db2eaf9 PHP 8.2 - Fix User module metadata e2f3a151fd PHP 8.2 - Fix ACL Roles c2148be2ed PHP 8.2 - Fix smarty plugins cca6f7e663 PHP 8.2 - Fix module builder d9d4687ae0 PHP 8.2 - Fix ListView 2bc9405185 Add new smarty plugins to SuiteCRM core bfb08d826a Close #9916 - Upgrade to Smarty 4 6ce3567c3e Fix smarty template syntax and reference issues 8fb748a1ba PHP 8.2 - Fix build_related_list 8be2226d39 PHP 8.2 - Fix json encode deabe60b25 PHP 8.2 - Fix unit tests f82356f93f PHP 8.2 - Make unit tests run 7d099fbe35 PHP 8.2 - Fix root files 21dc5200e9 Run rector on modules folder 8ace01e4b4 Run rector on modules/UpgradeWizard 5f829f5274 Run rector on modules/ModuleBuilder 52de5a494b PHP 8.2 - Fix deprecations 95ecd94c0d PHP 8.2 - Fix deprecated string interpolation style 6c058b733f Run rector on tests folder 96155ce400 Run rector root folder files 6adefc6a8b Run rector on modules folder 63d4ca29e4 Run rector on ModuleInstall folder 939652c3d8 Run rector on install folder 9a2b2bd10d Run rector on include folder d8aa6d8d3c Run rector on data folder c55360bc37 Run rector on lib/Utility folder aea9e59237 Run rector on lib/Search folder 1325c63cb0 Run rector on lib/Robo folder f86842bc62 Run rector on lib/PDF folder e121e08a44 Run rector on lib/log folder c9ba598fc4 Run rector on lib/Enumerator lib/Exception folders e50cb49ddd Run rector on lib/Api folder da135b4691 Run rector on service folder 6f74ca41be Run rector on jssource folder a3a7b88017 Run rector on XTemplate folder e7b7acd8e2 Run rector on soap folder 1c12f97dcc Run rector on Api folder f5df566954 Fix Unit Tests 6d4085c47d Fix #10053 - Issue when creating new tabs git-subtree-dir: public/legacy git-subtree-split: 8814fa0715e6b2276c74ab3ac51a9e8a5b87386b
2023-07-21 15:04:06 +01:00
if (!file_exists($local_location) || strpos((string) $local_location, "..")) {
if (isset($image_field)) {
header("Content-Type: image/png");
header("Content-Disposition: attachment; filename=\"No-Image.png\"");
header("X-Content-Type-Options: nosniff");
header("Content-Length: " . filesize('include/SugarFields/Fields/Image/no_image.png'));
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000));
set_time_limit(0);
readfile('include/SugarFields/Fields/Image/no_image.png');
die();
}
die($app_strings['ERR_INVALID_FILE_REFERENCE']);
}
$doQuery = true;
if ($file_type == 'documents' && !isset($image_field)) {
// cn: bug 9674 document_revisions table has no 'name' column.
$query = "SELECT filename name FROM document_revisions INNER JOIN documents ON documents.id = document_revisions.document_id ";
$query .= "WHERE document_revisions.id = '" . $db->quote($_REQUEST['id']) . "' ";
} elseif ($file_type == 'kbdocuments') {
$query = "SELECT document_revisions.filename name FROM document_revisions INNER JOIN kbdocument_revisions ON document_revisions.id = kbdocument_revisions.document_revision_id INNER JOIN kbdocuments ON kbdocument_revisions.kbdocument_id = kbdocuments.id ";
$query .= "WHERE document_revisions.id = '" . $db->quote($_REQUEST['id']) . "'";
} elseif ($file_type == 'notes') {
$query = "SELECT filename name, file_mime_type FROM notes ";
$query .= "WHERE notes.id = '" . $db->quote($_REQUEST['id']) . "'";
} elseif (!isset($_REQUEST['isTempFile']) && !isset($_REQUEST['tempName']) && isset($_REQUEST['type']) && $file_type != 'temp' && isset($image_field)) { //make sure not email temp file.
$file_type = ($file_type == "employees") ? "users" : $file_type;
//$query = "SELECT " . $image_field ." FROM " . $file_type . " LEFT JOIN " . $file_type . "_cstm cstm ON cstm.id_c = " . $file_type . ".id ";
// Fix for issue #1195: because the module was created using Module Builder and it does not create any _cstm table,
// there is a need to check whether the field has _c extension.
$file_type = $db->quote($file_type);
$query = "SELECT " . $db->quote($image_field) . " FROM " . $file_type . " ";
if (substr($image_field, -2) == "_c") {
$query .= "LEFT JOIN " . $file_type . "_cstm cstm ON cstm.id_c = " . $file_type . ".id ";
}
$query .= "WHERE " . $file_type . ".id= '" . $db->quote($image_id) . "'";
//$query .= "WHERE " . $file_type . ".id= '" . $db->quote($image_id) . "'";
} elseif (!isset($_REQUEST['isTempFile']) && !isset($_REQUEST['tempName']) && isset($_REQUEST['type']) && $file_type != 'temp') { //make sure not email temp file.
$query = "SELECT filename name FROM " . $file_type . " ";
$query .= "WHERE " . $file_type . ".id= '" . $db->quote($_REQUEST['id']) . "'";
} elseif ($file_type == 'temp') {
$doQuery = false;
}
// Fix for issue 1506 and issue 1304 : IE11 and Microsoft Edge cannot display generic 'application/octet-stream' (which is defined as "arbitrary binary data" in RFC 2046).
$mime_type = mime_content_type($local_location);
switch ($mime_type) {
case 'text/html':
$mime_type = 'text/plain';
break;
case null:
case '':
$mime_type = 'application/octet-stream';
break;
}
if ($doQuery && isset($query)) {
$rs = DBManagerFactory::getInstance()->query($query);
$row = DBManagerFactory::getInstance()->fetchByAssoc($rs);
if (empty($row)) {
die($app_strings['ERROR_NO_RECORD']);
}
if (isset($image_field)) {
$name = $row[$image_field];
} else {
$name = $row['name'];
}
// expose original mime type only for images, otherwise the content of arbitrary type
// may be interpreted/executed by browser
Squashed 'public/legacy/' changes from f7552f5bda..8814fa0715 8814fa0715 Fix install issues on php82 57aade8739 SuiteCRM 7.14 Alpha Build 714db79c16 PHP 8.2 - Fix Events acceptance tests cdbc9377bc PHP 8.2 - Fix Meetings EditView reminders panel d6c38694d4 PHP 8.2 - Skip some Emails acceptance tests 5ae1aa0ef0 PHP 8.2 - Fix Meetings acceptance tests d1f912a2af PHP 8.2 - Fix funtion.sugarvar access to vardef 8f8be198f7 PHP 8.2 - Fix SugarFieldFile a46d5dcd2f PHP 8.2 - Fix Accounts acceptance tests 2650ec8c5d PHP 8.2 - Fix ModuleBuilder Acceptance tests 96a96691eb PHP 8.2 - Fix User's acceptance tests ff6bd8365d PHP 8.2 - Fix CampaignsWizard 9bd6429d30 PHP 8.2 - Fix ModuleBuilder 01a77e10f3 PHP 8.2 - Fix Leads 601b0d876b PHP 8.2 - Fix InlineEdit 0873a99106 PHP 8.2 - Fix Emails DetailView 8e261a27ff PHP 8.2 - Fix User metadata a1e4e362a8 PHP 8.2 - Fix CaseUpdates 5d83ca6715 PHP 8.2 - Fix CaseEvents 2e1e610a5a PHP 8.2 - Fix Workflow d4df25fffc PHP 8.2 - Fix vCard 9c9fdea3c2 PHP 8.2 - Fix Markers c555bc5fbc PHP 8.2 - Fix sugar_button tpl calls b83a708b5a PHP 8.2 - Fix unit tests b52e10ed97 PHP 8.2 - Fix SecurityGroups dc06f62afa PHP 8.2 - Fix DetailView 8a2f316ff1 PHP 8.2 - Fix search 586dedf7c9 PHP 8.2 - Fix SugarBean 802d762dbe PHP 8.2 - Fix SugarView 4c52b30e0f PHP 8.2 - Fix Workflow module c650c08e01 PHP 8.2 - Fix DB Connector 178db2eaf9 PHP 8.2 - Fix User module metadata e2f3a151fd PHP 8.2 - Fix ACL Roles c2148be2ed PHP 8.2 - Fix smarty plugins cca6f7e663 PHP 8.2 - Fix module builder d9d4687ae0 PHP 8.2 - Fix ListView 2bc9405185 Add new smarty plugins to SuiteCRM core bfb08d826a Close #9916 - Upgrade to Smarty 4 6ce3567c3e Fix smarty template syntax and reference issues 8fb748a1ba PHP 8.2 - Fix build_related_list 8be2226d39 PHP 8.2 - Fix json encode deabe60b25 PHP 8.2 - Fix unit tests f82356f93f PHP 8.2 - Make unit tests run 7d099fbe35 PHP 8.2 - Fix root files 21dc5200e9 Run rector on modules folder 8ace01e4b4 Run rector on modules/UpgradeWizard 5f829f5274 Run rector on modules/ModuleBuilder 52de5a494b PHP 8.2 - Fix deprecations 95ecd94c0d PHP 8.2 - Fix deprecated string interpolation style 6c058b733f Run rector on tests folder 96155ce400 Run rector root folder files 6adefc6a8b Run rector on modules folder 63d4ca29e4 Run rector on ModuleInstall folder 939652c3d8 Run rector on install folder 9a2b2bd10d Run rector on include folder d8aa6d8d3c Run rector on data folder c55360bc37 Run rector on lib/Utility folder aea9e59237 Run rector on lib/Search folder 1325c63cb0 Run rector on lib/Robo folder f86842bc62 Run rector on lib/PDF folder e121e08a44 Run rector on lib/log folder c9ba598fc4 Run rector on lib/Enumerator lib/Exception folders e50cb49ddd Run rector on lib/Api folder da135b4691 Run rector on service folder 6f74ca41be Run rector on jssource folder a3a7b88017 Run rector on XTemplate folder e7b7acd8e2 Run rector on soap folder 1c12f97dcc Run rector on Api folder f5df566954 Fix Unit Tests 6d4085c47d Fix #10053 - Issue when creating new tabs git-subtree-dir: public/legacy git-subtree-split: 8814fa0715e6b2276c74ab3ac51a9e8a5b87386b
2023-07-21 15:04:06 +01:00
if (isset($row['file_mime_type']) && strpos((string) $row['file_mime_type'], 'image/') === 0) {
$mime_type = $row['file_mime_type'];
}
if (isset($_REQUEST['field'])) {
$id = $row[$id_field];
$download_location = "upload://{$id}";
} else {
$download_location = "upload://{$_REQUEST['id']}";
}
} else {
if (isset($_REQUEST['tempName']) && isset($_REQUEST['isTempFile'])) {
// downloading a temp file (email 2.0)
$download_location = $local_location;
$name = isset($_REQUEST['tempName']) ? $_REQUEST['tempName'] : '';
} else {
if (isset($_REQUEST['isTempFile']) && ($_REQUEST['type'] == "SugarFieldImage")) {
$download_location = $local_location;
$name = isset($_REQUEST['tempName']) ? $_REQUEST['tempName'] : '';
}
}
}
Squashed 'public/legacy/' changes from f7552f5bda..8814fa0715 8814fa0715 Fix install issues on php82 57aade8739 SuiteCRM 7.14 Alpha Build 714db79c16 PHP 8.2 - Fix Events acceptance tests cdbc9377bc PHP 8.2 - Fix Meetings EditView reminders panel d6c38694d4 PHP 8.2 - Skip some Emails acceptance tests 5ae1aa0ef0 PHP 8.2 - Fix Meetings acceptance tests d1f912a2af PHP 8.2 - Fix funtion.sugarvar access to vardef 8f8be198f7 PHP 8.2 - Fix SugarFieldFile a46d5dcd2f PHP 8.2 - Fix Accounts acceptance tests 2650ec8c5d PHP 8.2 - Fix ModuleBuilder Acceptance tests 96a96691eb PHP 8.2 - Fix User's acceptance tests ff6bd8365d PHP 8.2 - Fix CampaignsWizard 9bd6429d30 PHP 8.2 - Fix ModuleBuilder 01a77e10f3 PHP 8.2 - Fix Leads 601b0d876b PHP 8.2 - Fix InlineEdit 0873a99106 PHP 8.2 - Fix Emails DetailView 8e261a27ff PHP 8.2 - Fix User metadata a1e4e362a8 PHP 8.2 - Fix CaseUpdates 5d83ca6715 PHP 8.2 - Fix CaseEvents 2e1e610a5a PHP 8.2 - Fix Workflow d4df25fffc PHP 8.2 - Fix vCard 9c9fdea3c2 PHP 8.2 - Fix Markers c555bc5fbc PHP 8.2 - Fix sugar_button tpl calls b83a708b5a PHP 8.2 - Fix unit tests b52e10ed97 PHP 8.2 - Fix SecurityGroups dc06f62afa PHP 8.2 - Fix DetailView 8a2f316ff1 PHP 8.2 - Fix search 586dedf7c9 PHP 8.2 - Fix SugarBean 802d762dbe PHP 8.2 - Fix SugarView 4c52b30e0f PHP 8.2 - Fix Workflow module c650c08e01 PHP 8.2 - Fix DB Connector 178db2eaf9 PHP 8.2 - Fix User module metadata e2f3a151fd PHP 8.2 - Fix ACL Roles c2148be2ed PHP 8.2 - Fix smarty plugins cca6f7e663 PHP 8.2 - Fix module builder d9d4687ae0 PHP 8.2 - Fix ListView 2bc9405185 Add new smarty plugins to SuiteCRM core bfb08d826a Close #9916 - Upgrade to Smarty 4 6ce3567c3e Fix smarty template syntax and reference issues 8fb748a1ba PHP 8.2 - Fix build_related_list 8be2226d39 PHP 8.2 - Fix json encode deabe60b25 PHP 8.2 - Fix unit tests f82356f93f PHP 8.2 - Make unit tests run 7d099fbe35 PHP 8.2 - Fix root files 21dc5200e9 Run rector on modules folder 8ace01e4b4 Run rector on modules/UpgradeWizard 5f829f5274 Run rector on modules/ModuleBuilder 52de5a494b PHP 8.2 - Fix deprecations 95ecd94c0d PHP 8.2 - Fix deprecated string interpolation style 6c058b733f Run rector on tests folder 96155ce400 Run rector root folder files 6adefc6a8b Run rector on modules folder 63d4ca29e4 Run rector on ModuleInstall folder 939652c3d8 Run rector on install folder 9a2b2bd10d Run rector on include folder d8aa6d8d3c Run rector on data folder c55360bc37 Run rector on lib/Utility folder aea9e59237 Run rector on lib/Search folder 1325c63cb0 Run rector on lib/Robo folder f86842bc62 Run rector on lib/PDF folder e121e08a44 Run rector on lib/log folder c9ba598fc4 Run rector on lib/Enumerator lib/Exception folders e50cb49ddd Run rector on lib/Api folder da135b4691 Run rector on service folder 6f74ca41be Run rector on jssource folder a3a7b88017 Run rector on XTemplate folder e7b7acd8e2 Run rector on soap folder 1c12f97dcc Run rector on Api folder f5df566954 Fix Unit Tests 6d4085c47d Fix #10053 - Issue when creating new tabs git-subtree-dir: public/legacy git-subtree-split: 8814fa0715e6b2276c74ab3ac51a9e8a5b87386b
2023-07-21 15:04:06 +01:00
if (isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", (string) $_SERVER['HTTP_USER_AGENT'])) {
$name = urlencode($name);
$name = str_replace("+", "_", $name);
}
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
if (isset($_REQUEST['isTempFile']) && ($_REQUEST['type'] == "SugarFieldImage")) {
$mime = getimagesize($download_location);
if (!empty($mime)) {
header("Content-Type: {$mime['mime']}");
} else {
header("Content-Type: image/png");
}
} else {
header('Content-type: ' . $mime_type);
$showPreview = false;
global $sugar_config;
$allowedPreview = $sugar_config['allowed_preview'] ?? [];
if (empty($row['file_ext'])) {
Squashed 'public/legacy/' changes from f7552f5bda..8814fa0715 8814fa0715 Fix install issues on php82 57aade8739 SuiteCRM 7.14 Alpha Build 714db79c16 PHP 8.2 - Fix Events acceptance tests cdbc9377bc PHP 8.2 - Fix Meetings EditView reminders panel d6c38694d4 PHP 8.2 - Skip some Emails acceptance tests 5ae1aa0ef0 PHP 8.2 - Fix Meetings acceptance tests d1f912a2af PHP 8.2 - Fix funtion.sugarvar access to vardef 8f8be198f7 PHP 8.2 - Fix SugarFieldFile a46d5dcd2f PHP 8.2 - Fix Accounts acceptance tests 2650ec8c5d PHP 8.2 - Fix ModuleBuilder Acceptance tests 96a96691eb PHP 8.2 - Fix User's acceptance tests ff6bd8365d PHP 8.2 - Fix CampaignsWizard 9bd6429d30 PHP 8.2 - Fix ModuleBuilder 01a77e10f3 PHP 8.2 - Fix Leads 601b0d876b PHP 8.2 - Fix InlineEdit 0873a99106 PHP 8.2 - Fix Emails DetailView 8e261a27ff PHP 8.2 - Fix User metadata a1e4e362a8 PHP 8.2 - Fix CaseUpdates 5d83ca6715 PHP 8.2 - Fix CaseEvents 2e1e610a5a PHP 8.2 - Fix Workflow d4df25fffc PHP 8.2 - Fix vCard 9c9fdea3c2 PHP 8.2 - Fix Markers c555bc5fbc PHP 8.2 - Fix sugar_button tpl calls b83a708b5a PHP 8.2 - Fix unit tests b52e10ed97 PHP 8.2 - Fix SecurityGroups dc06f62afa PHP 8.2 - Fix DetailView 8a2f316ff1 PHP 8.2 - Fix search 586dedf7c9 PHP 8.2 - Fix SugarBean 802d762dbe PHP 8.2 - Fix SugarView 4c52b30e0f PHP 8.2 - Fix Workflow module c650c08e01 PHP 8.2 - Fix DB Connector 178db2eaf9 PHP 8.2 - Fix User module metadata e2f3a151fd PHP 8.2 - Fix ACL Roles c2148be2ed PHP 8.2 - Fix smarty plugins cca6f7e663 PHP 8.2 - Fix module builder d9d4687ae0 PHP 8.2 - Fix ListView 2bc9405185 Add new smarty plugins to SuiteCRM core bfb08d826a Close #9916 - Upgrade to Smarty 4 6ce3567c3e Fix smarty template syntax and reference issues 8fb748a1ba PHP 8.2 - Fix build_related_list 8be2226d39 PHP 8.2 - Fix json encode deabe60b25 PHP 8.2 - Fix unit tests f82356f93f PHP 8.2 - Make unit tests run 7d099fbe35 PHP 8.2 - Fix root files 21dc5200e9 Run rector on modules folder 8ace01e4b4 Run rector on modules/UpgradeWizard 5f829f5274 Run rector on modules/ModuleBuilder 52de5a494b PHP 8.2 - Fix deprecations 95ecd94c0d PHP 8.2 - Fix deprecated string interpolation style 6c058b733f Run rector on tests folder 96155ce400 Run rector root folder files 6adefc6a8b Run rector on modules folder 63d4ca29e4 Run rector on ModuleInstall folder 939652c3d8 Run rector on install folder 9a2b2bd10d Run rector on include folder d8aa6d8d3c Run rector on data folder c55360bc37 Run rector on lib/Utility folder aea9e59237 Run rector on lib/Search folder 1325c63cb0 Run rector on lib/Robo folder f86842bc62 Run rector on lib/PDF folder e121e08a44 Run rector on lib/log folder c9ba598fc4 Run rector on lib/Enumerator lib/Exception folders e50cb49ddd Run rector on lib/Api folder da135b4691 Run rector on service folder 6f74ca41be Run rector on jssource folder a3a7b88017 Run rector on XTemplate folder e7b7acd8e2 Run rector on soap folder 1c12f97dcc Run rector on Api folder f5df566954 Fix Unit Tests 6d4085c47d Fix #10053 - Issue when creating new tabs git-subtree-dir: public/legacy git-subtree-split: 8814fa0715e6b2276c74ab3ac51a9e8a5b87386b
2023-07-21 15:04:06 +01:00
$row['file_ext'] = pathinfo((string) $name, PATHINFO_EXTENSION);
}
Squashed 'public/legacy/' changes from e565a5751d..bf2afc2d9d bf2afc2d9d SuiteCRM 7.14.2 Release 563386fd5d Fix #9435 - Dropdown doesn't return empty selected value 8bcf240f81 Fix #9898 Invalid cookie domain when using non-standard HTTP Port. 58b599f236 Fix #9898 Invalid cookie domain when using non-standard HTTP Port. ac5b01f8bc Fix #9537 Activity subpanel isn't working in a module with a parent_type / flex relate field dfc2a95c2a Fix #10252 Google Maps Geocoded Counts not displaying properly 31cce5b118 Fix #10028 - Allow workflow to send plain text emails f81a52996f Fix #9412 - Wrong email value displayed when aborting an inline edition bb6267e605 Fix #9456 - choose email provider does not populate SMTP settings 6ab5229080 Fix #9440 - Forcing default null value for numeric core fields. 69868f8401 Fix #9880 - Error when importing currency fields with a decimal separator set to a comma af0ca19977 Fix #8980 - Check beanFiles for class path cd073ccc57 Fix #10027 - Respect wildcard in front when searching a full name in basic search 8db5ba4ad7 Fix #10049 - Relationship::delete expects a string 19a0c2ea27 Fix #10114 - Parameter userTime fcdb5ba2f9 Fix #10115 - Calculate Field Workflow action broken under PHP8 f13df9ac32 Fix #10141 - Orphaned Case Attachments bug 0649c48831 Update ready.php change checking of upload max filesize from > to >= 3521250d14 Fix #10159 - Accounts - Not able to search by fax on 'Any Phone' search field b8dfb45d80 Fix #9950 editing Email settings drops TLS SSL selection 9723f0b740 Fix #10205 - Compatibility hotfix for PHP 8 in ActivitiesRelationship.php d24147590e Declared sugarWidgetFieldID as property 1e54952636 Fix #10199 - PHP Fatal error: Uncaught Error: Non-static method SugarWidgetReportField::_get_column_select() 7326bd4b53 Fix #10220 - Add Email Filtering type criteria 0ede477f75 Fix #10220 - Add Email Filtering Body Type 414dd78b18 Fix #10246 - Outbound Email not showing link for non-admins 3cda70c50e Fix #10246 - Rename email account access function git-subtree-dir: public/legacy git-subtree-split: bf2afc2d9d060b31d4ece1309b8bbe98171e144f
2023-11-06 15:57:39 +00:00
if (!empty($row['file_ext']) && in_array($row['file_ext'], $allowedPreview, true)) {
$showPreview = isset($_REQUEST['preview']) && $_REQUEST['preview'] === 'yes' && $mime_type !== 'text/html';
}
if ($showPreview === true) {
header('Content-Disposition: inline; filename="' . $name . '";');
} else {
header('Content-Disposition: attachment; filename="' . $name . '";');
}
}
// disable content type sniffing in MSIE
header("X-Content-Type-Options: nosniff");
header("Content-Length: " . filesize($local_location));
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 2592000));
set_time_limit(0);
// When output_buffering = On, ob_get_level() may return 1 even if ob_end_clean() returns false
// This happens on some QA stacks. See Bug#64860
while (ob_get_level() && @ob_end_clean()) {
;
}
ob_start();
echo clean_file_output(file_get_contents($download_location), $mime_type);
$output = ob_get_contents();
ob_end_clean();
echo $output;