From 4e0125626cb2a16e172b37110f58e451d8cbed3b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 16 Aug 2013 16:32:12 +0200 Subject: [PATCH] Force download for dwg and dwf files see BT#6536 --- main/inc/lib/document.lib.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 35807de362..9e353a820d 100644 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -53,7 +53,8 @@ class DocumentManager { * @author Bert Vanderkimpen * */ - public static function file_get_mime_type($filename) { + public static function file_get_mime_type($filename) + { // All MIME types in an array (from 1.6, this is the authorative source) // Please, keep this alphabetical if you add something to this list! $mime_types = array( @@ -87,6 +88,7 @@ class DocumentManager { 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'dvi' => 'application/x-dvi', 'dwg' => 'application/vnd.dwg', + 'dwf' => 'application/vnd.dwf', 'dxf' => 'application/vnd.dxf', 'dxr' => 'application/x-director', 'eps' => 'application/postscript', @@ -302,10 +304,12 @@ class DocumentManager { * @param string $name * @return false if file doesn't exist, true if stream succeeded */ - public static function file_send_for_download($full_file_name, $forced = false, $name = '') { + public static function file_send_for_download($full_file_name, $forced = false, $name = '') + { if (!is_file($full_file_name)) { return false; } + $filename = ($name == '') ? basename($full_file_name) : replace_dangerous_char($name); $len = filesize($full_file_name); @@ -335,6 +339,7 @@ class DocumentManager { //no forced download, just let the browser decide what to do according to the mimetype $content_type = self::file_get_mime_type($filename); + header('Expires: Wed, 01 Jan 1990 00:00:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // Commented to avoid double caching declaration when playing with IE and HTTPS @@ -353,6 +358,10 @@ class DocumentManager { $content_type .= '; charset=' . $encoding; } break; + case 'application/vnd.dwg': + case 'application/vnd.dwf': + header('Content-type: application/octet-stream'); + break; } header('Content-type: ' . $content_type); header('Content-Length: ' . $len);