This file is indexed.

/usr/share/php/libphp-cloudfusion/sqs.class.php is in libphp-cloudfusion 2.5.0-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
<?php
/**
 * File: Amazon SQS
 * 	Amazon Simple Queue Service (http://aws.amazon.com/sqs)
 *
 * Version:
* 	2009.08.26
 *
 * Copyright:
 * 	2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
 *
 * License:
 * 	Simplified BSD License - http://opensource.org/licenses/bsd-license.php
 *
 * See Also:
 * 	CloudFusion - http://getcloudfusion.com
 * 	Amazon SQS - http://aws.amazon.com/sqs
 */


/*%******************************************************************************************%*/
// CONSTANTS

/**
 * Constant: SQS_DEFAULT_URL
 * 	Specify the default queue URL.
 */
define('SQS_DEFAULT_URL', 'queue.amazonaws.com');

/**
 * Constant: SQS_LOCATION_US
 * 	Specify the queue URL for the U.S.-specific hostname.
 */
define('SQS_LOCATION_US', '');

/**
 * Constant: SQS_LOCATION_EU
 * 	Specify the queue URL for the E.U.-specific hostname.
 */
define('SQS_LOCATION_EU', 'eu-west-1.');


/*%******************************************************************************************%*/
// EXCEPTIONS

/**
 * Exception: SQS_Exception
 * 	Default SQS Exception.
 */
class SQS_Exception extends Exception {}


/*%******************************************************************************************%*/
// MAIN CLASS

/**
 * Class: AmazonSQS
 * 	Container for all Amazon SQS-related methods. Inherits additional methods from CloudFusion.
 *
 * Extends:
 * 	CloudFusion
 */
class AmazonSQS extends CloudFusion
{
	/*%******************************************************************************************%*/
	// CONSTRUCTOR

	/**
	 * Method: __construct()
	 * 	The constructor
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	key - _string_ (Optional) Your Amazon API Key. If blank, it will look for the <AWS_KEY> constant.
	 * 	secret_key - _string_ (Optional) Your Amazon API Secret Key. If blank, it will look for the <AWS_SECRET_KEY> constant.
	 *
	 * Returns:
	 * 	_boolean_ false if no valid values are set, otherwise true.
	 */
	public function __construct($key = null, $secret_key = null)
	{
		$this->api_version = '2009-02-01';
		$this->hostname = SQS_DEFAULT_URL;

		if (!$key && !defined('AWS_KEY'))
		{
			throw new SQS_Exception('No account key was passed into the constructor, nor was it set in the AWS_KEY constant.');
		}

		if (!$secret_key && !defined('AWS_SECRET_KEY'))
		{
			throw new SQS_Exception('No account secret was passed into the constructor, nor was it set in the AWS_SECRET_KEY constant.');
		}

		return parent::__construct($key, $secret_key);
	}


	/*%******************************************************************************************%*/
	// MISCELLANEOUS

	/**
	 * Method: set_locale()
	 * 	By default SQS will self-select the most appropriate locale. This allows you to explicitly sets the locale for SQS to use.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	locale - _string_ (Required) The locale to explicitly set for SQS. Available options are <SQS_LOCATION_US> and <SQS_LOCATION_EU>.
	 *
	 * Returns:
	 * 	void
 	 *
	 * Examples:
	 * 	example::sqs/1_create_queue3.phpt:
	 * 	example::sqs/5_send_message3.phpt:
 	 * 	example::sqs/z_delete_queue3.phpt:
	 */
	public function set_locale($locale)
	{
		$this->hostname = $locale . SQS_DEFAULT_URL;
	}


	/*%******************************************************************************************%*/
	// QUEUES

	/**
	 * Method: create_queue()
	 * 	Creates a new queue to store messages in. You must provide a queue name that is unique within the scope of the queues you own. The queue is assigned a queue URL; you must use this URL when performing actions on the queue. When you create a queue, if a queue with the same name already exists, <create_queue()> returns the queue URL with an error indicating that the queue already exists.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to use for this action. The queue name must be unique within the scope of all your queues.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/1_create_queue.phpt:
 	 * 	example::sqs/1_create_queue3.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryCreateQueue.html
	 * 	Related - <delete_queue()>, <list_queues()>, <get_queue_attributes()>, <set_queue_attributes()>
	 */
	public function create_queue($queue_name, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['QueueName'] = $queue_name;
		$opt['returnCurlHandle'] = $returnCurlHandle;
		return $this->authenticate('CreateQueue', $opt, $this->hostname);
	}

	/**
	 * Method: delete_queue()
	 * 	Deletes the queue specified by the queue URL. This will delete the queue even if it's not empty.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/z_delete_queue.phpt:
 	 * 	example::sqs/z_delete_queue3.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryDeleteQueue.html
	 * 	Related - <create_queue()>, <list_queues()>, <get_queue_attributes()>, <set_queue_attributes()>
	 */
	public function delete_queue($queue_name, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['returnCurlHandle'] = $returnCurlHandle;
		return $this->authenticate('DeleteQueue', $opt, $this->hostname . '/' . $queue_name);
	}

	/**
	 * Method: list_queues()
	 * 	Returns a list of your queues. A maximum 1000 queue URLs are returned. If you specify a value for the optional <queue_name_prefix> parameter, only queues with a name beginning with the specified value are returned.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name_prefix - _string_ (Optional) String to use for filtering the list results. Only those queues whose name begins with the specified string are returned.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/2_list_queues.phpt:
 	 * 	example::sqs/2_list_queues2.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryListQueues.html
	 * 	Related - <create_queue()>, <delete_queue()>, <get_queue_attributes()>, <set_queue_attributes()>
	 */
	public function list_queues($queue_name_prefix = null, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['returnCurlHandle'] = $returnCurlHandle;
		if ($queue_name_prefix)
		{
			$opt['QueueNamePrefix'] = $queue_name_prefix;
		}
		return $this->authenticate('ListQueues', $opt, $this->hostname);
	}

	/**
	 * Method: get_queue_attributes()
	 * 	Gets one or all attributes of a queue.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	attributes - _string_|_array_ (Optional) The attribute you want to get. Setting this value to 'All' returns all the queue's attributes. Pass a string for a single attribute, or an indexed array for multiple attributes. Possible values are 'All', 'ApproximateNumberOfMessages', 'VisibilityTimeout', 'CreatedTimestamp', 'LastModifiedTimestamp', and 'Policy'. Defaults to 'All'.
 	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/4_get_queue_attributes.phpt:
 	 * 	example::sqs/4_get_queue_attributes4.phpt:
 	 * 	example::sqs/4_get_queue_attributes5.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryGetQueueAttributes.html
	 * 	Related - <create_queue()>, <delete_queue()>, <list_queues()>, <set_queue_attributes()>
	 */
	public function get_queue_attributes($queue_name, $attributes = 'All', $returnCurlHandle = null)
	{
		$opt = array();

		if (is_array($attributes))
		{
			for ($i = 0, $max = count($attributes); $i < $max; $i++)
			{
				$opt['AttributeName.' . ($i + 1)] = $attributes[$i];
			}
		}
		else
		{
			$opt['AttributeName.1'] = $attributes;
		}

		$opt['returnCurlHandle'] = $returnCurlHandle;

		return $this->authenticate('GetQueueAttributes', $opt, $this->hostname . '/' . $queue_name);
	}

	/**
	 * Method: set_queue_attributes()
	 * 	Sets an attribute of a queue. Currently, you can set only the <VisibilityTimeout> attribute for a queue. See Visibility Timeout for more information.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	opt - _array_ (Required) Associative array of parameters which can have the following keys:
	 *
	 * Keys for the $opt parameter:
	 * 	VisibilityTimeout - _integer_ (Optional) Must be an integer from 0 to 7200 (2 hours).
	 * 	Policy - _string_ (Optional) A policy generated by <generate_policy()>.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/3_set_queue_attributes.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryGetQueueAttributes.html
	 * 	Related - <create_queue()>, <delete_queue()>, <list_queues()>, <get_queue_attributes()>
	 */
	public function set_queue_attributes($queue_name, $opt = null)
	{
		if (!$opt) $opt = array();

		$count = 1;

		if (isset($opt['VisibilityTimeout']))
		{
			$opt['Attribute.' . $count . '.Name'] = 'VisibilityTimeout';
			$opt['Attribute.' . $count . '.Value'] = $opt['VisibilityTimeout'];
			unset($opt['VisibilityTimeout']);
			$count++;
		}

		if (isset($opt['Policy']))
		{
			$opt['Attribute.' . $count . '.Name'] = 'Policy';
			$opt['Attribute.' . $count . '.Value'] = $opt['Policy'];
			unset($opt['VisibilityTimeout']);
			$count++;
		}

		return $this->authenticate('SetQueueAttributes', $opt, $this->hostname . '/' . $queue_name);
	}


	/*%******************************************************************************************%*/
	// MESSAGES

	/**
	 * Method: send_message()
	 * 	Delivers a message to the specified queue.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	message - _string_ (Required) Message size cannot exceed 8 KB. Allowed Unicode characters (according to http://www.w3.org/TR/REC-xml/#charsets): #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF].
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/5_send_message.phpt:
 	 * 	example::sqs/5_send_message3.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QuerySendMessage.html
	 * 	Related - <send_message()>, <receive_message()>, <delete_message()>, <change_message_visibility()>
	 */
	public function send_message($queue_name, $message, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['returnCurlHandle'] = $returnCurlHandle;
		return $this->authenticate('SendMessage', $opt, $this->hostname . '/' . $queue_name, $message);
	}

	/**
	 * Method: receive_message()
	 * 	Retrieves one or more messages from the specified queue, including the message body and message ID of each message. Messages returned by this action stay in the queue until you delete them. However, once a message is returned to a <receive_message()> request, it is not returned on subsequent <receive_message()> requests for the duration of the <VisibilityTimeout>. If you do not specify a <VisibilityTimeout> in the request, the overall visibility timeout for the queue is used for the returned messages. A default visibility timeout of 30 seconds is set when you create the queue. You can also set the visibility timeout for the queue by using <set_queue_attributes()>. See Visibility Timeout for more information.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	opt - _array_ (Required) Associative array of parameters which can have the following keys:
	 *
	 * Keys for the $opt parameter:
	 * 	AttributeName - _string_|_array_ (Optional) The attribute you want to get. Pass a string for a single attribute, or an indexed array for multiple attributes. Possible values are 'SenderId' and 'SentTimestamp'.
	 * 	VisibilityTimeout - _integer_ (Optional) Must be an integer from 0 to 7200 (2 hours).
	 * 	MaxNumberOfMessages - _integer_ (Optional) Maximum number of messages to return, from 1 to 10. Not necessarily all the messages in the queue are returned. If there are fewer messages in the queue than <MaxNumberOfMessages>, the maximum number of messages returned is the current number of messages in the queue. Defaults to 1 message.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/7_receive_message.phpt:
 	 * 	example::sqs/7_receive_message3.phpt:
 	 * 	example::sqs/7_receive_message4.phpt:
 	 * 	example::sqs/7_receive_message7.phpt:
 	 * 	example::sqs/7_receive_message8.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryReceiveMessage.html
	 * 	Related - <send_message()>, <receive_message()>, <delete_message()>, <change_message_visibility()>
	 */
	public function receive_message($queue_name, $opt = null)
	{
		if (!$opt) $opt = array();

		if (isset($opt['AttributeName']))
		{
			if (is_array($opt['AttributeName']))
			{
				for ($i = 0, $max = count($opt['AttributeName']); $i < $max; $i++)
				{
					$opt['AttributeName.' . ($i + 1)] = $opt['AttributeName'][$i];
				}
			}
			else
			{
				$opt['AttributeName.1'] = $opt['AttributeName'];
			}

			unset($opt['AttributeName']);
		}

		return $this->authenticate('ReceiveMessage', $opt, $this->hostname . '/' . $queue_name);
	}

	/**
	 * Method: delete_message()
	 * 	Unconditionally removes the specified message from the specified queue. Even if the message is locked by another reader due to the visibility timeout setting, it is still deleted from the queue.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	receipt_handle - _string_ (Required) The receipt handle of the message to delete, returned by <receive_message()>.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 * 	example::sqs/8_delete_message.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/Query_QueryDeleteMessage.html
	 * 	Related - <send_message()>, <receive_message()>, <delete_message()>, <change_message_visibility()>
	 */
	public function delete_message($queue_name, $receipt_handle, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['ReceiptHandle'] = $receipt_handle;
		$opt['returnCurlHandle'] = $returnCurlHandle;
		return $this->authenticate('DeleteMessage', $opt, $this->hostname . '/' . $queue_name);
	}

	/**
	 * Method: change_message_visibility()
	 * 	Changes the visibility timeout of a specified message in a queue to a new value. The maximum 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 more than a total visibility timeout of 12 hours.
	 *
	 * 	For example, let's say you have a message and its default message visibility timeout is 30 minutes. You could call ChangeMessageVisiblity with a value of two hours and the effective timeout would be two hours and 30 minutes. When that time comes near you could again extend the time out by calling ChangeMessageVisiblity, but this time the maximum allowed timeout would be 9 hours and 30 minutes.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	receipt_handle - _string_ (Required) The receipt handle associated with the message whose visibility timeout you want to change. This parameter is returned by <receive_message()>.
	 * 	visibility_timeout - _string_ (Required) The new value for the message's visibility timeout (in seconds). This value is limited to 43200 seconds (12 hours).
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/index.html?Query_QueryChangeMessageVisibility.html
	 * 	Related - <send_message()>, <receive_message()>, <delete_message()>, <change_message_visibility()>
	 */
	public function change_message_visibility($receipt_handle, $visibility_timeout, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['ReceiptHandle'] = $receipt_handle;
		$opt['VisibilityTimeout'] = $visibility_timeout;
		$opt['returnCurlHandle'] = $returnCurlHandle;
		return $this->authenticate('ChangeMessageVisibility', $opt, $this->hostname);
	}


	/*%******************************************************************************************%*/
	// ACCESS CONTROL METHODS

	/**
	 *
	 */
	public function generate_policy()
	{

	}

	/**
	 * Method: add_permission()
	 * 	Adds a permission to a queue for a specific principal. This allows for sharing access to the queue. 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 to the queue.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
 	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 * 	label - _string_ (Required) The unique identification of the permission you're setting. Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.
	 * 	permissions - _array_ (Required) An associative array of AWS account numbers (key) and the actions they're allowed to execute (value). AWS account numbers are for those who will be given permission. Actions can be passed as a string for a single action, or an indexed array for multiple actions. Valid values are '*', 'SendMessage', 'ReceiveMessage', 'DeleteMessage', 'ChangeMessageVisibility', or 'GetQueueAttributes'.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
	 * 	example::sqs/add_permission.phpt:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/index.html?Query_QueryAddPermission.html
	 * 	Related - <add_permission()>, <remove_permission()>, <generate_policy()>
	 */
	public function add_permission($queue_name, $label, $permissions, $returnCurlHandle = null)
	{
		$opt = array();
		$opt['Label'] = $label;

		// Starting point.
		$count = 1;

		// Parse through the array
		if (is_array($permissions))
		{
			foreach ($permissions as $account_id => $actions)
			{
				if (is_array($actions))
				{
					foreach ($actions as $action)
					{
						$opt['AWSAccountId.' . $count] = $account_id;
						$opt['ActionName.' . $count] = $action;

						$count++;
					}
				}
				else
				{
					$opt['AWSAccountId.1'] = $account_id;
					$opt['ActionName.1'] = $actions;
				}

				$count++;
			}
		}
		else
		{
			throw new SQS_Exception('$permissions MUST be an associative array of AWS Account IDs and Actions they\'re allowed to execute.');
		}

		$opt['returnCurlHandle'] = $returnCurlHandle;

		return $this->authenticate('AddPermission', $opt, $this->hostname . '/' . $queue_name);
	}

	/**
	 * Method: remove_permission()
	 * 	Revokes any permissions in the queue policy that matches the Label parameter. Only the owner of the queue can remove permissions.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	label - _string_ (Required) This should match the label you set in <add_permission()>.
	 * 	returnCurlHandle - _boolean_ (Optional) A private toggle that will return the CURL handle for the request rather than actually completing the request. This is useful for MultiCURL requests.
	 *
	 * Returns:
	 * 	<ResponseCore> object
 	 *
 	 * Examples:
 	 *
	 * See Also:
	 * 	AWS Method - http://docs.amazonwebservices.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/index.html?Query_QueryRemovePermission.html
	 * 	Related - <add_permission()>, <remove_permission()>, <generate_policy()>
	 */
	public function remove_permission($label, $returnCurlHandle = null)
	{
		if (!$opt) $opt = array();
		$opt['Label'] = $label;
		$opt['returnCurlHandle'] = $returnCurlHandle;
		return $this->authenticate('RemovePermission', $opt, $this->hostname);
	}


	/*%******************************************************************************************%*/
	// HELPER/UTILITY METHODS

	/**
	 * Method: get_queue_size()
	 * 	Retrieves the approximate number of messages in the queue.
	 *
	 * Access:
	 * 	public
	 *
	 * Parameters:
	 * 	queue_name - _string_ (Required) The name of the queue to perform the action on.
	 *
	 * Returns:
	 * 	_integer_ The Approximate number of messages in the queue.
 	 *
 	 * Examples:
 	 * 	example::sqs/6_get_queue_size.phpt:
 	 *
	 * See Also:
	 * 	Related - <get_queue_attributes()>
	 */
	public function get_queue_size($queue_name)
	{
		$opt = array();
		$opt['AttributeName'] = 'ApproximateNumberOfMessages';
		$response = $this->authenticate('GetQueueAttributes', $opt, $this->hostname . '/' . $queue_name);

		if ($response->isOK() === false)
		{
			throw new SQS_Exception("Could not get queue size for $queue_name: " . $response->body->Error->Code);
		}

		return (integer) $response->body->GetQueueAttributesResult->Attribute->Value;
	}
}