=== iSpam ===
Contributors: keyvahardani
Tags: spam, anti-spam, comments, honeypot, gdpr
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.3
Stable tag: 5.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Privacy-friendly comment spam protection: signed time token, honeypot, JavaScript check and link limit. No captcha, no external service.

== Description ==

iSpam stops automated comment spam before it reaches your moderation queue – without captchas, without cookies and without sending data to third parties.

Every comment form gets a **signed time token**. Bots that submit the form instantly, reuse old forms or post directly to `wp-comments-post.php` are stopped. Additional checks catch more.

**Honest scope:** iSpam stops automated and simple bots. It does not stop spam that a person writes and sends manually – combine it with comment moderation (or a content-based filter) for that.

= Features =

* **Time check** – minimum time between loading the form and submitting it, optional maximum form age.
* **Signed token** – HMAC signature with your site's secret salt, bound to the post.
* **Honeypot** – an invisible field that humans leave empty.
* **JavaScript check (optional)** – a fresh, single-use token (valid for max. 2 hours) is fetched when the visitor starts typing. Works with page caching; falls back to admin-ajax.php if the REST API is blocked.
* **Link limit** – counts links in tags, plain URLs, protocol-relative URLs and "www." addresses, also when they are hidden behind HTML entities.
* **Pingbacks & trackbacks (optional)** – block them or send them to the spam folder.
* **Choose the action** – block with your own message (HTTP 403) or store the comment in the WordPress spam folder.
* **Spam log** – date, post, anonymised IP, reason and a short excerpt; filter by reason, delete single entries, bulk delete or empty the log.
* **Automatic cleanup** – log entries are deleted after a configurable number of days (default 30).
* **Overview & dashboard widget** – blocked comments in the last 24 hours, the last 7 days and since installation, most common reason.
* **Abilities API** – read-only ability `ispam/get-spam-statistics` for tools and AI agents (requires the capability `manage_options`, like the spam log).
* **WooCommerce reviews** are protected as well (they use the comment form).
* Skips logged-in users (optional), works with classic and block themes.

= For developers =

* Filter `ispam_check_result( $reason, $post_id, $content )` – return a reason code to block, or an empty string to allow.
* Filter `ispam_block_message( $message, $reason )`.
* Action `ispam_spam_detected( $reason, $post_id, $action )`.
* Ability `ispam/get-spam-statistics` – input `{ "entries": 0–50 }`, output totals, counts per reason and optionally the latest entries without IP addresses. Permission: `manage_options`.

== Installation ==

1. Install iSpam via Plugins › Add New, or upload the `ispam` folder to `/wp-content/plugins/`.
2. Activate the plugin.
3. If you use a page cache, clear it once.
4. Go to **iSpam › Settings** and adjust the checks. The defaults work for most sites.

== Frequently Asked Questions ==

= Does iSpam work with page caching? =

Yes. Clear the page cache once after installing or updating and after switching on the JavaScript check. The default settings (no maximum form age) are cache safe. With the JavaScript check, every visitor gets a fresh token, independent of the cache. Form tokens from cached pages created before the JavaScript check was switched on remain valid for two days.

= Will visitors without JavaScript be blocked? =

Only if you enable the JavaScript check. It is off by default.

= Does iSpam stop all spam? =

No. iSpam reliably stops automated and simple bots. Spam that a person writes and sends manually passes the technical checks – use comment moderation for that.

= Are comments via the REST API or XML-RPC checked? =

No. iSpam checks the comment form (`wp-comments-post.php`) and, optionally, pingbacks and trackbacks. By default WordPress only accepts comments via the REST API from logged-in users; XML-RPC comments also require a login. These authenticated channels are not checked.

= Does iSpam send data to an external service? =

No. Everything happens on your server.

= I updated from iSpam 4. What happens to my data? =

Your minimum time and custom message are taken over. The old maximum time is not taken over on purpose (it blocked visitors of cached pages); the maximum form age starts at 0 (off). Logged spam younger than the retention period is imported in the background with anonymised IP addresses; afterwards the old tables `dc_sp_log` and `dc_sp_spam` are removed. iSpam no longer writes to the database on every page view.

= How do I remove all data? =

Delete the plugin via Plugins › Installed Plugins. The log table, all settings, markers and scheduled events are removed.

== Privacy ==

iSpam does not set cookies and does not contact external services.

When a comment is classified as spam and logging is enabled, iSpam stores the date, the post, the anonymised IP address (IPv4: last octet removed, IPv6: shortened to the first 48 bits), the reason and the first 200 characters of the comment. Entries are deleted automatically after the configured retention period (default 30 days).

If the action "Mark as spam" is selected, the comment is additionally stored like every other WordPress comment in the spam folder – including the full IP address, name, email address and browser user agent – until it is deleted there.

To make JavaScript tokens single-use, iSpam stores a hash of each used token for at most two hours. A suggested text for your privacy policy is added under Settings › Privacy.

== Screenshots ==

1. Overview with key figures and the spam log.
2. Settings.

== Changelog ==

= 5.0.0 =
* Complete rebuild for WordPress 7.0+ and PHP 8.3+ (strict types, enums, readonly value objects, autoloader).
* New: signed time token instead of logging every page view – faster and privacy friendly.
* New: honeypot field, optional JavaScript check (script module, single-use tokens, max. 2 hours, admin-ajax fallback), link limit.
* New: optional blocking of pingbacks and trackbacks.
* New: choose between blocking and storing as spam.
* New: spam log with anonymised IP addresses (IPv6 /48), reason filter, bulk delete and automatic cleanup.
* New: overview with key figures, dashboard widget and the read-only ability "Get spam statistics".
* New: privacy policy text, page cache notice and complete cleanup on uninstall.
* Migration: minimum time and message are taken over; the old maximum time is not (it blocked visitors of cached pages). The old log is imported in the background, in batches and only within the retention period.
* Security: nonces (per entry for single deletes) and capability checks for all actions, sanitized input, escaped output, prepared SQL, atomic locks.
* Fixed: fatal error on uninstall (removed `mysql_query`).

= 4.0 =
* WordPress 5.6 release.

= 3.0 =
* WordPress 4.9 release.

= 2.0 =
* WordPress 4.x release.

= 1.0 =
* First release.

== Upgrade Notice ==

= 5.0.0 =
Complete rebuild. Requires PHP 8.3 and WordPress 7.0 – check your PHP version before updating. Settings are migrated automatically; the old maximum time is reset to "off". If you use a page cache, clear it after the update.
