BackWPup – WordPress Backup Plugin - Version 2.1.6

Version Description

  • fixed Dropbox with no path problem
  • fixed Dropbox path with witespace
  • Updated AWS lib to 1.4.5
  • 2. fix for security vulnerability
Download this release

Release Info

Developer danielhuesken
Plugin Icon 128x128 BackWPup – WordPress Backup Plugin
Version 2.1.6
Comparing to
See all releases

Code changes from version 2.1.5 to 2.1.6

backwpup-functions.php CHANGED
@@ -174,6 +174,7 @@ function backwpup_plugin_deactivate() {
174
  $cfg=get_option('backwpup');
175
  $cfg['last_activate']=''; //set to not activated
176
  update_option('backwpup',$cfg);
 
177
  }
178
 
179
  //get temp dir
@@ -207,7 +208,7 @@ function backwpup_check_open_basedir($dir) {
207
  }
208
 
209
  //Backwpup API
210
- function backwpup_api() {
211
  global $wp_version;
212
  $cfg=get_option('backwpup');
213
  $blugurl=get_option('siteurl');
@@ -1048,7 +1049,7 @@ function backwpup_get_job_vars($jobid='',$jobnewsettings='') {
1048
 
1049
  if (!isset($jobsettings['dropedir']) or !is_string($jobsettings['dropedir']) or $jobsettings['dropedir']=='/')
1050
  $jobsettings['dropedir']='';
1051
- $jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',str_replace(' ','_',trim($jobsettings['dropedir'])))));
1052
  if (substr($jobsettings['dropedir'],0,1)=='/')
1053
  $jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
1054
 
174
  $cfg=get_option('backwpup');
175
  $cfg['last_activate']=''; //set to not activated
176
  update_option('backwpup',$cfg);
177
+ backwpup_api(false);
178
  }
179
 
180
  //get temp dir
208
  }
209
 
210
  //Backwpup API
211
+ function backwpup_api($active=false) {
212
  global $wp_version;
213
  $cfg=get_option('backwpup');
214
  $blugurl=get_option('siteurl');
1049
 
1050
  if (!isset($jobsettings['dropedir']) or !is_string($jobsettings['dropedir']) or $jobsettings['dropedir']=='/')
1051
  $jobsettings['dropedir']='';
1052
+ $jobsettings['dropedir']=trailingslashit(str_replace('//','/',str_replace('\\','/',trim($jobsettings['dropedir']))));
1053
  if (substr($jobsettings['dropedir'],0,1)=='/')
1054
  $jobsettings['dropedir']=substr($jobsettings['dropedir'],1);
1055
 
backwpup.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: BackWPup
4
  Plugin URI: http://backwpup.com
5
  Description: WordPress Backup and more...
6
  Author: Daniel Hüsken
7
- Version: 2.1.5
8
  Author URI: http://danielhuesken.de
9
  Text Domain: backwpup
10
  Domain Path: /lang/
@@ -32,7 +32,7 @@ Domain Path: /lang/
32
  define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
33
  define('BACKWPUP_PLUGIN_BASEURL',plugins_url('',__FILE__));
34
  //Set Plugin Version
35
- define('BACKWPUP_VERSION', '2.1.5');
36
  //Set Min Wordpress Version
37
  define('BACKWPUP_MIN_WORDPRESS_VERSION', '3.1');
38
  //Set User Capability
4
  Plugin URI: http://backwpup.com
5
  Description: WordPress Backup and more...
6
  Author: Daniel Hüsken
7
+ Version: 2.1.6
8
  Author URI: http://danielhuesken.de
9
  Text Domain: backwpup
10
  Domain Path: /lang/
32
  define('BACKWPUP_PLUGIN_BASEDIR', dirname(plugin_basename(__FILE__)));
33
  define('BACKWPUP_PLUGIN_BASEURL',plugins_url('',__FILE__));
34
  //Set Plugin Version
35
+ define('BACKWPUP_VERSION', '2.1.6');
36
  //Set Min Wordpress Version
37
  define('BACKWPUP_MIN_WORDPRESS_VERSION', '3.1');
38
  //Set User Capability
job/dest_dropbox.php CHANGED
@@ -29,7 +29,7 @@ function dest_dropbox() {
29
  $dropbox->setProgressFunction='curl_progresscallback';
30
  // put the file
31
  trigger_error(__('Upload to DropBox now started... ','backwpup'),E_USER_NOTICE);
32
- $response = $dropbox->upload($STATIC['JOB']['backupdir'].$STATIC['backupfile'],$STATIC['JOB']['dropedir']);
33
  if ($response['bytes']==filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])) {
34
  $STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloaddropbox&file='.$STATIC['JOB']['dropedir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
35
  $WORKING['STEPDONE']++;
29
  $dropbox->setProgressFunction='curl_progresscallback';
30
  // put the file
31
  trigger_error(__('Upload to DropBox now started... ','backwpup'),E_USER_NOTICE);
32
+ $response = $dropbox->upload($STATIC['JOB']['backupdir'].$STATIC['backupfile'],$STATIC['JOB']['dropedir'].$STATIC['backupfile']);
33
  if ($response['bytes']==filesize($STATIC['JOB']['backupdir'].$STATIC['backupfile'])) {
34
  $STATIC['JOB']['lastbackupdownloadurl']=$STATIC['WP']['ADMINURL'].'?page=backwpupbackups&action=downloaddropbox&file='.$STATIC['JOB']['dropedir'].$STATIC['backupfile'].'&jobid='.$STATIC['JOB']['jobid'];
35
  $WORKING['STEPDONE']++;
job/job_functions.php CHANGED
@@ -178,8 +178,10 @@ function delete_working_file() {
178
 
179
  function update_working_file($mustwrite=false) {
180
  global $WORKING,$STATIC,$runmicrotime;
181
- if (!file_exists($STATIC['TEMPDIR'].'.running'))
182
  job_end();
 
 
183
  if ($mustwrite or empty($runmicrotime) or $runmicrotime<(microtime()-1000)) { //only update all 1 sec.
184
  if ($WORKING['STEPTODO']>0 and $WORKING['STEPDONE']>0)
185
  $steppersent=round($WORKING['STEPDONE']/$WORKING['STEPTODO']*100);
@@ -313,10 +315,9 @@ function joberrorhandler() {
313
  function job_end() {
314
  global $WORKING,$STATIC,$mysqlconlink;
315
  //check if job_end allredy runs
316
- if (empty($WORKING['JOBENDINPROGRESS']) or !$WORKING['JOBENDINPROGRESS']) {
317
  $WORKING['JOBENDINPROGRESS']=true;
318
- update_working_file(true);
319
- } else
320
  return;
321
 
322
  $WORKING['STEPTODO']=1;
178
 
179
  function update_working_file($mustwrite=false) {
180
  global $WORKING,$STATIC,$runmicrotime;
181
+ if (!file_exists($STATIC['TEMPDIR'].'.running')) {
182
  job_end();
183
+ return false;
184
+ }
185
  if ($mustwrite or empty($runmicrotime) or $runmicrotime<(microtime()-1000)) { //only update all 1 sec.
186
  if ($WORKING['STEPTODO']>0 and $WORKING['STEPDONE']>0)
187
  $steppersent=round($WORKING['STEPDONE']/$WORKING['STEPTODO']*100);
315
  function job_end() {
316
  global $WORKING,$STATIC,$mysqlconlink;
317
  //check if job_end allredy runs
318
+ if (empty($WORKING['JOBENDINPROGRESS']) or !$WORKING['JOBENDINPROGRESS'])
319
  $WORKING['JOBENDINPROGRESS']=true;
320
+ else
 
321
  return;
322
 
323
  $WORKING['STEPTODO']=1;
job/job_run.php CHANGED
@@ -52,11 +52,11 @@ if (empty($STATIC) or !file_exists($STATIC['LOGFILE'])) {
52
  //load translation
53
  if (is_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo')) {
54
  require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/mo.php');
55
- $TRANSLATE = &new MO();
56
  $TRANSLATE->import_from_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo');
57
  } else {
58
  require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/translations.php');
59
- $TRANSLATE = &new NOOP_Translations;
60
  }
61
  //set ticks
62
  declare(ticks=1);
52
  //load translation
53
  if (is_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo')) {
54
  require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/mo.php');
55
+ $TRANSLATE = new MO();
56
  $TRANSLATE->import_from_file(dirname(__FILE__).'/../lang/backwpup-'.$STATIC['WP']['WPLANG'].'.mo');
57
  } else {
58
  require($STATIC['WP']['ABSPATH'].$STATIC['WP']['WPINC'].'/pomo/translations.php');
59
+ $TRANSLATE = new NOOP_Translations;
60
  }
61
  //set ticks
62
  declare(ticks=1);
job/show_working.php CHANGED
@@ -61,8 +61,8 @@ function backwpup_read_logheader($logfile) {
61
  return $joddata;
62
  }
63
 
64
- $_POST['logfile']=trim(str_replace(array('://','@','../'),'',$_POST['logfile']));
65
- $_POST['BackWPupJobTemp']=trim(str_replace(array('://','@','../'),'',$_POST['BackWPupJobTemp']));
66
  if (is_file($_POST['logfile'].'.gz'))
67
  $_POST['logfile']=$_POST['logfile'].'.gz';
68
 
61
  return $joddata;
62
  }
63
 
64
+ $_POST['logfile']=trim(str_replace(array(':','@','../','//','\\'),'',$_POST['logfile']));
65
+ $_POST['BackWPupJobTemp']=trim(str_replace(array(':','@','../','//','\\'),'',$_POST['BackWPupJobTemp']));
66
  if (is_file($_POST['logfile'].'.gz'))
67
  $_POST['logfile']=$_POST['logfile'].'.gz';
68
 
job/wp_export_generate.php CHANGED
@@ -6,7 +6,7 @@ define('DONOTCDN', true);
6
  define('DONOTCACHCEOBJECT', true);
7
  define('W3TC_IN_MINIFY',false); //W3TC will not loaded
8
 
9
- $_POST['BackWPupJobTemp']=str_replace(array('://','@','../'),'',$_POST['BackWPupJobTemp']);
10
  if (is_file(trim($_POST['BackWPupJobTemp']).'.running'))
11
  $runningfile=file_get_contents(trim($_POST['BackWPupJobTemp']).'.running');
12
  $infile=array();
6
  define('DONOTCACHCEOBJECT', true);
7
  define('W3TC_IN_MINIFY',false); //W3TC will not loaded
8
 
9
+ $_POST['BackWPupJobTemp']=str_replace(array(':','@','../','//','\\'),'',$_POST['BackWPupJobTemp']);
10
  if (is_file(trim($_POST['BackWPupJobTemp']).'.running'))
11
  $runningfile=file_get_contents(trim($_POST['BackWPupJobTemp']).'.running');
12
  $infile=array();
libs/aws/sdk.class.php CHANGED
@@ -125,9 +125,9 @@ function __aws_sdk_ua_callback()
125
  // INTERMEDIARY CONSTANTS
126
 
127
  define('CFRUNTIME_NAME', 'aws-sdk-php');
128
- define('CFRUNTIME_VERSION', '1.4.4');
129
  // define('CFRUNTIME_BUILD', gmdate('YmdHis', filemtime(__FILE__))); // @todo: Hardcode for release.
130
- define('CFRUNTIME_BUILD', '20111012191027');
131
  define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . str_replace(' ', '_', php_uname('s')) . '/' . str_replace(' ', '_', php_uname('r')) . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());
132
 
133
 
125
  // INTERMEDIARY CONSTANTS
126
 
127
  define('CFRUNTIME_NAME', 'aws-sdk-php');
128
+ define('CFRUNTIME_VERSION', '1.4.5');
129
  // define('CFRUNTIME_BUILD', gmdate('YmdHis', filemtime(__FILE__))); // @todo: Hardcode for release.
130
+ define('CFRUNTIME_BUILD', '20111021191027');
131
  define('CFRUNTIME_USERAGENT', CFRUNTIME_NAME . '/' . CFRUNTIME_VERSION . ' PHP/' . PHP_VERSION . ' ' . str_replace(' ', '_', php_uname('s')) . '/' . str_replace(' ', '_', php_uname('r')) . ' Arch/' . php_uname('m') . ' SAPI/' . php_sapi_name() . ' Integer/' . PHP_INT_MAX . ' Build/' . CFRUNTIME_BUILD . __aws_sdk_ua_callback());
132
 
133
 
libs/aws/services/sqs.class.php CHANGED
@@ -15,76 +15,61 @@
15
  */
16
 
17
  /**
 
 
 
 
 
 
18
  *
19
- *
20
- * Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable, hosted queue for storing messages as they travel between
21
- * computers. By using Amazon SQS, developers can simply move data between distributed components of their applications that perform different
22
- * tasks, without losing messages or requiring each component to be always available. Amazon SQS makes it easy to build an automated workflow,
23
- * working in close conjunction with the Amazon Elastic Compute Cloud (Amazon EC2) and the other AWS infrastructure web services.
24
- *
25
- * Amazon SQS works by exposing Amazon's web-scale messaging infrastructure as a web service. Any computer on the Internet can add or read
26
- * messages without any installed software or special firewall configurations. Components of applications using Amazon SQS can run
27
- * independently, and do not need to be on the same network, developed with the same technologies, or running at the same time.
28
  *
29
  * Visit <a href="http://aws.amazon.com/sqs/">http://aws.amazon.com/sqs/</a> for more information.
30
  *
31
- * @version Thu Sep 01 21:24:22 PDT 2011
32
  * @license See the included NOTICE.md file for complete information.
33
  * @copyright See the included NOTICE.md file for complete information.
34
- * @link http://aws.amazon.com/sqs/Amazon Simple Queue Service
35
- * @link http://aws.amazon.com/documentation/sqs/Amazon Simple Queue Service documentation
36
  */
37
  class AmazonSQS extends CFRuntime
38
  {
39
-
40
  /*%******************************************************************************************%*/
41
  // CLASS CONSTANTS
42
 
43
  /**
44
- * Specify the default queue URL.
45
  */
46
- const DEFAULT_URL = 'sqs.us-east-1.amazonaws.com';
47
 
48
  /**
49
- * Specify the queue URL for the US-East (Northern Virginia) Region.
50
- */
51
- const REGION_US_E1 = self::DEFAULT_URL;
52
-
53
- /**
54
- * Specify the queue URL for the US-West (Northern California) Region.
55
  */
56
  const REGION_US_W1 = 'sqs.us-west-1.amazonaws.com';
57
 
58
  /**
59
- * Specify the queue URL for the EU (Ireland) Region.
60
  */
61
  const REGION_EU_W1 = 'sqs.eu-west-1.amazonaws.com';
62
 
63
  /**
64
- * Specify the queue URL for the Asia Pacific (Singapore) Region.
65
  */
66
  const REGION_APAC_SE1 = 'sqs.ap-southeast-1.amazonaws.com';
67
 
68
  /**
69
- * Specify the queue URL for the Asia Pacific (Japan) Region.
70
  */
71
  const REGION_APAC_NE1 = 'sqs.ap-northeast-1.amazonaws.com';
72
 
73
-
74
- /*%******************************************************************************************%*/
75
- // SETTERS
76
-
77
  /**
78
- * This allows you to explicitly sets the region for the service to use.
79
- *
80
- * @param string $region (Required) The region to use for subsequent Amazon S3 operations. [Allowed values: `AmazonSQS::REGION_US_E1 `, `AmazonSQS::REGION_US_W1`, `AmazonSQS::REGION_EU_W1`, `AmazonSQS::REGION_APAC_SE1`]
81
- * @return $this A reference to the current instance.
82
  */
83
- public function set_region($region)
84
- {
85
- $this->set_hostname($region);
86
- return $this;
87
- }
88
 
89
 
90
  /*%******************************************************************************************%*/
@@ -166,7 +151,7 @@ class AmazonSQS extends CFRuntime
166
  */
167
  public function __construct($key = null, $secret_key = null, $token = null)
168
  {
169
- $this->api_version = '2009-02-01';
170
  $this->hostname = self::DEFAULT_URL;
171
 
172
  if (!$key && !defined('AWS_KEY'))
@@ -193,34 +178,124 @@ class AmazonSQS extends CFRuntime
193
 
194
 
195
  /*%******************************************************************************************%*/
196
- // SERVICE METHODS
197
 
198
  /**
 
199
  *
200
- * Returns a list of your queues.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  *
 
 
 
 
202
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
203
- * <li><code>QueueNamePrefix</code> - <code>string</code> - Optional - A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned. </li>
204
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
205
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
206
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
207
  */
208
- public function list_queues($opt = null)
209
  {
210
  if (!$opt) $opt = array();
 
211
 
212
- return $this->authenticate('ListQueues', $opt, $this->hostname);
 
 
 
 
 
 
 
 
 
 
213
  }
214
 
215
  /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  *
217
- * Sets an attribute of a queue. Currently, you can set only the <code>VisibilityTimeout</code> attribute for a queue.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  *
219
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
220
- * @param array $attribute (Required) A list of attributes to set. <ul>
221
- * <li><code>x</code> - <code>array</code> - This represents a simple array index. <ul>
222
- * <li><code>Name</code> - <code>string</code> - Optional - The name of the queue attribute to set a custom value for. [Allowed values: <code>Policy</code>, <code>VisibilityTimeout</code>, <code>MaximumMessageSize</code>, <code>MessageRetentionPeriod</code>, <code>ApproximateNumberOfMessages</code>, <code>ApproximateNumberOfMessagesNotVisible</code>, <code>CreatedTimestamp</code>, <code>LastModifiedTimestamp</code>]</li>
223
- * <li><code>Value</code> - <code>string</code> - Optional - The custom value to assign for the matching attribute key. </li>
 
224
  * </ul></li>
225
  * </ul>
226
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
@@ -228,108 +303,161 @@ class AmazonSQS extends CFRuntime
228
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
229
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
230
  */
231
- public function set_queue_attributes($queue_url, $attribute, $opt = null)
232
  {
233
  if (!$opt) $opt = array();
234
 
235
- // Required parameter
236
  $opt = array_merge($opt, CFComplexType::map(array(
237
- 'Attribute' => (is_array($attribute) ? $attribute : array($attribute))
238
  )));
239
 
240
- return $this->authenticate('SetQueueAttributes', $opt, $queue_url);
241
  }
242
 
243
  /**
 
 
 
244
  *
245
- * The <code>ChangeMessageVisibility</code> action changes the visibility timeout of a specified message in a queue to a new value. The maximum
246
- * allowed timeout value you can set the value to is 12 hours. This means you can't extend the timeout of a message in an existing queue to
247
- * more than a total visibility timeout of 12 hours. (For more information visibility timeout, see <a
248
- * href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html">Visibility Timeout</a> in the Amazon
249
- * SQS Developer Guide.)
250
- *
251
- * For example, let's say you have a message and its default message visibility timeout is 30 minutes. You could call
252
- * <code>ChangeMessageVisiblity</code> with a value of two hours and the effective timeout would be two hours and 30 minutes. When that time
253
- * comes near you could again extend the time out by calling ChangeMessageVisiblity, but this time the maximum allowed timeout would be 9 hours
254
- * and 30 minutes.
255
  *
256
- * If you attempt to set the <code>VisibilityTimeout</code> to an amount more than the maximum time left, Amazon SQS returns an error. It will
257
- * not automatically recalculate and increase the timeout to the maximum time remaining.
 
258
  *
259
- * Unlike with a queue, when you change the visibility timeout for a specific message, that timeout value is applied immediately but is not
260
- * saved in memory for that message. If you don't delete a message after it is received, the visibility timeout for the message the next time
261
- * it is received reverts to the original timeout value, not the value you set with the ChangeMessageVisibility action.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  *
263
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
264
- * @param string $receipt_handle (Required) The receipt handle associated with the message whose visibility timeout should be changed.
265
- * @param integer $visibility_timeout (Required) The new value (in seconds) for the message's visibility timeout.
266
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
267
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
268
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
269
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
270
  */
271
- public function change_message_visibility($queue_url, $receipt_handle, $visibility_timeout, $opt = null)
272
  {
273
  if (!$opt) $opt = array();
274
  $opt['ReceiptHandle'] = $receipt_handle;
275
- $opt['VisibilityTimeout'] = $visibility_timeout;
276
 
277
- return $this->authenticate('ChangeMessageVisibility', $opt, $queue_url);
278
  }
279
 
280
  /**
 
 
 
281
  *
282
- * The <code>CreateQueue</code> action creates a new queue, or returns the URL of an existing one. When you request <code>CreateQueue</code>,
283
- * you provide a name for the queue. To successfully create a new queue, you must provide a name that is unique within the scope of your own
284
- * queues. If you provide the name of an existing queue, a new queue isn't created and an error isn't returned. Instead, the request succeeds
285
- * and the queue URL for the existing queue is returned.
286
- *
287
- * If you provide a value for <code>DefaultVisibilityTimeout</code> that is different from the value for the existing queue, you receive an
288
- * error.
289
- *
290
- * @param string $queue_name (Required) The name for the queue to be created.
291
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
292
- * <li><code>DefaultVisibilityTimeout</code> - <code>integer</code> - Optional - The visibility timeout (in seconds) to use for the created queue. </li>
293
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
294
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
295
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
296
  */
297
- public function create_queue($queue_name, $opt = null)
298
  {
299
  if (!$opt) $opt = array();
300
- $opt['QueueName'] = $queue_name;
301
 
302
- return $this->authenticate('CreateQueue', $opt, $this->hostname);
 
 
 
 
 
303
  }
304
 
305
  /**
 
 
306
  *
307
- * The <code>RemovePermission</code> action revokes any permissions in the queue policy that matches the specified <code>Label</code>
308
- * parameter. Only the owner of the queue can remove permissions.
309
  *
310
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
311
- * @param string $label (Required) The identfication of the permission to remove. This is the label added with the AddPermission operation.
312
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
313
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
314
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
315
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
316
  */
317
- public function remove_permission($queue_url, $label, $opt = null)
318
  {
319
  if (!$opt) $opt = array();
320
- $opt['Label'] = $label;
321
 
322
- return $this->authenticate('RemovePermission', $opt, $queue_url);
323
  }
324
 
325
  /**
326
- *
327
- * Gets one or all attributes of a queue. Queues currently have two attributes you can get: <code>ApproximateNumberOfMessages</code> and
328
- * <code>VisibilityTimeout</code>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
329
  *
330
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
331
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
332
- * <li><code>AttributeName</code> - <code>string|array</code> - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values. </li>
333
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
334
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
335
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
@@ -338,7 +466,7 @@ class AmazonSQS extends CFRuntime
338
  {
339
  if (!$opt) $opt = array();
340
 
341
- // Optional parameter
342
  if (isset($opt['AttributeName']))
343
  {
344
  $opt = array_merge($opt, CFComplexType::map(array(
@@ -351,95 +479,99 @@ class AmazonSQS extends CFRuntime
351
  }
352
 
353
  /**
 
354
  *
355
- * The AddPermission action adds a permission to a queue for a specific <a
356
- * href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Glossary.html#d0e3892">principal</a>. This allows for
357
- * sharing access to the queue.
358
- *
359
- * When you create a queue, you have full control access rights for the queue. Only you (as owner of the queue) can grant or deny permissions
360
- * to the queue. For more information about these permissions, see <a
361
- * href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/?acp-overview.html">Shared Queues</a> in the Amazon
362
- * SQS Developer Guide.
363
- *
364
- * <code>AddPermission</code> writes an SQS-generated policy. If you want to write your own policy, use SetQueueAttributes to upload your
365
- * policy. For more information about writing your own policy, see <a
366
- * href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/?AccessPolicyLanguage.html">Appendix: The Access
367
- * Policy Language</a> in the Amazon SQS Developer Guide.
368
- *
369
- * @param string $queue_url (Required) The URL of the SQS queue to take action on.
370
- * @param string $label (Required) The unique identification of the permission you're setting (e.g., <code>AliceSendMessage</code>). Constraints: Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.
371
- * @param string|array $account_id (Required) The AWS account number of the principal who will be given permission. The principal must have an AWS account, but does not need to be signed up for Amazon SQS. Pass a string for a single value, or an indexed array for multiple values.
372
- * @param string|array $action_name (Required) The action the client wants to allow for the specified principal. Pass a string for a single value, or an indexed array for multiple values.
373
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
 
374
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
375
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
376
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
377
  */
378
- public function add_permission($queue_url, $label, $account_id, $action_name, $opt = null)
379
  {
380
  if (!$opt) $opt = array();
381
- $opt['Label'] = $label;
382
 
383
- // Required parameter
384
- $opt = array_merge($opt, CFComplexType::map(array(
385
- 'AWSAccountId' => (is_array($account_id) ? $account_id : array($account_id))
386
- )));
387
 
388
- // Required parameter
389
- $opt = array_merge($opt, CFComplexType::map(array(
390
- 'ActionName' => (is_array($action_name) ? $action_name : array($action_name))
391
- )));
 
 
 
 
 
 
 
 
392
 
393
- return $this->authenticate('AddPermission', $opt, $queue_url);
394
  }
395
 
396
  /**
397
- *
398
- * This action unconditionally deletes the queue specified by the queue URL. Use this operation WITH CARE! The queue is deleted even if it is
399
- * NOT empty.
400
- *
401
- * Once a queue has been deleted, the queue name is unavailable for use with new queues for 60 seconds.
 
402
  *
403
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
404
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
 
 
 
405
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
406
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
407
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
408
  */
409
- public function delete_queue($queue_url, $opt = null)
410
  {
411
  if (!$opt) $opt = array();
412
 
413
- return $this->authenticate('DeleteQueue', $opt, $queue_url);
 
 
 
 
 
 
 
 
 
414
  }
415
 
416
  /**
417
- *
418
- * The <code>DeleteMessage</code> action unconditionally removes the specified message from the specified queue. Even if the message is locked
419
- * by another reader due to the visibility timeout setting, it is still deleted from the queue.
420
  *
421
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
422
- * @param string $receipt_handle (Required) The receipt handle associated with the message to delete.
423
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
424
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
425
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
426
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
427
  */
428
- public function delete_message($queue_url, $receipt_handle, $opt = null)
429
  {
430
  if (!$opt) $opt = array();
431
- $opt['ReceiptHandle'] = $receipt_handle;
432
 
433
- return $this->authenticate('DeleteMessage', $opt, $queue_url);
434
  }
435
 
436
  /**
437
- *
438
  * The <code>SendMessage</code> action delivers a message to the specified queue.
439
  *
440
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
441
  * @param string $message_body (Required) The message to send.
442
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
 
443
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
444
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
445
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
@@ -453,35 +585,61 @@ class AmazonSQS extends CFRuntime
453
  }
454
 
455
  /**
 
 
 
456
  *
457
- * Retrieves one or more messages from the specified queue, including the message body and message ID of each message. Messages returned by
458
- * this action stay in the queue until you delete them. However, once a message is returned to a <code>ReceiveMessage</code> request, it is not
459
- * returned on subsequent <code>ReceiveMessage</code> requests for the duration of the <code>VisibilityTimeout</code>. If you do not specify a
460
- * <code>VisibilityTimeout</code> in the request, the overall visibility timeout for the queue is used for the returned messages.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  *
462
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
 
 
 
 
 
 
463
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
464
- * <li><code>AttributeName</code> - <code>string|array</code> - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values. </li>
465
- * <li><code>MaxNumberOfMessages</code> - <code>integer</code> - Optional - The maximum number of messages to return. Amazon SQS never returns more messages than this value but may return fewer. All of the messages are not necessarily returned. </li>
466
- * <li><code>VisibilityTimeout</code> - <code>integer</code> - Optional - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a <code>ReceiveMessage</code> request. </li>
467
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
468
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
469
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
470
  */
471
- public function receive_message($queue_url, $opt = null)
472
  {
473
  if (!$opt) $opt = array();
474
 
475
- // Optional parameter
476
- if (isset($opt['AttributeName']))
477
- {
478
- $opt = array_merge($opt, CFComplexType::map(array(
479
- 'AttributeName' => (is_array($opt['AttributeName']) ? $opt['AttributeName'] : array($opt['AttributeName']))
480
- )));
481
- unset($opt['AttributeName']);
482
- }
483
 
484
- return $this->authenticate('ReceiveMessage', $opt, $queue_url);
485
  }
486
  }
487
 
@@ -489,7 +647,4 @@ class AmazonSQS extends CFRuntime
489
  /*%******************************************************************************************%*/
490
  // EXCEPTIONS
491
 
492
- /**
493
- * Default SQS Exception.
494
- */
495
- class SQS_Exception extends Exception {}
15
  */
16
 
17
  /**
18
+ * Amazon Simple Queue Service (Amazon SQS) offers a reliable, highly scalable, hosted queue for
19
+ * storing messages as they travel between computers. By using Amazon SQS, developers can simply
20
+ * move data between distributed components of their applications that perform different tasks,
21
+ * without losing messages or requiring each component to be always available. Amazon SQS makes it
22
+ * easy to build an automated workflow, working in close conjunction with the Amazon Elastic
23
+ * Compute Cloud (Amazon EC2) and the other AWS infrastructure web services.
24
  *
25
+ * Amazon SQS works by exposing Amazon's web-scale messaging infrastructure as a web service. Any
26
+ * computer on the Internet can add or read messages without any installed software or special
27
+ * firewall configurations. Components of applications using Amazon SQS can run independently, and
28
+ * do not need to be on the same network, developed with the same technologies, or running at the
29
+ * same time.
 
 
 
 
30
  *
31
  * Visit <a href="http://aws.amazon.com/sqs/">http://aws.amazon.com/sqs/</a> for more information.
32
  *
33
+ * @version 2011.10.20
34
  * @license See the included NOTICE.md file for complete information.
35
  * @copyright See the included NOTICE.md file for complete information.
36
+ * @link http://aws.amazon.com/sqs/ Amazon Simple Queue Service
37
+ * @link http://aws.amazon.com/sqs/documentation/ Amazon Simple Queue Service documentation
38
  */
39
  class AmazonSQS extends CFRuntime
40
  {
 
41
  /*%******************************************************************************************%*/
42
  // CLASS CONSTANTS
43
 
44
  /**
45
+ * Specify the queue URL for the United States East (Northern Virginia) Region.
46
  */
47
+ const REGION_US_E1 = 'sqs.us-east-1.amazonaws.com';
48
 
49
  /**
50
+ * Specify the queue URL for the United States West (Northern California) Region.
 
 
 
 
 
51
  */
52
  const REGION_US_W1 = 'sqs.us-west-1.amazonaws.com';
53
 
54
  /**
55
+ * Specify the queue URL for the Europe West (Ireland) Region.
56
  */
57
  const REGION_EU_W1 = 'sqs.eu-west-1.amazonaws.com';
58
 
59
  /**
60
+ * Specify the queue URL for the Asia Pacific Southeast (Singapore) Region.
61
  */
62
  const REGION_APAC_SE1 = 'sqs.ap-southeast-1.amazonaws.com';
63
 
64
  /**
65
+ * Specify the queue URL for the Asia Pacific Northeast (Tokyo) Region.
66
  */
67
  const REGION_APAC_NE1 = 'sqs.ap-northeast-1.amazonaws.com';
68
 
 
 
 
 
69
  /**
70
+ * Default service endpoint.
 
 
 
71
  */
72
+ const DEFAULT_URL = self::REGION_US_E1;
 
 
 
 
73
 
74
 
75
  /*%******************************************************************************************%*/
151
  */
152
  public function __construct($key = null, $secret_key = null, $token = null)
153
  {
154
+ $this->api_version = '2011-10-01';
155
  $this->hostname = self::DEFAULT_URL;
156
 
157
  if (!$key && !defined('AWS_KEY'))
178
 
179
 
180
  /*%******************************************************************************************%*/
181
+ // SETTERS
182
 
183
  /**
184
+ * This allows you to explicitly sets the region for the service to use.
185
  *
186
+ * @param string $region (Required) The region to explicitly set. Available options are <REGION_US_E1>, <REGION_US_W1>, <REGION_EU_W1>, <REGION_APAC_SE1>, <REGION_APAC_NE1>.
187
+ * @return $this A reference to the current instance.
188
+ */
189
+ public function set_region($region)
190
+ {
191
+ $this->set_hostname($region);
192
+ return $this;
193
+ }
194
+
195
+
196
+ /*%******************************************************************************************%*/
197
+ // SERVICE METHODS
198
+
199
+ /**
200
+ * The AddPermission action adds a permission to a queue for a specific <a href=
201
+ * "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Glossary.html#d0e3892">
202
+ * principal</a>. This allows for sharing access to the queue.
203
+ *
204
+ * When you create a queue, you have full control access rights for the queue. Only you (as owner
205
+ * of the queue) can grant or deny permissions to the queue. For more information about these
206
+ * permissions, see <a href=
207
+ * "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/?acp-overview.html">
208
+ * Shared Queues</a> in the Amazon SQS Developer Guide.
209
+ *
210
+ * <code>AddPermission</code> writes an SQS-generated policy. If you want to write your own
211
+ * policy, use SetQueueAttributes to upload your policy. For more information about writing your
212
+ * own policy, see <a href=
213
+ * "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/?AccessPolicyLanguage.html">
214
+ * Appendix: The Access Policy Language</a> in the Amazon SQS Developer Guide.
215
  *
216
+ * @param string $queue_url (Required) The URL of the SQS queue to take action on.
217
+ * @param string $label (Required) The unique identification of the permission you're setting (e.g., <code>AliceSendMessage</code>). Constraints: Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.
218
+ * @param string|array $aws_account_id (Required) The AWS account number of the <a href="http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/APIReference/Glossary.html">principal</a> who will be given permission. The principal must have an AWS account, but does not need to be signed up for Amazon SQS. Pass a string for a single value, or an indexed array for multiple values.
219
+ * @param string|array $action_name (Required) The action the client wants to allow for the specified principal. Pass a string for a single value, or an indexed array for multiple values.
220
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
 
221
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
222
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
223
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
224
  */
225
+ public function add_permission($queue_url, $label, $aws_account_id, $action_name, $opt = null)
226
  {
227
  if (!$opt) $opt = array();
228
+ $opt['Label'] = $label;
229
 
230
+ // Required list (non-map)
231
+ $opt = array_merge($opt, CFComplexType::map(array(
232
+ 'AWSAccountId' => (is_array($aws_account_id) ? $aws_account_id : array($aws_account_id))
233
+ )));
234
+
235
+ // Required list (non-map)
236
+ $opt = array_merge($opt, CFComplexType::map(array(
237
+ 'ActionName' => (is_array($action_name) ? $action_name : array($action_name))
238
+ )));
239
+
240
+ return $this->authenticate('AddPermission', $opt, $queue_url);
241
  }
242
 
243
  /**
244
+ * The <code>ChangeMessageVisibility</code> action changes the visibility timeout of a specified
245
+ * message in a queue to a new value. The maximum allowed timeout value you can set the value to
246
+ * is 12 hours. This means you can't extend the timeout of a message in an existing queue to more
247
+ * than a total visibility timeout of 12 hours. (For more information visibility timeout, see
248
+ * <a href=
249
+ * "http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html">
250
+ * Visibility Timeout</a> in the Amazon SQS Developer Guide.)
251
+ *
252
+ * For example, let's say you have a message and its default message visibility timeout is 30
253
+ * minutes. You could call <code>ChangeMessageVisiblity</code> with a value of two hours and the
254
+ * effective timeout would be two hours and 30 minutes. When that time comes near you could again
255
+ * extend the time out by calling ChangeMessageVisiblity, but this time the maximum allowed
256
+ * timeout would be 9 hours and 30 minutes.
257
+ *
258
+ * <p class="important">
259
+ * If you attempt to set the <code>VisibilityTimeout</code> to an amount more than the maximum
260
+ * time left, Amazon SQS returns an error. It will not automatically recalculate and increase the
261
+ * timeout to the maximum time remaining.
262
+ * </p>
263
+ * <p class="important">
264
+ * Unlike with a queue, when you change the visibility timeout for a specific message, that
265
+ * timeout value is applied immediately but is not saved in memory for that message. If you don't
266
+ * delete a message after it is received, the visibility timeout for the message the next time it
267
+ * is received reverts to the original timeout value, not the value you set with the
268
+ * ChangeMessageVisibility action.
269
+ * </p>
270
  *
271
+ * @param string $queue_url (Required) The URL of the SQS queue to take action on.
272
+ * @param string $receipt_handle (Required) The receipt handle associated with the message whose visibility timeout should be changed.
273
+ * @param integer $visibility_timeout (Required) The new value (in seconds) for the message's visibility timeout.
274
+ * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
275
+ * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
276
+ * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
277
+ * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
278
+ */
279
+ public function change_message_visibility($queue_url, $receipt_handle, $visibility_timeout, $opt = null)
280
+ {
281
+ if (!$opt) $opt = array();
282
+ $opt['ReceiptHandle'] = $receipt_handle;
283
+ $opt['VisibilityTimeout'] = $visibility_timeout;
284
+
285
+ return $this->authenticate('ChangeMessageVisibility', $opt, $queue_url);
286
+ }
287
+
288
+ /**
289
+ * This is a batch version of <code>ChangeMessageVisibility</code>. It takes multiple receipt
290
+ * handles and performs the operation on each of the them. The result of the operation on each
291
+ * message is reported individually in the response.
292
  *
293
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
294
+ * @param array $change_message_visibility_batch_request_entry (Required) A list of receipt handles of the messages for which the visibility timeout must be changed. <ul>
295
+ * <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
296
+ * <li><code>Id</code> - <code>string</code> - Required - An identifier for this particular receipt handle. This is used to communicate the result. Note that the <code>Id</code> s of a batch request need to be unique within the request.</li>
297
+ * <li><code>ReceiptHandle</code> - <code>string</code> - Required - A receipt handle.</li>
298
+ * <li><code>VisibilityTimeout</code> - <code>integer</code> - Optional - The new value (in seconds) for the message's visibility timeout.</li>
299
  * </ul></li>
300
  * </ul>
301
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
303
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
304
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
305
  */
306
+ public function change_message_visibility_batch($queue_url, $change_message_visibility_batch_request_entry, $opt = null)
307
  {
308
  if (!$opt) $opt = array();
309
 
310
+ // Required list + map
311
  $opt = array_merge($opt, CFComplexType::map(array(
312
+ 'ChangeMessageVisibilityBatchRequestEntry' => (is_array($change_message_visibility_batch_request_entry) ? $change_message_visibility_batch_request_entry : array($change_message_visibility_batch_request_entry))
313
  )));
314
 
315
+ return $this->authenticate('ChangeMessageVisibilityBatch', $opt, $queue_url);
316
  }
317
 
318
  /**
319
+ * The <code>CreateQueue</code> action creates a new queue, or returns the URL of an existing one.
320
+ * When you request <code>CreateQueue</code>, you provide a name for the queue. To successfully
321
+ * create a new queue, you must provide a name that is unique within the scope of your own queues.
322
  *
323
+ * You may pass one or more attributes in the request. If you do not provide a value for any
324
+ * attribute, the queue will have the default value for that attribute. Permitted attributes are
325
+ * the same that can be set using <code>SetQueueAttributes</code>.
 
 
 
 
 
 
 
326
  *
327
+ * If you provide the name of an existing queue, a new queue isn't created. If the values of
328
+ * attributes provided with the request match up with those on the existing queue, the queue URL
329
+ * is returned. Otherwise, a <code>QueueNameExists</code> error is returned.
330
  *
331
+ * @param string $queue_name (Required) The name for the queue to be created.
332
+ * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
333
+ * <li><code>Attribute</code> - <code>array</code> - Optional - A map of attributes with their corresponding values. <ul>
334
+ * <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
335
+ * <li><code>Name</code> - <code>string</code> - Optional - The name of a queue attribute. [Allowed values: <code>Policy</code>, <code>VisibilityTimeout</code>, <code>MaximumMessageSize</code>, <code>MessageRetentionPeriod</code>, <code>ApproximateNumberOfMessages</code>, <code>ApproximateNumberOfMessagesNotVisible</code>, <code>CreatedTimestamp</code>, <code>LastModifiedTimestamp</code>, <code>QueueArn</code>, <code>ApproximateNumberOfMessagesDelayed</code>, <code>DelaySeconds</code>]</li>
336
+ * <li><code>Value</code> - <code>string</code> - Optional - The value of a queue attribute.</li>
337
+ * </ul></li>
338
+ * </ul></li>
339
+ * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
340
+ * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
341
+ * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
342
+ */
343
+ public function create_queue($queue_name, $opt = null)
344
+ {
345
+ if (!$opt) $opt = array();
346
+ $opt['QueueName'] = $queue_name;
347
+
348
+ // Optional map (non-list)
349
+ if (isset($opt['Attribute']))
350
+ {
351
+ $opt = array_merge($opt, CFComplexType::map(array(
352
+ 'Attribute' => $opt['Attribute']
353
+ )));
354
+ unset($opt['Attribute']);
355
+ }
356
+
357
+ return $this->authenticate('CreateQueue', $opt, $this->hostname);
358
+ }
359
+
360
+ /**
361
+ * The <code>DeleteMessage</code> action unconditionally removes the specified message from the
362
+ * specified queue. Even if the message is locked by another reader due to the visibility timeout
363
+ * setting, it is still deleted from the queue.
364
  *
365
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
366
+ * @param string $receipt_handle (Required) The receipt handle associated with the message to delete.
 
367
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
368
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
369
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
370
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
371
  */
372
+ public function delete_message($queue_url, $receipt_handle, $opt = null)
373
  {
374
  if (!$opt) $opt = array();
375
  $opt['ReceiptHandle'] = $receipt_handle;
 
376
 
377
+ return $this->authenticate('DeleteMessage', $opt, $queue_url);
378
  }
379
 
380
  /**
381
+ * This is a batch version of <code>DeleteMessage</code>. It takes multiple receipt handles and
382
+ * deletes each one of the messages. The result of the delete operation on each message is
383
+ * reported individually in the response.
384
  *
385
+ * @param string $queue_url (Required) The URL of the SQS queue to take action on.
386
+ * @param array $delete_message_batch_request_entry (Required) A list of receipt handles for the messages to be deleted. <ul>
387
+ * <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
388
+ * <li><code>Id</code> - <code>string</code> - Required - An identifier for this particular receipt handle. This is used to communicate the result. Note that the <code>Id</code> s of a batch request need to be unique within the request.</li>
389
+ * <li><code>ReceiptHandle</code> - <code>string</code> - Required - A receipt handle.</li>
390
+ * </ul></li>
391
+ * </ul>
 
 
392
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
 
393
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
394
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
395
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
396
  */
397
+ public function delete_message_batch($queue_url, $delete_message_batch_request_entry, $opt = null)
398
  {
399
  if (!$opt) $opt = array();
 
400
 
401
+ // Required list + map
402
+ $opt = array_merge($opt, CFComplexType::map(array(
403
+ 'DeleteMessageBatchRequestEntry' => (is_array($delete_message_batch_request_entry) ? $delete_message_batch_request_entry : array($delete_message_batch_request_entry))
404
+ )));
405
+
406
+ return $this->authenticate('DeleteMessageBatch', $opt, $queue_url);
407
  }
408
 
409
  /**
410
+ * This action unconditionally deletes the queue specified by the queue URL. Use this operation
411
+ * WITH CARE! The queue is deleted even if it is NOT empty.
412
  *
413
+ * Once a queue has been deleted, the queue name is unavailable for use with new queues for 60
414
+ * seconds.
415
  *
416
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
 
417
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
418
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
419
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
420
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
421
  */
422
+ public function delete_queue($queue_url, $opt = null)
423
  {
424
  if (!$opt) $opt = array();
 
425
 
426
+ return $this->authenticate('DeleteQueue', $opt, $queue_url);
427
  }
428
 
429
  /**
430
+ * Gets attributes for the specified queue. The following attributes are supported:
431
+ *
432
+ * <ul>
433
+ * <li><code>All</code> - returns all values.</li>
434
+ * <li><code>ApproximateNumberOfMessages</code> - returns the approximate number of visible
435
+ * messages in a queue. For more information, see Resources Required to Process Messages in
436
+ * the Amazon SQS Developer Guide.</li>
437
+ * <li><code>ApproximateNumberOfMessagesNotVisible</code> - returns the approximate number of
438
+ * messages that are not timed-out and not deleted. For more information, see Resources
439
+ * Required to Process Messages in the Amazon SQS Developer Guide.</li>
440
+ * <li><code>VisibilityTimeout</code> - returns the visibility timeout for the queue. For more
441
+ * information about visibility timeout, see Visibility Timeout in the Amazon SQS Developer
442
+ * Guide.</li>
443
+ * <li><code>CreatedTimestamp</code> - returns the time when the queue was created (epoch time in
444
+ * seconds).</li>
445
+ * <li><code>LastModifiedTimestamp</code> - returns the time when the queue was last changed
446
+ * (epoch time in seconds).</li>
447
+ * <li><code>Policy</code> - returns the queue's policy.</li>
448
+ * <li><code>MaximumMessageSize</code> - returns the limit of how many bytes a message can contain
449
+ * before Amazon SQS rejects it.</li>
450
+ * <li><code>MessageRetentionPeriod</code> - returns the number of seconds Amazon SQS retains a
451
+ * message.</li>
452
+ * <li><code>QueueArn</code> - returns the queue's Amazon resource name (ARN).</li>
453
+ * <li><code>ApproximateNumberOfMessagesDelayed</code> - returns the approximate number of
454
+ * messages that are pending to be added to the queue.</li>
455
+ * <li><code>DelaySeconds</code> - returns the default delay on the queue in seconds.</li>
456
+ * </ul>
457
  *
458
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
459
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
460
+ * <li><code>AttributeName</code> - <code>string|array</code> - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values.</li>
461
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
462
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
463
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
466
  {
467
  if (!$opt) $opt = array();
468
 
469
+ // Optional list (non-map)
470
  if (isset($opt['AttributeName']))
471
  {
472
  $opt = array_merge($opt, CFComplexType::map(array(
479
  }
480
 
481
  /**
482
+ * The <code>GetQueueUrl</code> action returns the URL of an existing queue.
483
  *
484
+ * @param string $queue_name (Required) The name of the queue whose URL must be fetched.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
486
+ * <li><code>QueueOwnerAWSAccountId</code> - <code>string</code> - Optional - The AWS account number of the queue's owner.</li>
487
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
488
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
489
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
490
  */
491
+ public function get_queue_url($queue_name, $opt = null)
492
  {
493
  if (!$opt) $opt = array();
494
+ $opt['QueueName'] = $queue_name;
495
 
496
+ return $this->authenticate('GetQueueUrl', $opt, $this->hostname);
497
+ }
 
 
498
 
499
+ /**
500
+ * Returns a list of your queues.
501
+ *
502
+ * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
503
+ * <li><code>QueueNamePrefix</code> - <code>string</code> - Optional - A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned.</li>
504
+ * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
505
+ * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
506
+ * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
507
+ */
508
+ public function list_queues($opt = null)
509
+ {
510
+ if (!$opt) $opt = array();
511
 
512
+ return $this->authenticate('ListQueues', $opt, $this->hostname);
513
  }
514
 
515
  /**
516
+ * Retrieves one or more messages from the specified queue, including the message body and message
517
+ * ID of each message. Messages returned by this action stay in the queue until you delete them.
518
+ * However, once a message is returned to a <code>ReceiveMessage</code> request, it is not
519
+ * returned on subsequent <code>ReceiveMessage</code> requests for the duration of the
520
+ * <code>VisibilityTimeout</code>. If you do not specify a <code>VisibilityTimeout</code> in the
521
+ * request, the overall visibility timeout for the queue is used for the returned messages.
522
  *
523
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
524
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
525
+ * <li><code>AttributeName</code> - <code>string|array</code> - Optional - A list of attributes to retrieve information for. Pass a string for a single value, or an indexed array for multiple values.</li>
526
+ * <li><code>MaxNumberOfMessages</code> - <code>integer</code> - Optional - The maximum number of messages to return. Amazon SQS never returns more messages than this value but may return fewer. All of the messages are not necessarily returned.</li>
527
+ * <li><code>VisibilityTimeout</code> - <code>integer</code> - Optional - The duration (in seconds) that the received messages are hidden from subsequent retrieve requests after being retrieved by a <code>ReceiveMessage</code> request.</li>
528
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
529
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
530
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
531
  */
532
+ public function receive_message($queue_url, $opt = null)
533
  {
534
  if (!$opt) $opt = array();
535
 
536
+ // Optional list (non-map)
537
+ if (isset($opt['AttributeName']))
538
+ {
539
+ $opt = array_merge($opt, CFComplexType::map(array(
540
+ 'AttributeName' => (is_array($opt['AttributeName']) ? $opt['AttributeName'] : array($opt['AttributeName']))
541
+ )));
542
+ unset($opt['AttributeName']);
543
+ }
544
+
545
+ return $this->authenticate('ReceiveMessage', $opt, $queue_url);
546
  }
547
 
548
  /**
549
+ * The <code>RemovePermission</code> action revokes any permissions in the queue policy that
550
+ * matches the specified <code>Label</code> parameter. Only the owner of the queue can remove
551
+ * permissions.
552
  *
553
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
554
+ * @param string $label (Required) The identification of the permission to remove. This is the label added with the <code>AddPermission</code> operation.
555
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
556
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
557
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
558
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
559
  */
560
+ public function remove_permission($queue_url, $label, $opt = null)
561
  {
562
  if (!$opt) $opt = array();
563
+ $opt['Label'] = $label;
564
 
565
+ return $this->authenticate('RemovePermission', $opt, $queue_url);
566
  }
567
 
568
  /**
 
569
  * The <code>SendMessage</code> action delivers a message to the specified queue.
570
  *
571
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
572
  * @param string $message_body (Required) The message to send.
573
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
574
+ * <li><code>DelaySeconds</code> - <code>integer</code> - Optional - The number of seconds the message has to be delayed.</li>
575
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
576
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
577
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
585
  }
586
 
587
  /**
588
+ * This is a batch version of <code>SendMessage</code>. It takes multiple messages and adds each
589
+ * of them to the queue. The result of each add operation is reported individually in the
590
+ * response.
591
  *
592
+ * @param string $queue_url (Required) The URL of the SQS queue to take action on.
593
+ * @param array $send_message_batch_request_entry (Required) A list of <code>SendMessageBatchRequestEntry</code> s. <ul>
594
+ * <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
595
+ * <li><code>Id</code> - <code>string</code> - Required - An identifier for the message in this batch. This is used to communicate the result. Note that the the <code>Id</code> s of a batch request need to be unique within the request.</li>
596
+ * <li><code>MessageBody</code> - <code>string</code> - Required - Body of the message.</li>
597
+ * <li><code>DelaySeconds</code> - <code>integer</code> - Optional - The number of seconds for which the message has to be delayed.</li>
598
+ * </ul></li>
599
+ * </ul>
600
+ * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
601
+ * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
602
+ * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
603
+ * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
604
+ */
605
+ public function send_message_batch($queue_url, $send_message_batch_request_entry, $opt = null)
606
+ {
607
+ if (!$opt) $opt = array();
608
+
609
+ // Required list + map
610
+ $opt = array_merge($opt, CFComplexType::map(array(
611
+ 'SendMessageBatchRequestEntry' => (is_array($send_message_batch_request_entry) ? $send_message_batch_request_entry : array($send_message_batch_request_entry))
612
+ )));
613
+
614
+ return $this->authenticate('SendMessageBatch', $opt, $queue_url);
615
+ }
616
+
617
+ /**
618
+ * Sets an attribute of a queue. The set of attributes that can be set are - DelaySeconds,
619
+ * MessageRetentionPeriod, MaximumMessageSize, VisibilityTimeout and Policy.
620
  *
621
  * @param string $queue_url (Required) The URL of the SQS queue to take action on.
622
+ * @param array $attribute (Required) A map of attributes to set. <ul>
623
+ * <li><code>x</code> - <code>array</code> - Optional - This represents a simple array index. <ul>
624
+ * <li><code>Name</code> - <code>string</code> - Optional - The name of a queue attribute. [Allowed values: <code>Policy</code>, <code>VisibilityTimeout</code>, <code>MaximumMessageSize</code>, <code>MessageRetentionPeriod</code>, <code>ApproximateNumberOfMessages</code>, <code>ApproximateNumberOfMessagesNotVisible</code>, <code>CreatedTimestamp</code>, <code>LastModifiedTimestamp</code>, <code>QueueArn</code>, <code>ApproximateNumberOfMessagesDelayed</code>, <code>DelaySeconds</code>]</li>
625
+ * <li><code>Value</code> - <code>string</code> - Optional - The value of a queue attribute.</li>
626
+ * </ul></li>
627
+ * </ul>
628
  * @param array $opt (Optional) An associative array of parameters that can have the following keys: <ul>
 
 
 
629
  * <li><code>curlopts</code> - <code>array</code> - Optional - A set of values to pass directly into <code>curl_setopt()</code>, where the key is a pre-defined <code>CURLOPT_*</code> constant.</li>
630
  * <li><code>returnCurlHandle</code> - <code>boolean</code> - Optional - A private toggle specifying that the cURL handle be returned rather than actually completing the request. This toggle is useful for manually managed batch requests.</li></ul>
631
  * @return CFResponse A <CFResponse> object containing a parsed HTTP response.
632
  */
633
+ public function set_queue_attributes($queue_url, $attribute, $opt = null)
634
  {
635
  if (!$opt) $opt = array();
636
 
637
+ // Required list + map
638
+ $opt = array_merge($opt, CFComplexType::map(array(
639
+ 'Attribute' => (is_array($attribute) ? $attribute : array($attribute))
640
+ )));
 
 
 
 
641
 
642
+ return $this->authenticate('SetQueueAttributes', $opt, $queue_url);
643
  }
644
  }
645
 
647
  /*%******************************************************************************************%*/
648
  // EXCEPTIONS
649
 
650
+ class SQS_Exception extends Exception {}
 
 
 
libs/dropbox.php CHANGED
@@ -71,7 +71,7 @@ class backwpup_Dropbox {
71
  if (filesize($file)>157286400){
72
  throw new DropboxException("Error: File \"$file\" is to big max. 150 MB.");
73
  }
74
- $url = self::API_CONTENT_URL.self::API_VERSION_URL.'files_put/'.$this->root.'/'.trim($path, '/').'/'.basename($file);
75
  return $this->request($url, array('overwrite' => ($overwrite)? 'true' : 'false'), 'PUT', $file);
76
  }
77
 
@@ -90,12 +90,12 @@ class backwpup_Dropbox {
90
 
91
  public function fileopsDelete($path){
92
  $url = self::API_URL.self::API_VERSION_URL.'fileops/delete';
93
- return $this->request($url, array('path' => $path, 'root' => $this->root));
94
  }
95
 
96
  public function fileopsCreate_folder($path){
97
  $url = self::API_URL.self::API_VERSION_URL.'fileops/create_folder';
98
- return $this->request($url, array('path' => $path, 'root' => $this->root));
99
  }
100
 
101
  public function oAuthAuthorize($callback_url) {
@@ -171,6 +171,7 @@ class backwpup_Dropbox {
171
 
172
  protected function request($url, $args = null, $method = 'GET', $file = null,$echo=false){
173
  $args = (is_array($args)) ? $args : array();
 
174
  /* Sign Request*/
175
  $this->OAuthObject->reset();
176
  $OAuthSign=$this->OAuthObject->sign(array(
@@ -214,7 +215,7 @@ class backwpup_Dropbox {
214
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
215
  curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
216
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
217
- if (function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION')) {
218
  curl_setopt($ch, CURLOPT_NOPROGRESS, false);
219
  curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
220
  curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
@@ -227,6 +228,8 @@ class backwpup_Dropbox {
227
  $output = json_decode($content, true);
228
  }
229
  $status = curl_getinfo($ch);
 
 
230
 
231
  if (isset($output['error']) or $status['http_code']>=300 or $status['http_code']<200 or curl_errno($ch)>0) {
232
  if(isset($output['error']) && is_string($output['error'])) $message = '('.$status['http_code'].') '.$output['error'];
@@ -250,6 +253,17 @@ class backwpup_Dropbox {
250
  return $output;
251
  }
252
  }
 
 
 
 
 
 
 
 
 
 
 
253
 
254
  }
255
 
71
  if (filesize($file)>157286400){
72
  throw new DropboxException("Error: File \"$file\" is to big max. 150 MB.");
73
  }
74
+ $url = self::API_CONTENT_URL.self::API_VERSION_URL.'files_put/'.$this->root.'/'.trim($path, '/');
75
  return $this->request($url, array('overwrite' => ($overwrite)? 'true' : 'false'), 'PUT', $file);
76
  }
77
 
90
 
91
  public function fileopsDelete($path){
92
  $url = self::API_URL.self::API_VERSION_URL.'fileops/delete';
93
+ return $this->request($url, array('path' => '/'.trim($path,'/'), 'root' => $this->root));
94
  }
95
 
96
  public function fileopsCreate_folder($path){
97
  $url = self::API_URL.self::API_VERSION_URL.'fileops/create_folder';
98
+ return $this->request($url, array('path' => '/'.trim($path,'/'), 'root' => $this->root));
99
  }
100
 
101
  public function oAuthAuthorize($callback_url) {
171
 
172
  protected function request($url, $args = null, $method = 'GET', $file = null,$echo=false){
173
  $args = (is_array($args)) ? $args : array();
174
+ $url = $this->url_encode($url);
175
  /* Sign Request*/
176
  $this->OAuthObject->reset();
177
  $OAuthSign=$this->OAuthObject->sign(array(
215
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
216
  curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
217
  curl_setopt($ch, CURLINFO_HEADER_OUT, true);
218
+ if (!empty($this->ProgressFunction) and function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION')) {
219
  curl_setopt($ch, CURLOPT_NOPROGRESS, false);
220
  curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
221
  curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
228
  $output = json_decode($content, true);
229
  }
230
  $status = curl_getinfo($ch);
231
+ if ($method == 'PUT')
232
+ fclose($datafilefd);
233
 
234
  if (isset($output['error']) or $status['http_code']>=300 or $status['http_code']<200 or curl_errno($ch)>0) {
235
  if(isset($output['error']) && is_string($output['error'])) $message = '('.$status['http_code'].') '.$output['error'];
253
  return $output;
254
  }
255
  }
256
+
257
+ private function url_encode($string) {
258
+ $string = str_replace('?','%3F',$string);
259
+ $string = str_replace('=','%3D',$string);
260
+ $string = str_replace(' ','%20',$string);
261
+ $string = str_replace('(','%28',$string);
262
+ $string = str_replace(')','%29',$string);
263
+ $string = str_replace('&','%26',$string);
264
+ $string = str_replace('@','%40',$string);
265
+ return $string;
266
+ }
267
 
268
  }
269
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: backup, admin, file, Database, mysql, Cron, ftp, S3, export, xml, multisite, Rackspace, Cloud, Azure, DropBox, SugarSync, Google, Storage
5
  Requires at least: 3.1
6
  Tested up to: 3.2.1
7
- Stable tag: 2.1.5
8
 
9
  WordPress Backup and more...
10
 
@@ -52,6 +52,12 @@ Do backups and more for your WordPress Blog.
52
  4. Backups Manage Page
53
 
54
  == Changelog ==
 
 
 
 
 
 
55
  = 2.1.5 =
56
  * Updated AWS lib to 1.4.4
57
  * use my own dropbox lib again and chaned it to new api
4
  Tags: backup, admin, file, Database, mysql, Cron, ftp, S3, export, xml, multisite, Rackspace, Cloud, Azure, DropBox, SugarSync, Google, Storage
5
  Requires at least: 3.1
6
  Tested up to: 3.2.1
7
+ Stable tag: 2.1.6
8
 
9
  WordPress Backup and more...
10
 
52
  4. Backups Manage Page
53
 
54
  == Changelog ==
55
+ = 2.1.6 =
56
+ * fixed Dropbox with no path problem
57
+ * fixed Dropbox path with witespace
58
+ * Updated AWS lib to 1.4.5
59
+ * 2. fix for security vulnerability
60
+
61
  = 2.1.5 =
62
  * Updated AWS lib to 1.4.4
63
  * use my own dropbox lib again and chaned it to new api