[ticket/12960] Add incomplete captcha to prevent registration

PHPBB3-12960
This commit is contained in:
Marc Alexander 2024-03-26 21:00:31 +01:00
parent 5e9d8662d1
commit 716c1ca8eb
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 79 additions and 0 deletions

View file

@ -17,6 +17,11 @@ services:
core.captcha.plugins.incomplete:
class: phpbb\captcha\plugins\incomplete
shared: false
arguments:
- '@config'
- '@template'
- '%core.root_path%'
- '%core.php_ext%'
calls:
- [ set_name, [ core.captcha.plugins.incomplete ] ]
tags:

View file

@ -136,6 +136,7 @@ $lang = array_merge($lang, array(
'CONFIRMATION' => 'Confirmation of registration',
'CONFIRM_CHANGES' => 'Confirm changes',
'CONFIRM_EXPLAIN' => 'To prevent automated registrations the board requires you to enter a confirmation code. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.',
'CONFIRM_INCOMPLETE' => 'To prevent automated registrations the board requires you to enter a confirmation code. This has not been configured yet and hence cannot be used. Please try again later or contact the %sBoard Administrator%s.',
'VC_REFRESH' => 'Refresh confirmation code',
'VC_REFRESH_EXPLAIN' => 'If you cannot read the code you can request a new one by clicking the button.',

View file

@ -0,0 +1,66 @@
<?php
namespace phpbb\captcha\plugins;
use phpbb\config\config;
use phpbb\template\template;
class incomplete extends \phpbb\captcha\plugins\captcha_abstract
{
public function __construct(protected config $config, protected template $template,
protected string $phpbb_root_path, protected string $phpEx)
{}
public function is_available()
{
return true;
}
public function get_generator_class()
{
}
public static function get_name()
{
return 'CAPTCHA_INCOMPLETE';
}
public function init($type)
{
}
public function execute_demo()
{
}
public function execute()
{
}
public function get_demo_template($id)
{
return '';
}
public function get_template()
{
$contact_link = phpbb_get_board_contact_link($this->config, $this->phpbb_root_path, $this->phpEx);
$this->template->assign_vars([
'CONFIRM_LANG' => $this->type != CONFIRM_POST ? 'CONFIRM_INCOMPLETE' : 'POST_CONFIRM_INCOMPLETE',
'CONTACT_LINK' => $contact_link,
]);
return 'captcha_incomplete.html';
}
public function validate()
{
return false;
}
public function is_solved()
{
return false;
}
}

View file

@ -0,0 +1,7 @@
<div class="panel captcha-panel">
<div class="inner">
<h3 class="captcha-title">{{ lang('CONFIRMATION') }}</h3>
<p class="error">{{ lang(CONFIRM_LANG, '<a href="' ~ CONTACT_LINK ~ '">', '</a>') }}</p>
</div>
</div>