From 88d7c4fe57eb0255c6c5cb434f3a3aaa0f6e726c Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 30 Sep 2016 22:32:54 +0100 Subject: [PATCH] [ticket/14789] Move form key checks to where they actually do something PHPBB3-14789 --- phpBB/includes/acp/acp_database.php | 15 ++++++++++----- phpBB/includes/acp/acp_icons.php | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 16655ff4cb..a54ba76358 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -42,11 +42,6 @@ class acp_database $form_key = 'acp_database'; 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( '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); } + 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; if ($where == 'store_and_download' || $where == 'store') @@ -233,6 +233,11 @@ class acp_database $file = request_var('file', ''); $download = request_var('download', ''); + if (!check_form_key($form_key)) + { + trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + if (!preg_match('#^backup_\d{10,}_[a-z\d]{16}\.(sql(?:\.(?:gz|bz2))?)$#', $file, $matches)) { trigger_error($user->lang['BACKUP_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index e9bc02d88b..a0ea7dc9b1 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -45,11 +45,6 @@ class acp_icons $form_key = 'acp_icons'; 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'; $this->tpl_name = 'acp_icons'; @@ -334,6 +329,11 @@ class acp_icons case 'create': 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 $images = (isset($_POST['image'])) ? array_keys(request_var('image', array('' => 0))) : array(); @@ -522,6 +522,11 @@ class acp_icons { $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))) { 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( 'MESSAGE_TITLE' => $user->lang['EXPORT_' . $lang], - 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '', ''), + 'MESSAGE_TEXT' => sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '', ''), 'S_USER_NOTICE' => true, ) @@ -719,6 +724,11 @@ class acp_icons 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 * FROM $table ORDER BY {$fields}_order";