From 8a9c7c92bef76a8dfbb72556aaf55f961aa711b3 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Tue, 26 Jan 2010 14:01:20 +0000 Subject: [PATCH] tuning git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10454 89ea8834-ac86-4346-8a33-228a782c2dd0 --- .../plugins/phpbb_captcha_qa_plugin.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php index c8f68f23f0..619a05663f 100644 --- a/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_captcha_qa_plugin.php @@ -87,6 +87,12 @@ class phpbb_captcha_qa } $db->sql_freeresult($result); } + + // Possible snag: the user didn't send a confirm_id. See, if we have something on file. + if (!strlen($this->confirm_id)) + { + $this->load_confirm_id(); + } // okay, if there is a confirm_id, we try to load that confirm's state if (!strlen($this->confirm_id) || !$this->load_answer()) @@ -473,6 +479,38 @@ class phpbb_captcha_qa $this->load_answer(); } + + /** + * See if there is already an entry for the current session. + */ + function load_confirm_id() + { + global $db, $user; + + if (!sizeof($this->question_ids)) + { + return false; + } + + $sql = 'SELECT confirm_id + FROM ' . CAPTCHA_QA_CONFIRM_TABLE . " + WHERE + session_id = '" . $db->sql_escape($user->session_id) . "' + AND lang_iso = '" . $db->sql_escape($this->question_lang) . "' + AND confirm_type = " . $this->type; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($row) + { + $this->confirm_id = $row['confirm_id']; + return true; + } + + return false; + } + /** * Look up everything we need and populate the instance variables. */