This plugin implements a simple spam words guard for Martin Zurowietz' kirby-uniform
plugin for Kirby.
Use one of the following methods to install & use tearoom1/uniform-spam-words
:
If you know your way around Git, you can download this plugin as a submodule:
git submodule add https://github.com/tearoom1/uniform-spam-words.git site/plugins/uniform-spam-words
composer require tearoom1/uniform-spam-words
- Clone or download this repository from github: https://github.com/tearoom1/uniform-spam-words.git
- Unzip / Move the folder to
site/plugins
.
To use the plugin, you have to enable the guard by calling spamWordsGuard()
on the $form
object.
For more information, check out the kirby-uniform
docs on its magic methods:
$form = new Form();
if ($kirby->request()->is('POST')) {
# Call security
$form->spamWordsGuard();
# .. more code
}
You may change certain options from your config.php
globally:
return [
'tearoom1.uniform-spam-words' => [
'addressThreshold' => 2, // the number of addresses like links and emails that are allowed, default 2
'spamThreshold' => 8, // the threshold for the spam score, default 8
'useWordLists' => true, // Use the default word lists, default true
'spamWords' => [ // define your own spam words, the key number defines the weight of the words
1 => ['promotion', 'free'], // weight 1, increases spam likelihood only a little
6 => ['seo', 'marketing'], // weight 6, increases spam likelihood a lot
],
],
];
- The
addressThreshold
defines the number of addresses like links and emails that are allowed in the message. If the number of addresses exceeds this threshold, the form submission is blocked. - If no addresses can be found, then the message is considered as safe and no spam words are checked.
- The spam score is calculated by counting the occurrences of spam keywords in the message. The score is increased by the weight of the keyword. If the score exceeds the
spamThreshold
, the form submission is blocked.
This plugin is licensed under the MIT License, but using Kirby in production requires you to buy a license.