silverstripe/spamprotection
Composer 安装命令:
composer require silverstripe/spamprotection
包简介
Spam protection module for SilverStripe.
README 文档
README
Installation
composer require silverstripe/spamprotection
Maintainer Contact
-
Saophalkun Ponlu <phalkunz (at) silverstripe (dot) com>
-
Will Rossiter <will (at) fullscreen (dot) io>
Documentation
This module provides a generic, consistent API for adding spam protection to your Silverstripe Forms. This does not provide any spam protection out of the box. For that, you must also download one of the spam protection implementations. Currently available options are:
- reCAPTCHA v2 (two implementations: one, two)
- MathSpamProtection
- Akismet
- Mollom
- Cloudflare Turnstile
As a developer you can also provide your own protector by creating a class which
implements the \SilverStripe\SpamProtection\SpamProtector interface. More on that below.
Configuring
After installing this module and a protector of your choice (i.e mollom) you'll
need to rebuild your database by running sake db:build --flush and set the default protector
via SilverStripe's config system. This will update any Form instances that have
spam protection hooks with that protector.
mysite/_config/spamprotection.yml
--- name: mycustomspamprotection --- SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension: default_spam_protector: MollomSpamProtector
To add spam protection to your form instance call enableSpamProtection.
// your existing form code $form = new Form(/* .. */); $form->enableSpamProtection();
The logic to perform the actual spam validation is controlled by each of the
individual SpamProtector implementations since they each require a different
implementation client side or server side.
Options
enableSpamProtection takes a hash of optional configuration values.
$form->enableSpamProtection(array( 'protector' => MathSpamProtector::class, 'name' => 'Captcha' ));
Options to configure are:
-
protector: a class name string or class instance which implements\SilverStripe\SpamProtection\SpamProtector. Defaults to yourSilverStripe\SpamProtection\Extension\FormSpamProtectionExtension.default_spam_protectorvalue. -
name: the form field name argument for the Captcha. Defaults toCaptcha. -
title: title of the Captcha form field. Defaults to'' -
insertBefore: name of existing field to insert the spam protection field prior to -
mapping: an array mapping of the Form fields to the standardised list of field names. The list of standardised fields to pass to the spam protector are:
title
body
contextUrl
contextTitle
authorName
authorMail
authorUrl
authorIp
authorId
Defining your own SpamProtector
Any class that implements \SilverStripe\SpamProtection\SpamProtector and the getFormField() method can
be set as the spam protector. The getFormField() method returns the
FormField to be inserted into the Form. The FormField returned should be
in charge of the validation process.
<?php use CaptchaField; use SilverStripe\SpamProtection\SpamProtector; class CustomSpamProtector implements SpamProtector { public function getFormField($name = null, $title = null, $value = null) { // CaptchaField is an imagined class which has some functionality. // See silverstripe-mollom module for an example. return new CaptchaField($name, $title, $value); } }
Using Spam Protection with User Forms
This module provides an EditableSpamProtectionField wrapper which you can add
to your UserForm instances. After installing this module and running sake db:build --flush
to rebuild the database, your Form Builder interface will have an option for
Spam Protection Field. The type of spam protection used will be based on your
currently selected SpamProtector instance.
Releasing code with Spam Protection support
Spam protection is useful to provide but in some cases we do not want to require the developer to use spam protection. In that case, modules can provide the following pattern:
use SilverStripe\Forms\Form; use SilverStripe\SpamProtection\Extension\FormSpamProtectionExtension; $form = new Form(/* .. */); if ($form->hasExtension(FormSpamProtectionExtension::class)) { $form->enableSpamProtection(); }
silverstripe/spamprotection 适用场景与选型建议
silverstripe/spamprotection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.01M 次下载、GitHub Stars 达 43, 最近一次更新时间为 2012 年 11 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「silverstripe」 「spamprotection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe/spamprotection 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe/spamprotection 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe/spamprotection 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Spam protection using a honeypot field for the Neos form builder
Recaptcha V3 verification for Silverstripe framework, including a form field, spam protector and verification support
Analytics chooser extensions for site settings.
Protect your forms with hCaptcha
Simple spam protection module for Silverstripe 4.
统计信息
- 总下载量: 1.01M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 44
- 点击次数: 24
- 依赖项目数: 48
- 推荐数: 4
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2012-11-03