PluginProbe
MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall / 5.77
MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall v5.77
6.72 6.69 6.65 6.62 6.48 6.47 5.41 5.42 5.45 5.47 5.53 5.54 5.55 5.56 5.65 5.67 5.68 5.72 5.73 5.77 5.81 5.85 5.88 5.91 5.92 All 88 releases
malcare-security / info.php

info.php in MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall 5.77, at info.php

259 lines 7.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('MCInfo')) :
5 class MCInfo {
6 public $settings;
7 public $config;
8 public $plugname = 'malcare';
9 public $brandname = 'MalCare';
10 public $badgeinfo = 'mcbadge';
11 public $ip_header_option = 'mcipheader';
12 public $brand_option = 'bv_whitelabel_infos';
13 public $wp_lp_whitelabel_option = 'mcLpWhitelabelConf';
14 public $version = '5.77';
15 public $webpage = 'https://www.malcare.com';
16 public $appurl = 'https://app.malcare.com';
17 public $slug = 'malcare-security/malcare.php';
18 public $plug_redirect = 'mcredirect';
19 public $logo = '../img/logo.png';
20 public $brand_icon = '/img/icon.svg';
21 public $services_option_name = 'mcconfig';
22 public $author = 'MalCare Security';
23 public $title = 'MalCare WordPress Security Plugin - Malware Scanner, Cleaner, Security Firewall';
24
25 const DB_VERSION = '5';
26 const AL_CONF_VERSION = '1.1';
27
28 public function __construct($settings) {
29 $this->settings = $settings;
30 $this->config = $this->settings->getOption($this->services_option_name);
31 }
32
33 public function getCurrentDBVersion() {
34 $bvconfig = $this->config;
35 if ($bvconfig && array_key_exists('db_version', $bvconfig)) {
36 return $bvconfig['db_version'];
37 }
38 return false;
39 }
40
41 public function hasValidDBVersion() {
42 return MCInfo::DB_VERSION === $this->getCurrentDBVersion();
43 }
44
45 public function getLatestWooCommerceDBVersion() {
46 if (defined('WC_ABSPATH') && file_exists(WC_ABSPATH . 'includes/class-wc-install.php')) {
47 include_once WC_ABSPATH . 'includes/class-wc-install.php';
48
49 if (class_exists('WC_Install')) {
50 $update_versions = array_keys(WC_Install::get_db_update_callbacks());
51
52 if (!empty($update_versions)) {
53 asort($update_versions);
54 return end($update_versions);
55 }
56 }
57 }
58
59 return false;
60 }
61
62 public function getConnectionKey() {
63 require_once dirname( __FILE__ ) . '/recover.php';
64 $bvsiteinfo = new MCWPSiteInfo();
65 $encoded_url = base64_encode($bvsiteinfo->siteurl());
66 $secret = MCRecover::defaultSecret($this->settings);
67
68 return base64_encode("v1:".$secret.":".$encoded_url);
69 }
70
71 public function getDefaultSecret() {
72 require_once dirname( __FILE__ ) . '/recover.php';
73 $bvsiteinfo = new MCWPSiteInfo();
74 return MCRecover::defaultSecret($this->settings);
75 }
76
77 public function getLatestElementorDBVersion($file) {
78 $managerClass = $file === "elementor/elementor.php" ? '\Elementor\Core\Upgrade\Manager' : '\ElementorPro\Core\Upgrade\Manager';
79
80 if (!class_exists($managerClass)) {
81 return false;
82 }
83
84 $manager = new $managerClass();
85 return $manager->get_new_version();
86 }
87
88 public static function getRequestID() {
89 if (!defined("BV_REQUEST_ID")) {
90 define("BV_REQUEST_ID", uniqid(mt_rand()));
91 }
92 return BV_REQUEST_ID;
93 }
94
95 public function canSetCWBranding() {
96 if (MCWPSiteInfo::isCWServer()) {
97
98 $bot_protect_accounts = MCAccount::accountsByType($this->settings, 'botprotect');
99 if (sizeof($bot_protect_accounts) >= 1)
100 return true;
101
102 $bot_protect_accounts = MCAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/');
103 if (sizeof($bot_protect_accounts) >= 1)
104 return true;
105 }
106
107 return false;
108 }
109
110 public function canWhiteLabel($slug = NULL) {
111 if (array_key_exists("bv_override_global_whitelabel", $_REQUEST)) {
112 return false;
113 }
114 if (array_key_exists("bv_override_plugin_whitelabel", $_REQUEST) && isset($slug) &&
115 $_REQUEST["bv_override_plugin_whitelabel"] === $slug) {
116 return false;
117 }
118 return true;
119 }
120
121 public function getPluginWhitelabelInfo($slug = null) {
122 if ($slug === null) {
123 $slug = $this->slug;
124 }
125 $whitelabel_infos = $this->getPluginsWhitelabelInfos();
126 if (!array_key_exists($slug, $whitelabel_infos) || !is_array($whitelabel_infos[$slug])) {
127 return array();
128 }
129 return $whitelabel_infos[$slug];
130 }
131
132 public function getBrandInfo() {
133 return $this->settings->getOption($this->brand_option);
134 }
135
136 public function getPluginsWhitelabelInfos() {
137 $whitelabel_infos = $this->settings->getOption($this->brand_option);
138 return is_array($whitelabel_infos) ? $whitelabel_infos : array();
139 }
140
141 public function getLPWhitelabelInfo() {
142 $infos = $this->settings->getOption($this->wp_lp_whitelabel_option);
143 return is_array($infos) ? $infos : array();
144 }
145
146 public function getPluginsWhitelabelInfoByTitle() {
147 $whitelabel_infos = $this->getPluginsWhitelabelInfos();
148 $whitelabel_infos_by_title = array();
149 foreach ($whitelabel_infos as $slug => $whitelabel_info) {
150 if (is_array($whitelabel_info) && array_key_exists('default_title', $whitelabel_info) && isset($whitelabel_info['default_title'])) {
151 $whitelabel_info['slug'] = $slug;
152 $whitelabel_infos_by_title[$whitelabel_info['default_title']] = $whitelabel_info;
153 }
154 }
155 return $whitelabel_infos_by_title;
156 }
157
158 public function getBrandName() {
159 $brand = $this->getPluginWhitelabelInfo();
160 if (is_array($brand) && array_key_exists('menuname', $brand)) {
161 return $brand['menuname'];
162 }
163 $bvinfo = new MCInfo($this->settings);
164 if ($bvinfo->canSetCWBranding()) {
165 return "Cloudways";
166 }
167
168 return $this->brandname;
169 }
170
171 public function getBrandIcon() {
172 $brand = $this->getPluginWhitelabelInfo();
173 if (is_array($brand) && array_key_exists('brand_icon', $brand)) {
174 return $brand['brand_icon'];
175 }
176 return $this->brand_icon;
177 }
178
179 public function getWatchTime() {
180 $time = $this->settings->getOption('bvwatchtime');
181 return ($time ? $time : 0);
182 }
183
184 public function appUrl() {
185 if (defined('BV_APP_URL')) {
186 return BV_APP_URL;
187 } else {
188 $brand = $this->getPluginWhitelabelInfo();
189 if (is_array($brand) && array_key_exists('appurl', $brand)) {
190 return $brand['appurl'];
191 }
192 return $this->appurl;
193 }
194 }
195
196 public function isActivePlugin() {
197 $expiry_time = time() - (3 * 24 * 3600);
198 return ($this->getWatchTime() > $expiry_time);
199 }
200
201 public function isValidEnvironment(){
202 $bvsiteinfo = new MCWPSiteInfo();
203 $bvconfig = $this->config;
204
205 if (is_multisite()) {
206 return true;
207 } elseif ($bvconfig && array_key_exists("siteurl_scheme", $bvconfig)) {
208 $siteurl = $bvsiteinfo->siteurl('', $bvconfig["siteurl_scheme"]);
209 if (array_key_exists("abspath", $bvconfig) &&
210 array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) {
211 return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl);
212 }
213 }
214 return true;
215 }
216
217 public function isProtectModuleEnabled() {
218 return $this->isServiceActive("protect") && $this->isValidEnvironment();
219 }
220
221 public function isDynSyncModuleEnabled() {
222 if ($this->isServiceActive("dynsync")) {
223 $dynconfig = $this->config['dynsync'];
224 if (array_key_exists('dynplug', $dynconfig) && ($dynconfig['dynplug'] === $this->plugname)) {
225 return true;
226 }
227 }
228 return false;
229 }
230
231 public function isServiceActive($service) {
232 $bvconfig = $this->config;
233 if ($bvconfig && array_key_exists('services', $bvconfig)) {
234 return in_array($service, $bvconfig['services']) && $this->isActivePlugin();
235 }
236 return false;
237 }
238
239 public function isActivateRedirectSet() {
240 return ($this->settings->getOption($this->plug_redirect) === 'yes') ? true : false;
241 }
242
243 public function isMalcare() {
244 return $this->getBrandName() === 'MalCare';
245 }
246
247 public function isBlogvault() {
248 return $this->getBrandName() === 'BlogVault';
249 }
250
251 public function info() {
252 return array(
253 "bvversion" => $this->version,
254 "sha1" => "true",
255 "plugname" => $this->plugname
256 );
257 }
258 }
259 endif;