UpdraftPlus WordPress Backup Plugin - Version 1.2.4

Version Description

DropBox support

Download this release

Release Info

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

Code changes from version 1.2.3 to 1.2.4

includes/Dropbox/API.php CHANGED
@@ -8,9 +8,7 @@
8
  * @link https://status.dropbox.com Dropbox status
9
  * @package Dropbox
10
  */
11
- namespace Dropbox;
12
-
13
- class API
14
  {
15
  // API Endpoints
16
  const API_URL = 'https://api.dropbox.com/1/';
@@ -54,7 +52,7 @@ class API
54
  * @param OAuth\Consumer\ConsumerAbstract $OAuth
55
  * @param string $root Dropbox app access type
56
  */
57
- public function __construct(OAuth\Consumer\ConsumerAbstract $OAuth, $root = 'sandbox')
58
  {
59
  $this->OAuth = $OAuth;
60
  $this->setRoot($root);
8
  * @link https://status.dropbox.com Dropbox status
9
  * @package Dropbox
10
  */
11
+ class Dropbox_API
 
 
12
  {
13
  // API Endpoints
14
  const API_URL = 'https://api.dropbox.com/1/';
52
  * @param OAuth\Consumer\ConsumerAbstract $OAuth
53
  * @param string $root Dropbox app access type
54
  */
55
+ public function __construct(Dropbox_ConsumerAbstract $OAuth, $root = 'sandbox')
56
  {
57
  $this->OAuth = $OAuth;
58
  $this->setRoot($root);
includes/Dropbox/Exception.php CHANGED
@@ -6,9 +6,7 @@
6
  * @link https://github.com/benthedesigner/dropbox
7
  * @package Dropbox
8
  */
9
- namespace Dropbox;
10
-
11
- class Exception extends \Exception
12
  {
13
 
14
  }
6
  * @link https://github.com/benthedesigner/dropbox
7
  * @package Dropbox
8
  */
9
+ class Dropbox_Exception extends Exception
 
 
10
  {
11
 
12
  }
includes/Dropbox/OAuth/Consumer/ConsumerAbstract.php CHANGED
@@ -7,10 +7,8 @@
7
  * @package Dropbox\OAuth
8
  * @subpackage Consumer
9
  */
10
- namespace Dropbox\OAuth\Consumer;
11
- use \Dropbox\API as API;
12
 
13
- abstract class ConsumerAbstract
14
  {
15
  // Dropbox web endpoint
16
  const WEB_URL = 'https://www.dropbox.com/1/';
@@ -48,7 +46,7 @@ abstract class ConsumerAbstract
48
  if ((!$this->storage->get('access_token'))) {
49
  try {
50
  $this->getAccessToken();
51
- } catch(\Dropbox\Exception $e) {
52
  $this->getRequestToken();
53
  $this->authorise();
54
  }
@@ -64,7 +62,7 @@ abstract class ConsumerAbstract
64
  {
65
  // Nullify any request token we already have
66
  $this->storage->set(null, 'request_token');
67
- $url = API::API_URL . self::REQUEST_TOKEN_METHOD;
68
  $response = $this->fetch('POST', $url, '');
69
  $token = $this->parseTokenString($response['body']);
70
  $this->storage->set($token, 'request_token');
@@ -243,7 +241,7 @@ abstract class ConsumerAbstract
243
  $this->sigMethod = $method;
244
  break;
245
  default:
246
- throw new \Dropbox\Exception('Unsupported signature method ' . $method);
247
  }
248
  }
249
 
@@ -255,7 +253,7 @@ abstract class ConsumerAbstract
255
  public function setOutFile($handle)
256
  {
257
  if (!is_resource($handle) || get_resource_type($handle) != 'stream') {
258
- throw new \Dropbox\Exception('Outfile must be a stream resource');
259
  }
260
  $this->outFile = $handle;
261
  }
@@ -268,7 +266,7 @@ abstract class ConsumerAbstract
268
  public function setInFile($handle)
269
  {
270
  if (!is_resource($handle) || get_resource_type($handle) != 'stream') {
271
- throw new \Dropbox\Exception('Infile must be a stream resource');
272
  }
273
  fseek($handle, 0);
274
  $this->inFile = $handle;
7
  * @package Dropbox\OAuth
8
  * @subpackage Consumer
9
  */
 
 
10
 
11
+ abstract class Dropbox_ConsumerAbstract
12
  {
13
  // Dropbox web endpoint
14
  const WEB_URL = 'https://www.dropbox.com/1/';
46
  if ((!$this->storage->get('access_token'))) {
47
  try {
48
  $this->getAccessToken();
49
+ } catch(Dropbox_Exception $e) {
50
  $this->getRequestToken();
51
  $this->authorise();
52
  }
62
  {
63
  // Nullify any request token we already have
64
  $this->storage->set(null, 'request_token');
65
+ $url = Dropbox_API::API_URL . self::REQUEST_TOKEN_METHOD;
66
  $response = $this->fetch('POST', $url, '');
67
  $token = $this->parseTokenString($response['body']);
68
  $this->storage->set($token, 'request_token');
241
  $this->sigMethod = $method;
242
  break;
243
  default:
244
+ throw new Dropbox_Exception('Unsupported signature method ' . $method);
245
  }
246
  }
247
 
253
  public function setOutFile($handle)
254
  {
255
  if (!is_resource($handle) || get_resource_type($handle) != 'stream') {
256
+ throw new Dropbox_Exception('Outfile must be a stream resource');
257
  }
258
  $this->outFile = $handle;
259
  }
266
  public function setInFile($handle)
267
  {
268
  if (!is_resource($handle) || get_resource_type($handle) != 'stream') {
269
+ throw new Dropbox_Exception('Infile must be a stream resource');
270
  }
271
  fseek($handle, 0);
272
  $this->inFile = $handle;
includes/Dropbox/OAuth/Consumer/Curl.php CHANGED
@@ -7,11 +7,8 @@
7
  * @package Dropbox\OAuth
8
  * @subpackage Consumer
9
  */
10
- namespace Dropbox\OAuth\Consumer;
11
- use Dropbox\API as API;
12
- use Dropbox\OAuth\Storage\StorageInterface as StorageInterface;
13
 
14
- class Curl extends ConsumerAbstract
15
  {
16
  /**
17
  * Default cURL options
@@ -33,11 +30,11 @@ class Curl extends ConsumerAbstract
33
  * @param \Dropbox\OAuth\Consumer\StorageInterface $storage
34
  * @param string $callback
35
  */
36
- public function __construct($key, $secret, StorageInterface $storage, $callback = null)
37
  {
38
  // Check the cURL extension is loaded
39
  if (!extension_loaded('curl')) {
40
- throw new \Dropbox\Exception('The cURL OAuth consumer requires the cURL extension');
41
  }
42
 
43
  $this->consumerKey = $key;
@@ -101,7 +98,7 @@ class Curl extends ConsumerAbstract
101
  // Check if an error occurred and throw an Exception
102
  if (!empty($response['body']->error)) {
103
  $message = $response['body']->error . ' (Status Code: ' . $response['code'] . ')';
104
- throw new \Dropbox\Exception($message);
105
  }
106
 
107
  return $response;
7
  * @package Dropbox\OAuth
8
  * @subpackage Consumer
9
  */
 
 
 
10
 
11
+ class Dropbox_Curl extends Dropbox_ConsumerAbstract
12
  {
13
  /**
14
  * Default cURL options
30
  * @param \Dropbox\OAuth\Consumer\StorageInterface $storage
31
  * @param string $callback
32
  */
33
+ public function __construct($key, $secret, Dropbox_StorageInterface $storage, $callback = null)
34
  {
35
  // Check the cURL extension is loaded
36
  if (!extension_loaded('curl')) {
37
+ throw new Dropbox_Exception('The cURL OAuth consumer requires the cURL extension');
38
  }
39
 
40
  $this->consumerKey = $key;
98
  // Check if an error occurred and throw an Exception
99
  if (!empty($response['body']->error)) {
100
  $message = $response['body']->error . ' (Status Code: ' . $response['code'] . ')';
101
+ throw new Dropbox_Exception($message);
102
  }
103
 
104
  return $response;
includes/Dropbox/OAuth/Storage/Encrypter.php CHANGED
@@ -8,9 +8,8 @@
8
  * @package Dropbox\Oauth
9
  * @subpackage Storage
10
  */
11
- namespace Dropbox\OAuth\Storage;
12
 
13
- class Encrypter
14
  {
15
  // Encryption settings - default settings yield encryption to AES (256-bit) standard
16
  // @todo Provide PHPDOC for each class constant
@@ -34,9 +33,9 @@ class Encrypter
34
  public function __construct($key)
35
  {
36
  if (!extension_loaded('mcrypt')) {
37
- throw new \Dropbox\Exception('The storage encrypter requires the MCrypt extension');
38
  } elseif (($length = mb_strlen($key, '8bit')) !== self::KEY_SIZE) {
39
- throw new \Dropbox\Exception('Expecting a ' . self::KEY_SIZE . ' byte key, got ' . $length);
40
  } else {
41
  // Set the encryption key
42
  $this->key = $key;
8
  * @package Dropbox\Oauth
9
  * @subpackage Storage
10
  */
 
11
 
12
+ class Dropbox_Encrypter
13
  {
14
  // Encryption settings - default settings yield encryption to AES (256-bit) standard
15
  // @todo Provide PHPDOC for each class constant
33
  public function __construct($key)
34
  {
35
  if (!extension_loaded('mcrypt')) {
36
+ throw new Dropbox_Exception('The storage encrypter requires the MCrypt extension');
37
  } elseif (($length = mb_strlen($key, '8bit')) !== self::KEY_SIZE) {
38
+ throw new Dropbox_Exception('Expecting a ' . self::KEY_SIZE . ' byte key, got ' . $length);
39
  } else {
40
  // Set the encryption key
41
  $this->key = $key;
includes/Dropbox/OAuth/Storage/WordPress.php CHANGED
@@ -9,9 +9,8 @@
9
  * @package Dropbox\Oauth
10
  * @subpackage Storage
11
  */
12
- namespace Dropbox\OAuth\Storage;
13
 
14
- class WordPress implements StorageInterface
15
  {
16
  /**
17
  * Option name
@@ -29,9 +28,9 @@ class WordPress implements StorageInterface
29
  * Check if an instance of the encrypter is passed, set the encryption object
30
  * @return void
31
  */
32
- public function __construct(Encrypter $encrypter = null, $option_name_prefix = 'dropbox_token')
33
  {
34
- if ($encrypter instanceof Encrypter) {
35
  $this->encrypter = $encrypter;
36
  }
37
 
@@ -99,7 +98,7 @@ class WordPress implements StorageInterface
99
  $token = serialize($token);
100
 
101
  // Encrypt the token if there is an Encrypter instance
102
- if ($this->encrypter instanceof Encrypter) {
103
  $token = $this->encrypter->encrypt($token);
104
  }
105
 
@@ -117,7 +116,7 @@ class WordPress implements StorageInterface
117
  protected function decrypt($token)
118
  {
119
  // Decrypt the token if there is an Encrypter instance
120
- if ($this->encrypter instanceof Encrypter) {
121
  $token = $this->encrypter->decrypt($token);
122
  }
123
 
9
  * @package Dropbox\Oauth
10
  * @subpackage Storage
11
  */
 
12
 
13
+ class Dropbox_WordPress implements Dropbox_StorageInterface
14
  {
15
  /**
16
  * Option name
28
  * Check if an instance of the encrypter is passed, set the encryption object
29
  * @return void
30
  */
31
+ public function __construct(Dropbox_Encrypter $encrypter = null, $option_name_prefix = 'dropbox_token')
32
  {
33
+ if ($encrypter instanceof Dropbox_Encrypter) {
34
  $this->encrypter = $encrypter;
35
  }
36
 
98
  $token = serialize($token);
99
 
100
  // Encrypt the token if there is an Encrypter instance
101
+ if ($this->encrypter instanceof Dropbox_Encrypter) {
102
  $token = $this->encrypter->encrypt($token);
103
  }
104
 
116
  protected function decrypt($token)
117
  {
118
  // Decrypt the token if there is an Encrypter instance
119
+ if ($this->encrypter instanceof Dropbox_Encrypter) {
120
  $token = $this->encrypter->decrypt($token);
121
  }
122
 
methods/dropbox.php CHANGED
@@ -8,7 +8,7 @@ class UpdraftPlus_BackupModule_dropbox {
8
 
9
  global $updraftplus;
10
  $updraftplus->log("DropBox: begin cloud upload");
11
- if (!class_exists("DropBox\\API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
12
 
13
  if (!get_option('updraft_dropbox_appkey') || get_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') {
14
  $updraftplus->log('You do not appear to be authenticated with DropBox');
@@ -60,7 +60,7 @@ class UpdraftPlus_BackupModule_dropbox {
60
 
61
  global $updraftplus;
62
  $updraftplus->log("DropBox: request deletion: $file");
63
- if (!class_exists("DropBox\\API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
64
 
65
  if (!get_option('updraft_dropbox_appkey') || get_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') {
66
  $updraftplus->log('You do not appear to be authenticated with DropBox');
@@ -95,7 +95,7 @@ class UpdraftPlus_BackupModule_dropbox {
95
 
96
  global $updraftplus;
97
 
98
- if (!class_exists("DropBox\\API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
99
 
100
  if (!get_option('updraft_dropbox_appkey') || get_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') {
101
  $updraftplus->error('You do not appear to be authenticated with DropBox');
@@ -257,20 +257,21 @@ class UpdraftPlus_BackupModule_dropbox {
257
  // This basically reproduces the relevant bits of bootstrap.php from the SDK
258
  function bootstrap($key, $secret) {
259
 
260
- // Register a simple autoload function
261
- spl_autoload_register('updraftplus_dropbox_autoloader');
 
262
 
263
  // Set the callback URL
264
  $callback = admin_url('options-general.php?page=updraftplus&action=updraftmethod-dropbox-auth');
265
 
266
  // Instantiate the Encrypter and storage objects
267
- $encrypter = new \Dropbox\OAuth\Storage\Encrypter('ThisOneDoesNotMatterBeyondLength');
268
 
269
  // Instantiate the storage
270
- $storage = new \Dropbox\OAuth\Storage\WordPress($encrypter, "updraft_dropboxtk_");
271
 
272
- $OAuth = new \Dropbox\OAuth\Consumer\Curl($key, $secret, $storage, $callback);
273
- return new \Dropbox\API($OAuth);
274
  }
275
 
276
  function credentials_test() {
@@ -292,7 +293,7 @@ class UpdraftPlus_BackupModule_dropbox {
292
  return;
293
  }
294
 
295
- if (!class_exists("DropBox\\API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
296
 
297
  echo "Not yet implemented. $key $secret $folder";
298
 
@@ -305,9 +306,3 @@ class UpdraftPlus_BackupModule_dropbox {
305
  }
306
 
307
  }
308
-
309
- function updraftplus_dropbox_autoloader($class) {
310
- $class = str_replace('\\', '/', $class);
311
- $try_file = UPDRAFTPLUS_DIR.'/includes/' . $class . '.php';
312
- if (file_exists($try_file)) include_once($try_file);
313
- }
8
 
9
  global $updraftplus;
10
  $updraftplus->log("DropBox: begin cloud upload");
11
+ if (!class_exists("DropBox_API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
12
 
13
  if (!get_option('updraft_dropbox_appkey') || get_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') {
14
  $updraftplus->log('You do not appear to be authenticated with DropBox');
60
 
61
  global $updraftplus;
62
  $updraftplus->log("DropBox: request deletion: $file");
63
+ if (!class_exists("DropBox_API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
64
 
65
  if (!get_option('updraft_dropbox_appkey') || get_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') {
66
  $updraftplus->log('You do not appear to be authenticated with DropBox');
95
 
96
  global $updraftplus;
97
 
98
+ if (!class_exists("DropBox_API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
99
 
100
  if (!get_option('updraft_dropbox_appkey') || get_option('updraft_dropboxtk_request_token', 'xyz') == 'xyz') {
101
  $updraftplus->error('You do not appear to be authenticated with DropBox');
257
  // This basically reproduces the relevant bits of bootstrap.php from the SDK
258
  function bootstrap($key, $secret) {
259
 
260
+ require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Storage/Encrypter.php')
261
+ require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Storage/WordPress.php')
262
+ require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Consumer/Curl.php')
263
 
264
  // Set the callback URL
265
  $callback = admin_url('options-general.php?page=updraftplus&action=updraftmethod-dropbox-auth');
266
 
267
  // Instantiate the Encrypter and storage objects
268
+ $encrypter = new Dropbox_Encrypter('ThisOneDoesNotMatterBeyondLength');
269
 
270
  // Instantiate the storage
271
+ $storage = new Dropbox_WordPress($encrypter, "updraft_dropboxtk_");
272
 
273
+ $OAuth = new Dropbox_Curl($key, $secret, $storage, $callback);
274
+ return new Dropbox_API($OAuth);
275
  }
276
 
277
  function credentials_test() {
293
  return;
294
  }
295
 
296
+ if (!class_exists("DropBox_API")) require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
297
 
298
  echo "Not yet implemented. $key $secret $folder";
299
 
306
  }
307
 
308
  }
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: David Anderson
3
  Tags: backup, restore, database, cloud, amazon, s3, Amazon S3, DropBox, DropBox backup, google drive, google, gdrive, ftp, cloud, updraft, back up
4
  Requires at least: 3.2
5
  Tested up to: 3.5
6
- Stable tag: 1.2.3
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
@@ -112,7 +112,7 @@ Thanks for asking - yes, I have. Check out my profile page - http://profiles.wor
112
 
113
  == Changelog ==
114
 
115
- = 1.2.3 - 01/08/2013 =
116
  * DropBox support (no chunked uploading yet, but otherwise complete)
117
  * Make the creation of the database dump also resumable, for people with really slow servers
118
 
3
  Tags: backup, restore, database, cloud, amazon, s3, Amazon S3, DropBox, DropBox backup, google drive, google, gdrive, ftp, cloud, updraft, back up
4
  Requires at least: 3.2
5
  Tested up to: 3.5
6
+ Stable tag: 1.1.15
7
  Donate link: http://david.dw-perspective.org.uk/donate
8
  License: GPLv3 or later
9
 
112
 
113
  == Changelog ==
114
 
115
+ = 1.2.5 - 01/08/2013 =
116
  * DropBox support (no chunked uploading yet, but otherwise complete)
117
  * Make the creation of the database dump also resumable, for people with really slow servers
118
 
updraftplus.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: UpdraftPlus - Backup/Restore
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Backup and Restore: Uploads, themes, plugins, other content and your DB can be automatically backed up to Amazon S3, DropBox, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
- Version: 1.2.3
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
@@ -56,7 +56,7 @@ define('UPDRAFT_DEFAULT_OTHERS_EXCLUDE','upgrade,cache,updraft,index.php');
56
 
57
  class UpdraftPlus {
58
 
59
- var $version = '1.2.3';
60
 
61
  // Choices will be shown in the admin menu in the order used here
62
  var $backup_methods = array (
4
  Plugin URI: http://wordpress.org/extend/plugins/updraftplus
5
  Description: Backup and Restore: Uploads, themes, plugins, other content and your DB can be automatically backed up to Amazon S3, DropBox, Google Drive, FTP, or emailed, on separate schedules.
6
  Author: David Anderson.
7
+ Version: 1.2.5
8
  Donate link: http://david.dw-perspective.org.uk/donate
9
  License: GPLv3 or later
10
  Author URI: http://wordshell.net
56
 
57
  class UpdraftPlus {
58
 
59
+ var $version = '1.2.5';
60
 
61
  // Choices will be shown in the admin menu in the order used here
62
  var $backup_methods = array (