Merge pull request #4474 from marc1706/ticket/14789

[ticket/14789] Move form key checks to where they actually do something

* marc1706/ticket/14789:
  [ticket/14789] Remove obsolete check_form_key() and add missing hashes
  [ticket/14789] Move form key checks to where they actually do something
This commit is contained in:
Tristan Darricau 2016-10-02 17:18:22 +02:00
commit cd4190a72d
No known key found for this signature in database
GPG key ID: 817043C2E29DB881
3 changed files with 29 additions and 13 deletions

View file

@ -42,11 +42,6 @@ class acp_database
$form_key = 'acp_database'; $form_key = 'acp_database';
add_form_key($form_key); add_form_key($form_key);
if ($submit && !check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$template->assign_vars(array( $template->assign_vars(array(
'MODE' => $mode 'MODE' => $mode
)); ));
@ -70,6 +65,11 @@ class acp_database
trigger_error($user->lang['TABLE_SELECT_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['TABLE_SELECT_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING);
} }
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$store = $download = $structure = $schema_data = false; $store = $download = $structure = $schema_data = false;
if ($where == 'store_and_download' || $where == 'store') if ($where == 'store_and_download' || $where == 'store')

View file

@ -45,11 +45,6 @@ class acp_icons
$form_key = 'acp_icons'; $form_key = 'acp_icons';
add_form_key($form_key); add_form_key($form_key);
if ($submit && !check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$mode = ($mode == 'smilies') ? 'smilies' : 'icons'; $mode = ($mode == 'smilies') ? 'smilies' : 'icons';
$this->tpl_name = 'acp_icons'; $this->tpl_name = 'acp_icons';
@ -334,6 +329,11 @@ class acp_icons
case 'create': case 'create':
case 'modify': case 'modify':
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
// Get items to create/modify // Get items to create/modify
$images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array(); $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array();
@ -522,6 +522,11 @@ class acp_icons
{ {
$order = 0; $order = 0;
if (!check_form_key($form_key))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak))) if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak)))
{ {
trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING); trigger_error($user->lang['PAK_FILE_NOT_READABLE'] . adm_back_link($this->u_action), E_USER_WARNING);
@ -707,7 +712,7 @@ class acp_icons
$template->assign_vars(array( $template->assign_vars(array(
'MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang], 'MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang],
'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&amp;action=send">', '</a>'), 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="' . $this->u_action . '&amp;action=send&amp;hash=' . generate_link_hash('acp_icons') . '">', '</a>'),
'S_USER_NOTICE' => true, 'S_USER_NOTICE' => true,
) )
@ -719,6 +724,11 @@ class acp_icons
case 'send': case 'send':
if (!check_link_hash($request->variable('hash', ''), 'acp_icons'))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
$sql = "SELECT * $sql = "SELECT *
FROM $table FROM $table
ORDER BY {$fields}_order"; ORDER BY {$fields}_order";

View file

@ -2274,6 +2274,12 @@ class acp_users
{ {
trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING); trigger_error($user->lang['NO_GROUP'] . adm_back_link($this->u_action . '&amp;u=' . $user_id), E_USER_WARNING);
} }
if (!check_link_hash($request->variable('hash', ''), 'acp_users'))
{
trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
}
group_user_attributes($action, $group_id, $user_id); group_user_attributes($action, $group_id, $user_id);
if ($action == 'default') if ($action == 'default')
@ -2431,8 +2437,8 @@ class acp_users
{ {
$template->assign_block_vars('group', array( $template->assign_block_vars('group', array(
'U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&amp;mode=manage&amp;action=edit&amp;u=$user_id&amp;g={$data['group_id']}&amp;back_link=acp_users_groups"), 'U_EDIT_GROUP' => append_sid("{$phpbb_admin_path}index.$phpEx", "i=groups&amp;mode=manage&amp;action=edit&amp;u=$user_id&amp;g={$data['group_id']}&amp;back_link=acp_users_groups"),
'U_DEFAULT' => $this->u_action . "&amp;action=default&amp;u=$user_id&amp;g=" . $data['group_id'], 'U_DEFAULT' => $this->u_action . "&amp;action=default&amp;u=$user_id&amp;g=" . $data['group_id'] . '&amp;hash=' . generate_link_hash('acp_users'),
'U_DEMOTE_PROMOTE' => $this->u_action . '&amp;action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&amp;u=$user_id&amp;g=" . $data['group_id'], 'U_DEMOTE_PROMOTE' => $this->u_action . '&amp;action=' . (($data['group_leader']) ? 'demote' : 'promote') . "&amp;u=$user_id&amp;g=" . $data['group_id'] . '&amp;hash=' . generate_link_hash('acp_users'),
'U_DELETE' => $this->u_action . "&amp;action=delete&amp;u=$user_id&amp;g=" . $data['group_id'], 'U_DELETE' => $this->u_action . "&amp;action=delete&amp;u=$user_id&amp;g=" . $data['group_id'],
'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&amp;action=approve&amp;u=$user_id&amp;g=" . $data['group_id'] : '', 'U_APPROVE' => ($group_type == 'pending') ? $this->u_action . "&amp;action=approve&amp;u=$user_id&amp;g=" . $data['group_id'] : '',