=== Predax Security (formerly IPSentry) ===
Contributors: ipsentry
Tags: security, firewall, brute force, ip blocking, vpn
Requires at least: 5.8
Tested up to: 7.0
Stable tag: 1.9.4
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Real-time IP threat detection and blocking. Stop VPNs, proxies, Tor, bots, and high-risk IPs before they reach your site.

== Description ==

**Predax Security** connects your WordPress site to the Predax threat intelligence API to detect and block malicious traffic in real time — once the site administrator has enabled a protection preset.

After you complete setup and pick a protection preset (or enable individual protections from Settings), visitor IPs are checked against a continuously-updated database of known VPN providers, open proxies, Tor exit nodes, datacenter ranges, and web crawlers. High-risk IPs are blocked before they can log in, register, post comments, or browse your site.

On a fresh install the plugin is **off by default** — no visitor data is sent anywhere until you explicitly enable a protection via the setup wizard or the Settings &rarr; Protection tab.

= Key Features =

* **Security Dashboard** — real-time overview with blocking activity chart, threat breakdown, top targeted paths, protection status, and country analysis
* **Real-time VPN/Proxy/Tor/Datacenter detection** — checks every visitor against live threat intelligence
* **Risk score thresholds** — block IPs above a configurable risk score (0–100)
* **Country geo-blocking** — block or allow specific countries and regions
* **Login protection** — block high-risk IPs from attempting to log in
* **Registration protection** — stop fraudulent account creation
* **Comment protection** — block spam and bot comments at source
* **Visitor protection** — optionally check all page visitors (with 1-hour caching to minimise API calls)
* **XML-RPC & REST API protection** — extend blocking to XML-RPC calls and REST API requests
* **Disposable email blocking** — reject registrations using throwaway email services
* **Custom block page** — show a branded 403 page instead of the default WordPress error
* **Whitelist/blacklist** — override decisions for individual IPs or CIDR ranges
* **Threat log** — view and export all blocked events with IP, reason, and timestamp
* **Event tracking** — log successful checks for audit and analytics
* **Settings import/export** — back up and restore your configuration as a JSON file
* **WP-CLI commands** — manage whitelists, blacklists, and run IP tests from the command line

= Free Tier =

Sign up at [predax.io](https://predax.io) for a free API key. The free plan includes:

* 1,000 IP checks per day
* 5,000 IP checks per month
* VPN, proxy, Tor, and datacenter detection
* Country and region data

No credit card required.

= How It Works =

1. You install the plugin, enter an API key, and pick a protection preset during the Setup Wizard (or enable individual protections from Settings &rarr; Protection). This is the explicit opt-in — no data leaves the site until you do this.
2. A visitor makes a request to your site.
3. Predax checks their IP against the threat intelligence API (results cached for 1 hour per IP).
4. If the risk score exceeds your threshold, the visitor is blocked with a configurable message.
5. All block events are logged in the WordPress database for review.

= WP-CLI Commands =

`wp ipsentry status` — show current configuration and threat counts
`wp ipsentry test-ip <ip>` — run a live API check on any IP
`wp ipsentry whitelist add <ip>` — add an IP or CIDR to the whitelist
`wp ipsentry whitelist remove <ip>` — remove from whitelist
`wp ipsentry blacklist add <ip>` — add an IP or CIDR to the blacklist
`wp ipsentry log --limit=20` — view recent threat log entries

== Installation ==

1. Upload the `ipsentry-security` folder to `/wp-content/plugins/`
2. Activate the plugin through the **Plugins** menu in WordPress
3. The setup wizard will guide you through connecting your API key and choosing a protection level
4. Go to **Predax Security** in the admin sidebar to view the security dashboard
5. Click **Settings** to fine-tune protection types, risk thresholds, and advanced features
6. Visit the **Threat Log** page to verify the plugin is detecting threats

== Frequently Asked Questions ==

= Will this slow down my site? =

No. API results are cached in the WordPress database for 1 hour per IP. After the first check, returning visitors are served from cache with no API call. The cache TTL is configurable.

= Does this block all VPN users? =

Only if you enable VPN blocking. By default the plugin is set to *monitor* VPN traffic (log it but not block it). You control exactly which threat types trigger a block.

= What happens to blocked visitors? =

By default they see a standard WordPress error page with a 403 status code. You can enable the **Custom Block Page** option to show a branded page with your own message and a support link.

= Does it work with Cloudflare? =

Yes. The plugin reads the `CF-Connecting-IP` header automatically when Cloudflare is detected, so the real visitor IP is used rather than the Cloudflare proxy IP.

= Is the free plan enough for a small site? =

For most small sites, yes. The free plan provides 1,000 checks per day. With 1-hour caching, this covers approximately 1,000 unique visitors per day. Returning visitors within the hour use cached results and don't count against your quota.

= Can I whitelist my own IP? =

Yes. Go to **Settings → Predax Security → Whitelist / Blacklist** and add your IP or CIDR range. Whitelisted IPs bypass all checks.

= Does it protect the WooCommerce checkout? =

The base security plugin protects logins and registrations. For WooCommerce checkout protection (fraud scoring, country mismatch, order velocity, auto hold), use the companion **Predax WooCommerce Fraud Guard** plugin.

= What data is sent to the API? =

The visitor's IP address, and optionally their timezone when timezone mismatch detection is enabled. A temporary cookie is used to pass the timezone from the browser to the server. No page content or personal user data is transmitted. See the Third Party Services section below for full details.

== Third Party Services ==

This plugin connects to external services. By installing and activating this plugin you agree to the terms of each service you enable.

= Predax API =

This plugin transmits visitor IP addresses to the **Predax API** (https://predax.io) for real-time threat detection and risk scoring.

**What is sent:** The visitor's IP address, and optionally their timezone (when timezone mismatch detection is enabled and visitor protection is active).
**When it is sent:** On each page load, login attempt, registration, or comment submission, subject to your configured protection settings. Results are cached for 1 hour so repeat visits by the same IP do not generate additional API calls.
**Who operates the service:** Predax (predax.io)
**Terms of Service:** https://predax.io/terms
**Privacy Policy:** https://predax.io/privacy

= Community Threat Network (opt-in, disabled by default) =

The Community Threat Network is **opt-in and disabled by default**. No block or monitor events are sent to the community network unless you enable it yourself in **Settings → Predax Security → Advanced**.

When — and only when — you explicitly enable it, anonymised block and monitor events (containing: IP address, action taken, block reason, country code, and risk score) are sent to the Predax API at predax.io. This data is used to build a shared threat database that improves detection accuracy for all sites in the network. You can turn community reporting back off at any time in the same settings screen.

= Google reCAPTCHA =

When reCAPTCHA v3 is enabled (Settings → Protection → reCAPTCHA), this plugin loads the reCAPTCHA script from **google.com** and sends form submission tokens to **google.com/recaptcha** for verification. Google may collect data according to their privacy policy. You must provide your own reCAPTCHA site key and secret key.

**Google Privacy Policy:** https://policies.google.com/privacy
**reCAPTCHA Terms:** https://policies.google.com/terms

= Browser Fingerprinting =

When browser fingerprint scoring is enabled (Settings → Protection → Fingerprint Scoring), this plugin collects screen resolution, timezone, platform string, WebGL renderer, and plugin count from the visitor's browser on the login page. Fingerprint data is used locally to score bot likelihood and is stored in WordPress only while the login form is being submitted, then discarded. The visitor's timezone may be included in the API request to detect timezone mismatch when that feature is enabled.

= Cookies set by this plugin =

All cookies set by this plugin are functional service cookies, not tracking cookies, and are only written when the relevant feature is explicitly enabled by the site administrator:

* `ipsentry_tz` — carries the visitor's browser timezone to the Predax API when timezone-mismatch detection is active. Written from `ipsentry-tz.js` on the front-end. Expires after 24 hours. `SameSite=Lax`. Only set when an API key is configured AND visitor or login protection is enabled.
* `ips_jsc` — JavaScript challenge solve token. Written from `js-challenge.js` when a visitor passes the challenge. Expires after 24 hours. `SameSite=Lax`. Only set when the JavaScript Challenge feature is enabled.

No tracking or advertising cookies are written by this plugin.

By activating this plugin and entering an API key, you agree to the Predax Terms of Service and Privacy Policy. You are responsible for ensuring your use of visitor IP data complies with applicable privacy laws (GDPR, CCPA, etc.) and your own site's privacy policy.

== Screenshots ==

1. Settings page — configure API key, risk threshold, and protection types
2. Threat log — view all blocked events with IP, reason, risk score, and timestamp
3. Dashboard widget — at-a-glance threat stats on the WordPress dashboard
4. Custom block page — branded 403 page shown to blocked visitors
5. Country blocking — select countries and regions to allow or deny

== Changelog ==

= 1.9.4 =
* Compatibility: tested with WordPress 7.0 and PHP 8.2. No deprecations or warnings under `WP_DEBUG`.
* Branding: setup wizard logo and wordmark refreshed to Predax (the "(formerly IPSentry)" suffix remains in the plugin name for clarity). API key field now shows the current `prdx_live_…` placeholder. Existing `ipsent_*` keys continue to authenticate normally.
* Fix: setup wizard OAuth flow no longer fails with a blank "0" page on the redirect back from predax.io. The callback action is now passed explicitly so the flow is robust against future predax.io frontend changes.
* Internal: removed an unused legacy settings template that was shipping in the zip without being loaded anywhere.

= 1.9.3 =
* Branding: IPSentry has been rebranded to **Predax**. The plugin name, description, and admin labels now use the Predax name. The plugin slug, internal class names, text domain, settings, and your existing API key all remain unchanged — the upgrade is purely cosmetic and 100% backwards compatible.
* Branding: external links from the admin pages now point to `predax.io` instead of `ipsentry.io`. The legacy `ipsentry.io` URL still redirects, so older bookmarks continue to work.
* Compatibility: legacy `ipsent_*` API keys created before the rebrand continue to authenticate normally. New keys generated at `https://predax.io/dashboard/api-keys` start with `prdx_`. Both work.
* No data changes. No setting resets. Nothing to reconfigure after the update.

= 1.9.1 =
* Privacy & compliance: Community Threat Network now has an explicit opt-in toggle in Settings → Advanced (disabled by default). Clarified documentation: no data is shared with the community network unless the site admin explicitly enables it.
* Privacy & compliance: visitor protection and login protection are now **off by default on fresh installs**. They are enabled the moment a user completes the Setup Wizard and picks a protection preset (that click is the explicit opt-in). Existing sites upgrading from 1.9.0 are not affected — `add_option()` respects existing values, so if you already had these on, they stay on.
* Security: reordered nonce verification before capability check on the test-connection AJAX endpoint.
* Security: added IP/CIDR validation on the blacklist and whitelist inputs — invalid entries are now silently dropped rather than stored.
* Security: added `uninstall.php` that cleans up all plugin options and drops both custom tables when the plugin is deleted.
* Privacy: added `wp_add_privacy_policy_content` integration so administrators can pull suggested Privacy Policy text from Tools → Privacy.
* Code quality: extracted inline styles from the OAuth callback page, front-end footer badge, and comment honeypot into external stylesheets. Removed an inline `onclick` handler from the `[ipsentry_lookup]` shortcode.
* Code quality: internationalised hard-coded English error messages in admin endpoints. Localised number formatting in event counts and threat badges.

= 1.9.0 =
* New: Security Dashboard — a dedicated dashboard page with real-time threat statistics, blocking activity chart, protection status overview, firewall summary table, top targeted paths, threat type breakdown, and country analysis.
* Improved: Settings page redesigned with cleaner layout and better visual hierarchy.
* Improved: Setup wizard redesigned with modern dark theme and clearer protection preset cards.

= 1.8.0 =
* New: HTTP Security Headers — enable HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, and Permissions-Policy from the plugin settings. One toggle to harden your site's browser security.
* New: Google reCAPTCHA v3 — invisible bot protection for login and registration forms. No puzzles for visitors.
* New: Honeypot URL Traps — hidden decoy URLs that catch automated scanners instantly. Pre-configured with 8 common trap paths.
* New: User-Agent Blocking — block known malicious bots, scanners, and scrapers by their User-Agent string. Ships with 20 pre-configured patterns.
* New: 404 Threshold Blocking — automatically block IPs that trigger excessive 404 errors (scanner behavior). Configurable threshold and temporary or permanent blocking.
* New: Known Bot Verification — verify that visitors claiming to be Googlebot, Bingbot, and other search engines are legitimate using reverse DNS + forward DNS confirmation. Catches fake bot impersonators.
* New: JavaScript Challenge — invisible browser verification that blocks bots unable to execute JavaScript. Clean dark-themed challenge page.
* New: Comment Spam Honeypot — hidden form field that catches spam bots filling in invisible fields. Zero false positives.
* New: Browser Fingerprint Scoring — detects inconsistencies between User-Agent claims and actual browser capabilities on the login page. Logs suspicious fingerprints.
* New: Request Pattern Analysis — identifies bot-like request timing patterns (machine-precise intervals vs human browsing).
* New: WordPress Hardening — one-click toggles to disable XML-RPC, hide WordPress version, and disable file editing.
* New: IP Lookup Shortcode [ipsentry_lookup] — embed an IP threat check widget on any page. Dark and light themes available.
* New: Protected Badge Shortcode [ipsentry_badge] — display "Protected by Predax — X threats blocked" on your site.

= 1.7.0 =
* New: One-Click Connect — click "Connect with Predax" in the setup wizard to link your site instantly. No API key to copy or paste. Just log in (or create a free account), approve, and you're protected.
* New: OAuth2 Authorization Code flow with PKCE for secure, industry-standard site authentication.
* Improved: Setup wizard now defaults to one-click connect with manual API key entry as a fallback option.

= 1.6.0 =
* New: Setup Wizard — guided 3-step setup on first activation. Connect your API key, choose a protection level (Recommended, Strict, or Monitor Only), and you're done in under a minute.
* New: Protection presets — one-click configuration for common security profiles. Re-run anytime from Settings > Developer > Run Setup Wizard.

= 1.5.5 =
* Improvement: All block messages now clearly state "Predax has blocked your access" — visitors always know who blocked them and why.
* Improvement: VPN detection now uses ASN-based matching for major VPN providers (NordVPN, Mullvad, ProtonVPN, Surfshark, ExpressVPN, and more). Previously, some VPN IPs were only flagged as "datacenter" if not in the feed list.

= 1.5.4 =
* New: Reason-specific block pages — blocked visitors now see a clear, context-aware message explaining exactly why they were blocked (VPN detected, high-risk IP, Tor network, temporary lockout with countdown, etc.) instead of a generic error.
* New: Custom block page is now ON by default for all new installs. No configuration needed — blocked visitors immediately see a branded, professional page.
* New: Temporary lockout block message now shows the exact remaining wait time (e.g. "Please wait 2 hours and 30 minutes before trying again").
* New: All login, registration, and comment blocks now show reason-specific messages appropriate to the context.
* Improvement: Exponential backoff for clean IP lockouts — each repeated lockout doubles in duration (30min → 60min → 120min → ... → 24hr max). Resets on successful login.
* Improvement: Residential proxy and timezone mismatch signals now treated as risky (trigger permanent blacklist path, not temporary lockout).

= 1.5.3 =
* New: Risk-aware failed login protection — VPN/proxy/datacenter/high-risk IPs are permanently blocked after 3 failed attempts. Clean/residential IPs get a temporary lockout only (default 30 min), protecting legitimate users who forget their password. (If the Community Threat Network is enabled — it is off by default — these block events are also shared with the network.)
* Improvement: Lockout thresholds and duration are configurable in Settings → Protection.
* Fix: Test Connection button in Developer tab no longer submits the settings form, and now works reliably on slow/local dev environments (LocalWP, etc.).

= 1.5.2 =
* Fix: VPN/proxy users set to "Monitor" mode were incorrectly blocked by the risk threshold. The risk score on VPN/proxy IPs is elevated by the VPN/proxy flag itself — so if you've chosen to monitor (not block) those users, the threshold no longer overrides that decision.

= 1.5.1 =
* Improvement: Settings page redesigned with tabbed interface (Protection, Notifications, Advanced, Developer)
* Improvement: Save and Test Connection buttons now shown inline next to the API key field
* Improvement: Help tooltips added to every setting explaining what each option does
* Improvement: Visitor screening enabled by default for new installs
* Improvement: Custom block page now shows "Protected by Predax" footer branding
* Improvement: Developer tools (Test IP, Import/Export) moved to dedicated Developer tab

= 1.5.0 =
* New: Web Application Firewall — detects and blocks SQL injection, XSS, path traversal, file probes, known scanner tools, and command injection attempts
* New: Community Threat Network (opt-in, off by default) — when you enable it, IP blocks propagate to other opted-in sites in the network via the Predax community score
* New: WAF toggle in plugin settings (default on); independent of the risk score threshold

= 1.4.0 =
* New: Custom block page — show a branded 403 page with configurable title, message, and support link
* New: XML-RPC protection — block high-risk IPs from XML-RPC calls
* New: REST API protection — block high-risk IPs from WP REST API requests
* New: Disposable email blocking — reject registrations using throwaway email services (30+ providers)
* New: Settings import/export — back up and restore configuration as a JSON file
* New: WP-CLI commands — manage lists and run IP tests from the command line (`wp ipsentry`)
* New: Test IP override — set a fixed IP in settings for local/staging testing
* Fix: Registration protection now correctly flags disposable email domains

= 1.3.0 =
* New: General visitor protection — optionally check all site visitors (with transient caching)
* New: Country and region blocking with full ISO 3166-1 alpha-2 support (249 countries)
* New: Custom risk scoring weights — adjust how much each threat type contributes to the risk score
* New: Telemetry pipeline — anonymised threat signals can feed community intelligence when the Community Threat Network is enabled (off by default)
* Improvement: VPN/proxy/Tor options now have Off/Monitor/Block modes for finer control
* Fix: Transient cache key collisions on multisite installs

= 1.2.0 =
* New: Event tracking log — view all API check events (not just blocks) for audit purposes
* New: Admin dashboard widget with 7-day threat chart
* New: CIDR range support for whitelist and blacklist entries
* Improvement: API client now retries once on timeout before failing open

= 1.1.0 =
* New: Registration protection — block high-risk IPs from creating accounts
* New: Comment protection — block high-risk IPs from posting comments
* New: Configurable risk threshold (default 50)
* New: CSV export for the threat log
* Fix: Login protection now respects whitelist entries correctly

= 1.0.0 =
* Initial release
* Login protection with VPN, proxy, and Tor detection
* Whitelist/blacklist management
* Threat log
* Dashboard widget

== Upgrade Notice ==

= 1.9.4 =
WordPress 7.0 + PHP 8.2 compatibility tested. Setup wizard branding refreshed and a fix for an OAuth-redirect edge case that could show a blank "0" page. No settings changes. Safe to upgrade.

= 1.9.1 =
Privacy + security polish. Fresh installs: visitor and login protection now default OFF (enabled by picking a Setup Wizard preset). Community Threat Network opt-in toggle. IP/CIDR validation on blacklists. uninstall.php cleanup. Existing sites keep their settings. Safe to upgrade.

= 1.9.0 =
Adds a full security dashboard as the plugin's landing page. Settings and setup wizard redesigned. No configuration changes required. Safe to upgrade.

= 1.8.0 =
Major feature release — HTTP Security Headers, Google reCAPTCHA v3, Honeypot URL Traps, User-Agent Blocking, 404 Threshold Blocking, JavaScript Challenge, Browser Fingerprint Scoring, and more. All new features are off by default. Safe to upgrade.

= 1.7.0 =
Adds one-click OAuth connect via the setup wizard — link your site to Predax without copying an API key. Manual key entry remains available as a fallback.

= 1.6.0 =
Adds a 3-step setup wizard that runs on first activation. No configuration changes to existing installs. Safe to upgrade.

= 1.5.5 =
Recommended update — VPN detection improved (NordVPN and other major providers now reliably detected). Block messages updated to always mention Predax.

= 1.5.3 =
Recommended update — smarter login protection (hackers get permanently blocked, legitimate users get a temporary lockout). Test Connection button fixed.

= 1.5.2 =
Bug fix: VPN/proxy users in Monitor mode no longer get blocked by the risk threshold. Recommended update for anyone using VPN detection.

= 1.5.1 =
Settings page UX improvements — tabbed layout, inline save/test buttons, help tooltips. No configuration changes required.

= 1.5.0 =
Adds the Web Application Firewall (WAF, on by default) and the opt-in Community Threat Network (off by default; enable in Settings → Predax Security → Advanced to contribute block events to the shared feed). Safe to upgrade — no configuration changes required.

= 1.4.0 =
Adds custom block page, XML-RPC/REST API protection, disposable email blocking, WP-CLI commands, and settings import/export. All new features default to off — no behaviour changes on upgrade.
