Set response code in some cases (#1319)

* Set response code in some cases

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-01-17 11:10:18 +07:00 committed by GitHub
commit 125cd11c01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 33 additions and 34 deletions

View file

@ -1628,10 +1628,14 @@ function obtain_word_list(&$orig_word, &$replacement_word)
return true;
}
function bb_die($msg_text)
function bb_die($msg_text, $status_code = null)
{
global $ajax, $bb_cfg, $lang, $template, $theme, $userdata, $user;
if (isset($status_code)) {
http_response_code($status_code);
}
if (defined('IN_AJAX')) {
$ajax->ajax_die($msg_text);
}
@ -1682,15 +1686,20 @@ function bb_die($msg_text)
exit;
}
function bb_simple_die($txt)
function bb_simple_die($txt, $status_code = null)
{
global $bb_cfg;
header('Content-Type: text/plain; charset=' . $bb_cfg['charset']);
if (isset($status_code)) {
http_response_code($status_code);
}
if (!empty($_COOKIE['explain'])) {
bb_die("bb_simple_die:<br /><br />$txt");
}
header('Content-Type: text/plain; charset=' . $bb_cfg['charset']);
die($txt);
}
@ -1733,7 +1742,7 @@ function redirect($url)
$redirect_url = $server_protocol . $server_name . $server_port . $script_name . preg_replace('#^\/?(.*?)\/?$#', '/\1', $url);
// Behave as per HTTP/1.1 spec for others
header('Location: ' . $redirect_url);
header('Location: ' . $redirect_url, response_code: 301);
exit;
}