$fullpath .= '/';
}
if (!$file = $fs->get_file_by_hash(sha1($fullpath.'/.'))) {
- not_found();
+ send_file_not_found();
}
}
// do not serve dirs
if (!$file = $fs->get_file_by_hash(sha1($fullpath.'index.html'))) {
if (!$file = $fs->get_file_by_hash(sha1($fullpath.'index.htm'))) {
if (!$file = $fs->get_file_by_hash(sha1($fullpath.'Default.htm'))) {
- not_found();
+ send_file_not_found();
}
}
}
session_write_close(); // unlock session during fileserving
send_stored_file($file, $lifetime, $CFG->filteruploadedfiles, $forcedownload);
- function not_found() {
- global $CFG, $COURSE;
- header('HTTP/1.0 404 not found');
- print_error('filenotfound', 'error', $CFG->wwwroot.'/course/view.php?id='.$COURSE->id); //this is not displayed on IIS??
- }
return $result;
}
+/**
+ * Reprot file is not found or not accessible
+ * @return does not return, terminates script
+ */
+function send_file_not_found() {
+ global $CFG, $COURSE;
+ header('HTTP/1.0 404 not found');
+ print_error('filenotfound', 'error', $CFG->wwwroot.'/course/view.php?id='.$COURSE->id); //this is not displayed on IIS??
+}
+
/**
* Handles the sending of temporary file to user, download is forced.
* File is deleted after abort or succesful sending.
}
if ($CFG->bloglevel == BLOG_USER_LEVEL) {
if ($USER->id != $entry->userid) {
- not_found();
+ send_file_not_found();
}
}
}
$entryid = (int)array_shift($args);
if (!$entry = $DB->get_record('post', array('module'=>'blog', 'id'=>$entryid))) {
- not_found();
+ send_file_not_found();
}
if ('publishstate' === 'public') {
if ($CFG->forcelogin) {
} else if ('publishstate' === 'draft') {
require_login();
if ($USER->id != $entry->userid) {
- not_found();
+ send_file_not_found();
}
}
$fullpath = $context->id.'blog'.$entryid.$relativepath;
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
- not_found();
+ send_file_not_found();
}
send_stored_file($file, 10*60, 0, true); // download MUST be forced - security!
} else {
- not_found();
+ send_file_not_found();
}
} else if ($context->contextlevel == CONTEXT_USER) {
- not_found();
+ send_file_not_found();
} else if ($context->contextlevel == CONTEXT_COURSECAT) {
if ($filearea !== 'intro') {
- not_found();
+ send_file_not_found();
}
if ($CFG->forcelogin) {
$fullpath = $context->id.'intro0'.$relativepath;
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->get_filename() == '.') {
- not_found();
+ send_file_not_found();
}
session_write_close(); // unlock session during fileserving
} else if ($context->contextlevel == CONTEXT_COURSE) {
if ($filearea !== 'intro' and $filearea !== 'backup') {
- not_found();
+ send_file_not_found();
}
if (!$course = $DB->get_record('course', array('id'=>$context->instanceid))) {
$fullpath = $context->id.'intro0'.$relativepath;
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
- not_found();
+ send_file_not_found();
}
session_write_close(); // unlock session during fileserving
} else if ($context->contextlevel == CONTEXT_MODULE) {
if (!$coursecontext = get_context_instance_by_id(get_parent_contextid($context))) {
- not_found();
+ send_file_not_found();
}
if (!$course = $DB->get_record('course', array('id'=>$coursecontext->instanceid))) {
- not_found();
+ send_file_not_found();
}
$modinfo = get_fast_modinfo($course);
if (empty($modinfo->cms[$context->instanceid])) {
- not_found();
+ send_file_not_found();
}
$cminfo = $modinfo->cms[$context->instanceid];
}
}
}
- not_found();
+ send_file_not_found();
} else if ($context->contextlevel == CONTEXT_BLOCK) {
//not supported yet
- not_found();
+ send_file_not_found();
} else {
- not_found();
- }
-
-
- function not_found() {
- global $CFG;
- header('HTTP/1.0 404 not found');
- print_error('filenotfound', 'error', $CFG->wwwroot.'/'); //this is not displayed on IIS??
+ send_file_not_found();
}