MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall - Version 4.83

Version Description

  • Geo-blocking with advanced firewall
  • Activity log improvements and bug fixes
  • Woocommerce custom table support for real-time backups
Download this release

Release Info

Developer ritesh.soni36
Plugin Icon 128x128 MalCare WordPress Security Plugin – Malware Scanner, Cleaner, Security Firewall
Version 4.83
Comparing to
See all releases

Code changes from version 4.82 to 4.83

callback/base.php CHANGED
@@ -15,7 +15,7 @@ class BVCallbackBase {
15
  "MISC_WING_VERSION" => '1.2',
16
  "FS_WING_VERSION" => '1.2',
17
  "INFO_WING_VERSION" => '1.5',
18
- "WATCH_WING_VERSION" => '1.0',
19
  "FS_WRITE_WING_VERSION" => '1.0',
20
  "IPSTORE_WING_VERSION" => '1.0',
21
  "PROTECT_WING_VERSION" => '1.0',
15
  "MISC_WING_VERSION" => '1.2',
16
  "FS_WING_VERSION" => '1.2',
17
  "INFO_WING_VERSION" => '1.5',
18
+ "WATCH_WING_VERSION" => '1.1',
19
  "FS_WRITE_WING_VERSION" => '1.0',
20
  "IPSTORE_WING_VERSION" => '1.0',
21
  "PROTECT_WING_VERSION" => '1.0',
callback/wings/manage.php CHANGED
@@ -40,6 +40,8 @@ class BVManageCallback extends BVCallbackBase {
40
  @include_once ABSPATH.'wp-admin/includes/template.php';
41
  @include_once ABSPATH.'wp-includes/pluggable.php';
42
  @include_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
 
 
43
  @include_once ABSPATH.'wp-admin/includes/user.php';
44
  @include_once ABSPATH.'wp-includes/registration.php';
45
  @include_once ABSPATH.'wp-admin/includes/upgrade.php';
@@ -400,7 +402,7 @@ class BVManageCallback extends BVCallbackBase {
400
  if (!array_key_exists('plugins', $result))
401
  $result["plugins"] = array();
402
  $plugin['dest'] = WP_PLUGIN_DIR;
403
- $res = $this->installPackage($plugin, $has_bv_skin);
404
  $pluginName = $plugin['package'];
405
  $result["plugins"][$pluginName] = $res;
406
  }
@@ -410,7 +412,7 @@ class BVManageCallback extends BVCallbackBase {
410
  if (!array_key_exists('themes', $result))
411
  $result["themes"] = array();
412
  $theme['dest'] = WP_CONTENT_DIR.'/themes';
413
- $res = $this->installPackage($theme, $has_bv_skin);
414
  $themeName = $theme['package'];
415
  $result["themes"][$themeName] = $res;
416
  }
@@ -418,7 +420,7 @@ class BVManageCallback extends BVCallbackBase {
418
  return $result;
419
  }
420
 
421
- function installPackage($params, $has_bv_skin = false) {
422
  global $wp_filesystem;
423
 
424
  if (!isset($params['package']) || empty($params['package'])) {
@@ -435,21 +437,32 @@ class BVManageCallback extends BVCallbackBase {
435
  } else {
436
  $skin = new WP_Upgrader_Skin();
437
  }
438
- $upgrader = new WP_Upgrader($skin);
 
 
 
 
 
 
439
  $upgrader->init();
440
  $destination = $params['dest'];
441
  $clear_destination = isset($params['cleardest']) ? $params['cleardest'] : false;
442
  $package_url = $params['package'];
443
  $key = basename($package_url);
 
444
  $res = $upgrader->run(
445
  array(
446
  'package' => $package_url,
447
  'destination' => $destination,
448
  'clear_destination' => $clear_destination,
449
  'clear_working' => true,
450
- 'hook_extra' => array(),
 
 
 
451
  )
452
  );
 
453
  if (is_wp_error($res)) {
454
  $res = array('status' => "Error", 'message' => $this->getError($res));
455
  } else {
40
  @include_once ABSPATH.'wp-admin/includes/template.php';
41
  @include_once ABSPATH.'wp-includes/pluggable.php';
42
  @include_once ABSPATH.'wp-admin/includes/class-wp-upgrader.php';
43
+ @include_once ABSPATH.'wp-admin/includes/class-theme-upgrader.php';
44
+ @include_once ABSPATH.'wp-admin/includes/class-plugin-upgrader.php';
45
  @include_once ABSPATH.'wp-admin/includes/user.php';
46
  @include_once ABSPATH.'wp-includes/registration.php';
47
  @include_once ABSPATH.'wp-admin/includes/upgrade.php';
402
  if (!array_key_exists('plugins', $result))
403
  $result["plugins"] = array();
404
  $plugin['dest'] = WP_PLUGIN_DIR;
405
+ $res = $this->installPackage("plugin", $plugin, $has_bv_skin);
406
  $pluginName = $plugin['package'];
407
  $result["plugins"][$pluginName] = $res;
408
  }
412
  if (!array_key_exists('themes', $result))
413
  $result["themes"] = array();
414
  $theme['dest'] = WP_CONTENT_DIR.'/themes';
415
+ $res = $this->installPackage("theme", $theme, $has_bv_skin);
416
  $themeName = $theme['package'];
417
  $result["themes"][$themeName] = $res;
418
  }
420
  return $result;
421
  }
422
 
423
+ function installPackage($type, $params, $has_bv_skin = false) {
424
  global $wp_filesystem;
425
 
426
  if (!isset($params['package']) || empty($params['package'])) {
437
  } else {
438
  $skin = new WP_Upgrader_Skin();
439
  }
440
+ if ("plugin" === $type) {
441
+ $upgrader = new Plugin_Upgrader($skin);
442
+ } elseif ("theme" === $type) {
443
+ $upgrader = new Theme_Upgrader($skin);
444
+ } else {
445
+ $upgrader = new WP_Upgrader($skin);
446
+ }
447
  $upgrader->init();
448
  $destination = $params['dest'];
449
  $clear_destination = isset($params['cleardest']) ? $params['cleardest'] : false;
450
  $package_url = $params['package'];
451
  $key = basename($package_url);
452
+ add_filter('upgrader_source_selection', array($upgrader, 'check_package'));
453
  $res = $upgrader->run(
454
  array(
455
  'package' => $package_url,
456
  'destination' => $destination,
457
  'clear_destination' => $clear_destination,
458
  'clear_working' => true,
459
+ 'hook_extra' => array(
460
+ "type" => $type,
461
+ "action" => "install"
462
+ ),
463
  )
464
  );
465
+ remove_filter('upgrader_source_selection', array($upgrader, 'check_package'));
466
  if (is_wp_error($res)) {
467
  $res = array('status' => "Error", 'message' => $this->getError($res));
468
  } else {
callback/wings/watch.php CHANGED
@@ -7,7 +7,7 @@ class BVWatchCallback extends BVCallbackBase {
7
  public $db;
8
  public $settings;
9
 
10
- const WATCH_WING_VERSION = 1.0;
11
 
12
  public function __construct($callback_handler) {
13
  $this->db = $callback_handler->db;
@@ -155,6 +155,19 @@ class BVWatchCallback extends BVCallbackBase {
155
  }
156
  }
157
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  $resp["status"] = "done";
159
  break;
160
  case "rmdata":
7
  public $db;
8
  public $settings;
9
 
10
+ const WATCH_WING_VERSION = 1.1;
11
 
12
  public function __construct($callback_handler) {
13
  $this->db = $callback_handler->db;
155
  }
156
  }
157
 
158
+ if (array_key_exists('airlift_stats', $params)) {
159
+ $airlift_stats_table = "airlift_stats";
160
+ $airlift_stats_params = $params['airlift_stats'];
161
+ $table = $db->getBVTable($airlift_stats_table);
162
+ if (!isset($airlift_stats_params['bv_check_table']) || $db->isTablePresent($table)) {
163
+ $limit = intval(urldecode($airlift_stats_params['limit']));
164
+ $filter = urldecode($airlift_stats_params['filter']);
165
+ $db->deleteBVTableContent($airlift_stats_table, $airlift_stats_params['rmfilter']);
166
+ $resp["airlift_stats"] = $this->getData($table, $limit, $filter);
167
+ } else {
168
+ $resp["airlift_stats"] = array("status" => "TABLE_NOT_PRESENT");
169
+ }
170
+ }
171
  $resp["status"] = "done";
172
  break;
173
  case "rmdata":
info.php CHANGED
@@ -10,7 +10,7 @@ if (!class_exists('MCInfo')) :
10
  public $badgeinfo = 'mcbadge';
11
  public $ip_header_option = 'mcipheader';
12
  public $brand_option = 'mcbrand';
13
- public $version = '4.82';
14
  public $webpage = 'https://www.malcare.com';
15
  public $appurl = 'https://app.malcare.com';
16
  public $slug = 'malcare-security/malcare.php';
@@ -109,11 +109,16 @@ if ($bvinfo->canSetCWBranding()) {
109
 
110
  public function isValidEnvironment(){
111
  $bvsiteinfo = new MCWPSiteInfo();
112
- $siteurl = $bvsiteinfo->siteurl();
113
  $bvconfig = $this->config;
114
- if ($bvconfig && array_key_exists("abspath", $bvconfig) &&
115
- array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) {
116
- return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl);
 
 
 
 
 
 
117
  }
118
  return true;
119
  }
10
  public $badgeinfo = 'mcbadge';
11
  public $ip_header_option = 'mcipheader';
12
  public $brand_option = 'mcbrand';
13
+ public $version = '4.83';
14
  public $webpage = 'https://www.malcare.com';
15
  public $appurl = 'https://app.malcare.com';
16
  public $slug = 'malcare-security/malcare.php';
109
 
110
  public function isValidEnvironment(){
111
  $bvsiteinfo = new MCWPSiteInfo();
 
112
  $bvconfig = $this->config;
113
+
114
+ if (is_multisite()) {
115
+ return true;
116
+ } elseif ($bvconfig && array_key_exists("siteurl_scheme", $bvconfig)) {
117
+ $siteurl = $bvsiteinfo->siteurl('', $bvconfig["siteurl_scheme"]);
118
+ if (array_key_exists("abspath", $bvconfig) &&
119
+ array_key_exists("siteurl", $bvconfig) && !empty($siteurl)) {
120
+ return ($bvconfig["abspath"] == ABSPATH && $bvconfig["siteurl"] == $siteurl);
121
+ }
122
  }
123
  return true;
124
  }
malcare.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: https://www.malcare.com
5
  Description: MalCare WordPress Security Plugin - Malware Scanner, Cleaner, Security Firewall
6
  Author: MalCare Security
7
  Author URI: https://www.malcare.com
8
- Version: 4.82
9
  Network: True
10
  */
11
 
@@ -78,14 +78,24 @@ if (is_admin()) {
78
  add_action('admin_head', array($wpadmin, 'removeAdminNotices'), 3);
79
  add_action('admin_notices', array($wpadmin, 'activateWarning'));
80
  add_action('admin_enqueue_scripts', array($wpadmin, 'mcsecAdminMenu'));
81
- ##SOADMINMENU##
 
82
  }
83
 
84
-
85
  if ((array_key_exists('bvreqmerge', $_POST)) || (array_key_exists('bvreqmerge', $_GET))) {
86
  $_REQUEST = array_merge($_GET, $_POST);
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
89
  if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "malcare")) {
90
  require_once dirname( __FILE__ ) . '/callback/base.php';
91
  require_once dirname( __FILE__ ) . '/callback/response.php';
@@ -158,13 +168,6 @@ if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "
158
  $dynsync->init();
159
  }
160
 
161
- if ($bvinfo->isServiceActive('activity_log')) {
162
- require_once dirname( __FILE__ ) . '/wp_actlog.php';
163
- $bvconfig = $bvinfo->config;
164
- $actlog = new BVWPActLog($bvdb, $bvsettings, $bvinfo, $bvconfig['activity_log']);
165
- $actlog->init();
166
- }
167
-
168
  }
169
  $bv_site_settings = $bvsettings->getOption('bv_site_settings');
170
  if (isset($bv_site_settings)) {
5
  Description: MalCare WordPress Security Plugin - Malware Scanner, Cleaner, Security Firewall
6
  Author: MalCare Security
7
  Author URI: https://www.malcare.com
8
+ Version: 4.83
9
  Network: True
10
  */
11
 
78
  add_action('admin_head', array($wpadmin, 'removeAdminNotices'), 3);
79
  add_action('admin_notices', array($wpadmin, 'activateWarning'));
80
  add_action('admin_enqueue_scripts', array($wpadmin, 'mcsecAdminMenu'));
81
+ ##ALPURGECACHEFUNCTION##
82
+ ##ALADMINMENU##
83
  }
84
 
 
85
  if ((array_key_exists('bvreqmerge', $_POST)) || (array_key_exists('bvreqmerge', $_GET))) {
86
  $_REQUEST = array_merge($_GET, $_POST);
87
  }
88
 
89
+ if ($bvinfo->hasValidDBVersion()) {
90
+ if ($bvinfo->isServiceActive('activity_log')) {
91
+ require_once dirname( __FILE__ ) . '/wp_actlog.php';
92
+ $bvconfig = $bvinfo->config;
93
+ $actlog = new BVWPActLog($bvdb, $bvsettings, $bvinfo, $bvconfig['activity_log']);
94
+ $actlog->init();
95
+ }
96
+
97
+ }
98
+
99
  if ((array_key_exists('bvplugname', $_REQUEST)) && ($_REQUEST['bvplugname'] == "malcare")) {
100
  require_once dirname( __FILE__ ) . '/callback/base.php';
101
  require_once dirname( __FILE__ ) . '/callback/response.php';
168
  $dynsync->init();
169
  }
170
 
 
 
 
 
 
 
 
171
  }
172
  $bv_site_settings = $bvsettings->getOption('bv_site_settings');
173
  if (isset($bv_site_settings)) {
protect/fw/config.php CHANGED
@@ -16,6 +16,7 @@ class BVFWConfig {
16
  public $cookieDomain;
17
  public $loggingMode;
18
  public $rulesMode;
 
19
 
20
  public static $requests_table = 'fw_requests';
21
  public static $roleLevels = array(
@@ -40,6 +41,7 @@ class BVFWConfig {
40
  $this->canSetCachePreventionCookie = array_key_exists('cansetcachepreventioncookie', $confHash) ?
41
  $confHash['cansetcachepreventioncookie'] : false;
42
  $this->rulesMode = array_key_exists('rulesmode', $confHash) ? intval($confHash['rulesmode']) : BVFWConfig::DISABLED;
 
43
  }
44
 
45
  #mode
16
  public $cookieDomain;
17
  public $loggingMode;
18
  public $rulesMode;
19
+ public $isGeoBlocking;
20
 
21
  public static $requests_table = 'fw_requests';
22
  public static $roleLevels = array(
41
  $this->canSetCachePreventionCookie = array_key_exists('cansetcachepreventioncookie', $confHash) ?
42
  $confHash['cansetcachepreventioncookie'] : false;
43
  $this->rulesMode = array_key_exists('rulesmode', $confHash) ? intval($confHash['rulesmode']) : BVFWConfig::DISABLED;
44
+ $this->isGeoBlocking = array_key_exists('isgeoblocking', $confHash) ? $confHash['isgeoblocking'] : false;
45
  }
46
 
47
  #mode
protect/fw/fw.php CHANGED
@@ -75,8 +75,9 @@ class BVFW {
75
  public static function getInstance($logger, $confHash, $ip, $bvinfo, $ipstore, $ruleSet) {
76
  if (!isset(self::$instance)) {
77
  self::$instance = new BVFW($logger, $confHash, $ip, $bvinfo, $ipstore, $ruleSet);
 
 
78
  }
79
-
80
  return self::$instance;
81
  }
82
 
@@ -155,6 +156,11 @@ class BVFW {
155
  public function isActive() {
156
  return $this->config->isActive();
157
  }
 
 
 
 
 
158
  public function canSetAdminCookie() {
159
  return ($this->config->adminCookieMode === BVFWConfig::ADMIN_COOKIE_MODE_ENABLED);
160
  }
@@ -247,6 +253,14 @@ class BVFW {
247
  return true;
248
  }
249
 
 
 
 
 
 
 
 
 
250
  public function execute() {
251
  if ($this->config->canProfileReqInfo()) {
252
  $result = array();
@@ -266,12 +280,7 @@ class BVFW {
266
  $result += $this->profileRequestInfo($cookies, true, 'COOKIES[');
267
  $this->request->updateReqInfo($result);
268
  }
269
-
270
- if (!$this->canBypassFirewall() && $this->config->isProtecting()) {
271
- if ($this->isBlacklistedIP()) {
272
- $this->terminateRequest(BVWPRequest::BLACKLISTED);
273
- }
274
- }
275
  }
276
 
277
  public function canExecuteRules() {
75
  public static function getInstance($logger, $confHash, $ip, $bvinfo, $ipstore, $ruleSet) {
76
  if (!isset(self::$instance)) {
77
  self::$instance = new BVFW($logger, $confHash, $ip, $bvinfo, $ipstore, $ruleSet);
78
+ } else {
79
+ self::$instance->ipstore = $ipstore;
80
  }
 
81
  return self::$instance;
82
  }
83
 
156
  public function isActive() {
157
  return $this->config->isActive();
158
  }
159
+
160
+ public function isGeoBlocking() {
161
+ return $this->config->isGeoBlocking;
162
+ }
163
+
164
  public function canSetAdminCookie() {
165
  return ($this->config->adminCookieMode === BVFWConfig::ADMIN_COOKIE_MODE_ENABLED);
166
  }
253
  return true;
254
  }
255
 
256
+ public function blockIfBlacklisted() {
257
+ if (!$this->canBypassFirewall() && $this->config->isProtecting()) {
258
+ if ($this->isBlacklistedIP()) {
259
+ $this->terminateRequest(BVWPRequest::BLACKLISTED);
260
+ }
261
+ }
262
+ }
263
+
264
  public function execute() {
265
  if ($this->config->canProfileReqInfo()) {
266
  $result = array();
280
  $result += $this->profileRequestInfo($cookies, true, 'COOKIES[');
281
  $this->request->updateReqInfo($result);
282
  }
283
+ $this->blockIfBlacklisted();
 
 
 
 
 
284
  }
285
 
286
  public function canExecuteRules() {
protect/fw/rule_evaluator.php CHANGED
@@ -447,7 +447,7 @@ class BVFWRuleEvaluator {
447
  if (isset($post->post_type) && isset($post->post_status) &&
448
  in_array(array($post->post_type, $post->post_status), $posts_to_consider) &&
449
  !current_user_can("delete_{$post->post_type}", $post->ID)) {
450
- $log_data = array($post->ID, $post->post_type, $post->status);
451
  $this->request->updateRulesInfo("wp_hook_info", $curr_hook, $log_data);
452
  $this->fw->handleMatchedRule($rule_id);
453
  }
447
  if (isset($post->post_type) && isset($post->post_status) &&
448
  in_array(array($post->post_type, $post->post_status), $posts_to_consider) &&
449
  !current_user_can("delete_{$post->post_type}", $post->ID)) {
450
+ $log_data = array($post->ID, $post->post_type, $post->post_status);
451
  $this->request->updateRulesInfo("wp_hook_info", $curr_hook, $log_data);
452
  $this->fw->handleMatchedRule($rule_id);
453
  }
protect/wp/protect.php CHANGED
@@ -61,7 +61,10 @@ class BVProtect {
61
  register_shutdown_function(array($fw, 'log'));
62
 
63
  $fw->execute();
 
 
64
  }
 
65
  $fw->executeRules();
66
  }
67
 
61
  register_shutdown_function(array($fw, 'log'));
62
 
63
  $fw->execute();
64
+ } elseif ($fw->isGeoBlocking()) {
65
+ $fw->blockIfBlacklisted();
66
  }
67
+
68
  $fw->executeRules();
69
  }
70
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Donate link: https://www.malcare.com
6
  Requires at least: 4.0
7
  Tested up to: 6.1
8
  Requires PHP: 5.4.0
9
- Stable tag: 4.82
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
 
@@ -396,6 +396,11 @@ These are available on our website: [Terms of Service](https://www.malcare.com/t
396
  8. MalCare’s Uptime Monitoring notifies if a website goes down so that you can handle the situation before starting to lose visitors.
397
 
398
  == CHANGELOG ==
 
 
 
 
 
399
  = 4.82 =
400
  * Firewall Improvements
401
  * Real-time Improvements
6
  Requires at least: 4.0
7
  Tested up to: 6.1
8
  Requires PHP: 5.4.0
9
+ Stable tag: 4.83
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
 
396
  8. MalCare’s Uptime Monitoring notifies if a website goes down so that you can handle the situation before starting to lose visitors.
397
 
398
  == CHANGELOG ==
399
+ = 4.83 =
400
+ * Geo-blocking with advanced firewall
401
+ * Activity log improvements and bug fixes
402
+ * Woocommerce custom table support for real-time backups
403
+
404
  = 4.82 =
405
  * Firewall Improvements
406
  * Real-time Improvements
wp_actlog.php CHANGED
@@ -16,6 +16,7 @@ if (!class_exists('BVWPActLog')) :
16
  $this->bvinfo = $info;
17
  $this->request_id = MCInfo::getRequestID();
18
  $this->ip_header = array_key_exists('ip_header', $config) ? $config['ip_header'] : false;
 
19
  }
20
 
21
  function init() {
@@ -62,6 +63,7 @@ if (!class_exists('BVWPActLog')) :
62
  if (!empty($user)) {
63
  $data['username'] = $user->user_login;
64
  $data['email'] = $user->user_email;
 
65
  }
66
  return $data;
67
  }
@@ -144,6 +146,25 @@ if (!class_exists('BVWPActLog')) :
144
  $this->db->replaceIntoBVTable(BVWPActLog::$actlog_table, $values);
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  function user_login_handler($user_login, $user) {
148
  $event_data = array("user" => $this->get_user($user->ID));
149
  $this->add_activity($event_data);
@@ -185,6 +206,8 @@ if (!class_exists('BVWPActLog')) :
185
 
186
  function post_handler($post_id) {
187
  $post = $this->get_post($post_id);
 
 
188
  $event_data = array();
189
  if ($post["type"] === "product") {
190
  $event_data["product"] = $post;
@@ -198,6 +221,8 @@ if (!class_exists('BVWPActLog')) :
198
 
199
  function post_saved_handler($post_id, $post, $update) {
200
  $post = $this->get_post($post_id);
 
 
201
  $event_data = array();
202
  if ($post["type"] === "product") {
203
  $event_data["product"] = $post;
@@ -380,10 +405,18 @@ if (!class_exists('BVWPActLog')) :
380
  $event_data = array('action' => 'update');
381
  if ($options['type'] === 'plugin') {
382
  $event_data['type'] = 'plugin';
 
 
 
 
383
  $event_data['plugins'] = $this->get_plugin_update_data($options['plugins']);
384
  }
385
  else if ($options['type'] === 'theme') {
386
  $event_data['type'] = 'theme';
 
 
 
 
387
  $event_data['themes'] = $this->get_theme_update_data($options['themes']);
388
  }
389
  else if ($options['type'] === 'core') {
16
  $this->bvinfo = $info;
17
  $this->request_id = MCInfo::getRequestID();
18
  $this->ip_header = array_key_exists('ip_header', $config) ? $config['ip_header'] : false;
19
+ $this->ignored_events = array_key_exists('ignored_events', $config) ? $config['ignored_events'] : array();
20
  }
21
 
22
  function init() {
63
  if (!empty($user)) {
64
  $data['username'] = $user->user_login;
65
  $data['email'] = $user->user_email;
66
+ $data['role'] = $user->roles;
67
  }
68
  return $data;
69
  }
146
  $this->db->replaceIntoBVTable(BVWPActLog::$actlog_table, $values);
147
  }
148
 
149
+ function is_key_ignored($ignored_keys, $value) {
150
+ $is_ignored = false;
151
+ if (array_key_exists("post_types_regex", $ignored_keys)) {
152
+ foreach ($ignored_keys['post_types_regex'] as $val) {
153
+ if (preg_match($val, $value)) {
154
+ return true;
155
+ }
156
+ }
157
+ }
158
+ if (array_key_exists("post_types", $ignored_keys)) {
159
+ foreach ($ignored_keys['post_types'] as $val) {
160
+ if ($val == $value) {
161
+ return true;
162
+ }
163
+ }
164
+ }
165
+ return $is_ignored;
166
+ }
167
+
168
  function user_login_handler($user_login, $user) {
169
  $event_data = array("user" => $this->get_user($user->ID));
170
  $this->add_activity($event_data);
206
 
207
  function post_handler($post_id) {
208
  $post = $this->get_post($post_id);
209
+ if ($this->is_key_ignored($this->ignored_events, $post["type"]))
210
+ return;
211
  $event_data = array();
212
  if ($post["type"] === "product") {
213
  $event_data["product"] = $post;
221
 
222
  function post_saved_handler($post_id, $post, $update) {
223
  $post = $this->get_post($post_id);
224
+ if ($this->is_key_ignored($this->ignored_events, $post["type"]))
225
+ return;
226
  $event_data = array();
227
  if ($post["type"] === "product") {
228
  $event_data["product"] = $post;
405
  $event_data = array('action' => 'update');
406
  if ($options['type'] === 'plugin') {
407
  $event_data['type'] = 'plugin';
408
+ if (array_key_exists("plugin", $options)) {
409
+ $options['plugins'] = array($options['plugin']);
410
+ unset($options['plugin']);
411
+ }
412
  $event_data['plugins'] = $this->get_plugin_update_data($options['plugins']);
413
  }
414
  else if ($options['type'] === 'theme') {
415
  $event_data['type'] = 'theme';
416
+ if (array_key_exists("theme", $options)) {
417
+ $options['themes'] = array($options['theme']);
418
+ unset($options['theme']);
419
+ }
420
  $event_data['themes'] = $this->get_theme_update_data($options['themes']);
421
  }
422
  else if ($options['type'] === 'core') {
wp_cli.php CHANGED
@@ -23,7 +23,7 @@ class MCWPCli {
23
  $request_params['bvpublic'] = MCAccount::getApiPublicKey($this->settings);
24
  $request_params['bvsecret'] = MCRecover::defaultSecret($this->settings);
25
  $url = $this->bvinfo->appUrl()."/api/v3/accounts/".$params['account_id']."/sites";
26
- foreach (preg_grep('#site_id|email|password|wp_cli_command#i', array_keys($params)) as $key ) {
27
  $request_params[$key] = $params[$key];
28
  }
29
  $headers = array(
23
  $request_params['bvpublic'] = MCAccount::getApiPublicKey($this->settings);
24
  $request_params['bvsecret'] = MCRecover::defaultSecret($this->settings);
25
  $url = $this->bvinfo->appUrl()."/api/v3/accounts/".$params['account_id']."/sites";
26
+ foreach (preg_grep('#site_id|email|password|wp_cli_command|is_staging_env#i', array_keys($params)) as $key ) {
27
  $request_params[$key] = $params[$key];
28
  }
29
  $headers = array(
wp_dynsync.php CHANGED
@@ -267,6 +267,25 @@ class BVWPDynSync {
267
  }
268
  }
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  function woocommerce_new_order_item_handler($item_id, $item, $order_id) {
271
  $this->add_db_event('woocommerce_order_items', array('order_item_id' => $item_id));
272
  $this->add_db_event('woocommerce_order_itemmeta', array('order_item_id' => $item_id));
@@ -598,6 +617,9 @@ class BVWPDynSync {
598
  add_action('update_site_option', array($this, 'sitemeta_handler'), 10, 1);
599
 
600
  /* CAPTURING EVENTS FOR WOOCOMMERCE */
 
 
 
601
  add_action('woocommerce_resume_order', array($this, 'woocommerce_resume_order_handler'), 10, 1);
602
  add_action('woocommerce_new_order_item', array($this, 'woocommerce_new_order_item_handler'), 10, 3);
603
  add_action('woocommerce_update_order_item', array($this, 'woocommerce_update_order_item_handler'), 10, 2);
267
  }
268
  }
269
 
270
+ function woocommerce_update_order_handler($order_id, $order) {
271
+ $this->add_db_event('wc_orders', array('id' => $order_id));
272
+ $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
273
+ $this->add_db_event('wc_order_addresses', array('order_id' => $order_id));
274
+ $this->add_db_event('wc_order_operational_data', array('order_id' => $order_id));
275
+ }
276
+
277
+ function woocommerce_trash_order_handler($order_id) {
278
+ $this->add_db_event('wc_orders', array('id' => $order_id));
279
+ $this->add_db_event('wc_orders_meta', array('order_id' => $order_id));
280
+ }
281
+
282
+ function woocommerce_delete_order_handler($order_id) {
283
+ $this->add_db_event('wc_orders', array('id' => $order_id, 'msg_type' => 'delete'));
284
+ $this->add_db_event('wc_orders_meta', array('order_id' => $order_id, 'msg_type' => 'delete'));
285
+ $this->add_db_event('wc_order_addresses', array('order_id' => $order_id, 'msg_type' => 'delete'));
286
+ $this->add_db_event('wc_order_operational_data', array('order_id' => $order_id, 'msg_type' => 'delete'));
287
+ }
288
+
289
  function woocommerce_new_order_item_handler($item_id, $item, $order_id) {
290
  $this->add_db_event('woocommerce_order_items', array('order_item_id' => $item_id));
291
  $this->add_db_event('woocommerce_order_itemmeta', array('order_item_id' => $item_id));
617
  add_action('update_site_option', array($this, 'sitemeta_handler'), 10, 1);
618
 
619
  /* CAPTURING EVENTS FOR WOOCOMMERCE */
620
+ add_action('woocommerce_update_order', array($this, 'woocommerce_update_order_handler'), 10, 2);
621
+ add_action('woocommerce_delete_order', array($this, 'woocommerce_delete_order_handler'), 10, 1);
622
+ add_action('woocommerce_trash_order', array($this, 'woocommerce_trash_order_handler'), 10, 1);
623
  add_action('woocommerce_resume_order', array($this, 'woocommerce_resume_order_handler'), 10, 1);
624
  add_action('woocommerce_new_order_item', array($this, 'woocommerce_new_order_item_handler'), 10, 3);
625
  add_action('woocommerce_update_order_item', array($this, 'woocommerce_update_order_item_handler'), 10, 2);
wp_site_info.php CHANGED
@@ -11,9 +11,9 @@ class MCWPSiteInfo {
11
  return get_bloginfo('wpurl');
12
  }
13
 
14
- public function siteurl() {
15
  if (function_exists('site_url')) {
16
- return site_url();
17
  } else {
18
  return get_bloginfo('wpurl');
19
  }
11
  return get_bloginfo('wpurl');
12
  }
13
 
14
+ public function siteurl($path = '', $scheme = null) {
15
  if (function_exists('site_url')) {
16
+ return site_url($path, $scheme);
17
  } else {
18
  return get_bloginfo('wpurl');
19
  }