From a0acfb6a3fce9a547d19c28ac99654275152ac98 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Mon, 27 Jul 2009 11:39:28 +0000 Subject: [PATCH] Minor captcha API change - disable display of plugin by returning false in get_template. git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9869 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../captcha/plugins/captcha_abstract.php | 35 +++++++++++-------- .../plugins/phpbb_captcha_qa_plugin.php | 21 +++++++---- .../plugins/phpbb_recaptcha_plugin.php | 25 ++++++++----- phpBB/includes/functions.php | 1 - phpBB/includes/ucp/ucp_register.php | 3 +- .../styles/prosilver/template/login_body.html | 2 +- .../prosilver/template/posting_editor.html | 2 +- .../subsilver2/template/login_body.html | 2 +- .../subsilver2/template/posting_body.html | 2 +- 9 files changed, 56 insertions(+), 37 deletions(-) diff --git a/phpBB/includes/captcha/plugins/captcha_abstract.php b/phpBB/includes/captcha/plugins/captcha_abstract.php index fb64063a90..d24e554188 100644 --- a/phpBB/includes/captcha/plugins/captcha_abstract.php +++ b/phpBB/includes/captcha/plugins/captcha_abstract.php @@ -87,21 +87,28 @@ class phpbb_default_captcha { global $config, $user, $template, $phpEx, $phpbb_root_path; - $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); - $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; - - $template->assign_vars(array( - 'CONFIRM_IMAGE_LINK' => $link, - 'CONFIRM_IMAGE' => '', - 'CONFIRM_IMG' => '', - 'CONFIRM_ID' => $this->confirm_id, - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh'] && $this->type == CONFIRM_REG) ? true : false, - 'L_CONFIRM_EXPLAIN' => $explain, - )); + if ($this->is_solved()) + { + return false; + } + else + { + $link = append_sid($phpbb_root_path . 'ucp.' . $phpEx . '?mode=confirm&confirm_id=' . $this->confirm_id . '&type=' . $this->type); + $explain = ($this->type != CONFIRM_POST) ? sprintf($user->lang['CONFIRM_EXPLAIN'], '', '') : $user->lang['POST_CONFIRM_EXPLAIN']; + + $template->assign_vars(array( + 'CONFIRM_IMAGE_LINK' => $link, + 'CONFIRM_IMAGE' => '', + 'CONFIRM_IMG' => '', + 'CONFIRM_ID' => $this->confirm_id, + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + 'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh'] && $this->type == CONFIRM_REG) ? true : false, + 'L_CONFIRM_EXPLAIN' => $explain, + )); - return 'captcha_default.html'; + return 'captcha_default.html'; + } } function get_demo_template($id) diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index 0a0a9f9211..1b34f26bfa 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -171,14 +171,21 @@ class phpbb_captcha_qa { global $template; - $template->assign_vars(array( - 'QA_CONFIRM_QUESTION' => $this->question_text, - 'QA_CONFIRM_ID' => $this->confirm_id, - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); + if ($this->is_solved()) + { + return false; + } + else + { + $template->assign_vars(array( + 'QA_CONFIRM_QUESTION' => $this->question_text, + 'QA_CONFIRM_ID' => $this->confirm_id, + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + )); - return 'captcha_qa.html'; + return 'captcha_qa.html'; + } } /** diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index f148b12656..9a2cc11ebd 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -128,16 +128,23 @@ class phpbb_recaptcha extends phpbb_default_captcha { global $config, $user, $template; - $template->assign_vars(array( - 'RECAPTCHA_SERVER' => $this->recaptcha_server, - 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', - 'RECAPTCHA_ERRORGET' => '', - 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), - 'S_CONFIRM_CODE' => true, - 'S_TYPE' => $this->type, - )); + if ($this->is_solved()) + { + return false; + } + else + { + $template->assign_vars(array( + 'RECAPTCHA_SERVER' => $this->recaptcha_server, + 'RECAPTCHA_PUBKEY' => isset($config['recaptcha_pubkey']) ? $config['recaptcha_pubkey'] : '', + 'RECAPTCHA_ERRORGET' => '', + 'S_RECAPTCHA_AVAILABLE' => $this->is_available(), + 'S_CONFIRM_CODE' => true, + 'S_TYPE' => $this->type, + )); - return 'captcha_recaptcha.html'; + return 'captcha_recaptcha.html'; + } } function get_demo_template($id) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 2d86b233f7..4badd69e9f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2752,7 +2752,6 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa $captcha->reset(); $template->assign_vars(array( - 'S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index da62061a72..f428b4603c 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -446,10 +446,9 @@ class ucp_register $confirm_image = ''; // Visual Confirmation - Show images - if ($config['enable_confirm'] && !$captcha->is_solved()) + if ($config['enable_confirm']) { $template->assign_vars(array( - 'L_CONFIRM_EXPLAIN' => sprintf($user->lang['CONFIRM_EXPLAIN'], '', ''), 'CAPTCHA_TEMPLATE' => $captcha->get_template(), )); } diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index a4cd990630..61f796004f 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -21,7 +21,7 @@
{L_RESEND_ACTIVATION}
- + diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index dea3277ba2..a02ad3ed10 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -99,7 +99,7 @@
- + diff --git a/phpBB/styles/subsilver2/template/login_body.html b/phpBB/styles/subsilver2/template/login_body.html index b8a789bfe7..810a7376f2 100644 --- a/phpBB/styles/subsilver2/template/login_body.html +++ b/phpBB/styles/subsilver2/template/login_body.html @@ -65,7 +65,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/posting_body.html b/phpBB/styles/subsilver2/template/posting_body.html index f8996b1517..963e6fe966 100644 --- a/phpBB/styles/subsilver2/template/posting_body.html +++ b/phpBB/styles/subsilver2/template/posting_body.html @@ -332,7 +332,7 @@ - +