UpdraftPlus WordPress Backup Plugin - Version 1.4.12

Version Description

Important fix for people backing up databases without encryption

Download this release

Release Info

Developer DavidAnderson
Plugin Icon 128x128 UpdraftPlus WordPress Backup Plugin
Version 1.4.12
Comparing to
See all releases

Code changes from version 1.4.11 to 1.4.12

Files changed (3) hide show
  1. methods/googledrive.php +2 -2
  2. options.php +5 -1
  3. updraftplus.php +59 -16
methods/googledrive.php CHANGED
@@ -113,7 +113,7 @@ class UpdraftPlus_BackupModule_googledrive {
113
  // Do we have an access token?
114
  if ( !$access_token = $this->access_token( UpdraftPlus_Options::get_updraft_option('updraft_googledrive_token'), UpdraftPlus_Options::get_updraft_option('updraft_googledrive_clientid'), UpdraftPlus_Options::get_updraft_option('updraft_googledrive_secret') )) {
115
  $updraftplus->log('ERROR: Have not yet obtained an access token from Google (has the user authorised?)');
116
- $updraftplus->error('Have not yet obtained an access token frmo Google - you need to authorise or re-authorise your connection to Google Drive.');
117
  return new WP_Error( "no_access_token", "Have not yet obtained an access token from Google (has the user authorised?");
118
  }
119
 
@@ -360,4 +360,4 @@ class UpdraftPlus_BackupModule_googledrive {
360
 
361
  }
362
 
363
- ?>
113
  // Do we have an access token?
114
  if ( !$access_token = $this->access_token( UpdraftPlus_Options::get_updraft_option('updraft_googledrive_token'), UpdraftPlus_Options::get_updraft_option('updraft_googledrive_clientid'), UpdraftPlus_Options::get_updraft_option('updraft_googledrive_secret') )) {
115
  $updraftplus->log('ERROR: Have not yet obtained an access token from Google (has the user authorised?)');
116
+ $updraftplus->error('Have not yet obtained an access token from Google - you need to authorise or re-authorise your connection to Google Drive.');
117
  return new WP_Error( "no_access_token", "Have not yet obtained an access token from Google (has the user authorised?");
118
  }
119
 
360
 
361
  }
362
 
363
+ ?>
options.php CHANGED
@@ -66,7 +66,11 @@ class UpdraftPlus_Options {
66
  register_setting('updraft-options-group', 'updraft_include_others', 'absint' );
67
  register_setting('updraft-options-group', 'updraft_include_others_exclude' );
68
 
69
- if (is_multisite()) {
 
 
 
 
70
  add_action('admin_notices', array('UpdraftPlus_Options', 'show_admin_warning_multisite') );
71
  }
72
 
66
  register_setting('updraft-options-group', 'updraft_include_others', 'absint' );
67
  register_setting('updraft-options-group', 'updraft_include_others_exclude' );
68
 
69
+ register_setting('updraft-options-group', 'updraft_starttime_files', array($updraftplus, 'hourminute') );
70
+ register_setting('updraft-options-group', 'updraft_starttime_db', array($updraftplus, 'hourminute') );
71
+
72
+ global $pagenow;
73
+ if (is_multisite() && $pagenow == 'options-general.php') {
74
  add_action('admin_notices', array('UpdraftPlus_Options', 'show_admin_warning_multisite') );
75
  }
76
 
updraftplus.php CHANGED
@@ -4,10 +4,10 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Backup and restore: your content and database can be automatically backed up to Amazon S3, Dropbox, Google Drive, FTP or email, on separate schedules.
6
  Author: David Anderson
7
- Version: 1.4.11
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
- Author URI: http://wordshell.net
11
  */
12
 
13
  /*
@@ -30,6 +30,7 @@ TODO
30
  // Expert setting: force PCLZip
31
  // Don't stop at 10 retries if something useful is still measurably being done (in particular, chunked uploads are proceeding - set a flag to indicate "try it again")
32
  // Change FTP to use SSL by default
 
33
  // Tweak random_advert to not show the same one twice
34
  // When looking for files to delete, is the current encryption setting used? Should not be.
35
  // Create single zip, containing even WordPress itself
@@ -81,7 +82,7 @@ if (is_file(UPDRAFTPLUS_DIR.'/premium.php')) require_once(UPDRAFTPLUS_DIR.'/prem
81
 
82
  if ($dir_handle = @opendir(UPDRAFTPLUS_DIR.'/addons')) {
83
  while ($e = readdir($dir_handle)) {
84
- if (is_file(UPDRAFTPLUS_DIR.'/addons/'.$e)) {
85
  include_once(UPDRAFTPLUS_DIR.'/addons/'.$e);
86
  }
87
  }
@@ -218,7 +219,12 @@ class UpdraftPlus {
218
  $this->log("Opened log file at time: ".date('r'));
219
  global $wp_version;
220
  $logline = "UpdraftPlus: ".$this->version." WordPress: ".$wp_version." PHP: ".phpversion()." (".php_uname().") PHP Max Execution Time: ".@ini_get("max_execution_time")." ZipArchive::addFile exists: ";
221
- $logline .= (method_exists('ZipArchive', 'addFile')) ? "Y" : "N";
 
 
 
 
 
222
  $this->log($logline);
223
  }
224
 
@@ -1243,6 +1249,12 @@ class UpdraftPlus {
1243
 
1244
  /*END OF WP-DB-BACKUP BLOCK */
1245
 
 
 
 
 
 
 
1246
  /*
1247
  this function is both the backup scheduler and ostensibly a filter callback for saving the option.
1248
  it is called in the register_setting for the updraft_interval, which means when the admin settings
@@ -1260,7 +1272,8 @@ class UpdraftPlus {
1260
  case 'weekly':
1261
  case 'fortnightly':
1262
  case 'monthly':
1263
- wp_schedule_event(time()+30, $interval, 'updraft_backup');
 
1264
  break;
1265
  }
1266
  return wp_filter_nohtml_kses($interval);
@@ -1286,7 +1299,8 @@ class UpdraftPlus {
1286
  case 'weekly':
1287
  case 'fortnightly':
1288
  case 'monthly':
1289
- wp_schedule_event(time()+30, $interval, 'updraft_backup_database');
 
1290
  break;
1291
  }
1292
  return wp_filter_nohtml_kses($interval);
@@ -1629,7 +1643,7 @@ class UpdraftPlus {
1629
  echo ">$descrip</option>\n";
1630
  }
1631
  ?>
1632
- </select>
1633
  and retain this many backups: <?php
1634
  $updraft_retain = UpdraftPlus_Options::get_updraft_option('updraft_retain', 1);
1635
  $updraft_retain = ((int)$updraft_retain > 0) ? (int)$updraft_retain : 1;
@@ -1646,7 +1660,7 @@ class UpdraftPlus {
1646
  echo ">$descrip</option>\n";
1647
  }
1648
  ?>
1649
- </select>
1650
  and retain this many backups: <?php
1651
  $updraft_retain_db = UpdraftPlus_Options::get_updraft_option('updraft_retain_db', $updraft_retain);
1652
  $updraft_retain_db = ((int)$updraft_retain_db > 0) ? (int)$updraft_retain_db : 1;
@@ -1654,7 +1668,9 @@ class UpdraftPlus {
1654
  </td>
1655
  </tr>
1656
  <tr class="backup-interval-description">
1657
- <td></td><td>If you would like to automatically schedule backups, choose schedules from the dropdowns above. Backups will occur at the intervals specified starting just after the current time. If the two schedules are the same, then the two backups will take place together. If you choose &quot;manual&quot; then you must click the &quot;Backup Now!&quot; button whenever you wish a backup to occur. </td>
 
 
1658
  </tr>
1659
  <?php
1660
  # The true (default value if non-existent) here has the effect of forcing a default of on.
@@ -1896,7 +1912,7 @@ class UpdraftPlus {
1896
  if(isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_all') { $this->boot_backup(true,true); }
1897
  elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_db') { $this->backup_db(); }
1898
  elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_wipesettings') {
1899
- $settings = array('updraft_interval', 'updraft_interval_database', 'updraft_retain', 'updraft_retain_db', 'updraft_encryptionphrase', 'updraft_service', 'updraft_s3_login', 'updraft_s3_pass', 'updraft_s3_remote_path', 'updraft_dropbox_appkey', 'updraft_dropbox_secret', 'updraft_dropbox_folder', 'updraft_googledrive_clientid', 'updraft_googledrive_secret', 'updraft_googledrive_remotepath', 'updraft_ftp_login', 'updraft_ftp_pass', 'updraft_ftp_remote_path', 'updraft_server_address', 'updraft_dir', 'updraft_email', 'updraft_delete_local', 'updraft_debug_mode', 'updraft_include_plugins', 'updraft_include_themes', 'updraft_include_uploads', 'updraft_include_others', 'updraft_include_others_exclude', 'updraft_lastmessage', 'updraft_googledrive_clientid', 'updraft_googledrive_token', 'updraft_dropboxtk_request_token', 'updraft_dropboxtk_access_token', 'updraft_dropbox_folder', 'updraft_last_backup');
1900
  foreach ($settings as $s) {
1901
  UpdraftPlus_Options::delete_updraft_option($s);
1902
  }
@@ -1907,7 +1923,7 @@ class UpdraftPlus {
1907
  <div class="wrap">
1908
  <h1><?php echo $this->plugin_title; ?></h1>
1909
 
1910
- Maintained by <b>David Anderson</b> (<a href="http://updraftplus.com">UpdraftPlus.Com</a> | <a href="http://david.dw-perspective.org.uk">Author Homepage</a> | <?php if (!defined('UPDRAFTPLUS_PREMIUM')) { ?><a href="http://wordshell.net">WordShell - WordPress command line</a> | <a href="http://david.dw-perspective.org.uk/donate">Donate</a><?php } ?> | <a href="http://wordpress.org/extend/plugins/updraftplus/faq/">FAQs</a> | <a href="http://profiles.wordpress.org/davidanderson/">My other WordPress plugins</a>). Version: <?php echo $this->version; ?>
1911
  <br>
1912
  <?php
1913
  if(isset($_GET['updraft_restore_success'])) {
@@ -1949,18 +1965,40 @@ class UpdraftPlus {
1949
  <tr>
1950
  <?php
1951
  $updraft_dir = $this->backups_dir_location();
 
1952
  $next_scheduled_backup = wp_next_scheduled('updraft_backup');
1953
- $next_scheduled_backup = ($next_scheduled_backup) ? date('D, F j, Y H:i T',$next_scheduled_backup) : 'No backups are scheduled at this time.';
 
 
 
 
 
 
 
 
1954
  $next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database');
1955
  if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database',UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) {
1956
  $next_scheduled_backup_database = "Will take place at the same time as the files backup.";
1957
  } else {
1958
- $next_scheduled_backup_database = ($next_scheduled_backup_database) ? date('D, F j, Y H:i T',$next_scheduled_backup_database) : 'No backups are scheduled at this time.';
 
 
 
 
 
 
 
1959
  }
1960
- $current_time = date('D, F j, Y H:i T',time());
1961
  $updraft_last_backup = UpdraftPlus_Options::get_updraft_option('updraft_last_backup');
1962
  if($updraft_last_backup) {
1963
- $last_backup = ($updraft_last_backup['success']) ? date('D, F j, Y H:i T',$updraft_last_backup['backup_time']) : implode("<br>",$updraft_last_backup['errors']);
 
 
 
 
 
 
1964
  $last_backup_color = ($updraft_last_backup['success']) ? 'green' : 'red';
1965
  if (!empty($updraft_last_backup['backup_nonce'])) {
1966
  $potential_log_file = $updraft_dir."/log.".$updraft_last_backup['backup_nonce'].".txt";
@@ -2196,8 +2234,13 @@ class UpdraftPlus {
2196
  // Caution: $source is allowed to be an array, not just a filename
2197
  function make_zipfile($source, $destination) {
2198
 
 
 
 
 
 
2199
  // Fallback to PclZip - which my tests show is 25% slower
2200
- if ($this->zip_preferpcl || !method_exists('ZipArchive', 'addFile')) {
2201
  if(!class_exists('PclZip')) require_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
2202
  $zip_object = new PclZip($destination);
2203
  $zipcode = $zip_object->create($source, PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Backup and restore: your content and database can be automatically backed up to Amazon S3, Dropbox, Google Drive, FTP or email, on separate schedules.
6
  Author: David Anderson
7
+ Version: 1.4.12
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
+ Author URI: http://updraftplus.com
11
  */
12
 
13
  /*
30
  // Expert setting: force PCLZip
31
  // Don't stop at 10 retries if something useful is still measurably being done (in particular, chunked uploads are proceeding - set a flag to indicate "try it again")
32
  // Change FTP to use SSL by default
33
+ // Multisite add-on should allow restoring of each blog individually
34
  // Tweak random_advert to not show the same one twice
35
  // When looking for files to delete, is the current encryption setting used? Should not be.
36
  // Create single zip, containing even WordPress itself
82
 
83
  if ($dir_handle = @opendir(UPDRAFTPLUS_DIR.'/addons')) {
84
  while ($e = readdir($dir_handle)) {
85
+ if (is_file(UPDRAFTPLUS_DIR.'/addons/'.$e) && preg_match('/\.php$/', $e)) {
86
  include_once(UPDRAFTPLUS_DIR.'/addons/'.$e);
87
  }
88
  }
219
  $this->log("Opened log file at time: ".date('r'));
220
  global $wp_version;
221
  $logline = "UpdraftPlus: ".$this->version." WordPress: ".$wp_version." PHP: ".phpversion()." (".php_uname().") PHP Max Execution Time: ".@ini_get("max_execution_time")." ZipArchive::addFile exists: ";
222
+ // method_exists causes some faulty PHP installations to segfault, leading to support requests
223
+ if (version_compare(phpversion(), '5.2.0', '>=') && extension_loaded('zip')) {
224
+ $logline .= 'Y';
225
+ } else {
226
+ $logline .= (method_exists('ZipArchive', 'addFile')) ? "Y" : "N";
227
+ }
228
  $this->log($logline);
229
  }
230
 
1249
 
1250
  /*END OF WP-DB-BACKUP BLOCK */
1251
 
1252
+ function hourminute($pot) {
1253
+ if (preg_match("/^[0-2][0-9]:[0-5][0-9]$/", $pot)) return $pot;
1254
+ if ('' == $pot) return date('H:i', time()+300);
1255
+ return '00:00';
1256
+ }
1257
+
1258
  /*
1259
  this function is both the backup scheduler and ostensibly a filter callback for saving the option.
1260
  it is called in the register_setting for the updraft_interval, which means when the admin settings
1272
  case 'weekly':
1273
  case 'fortnightly':
1274
  case 'monthly':
1275
+ $first_time = apply_filters('updraftplus_schedule_start_files', time()+30);
1276
+ wp_schedule_event($first_time, $interval, 'updraft_backup');
1277
  break;
1278
  }
1279
  return wp_filter_nohtml_kses($interval);
1299
  case 'weekly':
1300
  case 'fortnightly':
1301
  case 'monthly':
1302
+ $first_time = apply_filters('updraftplus_schedule_start_db', time()+30);
1303
+ wp_schedule_event($first_time, $interval, 'updraft_backup_database');
1304
  break;
1305
  }
1306
  return wp_filter_nohtml_kses($interval);
1643
  echo ">$descrip</option>\n";
1644
  }
1645
  ?>
1646
+ </select> <?php echo apply_filters('updraftplus_schedule_showfileconfig', '<input type="hidden" name="updraftplus_starttime_files" value="">'); ?>
1647
  and retain this many backups: <?php
1648
  $updraft_retain = UpdraftPlus_Options::get_updraft_option('updraft_retain', 1);
1649
  $updraft_retain = ((int)$updraft_retain > 0) ? (int)$updraft_retain : 1;
1660
  echo ">$descrip</option>\n";
1661
  }
1662
  ?>
1663
+ </select> <?php echo apply_filters('updraftplus_schedule_showdbconfig', '<input type="hidden" name="updraftplus_starttime_db" value="">'); ?>
1664
  and retain this many backups: <?php
1665
  $updraft_retain_db = UpdraftPlus_Options::get_updraft_option('updraft_retain_db', $updraft_retain);
1666
  $updraft_retain_db = ((int)$updraft_retain_db > 0) ? (int)$updraft_retain_db : 1;
1668
  </td>
1669
  </tr>
1670
  <tr class="backup-interval-description">
1671
+ <td></td><td><p>If you would like to automatically schedule backups, choose schedules from the dropdowns above. Backups will occur at the intervals specified. If the two schedules are the same, then the two backups will take place together. If you choose &quot;manual&quot; then you must click the &quot;Backup Now!&quot; button whenever you wish a backup to occur.</p>
1672
+ <?php echo apply_filters('updraftplus_fixtime_advert', '<p><strong>To fix the time at which a backup should take place, </strong> (e.g. if your server is busy at day and you want to run overnight), <a href="http://updraftplus.com/shop/fix-time/">use the &quot;Fix Time&quot; add-on</a></p>'); ?>
1673
+ </td>
1674
  </tr>
1675
  <?php
1676
  # The true (default value if non-existent) here has the effect of forcing a default of on.
1912
  if(isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_all') { $this->boot_backup(true,true); }
1913
  elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_backup_debug_db') { $this->backup_db(); }
1914
  elseif (isset($_POST['action']) && $_POST['action'] == 'updraft_wipesettings') {
1915
+ $settings = array('updraft_interval', 'updraft_interval_database', 'updraft_retain', 'updraft_retain_db', 'updraft_encryptionphrase', 'updraft_service', 'updraft_s3_login', 'updraft_s3_pass', 'updraft_s3_remote_path', 'updraft_dropbox_appkey', 'updraft_dropbox_secret', 'updraft_dropbox_folder', 'updraft_googledrive_clientid', 'updraft_googledrive_secret', 'updraft_googledrive_remotepath', 'updraft_ftp_login', 'updraft_ftp_pass', 'updraft_ftp_remote_path', 'updraft_server_address', 'updraft_dir', 'updraft_email', 'updraft_delete_local', 'updraft_debug_mode', 'updraft_include_plugins', 'updraft_include_themes', 'updraft_include_uploads', 'updraft_include_others', 'updraft_include_others_exclude', 'updraft_lastmessage', 'updraft_googledrive_clientid', 'updraft_googledrive_token', 'updraft_dropboxtk_request_token', 'updraft_dropboxtk_access_token', 'updraft_dropbox_folder', 'updraft_last_backup', 'updraft_starttime_files', 'updraft_starttime_db');
1916
  foreach ($settings as $s) {
1917
  UpdraftPlus_Options::delete_updraft_option($s);
1918
  }
1923
  <div class="wrap">
1924
  <h1><?php echo $this->plugin_title; ?></h1>
1925
 
1926
+ Maintained by <b>David Anderson</b> (<a href="http://updraftplus.com">UpdraftPlus.Com</a> | <a href="http://david.dw-perspective.org.uk">Author Homepage</a> | <?php if (!defined('UPDRAFTPLUS_PREMIUM')) { ?><a href="http://wordshell.net">WordShell - WordPress command line</a> | <a href="http://david.dw-perspective.org.uk/donate">Donate</a> | <?php } ?><a href="http://wordpress.org/extend/plugins/updraftplus/faq/">FAQs</a> | <a href="http://profiles.wordpress.org/davidanderson/">My other WordPress plugins</a>). Version: <?php echo $this->version; ?>
1927
  <br>
1928
  <?php
1929
  if(isset($_GET['updraft_restore_success'])) {
1965
  <tr>
1966
  <?php
1967
  $updraft_dir = $this->backups_dir_location();
1968
+ // UNIX timestamp
1969
  $next_scheduled_backup = wp_next_scheduled('updraft_backup');
1970
+ if ($next_scheduled_backup) {
1971
+ // Convert to GMT
1972
+ $next_scheduled_backup_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup);
1973
+ // Convert to blog time zone
1974
+ $next_scheduled_backup = get_date_from_gmt($next_scheduled_backup_gmt, 'D, F j, Y H:i T');
1975
+ } else {
1976
+ $next_scheduled_backup = 'No backups are scheduled at this time.';
1977
+ }
1978
+
1979
  $next_scheduled_backup_database = wp_next_scheduled('updraft_backup_database');
1980
  if (UpdraftPlus_Options::get_updraft_option('updraft_interval_database',UpdraftPlus_Options::get_updraft_option('updraft_interval')) == UpdraftPlus_Options::get_updraft_option('updraft_interval')) {
1981
  $next_scheduled_backup_database = "Will take place at the same time as the files backup.";
1982
  } else {
1983
+ if ($next_scheduled_backup_database) {
1984
+ // Convert to GMT
1985
+ $next_scheduled_backup_database_gmt = gmdate('Y-m-d H:i:s', $next_scheduled_backup_database);
1986
+ // Convert to blog time zone
1987
+ $next_scheduled_backup_database = get_date_from_gmt($next_scheduled_backup_database_gmt, 'D, F j, Y H:i T');
1988
+ } else {
1989
+ $next_scheduled_backup_database = 'No backups are scheduled at this time.';
1990
+ }
1991
  }
1992
+ $current_time = get_date_from_gmt(gmdate('Y-m-d H:i:s'), 'D, F j, Y H:i T');
1993
  $updraft_last_backup = UpdraftPlus_Options::get_updraft_option('updraft_last_backup');
1994
  if($updraft_last_backup) {
1995
+ if ($updraft_last_backup['success']) {
1996
+ // Convert to GMT, then to blog time
1997
+ $last_backup = get_date_from_gmt(gmdate('Y-m-d H:i:s', $updraft_last_backup['backup_time']), 'D, F j, Y H:i T');
1998
+ } else {
1999
+ $last_backup = implode("<br>",$updraft_last_backup['errors']);
2000
+ }
2001
+
2002
  $last_backup_color = ($updraft_last_backup['success']) ? 'green' : 'red';
2003
  if (!empty($updraft_last_backup['backup_nonce'])) {
2004
  $potential_log_file = $updraft_dir."/log.".$updraft_last_backup['backup_nonce'].".txt";
2234
  // Caution: $source is allowed to be an array, not just a filename
2235
  function make_zipfile($source, $destination) {
2236
 
2237
+ // When to prefer PCL:
2238
+ // - We were asked to
2239
+ // - No zip extension present and no relevant method present
2240
+ // The zip extension check is not redundant, because method_exists segfaults some PHP installs, leading to support requests
2241
+
2242
  // Fallback to PclZip - which my tests show is 25% slower
2243
+ if ($this->zip_preferpcl || (!extension_loaded('zip') && !method_exists('ZipArchive', 'AddFile'))) {
2244
  if(!class_exists('PclZip')) require_once(ABSPATH.'/wp-admin/includes/class-pclzip.php');
2245
  $zip_object = new PclZip($destination);
2246
  $zipcode = $zip_object->create($source, PCLZIP_OPT_REMOVE_PATH, WP_CONTENT_DIR);