Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid - Version 1.6.2

Version Description

Release Date: May 25th, 2018

  • Update: Detect and use available resources to trigger cron tasks. Added cURL support.
Download this release

Release Info

Developer boldgrid
Plugin Icon 128x128 Total Upkeep – WordPress Backup Plugin plus Restore & Migrate by BoldGrid
Version 1.6.2
Comparing to
See all releases

Code changes from version 1.6.1 to 1.6.2

admin/class-boldgrid-backup-admin-core.php CHANGED
@@ -2498,6 +2498,8 @@ class Boldgrid_Backup_Admin_Core {
2498
  $cron = esc_html( $cron );
2499
  }
2500
 
 
 
2501
  // Enqueue CSS for the test page.
2502
  wp_enqueue_style( 'boldgrid-backup-admin-test',
2503
  plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-test.css', array(),
2498
  $cron = esc_html( $cron );
2499
  }
2500
 
2501
+ $cli_support = $this->test->get_cli_support();
2502
+
2503
  // Enqueue CSS for the test page.
2504
  wp_enqueue_style( 'boldgrid-backup-admin-test',
2505
  plugin_dir_url( __FILE__ ) . 'css/boldgrid-backup-admin-test.css', array(),
admin/class-boldgrid-backup-admin-folder-exclusion.php CHANGED
@@ -347,14 +347,20 @@ class Boldgrid_Backup_Admin_Folder_Exclusion {
347
 
348
  if ( $this->core->settings->is_saving_settings ) {
349
  $this->$type = $this->from_post( $type );
 
350
  /*
351
- * Is there value for this in the settings?
352
- *
353
- * Initially, we checked to make sure $settings[$key] wasn't empty and
354
- * it was a string. Now, we'll simply see if it is set. This will allow
355
- * for the user to enter nothing in the exclude field.
356
- */
357
  } elseif ( isset( $settings[ $key ] ) ) {
 
 
 
 
 
 
 
358
  $this->$type = $settings[ $key ];
359
  } elseif ( ! $settings ) {
360
  $settings = $this->core->settings->get_settings();
347
 
348
  if ( $this->core->settings->is_saving_settings ) {
349
  $this->$type = $this->from_post( $type );
350
+ } elseif ( isset( $settings['folder_exclusion_type'] ) && 'full' === $settings['folder_exclusion_type'] ) {
351
  /*
352
+ * If the user configured "Backup all files" as the "Files and Folders" settings, then
353
+ * use the default values.
354
+ */
355
+ $this->$default;
 
 
356
  } elseif ( isset( $settings[ $key ] ) ) {
357
+ /*
358
+ * Is there value for this in the settings?
359
+ *
360
+ * Initially, we checked to make sure $settings[$key] wasn't empty and
361
+ * it was a string. Now, we'll simply see if it is set. This will allow
362
+ * for the user to enter nothing in the exclude field.
363
+ */
364
  $this->$type = $settings[ $key ];
365
  } elseif ( ! $settings ) {
366
  $settings = $this->core->settings->get_settings();
admin/class-boldgrid-backup-admin-scheduler.php CHANGED
@@ -103,9 +103,10 @@ class Boldgrid_Backup_Admin_Scheduler {
103
  }
104
 
105
  $is_crontab_available = $this->core->test->is_crontab_available();
 
106
 
107
- // We schedule crontab jobs requiring the PHP setting "allow_url_fopen" be enabled.
108
- if ( $is_crontab_available && ini_get( 'allow_url_fopen' ) ) {
109
  $this->available['cron'] = array(
110
  'title' => 'Cron',
111
  );
103
  }
104
 
105
  $is_crontab_available = $this->core->test->is_crontab_available();
106
+ $cli_support = $this->core->test->get_cli_support();
107
 
108
+ // We schedule crontab jobs requiring fetching a url (curl or file_get_contents).
109
+ if ( $is_crontab_available && $cli_support['can_remote_get'] ) {
110
  $this->available['cron'] = array(
111
  'title' => 'Cron',
112
  );
admin/class-boldgrid-backup-admin-test.php CHANGED
@@ -624,6 +624,33 @@ class Boldgrid_Backup_Admin_Test {
624
  return $size;
625
  }
626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  /**
628
  * Get database size.
629
  *
624
  return $size;
625
  }
626
 
627
+ /**
628
+ * Check for support when php is ran from the CLI.
629
+ *
630
+ * If running a PHP script from CLI, it's possible that a different php.ini file will be used than
631
+ * if a server (nginx or apache) runs it.
632
+ *
633
+ * @since 1.6.2
634
+ *
635
+ * @return array
636
+ */
637
+ public function get_cli_support() {
638
+ $default = array(
639
+ 'has_curl_ssl' => false,
640
+ 'has_url_fopen' => false,
641
+ );
642
+
643
+ $cmd = 'php -f ' . trailingslashit( BOLDGRID_BACKUP_PATH ) . 'cron/cli-support.php';
644
+
645
+ $result = $this->core->execute_command( $cmd );
646
+ $result = json_decode( $result, true );
647
+ $result = is_array( $result ) ? $result : $default;
648
+
649
+ $result['can_remote_get'] = $result['has_curl_ssl'] || $result['has_url_fopen'];
650
+
651
+ return $result;
652
+ }
653
+
654
  /**
655
  * Get database size.
656
  *
admin/partials/boldgrid-backup-admin-test.php CHANGED
@@ -235,7 +235,17 @@ $tests[] = array(
235
 
236
  $tests[] = array(
237
  'k' => __( 'PHP allow_url_fopen enabled?', 'boldgrid-backup' ),
238
- 'v' => ( ini_get( 'allow_url_fopen' ) ? $lang['yes'] : sprintf( $error_span, $lang['no'], '' ) ),
 
 
 
 
 
 
 
 
 
 
239
  );
240
 
241
  $tests[] = array(
@@ -260,7 +270,7 @@ if ( $is_functional ) {
260
  );
261
 
262
  $tests[] = array(
263
- 'k' => __( 'Directory used to calculate disk space:', __( 'boldgrid-backup' ) ),
264
  'v' => $this->home_dir->get_for_disk(),
265
  );
266
 
235
 
236
  $tests[] = array(
237
  'k' => __( 'PHP allow_url_fopen enabled?', 'boldgrid-backup' ),
238
+ 'v' => true === $cli_support['has_url_fopen'] ? $lang['yes'] : sprintf( $warning_span, $lang['no'], '' ),
239
+ );
240
+
241
+ $tests[] = array(
242
+ 'k' => __( 'Curl SSL enabled?', 'boldgrid-backup' ),
243
+ 'v' => true === $cli_support['has_curl_ssl'] ? $lang['yes'] : sprintf( $warning_span, $lang['no'], '' ),
244
+ );
245
+
246
+ $tests[] = array(
247
+ 'k' => __( 'Can fetch a remote url via CLI?', 'boldgrid-backup' ),
248
+ 'v' => true === $cli_support['can_remote_get'] ? $lang['yes'] : sprintf( $error_span, $lang['no'], '' ),
249
  );
250
 
251
  $tests[] = array(
270
  );
271
 
272
  $tests[] = array(
273
+ 'k' => __( 'Directory used to calculate disk space:', 'boldgrid-backup' ),
274
  'v' => $this->home_dir->get_for_disk(),
275
  );
276
 
boldgrid-backup-cron.php CHANGED
@@ -6,9 +6,9 @@
6
  * @since 1.0
7
  *
8
  * @package Boldgrid_Backup
9
- * @copyright BoldGrid.com
10
  * @version $Id$
11
- * @author BoldGrid.com <wpb@boldgrid.com>
12
  */
13
 
14
  // Abort if not being ran from the command line.
@@ -58,10 +58,10 @@ if ( ! in_array( $input['mode'], $valid_modes, true ) ) {
58
  $url = $input['siteurl'] . '/wp-admin/admin-ajax.php?action=boldgrid_backup_run_' . $input['mode'] .
59
  '&id=' . $input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
60
 
61
- // Sanitize the url.
62
- $url = filter_var( $url, FILTER_SANITIZE_URL );
63
-
64
- $result = file_get_contents( $url );
65
 
66
  if ( false !== $result ) {
67
  $message = $result;
6
  * @since 1.0
7
  *
8
  * @package Boldgrid_Backup
9
+ * @copyright BoldGrid
10
  * @version $Id$
11
+ * @author BoldGrid <support@boldgrid.com>
12
  */
13
 
14
  // Abort if not being ran from the command line.
58
  $url = $input['siteurl'] . '/wp-admin/admin-ajax.php?action=boldgrid_backup_run_' . $input['mode'] .
59
  '&id=' . $input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
60
 
61
+ // The helper class method will sanitize the url.
62
+ require dirname( __FILE__ ) . '/cron/url-helper.php';
63
+ $url_helper = new Boldgrid_Backup_Url_Helper();
64
+ $result = $url_helper->call_url( $url );
65
 
66
  if ( false !== $result ) {
67
  $message = $result;
boldgrid-backup.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: BoldGrid Backup
16
  * Plugin URI: https://www.boldgrid.com/boldgrid-backup/
17
  * Description: BoldGrid Backup provides WordPress backup and restoration with update protection.
18
- * Version: 1.6.1
19
  * Author: BoldGrid
20
  * Author URI: https://www.boldgrid.com/
21
  * License: GPL-2.0+
15
  * Plugin Name: BoldGrid Backup
16
  * Plugin URI: https://www.boldgrid.com/boldgrid-backup/
17
  * Description: BoldGrid Backup provides WordPress backup and restoration with update protection.
18
+ * Version: 1.6.2
19
  * Author: BoldGrid
20
  * Author URI: https://www.boldgrid.com/
21
  * License: GPL-2.0+
cron/cli-support.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Test for support from the command line.
4
+ *
5
+ * @since 1.6.2
6
+ *
7
+ * @see Boldgrid_Backup_Admin_Test::get_cli_support().
8
+ */
9
+
10
+ // Require Boldgrid_Backup_Url_Helper class.
11
+ require dirname( __FILE__ ) . '/url-helper.php';
12
+ $url_helper = new Boldgrid_Backup_Url_Helper();
13
+
14
+ $support = array(
15
+ 'has_curl_ssl' => $url_helper->has_curl_ssl(),
16
+ 'has_url_fopen' => $url_helper->has_url_fopen(),
17
+ );
18
+
19
+ echo json_encode( $support );
cron/run_jobs.php CHANGED
@@ -6,9 +6,9 @@
6
  * @since 1.5.2
7
  *
8
  * @package Boldgrid_Backup
9
- * @copyright BoldGrid.com
10
  * @version $Id$
11
- * @author BoldGrid.com <wpb@boldgrid.com>
12
  */
13
 
14
  // Abort if not being ran from the command line.
@@ -47,10 +47,10 @@ if ( $error ) {
47
  $url = $input['siteurl'] . '/wp-admin/admin-ajax.php?action=boldgrid_backup_run_jobs&id=' .
48
  $input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
49
 
50
- // Sanitize the url.
51
- $url = filter_var( $url, FILTER_SANITIZE_URL );
52
-
53
- $result = file_get_contents( $url );
54
 
55
  if ( false !== $result ) {
56
  $message = $result;
6
  * @since 1.5.2
7
  *
8
  * @package Boldgrid_Backup
9
+ * @copyright BoldGrid
10
  * @version $Id$
11
+ * @author BoldGrid <support@boldgrid.com>
12
  */
13
 
14
  // Abort if not being ran from the command line.
47
  $url = $input['siteurl'] . '/wp-admin/admin-ajax.php?action=boldgrid_backup_run_jobs&id=' .
48
  $input['id'] . '&secret=' . $input['secret'] . '&doing_wp_cron=' . time();
49
 
50
+ // The helper class method will sanitize the url.
51
+ require dirname( __FILE__ ) . '/url-helper.php';
52
+ $url_helper = new Boldgrid_Backup_Url_Helper();
53
+ $result = $url_helper->call_url( $url );
54
 
55
  if ( false !== $result ) {
56
  $message = $result;
cron/url-helper.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * File: url-helper.php
4
+ *
5
+ * @link http://www.boldgrid.com
6
+ * @since 1.6.3
7
+ *
8
+ * @package Boldgrid_Backup
9
+ * @copyright BoldGrid
10
+ * @version $Id$
11
+ * @author BoldGrid <support@boldgrid.com>
12
+ */
13
+
14
+ class Boldgrid_Backup_Url_Helper {
15
+ /**
16
+ * Call a URL address.
17
+ *
18
+ * @since 1.6.3
19
+ *
20
+ * @param string $url
21
+ * @return mixed Returns a string or FALSE on failure to make the call.
22
+ */
23
+ public function call_url( $url ) {
24
+ $result = false;
25
+
26
+ if ( empty( $url ) ) {
27
+ return false;
28
+ }
29
+
30
+ // Sanitize the url.
31
+ $url = filter_var( $url, FILTER_SANITIZE_URL );
32
+
33
+ switch ( true ) {
34
+ case $this->has_curl_ssl() :
35
+ $ch = curl_init( $url );
36
+
37
+ $curl_options = array(
38
+ CURLOPT_FOLLOWLOCATION => true,
39
+ CURLOPT_RETURNTRANSFER => true,
40
+ CURLOPT_SSL_VERIFYPEER => false,
41
+ CURLOPT_SSL_VERIFYHOST => 0,
42
+ CURLOPT_TIMEOUT => 0,
43
+ CURLOPT_USERAGENT => 'BoldGrid Backup cron task',
44
+ );
45
+
46
+ curl_setopt_array( $ch, $curl_options );
47
+
48
+ $result = curl_exec( $ch );
49
+
50
+ if ( curl_errno( $ch ) ) {
51
+ $result = false;
52
+ }
53
+
54
+ curl_close( $ch );
55
+
56
+ break;
57
+
58
+ case $this->has_url_fopen() :
59
+ $result = file_get_contents( $url );
60
+ break;
61
+
62
+ default :
63
+ break;
64
+ }
65
+
66
+ return $result;
67
+ }
68
+
69
+ /**
70
+ * Detect if cURL SSL is available.
71
+ *
72
+ * @since 1.6.3
73
+ *
74
+ * @return bool
75
+ */
76
+ public function has_curl_ssl() {
77
+ $has_curl_ssl = false;
78
+
79
+ if ( function_exists( 'curl_version' ) ) {
80
+ $curl_version = curl_version();
81
+ $has_curl_ssl = (bool) ( $curl_version['features'] & CURL_VERSION_SSL );
82
+ }
83
+
84
+ return $has_curl_ssl;
85
+ }
86
+
87
+ /**
88
+ * Detect if allow_url_fopen is on.
89
+ *
90
+ * @since 1.6.3
91
+ *
92
+ * @return bool
93
+ */
94
+ public function has_url_fopen() {
95
+ return (bool) ini_get( 'allow_url_fopen' );
96
+ }
97
+ }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: boldgrid, backup, restore, migrate, migration
4
  Requires at least: 4.4
5
  Tested up to: 4.9.6
6
  Requires PHP: 5.3
7
- Stable tag: 1.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -28,6 +28,12 @@ WordPress backup and restoration with update protection.
28
 
29
  == Changelog ==
30
 
 
 
 
 
 
 
31
  = 1.6.1 =
32
 
33
  Release Date: May 24th, 2018
4
  Requires at least: 4.4
5
  Tested up to: 4.9.6
6
  Requires PHP: 5.3
7
+ Stable tag: 1.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
28
 
29
  == Changelog ==
30
 
31
+ = 1.6.2 =
32
+
33
+ Release Date: May 25th, 2018
34
+
35
+ * Update: Detect and use available resources to trigger cron tasks. Added cURL support.
36
+
37
  = 1.6.1 =
38
 
39
  Release Date: May 24th, 2018
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitf39823383f9fe9e7b3db616106f32896::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit6bc481f22016af48b669a607eb56454a::getLoader();
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitf39823383f9fe9e7b3db616106f32896
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitf39823383f9fe9e7b3db616106f32896
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitf39823383f9fe9e7b3db616106f32896', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitf39823383f9fe9e7b3db616106f32896', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInitf39823383f9fe9e7b3db616106f32896::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitf39823383f9fe9e7b3db616106f32896
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInitf39823383f9fe9e7b3db616106f32896::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequiref39823383f9fe9e7b3db616106f32896($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequiref39823383f9fe9e7b3db616106f32896($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit6bc481f22016af48b669a607eb56454a
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit6bc481f22016af48b669a607eb56454a', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit6bc481f22016af48b669a607eb56454a', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit6bc481f22016af48b669a607eb56454a::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit6bc481f22016af48b669a607eb56454a::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire6bc481f22016af48b669a607eb56454a($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire6bc481f22016af48b669a607eb56454a($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitf39823383f9fe9e7b3db616106f32896
8
  {
9
  public static $files = array (
10
  'f15d016d70663d5e96ccd2b863511eb8' => __DIR__ . '/..' . '/cbschuld/browser.php/lib/Browser.php',
@@ -44,8 +44,8 @@ class ComposerStaticInitf39823383f9fe9e7b3db616106f32896
44
  public static function getInitializer(ClassLoader $loader)
45
  {
46
  return \Closure::bind(function () use ($loader) {
47
- $loader->prefixLengthsPsr4 = ComposerStaticInitf39823383f9fe9e7b3db616106f32896::$prefixLengthsPsr4;
48
- $loader->prefixDirsPsr4 = ComposerStaticInitf39823383f9fe9e7b3db616106f32896::$prefixDirsPsr4;
49
 
50
  }, null, ClassLoader::class);
51
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit6bc481f22016af48b669a607eb56454a
8
  {
9
  public static $files = array (
10
  'f15d016d70663d5e96ccd2b863511eb8' => __DIR__ . '/..' . '/cbschuld/browser.php/lib/Browser.php',
44
  public static function getInitializer(ClassLoader $loader)
45
  {
46
  return \Closure::bind(function () use ($loader) {
47
+ $loader->prefixLengthsPsr4 = ComposerStaticInit6bc481f22016af48b669a607eb56454a::$prefixLengthsPsr4;
48
+ $loader->prefixDirsPsr4 = ComposerStaticInit6bc481f22016af48b669a607eb56454a::$prefixDirsPsr4;
49
 
50
  }, null, ClassLoader::class);
51
  }