oposs/silverstripe-hcaptcha

使用 hCaptcha 保护您的表单

安装次数: 1,008

依赖项: 0

建议者: 0

安全: 0

星标: 2

关注者: 5

分支: 1

公开问题: 0

类型:silverstripe-vendormodule

0.1.2 2023-02-09 12:11 UTC

This package is auto-updated.

Last update: 2024-09-09 15:26:29 UTC


README

使用 hCaptcha 保护您的表单,这是一个符合 GDPR、CCPA、LGPD、PIPL 等规范的垃圾邮件防护程序(根据其网站上的描述)

安装

在安装之前请确保满足以下要求

  • SilverStripe 4.x
  • SilverStripe Spam Protection 3.x
  • PHP CURL 和 JSON
composer require oposs/silverstripe-hcaptcha

并将 hCaptcha 设置为您的默认垃圾邮件防护程序

SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension:
  default_spam_protector: Oposs\hCaptcha\hCaptchaProtector

配置

在您的 app/_config/hcaptcha.yml

Oposs\hCaptcha\Forms\hCaptchaField:
  site_key: 'your_site_key'
  # Make sure to set the key starting with 0x.. in quotes
  secret_key: 'your_secret_key'
  # To configure options listed here https://docs.hcaptcha.com/configuration
  api_configuration:
    recaptchacompat: 'off'

有关更多配置选项,请参阅 hCaptchaField.php 中的注释

使用方法

在 PHP 中

use Oposs\hCaptcha\hCaptchaProtector\Forms

new hCaptchaField('SpamProtection', 'SpamProtection', null);

或者如果您使用 Userforms

img.png

故障排除

问题:当验证码错误或未解决时,用户会被重定向到主页

答案:这很可能是重定向问题,如果您的网站运行在代理后面,请查看 Director 的 alternate_base_url 属性(尽管使用频繁,但尚未进行文档记录...)

欢迎贡献 :)