silverstripe/akismet
Composer 安装命令:
composer require silverstripe/akismet
包简介
Akismet antispam module for Silverstripe
关键字:
README 文档
README
Simple spam filter for Silverstripe using Akismet
Also, please report any issues you may encounter, as it helps us all out!
Please see the changelog for module history.
Credits and Authors
- Damian Mooyman - https://github.com/tractorcow/silverstripe-akismet
- Attribution to Tijs Verkoyen for his Akismet API wrapper - https://github.com/tijsverkoyen/Akismet
Requirements
- Silverstripe ^4 || ^5
- Silverstripe SpamProtection module - https://github.com/silverstripe/silverstripe-spamprotection
- Tijs Verkoyen's Akismet API wrapper - https://github.com/tijsverkoyen/Akismet
Note: For a Silverstripe 4.x compatible version, please use 4.x release.
Installation Instructions
This module can be easily installed on any already-developed website
- You can install using Composer, as below:
composer require silverstripe/akismet
AkismetSpamProtector is automatically assigned as the default spam protector class.
- Get an API key from akismet.com and set in the site against one of the following ways.
config.yml:
--- Name: myspamprotection --- SilverStripe\Akismet\AkismetSpamProtector: api_key: 5555dddd55d5d
_config.php:
use SilverStripe\Akismet\AkismetSpamProtector; AkismetSpamProtector::singleton()->setApiKey('5555dddd55d5d');
.env:
SS_AKISMET_API_KEY="5555dddd55d5d"
If instead you want to configure your akismet key via the siteconfig (as a password field) you can add the included extension to SiteConfig
mysite/_config/settings.yml:
SilverStripe\SiteConfig\SiteConfig: extensions: - SilverStripe\Akismet\Config\AkismetConfig
Priority of defined API keys
Please note that the API key values defined in the various ways above will be prioritised as:
- Values assigned to the singleton via
AkismetSpamProtector::singleton()->setApiKey() - Values defined in configuration, whether YAML or in _config.php files with
Config::modify()->set(...) - Values defined in the environment via .env
Testing
By default, spam protection is disabled for users with ADMIN priviliges. There is also an option to disable spam protection for all logged in users. In order to disable this for testing purposes, you can temporarily modify these options in your development environment as below:
use SilverStripe\Akismet\AkismetSpamProtector; use SilverStripe\Control\Director; use SilverStripe\Core\Config\Config; if (!Director::isLive()) { Config::modify()->remove(AkismetSpamProtector::class, 'bypass_permission'); Config::modify()->remove(AkismetSpamProtector::class, 'bypass_members'); }
In order to check that your form is blocking spam correctly, you can always set 'viagra-test-123' as the author and Akismet will always mark this as spam.
Comments
If you're using Comments module you can quickly set akismet to filter these out by adding the CommentSpamProtection
extension to the CommentingController
config.yml
SilverStripe\Comments\Controllers\CommentingController: extensions: - CommentSpamProtection
If necessary, you can also mark spam comments to be saved to the database. This will still display the spam rejection notice, but spam comments will now be available for moderation in the backend. In order to enable this feature add the following to your configuration.
config.yml
# Allows spam posts to be saved for review if necessary SilverStripe\Akismet\AkismetSpamProtector: save_spam: true
Custom Form Usage
To enable spam protection in your custom forms, call the enableSpamProtection method with your field names mapped to the akismet fields:
$form = new Form($this, 'Form', $fields, $actions, $validator);
$form->enableSpamProtection(array(
'mapping' => array(
'Name' => 'authorName',
'Email' => 'authorMail',
'Comments' => 'body'
)
)
);
Important notes for those in the EU
Because of the way Akismet works (message, author, and other information sent to a third party) in some countries it's legally necessary to notify and gain the user's permission prior to verification.
To create a checkbox style authorisation prompt for this field set the following configuration option:
config.yml
SilverStripe\Akismet\AkismetSpamProtector: require_confirmation: true
_config.php
Config::modify()->set(AkismetSpamProtector::class, 'require_confirmation', true);
silverstripe/akismet 适用场景与选型建议
silverstripe/akismet 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 145.71k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 03 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Akismet」 「spam」 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe/akismet 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe/akismet 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe/akismet 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Symfony Benji07 AkismetBundle
Simple captcha generator
reCAPTCHA library
Client library for reCAPTCHA with proxy support, a free service that protects websites from spam and abuse.
PHP library for implementing Akismet spam filtering
Simple Akismet API Bindings
统计信息
- 总下载量: 145.71k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 19
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-03-22