1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-01-17 14:18:24 +01:00

[ticket/16955] Clean up captcha classes

PHPBB3-16955
This commit is contained in:
Marc Alexander 2022-12-27 16:13:56 +01:00
parent 83cb41e72a
commit 35228ffd62
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
6 changed files with 22 additions and 12 deletions

View File

@ -49,6 +49,7 @@ $phpbb_class_loader->register();
// Include files that require class loader to be initialized
require_once $phpbb_root_path . 'includes/acp/auth.' . $phpEx;
require_once $phpbb_root_path . 'includes/acp/acp_captcha.' . $phpEx;
class phpbb_cache_container extends \Symfony\Component\DependencyInjection\Container
{

View File

@ -23,6 +23,12 @@ class acp_captcha
{
var $u_action;
/** @var string Template name */
public $tpl_name = 'acp_captcha';
/** @var string Page title language variable */
public $page_title = 'ACP_VC_SETTINGS';
function main($id, $mode)
{
global $user, $template, $phpbb_log, $request;
@ -85,8 +91,6 @@ class acp_captcha
),
);
$this->tpl_name = 'acp_captcha';
$this->page_title = 'ACP_VC_SETTINGS';
$form_key = 'acp_captcha';
add_form_key($form_key);

View File

@ -41,7 +41,7 @@ class factory
* Return a new instance of a given plugin
*
* @param $name
* @return object
* @return object|null
*/
public function get_instance($name)
{

View File

@ -1653,6 +1653,8 @@ class gd
),
),
);
/** @var 1|2|3 $config['captcha_gd_fonts'] */
return array(
'width' => 9,
'height' => 15,

View File

@ -205,7 +205,7 @@ class gd_wave
$x_index_old = intval(($x - 1) / $subdivision_factor);
$x_index_new = intval($x / $subdivision_factor);
if (!empty($plane[$y_index_new][$x_index_new]))
if ($plane[$y_index_new][$x_index_new])
{
$img_pos_cur[1] += $this->wave_height($x, $y, $subdivision_factor, 1) - 30 - $cur_height;
$color = $colors[20];
@ -213,10 +213,10 @@ class gd_wave
$img_pos_cur[1] = min($img_pos_cur[1], $img_y - 1);
$img_buffer[$buffer_cur][$x] = $img_pos_cur;
// Smooth the edges as much as possible by having not more than one low<->high traingle per square
// Smooth the edges as much as possible by having not more than one low<->high triangle per square
// Otherwise, just
$diag_down = (empty($plane[$y_index_old][$x_index_old]) == empty($plane[$y_index_new][$x_index_new]));
$diag_up = (empty($plane[$y_index_old][$x_index_new]) == empty($plane[$y_index_new][$x_index_old]));
$diag_down = !$plane[$y_index_old][$x_index_old] && !$plane[$y_index_new][$x_index_new];
$diag_up = !$plane[$y_index_old][$x_index_new] && !$plane[$y_index_new][$x_index_old];
// natural switching
$mode = ($x + $y) & 1;

View File

@ -39,6 +39,9 @@ class qa
*/
protected $service_name;
/** @var int Question ID */
protected $question = -1;
/**
* Constructor
*
@ -450,7 +453,7 @@ class qa
'session_id' => (string) $user->session_id,
'lang_iso' => (string) $this->question_lang,
'confirm_type' => (int) $this->type,
'question_id' => (int) $this->question,
'question_id' => $this->question,
));
$db->sql_query($sql);
@ -473,7 +476,7 @@ class qa
$this->solved = 0;
$sql = 'UPDATE ' . $this->table_qa_confirm . '
SET question_id = ' . (int) $this->question . "
SET question_id = ' . $this->question . "
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
$db->sql_query($sql);
@ -493,7 +496,7 @@ class qa
$this->solved = 0;
$sql = 'UPDATE ' . $this->table_qa_confirm . '
SET question_id = ' . (int) $this->question . ",
SET question_id = ' . $this->question . ",
attempts = attempts + 1
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
@ -553,7 +556,7 @@ class qa
if ($row)
{
$this->question = $row['question_id'];
$this->question = (int) $row['question_id'];
$this->attempts = $row['attempts'];
$this->question_strict = $row['strict'];
@ -576,7 +579,7 @@ class qa
$sql = 'SELECT answer_text
FROM ' . $this->table_captcha_answers . '
WHERE question_id = ' . (int) $this->question;
WHERE question_id = ' . $this->question;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))