VaultPress - Version 1.5.1

Version Description

  • Feature: Adding file exclusion patterns to avoid backing up cache and backup directories.
Download this release

Release Info

Developer briancolinger
Plugin Icon 128x128 VaultPress
Version 1.5.1
Comparing to
See all releases

Code changes from version 1.5 to 1.5.1

Files changed (3) hide show
  1. class.vaultpress-filesystem.php +17 -1
  2. readme.txt +4 -1
  3. vaultpress.php +53 -3
class.vaultpress-filesystem.php CHANGED
@@ -93,7 +93,7 @@ class VaultPress_Filesystem {
93
  return $rval;
94
  }
95
 
96
- function ls( $what, $md5=false, $sha1=false, $limit=null, $offset=null ) {
97
  clearstatcache();
98
  $path = realpath($this->dir . $what);
99
  $dir = $this->dir;
@@ -113,6 +113,8 @@ class VaultPress_Filesystem {
113
  $limit = $offset + (int)$limit;
114
  foreach ( (array)$this->scan_dir( $path ) as $i ) {
115
  $current++;
 
 
116
  if ( $offset >= $current )
117
  continue;
118
  if ( $limit && $limit < $current )
@@ -128,6 +130,20 @@ class VaultPress_Filesystem {
128
  }
129
  }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  function validate( $file ) {
132
  $rpath = realpath( $this->dir.$file );
133
  $dir = $this->dir;
93
  return $rval;
94
  }
95
 
96
+ function ls( $what, $md5=false, $sha1=false, $limit=null, $offset=null, $full_list=false ) {
97
  clearstatcache();
98
  $path = realpath($this->dir . $what);
99
  $dir = $this->dir;
113
  $limit = $offset + (int)$limit;
114
  foreach ( (array)$this->scan_dir( $path ) as $i ) {
115
  $current++;
116
+ if ( !$full_list && !$this->should_backup_file( $i ) )
117
+ continue;
118
  if ( $offset >= $current )
119
  continue;
120
  if ( $limit && $limit < $current )
130
  }
131
  }
132
 
133
+ function should_backup_file( $filepath ) {
134
+ $vp = VaultPress::init();
135
+ if ( is_dir( $filepath ) )
136
+ $filepath = trailingslashit( $filepath );
137
+ $regex_patterns = $vp->get_should_ignore_files();
138
+ foreach ( $regex_patterns as $pattern ) {
139
+ $matches = array();
140
+ if ( preg_match( $pattern, $filepath, $matches ) ) {
141
+ return false;
142
+ }
143
+ }
144
+ return true;
145
+ }
146
+
147
  function validate( $file ) {
148
  $rpath = realpath( $this->dir.$file );
149
  $dir = $this->dir;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: automattic, apokalyptik, briancolinger, josephscott, shaunandrews,
3
  Tags: security, malware, virus, backups, scanning
4
  Requires at least: 2.9.2
5
  Tested up to: 3.8
6
- Stable tag: 1.5
7
  License: GPLv2
8
 
9
  VaultPress is a subscription service offering realtime backup, automated security scanning, and support from WordPress experts.
@@ -51,6 +51,9 @@ A VaultPress subscription is for a single WordPress site. You can purchase addit
51
  Yes, VaultPress supports Multisite installs. Each site will require its own subscription.
52
 
53
  == Changelog ==
 
 
 
54
  = 1.5 =
55
  * Bugfix: Don't show admin notices on the about page.
56
 
3
  Tags: security, malware, virus, backups, scanning
4
  Requires at least: 2.9.2
5
  Tested up to: 3.8
6
+ Stable tag: 1.5.1
7
  License: GPLv2
8
 
9
  VaultPress is a subscription service offering realtime backup, automated security scanning, and support from WordPress experts.
51
  Yes, VaultPress supports Multisite installs. Each site will require its own subscription.
52
 
53
  == Changelog ==
54
+ = 1.5.1 =
55
+ * Feature: Adding file exclusion patterns to avoid backing up cache and backup directories.
56
+
57
  = 1.5 =
58
  * Bugfix: Don't show admin notices on the about page.
59
 
vaultpress.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: VaultPress
4
  * Plugin URI: http://vaultpress.com/?utm_source=plugin-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
5
  * Description: Protect your content, themes, plugins, and settings with <strong>realtime backup</strong> and <strong>automated security scanning</strong> from <a href="http://vaultpress.com/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">VaultPress</a>. Activate, enter your registration key, and never worry again. <a href="http://vaultpress.com/help/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">Need some help?</a>
6
- * Version: 1.5
7
  * Author: Automattic
8
  * Author URI: http://vaultpress.com/?utm_source=author-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
9
  * License: GPL2+
@@ -18,7 +18,7 @@ if ( !defined( 'ABSPATH' ) )
18
  class VaultPress {
19
  var $option_name = 'vaultpress';
20
  var $db_version = 3;
21
- var $plugin_version = '1.5';
22
 
23
  function __construct() {
24
  register_activation_hook( __FILE__, array( $this, 'activate' ) );
@@ -517,6 +517,10 @@ class VaultPress {
517
  $val = $this->get_post_meta_name_ignore( true );
518
  update_option( '_vp_config_post_meta_name_ignore', $val );
519
  break;
 
 
 
 
520
  }
521
  return $val;
522
  }
@@ -549,6 +553,47 @@ class VaultPress {
549
  return array_unique( array_merge( $defaults, $ignore_names ) );
550
  }
551
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  ###
553
  ### Section: Backup Notification Hooks
554
  ###
@@ -1534,6 +1579,11 @@ JS;
1534
  else
1535
  $recursive = false;
1536
 
 
 
 
 
 
1537
  switch ( array_pop( explode( ':', $_GET['action'] ) ) ) {
1538
  default:
1539
  die( "naughty naughty" );
@@ -1547,7 +1597,7 @@ JS;
1547
  case 'get':
1548
  $bfs->fdump( $bfs->dir.$path );
1549
  case 'ls':
1550
- $this->response( $bfs->ls( $path, $md5, $sha1, $limit, $offset ) );
1551
  }
1552
  break;
1553
  case 'config:get':
3
  * Plugin Name: VaultPress
4
  * Plugin URI: http://vaultpress.com/?utm_source=plugin-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
5
  * Description: Protect your content, themes, plugins, and settings with <strong>realtime backup</strong> and <strong>automated security scanning</strong> from <a href="http://vaultpress.com/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">VaultPress</a>. Activate, enter your registration key, and never worry again. <a href="http://vaultpress.com/help/?utm_source=wp-admin&amp;utm_medium=plugin-description&amp;utm_campaign=1.0" rel="nofollow">Need some help?</a>
6
+ * Version: 1.5.1
7
  * Author: Automattic
8
  * Author URI: http://vaultpress.com/?utm_source=author-uri&amp;utm_medium=plugin-description&amp;utm_campaign=1.0
9
  * License: GPL2+
18
  class VaultPress {
19
  var $option_name = 'vaultpress';
20
  var $db_version = 3;
21
+ var $plugin_version = '1.5.1';
22
 
23
  function __construct() {
24
  register_activation_hook( __FILE__, array( $this, 'activate' ) );
517
  $val = $this->get_post_meta_name_ignore( true );
518
  update_option( '_vp_config_post_meta_name_ignore', $val );
519
  break;
520
+ case '_vp_config_should_ignore_files':
521
+ $val = $this->get_should_ignore_files( true );
522
+ update_option( '_vp_config_should_ignore_files', $val );
523
+ break;
524
  }
525
  return $val;
526
  }
553
  return array_unique( array_merge( $defaults, $ignore_names ) );
554
  }
555
 
556
+ // file name patterns to ignore
557
+ function get_should_ignore_files( $return_defaults = false ) {
558
+ $defaults = array(
559
+ '@.*/404\.log\.txt$@',
560
+ '@.*/\.DS_Store$@',
561
+ '@.*/debug\.log$@',
562
+ '@.*\.timthumb\.txt$@',
563
+ '@.*timthumb[A-Za-z0-9]*$@',
564
+ '@.*wp-content/contents/cache/@',
565
+ '@.*wp-content/content/cache/@',
566
+ '@.*wp-content/cache/@',
567
+ '@.*wp-content/old-cache/@',
568
+ '@.*cache/@',
569
+ '@.*wp-content/w3tc/@',
570
+ '@.*owa/owa-data/caches/@',
571
+ '@.*gt-cache@',
572
+ '@.*/wpclicks/tracker/cache/@',
573
+ '@.*amember/data/new_rewrite@',
574
+ '@.*sucuri/blocks/@',
575
+ '@.*/_sucuribackup.*@',
576
+ '@.*sess_[0-9a-zA-Z]{32,}@',
577
+ '@.*wp-content/backups.*@',
578
+ '@.*wp-content/backupwordpress@',
579
+ '@.*wp-content/backup-[0-9a-zA-Z]+@',
580
+ '@.*wp-content/[0-9a-zA-Z]+-backups@',
581
+ '@.*mwp_backups/@',
582
+ '@.*managewp/backups/@',
583
+ '@.*wp-snapshots/@',
584
+ '@.*error_log.*@',
585
+ '@.*/error-log.*@',
586
+ '@.*/error\.log$@',
587
+ '@.*/captcha/tmp.*@',
588
+ '@.*\.mt_backup_[0-9a-z:_]*$@i',
589
+ '@.*vp-uploaded-restore-.*@',
590
+ );
591
+ if ( $return_defaults )
592
+ return $defaults;
593
+ $ignore_names = (array) $this->get_config( '_vp_config_should_ignore_files' );
594
+ return array_unique( array_merge( $defaults, $ignore_names ) );
595
+ }
596
+
597
  ###
598
  ### Section: Backup Notification Hooks
599
  ###
1579
  else
1580
  $recursive = false;
1581
 
1582
+ if ( isset( $_POST['full_list'] ) )
1583
+ $full_list = (bool)$_POST['full_list'];
1584
+ else
1585
+ $full_list = false;
1586
+
1587
  switch ( array_pop( explode( ':', $_GET['action'] ) ) ) {
1588
  default:
1589
  die( "naughty naughty" );
1597
  case 'get':
1598
  $bfs->fdump( $bfs->dir.$path );
1599
  case 'ls':
1600
+ $this->response( $bfs->ls( $path, $md5, $sha1, $limit, $offset, $full_list ) );
1601
  }
1602
  break;
1603
  case 'config:get':