| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
/** |
| 4 |
* The BotBlocker Security bootstrap file |
| 5 |
* |
| 6 |
* This file is responsible for loading the necessary files and initializing the plugin functionality. |
| 7 |
* It defines various constants and includes the main class file, which is responsible for running the plugin. |
| 8 |
* The plugin is activated and deactivated using the activate_botblocker() and deactivate_botblocker() functions. |
| 9 |
* The bbcs_run_botblocker_shield() function initializes the plugin and its admin functionality. |
| 10 |
* |
| 11 |
* @link https://globus.studio |
| 12 |
* @package botblocker-security |
| 13 |
* @version 1.6.4 |
| 14 |
* |
| 15 |
* @wordpress-plugin |
| 16 |
* Plugin Name: BotBlocker Security |
| 17 |
* Plugin URI: https://globus.studio/wordpress-toolkit/ |
| 18 |
* Description: BotBlocker Security is a powerful WordPress plugin designed to safeguard your website from unwanted bots and malicious activities. With advanced detection algorithms, BotBlocker identifies and blocks harmful bots, reducing spam and protecting your site's resources. The plugin provides real-time monitoring and customizable rules, allowing you to control access and enhance site security effortlessly. Easy to install and configure, BotBlocker ensures a smooth user experience while keeping your site safe from automated threats. Keep your WordPress site secure and running efficiently with BotBlocker. |
| 19 |
* Version: 1.6.4 |
| 20 |
* Author: Yevhen Leonidov |
| 21 |
* Author URI: https://leonidov.dev/ |
| 22 |
* License: GPL-2.0+ |
| 23 |
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt |
| 24 |
* Requires at least: 5.0 |
| 25 |
* Tested up to: 6.8 |
| 26 |
* Requires PHP: 7.3 |
| 27 |
* Text Domain: botblocker-security |
| 28 |
* Domain Path: /languages |
| 29 |
*/ |
| 30 |
|
| 31 |
|
| 32 |
// Check minimum requirements (PHP) |
| 33 |
if ( version_compare( phpversion(), '7.3.0', '<' ) ) { |
| 34 |
function bbcs_minimum_php_version_notice() { |
| 35 |
echo '<div class="notice notice-error"><p>' . esc_html__( 'BotBlocker requires PHP 7.3 or higher.', 'botblocker-security') . '</p></div>'; |
| 36 |
} |
| 37 |
add_action( 'admin_notices', 'bbcs_minimum_php_version_notice' ); |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
// Check minimum requirements (WordPress) |
| 42 |
if ( version_compare( $GLOBALS['wp_version'], '5.0', '<' ) ) { |
| 43 |
function bbcs_minimum_wp_version_notice() { |
| 44 |
echo '<div class="notice notice-error"><p>' . esc_html__( 'BotBlocker requires WordPress 5.0 or later.', 'botblocker-security') . '</p></div>'; |
| 45 |
} |
| 46 |
add_action( 'admin_notices', 'bbcs_minimum_wp_version_notice' ); |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Constants for the BotBlocker plugin. |
| 52 |
* These constants define various settings and values used throughout the plugin. |
| 53 |
*/ |
| 54 |
if(!defined('BOTBLOCKER')) { |
| 55 |
define('BOTBLOCKER', true); |
| 56 |
} |
| 57 |
define('BOTBLOCKER_DIR', plugin_dir_path(__FILE__)); |
| 58 |
define('BOTBLOCKER_URL', plugin_dir_url(__FILE__)); |
| 59 |
define('BOTBLOCKER_BASENAME', plugin_basename(__FILE__)); |
| 60 |
|
| 61 |
// Include the defines file |
| 62 |
require_once BOTBLOCKER_DIR . 'includes/inc-botblocker-define.php'; |
| 63 |
// Include the helper functions file |
| 64 |
require_once BOTBLOCKER_DIR . 'helpers.php'; |
| 65 |
// Include the core helpers file |
| 66 |
require_once BOTBLOCKER_DIR . 'core-helpers.php'; |
| 67 |
|
| 68 |
// Error handler for critical errors |
| 69 |
if (BBCS_DEBUG == true) bbcs_errorHandlerSet(); |
| 70 |
|
| 71 |
// Include the installation file |
| 72 |
require_once BOTBLOCKER_DIR . 'includes/inc-botblocker-install.php'; |
| 73 |
|
| 74 |
// Include license functionality |
| 75 |
bbcs_handleBotblockerCloudAPI(); |
| 76 |
|
| 77 |
/** |
| 78 |
* Checks if the request is an AJAX request and performs logic. |
| 79 |
* |
| 80 |
* This function is responsible for checking if the current request is an AJAX request and performing the necessary bot blocking logic. |
| 81 |
* It prevents automated bots from accessing or submitting data through AJAX requests. |
| 82 |
* |
| 83 |
* @return void |
| 84 |
*/ |
| 85 |
function bbcs_botblocker_ajax_check() |
| 86 |
{ |
| 87 |
check_ajax_referer('botblocker_nonce', 'nonce'); |
| 88 |
|
| 89 |
/* Include the BotBlocker main class file */ |
| 90 |
require_once(BOTBLOCKER_DIR . 'includes/botblocker/class-botblocker.php'); |
| 91 |
$botBlocker = new BotBlocker(); |
| 92 |
$botBlocker->init_visitor_pages(); |
| 93 |
$botBlocker->initialize(); |
| 94 |
|
| 95 |
wp_die(); |
| 96 |
} |
| 97 |
add_action('wp_ajax_bbcs_botblocker_check', 'bbcs_botblocker_ajax_check'); |
| 98 |
add_action('wp_ajax_nopriv_bbcs_botblocker_check', 'bbcs_botblocker_ajax_check'); |
| 99 |
|
| 100 |
/** |
| 101 |
* Activates the BotBlocker plugin. |
| 102 |
* |
| 103 |
* This function is called when the plugin is activated. |
| 104 |
* It includes the necessary files, performs database operations, and creates rule files. |
| 105 |
* |
| 106 |
* @return void |
| 107 |
*/ |
| 108 |
function bbcs_activate_botblocker() |
| 109 |
{ |
| 110 |
// Open output buffering to prevent premature output |
| 111 |
ob_start(); |
| 112 |
|
| 113 |
/* Check installation and create tables if necessary */ |
| 114 |
bbcs_check_install(); |
| 115 |
|
| 116 |
require_once BOTBLOCKER_DIR . 'includes/class-botblocker-activator.php'; |
| 117 |
Botblocker_Activator::activate(); |
| 118 |
|
| 119 |
// Install mu-plugin |
| 120 |
if (defined('BOTBLOCKER_INTEGRATE_MU_PLUGINS') && BOTBLOCKER_INTEGRATE_MU_PLUGINS) { |
| 121 |
bbcs_installMuPlugin(); |
| 122 |
} |
| 123 |
|
| 124 |
bbcs_register_cron_tasks(); |
| 125 |
|
| 126 |
// License URL |
| 127 |
bbcs_rewrite_rules(); |
| 128 |
flush_rewrite_rules(true); |
| 129 |
|
| 130 |
// Clean up output buffering |
| 131 |
ob_end_clean(); |
| 132 |
} |
| 133 |
register_activation_hook(__FILE__, 'bbcs_activate_botblocker'); |
| 134 |
|
| 135 |
/** |
| 136 |
* Deactivates the BotBlocker plugin. |
| 137 |
* |
| 138 |
* This function is called when the plugin is deactivated. |
| 139 |
* It includes the necessary files and performs cleanup operations. |
| 140 |
* |
| 141 |
* @return void |
| 142 |
*/ |
| 143 |
function bbcs_deactivate_botblocker() |
| 144 |
{ |
| 145 |
require_once BOTBLOCKER_DIR . 'includes/class-botblocker-deactivator.php'; |
| 146 |
Botblocker_Deactivator::deactivate(); |
| 147 |
|
| 148 |
// Uninstall mu-plugin |
| 149 |
if (defined('BOTBLOCKER_INTEGRATE_MU_PLUGINS') && BOTBLOCKER_INTEGRATE_MU_PLUGINS) { |
| 150 |
bbcs_uninstallMuPlugin(); |
| 151 |
} |
| 152 |
|
| 153 |
bbcs_remove_cron_tasks(); |
| 154 |
|
| 155 |
flush_rewrite_rules(true); |
| 156 |
} |
| 157 |
register_deactivation_hook(__FILE__, 'bbcs_deactivate_botblocker'); |
| 158 |
|
| 159 |
// Include the main class file |
| 160 |
if (! class_exists('Cyber_Secure_Botblocker')) { |
| 161 |
require_once BOTBLOCKER_DIR . 'includes/class-cyber-secure-botblocker.php'; |
| 162 |
} |
| 163 |
|
| 164 |
/** |
| 165 |
* Runs the BotBlocker plugin. |
| 166 |
* |
| 167 |
* This function initializes the plugin and its admin functionality. |
| 168 |
* |
| 169 |
* @return void |
| 170 |
*/ |
| 171 |
function bbcs_run_botblocker_shield() |
| 172 |
{ |
| 173 |
/* Check installation and create tables if necessary (for corrupted installations) */ |
| 174 |
bbcs_check_install(); |
| 175 |
|
| 176 |
/* Include active addons after database is ready */ |
| 177 |
bbcs_include_active_addons(); |
| 178 |
|
| 179 |
/* Include the BotBlocker main interface class file */ |
| 180 |
$plugin = new Cyber_Secure_Botblocker(); |
| 181 |
$plugin->run(); |
| 182 |
|
| 183 |
// Initialize the admin functionality |
| 184 |
$bbcs_admin = Botblocker_Admin::getInstance(); |
| 185 |
add_action('admin_menu', array($bbcs_admin, 'add_admin_menu')); |
| 186 |
$bbcs_admin->run(); |
| 187 |
} |
| 188 |
|
| 189 |
add_action('plugins_loaded', 'bbcs_run_botblocker_shield', -9998); |
| 190 |
|
| 191 |
/* Add preconnect for Google Fonts and Google Charts*/ |
| 192 |
function bbcs_add_google_fonts_preconnect() |
| 193 |
{ |
| 194 |
echo '<link rel="preconnect" href="https://fonts.googleapis.com">'; |
| 195 |
echo '<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>'; |
| 196 |
} |
| 197 |
add_action('wp_head', 'bbcs_add_google_fonts_preconnect'); |
| 198 |
|
| 199 |
/* End of file botblocker-security.php */ |
| 200 |
|