MDL-32147 - use correct 404 for server type

This commit is contained in:
Dan Marsden
2012-03-23 10:00:31 +13:00
parent ef1889484b
commit 7ebb628d8d
2 changed files with 13 additions and 3 deletions
+12 -2
View File
@@ -1564,9 +1564,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.
@@ -1621,7 +1631,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