aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/captcha/plugins
diff options
context:
space:
mode:
authorTristan Darricau <tristan.darricau@sensiolabs.com>2016-03-25 11:43:05 +0100
committerTristan Darricau <tristan.darricau@sensiolabs.com>2016-03-25 11:43:05 +0100
commite873ed69449f4cbe0f055f0f9d25d0ef472fbc3a (patch)
treec1717f0d5a98ea7edcdfc60809b894eca282e327 /phpBB/phpbb/captcha/plugins
parent8d989810121e3baf315ceaf8d9cd225317a625d9 (diff)
parent6774c5077ddf82eb2f31e92d327ce6905b73c3df (diff)
downloadforums-e873ed69449f4cbe0f055f0f9d25d0ef472fbc3a.tar
forums-e873ed69449f4cbe0f055f0f9d25d0ef472fbc3a.tar.gz
forums-e873ed69449f4cbe0f055f0f9d25d0ef472fbc3a.tar.bz2
forums-e873ed69449f4cbe0f055f0f9d25d0ef472fbc3a.tar.xz
forums-e873ed69449f4cbe0f055f0f9d25d0ef472fbc3a.zip
Merge branch '3.1.x' into 3.2.x
* 3.1.x: [ticket/14241] Log fatal captcha error to error log [ticket/14241] Prevent empty q&a as a result of improper settings
Diffstat (limited to 'phpBB/phpbb/captcha/plugins')
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php34
1 files changed, 30 insertions, 4 deletions
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index 4df8a86432..7f804850a4 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()))
{
@@ -198,10 +220,12 @@ class qa
*/
function get_template()
{
- global $template;
+ global $phpbb_log, $template, $user;
- if ($this->is_solved())
+ if ($this->is_solved() || empty($this->question_text) || !count($this->question_ids))
{
+ /** @var \phpbb\log\log_interface $phpbb_log */
+ $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING')));
return false;
}
else
@@ -363,13 +387,15 @@ class qa
*/
function validate()
{
- global $user;
+ global $phpbb_log, $user;
$error = '';
if (!sizeof($this->question_ids))
{
- return false;
+ /** @var \phpbb\log\log_interface $phpbb_log */
+ $phpbb_log->add('critical', $user->data['user_id'], $user->ip, 'LOG_ERROR_CAPTCHA', time(), array($user->lang('CONFIRM_QUESTION_MISSING')));
+ return $user->lang('CONFIRM_QUESTION_MISSING');
}
if (!$this->confirm_id)