| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: WebTotem Security |
| 4 |
* Description: The <a href="https://wtotem.com/" target="_blank">WebTotem</a> Security plugin monitors websites and prevents website attacks with the help of special internal and external utilities. |
| 5 |
* Author URI: https://wtotem.com/ |
| 6 |
* Author: WebTotem |
| 7 |
* Text Domain: wtotem |
| 8 |
* Domain Path: /lang |
| 9 |
* Version: 2.4.17 |
| 10 |
* |
| 11 |
* PHP version 7.1 |
| 12 |
* |
| 13 |
* @copyright 2021-2022 WebTotem |
| 14 |
* @license https://www.gnu.org/licenses/gpl-2.0.txt GPL2 |
| 15 |
* @link https://wordpress.org/plugins/wt-security |
| 16 |
*/ |
| 17 |
|
| 18 |
/** |
| 19 |
* Main file to control the plugin. |
| 20 |
*/ |
| 21 |
define('WEBTOTEM_INIT', true); |
| 22 |
|
| 23 |
/** |
| 24 |
* Plugin dependencies. |
| 25 |
* |
| 26 |
* list of required WordPress functions for the plugin to work. |
| 27 |
*/ |
| 28 |
$wtotem_dependencies = array( |
| 29 |
'wp', |
| 30 |
'wp_die', |
| 31 |
'add_action', |
| 32 |
'remove_action', |
| 33 |
'wp_remote_get', |
| 34 |
'wp_remote_post', |
| 35 |
); |
| 36 |
|
| 37 |
// Stopping execution if dependencies are not met. |
| 38 |
foreach ($wtotem_dependencies as $dependency) { |
| 39 |
if (!function_exists($dependency)) { |
| 40 |
// Report invalid access. |
| 41 |
header('HTTP/1.1 403 Forbidden'); |
| 42 |
die("Protected By WebTotem!"); |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
// Stopping execution if the ABSPATH constant is not available |
| 47 |
if (!defined('ABSPATH')) { |
| 48 |
// Report invalid access. |
| 49 |
header('HTTP/1.1 403 Forbidden'); |
| 50 |
die("Protected By WebTotem!"); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Current version of the plugin's code. |
| 55 |
*/ |
| 56 |
define('WEBTOTEM_VERSION', '2.4.17'); |
| 57 |
|
| 58 |
/** |
| 59 |
* The name of the folder where the plugin's files will be located. |
| 60 |
*/ |
| 61 |
define("WEBTOTEM_PLUGIN_FOLDER", basename(dirname(__FILE__))); |
| 62 |
|
| 63 |
/** |
| 64 |
* The fullpath where the plugin's files will be located. |
| 65 |
*/ |
| 66 |
define('WEBTOTEM_PLUGIN_PATH', WP_PLUGIN_DIR . '/' . WEBTOTEM_PLUGIN_FOLDER); |
| 67 |
|
| 68 |
/** |
| 69 |
* The local URL where the plugin's files and assets are served. |
| 70 |
*/ |
| 71 |
define('WEBTOTEM_URL', rtrim(plugin_dir_url(__FILE__), '/')); |
| 72 |
|
| 73 |
/** |
| 74 |
* The domain name of the current site, without protocol and www. |
| 75 |
*/ |
| 76 |
define("WEBTOTEM_SITE_DOMAIN", str_replace(['http://', 'https://', '//', '://', 'www.'], '', get_site_url())); |
| 77 |
|
| 78 |
/** |
| 79 |
* Unique name of the plugin through out all the code. |
| 80 |
*/ |
| 81 |
define("WEBTOTEM", 'wtotem'); |
| 82 |
|
| 83 |
/* Load plugin translations */ |
| 84 |
function wtotem_load_plugin_textdomain() { |
| 85 |
load_plugin_textdomain('wtotem', false, basename(dirname(__FILE__)) . '/lang/'); |
| 86 |
} |
| 87 |
add_action('plugins_loaded', 'wtotem_load_plugin_textdomain'); |
| 88 |
|
| 89 |
|
| 90 |
/* Load all classes before anything else. */ |
| 91 |
require_once 'lib/Helper.php'; |
| 92 |
require_once 'lib/API.php'; |
| 93 |
require_once 'lib/DB.php'; |
| 94 |
require_once 'lib/Cache.php'; |
| 95 |
require_once 'lib/modules/login/Login.php'; |
| 96 |
require_once 'lib/modules/logs/EventListener.php'; |
| 97 |
require_once 'lib/modules/logs/Scan.php'; |
| 98 |
require_once 'lib/Request.php'; |
| 99 |
require_once 'lib/Interface.php'; |
| 100 |
require_once 'lib/AgentManager.php'; |
| 101 |
require_once 'lib/Option.php'; |
| 102 |
require_once 'lib/Template.php'; |
| 103 |
require_once 'lib/Country.php'; |
| 104 |
require_once 'lib/Ajax.php'; |
| 105 |
|
| 106 |
/* Load page and ajax handlers */ |
| 107 |
require_once 'src/PageHandler.php'; |
| 108 |
|
| 109 |
/* Load common variables and triggers */ |
| 110 |
require_once 'src/Common.php'; |
| 111 |
|
| 112 |
/** |
| 113 |
* Uninstalled the plugin |
| 114 |
* |
| 115 |
* @return void |
| 116 |
*/ |
| 117 |
function wtotemUninstall() { |
| 118 |
|
| 119 |
if (WebTotemOption::getPluginSettings('hide_wp_version')) { |
| 120 |
WebTotemOption::restoreReadme(); |
| 121 |
} |
| 122 |
|
| 123 |
if(WebTotem::isMultiSite()){ |
| 124 |
WebTotemOption::clearAllHosts(); |
| 125 |
} |
| 126 |
|
| 127 |
/* Delete all agents files and directories */ |
| 128 |
WebTotemAgentManager::removeAgents(); |
| 129 |
|
| 130 |
/* Delete settings from the database */ |
| 131 |
WebTotemDB::uninstall(); |
| 132 |
|
| 133 |
} |
| 134 |
|
| 135 |
register_uninstall_hook(__FILE__, 'wtotemUninstall'); |
| 136 |
|
| 137 |
/** |
| 138 |
* Deactivation plugin |
| 139 |
* |
| 140 |
* @return void |
| 141 |
*/ |
| 142 |
function wtotemDeactivation() { |
| 143 |
if (WebTotemOption::getPluginSettings('hide_wp_version')) { |
| 144 |
WebTotemOption::restoreReadme(); |
| 145 |
} |
| 146 |
} |
| 147 |
register_deactivation_hook( __FILE__, 'wtotemDeactivation' ); |
| 148 |
|
| 149 |
/** |
| 150 |
* Deactivation plugin |
| 151 |
* |
| 152 |
* @return void |
| 153 |
*/ |
| 154 |
function wtotemActivation() { |
| 155 |
WebTotemDB::install(); |
| 156 |
if (WebTotemOption::getPluginSettings('hide_wp_version')) { |
| 157 |
WebTotemOption::hideReadme(); |
| 158 |
} |
| 159 |
} |
| 160 |
|
| 161 |
register_activation_hook( __FILE__, 'wtotemActivation' ); |
| 162 |
|