aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/captcha/plugins/qa.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/phpbb/captcha/plugins/qa.php')
-rw-r--r--phpBB/phpbb/captcha/plugins/qa.php69
1 files changed, 35 insertions, 34 deletions
diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php
index a9d133d8f2..966b8d32f2 100644
--- a/phpBB/phpbb/captcha/plugins/qa.php
+++ b/phpBB/phpbb/captcha/plugins/qa.php
@@ -21,7 +21,7 @@ class qa
{
var $confirm_id;
var $answer;
- var $question_ids;
+ var $question_ids = [];
var $question_text;
var $question_lang;
var $question_strict;
@@ -58,14 +58,14 @@ class qa
*/
function init($type)
{
- global $config, $db, $user;
+ global $config, $db, $user, $request;
// load our language file
$user->add_lang('captcha_qa');
// read input
- $this->confirm_id = request_var('qa_confirm_id', '');
- $this->answer = utf8_normalize_nfc(request_var('qa_answer', '', true));
+ $this->confirm_id = $request->variable('qa_confirm_id', '');
+ $this->answer = $request->variable('qa_answer', '', true);
$this->type = (int) $type;
$this->question_lang = $user->lang_name;
@@ -84,7 +84,7 @@ class qa
$db->sql_freeresult($result);
// fallback to the board default lang
- if (!sizeof($this->question_ids))
+ if (!count($this->question_ids))
{
$this->question_lang = $config['default_lang'];
@@ -101,14 +101,13 @@ class qa
}
// final fallback to any language
- if (!sizeof($this->question_ids))
+ if (!count($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';
+ WHERE q.question_id = a.question_id';
$result = $db->sql_query($sql, 7200);
while ($row = $db->sql_fetchrow($result))
@@ -135,9 +134,9 @@ class qa
*/
public function is_installed()
{
- global $db;
+ global $phpbb_container;
- $db_tool = new \phpbb\db\tools($db);
+ $db_tool = $phpbb_container->get('dbal.tools');
return $db_tool->sql_table_exists($this->table_captcha_questions);
}
@@ -311,7 +310,7 @@ class qa
}
while ($row = $db->sql_fetchrow($result));
- if (sizeof($sql_in))
+ if (count($sql_in))
{
$sql = 'DELETE FROM ' . $this->table_qa_confirm . '
WHERE ' . $db->sql_in_set('confirm_id', $sql_in);
@@ -334,10 +333,9 @@ class qa
*/
function install()
{
- global $db;
-
- $db_tool = new \phpbb\db\tools($db);
+ global $phpbb_container;
+ $db_tool = $phpbb_container->get('dbal.tools');
$schemas = array(
$this->table_captcha_questions => array (
'COLUMNS' => array(
@@ -396,7 +394,7 @@ class qa
$error = '';
- if (!sizeof($this->question_ids))
+ if (!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')));
@@ -440,7 +438,7 @@ class qa
{
global $db, $user;
- if (!sizeof($this->question_ids))
+ if (!count($this->question_ids))
{
return;
}
@@ -466,7 +464,7 @@ class qa
{
global $db, $user;
- if (!sizeof($this->question_ids))
+ if (!count($this->question_ids))
{
return;
}
@@ -537,7 +535,7 @@ class qa
{
global $db, $user;
- if (!strlen($this->confirm_id) || !sizeof($this->question_ids))
+ if (!strlen($this->confirm_id) || !count($this->question_ids))
{
return false;
}
@@ -572,9 +570,9 @@ class qa
*/
function check_answer()
{
- global $db;
+ global $db, $request;
- $answer = ($this->question_strict) ? utf8_normalize_nfc(request_var('qa_answer', '', true)) : utf8_clean_string(utf8_normalize_nfc(request_var('qa_answer', '', true)));
+ $answer = ($this->question_strict) ? $request->variable('qa_answer', '', true) : utf8_clean_string($request->variable('qa_answer', '', true));
$sql = 'SELECT answer_text
FROM ' . $this->table_captcha_answers . '
@@ -626,7 +624,9 @@ class qa
*/
function is_solved()
{
- if (request_var('qa_answer', false) && $this->solved === 0)
+ global $request;
+
+ if ($request->variable('qa_answer', false) && $this->solved === 0)
{
$this->validate();
}
@@ -637,10 +637,9 @@ class qa
/**
* API function - The ACP backend, this marks the end of the easy methods
*/
- function acp_page($id, &$module)
+ function acp_page($id, $module)
{
- global $user, $template;
- global $config;
+ global $config, $request, $phpbb_log, $template, $user;
$user->add_lang('acp/board');
$user->add_lang('captcha_qa');
@@ -655,9 +654,9 @@ class qa
$form_key = 'acp_captcha';
add_form_key($form_key);
- $submit = request_var('submit', false);
- $question_id = request_var('question_id', 0);
- $action = request_var('action', '');
+ $submit = $request->variable('submit', false);
+ $question_id = $request->variable('question_id', 0);
+ $action = $request->variable('action', '');
// we have two pages, so users might want to navigate from one to the other
$list_url = $module->u_action . "&configure=1&select_captcha=" . $this->get_service_name();
@@ -762,7 +761,7 @@ class qa
$this->acp_add_question($question_input);
}
- add_log('admin', 'LOG_CONFIG_VISUAL');
+ $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CONFIG_VISUAL');
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($list_url));
}
}
@@ -776,7 +775,7 @@ class qa
/**
* This handles the list overview
*/
- function acp_question_list(&$module)
+ function acp_question_list($module)
{
global $db, $template;
@@ -848,7 +847,9 @@ class qa
*/
function acp_get_question_input()
{
- $answers = utf8_normalize_nfc(request_var('answers', '', true));
+ global $request;
+
+ $answers = $request->variable('answers', '', true);
// Convert answers into array and filter if answers are set
if (strlen($answers))
@@ -859,9 +860,9 @@ class qa
}
$question = array(
- 'question_text' => request_var('question_text', '', true),
- 'strict' => request_var('strict', false),
- 'lang_iso' => request_var('lang_iso', ''),
+ 'question_text' => $request->variable('question_text', '', true),
+ 'strict' => $request->variable('strict', false),
+ 'lang_iso' => $request->variable('lang_iso', ''),
'answers' => $answers,
);
return $question;
@@ -977,7 +978,7 @@ class qa
if (!isset($langs[$question_data['lang_iso']]) ||
!strlen($question_data['question_text']) ||
- !sizeof($question_data['answers']) ||
+ !count($question_data['answers']) ||
!is_array($question_data['answers']))
{
return false;