aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/captcha/plugins
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2016-03-11 10:51:07 +0100
committerMarc Alexander <admin@m-a-styles.de>2016-03-11 10:51:07 +0100
commit4c5c289f75c267e1f3e789c0304054ed4e3e2564 (patch)
treeddbc06fade7fe78f0e6322185c785f982c191497 /phpBB/phpbb/captcha/plugins
parent9288a50bcf30beb78a0b38ab39c38208becf6a2c (diff)
downloadforums-4c5c289f75c267e1f3e789c0304054ed4e3e2564.tar
forums-4c5c289f75c267e1f3e789c0304054ed4e3e2564.tar.gz
forums-4c5c289f75c267e1f3e789c0304054ed4e3e2564.tar.bz2
forums-4c5c289f75c267e1f3e789c0304054ed4e3e2564.tar.xz
forums-4c5c289f75c267e1f3e789c0304054ed4e3e2564.zip
[ticket/14241] Prevent empty q&a as a result of improper settings
Improper setup of the q&a captcha in combination with the admin choosing a default language that does not have any questions and answers set might result in the user being presented empty questions and answers. This change will try to fall back to any question in case the admin incorrectly set the default language and has no questions & answers set. If that does not work, the captcha will not allow passing it and suggest to contact the board admin to resolve this issue. PHPBB3-14241
Diffstat (limited to 'phpBB/phpbb/captcha/plugins')
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index 2771369e57..e6059b968f 100644
--- a/phpBB/phpbb/captcha/plugins/qa.php
+++ b/phpBB/phpbb/captcha/plugins/qa.php
@@ -100,6 +100,28 @@ class qa
$db->sql_freeresult($result);
}
+ // final fallback to any language
+ if (!sizeof($this->question_ids))
+ {
+ $this->question_lang = '';
+
+ $sql = 'SELECT q.question_id, q.lang_iso
+ FROM ' . $this->table_captcha_questions . ' q, ' . $this->table_captcha_answers . ' a
+ WHERE q.question_id = a.question_id
+ GROUP BY lang_iso';
+ $result = $db->sql_query($sql, 7200);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ if (empty($this->question_lang))
+ {
+ $this->question_lang = $row['lang_iso'];
+ }
+ $this->question_ids[$row['question_id']] = $row['question_id'];
+ }
+ $db->sql_freeresult($result);
+ }
+
// okay, if there is a confirm_id, we try to load that confirm's state. If not, we try to find one
if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer()))
{
@@ -200,7 +222,7 @@ class qa
{
global $template;
- if ($this->is_solved())
+ if ($this->is_solved() || !count($this->question_ids))
{
return false;
}
@@ -370,7 +392,7 @@ class qa
if (!sizeof($this->question_ids))
{
- return false;
+ return $user->lang['CONFIRM_QUESTION_MISSING'];
}
if (!$this->confirm_id)