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 | UpdraftPlus WordPress Backup Plugin |
Version | 1.2.7 |
Comparing to | |
See all releases |
Code changes from version 1.2.4 to 1.2.7
- includes/Dropbox/OAuth/Consumer/ConsumerAbstract.php +1 -1
- includes/Dropbox/OAuth/Storage/Filesystem.php +0 -131
- includes/Dropbox/OAuth/Storage/PDO.php +0 -188
- includes/Dropbox/OAuth/Storage/Session.php +0 -143
- includes/Dropbox/OAuth/Storage/StorageInterface.php +1 -2
- includes/Dropbox/OAuth/Storage/TableSchema.sql +0 -9
- methods/dropbox.php +8 -7
- readme.txt +2 -2
- updraftplus.php +10 -7
includes/Dropbox/OAuth/Consumer/ConsumerAbstract.php
CHANGED
@@ -115,7 +115,7 @@ abstract class Dropbox_ConsumerAbstract
|
|
115 |
public function getAccessToken()
|
116 |
{
|
117 |
// Get the signed request URL
|
118 |
-
$response = $this->fetch('POST',
|
119 |
$token = $this->parseTokenString($response['body']);
|
120 |
$this->storage->set($token, 'access_token');
|
121 |
}
|
115 |
public function getAccessToken()
|
116 |
{
|
117 |
// Get the signed request URL
|
118 |
+
$response = $this->fetch('POST', Dropbox_API::API_URL, self::ACCESS_TOKEN_METHOD);
|
119 |
$token = $this->parseTokenString($response['body']);
|
120 |
$this->storage->set($token, 'access_token');
|
121 |
}
|
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
|
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 ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
methods/dropbox.php
CHANGED
@@ -151,9 +151,6 @@ class UpdraftPlus_BackupModule_dropbox {
|
|
151 |
<td>
|
152 |
<?php
|
153 |
// Check requirements
|
154 |
-
if (version_compare(phpversion(), "5.3.1", "<")) {
|
155 |
-
?><p><strong>Warning:</strong> Your web server is running PHP <?php echo phpversion(); ?>. UpdraftPlus's DropBox module requires at least PHP 5.3.1. Possibly UpdraftPlus may work for you, but if it does not then please do not request support - we cannot help. Note that the popular "DropBox for WordPress" module is using the same DropBox toolkit as UpdraftPlus, so you will not have any more success there! PHP before 5.3.1 has been obsolete for a long time and you should ask your provider for an upgrade (or try <a href="http://www.simbahosting.co.uk">Simba Hosting</a>).</p><?php
|
156 |
-
}
|
157 |
if (!function_exists('mcrypt_encrypt')) {
|
158 |
?><p><strong>Warning:</strong> Your web server's PHP installation does not included a required module (MCrypt). Please contact your web hosting provider's support. UpdraftPlus's DropBox module <strong>requires</strong> MCrypt. Please do not file any support requests; there is no alternative.</p><?php
|
159 |
}
|
@@ -256,10 +253,14 @@ class UpdraftPlus_BackupModule_dropbox {
|
|
256 |
|
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/
|
261 |
-
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/
|
262 |
-
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Consumer/
|
|
|
|
|
|
|
|
|
263 |
|
264 |
// Set the callback URL
|
265 |
$callback = admin_url('options-general.php?page=updraftplus&action=updraftmethod-dropbox-auth');
|
151 |
<td>
|
152 |
<?php
|
153 |
// Check requirements
|
|
|
|
|
|
|
154 |
if (!function_exists('mcrypt_encrypt')) {
|
155 |
?><p><strong>Warning:</strong> Your web server's PHP installation does not included a required module (MCrypt). Please contact your web hosting provider's support. UpdraftPlus's DropBox module <strong>requires</strong> MCrypt. Please do not file any support requests; there is no alternative.</p><?php
|
156 |
}
|
253 |
|
254 |
// This basically reproduces the relevant bits of bootstrap.php from the SDK
|
255 |
function bootstrap($key, $secret) {
|
256 |
+
|
257 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/Exception.php');
|
258 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/API.php');
|
259 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Consumer/ConsumerAbstract.php');
|
260 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Storage/StorageInterface.php');
|
261 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Storage/Encrypter.php');
|
262 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Storage/WordPress.php');
|
263 |
+
require_once(UPDRAFTPLUS_DIR.'/includes/Dropbox/OAuth/Consumer/Curl.php');
|
264 |
|
265 |
// Set the callback URL
|
266 |
$callback = admin_url('options-general.php?page=updraftplus&action=updraftmethod-dropbox-auth');
|
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.
|
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.
|
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.2.7
|
7 |
Donate link: http://david.dw-perspective.org.uk/donate
|
8 |
License: GPLv3 or later
|
9 |
|
112 |
|
113 |
== Changelog ==
|
114 |
|
115 |
+
= 1.2.7 - 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.
|
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.
|
60 |
|
61 |
// Choices will be shown in the admin menu in the order used here
|
62 |
var $backup_methods = array (
|
@@ -865,11 +865,7 @@ class UpdraftPlus {
|
|
865 |
// Finally, stitch the files together
|
866 |
$this->backup_db_open($backup_file_base.'-db.gz', true);
|
867 |
$this->backup_db_header();
|
868 |
-
|
869 |
-
$this->stow("/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n");
|
870 |
-
$this->stow("/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n");
|
871 |
-
$this->stow("/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
|
872 |
-
}
|
873 |
foreach ($stitch_files as $table_file) {
|
874 |
$this->log("{$table_file}.gz: adding to final database dump");
|
875 |
$handle = gzopen($updraft_dir.'/'.$table_file.'.gz', "r");
|
@@ -877,6 +873,13 @@ class UpdraftPlus {
|
|
877 |
gzclose($handle);
|
878 |
@unlink($updraft_dir.'/'.$table_file.'.gz');
|
879 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
880 |
$this->log($file_base.'-db.gz: finished writing out complete database file');
|
881 |
$this->close($this->dbhandle);
|
882 |
|
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.7
|
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.7';
|
60 |
|
61 |
// Choices will be shown in the admin menu in the order used here
|
62 |
var $backup_methods = array (
|
865 |
// Finally, stitch the files together
|
866 |
$this->backup_db_open($backup_file_base.'-db.gz', true);
|
867 |
$this->backup_db_header();
|
868 |
+
|
|
|
|
|
|
|
|
|
869 |
foreach ($stitch_files as $table_file) {
|
870 |
$this->log("{$table_file}.gz: adding to final database dump");
|
871 |
$handle = gzopen($updraft_dir.'/'.$table_file.'.gz', "r");
|
873 |
gzclose($handle);
|
874 |
@unlink($updraft_dir.'/'.$table_file.'.gz');
|
875 |
}
|
876 |
+
|
877 |
+
if (defined("DB_CHARSET")) {
|
878 |
+
$this->stow("/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;\n");
|
879 |
+
$this->stow("/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;\n");
|
880 |
+
$this->stow("/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;\n");
|
881 |
+
}
|
882 |
+
|
883 |
$this->log($file_base.'-db.gz: finished writing out complete database file');
|
884 |
$this->close($this->dbhandle);
|
885 |
|