Skip to content

Commit

Permalink
Corrected oversight with uploaded file filters change
Browse files Browse the repository at this point in the history
  • Loading branch information
thepurpleblob committed Feb 21, 2006
1 parent e11108a commit b9709b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion file.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
// ========================================
session_write_close(); // unlock session during fileserving
$filename = $args[count($args)-1];
send_file($pathname, $filename, $lifetime, !empty($CFG->filteruploadedfiles), false, $forcedownload);
send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);

function not_found($courseid) {
global $CFG;
Expand Down
11 changes: 8 additions & 3 deletions lib/filelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ function mimeinfo($element, $filename) {
}
}

function send_file($path, $filename, $lifetime=86400 , $filter=false, $pathisstring=false, $forcedownload=false) {

/**
* @PARAM $filter int 0=no filtering, 1=all files, 2=html files only
*/
function send_file($path, $filename, $lifetime=86400 , $filter=0, $pathisstring=false, $forcedownload=false) {
global $CFG;

$mimetype = $forcedownload ? 'application/x-forcedownload' : mimeinfo('type', $filename);
Expand Down Expand Up @@ -223,7 +227,7 @@ function send_file($path, $filename, $lifetime=86400 , $filter=false, $pathisstr
@header('Accept-Ranges: none'); // Do not allow byteserving when caching disabled
}

if (!$filter) {
if (empty($filter)) {
if ($mimetype == 'text/html' && !empty($CFG->usesid) && empty($_COOKIE['MoodleSession'.$CFG->sessioncookie])) {
//cookieless mode - rewrite links
@header('Content-Type: text/html');
Expand Down Expand Up @@ -263,7 +267,8 @@ function send_file($path, $filename, $lifetime=86400 , $filter=false, $pathisstr
@header('Content-Type: text/html');
while (@ob_end_flush()); //flush the buffers - save memory and disable sid rewrite
echo $output;
} else if (($mimetype == 'text/plain') and ($CFG->filteruploadedfiles==1)) {
// only filter text if filter all files is selected
} else if (($mimetype == 'text/plain') and ($filter == 1)) {
$options->newlines = false;
$options->noclean = true;
$text = htmlentities($pathisstring ? $path : implode('', file($path)));
Expand Down

0 comments on commit b9709b7

Please sign in to comment.