]> git.mjollnir.org Git - moodle.git/commitdiff
fixed warning caused by missing fields in $course; tweaked mime info for firefox...
authorskodak <skodak>
Wed, 20 Sep 2006 17:51:59 +0000 (17:51 +0000)
committerskodak <skodak>
Wed, 20 Sep 2006 17:51:59 +0000 (17:51 +0000)
file.php
lib/filelib.php
lib/moodlelib.php

index e8501000d5910f03c99af2ad1a3999528e06cee3..3448ee0d834171ca7946484e02cefa8f286b124b 100644 (file)
--- a/file.php
+++ b/file.php
@@ -34,9 +34,7 @@
     }
 
     // security: limit access to existing course subdirectories
-    // note: course ID must be specified
-    // note: the lang field is needed for the course language switching hack in weblib.php
-    if (!$course = get_record_sql("SELECT id, lang FROM {$CFG->prefix}course WHERE id='".(int)$args[0]."'")) {
+    if (!$course = get_record_sql("SELECT * FROM {$CFG->prefix}course WHERE id='".(int)$args[0]."'")) {
         error('Invalid course ID');
     }
 
index 963dd53440a2e3b3e248ef61c669ecb2e735275e..eeb2eb3942aedd62014097d787cbf6fb036487e8 100644 (file)
@@ -216,10 +216,12 @@ function get_mimetype_description($mimetype,$capitalise=false) {
 function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false, $mimetype='') {
     global $CFG;
 
-    // Use given MIME type if specified, otherwise guess it using mimeinfo. 
-    // Always use application/x-forcedownload if that's requested.
-    $mimetype     = $forcedownload ? 'application/x-forcedownload' : 
-                        ($mimetype ? $mimetype : mimeinfo('type', $filename));
+    // Use given MIME type if specified, otherwise guess it using mimeinfo.
+    // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O
+    // only Firefox saves all files locally before opening when content-disposition: attachment stated
+    $isFF         = check_browser_version('Firefox', '1.5'); // only FF > 1.5 properly tested
+    $mimetype     = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : 
+                         ($mimetype ? $mimetype : mimeinfo('type', $filename));
     $lastmodified = $pathisstring ? time() : filemtime($path);
     $filesize     = $pathisstring ? strlen($path) : filesize($path);
 
index 6443057425f9d8e13486c5c23de3817e8956460d..9448ce2436b8ead2bc2430b49853049357634a54 100644 (file)
@@ -5126,6 +5126,16 @@ function check_php_version($version='4.1.0') {
 
     switch ($brand) {
 
+      case 'Firefox':   /// Mozilla Firefox browsers
+
+          if (preg_match("/Firefox\/([0-9\.]+)/i", $agent, $match)) {
+              if (version_compare($match[1], $version) >= 0) {
+                  return true;
+              }
+          }
+          break;
+
+
       case 'Gecko':   /// Gecko based browsers
 
           if (substr_count($agent, 'Camino')) {