Download the PHP package tearoom1/uniform-spam-words without Composer
On this page you can find all versions of the php package tearoom1/uniform-spam-words. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tearoom1/uniform-spam-words
More information about tearoom1/uniform-spam-words
Files in tearoom1/uniform-spam-words
Package uniform-spam-words
Short Description Simple spam guard for 'mzur/kirby-uniform' & Kirby
License MIT
Homepage https://github.com/tearoom1/uniform-spam-words
Informations about the package uniform-spam-words
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:
Composer
Clone or download
- Clone or download this repository from github: https://github.com/tearoom1/uniform-spam-words.git
- 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:
How it works
- Checks message length constraints
- Checks word count constraints
- Validates regex pattern (if configured)
- Runs custom validator (if configured)
- If addresses found (>= minAddresses), calculates spam score from keywords
- Rejects if thresholds exceeded
Configuration
The plugin comes with a few lists of words and phrases that are used to build a spam score. Thus the plugin should work out of the box.
You may change certain options in your global config.php
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| Validation Options | |||
minLength |
int|null | null |
Minimum character length required for the message. Set to null to disable. |
maxLength |
int|null | null |
Maximum character length allowed for the message. Set to null to disable. |
minWords |
int|null | null |
Minimum word count required for the message. Set to null to disable. |
maxWords |
int|null | null |
Maximum word count allowed for the message. Set to null to disable. |
regexMatch |
string|null | null |
Optional regex pattern that the message must match (e.g., /^[a-zA-Z0-9\s]+$/). Set to null to disable. |
customValidator |
callable|null | null |
Custom validation callback that receives the message and returns true (valid) or false (invalid). Set to null to disable. |
| Spam Detection Options | |||
minAddresses |
int | 1 |
Minimum number of addresses required to trigger spam word checking. Set to 0 to always check. |
addressThreshold |
int | 2 |
Number of addresses (links/emails) allowed before triggering spam check. |
addressesWeight |
int | 1 |
Weight multiplier for each address (link/email) found. Each address contributes addressesWeight points to the total spam score. |
spamThreshold |
int | 8 |
Spam score threshold for rejection. Higher values are more lenient. |
useWordLists |
bool | true |
Use built-in spam word lists. Set to false to disable built-in lists. |
wordListPaths |
string|array|null | null |
Custom paths to word list files or directories. Always additive (added to built-in lists if enabled). Can be a single path (string) or multiple paths (array). |
spamWords |
array | [] |
Custom spam words with weights. Format: [weight => ['word1', 'word2']]. Higher weight = stronger spam signal. |
| Other Options | |||
enabled |
bool | true |
Enable or disable the plugin globally. |
fields |
array | ['message'] |
Form fields to check for spam. Specify multiple fields to combine them for spam checking (e.g., ['message', 'subject', 'body']). |
wordListCache |
bool | true |
Enable caching of word lists. Set to false to reload word lists on every request (useful for development). |
silentReject |
bool | false |
Reject spam without showing error messages (returns a space character). |
debug |
bool | false |
Enable debug logging. Logs ALL validation attempts with reason, metrics, form data, checked fields, anonymized IP, and timestamp. |
debugLogFile |
string|null | null |
Path to debug log file. Defaults to uniform-spam-words.log in the kirby logs directory (e.g. site/logs/uniform-spam-words.log). |
attachDebugInfo |
bool | false |
Attach spam check data to Form object (accessible via $form->data('spam_words_guard_info')) for use in email templates. Be aware that by default all fields are sent in uniform emails. |
Message Rejection & Spam Score
- A message is rejected if the spam score is higher than the threshold. Or if the number of addresses are higher than twice the
addressThreshold. - A messages is soft rejected (different message) if the number of addresses are higher than
addressThresholdbut the spam score is lower than the threshold. - The spam score is calculated by adding the weights of all matched words.
Plus the number of addresses found times the
addressesWeight.
Common Use Cases
Full Configuration Example
Contact Form with Basic Spam Protection
Strict Comment System
Multi-Field Spam Checking
Increase Weight for Links/Emails
Development Mode (No Caching)
Custom Validation with Industry-Specific Terms
Debug Mode for Tuning
Debug logging captures:
- ✅ All rejections (regex, length, words, custom validator, spam detection)
- ✅ Successful validations (messages that pass all checks)
- ✅ Rejection reason and relevant metrics for each attempt
- ✅ Form data - All submitted form fields (truncated to 100 chars, excludes passwords/tokens)
- ✅ Checked fields - Which fields were combined for spam checking
- ✅ Anonymized IP address (GDPR compliant) and timestamp for tracking
Example log entry:
IP Anonymization (GDPR Compliant):
- IPv4: Last octet masked (e.g.,
192.168.1.123→192.168.1.0) - IPv6: Last 4 segments masked (e.g.,
2001:db8:85a3:8d3:1319:8a2e:370:7348→2001:db8:85a3:8d3:0000:0000:0000:0000)
Custom Word Lists
You can use your own spam word list files instead of or in addition to the built-in lists.
File Format
Word list files should be plain text files (.txt) with:
- One term (single word or combination) per line
- Weight encoded in filename as
_n.txtwherenis the weight (1-9) - Example:
custom_spam_5.txt(weight 5)
Example file content (my_spam_words_7.txt):
Configuration Options
Single file:
Multiple files:
Directory (loads all .txt files):
Multiple directories:
Combining with Built-in Lists
Custom word lists are added to the built-in lists (if enabled). The options work independently:
Built-in + Custom (default):
Notes
- Custom word lists are cached for 24 hours (same as built-in lists)
- Weight determines spam score contribution (higher = more spam-like)
- Words are case-insensitive
- Empty lines are skipped
- Files must be readable by the web server
Supported Languages
The plugin includes built-in translations for error messages in the following languages:
- English (en) - Default language
- German (de) - Deutsche Übersetzungen
- French (fr) - Traductions françaises
The plugin automatically uses the appropriate language based on your Kirby site's language configuration.
Custom Error Messages
Single-language sites: Define custom messages in config.php:
Multi-language sites: Define translations in your language files (site/languages/*.php):
License
This plugin is licensed under the MIT License
Credits
- Developed by Mathis Koblin
Screenshots
Screenshots use sample content at 1408 × 902 pixels. Panel views are cropped to the content area. The main image uses the light theme.
| View | Light | Dark |
|---|---|---|
| Overview | Light | Dark |
The spam rejection previews use the contact form with neutral T-Room styling.
