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

Version Description

  • Improved scanfiles and filelist api
Download this release

Release Info

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

Code changes from version 4.33 to 4.35

Files changed (4) hide show
  1. callback/wings/fs.php +62 -20
  2. info.php +2 -2
  3. malcare.php +2 -2
  4. readme.txt +5 -2
callback/wings/fs.php CHANGED
@@ -14,7 +14,7 @@ class BVFSCallback extends BVCallbackBase {
14
  $this->account = $callback_handler->account;
15
  }
16
 
17
- function fileStat($relfile) {
18
  $absfile = ABSPATH.$relfile;
19
  $fdata = array();
20
  $fdata["filename"] = $relfile;
@@ -26,6 +26,9 @@ class BVFSCallback extends BVCallbackBase {
26
  if (is_link($absfile)) {
27
  $fdata["link"] = @readlink($absfile);
28
  }
 
 
 
29
  } else {
30
  $fdata["failed"] = true;
31
  }
@@ -78,8 +81,9 @@ class BVFSCallback extends BVCallbackBase {
78
  return array("status" => "done");
79
  }
80
 
81
- function scanFiles($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true) {
82
  $i = 0;
 
83
  $dirs = array();
84
  $dirs[] = $initdir;
85
  $bfc = 0;
@@ -93,6 +97,9 @@ class BVFSCallback extends BVCallbackBase {
93
  if ($file == '.' || $file == '..') { continue; }
94
  $relfile = $dir.$file;
95
  $absfile = ABSPATH.$relfile;
 
 
 
96
  if (is_dir($absfile) && !is_link($absfile)) {
97
  $dirs[] = $relfile."/";
98
  }
@@ -103,7 +110,7 @@ class BVFSCallback extends BVCallbackBase {
103
  $i = count($dirs);
104
  break;
105
  }
106
- $bfa[] = $this->fileStat($relfile);
107
  $bfc++;
108
  if ($bfc == $bsize) {
109
  $str = serialize($bfa);
@@ -122,7 +129,8 @@ class BVFSCallback extends BVCallbackBase {
122
  $str = serialize($bfa);
123
  $this->stream->writeStream($str);
124
  }
125
- return array("status" => "done");
 
126
  }
127
 
128
  function calculateMd5($absfile, $fdata, $offset, $limit, $bsize) {
@@ -256,15 +264,29 @@ class BVFSCallback extends BVCallbackBase {
256
  $resp = $this->scanFilesUsingGlob($initdir, $offset, $limit, $bsize, $recurse, $regex);
257
  break;
258
  case "scanfiles":
259
- $initdir = urldecode($params['initdir']);
260
- $offset = intval(urldecode($params['offset']));
261
- $limit = intval(urldecode($params['limit']));
 
 
262
  $bsize = intval(urldecode($params['bsize']));
263
- $recurse = true;
264
- if (array_key_exists('recurse', $params) && $params["recurse"] == "false") {
265
- $recurse = false;
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
- $resp = $this->scanFiles($initdir, $offset, $limit, $bsize, $recurse);
268
  break;
269
  case "getfilesstats":
270
  $files = $params['files'];
@@ -285,17 +307,37 @@ class BVFSCallback extends BVCallbackBase {
285
  $resp = $this->uploadFiles($files, $offset, $limit, $bsize);
286
  break;
287
  case "filelist":
288
- $initdir = $params['initdir'];
289
- $glob_option = GLOB_MARK;
290
- if(array_key_exists('onlydir', $params)) {
291
- $glob_option = GLOB_ONLYDIR;
 
 
292
  }
293
- $regex = "*";
294
- if(array_key_exists('regex', $params)){
295
- $regex = $params['regex'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  }
297
- $directoryList = glob($initdir.$regex, $glob_option);
298
- $resp = $this->getFilesStats($directoryList);
299
  break;
300
  case "dirsexists":
301
  $resp = array();
14
  $this->account = $callback_handler->account;
15
  }
16
 
17
+ function fileStat($relfile, $md5 = false) {
18
  $absfile = ABSPATH.$relfile;
19
  $fdata = array();
20
  $fdata["filename"] = $relfile;
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 {
33
  $fdata["failed"] = true;
34
  }
81
  return array("status" => "done");
82
  }
83
 
84
+ function scanFiles($initdir = "./", $offset = 0, $limit = 0, $bsize = 512, $recurse = true, $md5 = false) {
85
  $i = 0;
86
+ $links = array();
87
  $dirs = array();
88
  $dirs[] = $initdir;
89
  $bfc = 0;
97
  if ($file == '.' || $file == '..') { continue; }
98
  $relfile = $dir.$file;
99
  $absfile = ABSPATH.$relfile;
100
+ if (is_link($absfile)) {
101
+ $links[] = $relfile;
102
+ }
103
  if (is_dir($absfile) && !is_link($absfile)) {
104
  $dirs[] = $relfile."/";
105
  }
110
  $i = count($dirs);
111
  break;
112
  }
113
+ $bfa[] = $this->fileStat($relfile, $md5);
114
  $bfc++;
115
  if ($bfc == $bsize) {
116
  $str = serialize($bfa);
129
  $str = serialize($bfa);
130
  $this->stream->writeStream($str);
131
  }
132
+
133
+ return $links;
134
  }
135
 
136
  function calculateMd5($absfile, $fdata, $offset, $limit, $bsize) {
264
  $resp = $this->scanFilesUsingGlob($initdir, $offset, $limit, $bsize, $recurse, $regex);
265
  break;
266
  case "scanfiles":
267
+ $links = array();
268
+ $dir_options = array();
269
+ if (array_key_exists('dir_options', $params)) {
270
+ $dir_options = $params['dir_options'];
271
+ }
272
  $bsize = intval(urldecode($params['bsize']));
273
+ foreach($dir_options as $option) {
274
+ $dir = urldecode($option['dir']);
275
+ $offset = intval(urldecode($option['offset']));
276
+ $limit = intval(urldecode($option['limit']));
277
+ $recurse = true;
278
+ if (array_key_exists('recurse', $option) && $option["recurse"] == "false") {
279
+ $recurse = false;
280
+ }
281
+ $md5 = true;
282
+ if (array_key_exists('md5', $option) && $option["md5"] == "false") {
283
+ $md5 = false;
284
+ }
285
+
286
+ $_links = $this->scanFiles($dir, $offset, $limit, $bsize, $recurse, $md5);
287
+ $links = array_merge($links, $_links);
288
  }
289
+ $resp = array("status" => "done", "links" => $links);
290
  break;
291
  case "getfilesstats":
292
  $files = $params['files'];
307
  $resp = $this->uploadFiles($files, $offset, $limit, $bsize);
308
  break;
309
  case "filelist":
310
+ $dir_options = array();
311
+ if (array_key_exists('dir_options', $params)) {
312
+ $dir_options = $params['dir_options'];
313
+ }
314
+ if (array_key_exists('chdir', $params)) {
315
+ chdir(ABSPATH);
316
  }
317
+ $resp = array();
318
+ foreach($dir_options as $options) {
319
+ $glob_option = 0;
320
+ if (array_key_exists('onlydir', $options)) {
321
+ $glob_option = GLOB_ONLYDIR;
322
+ }
323
+
324
+ $regexes = array("*", ".*");
325
+ if (array_key_exists('regex', $options)) {
326
+ $regexes = array($options['regex']);
327
+ }
328
+
329
+ $md5 = false;
330
+ if (array_key_exists('md5', $options)) {
331
+ $md5 = $options['md5'];
332
+ }
333
+
334
+ $directoryList = array();
335
+
336
+ foreach($regexes as $regex) {
337
+ $directoryList = array_merge($directoryList, glob($options['dir'].$regex, $glob_option));
338
+ }
339
+ $resp[$options['dir']] = $this->getFilesStats($directoryList, 0, 0, 0, $md5);
340
  }
 
 
341
  break;
342
  case "dirsexists":
343
  $resp = array();
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.33';
13
  public $webpage = 'https://www.malcare.com';
14
  public $appurl = 'https://app.malcare.com';
15
  public $slug = 'malcare-security/malcare.php';
@@ -103,4 +103,4 @@ if (MCWPSiteInfo::isCWServer() && !$bvinfo->isManualSignup()) {
103
  );
104
  }
105
  }
106
- endif;
9
  public $badgeinfo = 'mcbadge';
10
  public $ip_header_option = 'mcipheader';
11
  public $brand_option = 'mcbrand';
12
+ public $version = '4.35';
13
  public $webpage = 'https://www.malcare.com';
14
  public $appurl = 'https://app.malcare.com';
15
  public $slug = 'malcare-security/malcare.php';
103
  );
104
  }
105
  }
106
+ endif;
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.33
9
  Network: True
10
  */
11
 
@@ -142,4 +142,4 @@ 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.35
9
  Network: True
10
  */
11
 
142
  }
143
 
144
  ##DYNSYNCMODULE##
145
+ }
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.4
8
  Requires PHP: 5.4.0
9
- Stable tag: 4.33
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
 
@@ -390,6 +390,9 @@ 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.33 =
394
  * Hiding bot protection dashboard from wp-admin
395
 
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.5
8
  Requires PHP: 5.4.0
9
+ Stable tag: 4.35
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
 
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.35 =
394
+ * Improved scanfiles and filelist api
395
+
396
  = 4.33 =
397
  * Hiding bot protection dashboard from wp-admin
398