Permalink
Browse files

Merge branch 'm21_MDL-32147' of git://github.com/danmarsden/moodle in…

…to MOODLE_21_STABLE
  • Loading branch information...
2 parents 38dbeec + d23a6b0 commit 88ead1b9ff452ae08583a52ddc6f8d30483da7f3 Sam Hemelryk committed Mar 26, 2012
Showing with 16 additions and 2 deletions.
  1. +12 −2 lib/filelib.php
  2. +4 −0 mod/scorm/lib.php
View
14 lib/filelib.php
@@ -1555,9 +1555,19 @@ function get_mimetype_description($mimetype, $capitalise=false) {
*/
function send_file_not_found() {
global $CFG, $COURSE;
- header('HTTP/1.0 404 not found');
+ send_header_404();
print_error('filenotfound', 'error', $CFG->wwwroot.'/course/view.php?id='.$COURSE->id); //this is not displayed on IIS??
}
+/**
+ * Helper function to send correct 404 for server.
+ */
+function send_header_404() {
+ if (substr(php_sapi_name(), 0, 3) == 'cgi') {
+ header("Status: 404 Not Found");
+ } else {
+ header('HTTP/1.0 404 not found');
+ }
+}
/**
* Check output buffering settings before sending file.
@@ -1612,7 +1622,7 @@ function send_temp_file($path, $filename, $pathisstring=false) {
if (!$pathisstring) {
if (!file_exists($path)) {
- header('HTTP/1.0 404 not found');
+ send_header_404();
print_error('filenotfound', 'error', $CFG->wwwroot.'/');
}
// executed after normal finish or abort
View
4 mod/scorm/lib.php
@@ -909,6 +909,10 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
$fs = get_file_storage();
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
+ if ($filearea === 'content') { //return file not found straight away to improve performance.
+ send_header_404();
+ die;
+ }
return false;
}

0 comments on commit 88ead1b

Please sign in to comment.