Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions captcha.module
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Drupal\captcha\Entity\CaptchaPoint;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;

/**
Expand Down Expand Up @@ -43,24 +44,24 @@ define('CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE', 1);
/**
* Implements hook_help().
*/
function captcha_help($path, $arg) {
switch ($path) {
case 'admin/help#captcha':
function captcha_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.captcha':
$output = '<p>' . t('"CAPTCHA" is an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart". It is typically a challenge-response test to determine whether the user is human. The CAPTCHA module is a tool to fight automated submission by malicious users (spamming) of for example comments forms, user registration forms, guestbook forms, etc. You can extend the desired forms with an additional challenge, which should be easy for a human to solve correctly, but hard enough to keep automated scripts and spam bots out.') . '</p>';
$output .= '<p>' . t('Note that the CAPTCHA module interacts with page caching (see <a href="!performancesettings">performance settings</a>). Because the challenge should be unique for each generated form, the caching of the page it appears on is prevented. Make sure that these forms do not appear on too many pages or you will lose much caching efficiency. For example, if you put a CAPTCHA on the user login block, which typically appears on each page for anonymous visitors, caching will practically be disabled. The comment submission forms are another example. In this case you should set the <em>Location of comment submission form</em> to <em>Display on separate page</em> in the comment settings of the relevant <a href="!contenttypes">content types</a> for better caching efficiency.',
array(
'!performancesettings' => url('admin/config/development/performance'),
'!contenttypes' => url('admin/structure/types'),
'!performancesettings' => \Drupal::url('system.performance_settings'),
'!contenttypes' => \Drupal::url('node.overview_types'),
)
) . '</p>';
$output .= '<p>' . t('CAPTCHA is a trademark of Carnegie Mellon University.') . '</p>';
return $output;

case 'admin/config/people/captcha':
case 'admin/config/people/captcha/captcha':
case 'admin/config/people/captcha/captcha/settings':
case 'captcha_settings':
case 'captcha_settings_captcha':
case 'captcha_settings_general':
$output = '<p>' . t('A CAPTCHA can be added to virtually each Drupal form. Some default forms are already provided in the form list, but arbitrary forms can be easily added and managed when the option <em>Add CAPTCHA administration links to forms</em> is enabled.') . '</p>';
$output .= '<p>' . t('Users with the <em>Skip CAPTCHA</em> <a href="@perm">permission</a> won\'t be offered a challenge. Be sure to grant this permission to the trusted users (e.g. site administrators). If you want to test a protected form, be sure to do it as a user without the <em>Skip CAPTCHA</em> permission (e.g. as anonymous user).', array('@perm' => url('admin/people/permissions'))) . '</p>';
$output .= '<p>' . t('Users with the <em>Skip CAPTCHA</em> <a href="!perm">permission</a> won\'t be offered a challenge. Be sure to grant this permission to the trusted users (e.g. site administrators). If you want to test a protected form, be sure to do it as a user without the <em>Skip CAPTCHA</em> permission (e.g. as anonymous user).', array('!perm' => \Drupal::url('user.admin_permissions'))) . '</p>';
return $output;
}
}
Expand Down
16 changes: 16 additions & 0 deletions captcha.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ captcha_settings:
requirements:
_permission: 'administer CAPTCHA settings'

captcha_settings_captcha:
path: '/admin/config/people/captcha/captcha'
defaults:
_form: '\Drupal\captcha\Form\CaptchaSettingsForm'
_title: 'CAPTCHA'
requirements:
_permission: 'administer CAPTCHA settings'

captcha_settings_general:
path: '/admin/config/people/captcha/captcha/settings'
defaults:
_form: '\Drupal\captcha\Form\CaptchaSettingsForm'
_title: 'General settings'
requirements:
_permission: 'administer CAPTCHA settings'

captcha_examples:
path: '/admin/config/people/captcha/examples/{module}/{challenge}'
defaults:
Expand Down
8 changes: 5 additions & 3 deletions image_captcha/image_captcha.module
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Implements image CAPTCHA for use with the CAPTCHA module
*/

use Drupal\Core\Routing\RouteMatchInterface;

define('IMAGE_CAPTCHA_ALLOWED_CHARACTERS', 'aAbBCdEeFfGHhijKLMmNPQRrSTtWXYZ23456789');

// Setup status flags.
Expand All @@ -19,9 +21,9 @@ define('IMAGE_CAPTCHA_FILE_FORMAT_TRANSPARENT_PNG', 3);
/**
* Implements hook_help().
*/
function image_captcha_help($path, $arg) {
switch ($path) {
case 'admin/config/people/captcha/image_captcha':
function image_captcha_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'image_captcha.settings':
$output = '<p>' . t('The image CAPTCHA is a popular challenge where a random textual code is obfuscated in an image. The image is generated on the fly for each request, which is rather CPU intensive for the server. Be careful with the size and computation related settings.') . '</p>';
return $output;
}
Expand Down