mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch '3.2.x'
* 3.2.x: [ticket/14241] Log fatal captcha error to error log [ticket/14241] Prevent empty q&a as a result of improper settings
This commit is contained in:
commit
06186ea250
3 changed files with 32 additions and 5 deletions
|
@ -606,6 +606,7 @@ $lang = array_merge($lang, array(
|
||||||
|
|
||||||
'LOG_ERROR_JABBER' => '<strong>Jabber error</strong><br />» %s',
|
'LOG_ERROR_JABBER' => '<strong>Jabber error</strong><br />» %s',
|
||||||
'LOG_ERROR_EMAIL' => '<strong>Email error</strong><br />» %s',
|
'LOG_ERROR_EMAIL' => '<strong>Email error</strong><br />» %s',
|
||||||
|
'LOG_ERROR_CAPTCHA' => '<strong>CAPTCHA error</strong><br />» %s',
|
||||||
|
|
||||||
'LOG_FORUM_ADD' => '<strong>Created new forum</strong><br />» %s',
|
'LOG_FORUM_ADD' => '<strong>Created new forum</strong><br />» %s',
|
||||||
'LOG_FORUM_COPIED_PERMISSIONS' => '<strong>Copied forum permissions</strong> from %1$s<br />» %2$s',
|
'LOG_FORUM_COPIED_PERMISSIONS' => '<strong>Copied forum permissions</strong> from %1$s<br />» %2$s',
|
||||||
|
|
|
@ -40,6 +40,7 @@ $lang = array_merge($lang, array(
|
||||||
'CAPTCHA_QA' => 'Q&A',
|
'CAPTCHA_QA' => 'Q&A',
|
||||||
'CONFIRM_QUESTION_EXPLAIN' => 'This question is a means of preventing automated form submissions by spambots.',
|
'CONFIRM_QUESTION_EXPLAIN' => 'This question is a means of preventing automated form submissions by spambots.',
|
||||||
'CONFIRM_QUESTION_WRONG' => 'You have provided an invalid answer to the question.',
|
'CONFIRM_QUESTION_WRONG' => 'You have provided an invalid answer to the question.',
|
||||||
|
'CONFIRM_QUESTION_MISSING' => 'Questions for the captcha could not be retrieved. Please contact a board administrator.',
|
||||||
|
|
||||||
'QUESTION_ANSWERS' => 'Answers',
|
'QUESTION_ANSWERS' => 'Answers',
|
||||||
'ANSWERS_EXPLAIN' => 'Please enter valid answers to the question, one per line.',
|
'ANSWERS_EXPLAIN' => 'Please enter valid answers to the question, one per line.',
|
||||||
|
@ -60,5 +61,4 @@ $lang = array_merge($lang, array(
|
||||||
|
|
||||||
'QA_ERROR_MSG' => 'Please fill in all fields and enter at least one answer.',
|
'QA_ERROR_MSG' => 'Please fill in all fields and enter at least one answer.',
|
||||||
'QA_LAST_QUESTION' => 'You cannot delete all questions while the plugin is active.',
|
'QA_LAST_QUESTION' => 'You cannot delete all questions while the plugin is active.',
|
||||||
|
|
||||||
));
|
));
|
||||||
|
|
|
@ -100,6 +100,28 @@ class qa
|
||||||
$db->sql_freeresult($result);
|
$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
|
// 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()))
|
if (!$this->load_answer() && (!$this->load_confirm_id() || !$this->load_answer()))
|
||||||
{
|
{
|
||||||
|
@ -198,10 +220,12 @@ class qa
|
||||||
*/
|
*/
|
||||||
function get_template()
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -363,13 +387,15 @@ class qa
|
||||||
*/
|
*/
|
||||||
function validate()
|
function validate()
|
||||||
{
|
{
|
||||||
global $user;
|
global $phpbb_log, $user;
|
||||||
|
|
||||||
$error = '';
|
$error = '';
|
||||||
|
|
||||||
if (!sizeof($this->question_ids))
|
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)
|
if (!$this->confirm_id)
|
||||||
|
|
Loading…
Add table
Reference in a new issue