Version Description
- Disabling deactivate for botprotection accounts
- Disconnect functionality through wpcli with params account_gid and account_type
- Removed manual signup logic
Download this release
Release Info
Developer | ritesh.soni36 |
Plugin | MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall |
Version | 4.4 |
Comparing to | |
See all releases |
Code changes from version 4.35 to 4.4
- account.php +63 -2
- callback/wings/account.php +3 -7
- callback/wings/db.php +1 -1
- callback/wings/fs.php +20 -4
- callback/wings/misc.php +2 -2
- info.php +15 -5
- malcare.php +3 -1
- readme.txt +13 -4
- wp_admin.php +12 -5
- wp_cli.php +38 -15
account.php
CHANGED
@@ -84,6 +84,39 @@ if (!class_exists('MCAccount')) :
|
|
84 |
return $accountsByPlugname;
|
85 |
}
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
public static function isConfigured($settings) {
|
88 |
$accounts = self::accountsByPlugname($settings);
|
89 |
return (sizeof($accounts) >= 1);
|
@@ -155,16 +188,22 @@ if (!class_exists('MCAccount')) :
|
|
155 |
$this->settings->updateOption('bvLastRecvTime', $time);
|
156 |
return 1;
|
157 |
}
|
158 |
-
|
159 |
public function updateInfo($info) {
|
160 |
$accounts = self::allAccounts($this->settings);
|
161 |
-
$plugname =
|
|
|
162 |
$pubkey = $info['pubkey'];
|
163 |
if (!array_key_exists($pubkey, $accounts)) {
|
164 |
$accounts[$pubkey] = array();
|
165 |
}
|
|
|
|
|
|
|
|
|
166 |
$accounts[$pubkey]['lastbackuptime'] = time();
|
167 |
$accounts[$pubkey][$plugname] = true;
|
|
|
168 |
$accounts[$pubkey]['url'] = $info['url'];
|
169 |
$accounts[$pubkey]['email'] = $info['email'];
|
170 |
self::update($this->settings, $accounts);
|
@@ -180,6 +219,28 @@ if (!class_exists('MCAccount')) :
|
|
180 |
return false;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
public static function exists($settings, $pubkey) {
|
184 |
$accounts = self::allAccounts($settings);
|
185 |
return array_key_exists($pubkey, $accounts);
|
84 |
return $accountsByPlugname;
|
85 |
}
|
86 |
|
87 |
+
public static function accountsByType($settings, $account_type) {
|
88 |
+
$accounts = self::allAccounts($settings);
|
89 |
+
$accounts_by_type = array();
|
90 |
+
foreach ($accounts as $pubkey => $value) {
|
91 |
+
if (array_key_exists('account_type', $value) && $value['account_type'] === $account_type) {
|
92 |
+
$accounts_by_type[$pubkey] = $value;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
return $accounts_by_type;
|
96 |
+
}
|
97 |
+
|
98 |
+
public static function accountsByGid($settings, $account_gid) {
|
99 |
+
$accounts = self::allAccounts($settings);
|
100 |
+
$accounts_by_gid = array();
|
101 |
+
foreach ($accounts as $pubkey => $value) {
|
102 |
+
if (array_key_exists('account_gid', $value) && $value['account_gid'] === $account_gid) {
|
103 |
+
$accounts_by_gid[$pubkey] = $value;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
return $accounts_by_gid;
|
107 |
+
}
|
108 |
+
|
109 |
+
public static function accountsByPattern($settings, $search_key, $search_pattern) {
|
110 |
+
$accounts = self::allAccounts($settings);
|
111 |
+
$accounts_by_pattern = array();
|
112 |
+
foreach ($accounts as $pubkey => $value) {
|
113 |
+
if (array_key_exists($search_key, $value) && preg_match($search_pattern, $value[$search_key]) == 1) {
|
114 |
+
$accounts_by_pattern[$pubkey] = $value;
|
115 |
+
}
|
116 |
+
}
|
117 |
+
return $accounts_by_pattern;
|
118 |
+
}
|
119 |
+
|
120 |
public static function isConfigured($settings) {
|
121 |
$accounts = self::accountsByPlugname($settings);
|
122 |
return (sizeof($accounts) >= 1);
|
188 |
$this->settings->updateOption('bvLastRecvTime', $time);
|
189 |
return 1;
|
190 |
}
|
191 |
+
|
192 |
public function updateInfo($info) {
|
193 |
$accounts = self::allAccounts($this->settings);
|
194 |
+
$plugname = $info["plugname"];
|
195 |
+
$account_type = $info["account_type"];
|
196 |
$pubkey = $info['pubkey'];
|
197 |
if (!array_key_exists($pubkey, $accounts)) {
|
198 |
$accounts[$pubkey] = array();
|
199 |
}
|
200 |
+
if (array_key_exists('secret', $info)) {
|
201 |
+
$accounts[$pubkey]['secret'] = $info['secret'];
|
202 |
+
}
|
203 |
+
$accounts[$pubkey]['account_gid'] = $info['account_gid'];
|
204 |
$accounts[$pubkey]['lastbackuptime'] = time();
|
205 |
$accounts[$pubkey][$plugname] = true;
|
206 |
+
$accounts[$pubkey]['account_type'] = $account_type;
|
207 |
$accounts[$pubkey]['url'] = $info['url'];
|
208 |
$accounts[$pubkey]['email'] = $info['email'];
|
209 |
self::update($this->settings, $accounts);
|
219 |
return false;
|
220 |
}
|
221 |
|
222 |
+
public static function removeByAccountType($settings, $account_type) {
|
223 |
+
$accounts = MCAccount::accountsByType($settings, $account_type);
|
224 |
+
if (sizeof($accounts) >= 1) {
|
225 |
+
foreach ($accounts as $pubkey => $value) {
|
226 |
+
MCAccount::remove($settings, $pubkey);
|
227 |
+
}
|
228 |
+
return true;
|
229 |
+
}
|
230 |
+
return false;
|
231 |
+
}
|
232 |
+
|
233 |
+
public static function removeByAccountGid($settings, $account_gid) {
|
234 |
+
$accounts = MCAccount::accountsByGid($settings, $account_gid);
|
235 |
+
if (sizeof($accounts) >= 1) {
|
236 |
+
foreach ($accounts as $pubkey => $value) {
|
237 |
+
MCAccount::remove($settings, $pubkey);
|
238 |
+
}
|
239 |
+
return true;
|
240 |
+
}
|
241 |
+
return false;
|
242 |
+
}
|
243 |
+
|
244 |
public static function exists($settings, $pubkey) {
|
245 |
$accounts = self::allAccounts($settings);
|
246 |
return array_key_exists($pubkey, $accounts);
|
callback/wings/account.php
CHANGED
@@ -24,19 +24,15 @@ class BVAccountCallback extends BVCallbackBase {
|
|
24 |
$resp = array("status" => MCAccount::remove($this->settings, $params['public']));
|
25 |
break;
|
26 |
case "updt":
|
27 |
-
$
|
28 |
-
$info['email'] = $params['email'];
|
29 |
-
$info['url'] = $params['url'];
|
30 |
-
$info['pubkey'] = $params['pubkey'];
|
31 |
-
$account->updateInfo($info);
|
32 |
$resp = array("status" => MCAccount::exists($this->settings, $params['pubkey']));
|
33 |
break;
|
34 |
case "updtapikey":
|
35 |
MCAccount::updateApiPublicKey($this->settings, $params['pubkey']);
|
36 |
$resp = array("status" => $this->settings->getOption(MCAccount::$api_public_key));
|
37 |
break;
|
38 |
-
case "
|
39 |
-
$resp = array("status" => $settings->deleteOption('
|
40 |
break;
|
41 |
case "rmbvkeys":
|
42 |
$resp = array("status" => $settings->deleteOption('bvKeys'));
|
24 |
$resp = array("status" => MCAccount::remove($this->settings, $params['public']));
|
25 |
break;
|
26 |
case "updt":
|
27 |
+
$account->updateInfo($params);
|
|
|
|
|
|
|
|
|
28 |
$resp = array("status" => MCAccount::exists($this->settings, $params['pubkey']));
|
29 |
break;
|
30 |
case "updtapikey":
|
31 |
MCAccount::updateApiPublicKey($this->settings, $params['pubkey']);
|
32 |
$resp = array("status" => $this->settings->getOption(MCAccount::$api_public_key));
|
33 |
break;
|
34 |
+
case "rmbvscrt":
|
35 |
+
$resp = array("status" => $settings->deleteOption('bvSecretKey'));
|
36 |
break;
|
37 |
case "rmbvkeys":
|
38 |
$resp = array("status" => $settings->deleteOption('bvKeys'));
|
callback/wings/db.php
CHANGED
@@ -69,7 +69,7 @@ class BVDBCallback extends BVCallbackBase {
|
|
69 |
$params = $request->params;
|
70 |
$stream_init_info = BVStream::startStream($this->account, $request);
|
71 |
|
72 |
-
if(
|
73 |
$bv_table = $params['table'];
|
74 |
if (!empty($bv_table)) {
|
75 |
$allowed = false;
|
69 |
$params = $request->params;
|
70 |
$stream_init_info = BVStream::startStream($this->account, $request);
|
71 |
|
72 |
+
if($this->bvinfo->canSetCWBranding()) {
|
73 |
$bv_table = $params['table'];
|
74 |
if (!empty($bv_table)) {
|
75 |
$allowed = false;
|
callback/wings/fs.php
CHANGED
@@ -12,6 +12,7 @@ class BVFSCallback extends BVCallbackBase {
|
|
12 |
|
13 |
public function __construct($callback_handler) {
|
14 |
$this->account = $callback_handler->account;
|
|
|
15 |
}
|
16 |
|
17 |
function fileStat($relfile, $md5 = false) {
|
@@ -26,7 +27,7 @@ class BVFSCallback extends BVCallbackBase {
|
|
26 |
if (is_link($absfile)) {
|
27 |
$fdata["link"] = @readlink($absfile);
|
28 |
}
|
29 |
-
if ($md5 === true) {
|
30 |
$fdata["md5"] = $this->calculateMd5($absfile, array(), 0, 0, 0);
|
31 |
}
|
32 |
} else {
|
@@ -196,7 +197,7 @@ class BVFSCallback extends BVCallbackBase {
|
|
196 |
$result["missingfiles"][] = $file;
|
197 |
continue;
|
198 |
}
|
199 |
-
if ($md5 === true) {
|
200 |
$fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize);
|
201 |
}
|
202 |
$result["stats"][] = $fdata;
|
@@ -245,8 +246,23 @@ class BVFSCallback extends BVCallbackBase {
|
|
245 |
function process($request) {
|
246 |
$params = $request->params;
|
247 |
$stream_init_info = BVStream::startStream($this->account, $request);
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
|
251 |
if (array_key_exists('stream', $stream_init_info)) {
|
252 |
$this->stream = $stream_init_info['stream'];
|
12 |
|
13 |
public function __construct($callback_handler) {
|
14 |
$this->account = $callback_handler->account;
|
15 |
+
$this->bvinfo = $callback_handler->bvinfo;
|
16 |
}
|
17 |
|
18 |
function fileStat($relfile, $md5 = false) {
|
27 |
if (is_link($absfile)) {
|
28 |
$fdata["link"] = @readlink($absfile);
|
29 |
}
|
30 |
+
if ($md5 === true && !is_dir($absfile)) {
|
31 |
$fdata["md5"] = $this->calculateMd5($absfile, array(), 0, 0, 0);
|
32 |
}
|
33 |
} else {
|
197 |
$result["missingfiles"][] = $file;
|
198 |
continue;
|
199 |
}
|
200 |
+
if ($md5 === true && !is_dir($absfile)) {
|
201 |
$fdata["md5"] = $this->calculateMd5($absfile, $fdata, $offset, $limit, $bsize);
|
202 |
}
|
203 |
$result["stats"][] = $fdata;
|
246 |
function process($request) {
|
247 |
$params = $request->params;
|
248 |
$stream_init_info = BVStream::startStream($this->account, $request);
|
249 |
+
|
250 |
+
if($this->bvinfo->canSetCWBranding()) {
|
251 |
+
if(array_key_exists('initdir', $params)) {
|
252 |
+
return $stream_init_info;
|
253 |
+
}
|
254 |
+
|
255 |
+
if (array_key_exists('files', $params)) {
|
256 |
+
$files = $params['files'];
|
257 |
+
|
258 |
+
foreach($files as $file) {
|
259 |
+
if (!in_array($file, BVFSCallback::$cwAllowedFiles)) {
|
260 |
+
return $stream_init_info;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
}
|
264 |
+
}
|
265 |
+
|
266 |
|
267 |
if (array_key_exists('stream', $stream_init_info)) {
|
268 |
$this->stream = $stream_init_info['stream'];
|
callback/wings/misc.php
CHANGED
@@ -94,8 +94,8 @@ class BVMiscCallback extends BVCallbackBase {
|
|
94 |
case "dlttrsnt":
|
95 |
$resp = array("dlttrsnt" => $settings->deleteTransient($params['key']));
|
96 |
break;
|
97 |
-
case "
|
98 |
-
$resp = array("
|
99 |
break;
|
100 |
default:
|
101 |
$resp = false;
|
94 |
case "dlttrsnt":
|
95 |
$resp = array("dlttrsnt" => $settings->deleteTransient($params['key']));
|
96 |
break;
|
97 |
+
case "setbvss":
|
98 |
+
$resp = array("status" => $settings->updateOption('bv_site_settings', $params['bv_site_settings']));
|
99 |
break;
|
100 |
default:
|
101 |
$resp = false;
|
info.php
CHANGED
@@ -9,7 +9,7 @@ if (!class_exists('MCInfo')) :
|
|
9 |
public $badgeinfo = 'mcbadge';
|
10 |
public $ip_header_option = 'mcipheader';
|
11 |
public $brand_option = 'mcbrand';
|
12 |
-
public $version = '4.
|
13 |
public $webpage = 'https://www.malcare.com';
|
14 |
public $appurl = 'https://app.malcare.com';
|
15 |
public $slug = 'malcare-security/malcare.php';
|
@@ -21,9 +21,19 @@ if (!class_exists('MCInfo')) :
|
|
21 |
$this->settings = $settings;
|
22 |
}
|
23 |
|
24 |
-
public function
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
public function getBrandInfo() {
|
@@ -36,7 +46,7 @@ if (!class_exists('MCInfo')) :
|
|
36 |
return $brand['menuname'];
|
37 |
}
|
38 |
$bvinfo = new MCInfo($this->settings);
|
39 |
-
if (
|
40 |
return "Cloudways";
|
41 |
}
|
42 |
|
9 |
public $badgeinfo = 'mcbadge';
|
10 |
public $ip_header_option = 'mcipheader';
|
11 |
public $brand_option = 'mcbrand';
|
12 |
+
public $version = '4.4';
|
13 |
public $webpage = 'https://www.malcare.com';
|
14 |
public $appurl = 'https://app.malcare.com';
|
15 |
public $slug = 'malcare-security/malcare.php';
|
21 |
$this->settings = $settings;
|
22 |
}
|
23 |
|
24 |
+
public function canSetCWBranding() {
|
25 |
+
if (MCWPSiteInfo::isCWServer()) {
|
26 |
+
|
27 |
+
$bot_protect_accounts = MCAccount::accountsByType($this->settings, 'botprotect');
|
28 |
+
if (sizeof($bot_protect_accounts) >= 1)
|
29 |
+
return true;
|
30 |
+
|
31 |
+
$bot_protect_accounts = MCAccount::accountsByPattern($this->settings, 'email', '/@cw_user\.com$/');
|
32 |
+
if (sizeof($bot_protect_accounts) >= 1)
|
33 |
+
return true;
|
34 |
+
}
|
35 |
+
|
36 |
+
return false;
|
37 |
}
|
38 |
|
39 |
public function getBrandInfo() {
|
46 |
return $brand['menuname'];
|
47 |
}
|
48 |
$bvinfo = new MCInfo($this->settings);
|
49 |
+
if ($bvinfo->canSetCWBranding()) {
|
50 |
return "Cloudways";
|
51 |
}
|
52 |
|
malcare.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.malcare.com
|
|
5 |
Description: MalCare Security - Free Malware Scanner, Protection & Security for WordPress
|
6 |
Author: MalCare Security
|
7 |
Author URI: https://www.malcare.com
|
8 |
-
Version: 4.
|
9 |
Network: True
|
10 |
*/
|
11 |
|
@@ -74,6 +74,7 @@ if (is_admin()) {
|
|
74 |
add_action('admin_head', array($wpadmin, 'removeAdminNotices'), 3);
|
75 |
add_action('admin_notices', array($wpadmin, 'activateWarning'));
|
76 |
add_action('admin_enqueue_scripts', array($wpadmin, 'mcsecAdminMenu'));
|
|
|
77 |
}
|
78 |
|
79 |
|
@@ -142,4 +143,5 @@ if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "
|
|
142 |
}
|
143 |
|
144 |
##DYNSYNCMODULE##
|
|
|
145 |
}
|
5 |
Description: MalCare Security - Free Malware Scanner, Protection & Security for WordPress
|
6 |
Author: MalCare Security
|
7 |
Author URI: https://www.malcare.com
|
8 |
+
Version: 4.4
|
9 |
Network: True
|
10 |
*/
|
11 |
|
74 |
add_action('admin_head', array($wpadmin, 'removeAdminNotices'), 3);
|
75 |
add_action('admin_notices', array($wpadmin, 'activateWarning'));
|
76 |
add_action('admin_enqueue_scripts', array($wpadmin, 'mcsecAdminMenu'));
|
77 |
+
add_action('plugin_action_links', array($wpadmin, 'disableDeactivation'), 10, 2);
|
78 |
}
|
79 |
|
80 |
|
143 |
}
|
144 |
|
145 |
##DYNSYNCMODULE##
|
146 |
+
##WPAUTOUPDATEBLOCKMODULE##
|
147 |
}
|
readme.txt
CHANGED
@@ -4,9 +4,9 @@ Tags: security, wordpress security, security plugin, firewall, malware scanner,
|
|
4 |
Plugin URI: https://www.malcare.com
|
5 |
Donate link: https://www.malcare.com
|
6 |
Requires at least: 4.0
|
7 |
-
Tested up to: 5.
|
8 |
Requires PHP: 5.4.0
|
9 |
-
Stable tag: 4.
|
10 |
License: GPLv2 or later
|
11 |
License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
|
12 |
|
@@ -180,6 +180,10 @@ MalCare is perfect for:
|
|
180 |
|
181 |
== Detailed Setup Step-by-Step Tutorials ==
|
182 |
|
|
|
|
|
|
|
|
|
183 |
* [How to Set Up a MalCare Account?](https://malcare.freshdesk.com/support/solutions/articles/35000055512-how-do-i-set-up-a-malcare-account-) (Help Doc)
|
184 |
* [How to Set Up a MalCare Account?](https://www.youtube.com/watch?v=v8L_DZllk7k&list=) (Video)
|
185 |
|
@@ -378,6 +382,9 @@ MalCare runs on its own servers. We take great care to ensure that we do not add
|
|
378 |
=Where are my FTP details processed?=
|
379 |
FTP details input into MalCare is processed on our servers. We need your FTP credentials to access your website’s files and folders. We feel that FTP transfer is the safest way to transfer data to and from a site. However, they are treated like payment details (i.e. they’re not stored on our servers). Once we’ve processed them, they’re deleted from our servers.
|
380 |
|
|
|
|
|
|
|
381 |
== SCREENSHOTS ==
|
382 |
|
383 |
1. It’s extremely easy to add a website to MalCare’s dashboard. All you need to do is add a URL and install the plugin on your website.
|
@@ -390,8 +397,10 @@ FTP details input into MalCare is processed on our servers. We need your FTP cre
|
|
390 |
8. MalCare’s Uptime Monitoring notifies if a website goes down so that you can handle the situation before starting to lose visitors.
|
391 |
|
392 |
== CHANGELOG ==
|
393 |
-
= 4.
|
394 |
-
*
|
|
|
|
|
395 |
|
396 |
= 4.33 =
|
397 |
* Hiding bot protection dashboard from wp-admin
|
4 |
Plugin URI: https://www.malcare.com
|
5 |
Donate link: https://www.malcare.com
|
6 |
Requires at least: 4.0
|
7 |
+
Tested up to: 5.6
|
8 |
Requires PHP: 5.4.0
|
9 |
+
Stable tag: 4.4
|
10 |
License: GPLv2 or later
|
11 |
License URI: [http://www.gnu.org/licenses/gpl-2.0.html](http://www.gnu.org/licenses/gpl-2.0.html)
|
12 |
|
180 |
|
181 |
== Detailed Setup Step-by-Step Tutorials ==
|
182 |
|
183 |
+
This plugin works in tandem with the [MalCare](https://www.malcare.com) servers. MalCare servers do all the heavy processing and will alert you if your site has any issues.
|
184 |
+
|
185 |
+
Hence a MalCare account is needed to use the plugin. This account can also be used by our other products including [BlogVault](https://blogvault.net).
|
186 |
+
|
187 |
* [How to Set Up a MalCare Account?](https://malcare.freshdesk.com/support/solutions/articles/35000055512-how-do-i-set-up-a-malcare-account-) (Help Doc)
|
188 |
* [How to Set Up a MalCare Account?](https://www.youtube.com/watch?v=v8L_DZllk7k&list=) (Video)
|
189 |
|
382 |
=Where are my FTP details processed?=
|
383 |
FTP details input into MalCare is processed on our servers. We need your FTP credentials to access your website’s files and folders. We feel that FTP transfer is the safest way to transfer data to and from a site. However, they are treated like payment details (i.e. they’re not stored on our servers). Once we’ve processed them, they’re deleted from our servers.
|
384 |
|
385 |
+
=Where can I find the MalCare Terms of Use and Privacy Policy?=
|
386 |
+
These are available on our website: [Terms of Service](https://www.malcare.com/tos/) and [Privacy Policy](https://www.malcare.com/privacy/)
|
387 |
+
|
388 |
== SCREENSHOTS ==
|
389 |
|
390 |
1. It’s extremely easy to add a website to MalCare’s dashboard. All you need to do is add a URL and install the plugin on your website.
|
397 |
8. MalCare’s Uptime Monitoring notifies if a website goes down so that you can handle the situation before starting to lose visitors.
|
398 |
|
399 |
== CHANGELOG ==
|
400 |
+
= 4.4 =
|
401 |
+
* Disabling deactivate for botprotection accounts
|
402 |
+
* Disconnect functionality through wpcli with params account_gid and account_type
|
403 |
+
* Removed manual signup logic
|
404 |
|
405 |
= 4.33 =
|
406 |
* Hiding bot protection dashboard from wp-admin
|
wp_admin.php
CHANGED
@@ -31,6 +31,15 @@ class MCWPAdmin {
|
|
31 |
}
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
public function cwBrandInfo() {
|
35 |
return array(
|
36 |
'name' => "Bot Protection",
|
@@ -67,7 +76,6 @@ class MCWPAdmin {
|
|
67 |
}
|
68 |
if ($this->bvinfo->isActivateRedirectSet()) {
|
69 |
$this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
|
70 |
-
$this->settings->updateOption('bvmanualsignup', true);
|
71 |
wp_redirect($this->mainUrl());
|
72 |
}
|
73 |
}
|
@@ -105,7 +113,7 @@ class MCWPAdmin {
|
|
105 |
add_submenu_page(null, 'Malcare', 'Malcare', 'manage_options', 'bv_account_details',
|
106 |
array($this, 'showAccountDetailsPage'));
|
107 |
|
108 |
-
if (
|
109 |
$bname = $this->bvinfo->getBrandName();
|
110 |
$icon = $this->bvinfo->getBrandIcon();
|
111 |
|
@@ -137,7 +145,7 @@ class MCWPAdmin {
|
|
137 |
public function settingsLink($links, $file) {
|
138 |
#XNOTE: Fix this
|
139 |
if ( $file == plugin_basename( dirname(__FILE__).'/malcare.php' ) ) {
|
140 |
-
if (
|
141 |
$settings_link = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
|
142 |
array_unshift($links, $settings_link);
|
143 |
$account_details = '<a href="'.$this->mainUrl('&account_details=true').'">'.__( 'Account Details' ).'</a>';
|
@@ -188,7 +196,6 @@ class MCWPAdmin {
|
|
188 |
}
|
189 |
|
190 |
public function showAddAccountPage() {
|
191 |
-
$this->settings->updateOption('bvmanualsignup', true);
|
192 |
$this->enqueueBootstrapCSS();
|
193 |
require_once dirname( __FILE__ ) . "/admin/registration.php";
|
194 |
}
|
@@ -227,7 +234,7 @@ class MCWPAdmin {
|
|
227 |
return $plugins;
|
228 |
}
|
229 |
|
230 |
-
if (
|
231 |
$brand = $this->cwBrandInfo();
|
232 |
if (array_key_exists('name', $brand)) {
|
233 |
$plugins[$slug]['Name'] = $brand['name'];
|
31 |
}
|
32 |
}
|
33 |
|
34 |
+
public function disableDeactivation($actions, $plugin_file) {
|
35 |
+
if ($this->bvinfo->canSetCWBranding()) {
|
36 |
+
if ( $this->bvinfo->slug === $plugin_file ) {
|
37 |
+
unset( $actions['deactivate'] );
|
38 |
+
}
|
39 |
+
}
|
40 |
+
return $actions;
|
41 |
+
}
|
42 |
+
|
43 |
public function cwBrandInfo() {
|
44 |
return array(
|
45 |
'name' => "Bot Protection",
|
76 |
}
|
77 |
if ($this->bvinfo->isActivateRedirectSet()) {
|
78 |
$this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
|
|
|
79 |
wp_redirect($this->mainUrl());
|
80 |
}
|
81 |
}
|
113 |
add_submenu_page(null, 'Malcare', 'Malcare', 'manage_options', 'bv_account_details',
|
114 |
array($this, 'showAccountDetailsPage'));
|
115 |
|
116 |
+
if (!$this->bvinfo->canSetCWBranding()) {
|
117 |
$bname = $this->bvinfo->getBrandName();
|
118 |
$icon = $this->bvinfo->getBrandIcon();
|
119 |
|
145 |
public function settingsLink($links, $file) {
|
146 |
#XNOTE: Fix this
|
147 |
if ( $file == plugin_basename( dirname(__FILE__).'/malcare.php' ) ) {
|
148 |
+
if (!$this->bvinfo->canSetCWBranding()) {
|
149 |
$settings_link = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
|
150 |
array_unshift($links, $settings_link);
|
151 |
$account_details = '<a href="'.$this->mainUrl('&account_details=true').'">'.__( 'Account Details' ).'</a>';
|
196 |
}
|
197 |
|
198 |
public function showAddAccountPage() {
|
|
|
199 |
$this->enqueueBootstrapCSS();
|
200 |
require_once dirname( __FILE__ ) . "/admin/registration.php";
|
201 |
}
|
234 |
return $plugins;
|
235 |
}
|
236 |
|
237 |
+
if ($this->bvinfo->canSetCWBranding()) {
|
238 |
$brand = $this->cwBrandInfo();
|
239 |
if (array_key_exists('name', $brand)) {
|
240 |
$plugins[$slug]['Name'] = $brand['name'];
|
wp_cli.php
CHANGED
@@ -29,7 +29,12 @@ class MCWPCli {
|
|
29 |
$headers = array(
|
30 |
'Authorization' => "BVAPI-HMAC {$params['account_public']}:{$params['sig']}:{$params['timestamp']}"
|
31 |
);
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
public function setkeys($args, $params) {
|
@@ -55,7 +60,8 @@ class MCWPCli {
|
|
55 |
if (!$account) {
|
56 |
WP_CLI::error('Account not found');
|
57 |
}
|
58 |
-
$this->request($account->authenticatedUrl('/bvapi/disable_fw'));
|
|
|
59 |
}
|
60 |
|
61 |
public function enable_fw($args, $params) {
|
@@ -63,29 +69,46 @@ class MCWPCli {
|
|
63 |
if (!$account) {
|
64 |
WP_CLI::error('Account not found.');
|
65 |
}
|
66 |
-
$this->request($account->authenticatedUrl('/bvapi/enable_fw'));
|
|
|
67 |
}
|
68 |
|
69 |
public function disconnect($args, $params) {
|
|
|
70 |
if (isset($params['public_key'])) {
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
WP_CLI::error('No Account with provided public key exists.');
|
77 |
-
}
|
78 |
-
} else {
|
79 |
-
WP_CLI::error('Invalid Public Key.');
|
80 |
-
}
|
81 |
} else {
|
82 |
-
WP_CLI::error('Please
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
}
|
84 |
}
|
85 |
|
86 |
private function request($url, $request_params = array(), $headers = array()) {
|
87 |
$resp = $this->bvapi->http_request($url, $request_params, $headers);
|
88 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
|
91 |
private function handle_response($resp) {
|
29 |
$headers = array(
|
30 |
'Authorization' => "BVAPI-HMAC {$params['account_public']}:{$params['sig']}:{$params['timestamp']}"
|
31 |
);
|
32 |
+
|
33 |
+
$resp = $this->request($url, $request_params, $headers);
|
34 |
+
|
35 |
+
$this->updateAccountInfo($resp);
|
36 |
+
|
37 |
+
$this->handle_response($resp);
|
38 |
}
|
39 |
|
40 |
public function setkeys($args, $params) {
|
60 |
if (!$account) {
|
61 |
WP_CLI::error('Account not found');
|
62 |
}
|
63 |
+
$resp = $this->request($account->authenticatedUrl('/bvapi/disable_fw'));
|
64 |
+
$this->handle_response($resp);
|
65 |
}
|
66 |
|
67 |
public function enable_fw($args, $params) {
|
69 |
if (!$account) {
|
70 |
WP_CLI::error('Account not found.');
|
71 |
}
|
72 |
+
$resp = $this->request($account->authenticatedUrl('/bvapi/enable_fw'));
|
73 |
+
$this->handle_response($resp);
|
74 |
}
|
75 |
|
76 |
public function disconnect($args, $params) {
|
77 |
+
$status = false;
|
78 |
if (isset($params['public_key'])) {
|
79 |
+
$status = MCAccount::remove($this->settings, $params['public_key']);
|
80 |
+
} else if(isset($params['account_type'])) {
|
81 |
+
$status = MCAccount::removeByAccountType($this->settings, $params['account_type']);
|
82 |
+
} else if(isset($params['account_gid'])) {
|
83 |
+
$status = MCAccount::removeByAccountGid($this->settings, $params['account_gid']);
|
|
|
|
|
|
|
|
|
|
|
84 |
} else {
|
85 |
+
WP_CLI::error('Input Params are incorrect. Please validate the params.');
|
86 |
+
}
|
87 |
+
|
88 |
+
if ($status) {
|
89 |
+
WP_CLI::success('Account removed successfully.');
|
90 |
+
} else {
|
91 |
+
WP_CLI::error('No Account exists.');
|
92 |
}
|
93 |
}
|
94 |
|
95 |
private function request($url, $request_params = array(), $headers = array()) {
|
96 |
$resp = $this->bvapi->http_request($url, $request_params, $headers);
|
97 |
+
return $resp;
|
98 |
+
}
|
99 |
+
|
100 |
+
private function updateAccountInfo($resp) {
|
101 |
+
if(isset($resp["response"]) && isset($resp["response"]["code"]) && ($resp["response"]["code"] == 200)) {
|
102 |
+
if (isset($resp["body"])) {
|
103 |
+
$body = json_decode($resp["body"], true);
|
104 |
+
if (isset($body["account_info"])) {
|
105 |
+
$info = $body["account_info"];
|
106 |
+
MCAccount::addAccount($this->settings, $info['pubkey'], $info['secret']);
|
107 |
+
$account = MCAccount::find($this->settings, $info['pubkey']);
|
108 |
+
$account->updateInfo($info);
|
109 |
+
}
|
110 |
+
}
|
111 |
+
}
|
112 |
}
|
113 |
|
114 |
private function handle_response($resp) {
|