1. Go to this page and download the library: Download tearoom1/uniform-spam-words library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tearoom1 / uniform-spam-words example snippets
$form = new Form();
if ($kirby->request()->is('POST')) {
# Call security
$form->spamWordsGuard();
# .. more code
}
return [
'tearoom1.uniform-spam-words' => [
'enabled' => true, // enable the plugin, default true
'minLength' => 10, // the minimum length of the message, default null (disabled)
'maxLength' => 500, // the maximum length of the message, default null (disabled)
'minWords' => 3, // the minimum number of words in the message, default null (disabled)
'maxWords' => null, // the maximum number of words in the message, default null (disabled)
'regexMatch' => null, // the regex pattern to match against the message, default null (disabled)
'customValidator' => null, // custom validation callback, default null (disabled)
'minAddresses' => 0, // the minimum number of addresses like links and emails that are needed to check for spam, default 1
'addressThreshold' => 2, // the number of addresses like links and emails that are allowed, default 2
'addressesWeight' => 2, // the weight multiplier for each address (link/email), default 1
'spamThreshold' => 10, // 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
// Note: If a word exists in both built-in/file lists and spamWords config,
// the config weight will override the file weight (no double counting)
],
'silentReject' => false, // Reject spam without showing error messages (returns a space as error message), default false
'debug' => true, // Enable debug logging, default false
'debugLogFile' => 'site/logs/my_custom_logfile.log', // Path to debug log file, default null (uses Kirby's log directory)
],
];