Skip to content

A plugin for Kirby that provides a spam guard for the Uniform Form plugin. It uses extendable word lists and weights and counts links and emails to determine if a message is spam.

License

Notifications You must be signed in to change notification settings

tearoom1/uniform-spam-words

Repository files navigation

Spam Words Guard for Kirby Uniform

This plugin implements a simple spam words guard for Martin Zurowietz' kirby-uniform plugin for Kirby.

Getting started

Use one of the following methods to install & use tearoom1/uniform-spam-words:

Git submodule

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

composer require tearoom1/uniform-spam-words

Clone or download

  1. Clone or download this repository from github: https://github.com/tearoom1/uniform-spam-words.git
  2. Unzip / Move the folder to site/plugins.

Usage

Controller

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
}

Configuration

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.

License

This plugin is licensed under the MIT License, but using Kirby in production requires you to buy a license.

About

A plugin for Kirby that provides a spam guard for the Uniform Form plugin. It uses extendable word lists and weights and counts links and emails to determine if a message is spam.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages