mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12831] reimplemented headers as array
https://tracker.phpbb.com/browse/PHPBB3-12831 PHPBB3-12831
This commit is contained in:
parent
a7794b765c
commit
8989f6f878
2 changed files with 33 additions and 29 deletions
|
@ -5030,8 +5030,19 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||||
'SITE_LOGO_IMG' => $user->img('site_logo'),
|
'SITE_LOGO_IMG' => $user->img('site_logo'),
|
||||||
));
|
));
|
||||||
|
|
||||||
// A listener can set this variable to `false` when it wants to prevent setting of headers
|
// An array of http headers that phpbb will set. The following event may override these.
|
||||||
$page_header_set_headers = true;
|
$http_headers = array(
|
||||||
|
// application/xhtml+xml not used because of IE
|
||||||
|
'Content-type' => 'text/html; charset=UTF-8',
|
||||||
|
'Cache-Control' => 'private, no-cache="set-cookie"',
|
||||||
|
'Expires' => '0',
|
||||||
|
'Pragma' => 'no-cache',
|
||||||
|
);
|
||||||
|
if (!empty($user->data['is_bot']))
|
||||||
|
{
|
||||||
|
// Let reverse proxies know we detected a bot.
|
||||||
|
$http_headers['X-PHPBB-IS-BOT'] = 'yes';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute code and/or overwrite _common_ template variables after they have been assigned.
|
* Execute code and/or overwrite _common_ template variables after they have been assigned.
|
||||||
|
@ -5043,28 +5054,18 @@ function page_header($page_title = '', $display_online_list = false, $item_id =
|
||||||
* session item, e.g. forum for
|
* session item, e.g. forum for
|
||||||
* session_forum_id
|
* session_forum_id
|
||||||
* @var int item_id Restrict online users to item id
|
* @var int item_id Restrict online users to item id
|
||||||
* @var bool page_header_set_headers Set to false if phpBB should not
|
* @var array http_headers HTTP headers that should be set by phpbb
|
||||||
* set HTTP headers (since you have
|
|
||||||
* set them elsewhere).
|
|
||||||
*
|
*
|
||||||
* @since 3.1.0-b3
|
* @since 3.1.0-b3
|
||||||
*/
|
*/
|
||||||
$vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_set_headers');
|
$vars = array('page_title', 'display_online_list', 'item_id', 'item', 'http_headers');
|
||||||
extract($phpbb_dispatcher->trigger_event('core.page_header_after', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.page_header_after', compact($vars)));
|
||||||
|
|
||||||
if ($page_header_set_headers)
|
if (is_array($http_headers))
|
||||||
{
|
{
|
||||||
// application/xhtml+xml not used because of IE
|
foreach ($http_headers as $hname => $hval)
|
||||||
header('Content-type: text/html; charset=UTF-8');
|
|
||||||
|
|
||||||
header('Cache-Control: private, no-cache="set-cookie"');
|
|
||||||
header('Expires: 0');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
|
|
||||||
if (!empty($user->data['is_bot']))
|
|
||||||
{
|
{
|
||||||
// Let reverse proxies know we detected a bot.
|
header((string) $hname.': '.(string) $hval);
|
||||||
header('X-PHPBB-IS-BOT: yes');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,30 +107,33 @@ function adm_page_header($page_title)
|
||||||
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
|
||||||
));
|
));
|
||||||
|
|
||||||
// A listener can set this variable to `false` when it wants to prevent setting of headers
|
// An array of http headers that phpbb will set. The following event may override these.
|
||||||
$adm_page_header_set_headers = true;
|
$http_headers = array(
|
||||||
|
// application/xhtml+xml not used because of IE
|
||||||
|
'Content-type' => 'text/html; charset=UTF-8',
|
||||||
|
'Cache-Control' => 'private, no-cache="set-cookie"',
|
||||||
|
'Expires' => '0',
|
||||||
|
'Pragma' => 'no-cache',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute code and/or overwrite _common_ template variables after they have been assigned.
|
* Execute code and/or overwrite _common_ template variables after they have been assigned.
|
||||||
*
|
*
|
||||||
* @event core.adm_page_header_after
|
* @event core.adm_page_header_after
|
||||||
* @var string page_title Page title
|
* @var string page_title Page title
|
||||||
* @var bool adm_page_header_set_headers Set to false if phpBB should not
|
* @var array http_headers HTTP headers that should be set by phpbb
|
||||||
* set HTTP headers (useful for integrators).
|
|
||||||
*
|
*
|
||||||
* @since 3.1.0-RC3
|
* @since 3.1.0-RC3
|
||||||
*/
|
*/
|
||||||
$vars = array('page_title', 'adm_page_header_set_headers');
|
$vars = array('page_title', 'http_headers');
|
||||||
extract($phpbb_dispatcher->trigger_event('core.adm_page_header_after', compact($vars)));
|
extract($phpbb_dispatcher->trigger_event('core.adm_page_header_after', compact($vars)));
|
||||||
|
|
||||||
if ($adm_page_header_set_headers)
|
if (is_array($http_headers))
|
||||||
{
|
{
|
||||||
// application/xhtml+xml not used because of IE
|
foreach ($http_headers as $hname => $hval)
|
||||||
header('Content-type: text/html; charset=UTF-8');
|
{
|
||||||
|
header((string) $hname.': '.(string) $hval);
|
||||||
header('Cache-Control: private, no-cache="set-cookie"');
|
}
|
||||||
header('Expires: 0');
|
|
||||||
header('Pragma: no-cache');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue