From: moodler Date: Mon, 26 Apr 2004 03:41:45 +0000 (+0000) Subject: file.php now calculates content-length correctly for filtered text and HTML files. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e5890e7160485248419b59ff0025552329ee31d7;p=moodle.git file.php now calculates content-length correctly for filtered text and HTML files. Bug 1240 --- diff --git a/file.php b/file.php index 37d6d8bb5c..7b02dcec99 100644 --- a/file.php +++ b/file.php @@ -52,26 +52,30 @@ 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 "
";
-                echo format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid);
-                echo "
"; + $output = '
'.format_text(implode('', file($pathname)), FORMAT_MOODLE, $options, $courseid).'
'; + 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); }