diff --git a/3rdparty/aws-sdk/config-sample.inc.php b/3rdparty/aws-sdk/config-sample.inc.php deleted file mode 100755 index 93d2315b2f..0000000000 --- a/3rdparty/aws-sdk/config-sample.inc.php +++ /dev/null @@ -1,83 +0,0 @@ - array( - - // Amazon Web Services Key. Found in the AWS Security Credentials. You can also pass - // this value as the first parameter to a service constructor. - 'key' => 'development-key', - - // Amazon Web Services Secret Key. Found in the AWS Security Credentials. You can also - // pass this value as the second parameter to a service constructor. - 'secret' => 'development-secret', - - // This option allows you to configure a preferred storage type to use for caching by - // default. This can be changed later using the set_cache_config() method. - // - // Valid values are: `apc`, `xcache`, or a file system path such as `./cache` or - // `/tmp/cache/`. - 'default_cache_config' => '', - - // Determines which Cerificate Authority file to use. - // - // A value of boolean `false` will use the Certificate Authority file available on the - // system. A value of boolean `true` will use the Certificate Authority provided by the - // SDK. Passing a file system path to a Certificate Authority file (chmodded to `0755`) - // will use that. - // - // Leave this set to `false` if you're not sure. - 'certificate_authority' => false - ), - - // Specify a default credential set to use if there are more than one. - '@default' => 'development' -)); diff --git a/3rdparty/aws-sdk/lib/cachecore/LICENSE b/3rdparty/aws-sdk/lib/cachecore/LICENSE new file mode 100755 index 0000000000..49b38bd620 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + + * Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS +AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/3rdparty/aws-sdk/lib/cachecore/README b/3rdparty/aws-sdk/lib/cachecore/README new file mode 100755 index 0000000000..07e00267cb --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/README @@ -0,0 +1 @@ +A simple caching system for PHP5 that provides a single interface for a variety of storage types. diff --git a/3rdparty/aws-sdk/lib/cachecore/_sql/README b/3rdparty/aws-sdk/lib/cachecore/_sql/README new file mode 100755 index 0000000000..e25d53d120 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/_sql/README @@ -0,0 +1,5 @@ +The .sql files in this directory contain the code to create the tables for database caching. + +If you're not using database caching, you can safely ignore these. + +If you ARE using database caching, simply load the correct *.sql file into your database to set up the required tables. diff --git a/3rdparty/aws-sdk/lib/cachecore/_sql/mysql.sql b/3rdparty/aws-sdk/lib/cachecore/_sql/mysql.sql new file mode 100755 index 0000000000..2efee3a732 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/_sql/mysql.sql @@ -0,0 +1,7 @@ +CREATE TABLE `cache` ( + `id` char(40) NOT NULL default '', + `expires` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + `data` longtext, + PRIMARY KEY (`id`), + UNIQUE KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 \ No newline at end of file diff --git a/3rdparty/aws-sdk/lib/cachecore/_sql/pgsql.sql b/3rdparty/aws-sdk/lib/cachecore/_sql/pgsql.sql new file mode 100755 index 0000000000..f2bdd86a52 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/_sql/pgsql.sql @@ -0,0 +1,6 @@ +CREATE TABLE "cache" ( + expires timestamp without time zone NOT NULL, + id character(40) NOT NULL, + data text NOT NULL +) +WITH (OIDS=TRUE); \ No newline at end of file diff --git a/3rdparty/aws-sdk/lib/cachecore/_sql/sqlite3.sql b/3rdparty/aws-sdk/lib/cachecore/_sql/sqlite3.sql new file mode 100755 index 0000000000..590f45e4ff --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/_sql/sqlite3.sql @@ -0,0 +1,2 @@ +CREATE TABLE cache (id TEXT, expires NUMERIC, data BLOB); +CREATE UNIQUE INDEX idx ON cache(id ASC); \ No newline at end of file diff --git a/3rdparty/aws-sdk/lib/cachecore/cacheapc.class.php b/3rdparty/aws-sdk/lib/cachecore/cacheapc.class.php new file mode 100755 index 0000000000..59f5e88f39 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cacheapc.class.php @@ -0,0 +1,126 @@ +. Adheres + * to the ICacheCore interface. + * + * @version 2012.04.17 + * @copyright 2006-2012 Ryan Parman + * @copyright 2006-2010 Foleeo, Inc. + * @copyright 2012 Amazon.com, Inc. or its affiliates. + * @copyright 2008-2010 Contributors + * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License + * @link http://github.com/skyzyx/cachecore CacheCore + * @link http://getcloudfusion.com CloudFusion + * @link http://php.net/apc APC + */ +class CacheAPC extends CacheCore implements ICacheCore +{ + + /*%******************************************************************************************%*/ + // CONSTRUCTOR + + /** + * Constructs a new instance of this class. + * + * @param string $name (Required) A name to uniquely identify the cache object. + * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL. + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true. + * @return object Reference to the cache object. + */ + public function __construct($name, $location = null, $expires = 0, $gzip = true) + { + parent::__construct($name, null, $expires, $gzip); + $this->id = $this->name; + } + + /** + * Creates a new cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function create($data) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + return apc_add($this->id, $data, $this->expires); + } + + /** + * Reads a cache. + * + * @return mixed Either the content of the cache object, or boolean `false`. + */ + public function read() + { + if ($data = apc_fetch($this->id)) + { + $data = $this->gzip ? gzuncompress($data) : $data; + return unserialize($data); + } + + return false; + } + + /** + * Updates an existing cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function update($data) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + return apc_store($this->id, $data, $this->expires); + } + + /** + * Deletes a cache. + * + * @return boolean Whether the operation was successful. + */ + public function delete() + { + return apc_delete($this->id); + } + + /** + * Implemented here, but always returns `false`. APC manages its own expirations. + * + * @return boolean Whether the cache is expired or not. + */ + public function is_expired() + { + return false; + } + + /** + * Implemented here, but always returns `false`. APC manages its own expirations. + * + * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. + */ + public function timestamp() + { + return false; + } + + /** + * Implemented here, but always returns `false`. APC manages its own expirations. + * + * @return boolean Whether the operation was successful. + */ + public function reset() + { + return false; + } +} + + +/*%******************************************************************************************%*/ +// EXCEPTIONS + +class CacheAPC_Exception extends CacheCore_Exception {} diff --git a/3rdparty/aws-sdk/lib/cachecore/cachecore.class.php b/3rdparty/aws-sdk/lib/cachecore/cachecore.class.php new file mode 100755 index 0000000000..1670d31640 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachecore.class.php @@ -0,0 +1,160 @@ +name = $name; + $this->location = $location; + $this->expires = $expires; + $this->gzip = $gzip; + + return $this; + } + + /** + * Allows for chaining from the constructor. Requires PHP 5.3 or newer. + * + * @param string $name (Required) A name to uniquely identify the cache object. + * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL. + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true. + * @return object Reference to the cache object. + */ + public static function init($name, $location = null, $expires = 0, $gzip = true) + { + if (version_compare(PHP_VERSION, '5.3.0', '<')) + { + throw new Exception('PHP 5.3 or newer is required to use CacheCore::init().'); + } + + $self = get_called_class(); + return new $self($name, $location, $expires, $gzip); + } + + /** + * Set the number of seconds until a cache expires. + * + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @return $this + */ + public function expire_in($seconds) + { + $this->expires = $seconds; + return $this; + } + + /** + * Provides a simple, straightforward cache-logic mechanism. Useful for non-complex response caches. + * + * @param string|function $callback (Required) The name of the function to fire when we need to fetch new data to cache. + * @param array params (Optional) Parameters to pass into the callback function, as an array. + * @return array The cached data being requested. + */ + public function response_manager($callback, $params = null) + { + // Automatically handle $params values. + $params = is_array($params) ? $params : array($params); + + if ($data = $this->read()) + { + if ($this->is_expired()) + { + if ($data = call_user_func_array($callback, $params)) + { + $this->update($data); + } + else + { + $this->reset(); + $data = $this->read(); + } + } + } + else + { + if ($data = call_user_func_array($callback, $params)) + { + $this->create($data); + } + } + + return $data; + } +} + + +/*%******************************************************************************************%*/ +// CORE DEPENDENCIES + +// Include the ICacheCore interface. +if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'icachecore.interface.php')) +{ + include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'icachecore.interface.php'; +} + + +/*%******************************************************************************************%*/ +// EXCEPTIONS + +class CacheCore_Exception extends Exception {} diff --git a/3rdparty/aws-sdk/lib/cachecore/cachefile.class.php b/3rdparty/aws-sdk/lib/cachecore/cachefile.class.php new file mode 100755 index 0000000000..3df240151f --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachefile.class.php @@ -0,0 +1,189 @@ +. Adheres + * to the ICacheCore interface. + * + * @version 2012.04.17 + * @copyright 2006-2012 Ryan Parman + * @copyright 2006-2010 Foleeo, Inc. + * @copyright 2012 Amazon.com, Inc. or its affiliates. + * @copyright 2008-2010 Contributors + * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License + * @link http://github.com/skyzyx/cachecore CacheCore + * @link http://getcloudfusion.com CloudFusion + */ +class CacheFile extends CacheCore implements ICacheCore +{ + + /*%******************************************************************************************%*/ + // CONSTRUCTOR + + /** + * Constructs a new instance of this class. + * + * @param string $name (Required) A name to uniquely identify the cache object. + * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL. + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true. + * @return object Reference to the cache object. + */ + public function __construct($name, $location = null, $expires = 0, $gzip = true) + { + parent::__construct($name, $location, $expires, $gzip); + $this->id = $this->location . '/' . $this->name . '.cache'; + } + + /** + * Creates a new cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function create($data) + { + if (file_exists($this->id)) + { + return false; + } + elseif (realpath($this->location) && file_exists($this->location) && is_writeable($this->location)) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + return (bool) file_put_contents($this->id, $data); + } + elseif (realpath($this->location) && file_exists($this->location)) + { + throw new CacheFile_Exception('The file system location "' . $this->location . '" is not writable. Check the file system permissions for this directory.'); + } + else + { + throw new CacheFile_Exception('The file system location "' . $this->location . '" does not exist. Create the directory, or double-check any relative paths that may have been set.'); + } + + return false; + } + + /** + * Reads a cache. + * + * @return mixed Either the content of the cache object, or boolean `false`. + */ + public function read() + { + if (file_exists($this->id) && is_readable($this->id)) + { + $data = file_get_contents($this->id); + $data = $this->gzip ? gzuncompress($data) : $data; + $data = unserialize($data); + + if ($data === false) + { + /* + This should only happen when someone changes the gzip settings and there is + existing data or someone has been mucking about in the cache folder manually. + Delete the bad entry since the file cache doesn't clean up after itself and + then return false so fresh data will be retrieved. + */ + $this->delete(); + return false; + } + + return $data; + } + + return false; + } + + /** + * Updates an existing cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function update($data) + { + if (file_exists($this->id) && is_writeable($this->id)) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + return (bool) file_put_contents($this->id, $data); + } + else + { + throw new CacheFile_Exception('The file system location is not writeable. Check your file system permissions and ensure that the cache directory exists.'); + } + + return false; + } + + /** + * Deletes a cache. + * + * @return boolean Whether the operation was successful. + */ + public function delete() + { + if (file_exists($this->id)) + { + return unlink($this->id); + } + + return false; + } + + /** + * Checks whether the cache object is expired or not. + * + * @return boolean Whether the cache is expired or not. + */ + public function is_expired() + { + if ($this->timestamp() + $this->expires < time()) + { + return true; + } + + return false; + } + + /** + * Retrieves the timestamp of the cache. + * + * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. + */ + public function timestamp() + { + clearstatcache(); + + if (file_exists($this->id)) + { + $this->timestamp = filemtime($this->id); + return $this->timestamp; + } + + return false; + } + + /** + * Resets the freshness of the cache. + * + * @return boolean Whether the operation was successful. + */ + public function reset() + { + if (file_exists($this->id)) + { + return touch($this->id); + } + + return false; + } +} + + +/*%******************************************************************************************%*/ +// EXCEPTIONS + +class CacheFile_Exception extends CacheCore_Exception {} diff --git a/3rdparty/aws-sdk/lib/cachecore/cachemc.class.php b/3rdparty/aws-sdk/lib/cachecore/cachemc.class.php new file mode 100755 index 0000000000..5b0f8a9306 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachemc.class.php @@ -0,0 +1,183 @@ +. Adheres + * to the ICacheCore interface. + * + * @version 2012.04.17 + * @copyright 2006-2012 Ryan Parman + * @copyright 2006-2010 Foleeo, Inc. + * @copyright 2012 Amazon.com, Inc. or its affiliates. + * @copyright 2008-2010 Contributors + * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License + * @link http://github.com/skyzyx/cachecore CacheCore + * @link http://getcloudfusion.com CloudFusion + * @link http://php.net/memcache Memcache + * @link http://php.net/memcached Memcached + */ +class CacheMC extends CacheCore implements ICacheCore +{ + /** + * Holds the Memcache object. + */ + var $memcache = null; + + /** + * Whether the Memcached extension is being used (as opposed to Memcache). + */ + var $is_memcached = false; + + + /*%******************************************************************************************%*/ + // CONSTRUCTOR + + /** + * Constructs a new instance of this class. + * + * @param string $name (Required) A name to uniquely identify the cache object. + * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL. + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true. + * @return object Reference to the cache object. + */ + public function __construct($name, $location = null, $expires = 0, $gzip = true) + { + parent::__construct($name, null, $expires, $gzip); + $this->id = $this->name; + + // Prefer Memcached over Memcache. + if (class_exists('Memcached')) + { + $this->memcache = new Memcached(); + $this->is_memcached = true; + } + elseif (class_exists('Memcache')) + { + $this->memcache = new Memcache(); + } + else + { + return false; + } + + // Enable compression, if available + if ($this->gzip) + { + if ($this->is_memcached) + { + $this->memcache->setOption(Memcached::OPT_COMPRESSION, true); + } + else + { + $this->gzip = MEMCACHE_COMPRESSED; + } + } + + // Process Memcached servers. + if (isset($location) && sizeof($location) > 0) + { + foreach ($location as $loc) + { + if (isset($loc['port']) && !empty($loc['port'])) + { + $this->memcache->addServer($loc['host'], $loc['port']); + } + else + { + $this->memcache->addServer($loc['host'], 11211); + } + } + } + + return $this; + } + + /** + * Creates a new cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function create($data) + { + if ($this->is_memcached) + { + return $this->memcache->set($this->id, $data, $this->expires); + } + return $this->memcache->set($this->id, $data, $this->gzip, $this->expires); + } + + /** + * Reads a cache. + * + * @return mixed Either the content of the cache object, or boolean `false`. + */ + public function read() + { + if ($this->is_memcached) + { + return $this->memcache->get($this->id); + } + return $this->memcache->get($this->id, $this->gzip); + } + + /** + * Updates an existing cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function update($data) + { + if ($this->is_memcached) + { + return $this->memcache->replace($this->id, $data, $this->expires); + } + return $this->memcache->replace($this->id, $data, $this->gzip, $this->expires); + } + + /** + * Deletes a cache. + * + * @return boolean Whether the operation was successful. + */ + public function delete() + { + return $this->memcache->delete($this->id); + } + + /** + * Implemented here, but always returns `false`. Memcache manages its own expirations. + * + * @return boolean Whether the cache is expired or not. + */ + public function is_expired() + { + return false; + } + + /** + * Implemented here, but always returns `false`. Memcache manages its own expirations. + * + * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. + */ + public function timestamp() + { + return false; + } + + /** + * Implemented here, but always returns `false`. Memcache manages its own expirations. + * + * @return boolean Whether the operation was successful. + */ + public function reset() + { + return false; + } +} + + +/*%******************************************************************************************%*/ +// EXCEPTIONS + +class CacheMC_Exception extends CacheCore_Exception {} diff --git a/3rdparty/aws-sdk/lib/cachecore/cachepdo.class.php b/3rdparty/aws-sdk/lib/cachecore/cachepdo.class.php new file mode 100755 index 0000000000..5716021d8f --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachepdo.class.php @@ -0,0 +1,297 @@ +. Adheres + * to the ICacheCore interface. + * + * @version 2012.04.17 + * @copyright 2006-2012 Ryan Parman + * @copyright 2006-2010 Foleeo, Inc. + * @copyright 2012 Amazon.com, Inc. or its affiliates. + * @copyright 2008-2010 Contributors + * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License + * @link http://github.com/skyzyx/cachecore CacheCore + * @link http://getcloudfusion.com CloudFusion + * @link http://php.net/pdo PDO + */ +class CachePDO extends CacheCore implements ICacheCore +{ + /** + * Reference to the PDO connection object. + */ + var $pdo = null; + + /** + * Holds the parsed URL components. + */ + var $dsn = null; + + /** + * Holds the PDO-friendly version of the connection string. + */ + var $dsn_string = null; + + /** + * Holds the prepared statement for creating an entry. + */ + var $create = null; + + /** + * Holds the prepared statement for reading an entry. + */ + var $read = null; + + /** + * Holds the prepared statement for updating an entry. + */ + var $update = null; + + /** + * Holds the prepared statement for resetting the expiry of an entry. + */ + var $reset = null; + + /** + * Holds the prepared statement for deleting an entry. + */ + var $delete = null; + + /** + * Holds the response of the read so we only need to fetch it once instead of doing + * multiple queries. + */ + var $store_read = null; + + + /*%******************************************************************************************%*/ + // CONSTRUCTOR + + /** + * Constructs a new instance of this class. + * + * Tested with [MySQL 5.0.x](http://mysql.com), [PostgreSQL](http://postgresql.com), and + * [SQLite 3.x](http://sqlite.org). SQLite 2.x is assumed to work. No other PDO-supported databases have + * been tested (e.g. Oracle, Microsoft SQL Server, IBM DB2, ODBC, Sybase, Firebird). Feel free to send + * patches for additional database support. + * + * See for more information. + * + * @param string $name (Required) A name to uniquely identify the cache object. + * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL. + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true. + * @return object Reference to the cache object. + */ + public function __construct($name, $location = null, $expires = 0, $gzip = true) + { + // Make sure the name is no longer than 40 characters. + $name = sha1($name); + + // Call parent constructor and set id. + parent::__construct($name, $location, $expires, $gzip); + $this->id = $this->name; + $options = array(); + + // Check if the location contains :// (e.g. mysql://user:pass@hostname:port/table) + if (stripos($location, '://') === false) + { + // No? Just pass it through. + $this->dsn = parse_url($location); + $this->dsn_string = $location; + } + else + { + // Yes? Parse and set the DSN + $this->dsn = parse_url($location); + $this->dsn_string = $this->dsn['scheme'] . ':host=' . $this->dsn['host'] . ((isset($this->dsn['port'])) ? ';port=' . $this->dsn['port'] : '') . ';dbname=' . substr($this->dsn['path'], 1); + } + + // Make sure that user/pass are defined. + $user = isset($this->dsn['user']) ? $this->dsn['user'] : null; + $pass = isset($this->dsn['pass']) ? $this->dsn['pass'] : null; + + // Set persistence for databases that support it. + switch ($this->dsn['scheme']) + { + case 'mysql': // MySQL + case 'pgsql': // PostgreSQL + $options[PDO::ATTR_PERSISTENT] = true; + break; + } + + // Instantiate a new PDO object with a persistent connection. + $this->pdo = new PDO($this->dsn_string, $user, $pass, $options); + + // Define prepared statements for improved performance. + $this->create = $this->pdo->prepare("INSERT INTO cache (id, expires, data) VALUES (:id, :expires, :data)"); + $this->read = $this->pdo->prepare("SELECT id, expires, data FROM cache WHERE id = :id"); + $this->reset = $this->pdo->prepare("UPDATE cache SET expires = :expires WHERE id = :id"); + $this->delete = $this->pdo->prepare("DELETE FROM cache WHERE id = :id"); + } + + /** + * Creates a new cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function create($data) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + $this->create->bindParam(':id', $this->id); + $this->create->bindParam(':data', $data); + $this->create->bindParam(':expires', $this->generate_timestamp()); + + return (bool) $this->create->execute(); + } + + /** + * Reads a cache. + * + * @return mixed Either the content of the cache object, or boolean `false`. + */ + public function read() + { + if (!$this->store_read) + { + $this->read->bindParam(':id', $this->id); + $this->read->execute(); + $this->store_read = $this->read->fetch(PDO::FETCH_ASSOC); + } + + if ($this->store_read) + { + $data = $this->store_read['data']; + $data = $this->gzip ? gzuncompress($data) : $data; + + return unserialize($data); + } + + return false; + } + + /** + * Updates an existing cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function update($data) + { + $this->delete(); + return $this->create($data); + } + + /** + * Deletes a cache. + * + * @return boolean Whether the operation was successful. + */ + public function delete() + { + $this->delete->bindParam(':id', $this->id); + return $this->delete->execute(); + } + + /** + * Checks whether the cache object is expired or not. + * + * @return boolean Whether the cache is expired or not. + */ + public function is_expired() + { + if ($this->timestamp() + $this->expires < time()) + { + return true; + } + + return false; + } + + /** + * Retrieves the timestamp of the cache. + * + * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. + */ + public function timestamp() + { + if (!$this->store_read) + { + $this->read->bindParam(':id', $this->id); + $this->read->execute(); + $this->store_read = $this->read->fetch(PDO::FETCH_ASSOC); + } + + if ($this->store_read) + { + $value = $this->store_read['expires']; + + // If 'expires' isn't yet an integer, convert it into one. + if (!is_numeric($value)) + { + $value = strtotime($value); + } + + $this->timestamp = date('U', $value); + return $this->timestamp; + } + + return false; + } + + /** + * Resets the freshness of the cache. + * + * @return boolean Whether the operation was successful. + */ + public function reset() + { + $this->reset->bindParam(':id', $this->id); + $this->reset->bindParam(':expires', $this->generate_timestamp()); + return (bool) $this->reset->execute(); + } + + /** + * Returns a list of supported PDO database drivers. Identical to . + * + * @return array The list of supported database drivers. + * @link http://php.net/pdo.getavailabledrivers PHP Method + */ + public function get_drivers() + { + return PDO::getAvailableDrivers(); + } + + /** + * Returns a timestamp value apropriate to the current database type. + * + * @return mixed Timestamp for MySQL and PostgreSQL, integer value for SQLite. + */ + protected function generate_timestamp() + { + // Define 'expires' settings differently. + switch ($this->dsn['scheme']) + { + // These support timestamps. + case 'mysql': // MySQL + case 'pgsql': // PostgreSQL + $expires = date(DATE_FORMAT_MYSQL, time()); + break; + + // These support integers. + case 'sqlite': // SQLite 3 + case 'sqlite2': // SQLite 2 + $expires = time(); + break; + } + + return $expires; + } +} + + +/*%******************************************************************************************%*/ +// EXCEPTIONS + +class CachePDO_Exception extends CacheCore_Exception {} diff --git a/3rdparty/aws-sdk/lib/cachecore/cachexcache.class.php b/3rdparty/aws-sdk/lib/cachecore/cachexcache.class.php new file mode 100755 index 0000000000..a0f279aaea --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachexcache.class.php @@ -0,0 +1,129 @@ +. Adheres + * to the ICacheCore interface. + * + * @version 2012.04.17 + * @copyright 2006-2012 Ryan Parman + * @copyright 2006-2010 Foleeo, Inc. + * @copyright 2012 Amazon.com, Inc. or its affiliates. + * @copyright 2008-2010 Contributors + * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License + * @link http://github.com/skyzyx/cachecore CacheCore + * @link http://getcloudfusion.com CloudFusion + * @link http://xcache.lighttpd.net XCache + */ +class CacheXCache extends CacheCore implements ICacheCore +{ + + /*%******************************************************************************************%*/ + // CONSTRUCTOR + + /** + * Constructs a new instance of this class. + * + * @param string $name (Required) A name to uniquely identify the cache object. + * @param string $location (Optional) The location to store the cache object in. This may vary by cache method. The default value is NULL. + * @param integer $expires (Optional) The number of seconds until a cache object is considered stale. The default value is 0. + * @param boolean $gzip (Optional) Whether data should be gzipped before being stored. The default value is true. + * @return object Reference to the cache object. + */ + public function __construct($name, $location = null, $expires = 0, $gzip = true) + { + parent::__construct($name, null, $expires, $gzip); + $this->id = $this->name; + } + + /** + * Creates a new cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function create($data) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + return xcache_set($this->id, $data, $this->expires); + } + + /** + * Reads a cache. + * + * @return mixed Either the content of the cache object, or boolean `false`. + */ + public function read() + { + if ($data = xcache_get($this->id)) + { + $data = $this->gzip ? gzuncompress($data) : $data; + return unserialize($data); + } + + return false; + } + + /** + * Updates an existing cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function update($data) + { + $data = serialize($data); + $data = $this->gzip ? gzcompress($data) : $data; + + return xcache_set($this->id, $data, $this->expires); + } + + /** + * Deletes a cache. + * + * @return boolean Whether the operation was successful. + */ + public function delete() + { + return xcache_unset($this->id); + } + + /** + * Defined here, but always returns false. XCache manages it's own expirations. It's worth + * mentioning that if the server is configured for a long xcache.var_gc_interval then it IS + * possible for expired data to remain in the var cache, though it is not possible to access + * it. + * + * @return boolean Whether the cache is expired or not. + */ + public function is_expired() + { + return false; + } + + /** + * Implemented here, but always returns `false`. XCache manages its own expirations. + * + * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. + */ + public function timestamp() + { + return false; + } + + /** + * Implemented here, but always returns `false`. XCache manages its own expirations. + * + * @return boolean Whether the operation was successful. + */ + public function reset() + { + return false; + } +} + + +/*%******************************************************************************************%*/ +// EXCEPTIONS + +class CacheXCache_Exception extends CacheCore_Exception {} diff --git a/3rdparty/aws-sdk/lib/cachecore/icachecore.interface.php b/3rdparty/aws-sdk/lib/cachecore/icachecore.interface.php new file mode 100755 index 0000000000..8d49f5bf49 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/icachecore.interface.php @@ -0,0 +1,66 @@ + class. + * + * @version 2009.03.22 + * @copyright 2006-2010 Ryan Parman + * @copyright 2006-2010 Foleeo, Inc. + * @copyright 2008-2010 Contributors + * @license http://opensource.org/licenses/bsd-license.php Simplified BSD License + * @link http://github.com/skyzyx/cachecore CacheCore + * @link http://getcloudfusion.com CloudFusion + */ +interface ICacheCore +{ + /** + * Creates a new cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function create($data); + + /** + * Reads a cache. + * + * @return mixed Either the content of the cache object, or boolean `false`. + */ + public function read(); + + /** + * Updates an existing cache. + * + * @param mixed $data (Required) The data to cache. + * @return boolean Whether the operation was successful. + */ + public function update($data); + + /** + * Deletes a cache. + * + * @return boolean Whether the operation was successful. + */ + public function delete(); + + /** + * Checks whether the cache object is expired or not. + * + * @return boolean Whether the cache is expired or not. + */ + public function is_expired(); + + /** + * Retrieves the timestamp of the cache. + * + * @return mixed Either the Unix time stamp of the cache creation, or boolean `false`. + */ + public function timestamp(); + + /** + * Resets the freshness of the cache. + * + * @return boolean Whether the operation was successful. + */ + public function reset(); +} diff --git a/3rdparty/aws-sdk/sdk.class.php b/3rdparty/aws-sdk/sdk.class.php index 4e171b027c..8dcb7bf252 100755 --- a/3rdparty/aws-sdk/sdk.class.php +++ b/3rdparty/aws-sdk/sdk.class.php @@ -1387,48 +1387,49 @@ class CFLoader // Register the autoloader. spl_autoload_register(array('CFLoader', 'autoloader')); +// Don't look for any configuration files, the Amazon S3 storage backend handles configuration -/*%******************************************************************************************%*/ -// CONFIGURATION - -// Look for include file in the same directory (e.g. `./config.inc.php`). -if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php')) -{ - include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php'; -} -// Fallback to `~/.aws/sdk/config.inc.php` -else -{ - if (!isset($_ENV['HOME']) && isset($_SERVER['HOME'])) - { - $_ENV['HOME'] = $_SERVER['HOME']; - } - elseif (!isset($_ENV['HOME']) && !isset($_SERVER['HOME'])) - { - $_ENV['HOME'] = `cd ~ && pwd`; - if (!$_ENV['HOME']) - { - switch (strtolower(PHP_OS)) - { - case 'darwin': - $_ENV['HOME'] = '/Users/' . get_current_user(); - break; - - case 'windows': - case 'winnt': - case 'win32': - $_ENV['HOME'] = 'c:' . DIRECTORY_SEPARATOR . 'Documents and Settings' . DIRECTORY_SEPARATOR . get_current_user(); - break; - - default: - $_ENV['HOME'] = '/home/' . get_current_user(); - break; - } - } - } - - if (getenv('HOME') && file_exists(getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php')) - { - include_once getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php'; - } -} +// /*%******************************************************************************************%*/ +// // CONFIGURATION +// +// // Look for include file in the same directory (e.g. `./config.inc.php`). +// if (file_exists(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php')) +// { +// include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc.php'; +// } +// // Fallback to `~/.aws/sdk/config.inc.php` +// else +// { +// if (!isset($_ENV['HOME']) && isset($_SERVER['HOME'])) +// { +// $_ENV['HOME'] = $_SERVER['HOME']; +// } +// elseif (!isset($_ENV['HOME']) && !isset($_SERVER['HOME'])) +// { +// $_ENV['HOME'] = `cd ~ && pwd`; +// if (!$_ENV['HOME']) +// { +// switch (strtolower(PHP_OS)) +// { +// case 'darwin': +// $_ENV['HOME'] = '/Users/' . get_current_user(); +// break; +// +// case 'windows': +// case 'winnt': +// case 'win32': +// $_ENV['HOME'] = 'c:' . DIRECTORY_SEPARATOR . 'Documents and Settings' . DIRECTORY_SEPARATOR . get_current_user(); +// break; +// +// default: +// $_ENV['HOME'] = '/home/' . get_current_user(); +// break; +// } +// } +// } +// +// if (getenv('HOME') && file_exists(getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php')) +// { +// include_once getenv('HOME') . DIRECTORY_SEPARATOR . '.aws' . DIRECTORY_SEPARATOR . 'sdk' . DIRECTORY_SEPARATOR . 'config.inc.php'; +// } +// }