diff --git a/main/document/download.php b/main/document/download.php index 58f8ca7342..d269c4d0b2 100755 --- a/main/document/download.php +++ b/main/document/download.php @@ -103,6 +103,7 @@ if (Security::check_abs_path($sys_course_path.$doc_url, $sys_course_path.'/')) { // Launch event Event::event_download($doc_url); $download = !empty($_GET['dl']) ? true : false; + $result = DocumentManager::file_send_for_download($fullFileName, $download); if ($result === false) { api_not_allowed(true); diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 5104aa6179..dd9526563d 100644 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -139,7 +139,7 @@ class DocumentManager 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mpeg4-generic', + 'mp4' => 'video/mp4', 'mpa' => 'audio/mpeg', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', @@ -258,12 +258,12 @@ class DocumentManager return $mime_types; } - //get the extension of the file + // Get the extension of the file $extension = explode('.', $filename); - //$filename will be an array if a . was found + // $filename will be an array if a . was found if (is_array($extension)) { - $extension = strtolower($extension[sizeof($extension) - 1]); + $extension = strtolower($extension[count($extension) - 1]); } else { //file without extension $extension = 'empty'; @@ -273,6 +273,7 @@ class DocumentManager if (isset($mime_types[$extension])) { return $mime_types[$extension]; } + //else return octet-stream return 'application/octet-stream'; } @@ -349,7 +350,9 @@ class DocumentManager // Commented to avoid double caching declaration when playing with IE and HTTPS //header('Cache-Control: no-cache, must-revalidate'); //header('Pragma: no-cache'); + $contentType = self::file_get_mime_type($filename); + switch ($contentType) { case 'text/html': if (isset($lpFixedEncoding) && $lpFixedEncoding === 'true') { @@ -379,11 +382,13 @@ class DocumentManager header('Content-type: '.$contentType); header('Content-Length: '.$len); - $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']); - if (strpos($user_agent, 'msie')) { + $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); + + if (strpos($userAgent, 'msie')) { header('Content-Disposition: ; filename= '.$filename); } else { - header('Content-Disposition: inline; filename= '.$filename); + //header('Content-Disposition: inline'); + header('Content-Disposition: inline;'); } if ($fixLinksHttpToHttps) { @@ -3132,7 +3137,12 @@ class DocumentManager }*/ //$type = "video/$extension"; - $html = '