swordfox/silverstripe-recaptchamultiple

一种使用Google的reCAPTCHA 3的垃圾邮件防护工具和表单字段,支持单页面上多个表单。

安装次数 2,026

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:silverstripe-vendormodule

1.0.5 2020-05-05 23:55 UTC

This package is auto-updated.

Last update: 2024-08-29 04:37:26 UTC


README

一种使用Google的reCAPTCHA 3支持的多个表单的垃圾邮件防护工具和表单字段

基于 https://github.com/UndefinedOffset/silverstripe-nocaptcha - 主要变化是它注入CustomJs的方式,大部分内容已被移至JS文件中。

需求

安装

composer require swordfox/silverstripe-recaptchamultiple

通过composer或手动安装模块后,您必须将垃圾邮件防护设置为RecaptchaMultipleProtector,这需要在配置文件中设置,例如:mysite/_config/recaptchamultiple.yml。

SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension:
  default_spam_protector: Swordfox\RecaptchaMultiple\Forms\RecaptchaMultipleProtector

将“垃圾邮件防护”字段添加到您的表单字段中。

$form->enableSpamProtection()
	->fields()->fieldByName('Captcha')
	->setTitle("Spam protection")
	->setDescription("Please tick the box to prove you're a human and help us stop spam.");

为每个字段设置一个回调,对于ajax表单很有用

$form->enableSpamProtection()
	->fields()->fieldByName('Captcha')
	->setCallback("onSubmit");

配置

该字段有多种配置选项,您必须设置site_key和secret_key,您可以从reCAPTCHA页面获取。这些配置选项必须添加到配置文件中,例如:mysite/_config/recaptchamultiple.yml。

Swordfox\RecaptchaMultiple\Forms\RecaptchaMultipleField:
    site_key: "YOUR_SITE_KEY" #Your site key (required)
    secret_key: "YOUR_SECRET_KEY" #Your secret key (required)
    verify_ssl: true #Allows you to disable php-curl's SSL peer verification by setting this to false (optional, defaults to true)
    default_theme: "light" #Default theme color (optional, light or dark, defaults to light)
    default_type: "image" #Default captcha type (optional, image or audio, defaults to image)
    default_size: "normal" #Default size (optional, normal, compact or invisible, defaults to normal)
    default_badge: "bottomright" #Default badge position (bottomright, bottomleft or inline, defaults to bottomright)
    proxy_server: "" #Your proxy server address (optional)
    proxy_auth: "" #Your proxy server authentication information (optional)