UpdraftPlus WordPress Backup Plugin - Version 1.2.5

Version Description

  • 01/08/2013 =
  • DropBox support (no chunked uploading yet, but otherwise complete)
  • Make the creation of the database dump also resumable, for people with really slow servers
Download this release

Release Info

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

Code changes from version 1.2.3 to 1.2.5

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/Filesystem.php DELETED
@@ -1,131 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * OAuth storage handler built using the filesystem
5
- * @author Ben Tadiar <ben@handcraftedbyben.co.uk>
6
- * @author Jonas Schmid <jonas.schmid@gmail.com>
7
- * @link https://github.com/benthedesigner/dropbox
8
- * @package Dropbox\Oauth
9
- * @subpackage Storage
10
- */
11
- namespace Dropbox\OAuth\Storage;
12
-
13
- class Filesystem extends Session
14
- {
15
- /**
16
- * Authenticated user ID
17
- * @var int
18
- */
19
- private $userID = null;
20
-
21
- /**
22
- * Folder to store OAuth token files
23
- * @see \Dropbox\OAuth\Storage\Filesystem::setDirectory();
24
- * @var null|string
25
- */
26
- private $tokenDirectory = null;
27
-
28
- /**
29
- * Construct the parent object and
30
- * set the authenticated user ID
31
- * @param \Dropbox\OAuth\Storage\Encrypter $encrypter
32
- * @param int $userID
33
- * @throws \Dropbox\Exception
34
- */
35
- public function __construct(Encrypter $encrypter = null, $userID)
36
- {
37
- // Construct the parent object so we can access the SESSION
38
- // instead of reading the file on every request
39
- parent::__construct($encrypter);
40
-
41
- // Set the authenticated user ID
42
- $this->userID = $userID;
43
- }
44
-
45
- /**
46
- * Set the directory to store OAuth tokens
47
- * This method MUST be called after instantiating the storage
48
- * handler to avoid creating tokens in potentially vulnerable
49
- * locations (i.e. inside web root)
50
- * @param string $dir Path to token storage directory
51
- */
52
- public function setDirectory($dir)
53
- {
54
- if(!is_dir($dir) && !mkdir($dir, 0775, true)) {
55
- throw new \Dropbox\Exception('Unable to create directory ' . $dir);
56
- } else {
57
- $this->tokenDirectory = $dir;
58
- }
59
- }
60
-
61
- /**
62
- * Get an OAuth token from the file or session (see below)
63
- * Request tokens are stored in the session, access tokens in the file
64
- * Once a token is retrieved it will be stored in the user's session
65
- * for subsequent requests to reduce overheads
66
- * @param string $type Token type to retrieve
67
- * @return array|bool
68
- */
69
- public function get($type)
70
- {
71
- if ($type != 'request_token' && $type != 'access_token') {
72
- throw new \Dropbox\Exception("Expected a type of either 'request_token' or 'access_token', got '$type'");
73
- } elseif ($type == 'request_token') {
74
- return parent::get($type);
75
- } elseif ($token = parent::get($type)) {
76
- return $token;
77
- } else {
78
- $file = $this->getTokenFilePath();
79
- if(file_exists($file) && $token = file_get_contents($file)) {
80
- $_SESSION[$this->namespace][$type] = $token;
81
- return $this->decrypt($token);
82
- }
83
- return false;
84
- }
85
- }
86
-
87
- /**
88
- * Set an OAuth token in the file or session (see below)
89
- * Request tokens are stored in the session, access tokens in the file
90
- * @param \stdClass Token object to set
91
- * @param string $type Token type
92
- * @return void
93
- */
94
- public function set($token, $type)
95
- {
96
- if ($type != 'request_token' && $type != 'access_token') {
97
- throw new \Dropbox\Exception("Expected a type of either 'request_token' or 'access_token', got '$type'");
98
- } elseif ($type == 'request_token') {
99
- parent::set($token, $type);
100
- } else {
101
- $token = $this->encrypt($token);
102
- $file = $this->getTokenFilePath();
103
- file_put_contents($file, $token);
104
- $_SESSION[$this->namespace][$type] = $token;
105
- }
106
- }
107
-
108
- /**
109
- * Delete the access token stored on disk for the current user ID
110
- * @return bool
111
- */
112
- public function delete()
113
- {
114
- parent::delete();
115
- $file = $this->getTokenFilePath();
116
- return file_exists($file) && @unlink($file);
117
- }
118
-
119
- /**
120
- * Get the token file path for the specified user ID
121
- * @return string
122
- */
123
- private function getTokenFilePath()
124
- {
125
- if ($this->tokenDirectory === null) {
126
- throw new \Dropbox\Exception('OAuth token directory not set. See Filesystem::setDirectory()');
127
- } else {
128
- return $this->tokenDirectory . '/' . md5($this->userID) . '.token';
129
- }
130
- }
131
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/Dropbox/OAuth/Storage/PDO.php DELETED
@@ -1,188 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * OAuth storage handler built on PDO
5
- * @todo Add table creation script
6
- * @todo Database fallback?
7
- * @author Ben Tadiar <ben@handcraftedbyben.co.uk>
8
- * @link https://github.com/benthedesigner/dropbox
9
- * @package Dropbox\Oauth
10
- * @subpackage Storage
11
- */
12
- namespace Dropbox\OAuth\Storage;
13
-
14
- class PDO extends Session
15
- {
16
- /**
17
- * Authenticated user ID
18
- * @var int
19
- */
20
- private $userID = null;
21
-
22
- /**
23
- * Associative array of PDO connection options
24
- * @var array
25
- */
26
- private $options = array(
27
- \PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
28
- \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
29
- \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC,
30
- );
31
-
32
- /**
33
- * Forward-declare PDO object
34
- * @var null|PDO
35
- */
36
- private $pdo = null;
37
-
38
- /**
39
- * Default database table
40
- * Override this using setTable()
41
- * @var string
42
- */
43
- private $table = 'dropbox_oauth_tokens';
44
-
45
- /**
46
- * Construct the parent object and
47
- * set the authenticated user ID
48
- * @param \Dropbox\OAuth\Storage\Encrypter $encrypter
49
- * @param int $userID
50
- * @throws \Dropbox\Exception
51
- */
52
- public function __construct(Encrypter $encrypter = null, $userID)
53
- {
54
- // Throw an Exception if PDO is not loaded
55
- if (!extension_loaded('PDO')) {
56
- throw new \Dropbox\Exception('This storage handler requires the PDO extension');
57
- }
58
-
59
- // Construct the parent object so we can access the SESSION
60
- // instead of querying the database on every request
61
- parent::__construct($encrypter);
62
-
63
- // Set the authenticated user ID
64
- $this->userID = $userID;
65
- }
66
-
67
- /**
68
- * Connect to the database
69
- * @param string $host Database server hostname
70
- * @param string $db Database to connect to
71
- * @param string $user Database username
72
- * @param string $pass Database user password
73
- * @param int $port Database server port (Default: 3306)
74
- * @return void
75
- */
76
- public function connect($host, $db, $user, $pass, $port = 3306)
77
- {
78
- $dsn = 'mysql:host=' . $host . ';port=' . $port . ';dbname=' . $db;
79
- $this->pdo = new \PDO($dsn, $user, $pass, $this->options);
80
- }
81
-
82
- /**
83
- * Set the table to store OAuth tokens in
84
- * If the table does not exist, the get() method will attempt to create it when it is called.
85
- * @todo Check for valid table name and quote it (see below)
86
- * @link http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
87
- * @return void
88
- */
89
- public function setTable($table)
90
- {
91
- $this->table = $table;
92
- }
93
-
94
- /**
95
- * Get an OAuth token from the database or session (see below)
96
- * Request tokens are stored in the session, access tokens in the database
97
- * Once a token is retrieved it will be stored in the users session
98
- * for subsequent requests to reduce overheads
99
- * @param string $type Token type to retrieve
100
- * @return array|bool
101
- */
102
- public function get($type)
103
- {
104
- if ($type != 'request_token' && $type != 'access_token') {
105
- throw new \Dropbox\Exception("Expected a type of either 'request_token' or 'access_token', got '$type'");
106
- } elseif ($type == 'request_token') {
107
- return parent::get($type);
108
- } elseif ($token = parent::get($type)) {
109
- return $token;
110
- } else {
111
- try {
112
- $query = 'SELECT uid, userID, token FROM ' . $this->table . ' WHERE userID = ? LIMIT 1';
113
- $stmt = $this->pdo->prepare($query);
114
- $stmt->execute(array($this->userID));
115
- if ($result = $stmt->fetch()) {
116
- $token = $this->decrypt($result['token']);
117
- $_SESSION[$this->namespace][$type] = $result['token'];
118
- return $token;
119
- }
120
- } catch (\PDOException $e) {
121
- // Fetch error information from the statement handle
122
- $errorInfo = $stmt->errorInfo();
123
-
124
- // Handle the PDOException based on the error code
125
- switch ($errorInfo[1]) {
126
- case 1146: // Table does not exist
127
- $this->createTable();
128
- break;
129
- default: // Rethrow the PDOException
130
- throw $e;
131
- }
132
- }
133
-
134
- return false;
135
- }
136
- }
137
-
138
- /**
139
- * Set an OAuth token in the database or session (see below)
140
- * Request tokens are stored in the session, access tokens in the database
141
- * @param \stdClass Token object to set
142
- * @param string $type Token type
143
- * @return void
144
- */
145
- public function set($token, $type)
146
- {
147
- if ($type != 'request_token' && $type != 'access_token') {
148
- $message = "Expected a type of either 'request_token' or 'access_token', got '$type'";
149
- throw new \Dropbox\Exception($message);
150
- } elseif ($type == 'request_token') {
151
- parent::set($token, $type);
152
- } else {
153
- $query = 'INSERT INTO ' . $this->table . ' (userID, token) VALUES (?, ?) ON DUPLICATE KEY UPDATE token = ?';
154
- $stmt = $this->pdo->prepare($query);
155
- $token = $this->encrypt($token);
156
- $stmt->execute(array($this->userID, $token, $token));
157
- $_SESSION[$this->namespace][$type] = $token;
158
- }
159
- }
160
-
161
- /**
162
- * Delete access token for the current user ID from the database
163
- * @todo Add error checking
164
- * @return bool
165
- */
166
- public function delete()
167
- {
168
- try {
169
- parent::delete();
170
- $query = 'DELETE FROM ' . $this->table . ' WHERE userID = ?';
171
- $stmt = $this->pdo->prepare($query);
172
- $stmt->execute(array($this->userID));
173
- return $stmt->rowCount() > 0;
174
- } catch(\PDOException $e) {
175
- return false;
176
- }
177
- }
178
-
179
- /**
180
- * Attempt to create the OAuth token table
181
- * @return void
182
- */
183
- protected function createTable()
184
- {
185
- $template = file_get_contents(dirname(__FILE__) . '/TableSchema.sql');
186
- $this->pdo->query(sprintf($template, $this->table));
187
- }
188
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/Dropbox/OAuth/Storage/Session.php DELETED
@@ -1,143 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * OAuth storage handler using PHP sessions
5
- * This is a per session storage handler, meaning that you will need
6
- * to authorise the Dropbox app if the session ends (browser is closed,
7
- * session times out etc). For persistent storage of OAuth tokens,
8
- * please use \Dropbox\OAuth\Storage\PDO as your storage handler
9
- * @author Ben Tadiar <ben@handcraftedbyben.co.uk>
10
- * @link https://github.com/benthedesigner/dropbox
11
- * @package Dropbox\Oauth
12
- * @subpackage Storage
13
- */
14
- namespace Dropbox\OAuth\Storage;
15
-
16
- class Session implements StorageInterface
17
- {
18
- /**
19
- * Session namespace
20
- * @var string
21
- */
22
- protected $namespace = 'dropbox_api';
23
-
24
- /**
25
- * Encyption object
26
- * @var Encrypter|null
27
- */
28
- protected $encrypter = null;
29
-
30
- /**
31
- * Check if a session has been started (start one where appropriate)
32
- * and if an instance of the encrypter is passed, set the encryption object
33
- * @return void
34
- */
35
- public function __construct(Encrypter $encrypter = null)
36
- {
37
- $id = session_id();
38
-
39
- if (empty($id)) {
40
- session_start();
41
- }
42
-
43
- if ($encrypter instanceof Encrypter) {
44
- $this->encrypter = $encrypter;
45
- }
46
- }
47
-
48
- /**
49
- * Set the session namespace
50
- * $namespace corresponds to $_SESSION[$namespace]
51
- * @param string $namespace
52
- * @return void
53
- */
54
- public function setNamespace($namespace)
55
- {
56
- $this->namespace = $namespace;
57
- }
58
-
59
- /**
60
- * Get an OAuth token from the session
61
- * If the encrpytion object is set then decrypt the token before returning
62
- * @param string $type Token type to retrieve
63
- * @return array|bool
64
- */
65
- public function get($type)
66
- {
67
- if ($type != 'request_token' && $type != 'access_token') {
68
- throw new \Dropbox\Exception("Expected a type of either 'request_token' or 'access_token', got '$type'");
69
- } else {
70
- if (isset($_SESSION[$this->namespace][$type])) {
71
- $token = $this->decrypt($_SESSION[$this->namespace][$type]);
72
- return $token;
73
- }
74
- return false;
75
- }
76
- }
77
-
78
- /**
79
- * Set an OAuth token in the session by type
80
- * If the encryption object is set then encrypt the token before storing
81
- * @param \stdClass Token object to set
82
- * @param string $type Token type
83
- * @return void
84
- */
85
- public function set($token, $type)
86
- {
87
- if ($type != 'request_token' && $type != 'access_token') {
88
- throw new \Dropbox\Exception("Expected a type of either 'request_token' or 'access_token', got '$type'");
89
- } else {
90
- $token = $this->encrypt($token);
91
- $_SESSION[$this->namespace][$type] = $token;
92
- }
93
- }
94
-
95
- /**
96
- * Delete the request and access tokens currently stored in the session
97
- * @return bool
98
- */
99
- public function delete()
100
- {
101
- unset($_SESSION[$this->namespace]);
102
- return true;
103
- }
104
-
105
- /**
106
- * Use the Encrypter to encrypt a token and return it
107
- * If there is not encrypter object, return just the
108
- * serialized token object for storage
109
- * @param stdClass $token OAuth token to encrypt
110
- * @return stdClass|string
111
- */
112
- protected function encrypt($token)
113
- {
114
- // Serialize the token object
115
- $token = serialize($token);
116
-
117
- // Encrypt the token if there is an Encrypter instance
118
- if ($this->encrypter instanceof Encrypter) {
119
- $token = $this->encrypter->encrypt($token);
120
- }
121
-
122
- // Return the token
123
- return $token;
124
- }
125
-
126
- /**
127
- * Decrypt a token using the Encrypter object and return it
128
- * If there is no Encrypter object, assume the token was stored
129
- * serialized and return the unserialized token object
130
- * @param stdClass $token OAuth token to encrypt
131
- * @return stdClass|string
132
- */
133
- protected function decrypt($token)
134
- {
135
- // Decrypt the token if there is an Encrypter instance
136
- if ($this->encrypter instanceof Encrypter) {
137
- $token = $this->encrypter->decrypt($token);
138
- }
139
-
140
- // Return the unserialized token
141
- return @unserialize($token);
142
- }
143
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/Dropbox/OAuth/Storage/StorageInterface.php CHANGED
@@ -7,9 +7,8 @@
7
  * @package Dropbox\OAuth
8
  * @subpackage Storage
9
  */
10
- namespace Dropbox\OAuth\Storage;
11
 
12
- interface StorageInterface
13
  {
14
  /**
15
  * Get a token by type
7
  * @package Dropbox\OAuth
8
  * @subpackage Storage
9
  */
 
10
 
11
+ interface Dropbox_StorageInterface
12
  {
13
  /**
14
  * Get a token by type
includes/Dropbox/OAuth/Storage/TableSchema.sql DELETED
@@ -1,9 +0,0 @@
1
- CREATE TABLE `%s`
2
- (
3
- `uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
4
- `userID` int(10) unsigned NOT NULL,
5
- `token` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
6
- PRIMARY KEY (`uid`),
7
- UNIQUE KEY `userID` (`userID`)
8
- )
9
- ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
 
 
 
 
 
 
 
 
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 (