Version Description
- new dropbox class to use all functions (download, delete, list)
- added usefull inks in job edit page
- renamed functions.php to resolve problems with false includes of other plugins
- improvements
Download this release
Release Info
Developer | danielhuesken |
Plugin | BackWPup – WordPress Backup Plugin |
Version | 1.6.0 |
Comparing to | |
See all releases |
Code changes from version 1.5.5 to 1.6.0
- app/backwpup_dojob.php +57 -20
- app/libs/DropboxUploader.php +0 -144
- app/libs/dropbox.php +974 -0
- app/list-tables.php +12 -5
- app/options-edit-job.php +8 -7
- app/options-save.php +92 -41
- app/{functions.php → php-functions.php} +0 -0
- app/{functions5.php → php5-functions.php} +87 -48
- backwpup.php +8 -4
- readme.txt +8 -2
app/backwpup_dojob.php
CHANGED
@@ -1135,10 +1135,8 @@ class backwpup_dojob {
|
|
1135 |
if (($contents = $s3->list_objects($this->job['awsBucket'],array('prefix'=>$this->job['awsdir']))) !== false) {
|
1136 |
foreach ($contents->body->Contents as $object) {
|
1137 |
$file=basename($object->Key);
|
1138 |
-
if ($this->job['
|
1139 |
-
|
1140 |
-
$backupfilelist[]=$file;
|
1141 |
-
}
|
1142 |
}
|
1143 |
}
|
1144 |
if (sizeof($backupfilelist)>0) {
|
@@ -1161,7 +1159,7 @@ class backwpup_dojob {
|
|
1161 |
trigger_error(__('S3 Bucket not exists:','backwpup').' '.$this->job['awsBucket'],E_USER_ERROR);
|
1162 |
}
|
1163 |
} catch (Exception $e) {
|
1164 |
-
trigger_error(__('Amazon S3 API:','backwpup').' '
|
1165 |
return;
|
1166 |
}
|
1167 |
}
|
@@ -1200,7 +1198,7 @@ class backwpup_dojob {
|
|
1200 |
$is_container=false;
|
1201 |
}
|
1202 |
} catch (Exception $e) {
|
1203 |
-
trigger_error(__('Rackspase Cloud API:','backwpup').' '
|
1204 |
return;
|
1205 |
}
|
1206 |
|
@@ -1250,7 +1248,7 @@ class backwpup_dojob {
|
|
1250 |
}
|
1251 |
}
|
1252 |
} catch (Exception $e) {
|
1253 |
-
trigger_error(__('Rackspase Cloud API:','backwpup').' '
|
1254 |
}
|
1255 |
}
|
1256 |
|
@@ -1298,10 +1296,8 @@ class backwpup_dojob {
|
|
1298 |
if (is_array($blobs)) {
|
1299 |
foreach ($blobs as $blob) {
|
1300 |
$file=basename($blob->Name);
|
1301 |
-
if ($this->job['
|
1302 |
-
|
1303 |
-
$backupfilelist[]=$file;
|
1304 |
-
}
|
1305 |
}
|
1306 |
}
|
1307 |
if (sizeof($backupfilelist)>0) {
|
@@ -1317,7 +1313,7 @@ class backwpup_dojob {
|
|
1317 |
}
|
1318 |
|
1319 |
} catch (Exception $e) {
|
1320 |
-
trigger_error(__('Microsoft Azure API:','backwpup').' '
|
1321 |
}
|
1322 |
}
|
1323 |
|
@@ -1350,23 +1346,64 @@ class backwpup_dojob {
|
|
1350 |
|
1351 |
private function destination_dropbox(){
|
1352 |
if (empty($this->job['dropemail']) or empty($this->job['dropepass']))
|
1353 |
-
|
1354 |
|
1355 |
if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
1356 |
trigger_error(__('Can not load curl extension is needed for Dropbox!','backwpup'),E_USER_ERROR);
|
1357 |
return;
|
1358 |
}
|
1359 |
|
1360 |
-
if (!class_exists('
|
|
|
|
|
1361 |
try {
|
1362 |
-
|
1363 |
-
|
1364 |
-
$
|
1365 |
-
|
1366 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1367 |
} catch (Exception $e) {
|
1368 |
-
trigger_error(__('DropBox:','backwpup').' '
|
1369 |
}
|
|
|
|
|
1370 |
}
|
1371 |
|
1372 |
private function job_end($logfile ='') {
|
1135 |
if (($contents = $s3->list_objects($this->job['awsBucket'],array('prefix'=>$this->job['awsdir']))) !== false) {
|
1136 |
foreach ($contents->body->Contents as $object) {
|
1137 |
$file=basename($object->Key);
|
1138 |
+
if ($this->job['fileprefix'] == substr($file,0,strlen($this->job['fileprefix'])) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
1139 |
+
$backupfilelist[]=$file;
|
|
|
|
|
1140 |
}
|
1141 |
}
|
1142 |
if (sizeof($backupfilelist)>0) {
|
1159 |
trigger_error(__('S3 Bucket not exists:','backwpup').' '.$this->job['awsBucket'],E_USER_ERROR);
|
1160 |
}
|
1161 |
} catch (Exception $e) {
|
1162 |
+
trigger_error(__('Amazon S3 API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
1163 |
return;
|
1164 |
}
|
1165 |
}
|
1198 |
$is_container=false;
|
1199 |
}
|
1200 |
} catch (Exception $e) {
|
1201 |
+
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
1202 |
return;
|
1203 |
}
|
1204 |
|
1248 |
}
|
1249 |
}
|
1250 |
} catch (Exception $e) {
|
1251 |
+
trigger_error(__('Rackspase Cloud API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
1252 |
}
|
1253 |
}
|
1254 |
|
1296 |
if (is_array($blobs)) {
|
1297 |
foreach ($blobs as $blob) {
|
1298 |
$file=basename($blob->Name);
|
1299 |
+
if ($this->job['fileprefix'] == substr($file,0,strlen($this->job['fileprefix'])) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
1300 |
+
$backupfilelist[]=$file;
|
|
|
|
|
1301 |
}
|
1302 |
}
|
1303 |
if (sizeof($backupfilelist)>0) {
|
1313 |
}
|
1314 |
|
1315 |
} catch (Exception $e) {
|
1316 |
+
trigger_error(__('Microsoft Azure API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
1317 |
}
|
1318 |
}
|
1319 |
|
1346 |
|
1347 |
private function destination_dropbox(){
|
1348 |
if (empty($this->job['dropemail']) or empty($this->job['dropepass']))
|
1349 |
+
return;
|
1350 |
|
1351 |
if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
1352 |
trigger_error(__('Can not load curl extension is needed for Dropbox!','backwpup'),E_USER_ERROR);
|
1353 |
return;
|
1354 |
}
|
1355 |
|
1356 |
+
if (!class_exists('Dropbox'))
|
1357 |
+
require_once (dirname(__FILE__).'/libs/dropbox.php');
|
1358 |
+
|
1359 |
try {
|
1360 |
+
$dropbox = new Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET);
|
1361 |
+
// get the tokens
|
1362 |
+
$response = $dropbox->token($this->job['dropemail'], base64_decode($this->job['dropepass']));
|
1363 |
+
|
1364 |
+
if (!empty($response['token']) and !empty($response['secret'])) {
|
1365 |
+
$info=$dropbox->accountInfo();
|
1366 |
+
trigger_error(__('Authed to DropBox API from ','backwpup').$info['display_name'],E_USER_NOTICE);
|
1367 |
+
} else {
|
1368 |
+
trigger_error(__('Can not Auth with DropBox API:','backwpup').' '.$response['error'],E_USER_ERROR);
|
1369 |
+
return;
|
1370 |
+
}
|
1371 |
+
|
1372 |
+
// put the file
|
1373 |
+
$response = $dropbox->filesPost($this->job['dropedir'], $this->backupdir.$this->backupfile);
|
1374 |
+
if ($response['result']=="winner!") {
|
1375 |
+
$this->lastbackupdownloadurl='admin.php?page=BackWPup&subpage=backups&action=downloaddropbox&file='.$this->job['dropedir'].$this->backupfile.'&jobid='.$this->jobid;
|
1376 |
+
trigger_error(__('Backup File transferred to DropBox.','backwpup'),E_USER_NOTICE);
|
1377 |
+
} else {
|
1378 |
+
trigger_error(__('Can not transfere Backup file to DropBox:','backwpup').' '.$response['error'],E_USER_ERROR);
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
if ($this->job['dropemaxbackups']>0) { //Delete old backups
|
1382 |
+
$backupfilelist=array();
|
1383 |
+
$metadata = $dropbox->metadata($this->job['dropedir']);
|
1384 |
+
if (is_array($metadata)) {
|
1385 |
+
foreach ($metadata['contents'] as $data) {
|
1386 |
+
$file=basename($data['path']);
|
1387 |
+
if ($data['is_dir']!=true and $this->job['fileprefix'] == substr($file,0,strlen($this->job['fileprefix'])) and $this->backupfileformat == substr($file,-strlen($this->backupfileformat)))
|
1388 |
+
$backupfilelist[]=$file;
|
1389 |
+
}
|
1390 |
+
}
|
1391 |
+
if (sizeof($backupfilelist)>0) {
|
1392 |
+
rsort($backupfilelist);
|
1393 |
+
$numdeltefiles=0;
|
1394 |
+
for ($i=$this->job['dropemaxbackups'];$i<sizeof($backupfilelist);$i++) {
|
1395 |
+
$dropbox->fileopsDelete($this->job['dropedir'].$backupfilelist[$i]); //delte files on Cloud
|
1396 |
+
$numdeltefiles++;
|
1397 |
+
}
|
1398 |
+
if ($numdeltefiles>0)
|
1399 |
+
trigger_error($numdeltefiles.' '.__('files deleted on DropBox Folder!','backwpup'),E_USER_NOTICE);
|
1400 |
+
}
|
1401 |
+
}
|
1402 |
} catch (Exception $e) {
|
1403 |
+
trigger_error(__('DropBox API:','backwpup').' '.$e->getMessage(),E_USER_ERROR);
|
1404 |
}
|
1405 |
+
|
1406 |
+
|
1407 |
}
|
1408 |
|
1409 |
private function job_end($logfile ='') {
|
app/libs/DropboxUploader.php
DELETED
@@ -1,144 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Dropbox Uploader
|
4 |
-
*
|
5 |
-
* Copyright (c) 2009 Jaka Jancar
|
6 |
-
*
|
7 |
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 |
-
* of this software and associated documentation files (the "Software"), to deal
|
9 |
-
* in the Software without restriction, including without limitation the rights
|
10 |
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 |
-
* copies of the Software, and to permit persons to whom the Software is
|
12 |
-
* furnished to do so, subject to the following conditions:
|
13 |
-
*
|
14 |
-
* The above copyright notice and this permission notice shall be included in
|
15 |
-
* all copies or substantial portions of the Software.
|
16 |
-
*
|
17 |
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 |
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 |
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20 |
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 |
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 |
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 |
-
* THE SOFTWARE.
|
24 |
-
*
|
25 |
-
* @author Jaka Jancar [jaka@kubje.org] [http://jaka.kubje.org/]
|
26 |
-
* @version 1.1.5
|
27 |
-
*/
|
28 |
-
class DropboxUploader {
|
29 |
-
protected $email;
|
30 |
-
protected $password;
|
31 |
-
protected $caCertSourceType = self::CACERT_SOURCE_SYSTEM;
|
32 |
-
const CACERT_SOURCE_SYSTEM = 0;
|
33 |
-
const CACERT_SOURCE_FILE = 1;
|
34 |
-
const CACERT_SOURCE_DIR = 2;
|
35 |
-
protected $caCertSource;
|
36 |
-
protected $loggedIn = false;
|
37 |
-
protected $cookies = array();
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Constructor
|
41 |
-
*
|
42 |
-
* @param string $email
|
43 |
-
* @param string|null $password
|
44 |
-
*/
|
45 |
-
public function __construct($email, $password) {
|
46 |
-
// Check requirements
|
47 |
-
if (!extension_loaded('curl'))
|
48 |
-
throw new Exception('DropboxUploader requires the cURL extension.');
|
49 |
-
|
50 |
-
$this->email = $email;
|
51 |
-
$this->password = $password;
|
52 |
-
}
|
53 |
-
|
54 |
-
public function setCaCertificateFile($file)
|
55 |
-
{
|
56 |
-
$this->caCertSourceType = self::CACERT_SOURCE_FILE;
|
57 |
-
$this->caCertSource = $file;
|
58 |
-
}
|
59 |
-
|
60 |
-
public function setCaCertificateDir($dir)
|
61 |
-
{
|
62 |
-
$this->caCertSourceType = self::CACERT_SOURCE_DIR;
|
63 |
-
$this->caCertSource = $dir;
|
64 |
-
}
|
65 |
-
|
66 |
-
public function upload($filename, $remoteDir='/') {
|
67 |
-
if (!file_exists($filename) or !is_file($filename) or !is_readable($filename))
|
68 |
-
throw new Exception("File '$filename' does not exist or is not readable.");
|
69 |
-
|
70 |
-
if (!is_string($remoteDir))
|
71 |
-
throw new Exception("Remote directory must be a string, is ".gettype($remoteDir)." instead.");
|
72 |
-
|
73 |
-
if (!$this->loggedIn)
|
74 |
-
$this->login();
|
75 |
-
|
76 |
-
$data = $this->request('https://www.dropbox.com/home');
|
77 |
-
$token = $this->extractToken($data, 'https://dl-web.dropbox.com/upload');
|
78 |
-
|
79 |
-
$data = $this->request('https://dl-web.dropbox.com/upload', true, array('plain'=>'yes', 'file'=>'@'.$filename, 'dest'=>$remoteDir, 't'=>$token));
|
80 |
-
if (strpos($data, 'HTTP/1.1 302 FOUND') === false)
|
81 |
-
throw new Exception('Upload failed!');
|
82 |
-
}
|
83 |
-
|
84 |
-
protected function login() {
|
85 |
-
$data = $this->request('https://www.dropbox.com/login');
|
86 |
-
$token = $this->extractToken($data, '/login');
|
87 |
-
|
88 |
-
$data = $this->request('https://www.dropbox.com/login', true, array('login_email'=>$this->email, 'login_password'=>$this->password, 't'=>$token));
|
89 |
-
|
90 |
-
if (stripos($data, 'location: /home') === false)
|
91 |
-
throw new Exception('Login unsuccessful.');
|
92 |
-
|
93 |
-
$this->loggedIn = true;
|
94 |
-
}
|
95 |
-
|
96 |
-
protected function request($url, $post=false, $postData=array()) {
|
97 |
-
$ch = curl_init();
|
98 |
-
curl_setopt($ch, CURLOPT_URL, $url);
|
99 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
100 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
101 |
-
switch ($this->caCertSourceType) {
|
102 |
-
case self::CACERT_SOURCE_FILE:
|
103 |
-
curl_setopt($ch, CURLOPT_CAINFO, $this->caCertSource);
|
104 |
-
break;
|
105 |
-
case self::CACERT_SOURCE_DIR:
|
106 |
-
curl_setopt($ch, CURLOPT_CAPATH, $this->caCertSource);
|
107 |
-
break;
|
108 |
-
}
|
109 |
-
curl_setopt($ch, CURLOPT_HEADER, 1);
|
110 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
111 |
-
if ($post) {
|
112 |
-
curl_setopt($ch, CURLOPT_POST, $post);
|
113 |
-
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
|
114 |
-
}
|
115 |
-
|
116 |
-
// Send cookies
|
117 |
-
$rawCookies = array();
|
118 |
-
foreach ($this->cookies as $k=>$v)
|
119 |
-
$rawCookies[] = "$k=$v";
|
120 |
-
$rawCookies = implode(';', $rawCookies);
|
121 |
-
curl_setopt($ch, CURLOPT_COOKIE, $rawCookies);
|
122 |
-
|
123 |
-
$data = curl_exec($ch);
|
124 |
-
|
125 |
-
if ($data === false)
|
126 |
-
throw new Exception('Cannot execute request: '.curl_error($ch));
|
127 |
-
|
128 |
-
// Store received cookies
|
129 |
-
preg_match_all('/Set-Cookie: ([^=]+)=(.*?);/i', $data, $matches, PREG_SET_ORDER);
|
130 |
-
foreach ($matches as $match)
|
131 |
-
$this->cookies[$match[1]] = $match[2];
|
132 |
-
|
133 |
-
curl_close($ch);
|
134 |
-
|
135 |
-
return $data;
|
136 |
-
}
|
137 |
-
|
138 |
-
protected function extractToken($html, $formAction) {
|
139 |
-
if (!preg_match('/<form [^>]*'.preg_quote($formAction, '/').'[^>]*>.*?(<input [^>]*name="t" [^>]*value="(.*?)"[^>]*>).*?<\/form>/is', $html, $matches) || !isset($matches[2]))
|
140 |
-
throw new Exception("Cannot extract token! (form action=$formAction)");
|
141 |
-
return $matches[2];
|
142 |
-
}
|
143 |
-
|
144 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/libs/dropbox.php
ADDED
@@ -0,0 +1,974 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Dropbox class
|
5 |
+
*
|
6 |
+
* This source file can be used to communicate with Dropbox (http://dropbox.com)
|
7 |
+
*
|
8 |
+
* The class is documented in the file itself. If you find any bugs help me out and report them. Reporting can be done by sending an email to php-dropbox-bugs[at]verkoyen[dot]eu.
|
9 |
+
* If you report a bug, make sure you give me enough information (include your code).
|
10 |
+
*
|
11 |
+
* Changelog since 1.0.0
|
12 |
+
* - fixed some issues with generation off the basestring
|
13 |
+
*
|
14 |
+
* License
|
15 |
+
* Copyright (c) 2010, Tijs Verkoyen. All rights reserved.
|
16 |
+
*
|
17 |
+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
18 |
+
*
|
19 |
+
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
20 |
+
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
21 |
+
* 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
|
22 |
+
*
|
23 |
+
* This software is provided by the author "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the author be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
24 |
+
*
|
25 |
+
* @author Tijs Verkoyen <php-dropbox@verkoyen.eu>
|
26 |
+
* @version 1.0.1
|
27 |
+
*
|
28 |
+
* @copyright Copyright (c) 2010, Tijs Verkoyen. All rights reserved.
|
29 |
+
* @license BSD License
|
30 |
+
*/
|
31 |
+
class Dropbox
|
32 |
+
{
|
33 |
+
// internal constant to enable/disable debugging
|
34 |
+
const DEBUG = false;
|
35 |
+
|
36 |
+
// url for the dropbox-api
|
37 |
+
const API_URL = 'https://api.dropbox.com';
|
38 |
+
const API_CONTENT_URL = 'https://api-content.dropbox.com';
|
39 |
+
|
40 |
+
// port for the dropbox-api
|
41 |
+
const API_PORT = 443;
|
42 |
+
|
43 |
+
// current version
|
44 |
+
const VERSION = '1.0.1';
|
45 |
+
|
46 |
+
|
47 |
+
/**
|
48 |
+
* A cURL instance
|
49 |
+
*
|
50 |
+
* @var resource
|
51 |
+
*/
|
52 |
+
private $curl;
|
53 |
+
|
54 |
+
|
55 |
+
/**
|
56 |
+
* The application key
|
57 |
+
*
|
58 |
+
* @var string
|
59 |
+
*/
|
60 |
+
private $applicationKey;
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* The application secret
|
65 |
+
*
|
66 |
+
* @var string
|
67 |
+
*/
|
68 |
+
private $applicationSecret;
|
69 |
+
|
70 |
+
|
71 |
+
/**
|
72 |
+
* The oAuth-token
|
73 |
+
*
|
74 |
+
* @var string
|
75 |
+
*/
|
76 |
+
private $oAuthToken = '';
|
77 |
+
|
78 |
+
|
79 |
+
/**
|
80 |
+
* The oAuth-token-secret
|
81 |
+
*
|
82 |
+
* @var string
|
83 |
+
*/
|
84 |
+
private $oAuthTokenSecret = '';
|
85 |
+
|
86 |
+
|
87 |
+
/**
|
88 |
+
* The timeout
|
89 |
+
*
|
90 |
+
* @var int
|
91 |
+
*/
|
92 |
+
private $timeOut = 60;
|
93 |
+
|
94 |
+
|
95 |
+
/**
|
96 |
+
* The user agent
|
97 |
+
*
|
98 |
+
* @var string
|
99 |
+
*/
|
100 |
+
private $userAgent;
|
101 |
+
|
102 |
+
|
103 |
+
// class methods
|
104 |
+
/**
|
105 |
+
* Default constructor
|
106 |
+
*
|
107 |
+
* @return void
|
108 |
+
* @param string $consumerKey The consumer key to use.
|
109 |
+
* @param string $consumerSecret The consumer secret to use.
|
110 |
+
*/
|
111 |
+
public function __construct($applicationKey, $applicationSecret)
|
112 |
+
{
|
113 |
+
$this->setApplicationKey($applicationKey);
|
114 |
+
$this->setApplicationSecret($applicationSecret);
|
115 |
+
}
|
116 |
+
|
117 |
+
|
118 |
+
/**
|
119 |
+
* Default destructor
|
120 |
+
*
|
121 |
+
* @return void
|
122 |
+
*/
|
123 |
+
public function __destruct()
|
124 |
+
{
|
125 |
+
if($this->curl != null) curl_close($this->curl);
|
126 |
+
}
|
127 |
+
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Format the parameters as a querystring
|
131 |
+
*
|
132 |
+
* @return string
|
133 |
+
* @param array $parameters
|
134 |
+
*/
|
135 |
+
private function buildQuery(array $parameters)
|
136 |
+
{
|
137 |
+
// no parameters?
|
138 |
+
if(empty($parameters)) return '';
|
139 |
+
|
140 |
+
// encode the keys
|
141 |
+
$keys = self::urlencode_rfc3986(array_keys($parameters));
|
142 |
+
|
143 |
+
// encode the values
|
144 |
+
$values = self::urlencode_rfc3986(array_values($parameters));
|
145 |
+
|
146 |
+
// reset the parameters
|
147 |
+
$parameters = array_combine($keys, $values);
|
148 |
+
|
149 |
+
// sort parameters by key
|
150 |
+
uksort($parameters, 'strcmp');
|
151 |
+
|
152 |
+
// loop parameters
|
153 |
+
foreach($parameters as $key => $value)
|
154 |
+
{
|
155 |
+
// sort by value
|
156 |
+
if(is_array($value)) $parameters[$key] = natsort($value);
|
157 |
+
}
|
158 |
+
|
159 |
+
// process parameters
|
160 |
+
foreach($parameters as $key => $value) $chunks[] = $key .'='. str_replace('%25', '%', $value);
|
161 |
+
|
162 |
+
// return
|
163 |
+
return implode('&', $chunks);
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* All OAuth 1.0 requests use the same basic algorithm for creating a signature base string and a signature.
|
169 |
+
* The signature base string is composed of the HTTP method being used, followed by an ampersand ("&") and then the URL-encoded base URL being accessed,
|
170 |
+
* complete with path (but not query parameters), followed by an ampersand ("&").
|
171 |
+
* Then, you take all query parameters and POST body parameters (when the POST body is of the URL-encoded type, otherwise the POST body is ignored),
|
172 |
+
* including the OAuth parameters necessary for negotiation with the request at hand, and sort them in lexicographical order by first parameter name and
|
173 |
+
* then parameter value (for duplicate parameters), all the while ensuring that both the key and the value for each parameter are URL encoded in isolation.
|
174 |
+
* Instead of using the equals ("=") sign to mark the key/value relationship, you use the URL-encoded form of "%3D". Each parameter is then joined by the
|
175 |
+
* URL-escaped ampersand sign, "%26".
|
176 |
+
*
|
177 |
+
* @return string
|
178 |
+
* @param string $url
|
179 |
+
* @param string $method
|
180 |
+
* @param array $parameters
|
181 |
+
*/
|
182 |
+
private function calculateBaseString($url, $method, array $parameters)
|
183 |
+
{
|
184 |
+
// redefine
|
185 |
+
$url = (string) $url;
|
186 |
+
$parameters = (array) $parameters;
|
187 |
+
|
188 |
+
// init var
|
189 |
+
$pairs = array();
|
190 |
+
$chunks = array();
|
191 |
+
|
192 |
+
// sort parameters by key
|
193 |
+
uksort($parameters, 'strcmp');
|
194 |
+
|
195 |
+
// loop parameters
|
196 |
+
foreach($parameters as $key => $value)
|
197 |
+
{
|
198 |
+
// sort by value
|
199 |
+
if(is_array($value)) $parameters[$key] = natsort($value);
|
200 |
+
}
|
201 |
+
|
202 |
+
// process queries
|
203 |
+
foreach($parameters as $key => $value)
|
204 |
+
{
|
205 |
+
// only add if not already in the url
|
206 |
+
if(substr_count($url, $key .'='. $value) == 0) $chunks[] = self::urlencode_rfc3986($key) .'%3D'. self::urlencode_rfc3986($value);
|
207 |
+
}
|
208 |
+
|
209 |
+
$urlChunks = explode('/', $url);
|
210 |
+
$i = 0;
|
211 |
+
|
212 |
+
foreach($urlChunks as &$chunk)
|
213 |
+
{
|
214 |
+
if($i > 4) $chunk = self::urlencode_rfc3986($chunk);
|
215 |
+
else $chunk = urlencode($chunk);
|
216 |
+
|
217 |
+
$i++;
|
218 |
+
|
219 |
+
}
|
220 |
+
|
221 |
+
// build base
|
222 |
+
$base = $method .'&';
|
223 |
+
$base .= implode('%2F', $urlChunks);
|
224 |
+
$base .= (substr_count($url, '?')) ? '%26' : '&';
|
225 |
+
$base .= implode('%26', $chunks);
|
226 |
+
$base = str_replace(array('%3F', '%20'), array('&', '%2520'), $base);
|
227 |
+
|
228 |
+
// return
|
229 |
+
return $base;
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Build the Authorization header
|
235 |
+
* @later: fix me
|
236 |
+
*
|
237 |
+
* @return string
|
238 |
+
* @param array $parameters
|
239 |
+
* @param string $url
|
240 |
+
*/
|
241 |
+
private function calculateHeader(array $parameters, $url)
|
242 |
+
{
|
243 |
+
// redefine
|
244 |
+
$url = (string) $url;
|
245 |
+
|
246 |
+
// divide into parts
|
247 |
+
$parts = parse_url($url);
|
248 |
+
|
249 |
+
// init var
|
250 |
+
$chunks = array();
|
251 |
+
|
252 |
+
// process queries
|
253 |
+
foreach($parameters as $key => $value) $chunks[] = str_replace('%25', '%', self::urlencode_rfc3986($key) .'="'. self::urlencode_rfc3986($value) .'"');
|
254 |
+
|
255 |
+
// build return
|
256 |
+
$return = 'Authorization: OAuth realm="' . $parts['scheme'] . '://' . $parts['host'] . $parts['path'] . '", ';
|
257 |
+
$return .= implode(',', $chunks);
|
258 |
+
|
259 |
+
// prepend name and OAuth part
|
260 |
+
return $return;
|
261 |
+
}
|
262 |
+
|
263 |
+
|
264 |
+
/**
|
265 |
+
* Make an call to the oAuth
|
266 |
+
* @todo refactor me
|
267 |
+
*
|
268 |
+
* @return array
|
269 |
+
* @param string $method
|
270 |
+
* @param array[optional] $parameters
|
271 |
+
*/
|
272 |
+
private function doOAuthCall($url, array $parameters = null)
|
273 |
+
{
|
274 |
+
// redefine
|
275 |
+
$url = (string) $url;
|
276 |
+
|
277 |
+
// append default parameters
|
278 |
+
$parameters['oauth_consumer_key'] = $this->getApplicationKey();
|
279 |
+
$parameters['oauth_nonce'] = md5(microtime() . rand());
|
280 |
+
$parameters['oauth_timestamp'] = time();
|
281 |
+
$parameters['oauth_signature_method'] = 'HMAC-SHA1';
|
282 |
+
$parameters['oauth_version'] = '1.0';
|
283 |
+
|
284 |
+
// calculate the base string
|
285 |
+
$base = $this->calculateBaseString(self::API_URL .'/'. $url, 'POST', $parameters);
|
286 |
+
|
287 |
+
// add sign into the parameters
|
288 |
+
$parameters['oauth_signature'] = $this->hmacsha1($this->getApplicationSecret() .'&' . $this->getOAuthTokenSecret(), $base);
|
289 |
+
|
290 |
+
// calculate header
|
291 |
+
$header = $this->calculateHeader($parameters, self::API_URL .'/'. $url);
|
292 |
+
|
293 |
+
// set options
|
294 |
+
$options[CURLOPT_URL] = self::API_URL .'/'. $url;
|
295 |
+
$options[CURLOPT_PORT] = self::API_PORT;
|
296 |
+
$options[CURLOPT_USERAGENT] = $this->getUserAgent();
|
297 |
+
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) $options[CURLOPT_FOLLOWLOCATION] = true;
|
298 |
+
$options[CURLOPT_RETURNTRANSFER] = true;
|
299 |
+
$options[CURLOPT_TIMEOUT] = (int) $this->getTimeOut();
|
300 |
+
$options[CURLOPT_SSL_VERIFYPEER] = false;
|
301 |
+
$options[CURLOPT_SSL_VERIFYHOST] = false;
|
302 |
+
$options[CURLOPT_HTTPHEADER] = array('Expect:');
|
303 |
+
$options[CURLOPT_POST] = true;
|
304 |
+
$options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
|
305 |
+
|
306 |
+
// init
|
307 |
+
$this->curl = curl_init();
|
308 |
+
|
309 |
+
// set options
|
310 |
+
curl_setopt_array($this->curl, $options);
|
311 |
+
|
312 |
+
// execute
|
313 |
+
$response = curl_exec($this->curl);
|
314 |
+
$headers = curl_getinfo($this->curl);
|
315 |
+
|
316 |
+
// fetch errors
|
317 |
+
$errorNumber = curl_errno($this->curl);
|
318 |
+
$errorMessage = curl_error($this->curl);
|
319 |
+
|
320 |
+
// error?
|
321 |
+
if($errorNumber != '') throw new DropboxException($errorMessage, $errorNumber);
|
322 |
+
|
323 |
+
// return
|
324 |
+
return json_decode($response, true);
|
325 |
+
}
|
326 |
+
|
327 |
+
|
328 |
+
/**
|
329 |
+
* Make the call
|
330 |
+
*
|
331 |
+
* @return string
|
332 |
+
* @param string $url The url to call.
|
333 |
+
* @param array[optiona] $parameters Optional parameters.
|
334 |
+
* @param bool[optional] $method The method to use. Possible values are GET, POST.
|
335 |
+
* @param string[optional] $filePath The path to the file to upload.
|
336 |
+
* @param bool[optional] $expectJSON Do we expect JSON?
|
337 |
+
* @param bool[optional] $isContent Is this content?
|
338 |
+
*/
|
339 |
+
private function doCall($url, array $parameters = null, $method = 'GET', $filePath = null, $expectJSON = true, $isContent = false)
|
340 |
+
{
|
341 |
+
// allowed methods
|
342 |
+
$allowedMethods = array('GET', 'POST');
|
343 |
+
|
344 |
+
// redefine
|
345 |
+
$url = (string) $url;
|
346 |
+
$parameters = (array) $parameters;
|
347 |
+
$method = (string) $method;
|
348 |
+
$expectJSON = (bool) $expectJSON;
|
349 |
+
|
350 |
+
// validate method
|
351 |
+
if(!in_array($method, $allowedMethods)) throw new DropboxException('Unknown method ('. $method .'). Allowed methods are: '. implode(', ', $allowedMethods));
|
352 |
+
|
353 |
+
// append default parameters
|
354 |
+
$oauth['oauth_consumer_key'] = $this->getApplicationKey();
|
355 |
+
$oauth['oauth_nonce'] = md5(microtime() . rand());
|
356 |
+
$oauth['oauth_timestamp'] = time();
|
357 |
+
$oauth['oauth_token'] = $this->getOAuthToken();
|
358 |
+
$oauth['oauth_signature_method'] = 'HMAC-SHA1';
|
359 |
+
$oauth['oauth_version'] = '1.0';
|
360 |
+
|
361 |
+
// set data
|
362 |
+
$data = $oauth;
|
363 |
+
if(!empty($parameters))
|
364 |
+
{
|
365 |
+
// convert to UTF-8
|
366 |
+
foreach($parameters as &$value) $value = utf8_encode($value);
|
367 |
+
|
368 |
+
// merge
|
369 |
+
$data = array_merge($data, $parameters);
|
370 |
+
}
|
371 |
+
|
372 |
+
if($filePath != null)
|
373 |
+
{
|
374 |
+
// process file
|
375 |
+
$fileInfo = pathinfo($filePath);
|
376 |
+
|
377 |
+
// add to the data
|
378 |
+
$data['file'] = $fileInfo['basename'];
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
// calculate the base string
|
383 |
+
if($isContent) $base = $this->calculateBaseString(self::API_CONTENT_URL .'/'. $url, $method, $data);
|
384 |
+
else $base = $this->calculateBaseString(self::API_URL .'/'. $url, $method, $data);
|
385 |
+
|
386 |
+
// based on the method, we should handle the parameters in a different way
|
387 |
+
if($method == 'POST')
|
388 |
+
{
|
389 |
+
// file provided?
|
390 |
+
if($filePath != null)
|
391 |
+
{
|
392 |
+
// build a boundary
|
393 |
+
$boundary = md5(time());
|
394 |
+
|
395 |
+
// init var
|
396 |
+
$content = '--'. $boundary ."\r\n";
|
397 |
+
|
398 |
+
// set file
|
399 |
+
$content .= 'Content-Disposition: form-data; name=file; filename="'. $fileInfo['basename'] .'"' ."\r\n";
|
400 |
+
$content .= 'Content-Type: application/octet-stream'."\r\n";
|
401 |
+
$content .= "\r\n";
|
402 |
+
$content .= file_get_contents($filePath);
|
403 |
+
$content .="\r\n";
|
404 |
+
$content .="--". $boundary .'--';
|
405 |
+
|
406 |
+
// build headers
|
407 |
+
$headers[] = 'Content-Type: multipart/form-data; boundary='. $boundary;
|
408 |
+
$headers[] = 'Content-Length: '. strlen($content);
|
409 |
+
|
410 |
+
// set content
|
411 |
+
$options[CURLOPT_POSTFIELDS] = $content;
|
412 |
+
}
|
413 |
+
|
414 |
+
// no file
|
415 |
+
else $options[CURLOPT_POSTFIELDS] = $this->buildQuery($parameters);
|
416 |
+
|
417 |
+
// enable post
|
418 |
+
$options[CURLOPT_POST] = 1;
|
419 |
+
}
|
420 |
+
|
421 |
+
else
|
422 |
+
{
|
423 |
+
// add the parameters into the querystring
|
424 |
+
if(!empty($parameters)) $url .= '?'. $this->buildQuery($parameters);
|
425 |
+
$options[CURLOPT_POST] = 0;
|
426 |
+
}
|
427 |
+
|
428 |
+
// add sign into the parameters
|
429 |
+
$oauth['oauth_signature'] = $this->hmacsha1($this->getApplicationSecret() .'&' . $this->getOAuthTokenSecret(), $base);
|
430 |
+
|
431 |
+
if($isContent) $headers[] = $this->calculateHeader($oauth, self::API_CONTENT_URL .'/'. $url);
|
432 |
+
else $headers[] = $this->calculateHeader($oauth, self::API_URL .'/'. $url);
|
433 |
+
$headers[] = 'Expect:';
|
434 |
+
|
435 |
+
// set options
|
436 |
+
if($isContent) $options[CURLOPT_URL] = self::API_CONTENT_URL .'/'. $url;
|
437 |
+
else $options[CURLOPT_URL] = self::API_URL .'/'. $url;
|
438 |
+
$options[CURLOPT_PORT] = self::API_PORT;
|
439 |
+
$options[CURLOPT_USERAGENT] = $this->getUserAgent();
|
440 |
+
if(ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) $options[CURLOPT_FOLLOWLOCATION] = true;
|
441 |
+
$options[CURLOPT_RETURNTRANSFER] = true;
|
442 |
+
$options[CURLOPT_TIMEOUT] = (int) $this->getTimeOut();
|
443 |
+
$options[CURLOPT_SSL_VERIFYPEER] = false;
|
444 |
+
$options[CURLOPT_SSL_VERIFYHOST] = false;
|
445 |
+
$options[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1;
|
446 |
+
$options[CURLOPT_HTTPHEADER] = $headers;
|
447 |
+
|
448 |
+
// init
|
449 |
+
if($this->curl == null) $this->curl = curl_init();
|
450 |
+
|
451 |
+
// set options
|
452 |
+
curl_setopt_array($this->curl, $options);
|
453 |
+
|
454 |
+
// execute
|
455 |
+
$response = curl_exec($this->curl);
|
456 |
+
$headers = curl_getinfo($this->curl);
|
457 |
+
|
458 |
+
// fetch errors
|
459 |
+
$errorNumber = curl_errno($this->curl);
|
460 |
+
$errorMessage = curl_error($this->curl);
|
461 |
+
|
462 |
+
if(!$expectJSON && $isContent)
|
463 |
+
{
|
464 |
+
// is it JSON?
|
465 |
+
$json = @json_decode($response, true);
|
466 |
+
if($json !== false && isset($json['error'])) throw new DropboxException($json['error']);
|
467 |
+
|
468 |
+
// set return
|
469 |
+
$return['content_type'] = $headers['content_type'];
|
470 |
+
$return['data'] = base64_encode($response);
|
471 |
+
|
472 |
+
// return
|
473 |
+
return $return;
|
474 |
+
}
|
475 |
+
|
476 |
+
// we don't expect JSON, return the response
|
477 |
+
if(!$expectJSON) return $response;
|
478 |
+
|
479 |
+
// replace ids with their string values, added because of some PHP-version can't handle these large values
|
480 |
+
$response = preg_replace('/id":(\d+)/', 'id":"\1"', $response);
|
481 |
+
|
482 |
+
// we expect JSON, so decode it
|
483 |
+
$json = @json_decode($response, true);
|
484 |
+
|
485 |
+
// validate JSON
|
486 |
+
if($json === null)
|
487 |
+
{
|
488 |
+
// should we provide debug information
|
489 |
+
if(self::DEBUG)
|
490 |
+
{
|
491 |
+
// make it output proper
|
492 |
+
echo '<pre>';
|
493 |
+
|
494 |
+
// dump the header-information
|
495 |
+
var_dump($headers);
|
496 |
+
|
497 |
+
// dump the error
|
498 |
+
var_dump($errorMessage);
|
499 |
+
|
500 |
+
// dump the raw response
|
501 |
+
var_dump($response);
|
502 |
+
|
503 |
+
// end proper format
|
504 |
+
echo '</pre>';
|
505 |
+
}
|
506 |
+
|
507 |
+
// throw exception
|
508 |
+
throw new DropboxException('Invalid response.');
|
509 |
+
}
|
510 |
+
|
511 |
+
// any error
|
512 |
+
if(isset($json['error']))
|
513 |
+
{
|
514 |
+
// should we provide debug information
|
515 |
+
if(self::DEBUG)
|
516 |
+
{
|
517 |
+
// make it output proper
|
518 |
+
echo '<pre>';
|
519 |
+
|
520 |
+
// dump the header-information
|
521 |
+
var_dump($headers);
|
522 |
+
|
523 |
+
// dump the raw response
|
524 |
+
var_dump($response);
|
525 |
+
|
526 |
+
// end proper format
|
527 |
+
echo '</pre>';
|
528 |
+
}
|
529 |
+
|
530 |
+
if(isset($json['error']) && is_string($json['error'])) $message = $json['error'];
|
531 |
+
elseif(isset($json['error']['hash']) && $json['error']['hash'] != '') $message = (string) $json['error']['hash'];
|
532 |
+
else $message = 'Invalid response.';
|
533 |
+
|
534 |
+
// throw exception
|
535 |
+
throw new DropboxException($message);
|
536 |
+
}
|
537 |
+
|
538 |
+
// return
|
539 |
+
return $json;
|
540 |
+
}
|
541 |
+
|
542 |
+
|
543 |
+
/**
|
544 |
+
* Get the application key
|
545 |
+
*
|
546 |
+
* @return string
|
547 |
+
*/
|
548 |
+
private function getApplicationKey()
|
549 |
+
{
|
550 |
+
return $this->applicationKey;
|
551 |
+
}
|
552 |
+
|
553 |
+
|
554 |
+
/**
|
555 |
+
* Get the application secret
|
556 |
+
*
|
557 |
+
* @return string
|
558 |
+
*/
|
559 |
+
private function getApplicationSecret()
|
560 |
+
{
|
561 |
+
return $this->applicationSecret;
|
562 |
+
}
|
563 |
+
|
564 |
+
|
565 |
+
/**
|
566 |
+
* Get the oAuth-token
|
567 |
+
*
|
568 |
+
* @return string
|
569 |
+
*/
|
570 |
+
private function getOAuthToken()
|
571 |
+
{
|
572 |
+
return $this->oAuthToken;
|
573 |
+
}
|
574 |
+
|
575 |
+
|
576 |
+
/**
|
577 |
+
* Get the oAuth-token-secret
|
578 |
+
*
|
579 |
+
* @return string
|
580 |
+
*/
|
581 |
+
private function getOAuthTokenSecret()
|
582 |
+
{
|
583 |
+
return $this->oAuthTokenSecret;
|
584 |
+
}
|
585 |
+
|
586 |
+
|
587 |
+
/**
|
588 |
+
* Get the timeout
|
589 |
+
*
|
590 |
+
* @return int
|
591 |
+
*/
|
592 |
+
public function getTimeOut()
|
593 |
+
{
|
594 |
+
return (int) $this->timeOut;
|
595 |
+
}
|
596 |
+
|
597 |
+
|
598 |
+
/**
|
599 |
+
* Get the useragent that will be used. Our version will be prepended to yours.
|
600 |
+
* It will look like: "PHP Dropbox/<version> <your-user-agent>"
|
601 |
+
*
|
602 |
+
* @return string
|
603 |
+
*/
|
604 |
+
public function getUserAgent()
|
605 |
+
{
|
606 |
+
return (string) 'PHP Dropbox/'. self::VERSION .' '. $this->userAgent;
|
607 |
+
}
|
608 |
+
|
609 |
+
|
610 |
+
/**
|
611 |
+
* Set the application key
|
612 |
+
*
|
613 |
+
* @return void
|
614 |
+
* @param string $key The application key to use.
|
615 |
+
*/
|
616 |
+
private function setApplicationKey($key)
|
617 |
+
{
|
618 |
+
$this->applicationKey = (string) $key;
|
619 |
+
}
|
620 |
+
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Set the application secret
|
624 |
+
*
|
625 |
+
* @return void
|
626 |
+
* @param string $secret The application secret to use.
|
627 |
+
*/
|
628 |
+
private function setApplicationSecret($secret)
|
629 |
+
{
|
630 |
+
$this->applicationSecret = (string) $secret;
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
/**
|
635 |
+
* Set the oAuth-token
|
636 |
+
*
|
637 |
+
* @return void
|
638 |
+
* @param string $token The token to use.
|
639 |
+
*/
|
640 |
+
public function setOAuthToken($token)
|
641 |
+
{
|
642 |
+
$this->oAuthToken = (string) $token;
|
643 |
+
}
|
644 |
+
|
645 |
+
|
646 |
+
/**
|
647 |
+
* Set the oAuth-secret
|
648 |
+
*
|
649 |
+
* @return void
|
650 |
+
* @param string $secret The secret to use.
|
651 |
+
*/
|
652 |
+
public function setOAuthTokenSecret($secret)
|
653 |
+
{
|
654 |
+
$this->oAuthTokenSecret = (string) $secret;
|
655 |
+
}
|
656 |
+
|
657 |
+
|
658 |
+
/**
|
659 |
+
* Set the timeout
|
660 |
+
*
|
661 |
+
* @return void
|
662 |
+
* @param int $seconds The timeout in seconds
|
663 |
+
*/
|
664 |
+
public function setTimeOut($seconds)
|
665 |
+
{
|
666 |
+
$this->timeOut = (int) $seconds;
|
667 |
+
}
|
668 |
+
|
669 |
+
|
670 |
+
/**
|
671 |
+
* Get the useragent that will be used. Our version will be prepended to yours.
|
672 |
+
* It will look like: "PHP Dropbox/<version> <your-user-agent>"
|
673 |
+
*
|
674 |
+
* @return void
|
675 |
+
* @param string $userAgent Your user-agent, it should look like <app-name>/<app-version>
|
676 |
+
*/
|
677 |
+
public function setUserAgent($userAgent)
|
678 |
+
{
|
679 |
+
$this->userAgent = (string) $userAgent;
|
680 |
+
}
|
681 |
+
|
682 |
+
|
683 |
+
/**
|
684 |
+
* Build the signature for the data
|
685 |
+
*
|
686 |
+
* @return string
|
687 |
+
* @param string $key The key to use for signing.
|
688 |
+
* @param string $data The data that has to be signed.
|
689 |
+
*/
|
690 |
+
private function hmacsha1($key, $data)
|
691 |
+
{
|
692 |
+
return base64_encode(hash_hmac('SHA1', $data, $key, true));
|
693 |
+
}
|
694 |
+
|
695 |
+
|
696 |
+
/**
|
697 |
+
* URL-encode method for internatl use
|
698 |
+
*
|
699 |
+
* @return string
|
700 |
+
* @param mixed $value The value to encode.
|
701 |
+
*/
|
702 |
+
private static function urlencode_rfc3986($value)
|
703 |
+
{
|
704 |
+
if(is_array($value)) return array_map(array('Dropbox', 'urlencode_rfc3986'), $value);
|
705 |
+
else
|
706 |
+
{
|
707 |
+
$search = array('+', ' ', '%7E', '%');
|
708 |
+
$replace = array('%20', '%20', '~', '%25');
|
709 |
+
|
710 |
+
return str_replace($search, $replace, rawurlencode($value));
|
711 |
+
}
|
712 |
+
}
|
713 |
+
|
714 |
+
|
715 |
+
// token resources
|
716 |
+
/**
|
717 |
+
* The token call provides a consumer/secret key pair you can use to consistently access the user's account.
|
718 |
+
* This is the preferred method of authentication over storing the username and password.
|
719 |
+
* Use the key pair as a signature with every subsequent call.
|
720 |
+
* The request must be signed using the application's developer and secret key token. Request or access tokens are necessary.
|
721 |
+
*
|
722 |
+
* Warning: DO NOT STORE THE USER'S PASSWORD! The way this call works is you call it once with the user's email and password and then
|
723 |
+
* keep the token around for later. You do NOT (I repeat NOT) call this before everything you do or on each program startup.
|
724 |
+
* We watch for this and will shut down your application with little notice if we catch you.
|
725 |
+
* In fact, the Objective-C code does this for you so you can't get it wrong.
|
726 |
+
*
|
727 |
+
* @return array Upon successful verification of the user's credentials, returns an array representation of the access token and secret.
|
728 |
+
* @param string $email The email account of the user.
|
729 |
+
* @param string $password The password of the user.
|
730 |
+
*/
|
731 |
+
public function token($email, $password)
|
732 |
+
{
|
733 |
+
// build parameters
|
734 |
+
$parameters = array();
|
735 |
+
$parameters['email'] = (string) $email;
|
736 |
+
$parameters['password'] = (string) $password;
|
737 |
+
|
738 |
+
// make the call
|
739 |
+
$response = (array) $this->doOAuthCall('0/token', $parameters);
|
740 |
+
|
741 |
+
// validate and set
|
742 |
+
if(isset($response['token'])) $this->setOAuthToken($response['token']);
|
743 |
+
if(isset($response['secret'])) $this->setOAuthTokenSecret($response['secret']);
|
744 |
+
|
745 |
+
// return
|
746 |
+
return $response;
|
747 |
+
}
|
748 |
+
|
749 |
+
|
750 |
+
// account resources
|
751 |
+
/**
|
752 |
+
* Given a set of account information, the account call allows an application to create a new Dropbox user account.
|
753 |
+
* This is useful for situations where the trusted third party application is possibly the user's first interaction with Dropbox.
|
754 |
+
*
|
755 |
+
* @return bool
|
756 |
+
* @param string $email The email account of the user.
|
757 |
+
* @param string $password The password for the user.
|
758 |
+
* @param string $firstName The user's first name.
|
759 |
+
* @param string $lastName The user's last name.
|
760 |
+
*/
|
761 |
+
public function account($email, $password, $firstName, $lastName)
|
762 |
+
{
|
763 |
+
// build parameters
|
764 |
+
$parameters['email'] = (string) $email;
|
765 |
+
$parameters['first_name'] = (string) $firstName;
|
766 |
+
$parameters['last_name'] = (string) $lastName;
|
767 |
+
$parameters['password'] = (string) $password;
|
768 |
+
|
769 |
+
return (bool) ($this->doCall('0/account', $parameters, 'POST', null, false) == 'OK');
|
770 |
+
}
|
771 |
+
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Get the user account information.
|
775 |
+
*
|
776 |
+
* @return array
|
777 |
+
*/
|
778 |
+
public function accountInfo()
|
779 |
+
{
|
780 |
+
// make the call
|
781 |
+
return (array) $this->doCall('0/account/info');
|
782 |
+
}
|
783 |
+
|
784 |
+
|
785 |
+
// files & metadata
|
786 |
+
/**
|
787 |
+
* Retrieves file contents relative to the user's Dropbox root or the application's directory within the user's Dropbox.
|
788 |
+
*
|
789 |
+
* @return string
|
790 |
+
* @param string $path Path of the directory wherin the file is located.
|
791 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
792 |
+
*/
|
793 |
+
public function filesGet($path, $sandbox = false)
|
794 |
+
{
|
795 |
+
// build url
|
796 |
+
$url = '0/files/';
|
797 |
+
$url .= ($sandbox) ? 'sandbox/' : 'dropbox/';
|
798 |
+
$url .= trim((string) $path, '/');
|
799 |
+
|
800 |
+
// make the call
|
801 |
+
return $this->doCall($url, null, 'GET', null, false, true);
|
802 |
+
}
|
803 |
+
|
804 |
+
|
805 |
+
/**
|
806 |
+
* Uploads file contents relative to the user's Dropbox root or the application's directory within the user's Dropbox.
|
807 |
+
*
|
808 |
+
* @return bool
|
809 |
+
* @param string $path Path of the directory wherin the file should be uploaded.
|
810 |
+
* @param string $file Path to the local file.
|
811 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
812 |
+
*/
|
813 |
+
public function filesPost($path, $localFile, $sandbox = false)
|
814 |
+
{
|
815 |
+
// build url
|
816 |
+
$url = '0/files/';
|
817 |
+
$url .= ($sandbox) ? 'sandbox/' : 'dropbox/';
|
818 |
+
$url .= trim((string) $path, '/');
|
819 |
+
|
820 |
+
// make the call
|
821 |
+
return $this->doCall($url, null, 'POST', $localFile, true, true);
|
822 |
+
}
|
823 |
+
|
824 |
+
|
825 |
+
/**
|
826 |
+
* Returns metadata for the file or directory at the given <path> location relative to the user's Dropbox or
|
827 |
+
* the user's application sandbox. If <path> represents a directory and the list parameter is true, the metadata will
|
828 |
+
* also include a listing of metadata for the directory's contents.
|
829 |
+
*
|
830 |
+
* @return array
|
831 |
+
* @param int[optional] $fileLimit When listing a directory, the service will not report listings containing more than $fileLimit files.
|
832 |
+
* @param bool[optional] $hash Listing return values include a hash representing the state of the directory's contents.
|
833 |
+
* @param bool[optional] $list If true, this call returns a list of metadata representations for the contents of the directory. If false, this call returns the metadata for the directory itself.
|
834 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
835 |
+
*/
|
836 |
+
public function metadata($path = '', $fileLimit = 10000, $hash = false, $list = true, $sandbox = false)
|
837 |
+
{
|
838 |
+
// build url
|
839 |
+
$url = '0/metadata/';
|
840 |
+
$url .= ($sandbox) ? 'sandbox/' : 'dropbox/';
|
841 |
+
$url .= trim((string) $path, '/');
|
842 |
+
|
843 |
+
// build parameters
|
844 |
+
$parameters = null;
|
845 |
+
$parameters['file_limit'] = (int) $fileLimit;
|
846 |
+
if((bool) $hash) $parameters['hash'] = '';
|
847 |
+
$parameters['list'] = ($list) ? 'true': 'false';
|
848 |
+
|
849 |
+
// make the call
|
850 |
+
return (array) $this->doCall($url, $parameters);
|
851 |
+
}
|
852 |
+
|
853 |
+
|
854 |
+
/**
|
855 |
+
* Get a minimized thumbnail for a photo.
|
856 |
+
*
|
857 |
+
* @return string Will return a base64_encode string with the JPEG-data
|
858 |
+
* @param string $path The path to the photo.
|
859 |
+
* @param string[optional] $size The size, possible values are: 'small' (32x32), 'medium' (64x64), 'large' (128x128)
|
860 |
+
*/
|
861 |
+
public function thumbnails($path, $size = 'small')
|
862 |
+
{
|
863 |
+
// build url
|
864 |
+
$url = '0/thumbnails/dropbox/';
|
865 |
+
$url .= trim((string) $path, '/');
|
866 |
+
|
867 |
+
// build parameters
|
868 |
+
$parameters['size'] = (string) $size;
|
869 |
+
|
870 |
+
// make the call
|
871 |
+
return $this->doCall($url, $parameters, 'GET', null, false, true);
|
872 |
+
}
|
873 |
+
|
874 |
+
|
875 |
+
// file operations
|
876 |
+
/**
|
877 |
+
* Copy a file or folder to a new location.
|
878 |
+
*
|
879 |
+
* @return array
|
880 |
+
* @param string $fromPath fromPath specifies either a file or folder to be copied to the location specified by toPath. This path is interpreted relative to the location specified by root.
|
881 |
+
* @param string $toPath toPath specifies the destination path including the new name for file or folder. This path is interpreted relative to the location specified by root.
|
882 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
883 |
+
*/
|
884 |
+
public function fileopsCopy($fromPath, $toPath, $sandbox = false)
|
885 |
+
{
|
886 |
+
// build url
|
887 |
+
$url = '0/fileops/copy';
|
888 |
+
|
889 |
+
// build parameters
|
890 |
+
$parameters['from_path'] = (string) $fromPath;
|
891 |
+
$parameters['to_path'] = (string) $toPath;
|
892 |
+
$parameters['root'] = ($sandbox) ? 'sandbox' : 'dropbox';
|
893 |
+
|
894 |
+
// make the call
|
895 |
+
return $this->doCall($url, $parameters, 'POST');
|
896 |
+
}
|
897 |
+
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Create a folder relative to the user's Dropbox root or the user's application sandbox folder.
|
901 |
+
*
|
902 |
+
* @return array
|
903 |
+
* @param string $path The path to the new folder to create, relative to root.
|
904 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
905 |
+
*/
|
906 |
+
public function fileopsCreateFolder($path, $sandbox = false)
|
907 |
+
{
|
908 |
+
// build url
|
909 |
+
$url = '0/fileops/create_folder';
|
910 |
+
|
911 |
+
// build parameters
|
912 |
+
$parameters['path'] = trim((string) $path, '/');
|
913 |
+
$parameters['root'] = ($sandbox) ? 'sandbox' : 'dropbox';
|
914 |
+
|
915 |
+
// make the call
|
916 |
+
return $this->doCall($url, $parameters, 'POST');
|
917 |
+
}
|
918 |
+
|
919 |
+
|
920 |
+
/**
|
921 |
+
* Deletes a file or folder.
|
922 |
+
*
|
923 |
+
* @return array
|
924 |
+
* @param string $path path specifies either a file or folder to be deleted. This path is interpreted relative to the location specified by root.
|
925 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
926 |
+
*/
|
927 |
+
public function fileopsDelete($path, $sandbox = false)
|
928 |
+
{
|
929 |
+
// build url
|
930 |
+
$url = '0/fileops/delete';
|
931 |
+
|
932 |
+
// build parameters
|
933 |
+
$parameters['path'] = trim((string) $path, '/');
|
934 |
+
$parameters['root'] = ($sandbox) ? 'sandbox' : 'dropbox';
|
935 |
+
|
936 |
+
// make the call
|
937 |
+
return $this->doCall($url, $parameters, 'POST');
|
938 |
+
}
|
939 |
+
|
940 |
+
|
941 |
+
/**
|
942 |
+
* Move a file or folder to a new location.
|
943 |
+
*
|
944 |
+
* @return array
|
945 |
+
* @param string $fromPath fromPath specifies either a file or folder to be copied to the location specified by toPath. This path is interpreted relative to the location specified by root.
|
946 |
+
* @param string $toPath toPath specifies the destination path including the new name for file or folder. This path is interpreted relative to the location specified by root.
|
947 |
+
* @param bool[optional] $sandbox Sandbox mode?
|
948 |
+
*/
|
949 |
+
public function fileopsMove($fromPath, $toPath, $sandbox = false)
|
950 |
+
{
|
951 |
+
// build url
|
952 |
+
$url = '0/fileops/move';
|
953 |
+
|
954 |
+
// build parameters
|
955 |
+
$parameters['from_path'] = (string) $fromPath;
|
956 |
+
$parameters['to_path'] = (string) $toPath;
|
957 |
+
$parameters['root'] = ($sandbox) ? 'sandbox' : 'dropbox';
|
958 |
+
|
959 |
+
// make the call
|
960 |
+
return $this->doCall($url, $parameters, 'POST');
|
961 |
+
}
|
962 |
+
}
|
963 |
+
|
964 |
+
|
965 |
+
/**
|
966 |
+
* Dropbox Exception class
|
967 |
+
*
|
968 |
+
* @author Tijs Verkoyen <php-dropbox@verkoyen.eu>
|
969 |
+
*/
|
970 |
+
class DropboxException extends Exception
|
971 |
+
{
|
972 |
+
}
|
973 |
+
|
974 |
+
?>
|
app/list-tables.php
CHANGED
@@ -461,16 +461,23 @@ class BackWPup_Backups_Table extends WP_List_Table {
|
|
461 |
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="backupfiles[]" value="'. esc_attr($backup['file'].':'.$backup['jobid'].':'.$backup['type']) .'" /></th>';
|
462 |
break;
|
463 |
case 'backup':
|
|
|
|
|
|
|
|
|
|
|
464 |
if ($backup['type']=='FOLDER') {
|
465 |
-
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />"
|
466 |
} elseif ($backup['type']=='S3') {
|
467 |
-
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />S3://".$jobvalue['awsBucket']."/"
|
468 |
} elseif ($backup['type']=='FTP') {
|
469 |
-
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />ftp://".$jobvalue['ftphost']
|
470 |
} elseif ($backup['type']=='RSC') {
|
471 |
-
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />RSC://".$jobvalue['rscContainer']."/"
|
472 |
} elseif ($backup['type']=='MSAZURE') {
|
473 |
-
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />azure://".$jobvalue['msazureContainer']."/"
|
|
|
|
|
474 |
}
|
475 |
$actions = array();
|
476 |
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=delete&paged='.$this->get_pagenum().'&backupfiles[]='.esc_attr($backup['file'].':'.$backup['jobid'].':'.$backup['type']), 'bulk-backups') . "\" onclick=\"if ( confirm('" . esc_js(__("You are about to delete this Backup Archive. \n 'Cancel' to stop, 'OK' to delete.","backwpup")) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
|
461 |
$r .= '<th scope="row" class="check-column"><input type="checkbox" name="backupfiles[]" value="'. esc_attr($backup['file'].':'.$backup['jobid'].':'.$backup['type']) .'" /></th>';
|
462 |
break;
|
463 |
case 'backup':
|
464 |
+
$dir=dirname($backup['file']);
|
465 |
+
if ($dir=='.')
|
466 |
+
$dir='';
|
467 |
+
else
|
468 |
+
$dir.='/';
|
469 |
if ($backup['type']=='FOLDER') {
|
470 |
+
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />".$dir;
|
471 |
} elseif ($backup['type']=='S3') {
|
472 |
+
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />S3://".$jobvalue['awsBucket']."/".$dir;
|
473 |
} elseif ($backup['type']=='FTP') {
|
474 |
+
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />ftp://".$jobvalue['ftphost'].$dir;
|
475 |
} elseif ($backup['type']=='RSC') {
|
476 |
+
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />RSC://".$jobvalue['rscContainer']."/".$dir;
|
477 |
} elseif ($backup['type']=='MSAZURE') {
|
478 |
+
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />azure://".$jobvalue['msazureContainer']."/".$dir;
|
479 |
+
} elseif ($backup['type']=='DROPBOX') {
|
480 |
+
$r .= "<td $attributes><strong>".basename($backup['file'])."</strong><br />dropbox:/".$dir;
|
481 |
}
|
482 |
$actions = array();
|
483 |
$actions['delete'] = "<a class=\"submitdelete\" href=\"" . wp_nonce_url('admin.php?page=BackWPup&subpage=backups&action=delete&paged='.$this->get_pagenum().'&backupfiles[]='.esc_attr($backup['file'].':'.$backup['jobid'].':'.$backup['type']), 'bulk-backups') . "\" onclick=\"if ( confirm('" . esc_js(__("You are about to delete this Backup Archive. \n 'Cancel' to stop, 'OK' to delete.","backwpup")) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
|
app/options-edit-job.php
CHANGED
@@ -355,12 +355,12 @@ $dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
|
355 |
|
356 |
<?PHP if (in_array('S3',$dests)) { ?>
|
357 |
<div id="toamazon" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
358 |
-
<h3 class="hndle"><span><?PHP _e('Backup to Amazon S3','backwpup'); ?></span
|
359 |
<div class="inside">
|
360 |
<?PHP if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
361 |
echo "<b>".__('curl Support required','backwpup')."</b>";
|
362 |
} else { ?>
|
363 |
-
<b><?PHP _e('Access Key ID:','backwpup'); ?></b><br />
|
364 |
<input id="awsAccessKey" name="awsAccessKey" type="text" value="<?PHP echo $jobvalue['awsAccessKey'];?>" class="large-text" /><br />
|
365 |
<b><?PHP _e('Secret Access Key:','backwpup'); ?></b><br />
|
366 |
<input id="awsSecretKey" name="awsSecretKey" type="password" value="<?PHP echo $jobvalue['awsSecretKey'];?>" class="large-text" /><br />
|
@@ -379,7 +379,7 @@ $dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
|
379 |
|
380 |
<?PHP if (in_array('MSAZURE',$dests)) { ?>
|
381 |
<div id="tomsazure" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
382 |
-
<h3 class="hndle"><span><?PHP _e('Backup to Micosoft Azure (Blob)','backwpup'); ?></span></h3>
|
383 |
<div class="inside">
|
384 |
<?PHP if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
385 |
echo "<b>".__('curl Support required','backwpup')."</b>";
|
@@ -388,7 +388,7 @@ $dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
|
388 |
<input id="msazureHost" name="msazureHost" type="text" value="<?PHP echo $jobvalue['msazureHost'];?>" class="large-text" /><span class="description"><?PHP _e('Normely: blob.core.windows.net','backwpup');?></span><br />
|
389 |
<b><?PHP _e('Account Name:','backwpup'); ?></b><br />
|
390 |
<input id="msazureAccName" name="msazureAccName" type="text" value="<?PHP echo $jobvalue['msazureAccName'];?>" class="large-text" /><br />
|
391 |
-
<b><?PHP _e('Access Key:','backwpup'); ?></b><br />
|
392 |
<input id="msazureKey" name="msazureKey" type="password" value="<?PHP echo $jobvalue['msazureKey'];?>" class="large-text" /><br />
|
393 |
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
394 |
<input id="msazureContainerselected" name="msazureContainerselected" type="hidden" value="<?PHP echo $jobvalue['msazureContainer'];?>" />
|
@@ -404,14 +404,14 @@ $dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
|
404 |
|
405 |
<?PHP if (in_array('RSC',$dests)) { ?>
|
406 |
<div id="torsc" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
407 |
-
<h3 class="hndle"><span><?PHP _e('Backup to Rackspace Cloud','backwpup'); ?></span></h3>
|
408 |
<div class="inside">
|
409 |
<?PHP if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
410 |
echo "<b>".__('curl Support required','backwpup')."</b>";
|
411 |
} else { ?>
|
412 |
<b><?PHP _e('Username:','backwpup'); ?></b><br />
|
413 |
<input id="rscUsername" name="rscUsername" type="text" value="<?PHP echo $jobvalue['rscUsername'];?>" class="large-text" /><br />
|
414 |
-
<b><?PHP _e('API Key:','backwpup'); ?></b><br />
|
415 |
<input id="rscAPIKey" name="rscAPIKey" type="text" value="<?PHP echo $jobvalue['rscAPIKey'];?>" class="large-text" /><br />
|
416 |
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
417 |
<input id="rscContainerselected" name="rscContainerselected" type="hidden" value="<?PHP echo $jobvalue['rscContainer'];?>" />
|
@@ -427,7 +427,7 @@ $dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
|
427 |
|
428 |
<?PHP if (in_array('DROPBOX',$dests)) { ?>
|
429 |
<div id="todropbox" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
430 |
-
<h3 class="hndle"><span><?PHP _e('Backup to Dropbox','backwpup'); ?></span></h3>
|
431 |
<div class="inside">
|
432 |
<b><?PHP _e('Email:','backwpup'); ?></b><br />
|
433 |
<input name="dropemail" type="text" value="<?PHP echo $jobvalue['dropemail'];?>" class="large-text" /><br />
|
@@ -435,6 +435,7 @@ $dests=explode(',',strtoupper(BACKWPUP_DESTS));
|
|
435 |
<input name="dropepass" type="password" value="<?PHP echo base64_decode($jobvalue['dropepass']);?>" class="password large-text" /><br />
|
436 |
<b><?PHP _e('Directory:','backwpup'); ?></b><br />
|
437 |
<input name="dropedir" type="text" value="<?PHP echo $jobvalue['dropedir'];?>" class="user large-text" /><br />
|
|
|
438 |
</div>
|
439 |
</div>
|
440 |
<?PHP } ?>
|
355 |
|
356 |
<?PHP if (in_array('S3',$dests)) { ?>
|
357 |
<div id="toamazon" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
358 |
+
<h3 class="hndle"><span><?PHP _e('Backup to Amazon S3','backwpup'); ?></span> <a href="http://www.amazon.de/gp/redirect.html?ie=UTF8&location=http%3A%2F%2Fwww.amazon.com%2Fgp%2Faws%2Fregistration%2Fregistration-form.html&site-redirect=de&tag=hueskennet-21&linkCode=ur2&camp=1638&creative=6742" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a><img src="http://www.assoc-amazon.de/e/ir?t=hueskennet-21&l=ur2&o=3" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></h3>
|
359 |
<div class="inside">
|
360 |
<?PHP if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
361 |
echo "<b>".__('curl Support required','backwpup')."</b>";
|
362 |
} else { ?>
|
363 |
+
<b><?PHP _e('Access Key ID:','backwpup'); ?></b> <a href="http://aws-portal.amazon.com/gp/aws/developer/account/index.html?action=access-key" target="_blank"><?PHP _e('Find it','backwpup'); ?></a><br />
|
364 |
<input id="awsAccessKey" name="awsAccessKey" type="text" value="<?PHP echo $jobvalue['awsAccessKey'];?>" class="large-text" /><br />
|
365 |
<b><?PHP _e('Secret Access Key:','backwpup'); ?></b><br />
|
366 |
<input id="awsSecretKey" name="awsSecretKey" type="password" value="<?PHP echo $jobvalue['awsSecretKey'];?>" class="large-text" /><br />
|
379 |
|
380 |
<?PHP if (in_array('MSAZURE',$dests)) { ?>
|
381 |
<div id="tomsazure" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
382 |
+
<h3 class="hndle"><span><?PHP _e('Backup to Micosoft Azure (Blob)','backwpup'); ?></span> <a href="http://www.microsoft.com/windowsazure/offers/" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a></h3>
|
383 |
<div class="inside">
|
384 |
<?PHP if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
385 |
echo "<b>".__('curl Support required','backwpup')."</b>";
|
388 |
<input id="msazureHost" name="msazureHost" type="text" value="<?PHP echo $jobvalue['msazureHost'];?>" class="large-text" /><span class="description"><?PHP _e('Normely: blob.core.windows.net','backwpup');?></span><br />
|
389 |
<b><?PHP _e('Account Name:','backwpup'); ?></b><br />
|
390 |
<input id="msazureAccName" name="msazureAccName" type="text" value="<?PHP echo $jobvalue['msazureAccName'];?>" class="large-text" /><br />
|
391 |
+
<b><?PHP _e('Access Key:','backwpup'); ?></b> <a href="http://windows.azure.com/" target="_blank"><?PHP _e('Find it','backwpup'); ?></a><br />
|
392 |
<input id="msazureKey" name="msazureKey" type="password" value="<?PHP echo $jobvalue['msazureKey'];?>" class="large-text" /><br />
|
393 |
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
394 |
<input id="msazureContainerselected" name="msazureContainerselected" type="hidden" value="<?PHP echo $jobvalue['msazureContainer'];?>" />
|
404 |
|
405 |
<?PHP if (in_array('RSC',$dests)) { ?>
|
406 |
<div id="torsc" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
407 |
+
<h3 class="hndle"><span><?PHP _e('Backup to Rackspace Cloud','backwpup'); ?></span> <a href="http://www.rackspacecloud.com/2073.html" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a></h3>
|
408 |
<div class="inside">
|
409 |
<?PHP if (!(extension_loaded('curl') or @dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll'))) {
|
410 |
echo "<b>".__('curl Support required','backwpup')."</b>";
|
411 |
} else { ?>
|
412 |
<b><?PHP _e('Username:','backwpup'); ?></b><br />
|
413 |
<input id="rscUsername" name="rscUsername" type="text" value="<?PHP echo $jobvalue['rscUsername'];?>" class="large-text" /><br />
|
414 |
+
<b><?PHP _e('API Key:','backwpup'); ?></b> <a href="https://manage.rackspacecloud.com/APIAccess.do" target="_blank"><?PHP _e('Find it','backwpup'); ?></a><br />
|
415 |
<input id="rscAPIKey" name="rscAPIKey" type="text" value="<?PHP echo $jobvalue['rscAPIKey'];?>" class="large-text" /><br />
|
416 |
<b><?PHP _e('Container:','backwpup'); ?></b><br />
|
417 |
<input id="rscContainerselected" name="rscContainerselected" type="hidden" value="<?PHP echo $jobvalue['rscContainer'];?>" />
|
427 |
|
428 |
<?PHP if (in_array('DROPBOX',$dests)) { ?>
|
429 |
<div id="todropbox" class="postbox" <?PHP if (!in_array("FILE",$todo) and !in_array("DB",$todo) and !in_array("WPEXP",$todo)) echo 'style="display:none;"';?>>
|
430 |
+
<h3 class="hndle"><span><?PHP _e('Backup to Dropbox','backwpup'); ?></span> <a href="http://db.tt/MfxHKBd" target="_blank"><?PHP _e('Create Account','backwpup'); ?></a></h3>
|
431 |
<div class="inside">
|
432 |
<b><?PHP _e('Email:','backwpup'); ?></b><br />
|
433 |
<input name="dropemail" type="text" value="<?PHP echo $jobvalue['dropemail'];?>" class="large-text" /><br />
|
435 |
<input name="dropepass" type="password" value="<?PHP echo base64_decode($jobvalue['dropepass']);?>" class="password large-text" /><br />
|
436 |
<b><?PHP _e('Directory:','backwpup'); ?></b><br />
|
437 |
<input name="dropedir" type="text" value="<?PHP echo $jobvalue['dropedir'];?>" class="user large-text" /><br />
|
438 |
+
<?PHP _e('Max. Backup Files in Dopbox Folder:','backwpup'); ?><input name="dropemaxbackups" type="text" size="3" value="<?PHP echo $jobvalue['dropemaxbackups'];?>" class="small-text" /><span class="description"><?PHP _e('(Oldest files will deleted first.)','backwpup');?></span><br />
|
439 |
</div>
|
440 |
</div>
|
441 |
<?PHP } ?>
|
app/options-save.php
CHANGED
@@ -163,7 +163,9 @@ function backwpup_backups_operations($action) {
|
|
163 |
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
164 |
if (!class_exists('CF_Authentication'))
|
165 |
require_once(plugin_dir_path(__FILE__).'libs/rackspace/cloudfiles.php');
|
166 |
-
|
|
|
|
|
167 |
|
168 |
$num=0;
|
169 |
foreach ($deletebackups as $backups) {
|
@@ -185,7 +187,15 @@ function backwpup_backups_operations($action) {
|
|
185 |
$storageClient->deleteBlob($jobvalue['msazureContainer'],$backups['file']);
|
186 |
}
|
187 |
}
|
188 |
-
} elseif ($backups['type']=='
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
if (class_exists('CF_Authentication')) {
|
190 |
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
191 |
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
@@ -256,8 +266,12 @@ function backwpup_backups_operations($action) {
|
|
256 |
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
257 |
$jobs=get_option('backwpup_jobs');
|
258 |
$jobid=$_GET['jobid'];
|
259 |
-
|
260 |
-
|
|
|
|
|
|
|
|
|
261 |
if ($s3file->status==200) {
|
262 |
header("Pragma: public");
|
263 |
header("Expires: 0");
|
@@ -276,59 +290,95 @@ function backwpup_backups_operations($action) {
|
|
276 |
die();
|
277 |
}
|
278 |
break;
|
279 |
-
case '
|
280 |
check_admin_referer('download-backup');
|
281 |
-
|
282 |
-
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
283 |
-
require_once 'Microsoft/WindowsAzure/Storage/Blob.php';
|
284 |
$jobs=get_option('backwpup_jobs');
|
285 |
$jobid=$_GET['jobid'];
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
break;
|
302 |
-
case '
|
303 |
check_admin_referer('download-backup');
|
304 |
-
|
|
|
|
|
305 |
$jobs=get_option('backwpup_jobs');
|
306 |
$jobid=$_GET['jobid'];
|
307 |
-
|
308 |
-
|
309 |
-
if ($auth->authenticate()) {
|
310 |
-
$conn = new CF_Connection($auth);
|
311 |
-
$conn->ssl_use_cabundle();
|
312 |
-
$backwpupcontainer = $conn->get_container($jobs[$jobid]['rscContainer']);
|
313 |
-
$backupfile=$backwpupcontainer->get_object($_GET['file']);
|
314 |
header("Pragma: public");
|
315 |
header("Expires: 0");
|
316 |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
317 |
-
header("Content-Type: ".$
|
318 |
header("Content-Type: application/force-download");
|
319 |
header("Content-Type: application/octet-stream");
|
320 |
header("Content-Type: application/download");
|
321 |
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
322 |
header("Content-Transfer-Encoding: binary");
|
323 |
-
header("Content-Length: ".$
|
324 |
-
$
|
325 |
-
$backupfile->stream($output);
|
326 |
-
fclose($output);
|
327 |
die();
|
328 |
-
}
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
break;
|
333 |
}
|
334 |
}
|
@@ -451,6 +501,7 @@ function backwpup_save_job() { //Save Job settings
|
|
451 |
$jobs[$jobid]['ftppasv']= $_POST['ftppasv']==1 ? true : false;
|
452 |
$jobs[$jobid]['dropemail']=$_POST['dropemail'];
|
453 |
$jobs[$jobid]['dropepass']=base64_encode($_POST['dropepass']);
|
|
|
454 |
$jobs[$jobid]['dropedir']=$_POST['dropedir'];
|
455 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
456 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
163 |
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
164 |
if (!class_exists('CF_Authentication'))
|
165 |
require_once(plugin_dir_path(__FILE__).'libs/rackspace/cloudfiles.php');
|
166 |
+
if (!class_exists('Dropbox'))
|
167 |
+
require_once(dirname(__FILE__).'/libs/dropbox.php');
|
168 |
+
}
|
169 |
|
170 |
$num=0;
|
171 |
foreach ($deletebackups as $backups) {
|
187 |
$storageClient->deleteBlob($jobvalue['msazureContainer'],$backups['file']);
|
188 |
}
|
189 |
}
|
190 |
+
} elseif ($backups['type']=='DROPBOX') {
|
191 |
+
if (class_exists('Dropbox')) {
|
192 |
+
if (!empty($jobvalue['dropemail']) and !empty($jobvalue['dropepass'])) {
|
193 |
+
$dropbox = new Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET);
|
194 |
+
$dropbox->token($jobvalue['dropemail'], base64_decode($jobvalue['dropepass']));
|
195 |
+
$dropbox->fileopsDelete($backups['file']);
|
196 |
+
}
|
197 |
+
}
|
198 |
+
}elseif ($backups['type']=='RSC') {
|
199 |
if (class_exists('CF_Authentication')) {
|
200 |
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
201 |
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
266 |
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
267 |
$jobs=get_option('backwpup_jobs');
|
268 |
$jobid=$_GET['jobid'];
|
269 |
+
try {
|
270 |
+
$s3 = new AmazonS3($jobs[$jobid]['awsAccessKey'], $jobs[$jobid]['awsSecretKey']);
|
271 |
+
$s3file=$s3->get_object($jobs[$jobid]['awsBucket'], $_GET['file']);
|
272 |
+
} catch (Exception $e) {
|
273 |
+
die($e->getMessage());
|
274 |
+
}
|
275 |
if ($s3file->status==200) {
|
276 |
header("Pragma: public");
|
277 |
header("Expires: 0");
|
290 |
die();
|
291 |
}
|
292 |
break;
|
293 |
+
case 'downloaddropbox': //Download Dropbox Backup
|
294 |
check_admin_referer('download-backup');
|
295 |
+
require_once(dirname(__FILE__).'/libs/dropbox.php');
|
|
|
|
|
296 |
$jobs=get_option('backwpup_jobs');
|
297 |
$jobid=$_GET['jobid'];
|
298 |
+
try {
|
299 |
+
$dropbox = new Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET);
|
300 |
+
$dropbox->token($jobs[$jobid]['dropemail'], base64_decode($jobs[$jobid]['dropepass']));
|
301 |
+
$dropfile = $dropbox->filesGet($_GET['file']);
|
302 |
+
} catch (Exception $e) {
|
303 |
+
die($e->getMessage());
|
304 |
+
}
|
305 |
+
if (!empty($dropfile['content_type'])) {
|
306 |
+
header("Pragma: public");
|
307 |
+
header("Expires: 0");
|
308 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
309 |
+
header("Content-Type: ".$dropfile['content_type']);
|
310 |
+
header("Content-Type: application/force-download");
|
311 |
+
header("Content-Type: application/octet-stream");
|
312 |
+
header("Content-Type: application/download");
|
313 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
314 |
+
header("Content-Transfer-Encoding: binary");
|
315 |
+
header("Content-Length: ".$dropfile['bytes']);
|
316 |
+
echo base64_decode($dropfile['data']);
|
317 |
+
die();
|
318 |
+
} else {
|
319 |
+
header('HTTP/1.0 '.$s3file->status.' Not Found');
|
320 |
+
die();
|
321 |
+
}
|
322 |
break;
|
323 |
+
case 'downloadmsazure': //Download Microsoft Azure Backup
|
324 |
check_admin_referer('download-backup');
|
325 |
+
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__FILE__).'/libs');
|
326 |
+
if (!class_exists('Microsoft_WindowsAzure_Storage_Blob'))
|
327 |
+
require_once 'Microsoft/WindowsAzure/Storage/Blob.php';
|
328 |
$jobs=get_option('backwpup_jobs');
|
329 |
$jobid=$_GET['jobid'];
|
330 |
+
try {
|
331 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobs[$jobid]['msazureHost'],$jobs[$jobid]['msazureAccName'],$jobs[$jobid]['msazureKey']);
|
|
|
|
|
|
|
|
|
|
|
332 |
header("Pragma: public");
|
333 |
header("Expires: 0");
|
334 |
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
335 |
+
//header("Content-Type: ".$s3file->header->_info->content_type);
|
336 |
header("Content-Type: application/force-download");
|
337 |
header("Content-Type: application/octet-stream");
|
338 |
header("Content-Type: application/download");
|
339 |
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
340 |
header("Content-Transfer-Encoding: binary");
|
341 |
+
//header("Content-Length: ".$s3file->header->_info->size_download);
|
342 |
+
echo $storageClient->getBlobData($jobs[$jobid]['msazureContainer'], $_GET['file']);
|
|
|
|
|
343 |
die();
|
344 |
+
} catch (Exception $e) {
|
345 |
+
die($e->getMessage());
|
346 |
+
}
|
347 |
+
break;
|
348 |
+
case 'downloadrsc': //Download RSC Backup
|
349 |
+
check_admin_referer('download-backup');
|
350 |
+
require_once(plugin_dir_path(__FILE__).'libs/rackspace/cloudfiles.php');
|
351 |
+
$jobs=get_option('backwpup_jobs');
|
352 |
+
$jobid=$_GET['jobid'];
|
353 |
+
try {
|
354 |
+
$auth = new CF_Authentication($jobs[$jobid]['rscUsername'], $jobs[$jobid]['rscAPIKey']);
|
355 |
+
$auth->ssl_use_cabundle();
|
356 |
+
if ($auth->authenticate()) {
|
357 |
+
$conn = new CF_Connection($auth);
|
358 |
+
$conn->ssl_use_cabundle();
|
359 |
+
$backwpupcontainer = $conn->get_container($jobs[$jobid]['rscContainer']);
|
360 |
+
$backupfile=$backwpupcontainer->get_object($_GET['file']);
|
361 |
+
header("Pragma: public");
|
362 |
+
header("Expires: 0");
|
363 |
+
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
364 |
+
header("Content-Type: ".$backupfile->content_type);
|
365 |
+
header("Content-Type: application/force-download");
|
366 |
+
header("Content-Type: application/octet-stream");
|
367 |
+
header("Content-Type: application/download");
|
368 |
+
header("Content-Disposition: attachment; filename=".basename($_GET['file']).";");
|
369 |
+
header("Content-Transfer-Encoding: binary");
|
370 |
+
header("Content-Length: ".$backupfile->content_length);
|
371 |
+
$output = fopen("php://output", "w");
|
372 |
+
$backupfile->stream($output);
|
373 |
+
fclose($output);
|
374 |
+
die();
|
375 |
+
} else {
|
376 |
+
header('HTTP/1.0 404 Not Found');
|
377 |
+
die(__('File does not exist.', 'backwpup'));
|
378 |
+
}
|
379 |
+
} catch (Exception $e) {
|
380 |
+
die($e->getMessage());
|
381 |
+
}
|
382 |
break;
|
383 |
}
|
384 |
}
|
501 |
$jobs[$jobid]['ftppasv']= $_POST['ftppasv']==1 ? true : false;
|
502 |
$jobs[$jobid]['dropemail']=$_POST['dropemail'];
|
503 |
$jobs[$jobid]['dropepass']=base64_encode($_POST['dropepass']);
|
504 |
+
$jobs[$jobid]['dropemaxbackups']=(int)$_POST['dropemaxbackups'];
|
505 |
$jobs[$jobid]['dropedir']=$_POST['dropedir'];
|
506 |
$jobs[$jobid]['awsAccessKey']=$_POST['awsAccessKey'];
|
507 |
$jobs[$jobid]['awsSecretKey']=$_POST['awsSecretKey'];
|
app/{functions.php → php-functions.php}
RENAMED
File without changes
|
app/{functions5.php → php5-functions.php}
RENAMED
@@ -256,8 +256,7 @@ function backwpup_check_job_vars($jobsettings,$jobid='') {
|
|
256 |
|
257 |
if (!isset($jobsettings['rscmaxbackups']) or !is_int($jobsettings['rscmaxbackups']))
|
258 |
$jobsettings['rscmaxbackups']=0;
|
259 |
-
|
260 |
-
|
261 |
if (!isset($jobsettings['dropemail']) or !is_string($jobsettings['dropemail']))
|
262 |
$jobsettings['dropemail']='';
|
263 |
|
@@ -268,7 +267,10 @@ function backwpup_check_job_vars($jobsettings,$jobid='') {
|
|
268 |
$jobsettings['dropedir']='';
|
269 |
$jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['dropedir']))));
|
270 |
if (substr($jobsettings['dropedir'],0,1)=='/')
|
271 |
-
$jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
|
|
|
|
|
|
|
272 |
|
273 |
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
274 |
$jobsettings['mailaddress']='';
|
@@ -292,6 +294,8 @@ function backwpup_get_backup_files($onlyjobid='') {
|
|
292 |
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
293 |
if (!class_exists('CF_Authentication'))
|
294 |
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
|
|
|
|
295 |
}
|
296 |
|
297 |
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
@@ -323,72 +327,107 @@ function backwpup_get_backup_files($onlyjobid='') {
|
|
323 |
$donefolders[]=$jobvalue['backupdir'];
|
324 |
}
|
325 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
//Get files/filinfo from S3
|
327 |
if (class_exists('AmazonS3') and in_array('S3',$dests) and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
328 |
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
$
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
|
|
|
|
341 |
}
|
342 |
}
|
|
|
|
|
343 |
}
|
344 |
-
$donefolders[]=$jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'];
|
345 |
}
|
346 |
}
|
347 |
//Get files/filinfo from Microsoft Azure
|
348 |
if (class_exists('Microsoft_WindowsAzure_Storage_Blob') and in_array('MSAZURE',$dests) and !in_array($jobvalue['msazureAccName'].'|'.$jobvalue['msazureKey'].'|'.$jobvalue['msazureContainer'].'|'.$jobvalue['msazuredir'],$donefolders)) {
|
349 |
if (!empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer'])) {
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
$
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
|
|
|
|
363 |
}
|
364 |
}
|
|
|
|
|
365 |
}
|
366 |
-
$donefolders[]=$jobvalue['msazureAccName'].'|'.$jobvalue['msazureKey'].'|'.$jobvalue['msazureContainer'].'|'.$jobvalue['msazuredir'];
|
367 |
}
|
368 |
}
|
369 |
//Get files/filinfo from RSC
|
370 |
if (class_exists('CF_Authentication') and in_array('RSC',$dests) and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
371 |
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
$
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
|
|
|
|
389 |
}
|
|
|
390 |
}
|
391 |
-
|
392 |
}
|
393 |
}
|
394 |
}
|
256 |
|
257 |
if (!isset($jobsettings['rscmaxbackups']) or !is_int($jobsettings['rscmaxbackups']))
|
258 |
$jobsettings['rscmaxbackups']=0;
|
259 |
+
|
|
|
260 |
if (!isset($jobsettings['dropemail']) or !is_string($jobsettings['dropemail']))
|
261 |
$jobsettings['dropemail']='';
|
262 |
|
267 |
$jobsettings['dropedir']='';
|
268 |
$jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['dropedir']))));
|
269 |
if (substr($jobsettings['dropedir'],0,1)=='/')
|
270 |
+
$jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
|
271 |
+
|
272 |
+
if (!isset($jobsettings['dropemaxbackups']) or !is_int($jobsettings['dropemaxbackups']))
|
273 |
+
$jobsettings['dropemaxbackups']=0;
|
274 |
|
275 |
if (!is_string($jobsettings['mailaddress']) or false === $pos=strpos($jobsettings['mailaddress'],'@') or false === strpos($jobsettings['mailaddress'],'.',$pos))
|
276 |
$jobsettings['mailaddress']='';
|
294 |
require_once(dirname(__FILE__).'/libs/aws/sdk.class.php');
|
295 |
if (!class_exists('CF_Authentication'))
|
296 |
require_once(dirname(__FILE__).'/libs/rackspace/cloudfiles.php');
|
297 |
+
if (!class_exists('Dropbox'))
|
298 |
+
require_once(dirname(__FILE__).'/libs/dropbox.php');
|
299 |
}
|
300 |
|
301 |
foreach ($jobs as $jobid => $jobvalue) { //go job by job
|
327 |
$donefolders[]=$jobvalue['backupdir'];
|
328 |
}
|
329 |
}
|
330 |
+
//Get files/filinfo from Dropbox
|
331 |
+
if (class_exists('Dropbox') and in_array('DROPBOX',$dests) and !in_array($jobvalue['dropemail'].'|'.$jobvalue['dropepass'].'|'.$jobvalue['dropedir'],$donefolders)) {
|
332 |
+
if (!empty($jobvalue['dropemail']) and !empty($jobvalue['dropepass'])) {
|
333 |
+
try {
|
334 |
+
$dropbox = new Dropbox(BACKWPUP_DROPBOX_APP_KEY, BACKWPUP_DROPBOX_APP_SECRET);
|
335 |
+
$dropbox->token($jobvalue['dropemail'], base64_decode($jobvalue['dropepass']));
|
336 |
+
$contents = $dropbox->metadata($jobvalue['dropedir']);
|
337 |
+
if (is_array($contents)) {
|
338 |
+
foreach ($contents['contents'] as $object) {
|
339 |
+
if ($object['is_dir']!=true and (strtolower(substr($object['path'],-4))=='.zip' or strtolower(substr($object['path'],-4))=='.tar' or strtolower(substr($object['path'],-7))=='.tar.gz' or strtolower(substr($$object['path'],-8))=='.tar.bz2')) {
|
340 |
+
$files[$filecounter]['type']='DROPBOX';
|
341 |
+
$files[$filecounter]['jobid']=$jobid;
|
342 |
+
$files[$filecounter]['file']=$object['path'];
|
343 |
+
$files[$filecounter]['filename']=basename($object['path']);
|
344 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloaddropbox&file='.$object['path'].'&jobid='.$jobid;
|
345 |
+
$files[$filecounter]['filesize']=$object['bytes'];
|
346 |
+
$files[$filecounter]['time']=strtotime($object['modified']);
|
347 |
+
$filecounter++;
|
348 |
+
}
|
349 |
+
}
|
350 |
+
}
|
351 |
+
$donefolders[]=$jobvalue['dropemail'].'|'.$jobvalue['dropepass'].'|'.$jobvalue['dropedir'];
|
352 |
+
} catch (Exception $e) {
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
//Get files/filinfo from S3
|
357 |
if (class_exists('AmazonS3') and in_array('S3',$dests) and !in_array($jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'],$donefolders)) {
|
358 |
if (!empty($jobvalue['awsAccessKey']) and !empty($jobvalue['awsSecretKey']) and !empty($jobvalue['awsBucket'])) {
|
359 |
+
try {
|
360 |
+
$s3 = new AmazonS3($jobvalue['awsAccessKey'], $jobvalue['awsSecretKey']);
|
361 |
+
if (($contents = $s3->list_objects($jobvalue['awsBucket'],array('prefix'=>$jobvalue['awsdir']))) !== false) {
|
362 |
+
foreach ($contents->body->Contents as $object) {
|
363 |
+
if (strtolower(substr($object->Key,-4))=='.zip' or strtolower(substr($object->Key,-4))=='.tar' or strtolower(substr($object->Key,-7))=='.tar.gz' or strtolower(substr($object->Key,-8))=='.tar.bz2') {
|
364 |
+
$files[$filecounter]['type']='S3';
|
365 |
+
$files[$filecounter]['jobid']=$jobid;
|
366 |
+
$files[$filecounter]['file']=(string)$object->Key;
|
367 |
+
$files[$filecounter]['filename']=basename($object->Key);
|
368 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloads3&file='.$object->Key.'&jobid='.$jobid;
|
369 |
+
$files[$filecounter]['filesize']=(string)$object->Size;
|
370 |
+
$files[$filecounter]['time']=strtotime($object->LastModified);
|
371 |
+
$filecounter++;
|
372 |
+
}
|
373 |
}
|
374 |
}
|
375 |
+
$donefolders[]=$jobvalue['awsAccessKey'].'|'.$jobvalue['awsBucket'].'|'.$jobvalue['awsdir'];
|
376 |
+
} catch (Exception $e) {
|
377 |
}
|
|
|
378 |
}
|
379 |
}
|
380 |
//Get files/filinfo from Microsoft Azure
|
381 |
if (class_exists('Microsoft_WindowsAzure_Storage_Blob') and in_array('MSAZURE',$dests) and !in_array($jobvalue['msazureAccName'].'|'.$jobvalue['msazureKey'].'|'.$jobvalue['msazureContainer'].'|'.$jobvalue['msazuredir'],$donefolders)) {
|
382 |
if (!empty($jobvalue['msazureHost']) and !empty($jobvalue['msazureAccName']) and !empty($jobvalue['msazureKey']) and !empty($jobvalue['msazureContainer'])) {
|
383 |
+
try {
|
384 |
+
$storageClient = new Microsoft_WindowsAzure_Storage_Blob($jobvalue['msazureHost'],$jobvalue['msazureAccName'],$jobvalue['msazureKey']);
|
385 |
+
$blobs = $storageClient->listBlobs($jobvalue['msazureContainer'],$jobvalue['msazuredir']);
|
386 |
+
if (is_array($blobs)) {
|
387 |
+
foreach ($blobs as $blob) {
|
388 |
+
if (strtolower(substr($blob->Name,-4))=='.zip' or strtolower(substr($blob->Name,-4))=='.tar' or strtolower(substr($blob->Name,-7))=='.tar.gz' or strtolower(substr($blob->Name,-8))=='.tar.bz2') {
|
389 |
+
$files[$filecounter]['type']='MSAZURE';
|
390 |
+
$files[$filecounter]['jobid']=$jobid;
|
391 |
+
$files[$filecounter]['file']=$blob->Name;
|
392 |
+
$files[$filecounter]['filename']=basename($blob->Name);
|
393 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloadmsazure&file='.$blob->Name.'&jobid='.$jobid;
|
394 |
+
$files[$filecounter]['filesize']=$blob->size;
|
395 |
+
$files[$filecounter]['time']=strtotime($blob->lastmodified);
|
396 |
+
$filecounter++;
|
397 |
+
}
|
398 |
}
|
399 |
}
|
400 |
+
$donefolders[]=$jobvalue['msazureAccName'].'|'.$jobvalue['msazureKey'].'|'.$jobvalue['msazureContainer'].'|'.$jobvalue['msazuredir'];
|
401 |
+
} catch (Exception $e) {
|
402 |
}
|
|
|
403 |
}
|
404 |
}
|
405 |
//Get files/filinfo from RSC
|
406 |
if (class_exists('CF_Authentication') and in_array('RSC',$dests) and !in_array($jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'],$donefolders)) {
|
407 |
if (!empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
|
408 |
+
try {
|
409 |
+
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
|
410 |
+
$auth->ssl_use_cabundle();
|
411 |
+
if ($auth->authenticate()) {
|
412 |
+
$conn = new CF_Connection($auth);
|
413 |
+
$conn->ssl_use_cabundle();
|
414 |
+
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
|
415 |
+
$contents = $backwpupcontainer->get_objects(0,NULL,NULL,$jobvalue['rscdir']);
|
416 |
+
foreach ($contents as $object) {
|
417 |
+
if (strtolower(substr($object->name,-4))=='.zip' or strtolower(substr($object->name,-4))=='.tar' or strtolower(substr($object->name,-7))=='.tar.gz' or strtolower(substr($object->name,-8))=='.tar.bz2') {
|
418 |
+
$files[$filecounter]['type']='RSC';
|
419 |
+
$files[$filecounter]['jobid']=$jobid;
|
420 |
+
$files[$filecounter]['file']=$object->name;
|
421 |
+
$files[$filecounter]['filename']=basename($object->name);
|
422 |
+
$files[$filecounter]['downloadurl']='admin.php?page=BackWPup&subpage=backups&action=downloadrsc&file='.$object->name.'&jobid='.$jobid;
|
423 |
+
$files[$filecounter]['filesize']=$object->content_length;
|
424 |
+
$files[$filecounter]['time']=$object->last_modified;
|
425 |
+
$filecounter++;
|
426 |
+
}
|
427 |
}
|
428 |
+
$donefolders[]=$jobvalue['rscUsername'].'|'.$jobvalue['rscContainer'].'|'.$jobvalue['rscdir'];
|
429 |
}
|
430 |
+
} catch (Exception $e) {
|
431 |
}
|
432 |
}
|
433 |
}
|
backwpup.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: BackWPup
|
|
4 |
Plugin URI: http://danielhuesken.de/portfolio/backwpup/
|
5 |
Description: Backup and more of your WordPress Blog Database and Files.
|
6 |
Author: Daniel Hüsken
|
7 |
-
Version: 1.
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
@@ -34,16 +34,20 @@ if ( !defined('ABSPATH') )
|
|
34 |
//Set plugin dirname
|
35 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
36 |
//Set Plugin Version
|
37 |
-
define('BACKWPUP_VERSION', '1.
|
38 |
//Set User Capability
|
39 |
define('BACKWPUP_USER_CAPABILITY', 'export');
|
40 |
//Set useable destinations
|
41 |
if (!defined('BACKWPUP_DESTS'))
|
42 |
define('BACKWPUP_DESTS', 'S3,RSC,FTP,DROPBOX,MSAZURE');
|
|
|
|
|
|
|
|
|
43 |
//load Text Domain
|
44 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
45 |
//Load functions file
|
46 |
-
require_once(dirname(__FILE__).'/app/functions.php');
|
47 |
//Plugin activate
|
48 |
register_activation_hook(__FILE__, 'backwpup_plugin_activate');
|
49 |
//Plugin deactivate
|
@@ -52,7 +56,7 @@ register_deactivation_hook(__FILE__, 'backwpup_plugin_deactivate');
|
|
52 |
add_action('admin_notices', 'backwpup_admin_notice');
|
53 |
if (backwpup_env_checks()) {
|
54 |
//include php5 functions
|
55 |
-
require_once(dirname(__FILE__).'/app/
|
56 |
//add Menu
|
57 |
add_action('admin_menu', 'backwpup_admin_menu');
|
58 |
//add cron intervals
|
4 |
Plugin URI: http://danielhuesken.de/portfolio/backwpup/
|
5 |
Description: Backup and more of your WordPress Blog Database and Files.
|
6 |
Author: Daniel Hüsken
|
7 |
+
Version: 1.6.0
|
8 |
Author URI: http://danielhuesken.de
|
9 |
Text Domain: backwpup
|
10 |
Domain Path: /lang/
|
34 |
//Set plugin dirname
|
35 |
define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
|
36 |
//Set Plugin Version
|
37 |
+
define('BACKWPUP_VERSION', '1.6.0');
|
38 |
//Set User Capability
|
39 |
define('BACKWPUP_USER_CAPABILITY', 'export');
|
40 |
//Set useable destinations
|
41 |
if (!defined('BACKWPUP_DESTS'))
|
42 |
define('BACKWPUP_DESTS', 'S3,RSC,FTP,DROPBOX,MSAZURE');
|
43 |
+
//Set Dropbox Aplication Keys
|
44 |
+
define('BACKWPUP_DROPBOX_APP_KEY', 'q2jbt0unkkc54u2');
|
45 |
+
//Set Dropbox Aplication Keys
|
46 |
+
define('BACKWPUP_DROPBOX_APP_SECRET', 't5hlbxtz473hchy');
|
47 |
//load Text Domain
|
48 |
load_plugin_textdomain('backwpup', false, BACKWPUP_PLUGIN_BASEDIR.'/lang');
|
49 |
//Load functions file
|
50 |
+
require_once(dirname(__FILE__).'/app/php-functions.php');
|
51 |
//Plugin activate
|
52 |
register_activation_hook(__FILE__, 'backwpup_plugin_activate');
|
53 |
//Plugin deactivate
|
56 |
add_action('admin_notices', 'backwpup_admin_notice');
|
57 |
if (backwpup_env_checks()) {
|
58 |
//include php5 functions
|
59 |
+
require_once(dirname(__FILE__).'/app/php5-functions.php');
|
60 |
//add Menu
|
61 |
add_action('admin_menu', 'backwpup_admin_menu');
|
62 |
//add cron intervals
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=danie
|
|
4 |
Tags: backup, admin, file, Database, mysql, cron, ftp, S3, export, xml, Rackspase, cloud, azure, dropbox
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1.0
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
@@ -40,7 +40,7 @@ I can give no WARRANTY to any backups...
|
|
40 |
= Requires =
|
41 |
* PHP 5.2.0
|
42 |
* WordPress 2.8 better 3.1
|
43 |
-
* curl (for Amazon S3 Support)
|
44 |
* gzip (for PCLZIP and gzip archives)
|
45 |
* bzip2 (for bzip2 archives)
|
46 |
|
@@ -100,6 +100,12 @@ Destinations are:
|
|
100 |
1. Job Page
|
101 |
|
102 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
= 1.5.5 =
|
104 |
* Updatet AWS SDK to ver.1.2.6 for Amazon S3
|
105 |
* Added AWS Regin "Northeast" (Japan)
|
4 |
Tags: backup, admin, file, Database, mysql, cron, ftp, S3, export, xml, Rackspase, cloud, azure, dropbox
|
5 |
Requires at least: 2.8
|
6 |
Tested up to: 3.1.0
|
7 |
+
Stable tag: 1.6.0
|
8 |
|
9 |
Backup and more of your WordPress Blog Database and Files
|
10 |
|
40 |
= Requires =
|
41 |
* PHP 5.2.0
|
42 |
* WordPress 2.8 better 3.1
|
43 |
+
* curl (for Amazon S3, MS Azur, RackSpace,Dropbox Support)
|
44 |
* gzip (for PCLZIP and gzip archives)
|
45 |
* bzip2 (for bzip2 archives)
|
46 |
|
100 |
1. Job Page
|
101 |
|
102 |
== Changelog ==
|
103 |
+
= 1.6.0 =
|
104 |
+
* new dropbox class to use all functions (download, delete, list)
|
105 |
+
* added usefull inks in job edit page
|
106 |
+
* renamed functions.php to resolve problems with false includes of other plugins
|
107 |
+
* improvements
|
108 |
+
|
109 |
= 1.5.5 =
|
110 |
* Updatet AWS SDK to ver.1.2.6 for Amazon S3
|
111 |
* Added AWS Regin "Northeast" (Japan)
|