mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-12 14:28:56 +00:00
Merge pull request #2845 from rxu/ticket/12942
[ticket/12942] Add core.add_form_key core event
This commit is contained in:
commit
c10c6bd342
1 changed files with 22 additions and 1 deletions
|
@ -2540,7 +2540,7 @@ function check_link_hash($token, $link_name)
|
||||||
*/
|
*/
|
||||||
function add_form_key($form_name)
|
function add_form_key($form_name)
|
||||||
{
|
{
|
||||||
global $config, $template, $user;
|
global $config, $template, $user, $phpbb_dispatcher;
|
||||||
|
|
||||||
$now = time();
|
$now = time();
|
||||||
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
|
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
|
||||||
|
@ -2551,6 +2551,27 @@ function add_form_key($form_name)
|
||||||
'form_token' => $token,
|
'form_token' => $token,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Perform additional actions on creation of the form token
|
||||||
|
*
|
||||||
|
* @event core.add_form_key
|
||||||
|
* @var string form_name The form name
|
||||||
|
* @var int now Current time timestamp
|
||||||
|
* @var string s_fields Generated hidden fields
|
||||||
|
* @var string token Form token
|
||||||
|
* @var string token_sid User session ID
|
||||||
|
*
|
||||||
|
* @since 3.1.0-RC3
|
||||||
|
*/
|
||||||
|
$vars = array(
|
||||||
|
'form_name',
|
||||||
|
'now',
|
||||||
|
's_fields',
|
||||||
|
'token',
|
||||||
|
'token_sid',
|
||||||
|
);
|
||||||
|
extract($phpbb_dispatcher->trigger_event('core.add_form_key', compact($vars)));
|
||||||
|
|
||||||
$template->assign_vars(array(
|
$template->assign_vars(array(
|
||||||
'S_FORM_TOKEN' => $s_fields,
|
'S_FORM_TOKEN' => $s_fields,
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Reference in a new issue