tractorcow / silverstripe-akismet
Requires
- silverstripe/spamprotection: >=1.2.0
- tijsverkoyen/akismet: 1.1.0
This package is auto-updated.
Last update: 2022-02-01 12:26:32 UTC
README
使用Akismet的Silverstripe简单垃圾邮件过滤器
另外,请报告任何您遇到的问题,这有助于我们所有人。
鸣谢和作者
- Damian Mooyman - https://github.com/tractorcow/silverstripe-akismet
- 感谢Tijs Verkoyen提供的Akismet API包装器 - https://github.com/tijsverkoyen/Akismet
要求
- SilverStripe 3.1
- Silverstripe垃圾邮件保护模块 - https://github.com/silverstripe/silverstripe-spamprotection
- Tijs Verkoyen的Akismet API包装器 - https://github.com/tijsverkoyen/Akismet
- PHP 5.3
安装说明
此模块可以轻松安装在已开发的任何网站上
- 如果使用composer,安装可以按以下方式进行
composer require tractorcow/silverstripe-akismet 3.1.x-dev
-
配置您的环境,将'AkismetSpamProtector'设置为保护类,并从akismet.com获取API密钥,然后以以下任一方式设置到网站上。
config.yml
--- Name: myspamprotection --- FormSpamProtectionExtension: default_spam_protector: AkismetSpamProtector AkismetSpamProtector: api_key: 5555dddd55d5d
_config.php
Config::inst()->update('FormSpamProtectionExtension', 'default_spam_protector', 'AkismetSpamProtector'); AkismetSpamProtector::set_api_key('5555dddd55d5d');
_ss_environment.php
define('SS_AKISMET_API_KEY', '5555dddd55d5d');
// and set AkismetSpamProtector as your spam protector using one of the above methods
测试
默认情况下,对于具有ADMIN权限的用户,禁用了垃圾邮件保护。还可以选择禁用所有登录用户的垃圾邮件保护。为了测试目的暂时禁用此功能,您可以在开发环境中按以下方式修改这些选项
if(!Director::isLive()) { Config::inst()->remove('AkismetSpamProtector', 'bypass_permission'); Config::inst()->remove('AkismetSpamProtector', 'bypass_members'); }
为了检查您的表单是否正确阻止垃圾邮件,您可以始终将'viagra-test-123'设置为作者,Akismet将始终将其标记为垃圾邮件。
评论
如果您使用评论模块,可以通过将CommentSpamProtection
扩展添加到CommentingController
来快速设置akismet过滤这些评论。
config.yml
CommentingController: extensions: - CommentSpamProtection
_config.php
CommentingController::add_extension('CommentSpamProtection');
自定义表单使用
为了在自定义表单中启用垃圾邮件保护,请使用字段名称映射到akismet字段的enableSpamProtection方法调用
$form = new Form($this, 'Form', $fields, $actions, $validator);
$form->enableSpamProtection(array(
'mapping' => array(
'Name' => 'authorName',
'Email' => 'authorMail',
'Comments' => 'body'
)
)
);
对欧盟用户的重要提示
由于Akismet的工作方式(向第三方发送消息、作者和其他信息),在某些国家,在验证之前通知并获得用户的同意是法律上必要的。
为了为该字段创建复选框样式的授权提示,请设置以下配置选项
config.yml
AkismetSpamProtector: require_confirmation: true
_config.php
Config::inst()->update('AkismetSpamProtector', 'require_confirmation', true);
许可证
修订版BSD许可证
版权所有(c)2013,Damian Mooyman。保留所有权利。
保留所有权利。
以下条件满足的情况下,允许重新分发和使用源代码和二进制代码,无论是否修改:
- 源代码的重新分发必须保留上述版权声明、本条件列表和以下免责声明。
- 二进制形式的重新分发必须在文档和/或其他与分发一起提供的材料中重新生产上述版权声明、本条件列表和以下免责声明。
- 未经特定事先书面许可,不得使用Damian Mooyman的姓名来认可或推广由此软件派生的产品。
本软件由版权所有者和贡献者按“原样”提供,并明确或暗示地放弃包括但不限于商销性和适用于特定目的的默示保证。在任何情况下,不应对任何直接、间接、偶然、特殊、示范性或后果性的损害(包括但不限于替代商品或服务的采购;使用、数据或利润的损失;或业务中断)负责,无论其责任理论是什么,无论是否已告知此类损害的可能性,均不承担此类损害的责任。