diff options
Diffstat (limited to 'phpBB/includes/acp/acp_extensions.php')
-rw-r--r-- | phpBB/includes/acp/acp_extensions.php | 60 |
1 files changed, 41 insertions, 19 deletions
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index b41f4d4e81..2ff479d824 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -55,6 +55,11 @@ class acp_extensions $ext_name = ''; } + if (in_array($action, array('enable', 'disable', 'delete_data')) && !check_link_hash($request->variable('hash', ''), $action . '.' . $ext_name)) + { + trigger_error('FORM_INVALID', E_USER_WARNING); + } + // If they've specified an extension, let's load the metadata manager and validate it. if ($ext_name) { @@ -66,7 +71,7 @@ class acp_extensions } catch(\phpbb\extension\exception $e) { - trigger_error($e); + trigger_error($e, E_USER_WARNING); } } @@ -83,6 +88,11 @@ class acp_extensions break; case 'enable_pre': + if (!$md_manager->validate_dir()) + { + trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + if (!$md_manager->validate_enable()) { trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); @@ -96,12 +106,18 @@ class acp_extensions $this->tpl_name = 'acp_ext_enable'; $template->assign_vars(array( - 'PRE' => true, - 'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name), + 'PRE' => true, + 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_ENABLE_CONFIRM', $md_manager->get_metadata('display-name')), + 'U_ENABLE' => $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name), )); break; case 'enable': + if (!$md_manager->validate_dir()) + { + trigger_error($user->lang['EXTENSION_DIR_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + if (!$md_manager->validate_enable()) { trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); @@ -116,7 +132,7 @@ class acp_extensions { $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=enable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('enable.' . $ext_name)); } } } @@ -128,7 +144,7 @@ class acp_extensions $this->tpl_name = 'acp_ext_enable'; $template->assign_vars(array( - 'U_RETURN' => $this->u_action . '&action=list', + 'U_RETURN' => $this->u_action . '&action=list', )); break; @@ -141,8 +157,9 @@ class acp_extensions $this->tpl_name = 'acp_ext_disable'; $template->assign_vars(array( - 'PRE' => true, - 'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name), + 'PRE' => true, + 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DISABLE_CONFIRM', $md_manager->get_metadata('display-name')), + 'U_DISABLE' => $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name), )); break; @@ -154,7 +171,7 @@ class acp_extensions { $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=disable&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('disable.' . $ext_name)); } } @@ -165,16 +182,21 @@ class acp_extensions )); break; - case 'purge_pre': - $this->tpl_name = 'acp_ext_purge'; + case 'delete_data_pre': + if ($phpbb_extension_manager->enabled($ext_name)) + { + redirect($this->u_action); + } + $this->tpl_name = 'acp_ext_delete_data'; $template->assign_vars(array( - 'PRE' => true, - 'U_PURGE' => $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name), + 'PRE' => true, + 'L_CONFIRM_MESSAGE' => $this->user->lang('EXTENSION_DELETE_DATA_CONFIRM', $md_manager->get_metadata('display-name')), + 'U_PURGE' => $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name), )); break; - case 'purge': + case 'delete_data': try { while ($phpbb_extension_manager->purge_step($ext_name)) @@ -184,7 +206,7 @@ class acp_extensions { $template->assign_var('S_NEXT_STEP', true); - meta_refresh(0, $this->u_action . '&action=purge&ext_name=' . urlencode($ext_name)); + meta_refresh(0, $this->u_action . '&action=delete_data&ext_name=' . urlencode($ext_name) . '&hash=' . generate_link_hash('delete_data.' . $ext_name)); } } } @@ -193,7 +215,7 @@ class acp_extensions $template->assign_var('MIGRATOR_ERROR', $e->getLocalisedMessage($user)); } - $this->tpl_name = 'acp_ext_purge'; + $this->tpl_name = 'acp_ext_delete_data'; $template->assign_vars(array( 'U_RETURN' => $this->u_action . '&action=list', @@ -233,7 +255,6 @@ class acp_extensions $this->output_actions('enabled', array( 'DISABLE' => $this->u_action . '&action=disable_pre&ext_name=' . urlencode($name), - 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . urlencode($name), )); } catch(\phpbb\extension\exception $e) @@ -267,7 +288,7 @@ class acp_extensions $this->output_actions('disabled', array( 'ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name), - 'PURGE' => $this->u_action . '&action=purge_pre&ext_name=' . urlencode($name), + 'DELETE_DATA' => $this->u_action . '&action=delete_data_pre&ext_name=' . urlencode($name), )); } catch(\phpbb\extension\exception $e) @@ -325,8 +346,9 @@ class acp_extensions foreach ($actions as $lang => $url) { $this->template->assign_block_vars($block . '.actions', array( - 'L_ACTION' => $this->user->lang($lang), - 'U_ACTION' => $url, + 'L_ACTION' => $this->user->lang('EXTENSION_' . $lang), + 'L_ACTION_EXPLAIN' => (isset($this->user->lang['EXTENSION_' . $lang . '_EXPLAIN'])) ? $this->user->lang('EXTENSION_' . $lang . '_EXPLAIN') : '', + 'U_ACTION' => $url, )); } } |