mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-10 13:28:55 +00:00
[ticket/16955] Clean up captcha classes
PHPBB3-16955
This commit is contained in:
parent
83cb41e72a
commit
35228ffd62
6 changed files with 22 additions and 12 deletions
|
@ -49,6 +49,7 @@ $phpbb_class_loader->register();
|
||||||
|
|
||||||
// Include files that require class loader to be initialized
|
// 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/auth.' . $phpEx;
|
||||||
|
require_once $phpbb_root_path . 'includes/acp/acp_captcha.' . $phpEx;
|
||||||
|
|
||||||
class phpbb_cache_container extends \Symfony\Component\DependencyInjection\Container
|
class phpbb_cache_container extends \Symfony\Component\DependencyInjection\Container
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,12 @@ class acp_captcha
|
||||||
{
|
{
|
||||||
var $u_action;
|
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)
|
function main($id, $mode)
|
||||||
{
|
{
|
||||||
global $user, $template, $phpbb_log, $request;
|
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';
|
$form_key = 'acp_captcha';
|
||||||
add_form_key($form_key);
|
add_form_key($form_key);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class factory
|
||||||
* Return a new instance of a given plugin
|
* Return a new instance of a given plugin
|
||||||
*
|
*
|
||||||
* @param $name
|
* @param $name
|
||||||
* @return object
|
* @return object|null
|
||||||
*/
|
*/
|
||||||
public function get_instance($name)
|
public function get_instance($name)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1653,6 +1653,8 @@ class gd
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** @var 1|2|3 $config['captcha_gd_fonts'] */
|
||||||
return array(
|
return array(
|
||||||
'width' => 9,
|
'width' => 9,
|
||||||
'height' => 15,
|
'height' => 15,
|
||||||
|
|
|
@ -205,7 +205,7 @@ class gd_wave
|
||||||
$x_index_old = intval(($x - 1) / $subdivision_factor);
|
$x_index_old = intval(($x - 1) / $subdivision_factor);
|
||||||
$x_index_new = intval($x / $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;
|
$img_pos_cur[1] += $this->wave_height($x, $y, $subdivision_factor, 1) - 30 - $cur_height;
|
||||||
$color = $colors[20];
|
$color = $colors[20];
|
||||||
|
@ -213,10 +213,10 @@ class gd_wave
|
||||||
$img_pos_cur[1] = min($img_pos_cur[1], $img_y - 1);
|
$img_pos_cur[1] = min($img_pos_cur[1], $img_y - 1);
|
||||||
$img_buffer[$buffer_cur][$x] = $img_pos_cur;
|
$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
|
// Otherwise, just
|
||||||
$diag_down = (empty($plane[$y_index_old][$x_index_old]) == empty($plane[$y_index_new][$x_index_new]));
|
$diag_down = !$plane[$y_index_old][$x_index_old] && !$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_up = !$plane[$y_index_old][$x_index_new] && !$plane[$y_index_new][$x_index_old];
|
||||||
|
|
||||||
// natural switching
|
// natural switching
|
||||||
$mode = ($x + $y) & 1;
|
$mode = ($x + $y) & 1;
|
||||||
|
|
|
@ -39,6 +39,9 @@ class qa
|
||||||
*/
|
*/
|
||||||
protected $service_name;
|
protected $service_name;
|
||||||
|
|
||||||
|
/** @var int Question ID */
|
||||||
|
protected $question = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -450,7 +453,7 @@ class qa
|
||||||
'session_id' => (string) $user->session_id,
|
'session_id' => (string) $user->session_id,
|
||||||
'lang_iso' => (string) $this->question_lang,
|
'lang_iso' => (string) $this->question_lang,
|
||||||
'confirm_type' => (int) $this->type,
|
'confirm_type' => (int) $this->type,
|
||||||
'question_id' => (int) $this->question,
|
'question_id' => $this->question,
|
||||||
));
|
));
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
|
||||||
|
@ -473,7 +476,7 @@ class qa
|
||||||
$this->solved = 0;
|
$this->solved = 0;
|
||||||
|
|
||||||
$sql = 'UPDATE ' . $this->table_qa_confirm . '
|
$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) . "'
|
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
|
||||||
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
|
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
|
@ -493,7 +496,7 @@ class qa
|
||||||
$this->solved = 0;
|
$this->solved = 0;
|
||||||
|
|
||||||
$sql = 'UPDATE ' . $this->table_qa_confirm . '
|
$sql = 'UPDATE ' . $this->table_qa_confirm . '
|
||||||
SET question_id = ' . (int) $this->question . ",
|
SET question_id = ' . $this->question . ",
|
||||||
attempts = attempts + 1
|
attempts = attempts + 1
|
||||||
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
|
WHERE confirm_id = '" . $db->sql_escape($this->confirm_id) . "'
|
||||||
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
|
AND session_id = '" . $db->sql_escape($user->session_id) . "'";
|
||||||
|
@ -553,7 +556,7 @@ class qa
|
||||||
|
|
||||||
if ($row)
|
if ($row)
|
||||||
{
|
{
|
||||||
$this->question = $row['question_id'];
|
$this->question = (int) $row['question_id'];
|
||||||
|
|
||||||
$this->attempts = $row['attempts'];
|
$this->attempts = $row['attempts'];
|
||||||
$this->question_strict = $row['strict'];
|
$this->question_strict = $row['strict'];
|
||||||
|
@ -576,7 +579,7 @@ class qa
|
||||||
|
|
||||||
$sql = 'SELECT answer_text
|
$sql = 'SELECT answer_text
|
||||||
FROM ' . $this->table_captcha_answers . '
|
FROM ' . $this->table_captcha_answers . '
|
||||||
WHERE question_id = ' . (int) $this->question;
|
WHERE question_id = ' . $this->question;
|
||||||
$result = $db->sql_query($sql);
|
$result = $db->sql_query($sql);
|
||||||
|
|
||||||
while ($row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
|
|
Loading…
Add table
Reference in a new issue