diff --git a/.gitignore b/.gitignore
index 9abaada..443c2e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,12 @@
.DS_Store
+output
config-rp.inc.php
config-ws.inc.php
config.inc.php
*sandbox*
+*_cache*
+*.cache
+*.diff
+*.log
+*.out
+*.exp
diff --git a/README.textile b/README.md
similarity index 53%
rename from README.textile
rename to README.md
index b75bb30..029c871 100644
--- a/README.textile
+++ b/README.md
@@ -1,8 +1,14 @@
-h1. CloudFusion
+# CloudFusion
Build awesome, cloud-based web applications in a fraction of the time!
-h2. Requirements
+## 3.0 is coming!
+
+CloudFusion 3.0 is a pretty sizable update and is coming very soon. If you're thinking about patching some aspect of CloudFusion and submitting it as a contribution, hang onto your shorts. Chances are, I've already fixed it.
+
+Keep an eye on the [3.0 Milestone](http://code.google.com/p/tarzan-aws/issues/list?q=label:Milestone-3.0) to get a sense of how much I have left to do -- it's not much at all! :)
+
+## Requirements
* PHP 5.1.4 or newer (PHP 5.2+ recommended)
* SimpleXML extension
@@ -18,7 +24,7 @@ Caching support requires one or more of the following:
* *MySQL:* PDO extension, PDO_MYSQL adapter, MySQL extension (or mysqlnd for PHP 5.3)
* *PostgreSQL:* PDO extension, PDO_PGSQL adapter, PGSQL extension
-h2. Get the latest code
+## Get the latest code
The following will pull down the latest development code, including CacheCore and RequestCore.
@@ -28,47 +34,44 @@ git submodule init
git submodule update
-h2. Donate
-
-Help me stop being broke by donating anything you can towards the further development of this software.
-
-h2. Getting the hang of Git
+## Getting the hang of Git
As of early November 2009, CloudFusion has moved to the Git SCM and GitHub for a code repository.
-h3. Mac
+### Mac
-Mac users can install Git either from "the installer":http://code.google.com/p/git-osx-installer/downloads/list?can=3 or via "MacPorts":http://macports.org. If installing via MacPorts, I'd recommend calling sudo port install git-core +svn.
+Mac users can install Git either from [the installer](http://code.google.com/p/git-osx-installer/downloads/list?can=3) or via [MacPorts](http://macports.org). If installing via MacPorts, I'd recommend calling `sudo port install git-core +svn`.
-h3. Windows
+### Windows
-Windows users can install "msys-git":http://code.google.com/p/msysgit/ or "TortoiseGit":http://code.google.com/p/tortoisegit/. "Getting started with Git and Github on Windows":http://kylecordes.com/2008/04/30/git-windows-go/ would be a good place to start.
+Windows users can install [msys-git](http://code.google.com/p/msysgit/) or [TortoiseGit](http://code.google.com/p/tortoisegit/). [Getting started with Git and Github on Windows](http://kylecordes.com/2008/04/30/git-windows-go/) would be a good place to start.
-h3. Linux
+### Linux
-Depending on your flavor of Linux you can likely either use yum or apt-get to install the Git package.
+Depending on your flavor of Linux you can likely either use `yum` or `apt-get` to install the Git package.
-h2. Contributing
+## Contributing
I want to see CloudFusion become a community project. If you have a patch for a bug or new feature, fork CloudFusion, make the updates, then send me a Github pull request. This makes patching much easier.
-It's even better when it's unit tested. Bug fix patches should include matching "PHPT":http://qa.php.net/write-test.php unit tests, and new features should include unit tests and documentation in "NaturalDocs":http://naturaldocs.org format.
+It's even better when it's unit tested. Bug fix patches should include matching [PHPT](http://qa.php.net/write-test.php) unit tests, and new features should include unit tests and documentation in [NaturalDocs](http://naturaldocs.org) format.
Documentation is equally as important as the code itself, and unit tests are actually used for code samples within the documentation. Doing your best will make my job easier. :)
I definitely need help with:
+
* Writing PHPT tests for the S3 class
* Writing PHPT tests for the EC2 class
* Supporting the new EC2-related services that have come out in the past few months
-h2. Links
+## Links
-* "Main site":http://getcloudfusion.com
-* "API reference":http://getcloudfusion.com/docs/latest
-* "Tutorials and screencasts":http://getcloudfusion.com/docs
-* "Discussion and support list":http://getcloudfusion.com/discussion
+* [Main site](http://getcloudfusion.com)
+* [API reference](http://getcloudfusion.com/docs/latest)
+* [Tutorials and screencasts](http://getcloudfusion.com/docs)
+* [Discussion and support list](http://getcloudfusion.com/discussion)
* Donate! -- Click the little "Donate" button in the upper-right corner
-h2. License
+## License
Code is BSD licensed. Documentation and tutorials are Creative Commons licensed. You can find exact details in the footer of the main site.
diff --git a/_tests/_cache/sqlite.db b/_tests/_cache/sqlite.db
index 78afb37..d4456b3 100755
Binary files a/_tests/_cache/sqlite.db and b/_tests/_cache/sqlite.db differ
diff --git a/_tests/cloudfront/create_distribution3.phpt b/_tests/cloudfront/create_distribution3.phpt
new file mode 100644
index 0000000..1e6c411
--- /dev/null
+++ b/_tests/cloudfront/create_distribution3.phpt
@@ -0,0 +1,31 @@
+--TEST--
+CloudFront: create_distribution(), with streaming.
+
+--FILE--
+create_distribution('warpshare.test', 'TarzanDemo2', array(
+ 'Enabled' => true,
+ 'Comment' => 'This is my sample comment',
+ 'CNAME' => 'unit-test2.warpshare.com',
+ 'Logging' => array(
+ 'Bucket' => 'warpshare.logging',
+ 'Prefix' => 'wslog_'
+ ),
+ 'Streaming' => true
+ ));
+
+ // Store the Distribution ID so that we can re-use it later. This is useful for unit testing.
+ // This is The Wrong Way To Do Itâ„¢
+ file_put_contents('create_distribution_stream.cache', (string) $response->body->Id);
+
+ // Success?
+ var_dump($response->isOK());
+?>
+
+--EXPECT--
+bool(true)
diff --git a/_tests/cloudfront/generate_config_xml10.phpt b/_tests/cloudfront/generate_config_xml10.phpt
new file mode 100644
index 0000000..4974bbb
--- /dev/null
+++ b/_tests/cloudfront/generate_config_xml10.phpt
@@ -0,0 +1,27 @@
+--TEST--
+CloudFront: generate_config_xml() testing enabled, comments, and multiple CNAMEs
+
+--FILE--
+generate_config_xml('warpshare.test.s3.amazonaws.com', 'WarpShareS3', array(
+ 'Enabled' => true,
+ 'Comment' => 'This is my sample comment',
+ 'CNAME' => array(
+ 'cdn1.warpshare.com',
+ 'cdn2.warpshare.com',
+ 'cdn3.warpshare.com'
+ ),
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/generate_config_xml7.phpt b/_tests/cloudfront/generate_config_xml7.phpt
new file mode 100644
index 0000000..7092db8
--- /dev/null
+++ b/_tests/cloudfront/generate_config_xml7.phpt
@@ -0,0 +1,20 @@
+--TEST--
+CloudFront: generate_config_xml(), with streaming
+
+--FILE--
+generate_config_xml('warpshare.test', 'WarpShareS3', array(
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/generate_config_xml8.phpt b/_tests/cloudfront/generate_config_xml8.phpt
new file mode 100644
index 0000000..8fa1504
--- /dev/null
+++ b/_tests/cloudfront/generate_config_xml8.phpt
@@ -0,0 +1,20 @@
+--TEST--
+CloudFront: generate_config_xml() testing FQDN, with streaming
+
+--FILE--
+generate_config_xml('warpshare.test.s3.amazonaws.com', 'WarpShareS3', array(
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/generate_config_xml9.phpt b/_tests/cloudfront/generate_config_xml9.phpt
new file mode 100644
index 0000000..79e6a70
--- /dev/null
+++ b/_tests/cloudfront/generate_config_xml9.phpt
@@ -0,0 +1,23 @@
+--TEST--
+CloudFront: generate_config_xml() testing enabled, comments, and single CNAME
+
+--FILE--
+generate_config_xml('warpshare.test.s3.amazonaws.com', 'WarpShareS3', array(
+ 'Enabled' => true,
+ 'Comment' => 'This is my sample comment',
+ 'CNAME' => 'cdn1.warpshare.com',
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/get_distribution_info3.phpt b/_tests/cloudfront/get_distribution_info3.phpt
new file mode 100644
index 0000000..257bccd
--- /dev/null
+++ b/_tests/cloudfront/get_distribution_info3.phpt
@@ -0,0 +1,23 @@
+--TEST--
+CloudFront: get_distribution_info() with streaming.
+
+--FILE--
+get_distribution_info($distribution_id, array(
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response->isOK());
+?>
+
+--EXPECT--
+bool(true)
diff --git a/_tests/cloudfront/get_private_object_url.phpt b/_tests/cloudfront/get_private_object_url.phpt
new file mode 100644
index 0000000..0d6ed73
--- /dev/null
+++ b/_tests/cloudfront/get_private_object_url.phpt
@@ -0,0 +1,34 @@
+--TEST--
+CloudFront: get_private_object_url() testing url generation
+
+--FILE--
+set_domain('p1dcedm05cjidz1.cloudfront.net');
+ $cdn->set_key_pair_id('ACVAD62RGVXHNO6TVPX9');
+ $cdn->set_private_key($pkeyid);
+
+ $url = $cdn->get_private_object_url('https://github.com/myfile.mp4',%20array('IpAddress'=%3E'73.121.132.9','DateLessThan'=%3E3600));
+
+ // free the key from memory
+ openssl_free_key($pkeyid);
+
+ // Success?
+ var_dump($url);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/list_distributions4.phpt b/_tests/cloudfront/list_distributions4.phpt
new file mode 100644
index 0000000..76479bd
--- /dev/null
+++ b/_tests/cloudfront/list_distributions4.phpt
@@ -0,0 +1,21 @@
+--TEST--
+CloudFront: list_distributions() with MaxResults and streaming.
+
+--FILE--
+list_distributions(array(
+ 'MaxItems' => 1,
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response->isOK());
+?>
+
+--EXPECT--
+bool(true)
diff --git a/_tests/cloudfront/set_distribution_config3.phpt b/_tests/cloudfront/set_distribution_config3.phpt
new file mode 100644
index 0000000..cac5e47
--- /dev/null
+++ b/_tests/cloudfront/set_distribution_config3.phpt
@@ -0,0 +1,40 @@
+--TEST--
+CloudFront: set_distribution_config() with streaming.
+
+--FILE--
+get_distribution_config($distribution_id, array(
+ 'Streaming' => true
+ ));
+
+ // Generate an updated XML config...
+ $updated_xml = $cdn->update_config_xml($existing_xml, array(
+ 'Enabled' => false,
+ 'Streaming' => true
+ ));
+
+ // Fetch an updated ETag value
+ $etag = $cdn->get_distribution_config($distribution_id, array(
+ 'Streaming' => true
+ ))->header['etag'];
+
+ // Set the updated config XML to the distribution.
+ $response = $cdn->set_distribution_config($distribution_id, $updated_xml, $etag, array(
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response->isOK());
+?>
+
+--EXPECT--
+bool(true)
diff --git a/_tests/cloudfront/update_config_xml10.phpt b/_tests/cloudfront/update_config_xml10.phpt
new file mode 100644
index 0000000..974e8b0
--- /dev/null
+++ b/_tests/cloudfront/update_config_xml10.phpt
@@ -0,0 +1,27 @@
+--TEST--
+CloudFront: update_config_xml() testing enabled, comments, and single CNAME using a ResponseCore object, with streaming.
+
+--FILE--
+ object instead of just the SimpleXML body.
+ $config_xml = $cdn->get_distribution_config('E2L6A3OZHQT5W4');
+
+ // Update the XML content
+ $response = $cdn->update_config_xml($config_xml, array(
+ 'Enabled' => true,
+ 'Comment' => 'This is my sample comment',
+ 'CNAME' => 'cdn1.warpshare.com',
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/update_config_xml6.phpt b/_tests/cloudfront/update_config_xml6.phpt
index 94ce4d7..b6aab90 100644
--- a/_tests/cloudfront/update_config_xml6.phpt
+++ b/_tests/cloudfront/update_config_xml6.phpt
@@ -1,5 +1,5 @@
--TEST--
-CloudFront: update_config_xml() testing enabled, comments, and single CNAME using a string.
+CloudFront: update_config_xml() testing enabled, comments, single CNAME using a string, adding logging.
--FILE--
get_distribution_config('E2L6A3OZHQT5W4')->body;
+
+ // Update the XML content
+ $response = $cdn->update_config_xml($config_xml, array(
+ 'Enabled' => true,
+ 'Comment' => 'This is my sample comment',
+ 'CNAME' => 'cdn1.warpshare.com',
+ 'Logging' => array(
+ 'Bucket' => 'warpshare.logging',
+ 'Prefix' => 'wslog_'
+ ),
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/update_config_xml8.phpt b/_tests/cloudfront/update_config_xml8.phpt
new file mode 100644
index 0000000..02744f2
--- /dev/null
+++ b/_tests/cloudfront/update_config_xml8.phpt
@@ -0,0 +1,31 @@
+--TEST--
+CloudFront: update_config_xml() testing enabled, comments, and multiple CNAMEs, with streaming.
+
+--FILE--
+get_distribution_config('E2L6A3OZHQT5W4')->body;
+
+ // Update the XML content
+ $response = $cdn->update_config_xml($config_xml, array(
+ 'Enabled' => true,
+ 'Comment' => 'This is my sample comment',
+ 'CNAME' => array(
+ 'cdn1.warpshare.com',
+ 'cdn2.warpshare.com',
+ 'cdn3.warpshare.com'
+ ),
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/update_config_xml9.phpt b/_tests/cloudfront/update_config_xml9.phpt
new file mode 100644
index 0000000..2c9c4e1
--- /dev/null
+++ b/_tests/cloudfront/update_config_xml9.phpt
@@ -0,0 +1,28 @@
+--TEST--
+CloudFront: update_config_xml() testing logging, with streaming.
+
+--FILE--
+get_distribution_config('E2L6A3OZHQT5W4')->body;
+
+ // Update the XML content
+ $response = $cdn->update_config_xml($config_xml, array(
+ 'Logging' => array(
+ 'Bucket' => 'warpshare.logging',
+ 'Prefix' => 'wslog_'
+ ),
+ 'Streaming' => true
+ ));
+
+ // Success?
+ var_dump($response);
+?>
+
+--EXPECTF--
+string(%d) "%s"
diff --git a/_tests/cloudfront/z_delete_distribution2.phpt b/_tests/cloudfront/z_delete_distribution2.phpt
new file mode 100644
index 0000000..be7aa86
--- /dev/null
+++ b/_tests/cloudfront/z_delete_distribution2.phpt
@@ -0,0 +1,31 @@
+--TEST--
+CloudFront: delete_distribution() with streaming.
+
+--FILE--
+get_distribution_config($distribution_id)->header['etag'];
+
+ // Set the updated config XML to the distribution.
+ $response = $cdn->delete_distribution($distribution_id, $etag);
+
+ // Success?
+ var_dump($response->isOK());
+
+ // If the delete request was successful, delete the cached file.
+ if ($response->isOK())
+ {
+ unlink('create_distribution_stream.cache');
+ }
+?>
+
+--EXPECT--
+bool(true)
diff --git a/cloudfusion.class.php b/cloudfusion.class.php
index f38069b..be615e3 100755
--- a/cloudfusion.class.php
+++ b/cloudfusion.class.php
@@ -8,7 +8,7 @@
* 2009.10.10
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
@@ -41,7 +41,7 @@
* Constant: CLOUDFUSION_VERSION
* Version of the software.
*/
-define('CLOUDFUSION_VERSION', '2.5');
+define('CLOUDFUSION_VERSION', '2.5.1-dev');
/**
* Constant: CLOUDFUSION_BUILD
@@ -243,11 +243,11 @@ public static function autoloader($class)
if (strstr($class, 'Amazon'))
{
- $path .= str_ireplace('Amazon', '', strtolower($class)) . '.class.php';
+ $path .= 'services/' . str_ireplace('Amazon', '', strtolower($class)) . '.class.php';
}
elseif (strstr($class, 'CF'))
{
- $path .= str_ireplace('CF', '_', strtolower($class)) . '.class.php';
+ $path .= 'services/' . str_ireplace('CF', '_', strtolower($class)) . '.class.php';
}
elseif (strstr($class, 'Cache'))
{
@@ -362,9 +362,6 @@ public function __construct($key = null, $secret_key = null, $account_id = null,
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/adjust_offset.phpt:
*/
public function adjust_offset($seconds)
{
@@ -384,9 +381,6 @@ public function adjust_offset($seconds)
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/set_proxy.phpt:
*/
public function set_proxy($proxy)
{
@@ -406,9 +400,6 @@ public function set_proxy($proxy)
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/set_hostname.phpt:
*/
public function set_hostname($hostname)
{
@@ -425,9 +416,6 @@ public function set_hostname($hostname)
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/disable_ssl.phpt:
*/
public function disable_ssl()
{
@@ -451,9 +439,6 @@ public function disable_ssl()
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/set_utilities_class.phpt:
*/
function set_utilities_class($class = 'CFUtilities')
{
@@ -474,9 +459,6 @@ function set_utilities_class($class = 'CFUtilities')
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/set_request_class.phpt:
*/
function set_request_class($class = 'RequestCore')
{
@@ -496,9 +478,6 @@ function set_request_class($class = 'RequestCore')
*
* Returns:
* void
- *
- * Examples:
- * example::cloudfusion/set_response_class.phpt:
*/
function set_response_class($class = 'ResponseCore')
{
@@ -654,14 +633,6 @@ public function authenticate($action, $opt = null, $domain = null, $message = nu
*
* Returns:
* object
- *
- * Examples:
- * example::cloudfusion/cache_response_apc.phpt:
- * example::cloudfusion/cache_response_file.phpt:
- * example::cloudfusion/cache_response_memcached.phpt:
- * example::cloudfusion/cache_response_pdo_sqlite.phpt:
- * example::cloudfusion/cache_response_multi_apc.phpt:
- * example::cloudfusion/cache_response_multi_file.phpt:
*/
public function cache_response($method, $location, $expires, $params = null, $gzip = true)
{
@@ -861,12 +832,6 @@ public function cache_response($method, $location, $expires, $params = null, $gz
*
* Returns:
* boolean TRUE if cached object exists and is successfully deleted, otherwise FALSE
- *
- * Examples:
- * example::cloudfusion/delete_cache_response_apc.phpt:
- * example::cloudfusion/delete_cache_response_file.phpt:
- * example::cloudfusion/delete_cache_response_memcached.phpt:
- * example::cloudfusion/delete_cache_response_pdo_sqlite.phpt:
*/
public function delete_cache_response($method, $location, $params = null)
{
diff --git a/config-sample.inc.php b/config-sample.inc.php
index 8e61684..40f1f3d 100644
--- a/config-sample.inc.php
+++ b/config-sample.inc.php
@@ -4,10 +4,10 @@
* Stores your AWS account information. Add your account information, then rename this file to 'config.inc.php'.
*
* Version:
- * 2009.08.20
+ * 2010.01.19
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
@@ -19,19 +19,19 @@
/**
* Constant: AWS_KEY
- * Amazon Web Services Key.
+ * Amazon Web Services Key.
*/
define('AWS_KEY', '');
/**
* Constant: AWS_SECRET_KEY
- * Amazon Web Services Secret Key.
+ * Amazon Web Services Secret Key.
*/
define('AWS_SECRET_KEY', '');
/**
* Constant: AWS_ACCOUNT_ID
- * Amazon Account ID without dashes. Used for identification with Amazon EC2.
+ * Amazon Account ID without dashes. Used for identification with Amazon EC2.
*/
define('AWS_ACCOUNT_ID', '');
diff --git a/examples.yml b/examples.yml
new file mode 100644
index 0000000..cc93bc0
--- /dev/null
+++ b/examples.yml
@@ -0,0 +1,30 @@
+CloudFusion:
+ __construct:
+ adjust_offset:
+ - _tests/cloudfusion/adjust_offset.phpt
+ authenticate:
+ autoloader:
+ cache_response:
+ - _tests/cloudfusion/cache_response_apc.phpt
+ - _tests/cloudfusion/cache_response_file.phpt
+ - _tests/cloudfusion/cache_response_memcached.phpt
+ - _tests/cloudfusion/cache_response_pdo_sqlite.phpt
+ - _tests/cloudfusion/cache_response_multi_apc.phpt
+ - _tests/cloudfusion/cache_response_multi_file.phpt
+ delete_cache_response:
+ - _tests/cloudfusion/delete_cache_response_apc.phpt
+ - _tests/cloudfusion/delete_cache_response_file.phpt
+ - _tests/cloudfusion/delete_cache_response_memcached.phpt
+ - _tests/cloudfusion/delete_cache_response_pdo_sqlite.phpt
+ disable_ssl:
+ - _tests/cloudfusion/disable_ssl.phpt
+ set_hostname:
+ - _tests/cloudfusion/set_hostname.phpt
+ set_proxy:
+ - _tests/cloudfusion/set_proxy.phpt
+ set_request_class:
+ - _tests/cloudfusion/set_request_class.phpt
+ set_response_class:
+ - _tests/cloudfusion/set_response_class.phpt
+ set_utilities_class:
+ - _tests/cloudfusion/set_utilities_class.phpt
diff --git a/lib/requestcore b/lib/requestcore
index d91045f..61e58d2 160000
--- a/lib/requestcore
+++ b/lib/requestcore
@@ -1 +1 @@
-Subproject commit d91045fac3a25622a5121c6146f68c8864e47c63
+Subproject commit 61e58d22804053d643aee1248a171bce12e2ff4c
diff --git a/package.xml b/package.xml
new file mode 100644
index 0000000..0d382a3
--- /dev/null
+++ b/package.xml
@@ -0,0 +1,60 @@
+
+
+ cloudfusion
+ pear.warpshare.org
+ Build awesome, cloud-based web applications in a fraction of the time!
+ Fast, powerful PHP toolkit with an easy to learn, consistent API. Highly extensible framework for easily adding new services. Ridiculously thorough API reference, code samples and tutorials. Works with Amazon Web Services and Eucalyptus.
+
+ Ryan Parman
+ skyzyx
+ ryan@getcloudfusion.com
+ yes
+
+ 2010-02-09
+
+
+ 2.5.0
+ 2.5.0
+
+
+ stable
+ stable
+
+ New BSD
+ version 2.5.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5.1.4
+
+
+ 1.4.0
+
+
+
+
+
diff --git a/_utilities.class.php b/services/_utilities.class.php
similarity index 96%
rename from _utilities.class.php
rename to services/_utilities.class.php
index d9c27c2..6768a32 100644
--- a/_utilities.class.php
+++ b/services/_utilities.class.php
@@ -4,10 +4,10 @@
* Utilities for connecting to, and working with, AWS.
*
* Version:
- * 2009.08.24
+ * 2010.02.07
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
@@ -87,7 +87,9 @@ public function hex_to_base64($str)
*/
public function to_query_string($array)
{
- return http_build_query($array);
+ // Explicitly pass a third parameter.
+ // http://php.net/manual/en/function.http-build-query.php#74781
+ return http_build_query($array, '', '&');
}
/**
@@ -341,7 +343,8 @@ public function json_encode($obj)
{
if (function_exists('json_encode'))
{
- return json_encode($obj);
+ //str_replace is for a json_encode bug where it escapes forward slashes
+ return str_replace('\/','/',json_encode($obj));
}
return $this->json_encode_php51($obj);
diff --git a/cloudfront.class.php b/services/cloudfront.class.php
similarity index 59%
rename from cloudfront.class.php
rename to services/cloudfront.class.php
index 1af1938..145b518 100644
--- a/cloudfront.class.php
+++ b/services/cloudfront.class.php
@@ -4,10 +4,10 @@
* Amazon CloudFront CDN Service (http://aws.amazon.com/cloudfront)
*
* Version:
- * 2009.10.11
+ * 2010.03.26
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
@@ -51,11 +51,29 @@ class CloudFront_Exception extends Exception {}
class AmazonCloudFront extends CloudFusion
{
/**
- * Property: base_xml
+ * Property: base_standard_xml
* The base content to use for generating the DistributionConfig XML.
*/
var $base_xml;
+ /**
+ * Property: domain
+ * The CloudFront distribution domain to use.
+ */
+ var $domain;
+
+ /**
+ * Property: key_pair_id
+ * The RSA key pair ID to use.
+ */
+ var $key_pair_id;
+
+ /**
+ * Property: private_key
+ * The RSA private key resource locator.
+ */
+ var $private_key;
+
/*%******************************************************************************************%*/
// CONSTRUCTOR
@@ -76,9 +94,10 @@ class AmazonCloudFront extends CloudFusion
*/
public function __construct($key = null, $secret_key = null)
{
- $this->api_version = '2009-04-02';
+ $this->api_version = '2009-12-01';
$this->hostname = CDN_DEFAULT_URL;
- $this->base_xml = '';
+
+ $this->base_xml = '<%s xmlns="http://cloudfront.amazonaws.com/doc/' . $this->api_version . '/">%1$s>';
if (!$key && !defined('AWS_KEY'))
{
@@ -121,19 +140,127 @@ public function authenticate($method = HTTP_GET, $path = null, $opt = null, $xml
{
$querystring = null;
- if (!$opt) $opt = array();
-
- // Generate the querystring from $opt, removing a reference to returnCurlHandle.
- if ($opt)
+ if (!$opt)
+ {
+ $opt = array();
+ }
+ else
{
+ // Generating a pre-signed URL
+ if (isset($opt['conditions']))
+ {
+ // Put this at the top since if we're requesting a URL be generated the rest of this function is not going to be executed
+ $domain = null;
+ $filename = null;
+ $conditions = null;
+ $private_key = null;
+ $return = array();
+ extract($opt);
+
+ if (isset($conditions['DateLessThanExact']))
+ {
+ $expires = $conditions['DateLessThanExact'];
+ unset($conditions['DateLessThanExact']);
+ }
+ else
+ {
+ // Get the expiry time
+ $expires = time() + $conditions['DateLessThan'];
+ }
+
+ // Reformat the conditions
+ $conditions['DateLessThan'] = array(
+ 'AWS:EpochTime' => $expires
+ );
+
+ if (isset($conditions['DateGreaterThan']))
+ {
+ $conditions['DateGreaterThan'] = array(
+ 'AWS:EpochTime' => time() + $conditions['DateGreaterThan']
+ );
+ }
+ elseif (isset($conditions['DateGreaterThanExact']))
+ {
+ $conditions['DateGreaterThan'] = array(
+ 'AWS:EpochTime' => $conditions['DateGreaterThanExact']
+ );
+
+ unset($conditions['DateGreaterThanExact']);
+ }
+
+ if (isset($conditions['IpAddress']))
+ {
+ $conditions['IpAddress'] = array(
+ 'AWS:SourceIp' => $conditions['IpAddress']
+ );
+ }
+
+ // Prepare the resource
+ $resource = 'http://' . $domain . '/' . str_replace(' ', '%20', $filename);
+
+ // Canned policy
+ if (count($conditions) === 1)
+ {
+ // Prepare the policy - the str_replace is because json_encode has a bug where it escapes forward slashes
+ $policy = $this->util->json_encode(array(
+ 'Statement' => array(
+ array(
+ 'Resource' => $resource,
+ 'Condition' => $conditions
+ )
+ )
+ ));
+
+ $return['expires'] = $expires;
+ }
+ else
+ {
+ // Prepare the policy
+ // The str_replace is because json_encode has a bug where it escapes forward slashes -- the new line is required for custom policies
+ $policy = $this->util->json_encode(array(
+ 'Statement' => array(
+ array(
+ 'Resource' => $resource,
+ 'Condition' => $conditions
+ )
+ )
+ )) . "\n";
+
+ // URL-safe the policy
+ $policy_encoded = strtr(base64_encode($policy), '+=/', '-_~');
+ $return['policy'] = $policy_encoded;
+ }
+
+ // Sign the policy
+ openssl_sign($policy, $signature, $private_key);
+
+ // URL-safe the signature
+ $signature = strtr(base64_encode($signature), '+=/', '-_~');
+
+ $return['resource'] = $resource;
+ $return['signature'] = $signature;
+
+ return $return;
+ }
+
+ // Generate the querystring from $opt, removing a reference to returnCurlHandle.
$query = $opt;
+ // Get the action from $opt
+ if (isset($query['action']))
+ {
+ unset($query['action']);
+ }
+
if (isset($query['returnCurlHandle']))
{
unset($query['returnCurlHandle']);
}
- $querystring = '?' . $this->util->to_query_string($query);
+ if (count($query) > 0)
+ {
+ $querystring = '?' . $this->util->to_query_string($query);
+ }
}
// Gather information to pass along to other classes.
@@ -144,7 +271,8 @@ public function authenticate($method = HTTP_GET, $path = null, $opt = null, $xml
);
// Compose the request.
- $request_url = 'https://' . $this->hostname . '/' . $this->api_version . '/distribution';
+ $request_url = 'https://' . $this->hostname . '/' . $this->api_version . '/' . $opt['action'];
+
$request_url .= ($path) ? $path : '';
$request_url .= ($querystring) ? $querystring : '';
$request = new $this->request_class($request_url, $this->set_proxy, $helpers);
@@ -189,6 +317,63 @@ public function authenticate($method = HTTP_GET, $path = null, $opt = null, $xml
return $data;
}
+ /**
+ * Method: set_domain()
+ * Set the domain to be used for your CloudFront distribution.
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * domain - _string_ (Required) The hostname to use.
+ *
+ * Returns:
+ * void
+ *
+ */
+ public function set_domain($domain)
+ {
+ $this->domain = $domain;
+ }
+
+ /**
+ * Method: set_keypair_id()
+ * Set the key ID of the RSA key pair being used.
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * key_pair_id - _string_ (Required) ID of the RSA key pair being used.
+ *
+ * Returns:
+ * void
+ *
+ */
+ public function set_keypair_id($key_pair_id)
+ {
+ $this->key_pair_id = $key_pair_id;
+ }
+
+ /**
+ * Method: set_private_key()
+ * Set the private key resource locator being used.
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * private_key - _string_ (Optional) RSA private key resource identifier used to sign requests. You must use openssl_get_privatekey() or openssl_pkey_get_private() to get the resource identifier. Don't forget to call openssl_free_key() when you're done.
+ *
+ * Returns:
+ * void
+ *
+ */
+ public function set_private_key($private_key)
+ {
+ $this->private_key = $private_key;
+ }
+
/*%******************************************************************************************%*/
// SET CUSTOM SETTINGS
@@ -227,7 +412,10 @@ public function disable_ssl()
* Keys for the $opt parameter:
* CNAME - _string_|_array_ (Optional) A DNS CNAME to use to map to the CloudFront distribution. If setting more than one, use an indexed array. Supports 1-10 CNAMEs.
* Comment - _integer_ (Optional) A comment to apply to the distribution. Cannot exceed 128 characters.
+ * OriginAccessIdentity - _string_ (Optional) The Origin Access Identity associated with this distribution. Use the Identity ID, not the CanonicalId.
+ * TrustedSigners - _array_ (Optional) Array of AWS Account numbers who are trusted signers. You must explicitly add "Self" (exactly as shown) to the array if you want your own account to be a trusted signer.
* Enabled - _string_ (Optional) Defaults to true. Use this to set Enabled to false.
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
*
* Returns:
* String DistributionConfig XML document.
@@ -236,6 +424,8 @@ public function disable_ssl()
* example::cloudfront/generate_config_xml3.phpt:
* example::cloudfront/generate_config_xml4.phpt:
* example::cloudfront/generate_config_xml5.phpt:
+ * example::cloudfront/generate_config_xml9.phpt:
+ * example::cloudfront/generate_config_xml10.phpt:
*
* See Also:
* Related - , ,
@@ -243,7 +433,14 @@ public function disable_ssl()
public function generate_config_xml($origin, $caller_reference, $opt = null)
{
// Default, empty XML
- $xml = simplexml_load_string($this->base_xml);
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) // Did we ask to stream?
+ {
+ $xml = simplexml_load_string(sprintf($this->base_xml,'StreamingDistributionConfig'));
+ }
+ else
+ {
+ $xml = simplexml_load_string(sprintf($this->base_xml,'DistributionConfig'));
+ }
// Origin
if (stripos($origin, '.s3.amazonaws.com') !== false)
@@ -312,6 +509,32 @@ public function generate_config_xml($origin, $caller_reference, $opt = null)
}
}
+ // Origin Access Identity
+ if (isset($opt['OriginAccessIdentity']))
+ {
+ $xml->addChild('OriginAccessIdentity', 'origin-access-identity/cloudfront/' . $opt['OriginAccessIdentity']);
+ }
+
+ // Trusted Signers
+ if (isset($opt['TrustedSigners']))
+ {
+ if (is_array($opt['TrustedSigners']))
+ {
+ $trusted_signers = $xml->addChild('TrustedSigners');
+ foreach($opt['TrustedSigners'] as $signer)
+ {
+ if ($signer === 'Self')
+ {
+ $trusted_signers->addChild('Self');
+ }
+ else
+ {
+ $trusted_signers->addChild('AwsAccountNumber', $signer);
+ }
+ }
+ }
+ }
+
return $xml->asXML();
}
@@ -330,12 +553,17 @@ public function generate_config_xml($origin, $caller_reference, $opt = null)
* CNAME - _string_|_array_ (Optional) This (these) value(s) will be ADDED to the existing list of CNAME values. To remove a CNAME value, see .
* Comment - _integer_ (Optional) This value will replace the existing value for 'Comment'. Cannot exceed 128 characters.
* Enabled - _string_ (Optional) This value will replace the existing value for 'Enabled'.
+ * Logging - _array_ (Optional)
+ * OriginAccessIdentity - _string_ (Optional) This value will replace the existing value for 'OriginAccessIdentity'.
+ * TrustedSigners - _array_ (Optional) This array will replace the existing array for 'TrustedSigners'.
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
*
* Returns:
* String DistributionConfig XML document.
*
* Examples:
* example::cloudfront/update_config_xml4.phpt:
+ * example::cloudfront/update_config_xml10.phpt:
*
* See Also:
* Related - , ,
@@ -355,7 +583,14 @@ public function update_config_xml($xml, $opt = null)
}
// Default, empty XML
- $update = simplexml_load_string($this->base_xml);
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true) // Did we ask to stream?
+ {
+ $update = simplexml_load_string(sprintf($this->base_xml, 'StreamingDistributionConfig'));
+ }
+ else
+ {
+ $update = simplexml_load_string(sprintf($this->base_xml, 'DistributionConfig'));
+ }
// These can't change.
$update->addChild('Origin', $xml->Origin);
@@ -431,6 +666,51 @@ public function update_config_xml($xml, $opt = null)
$logging->addChild('Prefix', $xml->Logging->Prefix);
}
+ // Origin Access Identity
+ if (isset($opt['OriginAccessIdentity']))
+ {
+ $update->addChild('OriginAccessIdentity', 'origin-access-identity/cloudfront/' . $opt['OriginAccessIdentity']);
+ }
+ elseif (isset($xml->OriginAccessIdentity))
+ {
+ $update->addChild('OriginAccessIdentity', 'origin-access-identity/cloudfront/' . $xml->OriginAccessIdentity);
+ }
+
+ // Trusted Signers
+ if (isset($opt['TrustedSigners']))
+ {
+ if (is_array($opt['TrustedSigners']))
+ {
+ $trusted_signers = $update->addChild('TrustedSigners');
+ foreach($opt['TrustedSigners'] as $signer)
+ {
+ if ($signer == 'Self')
+ {
+ $trusted_signers->addChild('Self');
+ }
+ else
+ {
+ $trusted_signers->addChild('AwsAccountNumber', $signer);
+ }
+ }
+ }
+ }
+ elseif (isset($xml->TrustedSigners) && $xml->TrustedSigners->count())
+ {
+ $trusted_signers = $xml->TrustedSigners;
+ foreach($xml->TrustedSigners->children() as $signer)
+ {
+ if ($signer === 'Self')
+ {
+ $trusted_signers->addChild('Self');
+ }
+ else
+ {
+ $trusted_signers->addChild('AWSAccountNumber', $signer);
+ }
+ }
+ }
+
// Output
return $update->asXML();
}
@@ -505,6 +785,38 @@ public function remove_cname($xml, $cname)
return $xml->asXML();
}
+ /**
+ * Method: oai_config_xml()
+ * Used to generate the Origin Access Identity Config XML used in .
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * caller_reference - _string_ (Required) A unique identifier for the request. Must be generated on your own. A time stamp or hash is a good example.
+ * comment - _string_ (Optional) A comment about the origin access identity.
+ *
+ * Returns:
+ * String CloudFrontOriginAccessIdentityConfig XML document.
+ *
+ */
+ public function oai_config_xml($caller_reference, $comment = null)
+ {
+ // Default, empty XML
+ $xml = simplexml_load_string(sprintf($this->base_xml, 'CloudFrontOriginAccessIdentityConfig'));
+
+ // CallerReference
+ $xml->addChild('CallerReference', $caller_reference);
+
+ // Comment
+ if ($comment !== null)
+ {
+ $xml->addChild('Comment', $comment);
+ }
+
+ return $xml->asXML();
+ }
+
/*%******************************************************************************************%*/
// DISTRIBUTIONS
@@ -513,6 +825,8 @@ public function remove_cname($xml, $cname)
* Method: create_distribution()
* The response echoes the DistributionConfig element and returns other metadata about the distribution. For more information, see Parts of a Basic Distribution. It takes a short time for CloudFront to propagate your new distribution's information throughout the CloudFront system. For more information, see Eventual Consistency. You can have up to 100 distributions in the Amazon CloudFront system.
*
+ * For an Adobe Real-Time Messaging Protocol (RTMP) streaming distribution, set the Streaming option to true.
+ *
* Access:
* public
*
@@ -525,6 +839,9 @@ public function remove_cname($xml, $cname)
* CNAME - _string_|_array_ (Optional) A DNS CNAME to use to map to the CloudFront distribution. If setting more than one, use an indexed array. Supports 1-10 CNAMEs.
* Comment - _integer_ (Optional) A comment to apply to the distribution. Cannot exceed 128 characters.
* Enabled - _string_ (Optional) Defaults to true. Use this to set Enabled to false.
+ * OriginAccessIdentity - _string_ (Optional) The Origin Access Identity associated with this distribution. Use the Identity ID, not the CanonicalId.
+ * TrustedSigners - _array_ (Optional) Array of AWS Account numbers who are trusted signers. You must explicitly add "Self" (exactly as shown) to the array if you want your own account to be a trusted signer.
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
* 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:
@@ -532,6 +849,7 @@ public function remove_cname($xml, $cname)
*
* Examples:
* example::cloudfront/create_distribution.phpt:
+ * example::cloudfront/create_distribution3.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/CreateDistribution.html
@@ -540,12 +858,23 @@ public function remove_cname($xml, $cname)
public function create_distribution($origin, $caller_reference, $opt = null)
{
$auth = array();
+
if (isset($opt['returnCurlHandle']))
{
$auth['returnCurlHandle'] = $opt['returnCurlHandle'];
unset($opt['returnCurlHandle']);
}
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true)
+ {
+ $auth['action'] = 'streaming-distribution';
+ unset($opt['Streaming']);
+ }
+ else
+ {
+ $auth['action'] = 'distribution';
+ }
+
$xml = $this->generate_config_xml($origin, $caller_reference, $opt);
return $this->authenticate(HTTP_POST, null, $auth, $xml, null);
@@ -555,6 +884,8 @@ public function create_distribution($origin, $caller_reference, $opt = null)
* Method: list_distributions()
* Gets a list of your distributions. By default, your entire list of distributions is returned in one single page. If the list is long, you can paginate it using the MaxItems and Marker parameters.
*
+ * Standard distributions are listed separately from streaming distributions. For streaming distributions, set the Streaming option to true.
+ *
* Access:
* public
*
@@ -564,6 +895,7 @@ public function create_distribution($origin, $caller_reference, $opt = null)
* Keys for the $opt parameter:
* Marker - _string_ (Optional) Use this when paginating results to indicate where in your list of distributions to begin. The results include distributions in the list that occur after the marker. To get the next page of results, set the Marker to the value of the NextMarker from the current page's response (which is also the ID of the last distribution on that page).
* MaxItems - _integer_ (Optional) The maximum number of distributions you want in the response body. Maximum of 100.
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
* 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:
@@ -572,6 +904,7 @@ public function create_distribution($origin, $caller_reference, $opt = null)
* Examples:
* example::cloudfront/list_distributions.phpt:
* example::cloudfront/list_distributions2.phpt:
+ * example::cloudfront/list_distributions4.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/ListDistributions.html
@@ -579,6 +912,16 @@ public function create_distribution($origin, $caller_reference, $opt = null)
*/
public function list_distributions($opt = null)
{
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true)
+ {
+ $opt['action'] = 'streaming-distribution';
+ unset($opt['Streaming']);
+ }
+ else
+ {
+ $opt['action'] = 'distribution';
+ }
+
return $this->authenticate(HTTP_GET, null, $opt, null, null);
}
@@ -586,6 +929,8 @@ public function list_distributions($opt = null)
* Method: get_distribution_info()
* Gets information about a given distribution.
*
+ * Standard distributions are handled separately from streaming distributions. For streaming distributions, set the Streaming option to true.
+ *
* Access:
* public
*
@@ -594,6 +939,7 @@ public function list_distributions($opt = null)
* opt - _array_ (Required) Associative array of parameters which can have the following keys:
*
* Keys for the $opt parameter:
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
* 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:
@@ -601,6 +947,7 @@ public function list_distributions($opt = null)
*
* Examples:
* example::cloudfront/get_distribution_info.phpt:
+ * example::cloudfront/get_distribution_info3.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/GetDistribution.html
@@ -608,6 +955,16 @@ public function list_distributions($opt = null)
*/
public function get_distribution_info($distribution_id, $opt = null)
{
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true)
+ {
+ $opt['action'] = 'streaming-distribution';
+ unset($opt['Streaming']);
+ }
+ else
+ {
+ $opt['action'] = 'distribution';
+ }
+
return $this->authenticate(HTTP_GET, '/' . $distribution_id, $opt, null, null);
}
@@ -615,6 +972,8 @@ public function get_distribution_info($distribution_id, $opt = null)
* Method: delete_distribution()
* Deletes a disabled distribution. If you haven't disabled the distribution, Amazon CloudFront returns a DistributionNotDisabled error. Use to disable a distribution before attempting to delete.
*
+ * For an Adobe Real-Time Messaging Protocol (RTMP) streaming distribution, set the Streaming option to true.
+ *
* Access:
* public
*
@@ -624,6 +983,7 @@ public function get_distribution_info($distribution_id, $opt = null)
* opt - _array_ (Optional) Associative array of parameters which can have the following keys:
*
* Keys for the $opt parameter:
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
* 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:
@@ -631,6 +991,7 @@ public function get_distribution_info($distribution_id, $opt = null)
*
* Examples:
* example::cloudfront/z_delete_distribution.phpt:
+ * example::cloudfront/z_delete_distribution2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/DeleteDistribution.html
@@ -638,9 +999,44 @@ public function get_distribution_info($distribution_id, $opt = null)
*/
public function delete_distribution($distribution_id, $etag = null, $opt = null)
{
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true)
+ {
+ $opt['action'] = 'streaming-distribution';
+ unset($opt['Streaming']);
+ }
+ else
+ {
+ $opt['action'] = 'distribution';
+ }
+
return $this->authenticate(HTTP_DELETE, '/' . $distribution_id, $opt, null, $etag);
}
+ /**
+ * Method: create_origin_access_identity()
+ * The response echoes the CloudFrontOriginAccessIdentity element and returns the newly created identity, an existing identity if the caller_reference is the same, or an error if caller_reference is the same but the rest of the content differs. You can have 100 origin access identities.
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * caller_reference - _string_ (Required) A unique identifier for the request. Must be generated on your own. A time stamp or hash is a good example.
+ * comment - _string_ (Optional) A comment about the origin access identity.
+ *
+ * Returns:
+ * object
+ *
+ */
+ public function create_origin_access_identity($caller_reference, $comment = null)
+ {
+ $auth = array();
+ $auth['action'] = 'origin-access-identity/cloudfront';
+
+ $xml = $this->oai_config_xml($caller_reference, $comment);
+
+ return $this->authenticate(HTTP_POST, null, $auth, $xml, null);
+ }
+
/*%******************************************************************************************%*/
// DISTRIBUTION CONFIG
@@ -649,6 +1045,8 @@ public function delete_distribution($distribution_id, $etag = null, $opt = null)
* Method: get_distribution_config()
* Gets the current distribution config information for a given distribution ID.
*
+ * Standard distributions are handled separately from streaming distributions. For streaming distributions, set the Streaming option to true.
+ *
* Access:
* public
*
@@ -657,6 +1055,7 @@ public function delete_distribution($distribution_id, $etag = null, $opt = null)
* opt - _array_ (Required) Associative array of parameters which can have the following keys:
*
* Keys for the $opt parameter:
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
* 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:
@@ -664,6 +1063,7 @@ public function delete_distribution($distribution_id, $etag = null, $opt = null)
*
* Examples:
* example::cloudfront/get_distribution_config.phpt:
+ * example::cloudfront/get_distribution_config2.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/GetConfig.html
@@ -671,6 +1071,16 @@ public function delete_distribution($distribution_id, $etag = null, $opt = null)
*/
public function get_distribution_config($distribution_id, $opt = null)
{
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true)
+ {
+ $opt['action'] = 'streaming-distribution';
+ unset($opt['Streaming']);
+ }
+ else
+ {
+ $opt['action'] = 'distribution';
+ }
+
return $this->authenticate(HTTP_GET, '/' . $distribution_id . '/config', $opt, null, null);
}
@@ -678,6 +1088,8 @@ public function get_distribution_config($distribution_id, $opt = null)
* Method: set_distribution_config()
* Sets a new distribution config for a given distribution ID.
*
+ * Standard distributions are handled separately from streaming distributions. For streaming distributions, set the Streaming option to true.
+ *
* Access:
* public
*
@@ -688,6 +1100,7 @@ public function get_distribution_config($distribution_id, $opt = null)
* opt - _array_ (Required) Associative array of parameters which can have the following keys:
*
* Keys for the $opt parameter:
+ * Streaming - _boolean_ (Optional) Whether this should be for a streaming distribution or not. Defaults to false.
* 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:
@@ -695,6 +1108,7 @@ public function get_distribution_config($distribution_id, $opt = null)
*
* Examples:
* example::cloudfront/set_distribution_config.phpt:
+ * example::cloudfront/set_distribution_config3.phpt:
*
* See Also:
* AWS Method - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/PutConfig.html
@@ -702,6 +1116,66 @@ public function get_distribution_config($distribution_id, $opt = null)
*/
public function set_distribution_config($distribution_id, $xml, $etag, $opt = null)
{
+ if (isset($opt['Streaming']) && $opt['Streaming'] == (bool) true)
+ {
+ $opt['action'] = 'streaming-distribution';
+ unset($opt['Streaming']);
+ }
+ else
+ {
+ $opt['action'] = 'distribution';
+ }
+
return $this->authenticate(HTTP_PUT, '/' . $distribution_id . '/config', $opt, $xml, $etag);
}
+
+
+ /*%******************************************************************************************%*/
+ // URLS
+
+ /**
+ * Method: get_private_object_url()
+ * Generates a time-limited and/or query signed request for a private file with additional optional restrictions.
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * filename - _string_ (Required) The filename of the object. Query parameters can be included.
+ * conditions - _array_ (Required) Associative array of conditions to restrict access. Canned/custom policies are done for you depending on what you specify.
+ *
+ * Keys for the $conditions parameter:
+ * DateLessThan - _int_ (Required) Time in seconds until the URL expires.
+ * DateGreaterThan - _int_ (Optional) Time in seconds until the URL becomes valid.
+ * IpAddress - _string_ (Optional) IP address to restrict the access to.
+ * DateLessThanExact - _int_ (Optional) Exact Unix timestamp of expiry time.
+ * DateGreaterThanExact - _int_ (Optional) Exact Unix timestamp until URL becomes valid.
+ *
+ * Returns:
+ * _string_ The file URL with authentication parameters.
+ *
+ * Examples:
+ * example::cloudfront/get_private_object_url.phpt:
+ *
+ * See Also:
+ * Serving Private Content - http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/PrivateContent.html
+ */
+ public function get_private_object_url(https://github.com/$filename,%20$conditions)
+ {
+ // Add this to our request
+ $opt = array();
+ $opt['domain'] = $this->domain;
+ $opt['filename'] = $filename;
+ $opt['conditions'] = $conditions;
+ $opt['private_key'] = $this->private_key;
+
+ // Authenticate to S3
+ $data = $this->authenticate(HTTP_GET,null,$opt);
+
+ return $data['resource']
+ . ((strpos($opt['filename'],'?') === false) ? '?' : '&')
+ . ((isset($data['policy'])) ? 'Policy=' . $data['policy'] : 'Expires=' . $data['expires'])
+ . '&Signature=' . $data['signature']
+ . '&Key-Pair-Id=' . $this->key_pair_id;
+ }
}
diff --git a/cloudwatch.class.php b/services/cloudwatch.class.php
similarity index 99%
rename from cloudwatch.class.php
rename to services/cloudwatch.class.php
index a69c3b2..43eb2d5 100644
--- a/cloudwatch.class.php
+++ b/services/cloudwatch.class.php
@@ -7,7 +7,7 @@
* 2009.08.26
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
diff --git a/ec2.class.php b/services/ec2.class.php
similarity index 99%
rename from ec2.class.php
rename to services/ec2.class.php
index 1165e02..7030637 100755
--- a/ec2.class.php
+++ b/services/ec2.class.php
@@ -7,7 +7,7 @@
* 2010.01.10
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
diff --git a/pas.class.php b/services/pas.class.php
similarity index 99%
rename from pas.class.php
rename to services/pas.class.php
index 8ab4c5d..0a38da9 100755
--- a/pas.class.php
+++ b/services/pas.class.php
@@ -7,7 +7,7 @@
* 2009.09.04
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
@@ -308,8 +308,8 @@ public function pas_authenticate($action, $opt = null, $locale = null)
// Prepare the response.
$headers = $request->get_response_header();
- $headers['x-tarzan-requesturl'] = $request_url;
- $headers['x-tarzan-stringtosign'] = $stringToSign;
+ $headers['x-cloudfusion-requesturl'] = $request_url;
+ $headers['x-cloudfusion-stringtosign'] = $stringToSign;
$data = new $this->response_class($headers, new SimpleXMLElement($request->get_response_body()), $request->get_response_code());
// Return!
diff --git a/s3.class.php b/services/s3.class.php
old mode 100755
new mode 100644
similarity index 91%
rename from s3.class.php
rename to services/s3.class.php
index 2cc306a..779814d
--- a/s3.class.php
+++ b/services/s3.class.php
@@ -4,10 +4,10 @@
* Amazon Simple Storage Service (http://aws.amazon.com/s3)
*
* Version:
- * 2010.01.10
+ * 2010.03.26
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
@@ -31,7 +31,7 @@
* Constant: S3_LOCATION_US
* Specify the US location.
*/
-define('S3_LOCATION_US', 'us');
+define('S3_LOCATION_US', 'us-west-1');
/**
* Constant: S3_LOCATION_EU
@@ -240,6 +240,7 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
$bucket = strtolower($bucket);
$acl = null;
$body = null;
+ $inputFilename = null;
$contentType = 'application/x-www-form-urlencoded';
$delimiter = null;
$filename = null;
@@ -412,6 +413,9 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
foreach ($meta as $k => $v)
{
+ // Strip line breaks.
+ $v = str_replace(array("\r", "\n", '%0A'), '', $v);
+
$req->add_header('x-amz-meta-' . strtolower($k), $v);
$acl .= 'x-amz-meta-' . strtolower($k) . ':' . $v . "\n";
}
@@ -452,6 +456,15 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
$md5 = $this->util->hex_to_base64(md5($body));
$req->add_header('Content-MD5', $md5);
}
+ elseif (isset($inputFilename) && !empty($inputFilename) && $method === 'create_object')
+ {
+ $fileResourcePointer = fopen($inputFilename, 'r');
+ $req->set_curlopts(array(
+ CURLOPT_PUT => true,
+ CURLOPT_INFILE => $fileResourcePointer,
+ CURLOPT_INFILESIZE => filesize($inputFilename) // on 32-bit systems filesize cannot be greater than 2GB
+ ));
+ }
// Add any standard HTTP headers.
if ($headers)
@@ -471,6 +484,9 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
foreach ($meta as $k => $v)
{
+ // Strip line breaks.
+ $v = str_replace(array("\r", "\n", '%0A'), '', $v);
+
$req->add_header('x-amz-meta-' . strtolower($k), $v);
$hmeta .= 'x-amz-meta-' . strtolower($k) . ':' . $v . "\n";
}
@@ -489,7 +505,7 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
if ($qsa)
{
// Prepare the string to sign
- $stringToSign = "$verb\n$md5\n$contentType\n$since_epoch\n$acl$hmeta/$bucket$filename";
+ $stringToSign = "$verb\n\n\n$since_epoch\n$acl$hmeta/$bucket$filename";
}
else
{
@@ -500,15 +516,6 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
// Hash the AWS secret key and generate a signature for the request.
$signature = $this->util->hex_to_base64(hash_hmac('sha1', $stringToSign, $this->secret_key));
- // Pass the developer key and signature
- $req->add_header("Authorization", "AWS " . $this->key . ":" . $signature);
-
- // If we have a "true" value for returnCurlHandle, do that instead of completing the request.
- if ($returnCurlHandle)
- {
- return $req->prep_request();
- }
-
// Are we getting a Query String Auth?
if ($qsa)
{
@@ -521,15 +528,30 @@ public function authenticate($bucket, $opt = null, $location = null, $redirects
);
}
+ // Pass the developer key and signature
+ $req->add_header("Authorization", "AWS " . $this->key . ":" . $signature);
+
+ // If we have a "true" value for returnCurlHandle, do that instead of completing the request.
+ if ($returnCurlHandle)
+ {
+ return $req->prep_request();
+ }
+
// Send!
$req->send_request();
+ // Close file resource pointer if we were reading file
+ if (isset($fileResourcePointer))
+ {
+ fclose($fileResourcePointer);
+ }
+
// Prepare the response.
$headers = $req->get_response_header();
- $headers['x-tarzan-redirects'] = $redirects;
- $headers['x-tarzan-requesturl'] = $this->request_url;
- $headers['x-tarzan-stringtosign'] = $stringToSign;
- $headers['x-tarzan-requestheaders'] = $req->request_headers;
+ $headers['x-cloudfusion-redirects'] = $redirects;
+ $headers['x-cloudfusion-requesturl'] = $this->request_url;
+ $headers['x-cloudfusion-stringtosign'] = $stringToSign;
+ $headers['x-cloudfusion-requestheaders'] = $req->request_headers;
if (strpos($req->get_response_body(), 'US';
+ $body = '';
$contentType = 'application/xml';
break;
}
}
else
{
- $body = 'US';
+ $body = '';
$contentType = 'application/xml';
}
@@ -1090,7 +1112,8 @@ public function set_bucket_acl($bucket, $acl = S3_ACL_PRIVATE, $returnCurlHandle
*
* Keys for the $opt parameter:
* filename - _string_ (Required) The filename for the object.
- * body - _string_ (Required) The data to be stored in the object.
+ * body - _string_ (Required) The data to be stored in the object. Either this or inputFilename is required.
+ * inputFilename - _string_ (Optional) Upload this file instead of the body data. Either this or body is required.
* contentType - _string_ (Required) The type of content that is being sent in the body.
* acl - _string_ (Optional) One of the following options: , , , or . Defaults to .
* headers - _array_ (Optional) Standard HTTP headers to send along in the request.
@@ -1208,7 +1231,19 @@ public function head_object($bucket, $filename, $returnCurlHandle = null)
public function if_object_exists($bucket, $filename)
{
$header = $this->head_object($bucket, $filename);
- return $header->isOK();
+
+ if ($header->isOK())
+ {
+ return true;
+ }
+ elseif ($header->status === 404)
+ {
+ return false;
+ }
+ else
+ {
+ return null;
+ }
}
/**
@@ -1252,7 +1287,14 @@ public function delete_object($bucket, $filename, $returnCurlHandle = null)
*
* Parameters:
* bucket - _string_ (Required) The name of the bucket to be used.
- * pcre - _string_ (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against. Defaults to .
+ *
+ * Keys for the $opt parameter:
+ * prefix - _string_ (Optional) Restricts the response to only contain results that begin with the specified prefix.
+ * marker - _string_ (Optional) It restricts the response to only contain results that occur alphabetically after the value of marker.
+ * maxKeys - _string_ (Optional) Limits the number of results returned in response to your query. Will return no more than this number of results, but possibly less.
+ * delimiter - _string_ (Optional) Unicode string parameter. Keys that contain the same string between the prefix and the first occurrence of the delimiter will be rolled up into a single result element in the CommonPrefixes collection.
+ * pcre - _string_ (Optional) A Perl-Compatible Regular Expression (PCRE) to filter the names against. This is applied AFTER any native S3 filtering from 'prefix', 'marker', 'maxKeys', or 'delimiter'.
+ * 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:
* _boolean_ Determines the success of deleting all files.
@@ -1260,10 +1302,10 @@ public function delete_object($bucket, $filename, $returnCurlHandle = null)
* See Also:
* Related -
*/
- public function delete_all_objects($bucket, $pcre = S3_PCRE_ALL)
+ public function delete_all_objects($bucket, $opt)
{
// Collect all matches
- $list = $this->get_object_list($bucket, array('pcre' => $pcre));
+ $list = $this->get_object_list($bucket, $opt);
// As long as we have at least one match...
if (count($list) > 0)
@@ -1862,7 +1904,7 @@ public function store_remote_file($remote_file, $bucket, $filename, $opt = null)
// Was the request successful?
if ($object->isOK())
{
- $url = $object->header['x-tarzan-requesturl'];
+ $url = $object->header['x-cloudfusion-requesturl'];
// If we have a virtual host value, use that instead of Amazon's hostname. There are better ways of doing this, but it works for now.
if ($this->vhost)
@@ -1912,7 +1954,7 @@ public function change_content_type($bucket, $filename, $contentType, $returnCur
/**
* Method: get_object_url()
- * Gets the web-accessible URL for the file (assuming you've set the ACL settings to ).
+ * Gets the web-accessible URL for the file or generates a time-limited signed request for a private file.
*
* Access:
* public
@@ -2053,10 +2095,19 @@ public function generate_access_policy($canonical_id, $canonical_name, $users)
$grantee->addChild('URI', S3_USERS_LOGGING);
break;
- // Assume an Email Address
+ // Email Address or Canonical Id
default:
- $grantee->addAttribute('xsi:type', 'AmazonCustomerByEmail', 'http://www.w3.org/2001/XMLSchema-instance');
- $grantee->addChild('EmailAddress', $user['id']);
+ if (strpos($user['id'],'@'))
+ {
+ $grantee->addAttribute('xsi:type', 'AmazonCustomerByEmail', 'http://www.w3.org/2001/XMLSchema-instance');
+ $grantee->addChild('EmailAddress', $user['id']);
+ }
+ else
+ {
+ // Assume Canonical Id
+ $grantee->addAttribute('xsi:type', 'CanonicalUser', 'http://www.w3.org/2001/XMLSchema-instance');
+ $grantee->addChild('ID', $user['id']);
+ }
break;
}
@@ -2084,4 +2135,78 @@ public function get_canonical_user_id()
'display_name' => (string) $id->body->Owner->DisplayName
);
}
+
+ /**
+ * Method: authorize_upload()
+ * Authorizes a browser based upload.
+ *
+ * Access:
+ * public
+ *
+ * Parameters:
+ * conditions - _array_ (Required) Associative array of policy conditions. Conditions must match those sent from the form.
+ * expires - _int_ (Optional) Time in seconds until the policy expires. Defaults to 1 hour.
+ *
+ * Keys for the $opt parameter:
+ * bucket - _string_ (Required) Bucket to authorize the upload to.
+ * key - _string_ (Required) Either this, or a starts-with for key must be specified.
+ * acl - _string_ (Optional) Values: private, public-read, public-read-write, authenticated-read, bucket-owner-read, bucket-owner-full-control
+ * success_action_redirect - _string_ (Optional) URL to redirect to on successful upload. Alias is "redirect".
+ * Content-Type - _string_ (Optional) Content typpe of the file.
+ * Cache-Control - _string_ (Optional)
+ * Content-Disposition - _string_ (Optional)
+ * Content-Encoding - _string_ (Optional)
+ * Expires - _string_ (Optional)
+ * x-amz-meta-... - _string_ (Optional) User metadata.
+ * starts-with - _array_ (Optional) Array of associative arrays of any of the above keys and the prefix value to match. Ex. array(array('$key',$prefix),array('$Content-Type','')).
+ * success_action_status - _int_ (Optional) Status code to return if success_action_redirect is not specified.
+ * x-amz-security-token - _string_ (Optional) Amazon DevPay security token. Must contain product and user token seperated by a comma in the string.
+ * content-length-range - _array_ (Optional) Content range to be uploaded. Useful for setting the minimum and maximum file size. Ex. array(min,max).
+ *
+ * Returns:
+ * _array_ Base64 encoded policy and signature strings.
+ *
+ * See Also
+ * Browser-Based Uploads - http://docs.amazonwebservices.com/AmazonS3/latest/UsingHTTPPOST.html
+ */
+ public function authorize_upload($conditions, $expires = 3600)
+ {
+ if (isset($conditions['starts-with']))
+ {
+ foreach($conditions['starts-with'] as $prefix)
+ {
+ $conditions_array[] = array('starts-with', $prefix[0], $prefix[1]);
+ }
+ unset($conditions['starts-with']);
+ }
+
+ if (isset($conditions['content-length-range']))
+ {
+ $conditions_array[] = array('content-length-range', $conditions['content-length-range'][0], $conditions['content-length-range'][1]);
+ unset($conditions['content-length-range']);
+ }
+
+ foreach (array_keys($conditions) as $condition)
+ {
+ $conditions_array[] = array($condition=>$conditions[$condition]);
+ }
+
+ $policy = array(
+ 'expiration' => gmdate(DATE_FORMAT_ISO8601, time() + $expires),
+ 'conditions' => $conditions_array
+ );
+
+ $policyToSign = $this->util->json_encode($policy);
+
+ // Base64 encode the policy
+ $policy_encoded = base64_encode($policyToSign);
+
+ // Hash the AWS secret key and generate a signature for the request.
+ $signature = base64_encode(hash_hmac('sha1', $policy_encoded, $this->secret_key, true));
+
+ return array(
+ $policy_encoded,
+ $signature
+ );
+ }
}
diff --git a/sdb.class.php b/services/sdb.class.php
similarity index 99%
rename from sdb.class.php
rename to services/sdb.class.php
index 4e54e5f..78f295d 100644
--- a/sdb.class.php
+++ b/services/sdb.class.php
@@ -7,7 +7,7 @@
* 2009.08.23
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
diff --git a/sqs.class.php b/services/sqs.class.php
similarity index 99%
rename from sqs.class.php
rename to services/sqs.class.php
index 6cd6fde..95eb77a 100755
--- a/sqs.class.php
+++ b/services/sqs.class.php
@@ -7,7 +7,7 @@
* 2009.08.26
*
* Copyright:
- * 2006-2009 Foleeo, Inc., and contributors.
+ * 2006-2010 Ryan Parman, Foleeo, Inc., and contributors.
*
* License:
* Simplified BSD License - http://opensource.org/licenses/bsd-license.php
diff --git a/sqsqueue.class.php b/sqsqueue.class.php
deleted file mode 100644
index f3d0f82..0000000
--- a/sqsqueue.class.php
+++ /dev/null
@@ -1,340 +0,0 @@
- constant.
- * secret_key - _string_ (Optional) Your Amazon API Secret Key. If blank, it will look for the constant.
- *
- * Returns:
- * _boolean_ false if no valid values are set, otherwise true.
- *
- * Examples:
- * example::sqsqueue/5_send_message.phpt:
- * example::sqsqueue/7_receive_message.phpt:
- * example::sqsqueue/8_delete_message.phpt:
- */
- public function __construct($queue = null, $key = null, $secret_key = null)
- {
- $this->queue_name = $queue;
- return parent::__construct($key, $secret_key);
- }
-
-
- /*%******************************************************************************************%*/
- // QUEUES
-
- /**
- * Method: create_queue()
- * Identical to . The queue URL created from this method will replace the queue URL already being used with this class.
- *
- * New queue URL will NOT automatically apply when using MultiCurl for parallel requests.
- *
- * Access:
- * public
- *
- * Parameters:
- * queue_name - See .
- * returnCurlHandle - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/1_create_queue.phpt:
- * example::sqsqueue/1_create_queue3.phpt:
- */
- public function create_queue($queue_name, $returnCurlHandle = null)
- {
- $data = parent::create_queue($queue_name, $returnCurlHandle);
-
- if ($data instanceof ResponseCore)
- {
- $this->queue_name = (string) $data->body->CreateQueueResult->QueueUrl;
- }
-
- return $data;
- }
-
- /**
- * Method: delete_queue()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Parameters:
- * returnCurlHandle - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/z_delete_queue.phpt:
- * example::sqsqueue/z_delete_queue3.phpt:
- */
- public function delete_queue($returnCurlHandle = null)
- {
- if ($this->queue_name)
- {
- return parent::delete_queue($this->queue_name, $returnCurlHandle);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-
- /**
- * Method: get_queue_attributes()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Parameters:
- * 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 - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/4_get_queue_attributes.phpt:
- * example::sqsqueue/4_get_queue_attributes4.phpt:
- * example::sqsqueue/4_get_queue_attributes5.phpt:
- */
- public function get_queue_attributes($attributes = 'All', $returnCurlHandle = null)
- {
- if ($this->queue_name)
- {
- return parent::get_queue_attributes($this->queue_name, $attributes, $returnCurlHandle);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-
- /**
- * Method: set_queue_attributes()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Parameters:
- * opt - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/3_set_queue_attributes.phpt:
- */
- public function set_queue_attributes($opt = null)
- {
- if ($this->queue_name)
- {
- return parent::set_queue_attributes($this->queue_name, $opt);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-
-
- /*%******************************************************************************************%*/
- // MESSAGES
-
- /**
- * Method: send_message()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Parameters:
- * message - See .
- * returnCurlHandle - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/5_send_message.phpt:
- * example::sqsqueue/5_send_message3.phpt:
- */
- public function send_message($message, $returnCurlHandle = null)
- {
- if ($this->queue_name)
- {
- return parent::send_message($this->queue_name, $message, $returnCurlHandle);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-
- /**
- * Method: receive_message()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Parameters:
- * opt - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/7_receive_message.phpt:
- * example::sqsqueue/7_receive_message3.phpt:
- * example::sqsqueue/7_receive_message4.phpt:
- * example::sqsqueue/7_receive_message7.phpt:
- * example::sqsqueue/7_receive_message8.phpt:
- */
- public function receive_message($opt = null)
- {
- if ($this->queue_name)
- {
- return parent::receive_message($this->queue_name, $opt);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-
- /**
- * Method: delete_message()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Parameters:
- * receipt_handle - See .
- * returnCurlHandle - See .
- *
- * Returns:
- * object
- *
- * Examples:
- * example::sqsqueue/8_delete_message.phpt:
- */
- public function delete_message($receipt_handle, $returnCurlHandle = null)
- {
- if ($this->queue_name)
- {
- return parent::delete_message($this->queue_name, $receipt_handle, $returnCurlHandle);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-
- /**
- *
- */
- public function change_message_visibility()
- {
-
- }
-
-
- /*%******************************************************************************************%*/
- // ACCESS CONTROL METHODS
-
- // Inherit from parent class
- // public function generate_policy() {}
-
- public function add_permission() {}
-
- public function remove_permission() {}
-
-
- /*%******************************************************************************************%*/
- // HELPER/UTILITY METHODS
-
- /**
- * Method: get_queue_size()
- * Identical to , except that you don't need to pass in a queue URL.
- *
- * Access:
- * public
- *
- * Returns:
- * _integer_ The Approximate number of messages in the queue.
- *
- * Examples:
- * example::sqsqueue/6_get_queue_size.phpt:
- */
- public function get_queue_size()
- {
- if ($this->queue_name)
- {
- return parent::get_queue_size($this->queue_name);
- }
-
- throw new SQSQueue_Exception(SQSQUEUE_DEFAULT_ERROR);
- }
-}