mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge branch 'ticket/p/7782' into develop-olympus
* ticket/p/7782: [ticket/7782] Return 404 HTTP status code for nonexistent attachments. [ticket/7782] Added spaces. [ticket/7782] Added phpdoc comment for send_status_line function. [ticket/7782] Send status line using refactored download/file.php logic.
This commit is contained in:
commit
26c2efc083
2 changed files with 44 additions and 11 deletions
|
@ -670,15 +670,7 @@ function set_modified_headers($stamp, $browser)
|
|||
{
|
||||
if ($last_load !== false && $last_load >= $stamp)
|
||||
{
|
||||
if (substr(strtolower(@php_sapi_name()),0,3) === 'cgi')
|
||||
{
|
||||
// in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though
|
||||
header('Status: 304 Not Modified', true, 304);
|
||||
}
|
||||
else
|
||||
{
|
||||
header('HTTP/1.0 304 Not Modified', true, 304);
|
||||
}
|
||||
send_status_line(304, 'Not Modified');
|
||||
// seems that we need those too ... browsers
|
||||
header('Pragma: public');
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000));
|
||||
|
|
|
@ -2578,6 +2578,47 @@ function meta_refresh($time, $url, $disable_cd_check = false)
|
|||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs correct status line header.
|
||||
*
|
||||
* Depending on php sapi one of the two following forms is used:
|
||||
*
|
||||
* Status: 404 Not Found
|
||||
*
|
||||
* HTTP/1.x 404 Not Found
|
||||
*
|
||||
* HTTP version is taken from HTTP_VERSION environment variable,
|
||||
* and defaults to 1.0.
|
||||
*
|
||||
* Sample usage:
|
||||
*
|
||||
* send_status_line(404, 'Not Found');
|
||||
*
|
||||
* @param int $code HTTP status code
|
||||
* @param string $message Message for the status code
|
||||
* @return void
|
||||
*/
|
||||
function send_status_line($code, $message)
|
||||
{
|
||||
if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi')
|
||||
{
|
||||
// in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though
|
||||
header("Status: $code $message", true, $code);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($_SERVER['HTTP_VERSION']))
|
||||
{
|
||||
$version = $_SERVER['HTTP_VERSION'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = 'HTTP/1.0';
|
||||
}
|
||||
header("$version $code $message", true, $code);
|
||||
}
|
||||
}
|
||||
|
||||
//Form validation
|
||||
|
||||
|
||||
|
@ -3621,9 +3662,9 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
|
|||
$user->setup();
|
||||
}
|
||||
|
||||
if ($msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER')
|
||||
if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER')
|
||||
{
|
||||
header("HTTP/1.x 404 Not Found");
|
||||
send_status_line(404, 'Not Found');
|
||||
}
|
||||
|
||||
$msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text;
|
||||
|
|
Loading…
Add table
Reference in a new issue