diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-06-11 10:59:19 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-06-11 10:59:19 +0200 |
commit | f4c459782ba4e045509c22a181f18e0c6fc54764 (patch) | |
tree | 63ae24121c15a56d3e39de14c9ea01ab702c9111 | |
parent | ece11629490407bac9489919171ed08b8452515d (diff) | |
parent | 1cb1980d6200a18c288d5db3d0dadebd65ae894b (diff) | |
download | nextcloud-server-f4c459782ba4e045509c22a181f18e0c6fc54764.tar.gz nextcloud-server-f4c459782ba4e045509c22a181f18e0c6fc54764.zip |
Merge branch 'master' into calendar_repeat
35 files changed, 1294 insertions, 157 deletions
diff --git a/3rdparty/aws-sdk/config-sample.inc.php b/3rdparty/aws-sdk/config-sample.inc.php deleted file mode 100755 index 93d2315b2ff..00000000000 --- a/3rdparty/aws-sdk/config-sample.inc.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php if (!class_exists('CFRuntime')) die('No direct access allowed.'); -/** - * Stores your AWS account information. Add your account information, and then rename this file - * to 'config.inc.php'. - * - * @version 2011.12.14 - * @license See the included NOTICE.md file for more information. - * @copyright See the included NOTICE.md file for more information. - * @link http://aws.amazon.com/php/ PHP Developer Center - * @link http://aws.amazon.com/security-credentials AWS Security Credentials - */ - - -/*################################################################################################### - - As of version 1.5, the AWS SDK for PHP uses the CFCredentials class to handle credentials. - This class has the advantage of being able to support multiple sets of credentials at a time, - including the ability for credential sets to inherit settings from other credential sets. - - Some example uses are noted at https://gist.github.com/1478912 - - Notes: - - * You can define one or more credential sets. - - * Credential sets can be named anything that PHP allows for an associative array key; - "production", "staging", etc., are just sample values. Feel free to rename them. - - * A credential set only has four required entries: key, secret, default_cache_config and - certificate_authority. Aside from these, you can add any additional bits of information - you'd like to keep easily accessible (e.g., multi-factor authentication device key, your - AWS Account ID, your canonical identifiers). - - * Additional credential sets can inherit the properties of another credential set using the - @inherit keyword. - - * If more than one credential set is provided, a default credential set must be specified - using the @default keyword. - - * If you only have one credential set, you can set it to the @default keyword. - - * View the documentation for the CFCredentials::set() method to view usage examples. - -###################################################################################################*/ - - -/** - * Create a list of credential sets that can be used with the SDK. - */ -CFCredentials::set(array( - - // Credentials for the development environment. - 'development' => 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 00000000000..49b38bd620a --- /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 00000000000..07e00267cbb --- /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 00000000000..e25d53d1208 --- /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 00000000000..2efee3a732f --- /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 00000000000..f2bdd86a528 --- /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 00000000000..590f45e4ff1 --- /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 00000000000..59f5e88f397 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cacheapc.class.php @@ -0,0 +1,126 @@ +<?php +/** + * Container for all APC-based cache methods. Inherits additional methods from <CacheCore>. 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 00000000000..1670d316408 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachecore.class.php @@ -0,0 +1,160 @@ +<?php +/** + * Container for all shared caching methods. This is not intended to be instantiated directly, but is + * extended by the cache-specific classes. + * + * @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 CacheCore +{ + /** + * A name to uniquely identify the cache object by. + */ + var $name; + + /** + * Where to store the cache. + */ + var $location; + + /** + * The number of seconds before a cache object is considered stale. + */ + var $expires; + + /** + * Used internally to uniquely identify the location + name of the cache object. + */ + var $id; + + /** + * Stores the time when the cache object was created. + */ + var $timestamp; + + /** + * Stores whether or not the content should be gzipped when stored + */ + var $gzip; + + + /*%******************************************************************************************%*/ + // 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) + { + if (!extension_loaded('zlib')) + { + $gzip = false; + } + + $this->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 00000000000..3df240151fb --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachefile.class.php @@ -0,0 +1,189 @@ +<?php +/** + * Container for all file-based cache methods. Inherits additional methods from <CacheCore>. 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 00000000000..5b0f8a93061 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachemc.class.php @@ -0,0 +1,183 @@ +<?php +/** + * Container for all Memcache-based cache methods. Inherits additional methods from <CacheCore>. 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 00000000000..5716021d8fc --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachepdo.class.php @@ -0,0 +1,297 @@ +<?php +/** + * Container for all PDO-based cache methods. Inherits additional methods from <CacheCore>. 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 <http://php.net/pdo> 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 <PDO::getAvailableDrivers()>. + * + * @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 00000000000..a0f279aaea3 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/cachexcache.class.php @@ -0,0 +1,129 @@ +<?php +/** + * Container for all XCache-based cache methods. Inherits additional methods from <CacheCore>. 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 00000000000..8d49f5bf492 --- /dev/null +++ b/3rdparty/aws-sdk/lib/cachecore/icachecore.interface.php @@ -0,0 +1,66 @@ +<?php +/** + * Defines the methods that all implementing classes MUST have. Covers CRUD (create, read, update, + * delete) methods, as well as others that are used in the base <CacheCore> 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 4e171b027cb..8dcb7bf252f 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')); - -/*%******************************************************************************************%*/ -// 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'; - } -} +// 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'; +// } +// } diff --git a/apps/bookmarks/addBm.php b/apps/bookmarks/addBm.php index 313489d22fb..866fa1e7b1e 100644 --- a/apps/bookmarks/addBm.php +++ b/apps/bookmarks/addBm.php @@ -28,6 +28,6 @@ OCP\User::checkLoggedIn(); OCP\App::checkAppEnabled('bookmarks'); require_once('bookmarksHelper.php'); -addBookmark($_GET['url'], '', 'Read-Later'); +addBookmark($_POST['url'], '', 'Read-Later'); include 'templates/addBm.php'; diff --git a/apps/bookmarks/ajax/addBookmark.php b/apps/bookmarks/ajax/addBookmark.php index 9241dc8ddf6..a2eb506f85e 100644 --- a/apps/bookmarks/ajax/addBookmark.php +++ b/apps/bookmarks/ajax/addBookmark.php @@ -31,5 +31,5 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); require_once(OC::$APPSROOT . '/apps/bookmarks/bookmarksHelper.php'); -$id = addBookmark($_GET['url'], $_GET['title'], $_GET['tags']); +$id = addBookmark($_POST['url'], $_POST['title'], $_POST['tags']); OCP\JSON::success(array('data' => $id));
\ No newline at end of file diff --git a/apps/bookmarks/ajax/delBookmark.php b/apps/bookmarks/ajax/delBookmark.php index 0b5689811ae..5a067701c9f 100644 --- a/apps/bookmarks/ajax/delBookmark.php +++ b/apps/bookmarks/ajax/delBookmark.php @@ -30,7 +30,7 @@ $RUNTIME_NOSETUPFS=true; OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('bookmarks'); -$id = $_GET['id']; +$id = $_POST['id']; if (!OC_Bookmarks_Bookmarks::deleteUrl($id)){ OC_JSON::error(); exit(); diff --git a/apps/bookmarks/ajax/editBookmark.php b/apps/bookmarks/ajax/editBookmark.php index db349af35c1..fcec2e1cedb 100644 --- a/apps/bookmarks/ajax/editBookmark.php +++ b/apps/bookmarks/ajax/editBookmark.php @@ -39,7 +39,7 @@ if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){ $_ut = "UNIX_TIMESTAMP()"; } -$bookmark_id = (int)$_GET["id"]; +$bookmark_id = (int)$_POST["id"]; $query = OCP\DB::prepare(" UPDATE *PREFIX*bookmarks @@ -48,8 +48,8 @@ $query = OCP\DB::prepare(" "); $params=array( - htmlspecialchars_decode($_GET["url"]), - htmlspecialchars_decode($_GET["title"]), + htmlspecialchars_decode($_POST["url"]), + htmlspecialchars_decode($_POST["title"]), ); $query->execute($params); @@ -67,7 +67,7 @@ $query = OCP\DB::prepare(" VALUES (?, ?) "); -$tags = explode(' ', urldecode($_GET["tags"])); +$tags = explode(' ', urldecode($_POST["tags"])); foreach ($tags as $tag) { if(empty($tag)) { //avoid saving blankspaces diff --git a/apps/bookmarks/ajax/recordClick.php b/apps/bookmarks/ajax/recordClick.php index 2bd91f232a4..1eee1718d13 100644 --- a/apps/bookmarks/ajax/recordClick.php +++ b/apps/bookmarks/ajax/recordClick.php @@ -37,7 +37,7 @@ $query = OCP\DB::prepare(" AND url LIKE ? "); -$params=array(OCP\USER::getUser(), htmlspecialchars_decode($_GET["url"])); +$params=array(OCP\USER::getUser(), htmlspecialchars_decode($_POST["url"])); $bookmarks = $query->execute($params); header( "HTTP/1.1 204 No Content" ); diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php index c919a5fc439..4de2475d067 100644 --- a/apps/bookmarks/ajax/updateList.php +++ b/apps/bookmarks/ajax/updateList.php @@ -33,11 +33,11 @@ OCP\JSON::checkAppEnabled('bookmarks'); //Filter for tag? -$filterTag = isset($_GET['tag']) ? htmlspecialchars_decode($_GET['tag']) : false; +$filterTag = isset($_POST['tag']) ? htmlspecialchars_decode($_POST['tag']) : false; -$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0; +$offset = isset($_POST['page']) ? intval($_POST['page']) * 10 : 0; -$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent'; +$sort = isset($_POST['sort']) ? ($_POST['sort']) : 'bookmarks_sorting_recent'; if($sort == 'bookmarks_sorting_clicks') { $sqlSortColumn = 'clickcount'; } else { diff --git a/apps/bookmarks/js/addBm.js b/apps/bookmarks/js/addBm.js index d64e55e8920..625ac8420a8 100644 --- a/apps/bookmarks/js/addBm.js +++ b/apps/bookmarks/js/addBm.js @@ -6,6 +6,7 @@ function addBookmark(event) { var url = $('#bookmark_add_url').val(); var tags = $('#bookmark_add_tags').val(); $.ajax({ + type: 'POST', url: 'ajax/addBookmark.php', data: 'url=' + encodeURI(url) + '&tags=' + encodeURI(tags), success: function(data){ diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js index a746cf437bf..7f3104e812f 100644 --- a/apps/bookmarks/js/bookmarks.js +++ b/apps/bookmarks/js/bookmarks.js @@ -20,6 +20,7 @@ function getBookmarks() { } $.ajax({ + type: 'POST', url: OC.filePath('bookmarks', 'ajax', 'updateList.php'), data: 'tag=' + encodeURIComponent($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting, success: function(bookmarks){ @@ -70,6 +71,7 @@ function addOrEditBookmark(event) { } if (id == 0) { $.ajax({ + type: 'POST', url: OC.filePath('bookmarks', 'ajax', 'addBookmark.php'), data: 'url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title) + '&tags=' + encodeURIComponent(tags), success: function(response){ @@ -82,6 +84,7 @@ function addOrEditBookmark(event) { } else { $.ajax({ + type: 'POST', url: OC.filePath('bookmarks', 'ajax', 'editBookmark.php'), data: 'id=' + id + '&url=' + encodeURIComponent(url) + '&title=' + encodeURIComponent(title) + '&tags=' + encodeURIComponent(tags), success: function(){ @@ -99,6 +102,7 @@ function addOrEditBookmark(event) { function delBookmark(event) { var record = $(this).parent().parent(); $.ajax({ + type: 'POST', url: OC.filePath('bookmarks', 'ajax', 'delBookmark.php'), data: 'id=' + record.data('id'), success: function(data){ @@ -177,6 +181,7 @@ function updateOnBottom() { function recordClick(event) { $.ajax({ + type: 'POST', url: OC.filePath('bookmarks', 'ajax', 'recordClick.php'), data: 'url=' + encodeURIComponent($(this).attr('href')), }); diff --git a/apps/bookmarks/js/bookmarksearch.js b/apps/bookmarks/js/bookmarksearch.js index e7a4fb18393..e8f5363c935 100644 --- a/apps/bookmarks/js/bookmarksearch.js +++ b/apps/bookmarks/js/bookmarksearch.js @@ -16,6 +16,7 @@ function recordClick(event) { var jsFileLocation = $('script[src*=bookmarksearch]').attr('src'); jsFileLocation = jsFileLocation.replace('js/bookmarksearch.js', ''); $.ajax({ + type: 'POST', url: jsFileLocation + 'ajax/recordClick.php', data: 'url=' + encodeURI($(this).attr('href')), }); diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php index a8ad695f620..20a9e4afc9c 100644 --- a/apps/contacts/lib/vcard.php +++ b/apps/contacts/lib/vcard.php @@ -373,6 +373,10 @@ class OC_Contacts_VCard{ public static function editFromDAVData($aid,$uri,$data){ $oldcard = self::findWhereDAVDataIs($aid,$uri); $card = OC_VObject::parse($data); + if(!$card) { + OCP\Util::writeLog('contacts','OC_Contacts_VCard::editFromDAVData. Unable to parse VCARD, uri: '.$uri,OCP\Util::ERROR); + return false; + } return self::edit($oldcard['id'], $card); } diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php index fee5be08004..c1ba1ccdc21 100644 --- a/apps/contacts/templates/part.contact.php +++ b/apps/contacts/templates/part.contact.php @@ -34,7 +34,7 @@ $id = isset($_['id']) ? $_['id'] : ''; <dd class="propertycontainer hidden" id="org_value" data-element="ORG"><input id="org" required="required" name="value[ORG]" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Organization'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd> <dt class="hidden" id="nickname_label" data-element="NICKNAME"><label for="nickname"><?php echo $l->t('Nickname'); ?></label></dt> <dd class="propertycontainer hidden" id="nickname_value" data-element="NICKNAME"><input id="nickname" required="required" name="value[NICKNAME]" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('Enter nickname'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd> - <dt class="hidden" id="url_label" data-element="URL"><label for="nickname"><?php echo $l->t('Web site'); ?></label></dt> + <dt class="hidden" id="url_label" data-element="URL"><label for="url"><?php echo $l->t('Web site'); ?></label></dt> <dd class="propertycontainer hidden" id="url_value" data-element="URL"><input id="url" required="required" name="value[URL]" type="text" class="contacts_property big" name="value" value="" placeholder="<?php echo $l->t('http://www.somesite.com'); ?>" /><a role="button" class="action globe" title="<?php echo $l->t('Go to web site'); ?>"><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd> <dt class="hidden" id="bday_label" data-element="BDAY"><label for="bday"><?php echo $l->t('Birthday'); ?></label></dt> <dd class="propertycontainer hidden" id="bday_value" data-element="BDAY"><input id="bday" required="required" name="value" type="text" class="contacts_property big" value="" placeholder="<?php echo $l->t('dd-mm-yyyy'); ?>" /><a role="button" class="action delete" title="<?php echo $l->t('Delete'); ?>"></a></dd> diff --git a/apps/external/ajax/setsites.php b/apps/external/ajax/setsites.php index c758a3508c5..772863974ae 100644 --- a/apps/external/ajax/setsites.php +++ b/apps/external/ajax/setsites.php @@ -12,7 +12,7 @@ OCP\User::checkAdminUser(); $sites = array(); for ($i = 0; $i < sizeof($_POST['site_name']); $i++) { if (!empty($_POST['site_name'][$i]) && !empty($_POST['site_url'][$i])) { - array_push($sites, array($_POST['site_name'][$i], $_POST['site_url'][$i])); + array_push($sites, array(strip_tags($_POST['site_name'][$i]), strip_tags($_POST['site_url'][$i]))); } } diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index a87319d33b2..56a61e9ab89 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -98,8 +98,8 @@ class OC_Mount_Config { $personal = array(); if (isset($mountPoints[self::MOUNT_TYPE_USER][$uid])) { foreach ($mountPoints[self::MOUNT_TYPE_USER][$uid] as $mountPoint => $mount) { - // Remove '/$user/files/' from mount point - $personal[substr($mountPoint, 13)] = array('class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options']); + // Remove '/uid/files/' from mount point + $personal[substr($mountPoint, strlen($uid) + 8)] = array('class' => $mount['class'], 'backend' => $backends[$mount['class']]['backend'], 'configuration' => $mount['options']); } } return $personal; @@ -123,8 +123,11 @@ class OC_Mount_Config { if ($applicable != OCP\User::getUser() || $class == 'OC_Filestorage_Local') { return false; } + $mountPoint = '/'.$applicable.'/files/'.ltrim($mountPoint, '/'); + } else { + $mountPoint = '/$user/files/'.ltrim($mountPoint, '/'); } - $mount = array($applicable => array('/$user/files/'.$mountPoint => array('class' => $class, 'options' => $classOptions))); + $mount = array($applicable => array($mountPoint => array('class' => $class, 'options' => $classOptions))); $mountPoints = self::readData($isPersonal); // Merge the new mount point into the current mount points if (isset($mountPoints[$mountType])) { diff --git a/apps/files_external/templates/settings.php b/apps/files_external/templates/settings.php index 9f65cfca965..af185c28030 100644 --- a/apps/files_external/templates/settings.php +++ b/apps/files_external/templates/settings.php @@ -16,7 +16,7 @@ <?php $_['mounts'] = array_merge($_['mounts'], array('' => array())); ?> <?php foreach ($_['mounts'] as $mountPoint => $mount): ?> <tr <?php if ($mountPoint == '') echo 'id="addMountPoint"'; ?>> - <td class="mountPoint"><input type="text" name="mountPoint" value="<?php echo $mountPoint; ?>" placeholder="<?php echo $l->t('Mount point'); ?>" /></td> + <td class="mountPoint"><input type="text" name="mountPoint" value="<?php echo htmlentities($mountPoint); ?>" placeholder="<?php echo $l->t('Mount point'); ?>" /></td> <?php if ($mountPoint == ''): ?> <td class="backend"> <select id="selectBackend" data-configurations='<?php echo json_encode($_['backends']); ?>'> @@ -35,13 +35,13 @@ <?php if (isset($_['backends'][$mount['class']]['configuration'][$parameter])): ?> <?php $placeholder = $_['backends'][$mount['class']]['configuration'][$parameter]; ?> <?php if (strpos($placeholder, '*') !== false): ?> - <input type="password" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo substr($placeholder, 1); ?>" /> + <input type="password" data-parameter="<?php echo $parameter; ?>" value="<?php echo htmlentities($value); ?>" placeholder="<?php echo substr($placeholder, 1); ?>" /> <?php elseif(strpos($placeholder, '!') !== false): ?> <label><input type="checkbox" data-parameter="<?php echo $parameter; ?>" <?php if ($value == 'true') echo ' checked="checked"'; ?> /><?php echo substr($placeholder, 1); ?></label> <?php elseif (strpos($placeholder, '&') !== false): ?> - <input type="text" class="optional" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo substr($placeholder, 1); ?>" /> + <input type="text" class="optional" data-parameter="<?php echo $parameter; ?>" value="<?php echo htmlentities($value); ?>" placeholder="<?php echo substr($placeholder, 1); ?>" /> <?php else: ?> - <input type="text" data-parameter="<?php echo $parameter; ?>" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /> + <input type="text" data-parameter="<?php echo $parameter; ?>" value="<?php echo htmlentities($value); ?>" placeholder="<?php echo $placeholder; ?>" /> <?php endif; ?> <?php endif; ?> <?php endforeach; ?> diff --git a/apps/gallery/lib/tiles.php b/apps/gallery/lib/tiles.php index e43c99bb76a..5837c752ef6 100644 --- a/apps/gallery/lib/tiles.php +++ b/apps/gallery/lib/tiles.php @@ -141,7 +141,7 @@ class TileStack extends TileBase { } public function get() { - $r = '<div class="title gallery_div">'.$this->stack_name.'</div>'; + $r = '<div class="title gallery_div">'.htmlentities($this->stack_name).'</div>'; for ($i = 0; $i < count($this->tiles_array); $i++) { $top = rand(-5, 5); $left = rand(-5, 5); @@ -168,7 +168,7 @@ class TileStack extends TileBase { } public function getOnClickAction() { - return 'javascript:openNewGal(\''.$this->stack_name.'\');'; + return 'javascript:openNewGal(\''.htmlentities($this->stack_name).'\');'; } private $tiles_array; diff --git a/apps/gallery/templates/index.php b/apps/gallery/templates/index.php index fd83490d60c..f9926045498 100644 --- a/apps/gallery/templates/index.php +++ b/apps/gallery/templates/index.php @@ -14,7 +14,7 @@ div.visible { opacity: 0.8;} </style> <script type="text/javascript"> -var root = "<?php echo $root; ?>"; +var root = "<?php echo htmlentities($root); ?>"; function explode(element) { $('div', element).each(function(index, elem) { diff --git a/apps/user_ldap/settings.php b/apps/user_ldap/settings.php index 9c0620578be..f1a474ff27d 100644 --- a/apps/user_ldap/settings.php +++ b/apps/user_ldap/settings.php @@ -47,7 +47,7 @@ if ($_POST) { // fill template $tmpl = new OCP\Template( 'user_ldap', 'settings'); foreach($params as $param){ - $value = OCP\Config::getAppValue('user_ldap', $param,''); + $value = htmlentities(OCP\Config::getAppValue('user_ldap', $param,'')); $tmpl->assign($param, $value); } diff --git a/apps/user_openid/settings.php b/apps/user_openid/settings.php index 921fa371dde..062322f6fe4 100644 --- a/apps/user_openid/settings.php +++ b/apps/user_openid/settings.php @@ -2,7 +2,7 @@ $tmpl = new OCP\Template( 'user_openid', 'settings'); $identity=OCP\Config::getUserValue(OCP\USER::getUser(),'user_openid','identity',''); -$tmpl->assign('identity',$identity); +$tmpl->assign('identity',htmlentities($identity)); OCP\Util::addscript('user_openid','settings'); diff --git a/lib/util.php b/lib/util.php index 53096f029a2..7c85db71f5f 100644 --- a/lib/util.php +++ b/lib/util.php @@ -70,6 +70,15 @@ class OC_Util { $quotaProxy=new OC_FileProxy_Quota(); OC_FileProxy::register($quotaProxy); self::$fsSetup=true; + // Load personal mount config + if (is_file($CONFIG_DATADIRECTORY_ROOT.'/'.$user.'/mount.php')) { + $mountConfig = include($CONFIG_DATADIRECTORY_ROOT.'/'.$user.'/mount.php'); + if (isset($mountConfig['user'][$user])) { + foreach ($mountConfig['user'][$user] as $mountPoint => $options) { + OC_Filesystem::mount($options['class'], $options['options'], $mountPoint); + } + } + } } } diff --git a/lib/vcategories.php b/lib/vcategories.php index ddcec1b6a4e..1e79b62f0d6 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -63,7 +63,7 @@ class OC_VCategories { * @returns array containing the categories as strings. */ public function categories() { - OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG); + //OC_Log::write('core','OC_VCategories::categories: '.print_r($this->categories, true), OC_Log::DEBUG); usort($this->categories, 'strnatcasecmp'); // usort to also renumber the keys return $this->categories; } @@ -169,7 +169,7 @@ class OC_VCategories { foreach($names as $name) { OC_Log::write('core','OC_VCategories::delete: '.$name, OC_Log::DEBUG); if($this->hasCategory($name)) { - OC_Log::write('core','OC_VCategories::delete: '.$name.' got it', OC_Log::DEBUG); + //OC_Log::write('core','OC_VCategories::delete: '.$name.' got it', OC_Log::DEBUG); unset($this->categories[$this->array_searchi($name, $this->categories)]); } } @@ -183,14 +183,14 @@ class OC_VCategories { //OC_Log::write('core','OC_VCategories::delete, before: '.$key.': '.print_r($categories, true), OC_Log::DEBUG); foreach($names as $name) { $idx = $this->array_searchi($name, $categories); - OC_Log::write('core','OC_VCategories::delete, loop: '.$name.', '.print_r($idx, true), OC_Log::DEBUG); + //OC_Log::write('core','OC_VCategories::delete, loop: '.$name.', '.print_r($idx, true), OC_Log::DEBUG); if($idx !== false) { OC_Log::write('core','OC_VCategories::delete, unsetting: '.$categories[$this->array_searchi($name, $categories)], OC_Log::DEBUG); unset($categories[$this->array_searchi($name, $categories)]); //unset($categories[$idx]); } } - OC_Log::write('core','OC_VCategories::delete, after: '.$key.': '.print_r($categories, true), OC_Log::DEBUG); + //OC_Log::write('core','OC_VCategories::delete, after: '.$key.': '.print_r($categories, true), OC_Log::DEBUG); $vobject->setString('CATEGORIES', implode(',', $categories)); $value[1] = $vobject->serialize(); $objects[$key] = $value; |