diff --git a/build/psalm_bootstrap.php b/build/psalm_bootstrap.php index cea4bc64be..03afd6da3d 100644 --- a/build/psalm_bootstrap.php +++ b/build/psalm_bootstrap.php @@ -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 { diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index b49c5ca0d3..ff9f515d32 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -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); diff --git a/phpBB/phpbb/captcha/factory.php b/phpBB/phpbb/captcha/factory.php index dd44aca8bb..2e75ce8667 100644 --- a/phpBB/phpbb/captcha/factory.php +++ b/phpBB/phpbb/captcha/factory.php @@ -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) { diff --git a/phpBB/phpbb/captcha/gd.php b/phpBB/phpbb/captcha/gd.php index 7f4d26ff00..308bc73e0b 100644 --- a/phpBB/phpbb/captcha/gd.php +++ b/phpBB/phpbb/captcha/gd.php @@ -1653,6 +1653,8 @@ class gd ), ), ); + + /** @var 1|2|3 $config['captcha_gd_fonts'] */ return array( 'width' => 9, 'height' => 15, diff --git a/phpBB/phpbb/captcha/gd_wave.php b/phpBB/phpbb/captcha/gd_wave.php index 4f64e95a1d..e0801e7c50 100644 --- a/phpBB/phpbb/captcha/gd_wave.php +++ b/phpBB/phpbb/captcha/gd_wave.php @@ -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; diff --git a/phpBB/phpbb/captcha/plugins/qa.php b/phpBB/phpbb/captcha/plugins/qa.php index f709c95353..811421a63c 100644 --- a/phpBB/phpbb/captcha/plugins/qa.php +++ b/phpBB/phpbb/captcha/plugins/qa.php @@ -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))