]> git.mjollnir.org Git - moodle.git/commitdiff
file.php now calculates content-length correctly for filtered text and HTML files.
authormoodler <moodler>
Mon, 26 Apr 2004 03:41:45 +0000 (03:41 +0000)
committermoodler <moodler>
Mon, 26 Apr 2004 03:41:45 +0000 (03:41 +0000)
Bug 1240

file.php

index 37d6d8bb5cc00be94a056bdce73b5c401c00334a..7b02dcec9931373a73fc1ea1273ca7d9a4dc57f7 100644 (file)
--- a/file.php
+++ b/file.php
         header("Cache-control: max_age = $CFG->filelifetime");
         header("Pragma: ");
         header("Content-disposition: inline; filename=$filename");
-        header("Content-length: ".filesize($pathname));
 
 
         if (empty($CFG->filteruploadedfiles)) {
+            header("Content-length: ".filesize($pathname));
             header("Content-type: $mimetype");
             readfile($pathname);
 
         } else {     /// Try and put the file through filters
             if ($mimetype == "text/html") {
+                $output = format_text(implode('', file($pathname)), FORMAT_HTML, NULL, $courseid);
+
+                header("Content-length: ".strlen($output));
                 header("Content-type: text/html");
-                echo format_text(implode('', file($pathname)), FORMAT_HTML, NULL, $courseid);
+                echo $output;
     
             } else if ($mimetype == "text/plain") {
-                header("Content-type: text/html");
                 $options->newlines = false;
-                echo "<pre>";
-                echo format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid);
-                echo "</pre>";
+                $output = '<pre>'.format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid).'</pre>';
+                header("Content-length: ".strlen($output));
+                header("Content-type: text/html");
+                echo $output;
     
             } else {    /// Just send it out raw
+                header("Content-length: ".filesize($pathname));
                 header("Content-type: $mimetype");
                 readfile($pathname);
             }