=== Simple DDoS Monitor ===
Contributors: tlloancy
Stable Tag: 1.1.0
Requires at least: 4.0
Tested up to: 7.0
Requires PHP: 7.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A lightweight WordPress plugin to monitor websites for database errors or server outages with real-time status updates.

== Description ==

**Simple DDoS Monitor** is your go-to solution for keeping an eye on your websites. This lightweight plugin checks for database errors or server downtimes, providing visual status indicators and email alerts when issues arise. Designed for simplicity and efficiency, it's perfect for WordPress administrators who need reliable monitoring without complexity.

- **Automatic Monitoring**: Checks your sites every minute via WP-Cron.
- **Visual Dashboard**: Colour-coded rows with a global health badge and response-time chips.
- **Check Now**: Instantly trigger a manual check from the dashboard without waiting for cron.
- **Response Times**: See how fast each monitored URL responds, colour-coded fast / medium / slow.
- **Last-Checked Timestamps**: Each row shows how long ago the last check ran ("just now", "2 min ago"…).
- **Recovery Alerts**: Get notified by email when a site comes *back* online, not only when it goes down.
- **Animated Feedback**: Status changes trigger a visual flash so you catch them at a glance.
- **Clean Uninstall**: All options and transients are removed when the plugin is deleted.
- **Lightweight Design**: Minimal server impact for maximum efficiency.

== Installation ==

1. **Download** the plugin from WordPress.org.
2. **Upload** the `simple-ddos-monitor` folder to the `/wp-content/plugins/` directory.
3. **Activate** the plugin through the **Plugins** menu in WordPress.
4. **Configure** by navigating to **Settings > DDoS Monitor** in your WordPress dashboard.

== Usage ==

1. Go to **Settings > DDoS Monitor** in your WordPress admin dashboard.
2. Enter the URLs of the websites you want to monitor, separated by commas.
3. Save your settings and let the plugin do the rest.
4. Use the **Check Now** button for an on-demand check at any time.

== Features ==

- Automatic site checks every minute via WP-Cron (runs in the background — no admin page required).
- Manual **Check Now** button triggers an immediate synchronous check and returns fresh results.
- Visual dashboard with per-site status rows and a global health badge.
- Per-row response-time chip (green < 500 ms / amber < 2 s / red ≥ 2 s).
- Per-row "last checked" relative timestamp, refreshed live in the browser.
- Flash animation when a row's status changes so you never miss an update.
- Email alerts when a site's status changes from OK to an error state.
- Email alerts when a site **recovers** and returns to OK.
- Uses `wp_remote_get` for reliable HTTP requests.
- Automatic protocol handling (no need to specify `http://` or `https://`).
- Proper activation and deactivation hooks — cron is scheduled on activation and cleaned up on deactivation.

== Notes ==

- The plugin relies on `wp_remote_get` for site checks. Ensure your server allows outgoing HTTP requests.
- URLs do not require `http://` or `https://` prefixes; the plugin adds them automatically.
- Monitoring runs via WP-Cron and does not require you to have the admin page open.

== Frequently Asked Questions ==

= How do I add websites to monitor? =

Navigate to **Settings > DDoS Monitor** in your WordPress dashboard and enter the URLs, separated by commas.

= Does the plugin run in the background? =

Yes. Monitoring is handled entirely by WP-Cron and runs even when no admin is viewing the plugin page. Use **Check Now** for an immediate on-demand check.

= What does the response time colour mean? =

Green (< 500 ms) means the server is fast. Amber (500 ms – 2 s) is moderate. Red (≥ 2 s) may indicate a slow or overloaded server.

= Will I get an email when a site recovers? =

Yes. Since 1.1.0 the plugin sends a recovery alert whenever a monitored site returns to an OK state after being in an error state.

= What happens if my server blocks outgoing HTTP requests? =

The plugin uses `wp_remote_get` to check sites. If your server blocks outgoing HTTP requests, monitoring will not work. Contact your hosting provider to enable this.

= Do I need to include `http://` or `https://` in the URLs? =

No, the plugin automatically adds the appropriate protocol.

= What is removed when I delete the plugin? =

All options (`ddos_monitor_urls`, `ddos_monitor_enable_email`, `ddos_monitor_email`) and all status transients are deleted on uninstall.

== Changelog ==

= 1.1.0 =
* New: Tested and compatible with WordPress 7.0.
* New: **Check Now** button — trigger an immediate manual check from the dashboard.
* New: Response-time chip per URL (colour-coded: fast / medium / slow).
* New: "Last checked" relative timestamp per URL, refreshed live every 30 seconds.
* New: Flash animation on rows when their status changes.
* New: Pulsing dot animation during loading and manual checks.
* New: Recovery email alerts — admins are now notified when a site comes back online.
* New: `uninstall.php` — all options and transients removed on plugin deletion.
* New: `register_activation_hook` / `register_deactivation_hook` for proper cron lifecycle management.
* Fixed: Global badge text no longer shows `undefined` — localized labels (`label_all_ok`, `label_issues`, `label_pending`) now passed via `wp_localize_script`.
* Fixed: Duplicate `wp_ajax_ddos_monitor_toggle_email` hook registration removed from main plugin file.
* Improved: Status transients now store structured data (status, response_time, checked_at) with backward-compatible fallback for 1.0.x string format.
* Improved: Dashboard UI polished — status bar split into left group and Check Now button, card shadow, smoother transitions.

= 1.0.2 =
* Fixed: `Tested up to` updated to WordPress 6.9.
* Fixed: Added version parameter to `wp_enqueue_style` and `wp_enqueue_script` to prevent browser caching issues.
* Fixed: `$checked` attribute in email checkbox now correctly escaped via `esc_attr()`.
* Fixed: `$_POST['email']` now unslashed with `wp_unslash()` before sanitization.
* Fixed: Removed all `error_log()` calls from production code.
* Fixed: Removed `wp_ajax_nopriv` registration for `ddos_monitor_toggle_email`.
* Fixed: Removed `wp_ajax_nopriv` registration for `ddos_monitor_get_statuses`.
* Fixed: Status transient TTL increased from 60 s to 5 minutes to survive brief cron delays.
* Fixed: Duplicate status refresh (double `setInterval`) eliminated in JavaScript.
* Improved: Admin dashboard redesigned with colour-coded site rows and a global health badge.
* Improved: Scripts and styles only enqueued on the plugin's own admin page.
* Improved: `wp_send_json_success` / `wp_send_json_error` used consistently for AJAX responses.

= 1.0.1 =
* Fixed issues for WordPress.org plugin review compliance.

= 1.0 =
* Initial release of Simple DDoS Monitor.

== Screenshots ==

1. **Monitoring Dashboard**: View the status of all monitored websites at a glance, with response times and last-checked timestamps.
2. **Status Indicators**: Colour-coded rows with green/red/pending badges, response-time chips, and animated flash on change.
3. **Check Now**: The manual check button triggers an immediate synchronous check.
4. **Configuration Page**: Easily add or edit URLs to monitor.
5. Example of a failure email alert sent when a monitored website experiences downtime.
6. Example of a recovery email alert sent when a monitored website comes back online.

---

**Tags:** website monitoring, server status, database errors, email alerts, site health, uptime monitor
