UpdraftPlus WordPress Backup Plugin - Version 1.0.10

Version Description

  • 12/22/2012 =
  • Fixed bug that set 1Tb (instead of 1Mb) chunk sizes for Google Drive uploads
  • Added link to some screenshots to help with Google Drive setup
  • Allowed use of existing Amazon S3 buckets with restrictive policies (previously, we tested for the bucket's existence by running a create operation on it, which may not be permitted)
  • Use CURL instead of native PHP for Google Drive HTTP interactions
Download this release

Release Info

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

Code changes from version 1.0.8 to 1.0.10

Files changed (2) hide show
  1. readme.txt +11 -3
  2. updraftplus.php +45 -19
readme.txt CHANGED
@@ -8,7 +8,7 @@ Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
10
  == Upgrade Notice ==
11
- Fixed bug with Google Drive uploads
12
 
13
  == Description ==
14
 
@@ -43,7 +43,13 @@ That's very good of you, thank you. You are looking for WordShell, <a href="http
43
 
44
  = I found a bug. What do I do? =
45
 
46
- Contact me! This is a complex plugin and the only way I can ensure it's robust is to get bug reports and fix the problems that crop up. Please turn on debugging mode (in the UpdraftPlus options page) and then try again, and after that send me the log if you can find it (it is in the directory wp-content/updraft, so FTP in and look for it there). If you cannot find the log, then I may not be able to help, but you can try - include as much information as you can when reporting (PHP version, your blog's site, the error you saw and how you got to the page that caused it, etcetera). If you can send a patch, that's even better. Finally, if you post in the WordPress support forum, then make sure you include the word UpdraftPlus in your post; otherwise I will not be automatically notified that you posted.
 
 
 
 
 
 
47
 
48
  = Some of my files have uploaded into my cloud storage, but not others. =
49
 
@@ -81,9 +87,11 @@ No, there's no warranty or guarantee, etc. It's completely up to you to verify t
81
 
82
  == Changelog ==
83
 
84
- = 1.0.8 - 12/20/2012 =
85
  * Fixed bug that set 1Tb (instead of 1Mb) chunk sizes for Google Drive uploads
86
  * Added link to some screenshots to help with Google Drive setup
 
 
87
 
88
  = 1.0.5 - 12/13/2012 =
89
  * Tweaked default Google Drive options
8
  License: GPLv3 or later
9
 
10
  == Upgrade Notice ==
11
+ Allowed use of existing Amazon S3 buckets with more restrictive policies
12
 
13
  == Description ==
14
 
43
 
44
  = I found a bug. What do I do? =
45
 
46
+ Contact me! This is a complex plugin and the only way I can ensure it's robust is to get bug reports and fix the problems that crop up. Please make sure you are using the latest version of the plugin, and that you include the version in your bug report - if you are not using the latest, then the first thing you will be asked to do is upgrade.
47
+
48
+ Please turn on debugging mode (in the UpdraftPlus options page) and then try again, and after that send me the log if you can find it (it is in the directory wp-content/updraft, so FTP in and look for it there). If you cannot find the log, then I may not be able to help, but you can try - include as much information as you can when reporting (PHP version, your blog's site, the error you saw and how you got to the page that caused it, etcetera).
49
+
50
+ If you can send a patch, that's even better.
51
+
52
+ Finally, if you post in the WordPress support forum, then make sure you include the word UpdraftPlus in your post; otherwise I will not be automatically notified that you posted.
53
 
54
  = Some of my files have uploaded into my cloud storage, but not others. =
55
 
87
 
88
  == Changelog ==
89
 
90
+ = 1.0.10 - 12/22/2012 =
91
  * Fixed bug that set 1Tb (instead of 1Mb) chunk sizes for Google Drive uploads
92
  * Added link to some screenshots to help with Google Drive setup
93
+ * Allowed use of existing Amazon S3 buckets with restrictive policies (previously, we tested for the bucket's existence by running a create operation on it, which may not be permitted)
94
+ * Use CURL instead of native PHP for Google Drive HTTP interactions
95
 
96
  = 1.0.5 - 12/13/2012 =
97
  * Tweaked default Google Drive options
updraftplus.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Uploads, themes, plugins, and your DB can be automatically backed up to Amazon S3, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
- Version: 1.0.8
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
@@ -60,7 +60,7 @@ define('UPDRAFT_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,index.php');
60
 
61
  class UpdraftPlus {
62
 
63
- var $version = '1.0.8';
64
 
65
  var $dbhandle;
66
  var $errors = array();
@@ -136,7 +136,7 @@ class UpdraftPlus {
136
  )
137
  );
138
  $this->log("Google Drive: requesting access token: client_id=$client_id");
139
- $result = @file_get_contents('https://accounts.google.com/o/oauth2/token', false, stream_context_create($context));
140
  if($result) {
141
  $result = json_decode( $result, true );
142
  if ( isset( $result['access_token'] ) ) {
@@ -172,6 +172,36 @@ class UpdraftPlus {
172
  return;
173
  }
174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  /**
176
  * Get a Google account refresh token using the code received from gdrive_auth_request
177
  */
@@ -191,13 +221,7 @@ class UpdraftPlus {
191
  ) )
192
  )
193
  );
194
- // TODO Use curl??
195
- $result = @file_get_contents('https://accounts.google.com/o/oauth2/token', false, stream_context_create($context));
196
- # Oddly, sometimes fails and then trying again works...
197
- /*
198
- if (!$result) { sleep(1); $result = @file_get_contents('https://accounts.google.com/o/oauth2/token', false, stream_context_create($context));}
199
- if (!$result) { sleep(1); $result = @file_get_contents('https://accounts.google.com/o/oauth2/token', false, stream_context_create($context));}
200
- */
201
  if($result) {
202
  $result = json_decode( $result, true );
203
  if ( isset( $result['refresh_token'] ) ) {
@@ -220,9 +244,9 @@ class UpdraftPlus {
220
  * Revoke a Google account refresh token
221
  */
222
  function gdrive_auth_revoke() {
223
- @file_get_contents( 'https://accounts.google.com/o/oauth2/revoke?token=' . get_option('updraft_googledrive_token') );
224
  update_option('updraft_googledrive_token','');
225
- header( 'Location: '.admin_url( 'options-general.php?page=updraftplus&message=' . __( 'Authorization revoked.', 'backup' ) ) );
226
  }
227
 
228
  # Adds the settings link under the plugin on the plugin screen.
@@ -637,7 +661,8 @@ class UpdraftPlus {
637
  $bucket_path = $bmatches[2]."/";
638
  }
639
 
640
- if (@$s3->putBucket($bucket_name, S3::ACL_PRIVATE)) {
 
641
 
642
  foreach($backup_array as $file) {
643
 
@@ -1541,7 +1566,7 @@ class UpdraftPlus {
1541
  $bucket_name = $bmatches[1];
1542
  $bucket_path = $bmatches[2]."/";
1543
  }
1544
- if (@$s3->putBucket($bucket_name, S3::ACL_PRIVATE)) {
1545
  $fullpath = trailingslashit(get_option('updraft_dir')).$file;
1546
  if (!$s3->getObject($bucket_name, $bucket_path.$file, $fullpath)) {
1547
  $this->error("S3 Error: Failed to download $fullpath. Error was ".$php_errormsg);
@@ -1769,9 +1794,10 @@ class UpdraftPlus {
1769
  function wordshell_random_advert($urls) {
1770
  $url_start = ($urls) ? '<a href="http://wordshell.net">' : "";
1771
  $url_end = ($urls) ? '</a>' : " (www.wordshell.net)";
1772
- if (rand(0,1) == 0) {
 
1773
  return "Like automating WordPress operations? Use the CLI? ${url_start}You will love WordShell${url_end} - saves time and money fast.";
1774
- } else {
1775
  return "${url_start}Check out WordShell${url_end} - manage WordPress from the command line - huge time-saver";
1776
  }
1777
  }
@@ -1950,7 +1976,7 @@ ENDHERE;
1950
  <div style="float:left; width:200px; padding-top: 100px;">
1951
  <form method="post" action="">
1952
  <input type="hidden" name="action" value="updraft_backup" />
1953
- <p><input type="submit" <?php echo $backup_disabled ?> class="button-primary" value="Backup Now!" style="padding-top:7px;padding-bottom:7px;font-size:24px !important" onclick="return(confirm('This will schedule a one-time backup. To trigger the backup immediately you may need to load a page on your site.'))" /></p>
1954
  </form>
1955
  <div style="position:relative">
1956
  <div style="position:absolute;top:0;left:0">
@@ -1986,7 +2012,7 @@ ENDHERE;
1986
  </tr>
1987
  <tr>
1988
  <td></td><td class="download-backups" style="display:none">
1989
- <em>Click on a button to download the corresponding file to your computer. If you are using Opera, you should turn Turbo mode off.</em>
1990
  <table>
1991
  <?php
1992
  foreach($backup_history as $key=>$value) {
@@ -2210,7 +2236,7 @@ echo $delete_local; ?> /> <br>Check this to delete the local backup file (only s
2210
  </tr>
2211
  <tr class="s3" <?php echo $s3_display?>>
2212
  <th></th>
2213
- <td><p>Get your access key and secret key from your AWS page, then pick a (globally unique) bucket name (letters and numbers) (and optionally a path) to use for storage.</p></td>
2214
  </tr>
2215
 
2216
  <!-- Google Drive -->
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Uploads, themes, plugins, and your DB can be automatically backed up to Amazon S3, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
+ Version: 1.0.10
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
60
 
61
  class UpdraftPlus {
62
 
63
+ var $version = '1.0.10';
64
 
65
  var $dbhandle;
66
  var $errors = array();
136
  )
137
  );
138
  $this->log("Google Drive: requesting access token: client_id=$client_id");
139
+ $result = $this->http_post('https://accounts.google.com/o/oauth2/token', $context);
140
  if($result) {
141
  $result = json_decode( $result, true );
142
  if ( isset( $result['access_token'] ) ) {
172
  return;
173
  }
174
 
175
+ function http_get($url) {
176
+ if (function_exists('curl_init')) {
177
+ $ch = curl_init();
178
+ curl_setopt($ch, CURLOPT_URL, $url);
179
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
180
+ $output = curl_exec($ch);
181
+ curl_close($ch);
182
+ return $output;
183
+ } elseif (function_exists('http_get')) {
184
+ return http_get($url);
185
+ } else {
186
+ return @file_get_contents($url);
187
+ }
188
+ }
189
+
190
+ function http_post($url,$options) {
191
+ if (function_exists('curl_init')) {
192
+ $ch = curl_init();
193
+ curl_setopt($ch, CURLOPT_URL, $url);
194
+ curl_setopt($ch, CURLOPT_POST, 1);
195
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $options['http']['content']);
196
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
197
+ $output = curl_exec($ch);
198
+ curl_close($ch);
199
+ return $output;
200
+ } else {
201
+ return @file_get_contents($url, false, stream_context_create($options));
202
+ }
203
+ }
204
+
205
  /**
206
  * Get a Google account refresh token using the code received from gdrive_auth_request
207
  */
221
  ) )
222
  )
223
  );
224
+ $result = $this->http_post('https://accounts.google.com/o/oauth2/token', $context);
 
 
 
 
 
 
225
  if($result) {
226
  $result = json_decode( $result, true );
227
  if ( isset( $result['refresh_token'] ) ) {
244
  * Revoke a Google account refresh token
245
  */
246
  function gdrive_auth_revoke() {
247
+ $ignore = $this->http_get('https://accounts.google.com/o/oauth2/revoke?token='.get_option('updraft_googledrive_token'));
248
  update_option('updraft_googledrive_token','');
249
+ header('Location: '.admin_url( 'options-general.php?page=updraftplus&message=Authorisation revoked'));
250
  }
251
 
252
  # Adds the settings link under the plugin on the plugin screen.
661
  $bucket_path = $bmatches[2]."/";
662
  }
663
 
664
+ // See if we can detect the region (which implies the bucket exists and is ours), or if not create it
665
+ if (@$s3->getBucketLocation($bucket_name) || @$s3->putBucket($bucket_name, S3::ACL_PRIVATE)) {
666
 
667
  foreach($backup_array as $file) {
668
 
1566
  $bucket_name = $bmatches[1];
1567
  $bucket_path = $bmatches[2]."/";
1568
  }
1569
+ if (@$s3->getBucketLocation($bucket_name)) {
1570
  $fullpath = trailingslashit(get_option('updraft_dir')).$file;
1571
  if (!$s3->getObject($bucket_name, $bucket_path.$file, $fullpath)) {
1572
  $this->error("S3 Error: Failed to download $fullpath. Error was ".$php_errormsg);
1794
  function wordshell_random_advert($urls) {
1795
  $url_start = ($urls) ? '<a href="http://wordshell.net">' : "";
1796
  $url_end = ($urls) ? '</a>' : " (www.wordshell.net)";
1797
+ $rad = rand(0,1);
1798
+ if ($rad == 0) {
1799
  return "Like automating WordPress operations? Use the CLI? ${url_start}You will love WordShell${url_end} - saves time and money fast.";
1800
+ } elseif ($rad == 1) {
1801
  return "${url_start}Check out WordShell${url_end} - manage WordPress from the command line - huge time-saver";
1802
  }
1803
  }
1976
  <div style="float:left; width:200px; padding-top: 100px;">
1977
  <form method="post" action="">
1978
  <input type="hidden" name="action" value="updraft_backup" />
1979
+ <p><input type="submit" <?php echo $backup_disabled ?> class="button-primary" value="Backup Now!" style="padding-top:7px;padding-bottom:7px;font-size:24px !important" onclick="return(confirm('This will schedule a one-time backup. To trigger the backup you should go ahead, then wait 10 seconds, then load a page on your site.'))" /></p>
1980
  </form>
1981
  <div style="position:relative">
1982
  <div style="position:absolute;top:0;left:0">
2012
  </tr>
2013
  <tr>
2014
  <td></td><td class="download-backups" style="display:none">
2015
+ <em>Click on a button to download the corresponding file to your computer. If you are using the <a href="http://opera.com">Opera web browser</a> then you should turn Turbo mode off.</em>
2016
  <table>
2017
  <?php
2018
  foreach($backup_history as $key=>$value) {
2236
  </tr>
2237
  <tr class="s3" <?php echo $s3_display?>>
2238
  <th></th>
2239
+ <td><p>Get your access key and secret key from your AWS page, then pick a (globally unique) bucket name (letters and numbers) (and optionally a path) to use for storage. This bucket will be created for you if it does not already exist.</p></td>
2240
  </tr>
2241
 
2242
  <!-- Google Drive -->