Merges informatiq-wp-secure + informatiq-utils + HoneypotFields into a single unified plugin with the following improvements: - Fixed deactivation bug: all protection methods now guard themselves with their own option check so toggling off via AJAX takes effect immediately without any hook re-registration. - Added rate-limiting for good/legitimate bots (Googlebot, Bingbot, DuckDuckBot, Yandex, etc.) via transient sliding-window counters; configurable per-bot limits in goodbots.conf (BotName|req/min); returns HTTP 429 with Retry-After: 60 when over limit. - Unified MySQL-backed logging (itk_bot_log + itk_honeypot_log tables) replaces the old wp_options-based 100-entry cap. - New Dashboard tab with terminal-style bot activity monitor: total blocked, today's count, rate-limited hits, top threat sources (bar chart), top IPs, top honeypot form types, active-module status panel. - All optimizations from utils.php merged into Optimization tab as toggleable settings (was always-on before). - Single admin page (Settings → InformatiQ Toolkit) with 8 tabs: Dashboard | Bot Blocker | Protection | Optimization | Honeypot | Bot Logs | Honeypot Logs | Config Files. - Config file editor for badbots.conf, goodbots.conf, referrers.conf, networks.conf, allowed-ips.conf with AJAX save and transient flush. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
148 lines
5.3 KiB
PHP
148 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: InformatiQ Toolkit
|
|
* Plugin URI: https://informatiq.services
|
|
* Description: All-in-one security, optimization, and anti-spam toolkit. Bot blocking with dashboard, login protection, honeypot forms, and WordPress optimizations.
|
|
* Version: 1.0.0
|
|
* Author: Mălin Cenușă
|
|
* Author URI: https://mălin.ro
|
|
* License: GPL v2 or later
|
|
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
|
* Text Domain: informatiq-toolkit
|
|
*/
|
|
|
|
if (!defined('ABSPATH')) {
|
|
exit;
|
|
}
|
|
|
|
define('ITK_VERSION', '1.0.0');
|
|
define('ITK_PATH', plugin_dir_path(__FILE__));
|
|
define('ITK_URL', plugin_dir_url(__FILE__));
|
|
define('ITK_BASENAME', plugin_basename(__FILE__));
|
|
|
|
require_once ITK_PATH . 'includes/class-itk-database.php';
|
|
require_once ITK_PATH . 'includes/class-itk-bot-blocker.php';
|
|
require_once ITK_PATH . 'includes/class-itk-protection.php';
|
|
require_once ITK_PATH . 'includes/class-itk-optimization.php';
|
|
require_once ITK_PATH . 'includes/class-itk-honeypot.php';
|
|
require_once ITK_PATH . 'includes/class-itk-admin.php';
|
|
|
|
class InformatiQ_Toolkit {
|
|
|
|
private static $instance = null;
|
|
|
|
public static function instance() {
|
|
if (null === self::$instance) {
|
|
self::$instance = new self();
|
|
}
|
|
return self::$instance;
|
|
}
|
|
|
|
private function __construct() {
|
|
new ITK_Bot_Blocker();
|
|
new ITK_Protection();
|
|
new ITK_Optimization();
|
|
new ITK_Honeypot();
|
|
|
|
if (is_admin()) {
|
|
new ITK_Admin();
|
|
}
|
|
|
|
add_filter('plugin_action_links_' . ITK_BASENAME, [$this, 'add_settings_link']);
|
|
}
|
|
|
|
public function add_settings_link($links) {
|
|
array_unshift($links, '<a href="' . admin_url('options-general.php?page=informatiq-toolkit') . '">Settings</a>');
|
|
return $links;
|
|
}
|
|
|
|
public static function activate() {
|
|
ITK_Database::install();
|
|
|
|
// Default security settings
|
|
if (!get_option('itk_security')) {
|
|
add_option('itk_security', [
|
|
'block_openai_bots' => 1,
|
|
'block_malicious_bots' => 1,
|
|
'block_bad_referrers' => 1,
|
|
'block_bad_networks' => 1,
|
|
'rate_limit_good_bots' => 1,
|
|
'protect_wp_login' => 1,
|
|
'protect_wp_includes' => 1,
|
|
'protect_uploads' => 1,
|
|
'block_author_scans' => 1,
|
|
'block_malicious_queries'=> 1,
|
|
'add_security_headers' => 1,
|
|
'block_xmlrpc' => 1,
|
|
'enable_custom_login' => 0,
|
|
'custom_login_slug' => 'thoushallpass',
|
|
'response_code' => '301_custom',
|
|
'redirect_url' => 'https://example.com/blocked',
|
|
'custom_message' => 'Access denied.',
|
|
'log_blocked_attempts' => 1,
|
|
]);
|
|
}
|
|
|
|
// Default optimization settings
|
|
if (!get_option('itk_optimization')) {
|
|
add_option('itk_optimization', [
|
|
'remove_wp_version' => 1,
|
|
'hide_login_errors' => 1,
|
|
'remove_author_class' => 1,
|
|
'remove_script_versions' => 1,
|
|
'change_author_base' => 1,
|
|
'limit_revisions' => 1,
|
|
'remove_emoji' => 1,
|
|
'remove_default_userfields'=> 1,
|
|
'clean_bad_content' => 1,
|
|
'remove_wp_head_noise' => 1,
|
|
'disable_xml_rpc' => 1,
|
|
'deregister_wp_embed' => 1,
|
|
'stop_empty_search_redirect'=> 1,
|
|
'unregister_default_widgets'=> 1,
|
|
'defer_js' => 1,
|
|
'limit_heartbeat' => 1,
|
|
'disable_dashboard_widgets'=> 1,
|
|
'disable_comments_url' => 1,
|
|
'disable_floc' => 1,
|
|
'lightbox_images' => 1,
|
|
'remove_admin_bar_links' => 1,
|
|
'admin_branding' => 1,
|
|
'use_google_jquery' => 0,
|
|
'featured_image_rss' => 1,
|
|
'dns_prefetch' => 1,
|
|
]);
|
|
}
|
|
|
|
// Default honeypot settings
|
|
if (!get_option('itk_honeypot')) {
|
|
add_option('itk_honeypot', [
|
|
'enabled' => 1,
|
|
'protect_comments' => 1,
|
|
'protect_login' => 1,
|
|
'protect_register' => 1,
|
|
'protect_lost_password'=> 1,
|
|
'protect_woocommerce' => 1,
|
|
'protect_cf7' => 1,
|
|
'protect_elementor' => 1,
|
|
'protect_gravity' => 1,
|
|
'protect_search' => 1,
|
|
'min_time' => 3,
|
|
'max_time' => 7200,
|
|
'retain_days' => 90,
|
|
]);
|
|
}
|
|
|
|
flush_rewrite_rules();
|
|
}
|
|
|
|
public static function deactivate() {
|
|
flush_rewrite_rules();
|
|
}
|
|
}
|
|
|
|
register_activation_hook(__FILE__, ['InformatiQ_Toolkit', 'activate']);
|
|
register_deactivation_hook(__FILE__, ['InformatiQ_Toolkit', 'deactivate']);
|
|
|
|
add_action('plugins_loaded', ['InformatiQ_Toolkit', 'instance']);
|