diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-02-20 13:52:53 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-02-20 13:52:53 +0100 |
commit | 31bab5584784f7f157b46be761b4344d25d11031 (patch) | |
tree | 044b531dac012e4694133f2c269456070c0302b2 /lib/private | |
parent | 8cf73ca42fd3e2d362a75e11a0f3ac1ae0ab3a34 (diff) | |
parent | 742f54b6d556797bbef2847e546861de0008a28a (diff) | |
download | nextcloud-server-31bab5584784f7f157b46be761b4344d25d11031.tar.gz nextcloud-server-31bab5584784f7f157b46be761b4344d25d11031.zip |
Merge branch 'master' into no-css-js-delivery-via-php
Diffstat (limited to 'lib/private')
55 files changed, 347 insertions, 71 deletions
diff --git a/lib/private/app.php b/lib/private/app.php index e60a8a4e0b1..47f983cce35 100644 --- a/lib/private/app.php +++ b/lib/private/app.php @@ -640,6 +640,8 @@ class OC_App{ /** * register an admin form to be shown + * @param string $app + * @param string $page */ public static function registerAdmin($app, $page) { self::$adminForms[]= $app.'/'.$page.'.php'; diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php index a32c1126c7b..cdaaebb87e5 100644 --- a/lib/private/appconfig.php +++ b/lib/private/appconfig.php @@ -69,6 +69,9 @@ class AppConfig implements \OCP\IAppConfig { return $this->cache[$app]; } + /** + * @param string $app + */ private function getAppValues($app) { $appCache = $this->getAppCache($app); if (array_search($app, $this->appsLoaded) === false) { @@ -184,7 +187,7 @@ class AppConfig implements \OCP\IAppConfig { * @brief Deletes a key * @param string $app app * @param string $key key - * @return bool + * @return boolean|null */ public function deleteKey($app, $key) { $where = array( @@ -200,7 +203,7 @@ class AppConfig implements \OCP\IAppConfig { /** * @brief Remove app from appconfig * @param string $app app - * @return bool + * @return boolean|null * * Removes all keys in appconfig belonging to the app. */ diff --git a/lib/private/appframework/app.php b/lib/private/appframework/app.php index b835188661a..3b13194862d 100644 --- a/lib/private/appframework/app.php +++ b/lib/private/appframework/app.php @@ -25,7 +25,6 @@ namespace OC\AppFramework; use OC\AppFramework\DependencyInjection\DIContainer; -use OCP\AppFramework\IAppContainer; /** diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php index b6ccf60db4b..4821ecaf67b 100644 --- a/lib/private/appframework/dependencyinjection/dicontainer.php +++ b/lib/private/appframework/dependencyinjection/dicontainer.php @@ -34,7 +34,6 @@ use OC\AppFramework\Utility\SimpleContainer; use OC\AppFramework\Utility\TimeFactory; use OCP\AppFramework\IApi; use OCP\AppFramework\IAppContainer; -use OCP\AppFramework\IMiddleWare; use OCP\AppFramework\Middleware; use OCP\IServerContainer; diff --git a/lib/private/appframework/http/redirectresponse.php b/lib/private/appframework/http/redirectresponse.php index 5c4e1c06dc3..05353349065 100644 --- a/lib/private/appframework/http/redirectresponse.php +++ b/lib/private/appframework/http/redirectresponse.php @@ -24,8 +24,8 @@ namespace OC\AppFramework\Http; -use OCP\AppFramework\Http\Response, - OCP\AppFramework\Http; +use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http; /** diff --git a/lib/private/appframework/middleware/security/securitymiddleware.php b/lib/private/appframework/middleware/security/securitymiddleware.php index c3143754823..bb02d565fa4 100644 --- a/lib/private/appframework/middleware/security/securitymiddleware.php +++ b/lib/private/appframework/middleware/security/securitymiddleware.php @@ -66,7 +66,7 @@ class SecurityMiddleware extends Middleware { * This runs all the security checks before a method call. The * security checks are determined by inspecting the controller method * annotations - * @param string/Controller $controller the controllername or string + * @param string $controller the controllername or string * @param string $methodName the name of the method * @throws SecurityException when a security check fails */ diff --git a/lib/private/archive.php b/lib/private/archive.php index a18f8d3ffbd..6f51066ddf8 100644 --- a/lib/private/archive.php +++ b/lib/private/archive.php @@ -88,7 +88,6 @@ abstract class OC_Archive{ abstract function extractFile($path, $dest); /** * extract the archive - * @param string $path * @param string $dest * @return bool */ diff --git a/lib/private/archive/tar.php b/lib/private/archive/tar.php index 5538e027ab4..cbdb565ba35 100644 --- a/lib/private/archive/tar.php +++ b/lib/private/archive/tar.php @@ -22,6 +22,9 @@ class OC_Archive_TAR extends OC_Archive{ private $tar=null; private $path; + /** + * @param string $source + */ function __construct($source) { $types=array(null, 'gz', 'bz'); $this->path=$source; @@ -122,6 +125,9 @@ class OC_Archive_TAR extends OC_Archive{ return true; } + /** + * @param string $file + */ private function getHeader($file) { if ( ! $this->cachedHeaders ) { $this->cachedHeaders = $this->tar->listContent(); diff --git a/lib/private/archive/zip.php b/lib/private/archive/zip.php index cd5479299a1..fa5630d7665 100644 --- a/lib/private/archive/zip.php +++ b/lib/private/archive/zip.php @@ -13,6 +13,9 @@ class OC_Archive_ZIP extends OC_Archive{ private $zip=null; private $path; + /** + * @param string $source + */ function __construct($source) { $this->path=$source; $this->zip=new ZipArchive(); @@ -125,7 +128,6 @@ class OC_Archive_ZIP extends OC_Archive{ } /** * extract the archive - * @param string $path * @param string $dest * @return bool */ diff --git a/lib/private/arrayparser.php b/lib/private/arrayparser.php index c4ad1264fbb..d353e486577 100644 --- a/lib/private/arrayparser.php +++ b/lib/private/arrayparser.php @@ -39,6 +39,9 @@ class ArrayParser { return $this->parse($string); } + /** + * @param string $string + */ function stripPHPTags($string) { $string = trim($string); if (substr($string, 0, 5) === '<?php') { diff --git a/lib/private/backgroundjob.php b/lib/private/backgroundjob.php index aa740a89532..afc3c270405 100644 --- a/lib/private/backgroundjob.php +++ b/lib/private/backgroundjob.php @@ -38,7 +38,7 @@ class OC_BackgroundJob{ /** * @brief sets the background jobs execution type * @param string $type execution type - * @return boolean|null + * @return false|null * * This method sets the execution type of the background jobs. Possible types * are "none", "ajax", "webcron", "cron" diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php index 2740d2bd856..26c90269349 100644 --- a/lib/private/backgroundjob/joblist.php +++ b/lib/private/backgroundjob/joblist.php @@ -31,7 +31,7 @@ class JobList implements IJobList { } /** - * @param Job|string $job + * @param \Test\BackgroundJob\TestJob $job * @param mixed $argument */ public function add($job, $argument = null) { diff --git a/lib/private/cache/usercache.php b/lib/private/cache/usercache.php index baa8820700b..486e08218a2 100644 --- a/lib/private/cache/usercache.php +++ b/lib/private/cache/usercache.php @@ -35,7 +35,7 @@ class UserCache implements \OCP\ICache { * Set a value in the user cache * * @param string $key - * @param mixed $value + * @param string $value * @param int $ttl Time To Live in seconds. Defaults to 60*60*24 * @return bool */ diff --git a/lib/private/config.php b/lib/private/config.php index 8399d0defbd..3649da84973 100644 --- a/lib/private/config.php +++ b/lib/private/config.php @@ -77,7 +77,7 @@ class Config { /** * @brief Gets a value from config.php * @param string $key key - * @param mixed $default = null default value + * @param string|null $default = null default value * @return string the value or $default * * This function gets the value from config.php. If it does not exist, @@ -94,7 +94,7 @@ class Config { /** * @brief Sets a value * @param string $key key - * @param mixed $value value + * @param string $value value * * This function sets the value and writes the config.php. * diff --git a/lib/private/connector/sabre/aborteduploaddetectionplugin.php b/lib/private/connector/sabre/aborteduploaddetectionplugin.php index 10cca647e8d..ad759d1d84a 100644 --- a/lib/private/connector/sabre/aborteduploaddetectionplugin.php +++ b/lib/private/connector/sabre/aborteduploaddetectionplugin.php @@ -47,7 +47,7 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl } /** - * @param $filePath + * @param string $filePath * @param Sabre_DAV_INode $node * @throws Sabre_DAV_Exception_BadRequest */ diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php index 5ef6365f657..ef6caaf22a7 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -58,6 +58,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D throw new \Sabre_DAV_Exception_ServiceUnavailable(); } + $fileName = basename($this->path); + if (!\OCP\Util::isValidFileName($fileName)) { + throw new \Sabre_DAV_Exception_BadRequest(); + } + // chunked handling if (isset($_SERVER['HTTP_OC_CHUNKED'])) { return $this->createFileChunked($data); @@ -142,15 +147,16 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D * @throws Sabre_DAV_Exception_Forbidden */ public function delete() { + $fs = $this->getFS(); if ($this->path === 'Shared') { throw new \Sabre_DAV_Exception_Forbidden(); } - if (!\OC\Files\Filesystem::isDeletable($this->path)) { + if (!$fs->isDeletable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } - \OC\Files\Filesystem::unlink($this->path); + $fs->unlink($this->path); // remove properties $this->removeProperties(); diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index 05d2d2291ec..5807c5c7f71 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -85,19 +85,24 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @return void */ public function setName($name) { + $fs = $this->getFS(); // rename is only allowed if the update privilege is granted - if (!\OC\Files\Filesystem::isUpdatable($this->path)) { + if (!$fs->isUpdatable($this->path)) { throw new \Sabre_DAV_Exception_Forbidden(); } list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path); list(, $newName) = Sabre_DAV_URLUtil::splitPath($name); + if (!\OCP\Util::isValidFileName($newName)) { + throw new \Sabre_DAV_Exception_BadRequest(); + } + $newPath = $parentPath . '/' . $newName; $oldPath = $this->path; - \OC\Files\Filesystem::rename($this->path, $newPath); + $fs->rename($this->path, $newPath); $this->path = $newPath; diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php index d1e179af2ec..d2fa425b22c 100644 --- a/lib/private/connector/sabre/objecttree.php +++ b/lib/private/connector/sabre/objecttree.php @@ -105,6 +105,11 @@ class ObjectTree extends \Sabre_DAV_ObjectTree { } } + $fileName = basename($destinationPath); + if (!\OCP\Util::isValidFileName($fileName)) { + throw new \Sabre_DAV_Exception_BadRequest(); + } + $renameOkay = $fs->rename($sourcePath, $destinationPath); if (!$renameOkay) { throw new \Sabre_DAV_Exception_Forbidden(''); diff --git a/lib/private/connector/sabre/quotaplugin.php b/lib/private/connector/sabre/quotaplugin.php index d6255325343..8099794f670 100644 --- a/lib/private/connector/sabre/quotaplugin.php +++ b/lib/private/connector/sabre/quotaplugin.php @@ -46,6 +46,7 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin { * This method is called before any HTTP method and validates there is enough free space to store the file * * @throws Sabre_DAV_Exception + * @param string $uri * @return bool */ public function checkQuota($uri, $data = null) { diff --git a/lib/private/db.php b/lib/private/db.php index 23e9593a579..cfdac766bff 100644 --- a/lib/private/db.php +++ b/lib/private/db.php @@ -252,7 +252,7 @@ class OC_DB { * an array with 'sql' and optionally 'limit' and 'offset' keys * .. or a simple sql query string * @param array $parameters - * @return result + * @return OC_DB_StatementWrapper * @throws DatabaseException */ static public function executeAudited( $stmt, array $parameters = null) { @@ -315,6 +315,7 @@ class OC_DB { * @brief Insert a row if a matching row doesn't exists. * @param string $table. The table to insert into in the form '*PREFIX*tableName' * @param array $input. An array of fieldname/value pairs + * @param string $table * @return boolean number of updated rows */ public static function insertIfNotExist($table, $input) { diff --git a/lib/private/db/mdb2schemawriter.php b/lib/private/db/mdb2schemawriter.php index 42d5bbab112..a2a62a81475 100644 --- a/lib/private/db/mdb2schemawriter.php +++ b/lib/private/db/mdb2schemawriter.php @@ -51,6 +51,9 @@ class OC_DB_MDB2SchemaWriter { } } + /** + * @param SimpleXMLElement $xml + */ private static function saveColumn($column, $xml) { $xml->addChild('name', $column->getName()); switch($column->getType()) { @@ -114,6 +117,9 @@ class OC_DB_MDB2SchemaWriter { } } + /** + * @param SimpleXMLElement $xml + */ private static function saveIndex($index, $xml) { $xml->addChild('name', $index->getName()); if ($index->isPrimary()) { diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php index 09b30af48b2..be7f4e14a11 100644 --- a/lib/private/filechunking.php +++ b/lib/private/filechunking.php @@ -41,7 +41,7 @@ class OC_FileChunking { * Stores the given $data under the given $key - the number of stored bytes is returned * * @param string $index - * @param $data + * @param resource $data * @return int */ public function store($index, $data) { diff --git a/lib/private/fileproxy.php b/lib/private/fileproxy.php index 62187e1ec74..88976c1b8e5 100644 --- a/lib/private/fileproxy.php +++ b/lib/private/fileproxy.php @@ -110,6 +110,7 @@ class OC_FileProxy{ /** * @param string $operation + * @param string|boolean $path * * @return string */ diff --git a/lib/private/files.php b/lib/private/files.php index 4a6b9d8ca0e..656d6f044ca 100644 --- a/lib/private/files.php +++ b/lib/private/files.php @@ -32,6 +32,9 @@ class OC_Files { return \OC\Files\Filesystem::getFileInfo($path, $includeMountPoints); } + /** + * @param string $path + */ static public function getDirectoryContent($path){ return \OC\Files\Filesystem::getDirectoryContent($path); } @@ -103,7 +106,12 @@ class OC_Files { if ($xsendfile) { $filename = OC_Helper::moveToNoClean($filename); } - $name = $files . '.zip'; + // downloading root ? + if ($files === '') { + $name = 'download.zip'; + } else { + $name = $files . '.zip'; + } set_time_limit($executionTime); } else { $zip = false; @@ -205,6 +213,8 @@ class OC_Files { $dirname=basename($dir); $zip->addEmptyDir($internalDir.$dirname); $internalDir.=$dirname.='/'; + // prevent absolute dirs + $internalDir = ltrim($internalDir, '/'); $files=OC_Files::getDirectoryContent($dir); foreach($files as $file) { $filename=$file['name']; diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php index e4114e572fe..7a45b9e9e96 100644 --- a/lib/private/files/cache/updater.php +++ b/lib/private/files/cache/updater.php @@ -8,8 +8,6 @@ namespace OC\Files\Cache; -use OCP\Util; - /** * listen to filesystem hooks and change the cache accordingly */ diff --git a/lib/private/files/cache/watcher.php b/lib/private/files/cache/watcher.php index 251ecbe7071..48aa6f853ce 100644 --- a/lib/private/files/cache/watcher.php +++ b/lib/private/files/cache/watcher.php @@ -12,6 +12,14 @@ namespace OC\Files\Cache; * check the storage backends for updates and change the cache accordingly */ class Watcher { + const CHECK_NEVER = 0; // never check the underlying filesystem for updates + const CHECK_ONCE = 1; // check the underlying filesystem for updates once every request for each file + const CHECK_ALWAYS = 2; // always check the underlying filesystem for updates + + protected $watchPolicy = self::CHECK_ONCE; + + protected $checkedPaths = array(); + /** * @var \OC\Files\Storage\Storage $storage */ @@ -23,7 +31,7 @@ class Watcher { protected $cache; /** - * @var Scanner $scanner; + * @var Scanner $scanner ; */ protected $scanner; @@ -37,26 +45,38 @@ class Watcher { } /** + * @param int $policy either \OC\Files\Cache\Watcher::UPDATE_NEVER, \OC\Files\Cache\Watcher::UPDATE_ONCE, \OC\Files\Cache\Watcher::UPDATE_ALWAYS + */ + public function setPolicy($policy) { + $this->watchPolicy = $policy; + } + + /** * check $path for updates * * @param string $path * @return boolean | array true if path was updated, otherwise the cached data is returned */ public function checkUpdate($path) { - $cachedEntry = $this->cache->get($path); - if ($this->storage->hasUpdated($path, $cachedEntry['storage_mtime'])) { - if ($this->storage->is_dir($path)) { - $this->scanner->scan($path, Scanner::SCAN_SHALLOW); - } else { - $this->scanner->scanFile($path); - } - if ($cachedEntry['mimetype'] === 'httpd/unix-directory') { - $this->cleanFolder($path); + if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false)) { + $cachedEntry = $this->cache->get($path); + $this->checkedPaths[] = $path; + if ($this->storage->hasUpdated($path, $cachedEntry['storage_mtime'])) { + if ($this->storage->is_dir($path)) { + $this->scanner->scan($path, Scanner::SCAN_SHALLOW); + } else { + $this->scanner->scanFile($path); + } + if ($cachedEntry['mimetype'] === 'httpd/unix-directory') { + $this->cleanFolder($path); + } + $this->cache->correctFolderSize($path); + return true; } - $this->cache->correctFolderSize($path); - return true; + return $cachedEntry; + } else { + return false; } - return $cachedEntry; } /** diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php index c77571cd2a7..2dbdd80a26b 100644 --- a/lib/private/files/fileinfo.php +++ b/lib/private/files/fileinfo.php @@ -29,6 +29,10 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess { */ private $internalPath; + /** + * @param string|boolean $path + * @param Storage\Storage $storage + */ public function __construct($path, $storage, $internalPath, $data) { $this->path = $path; $this->storage = $storage; diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php index ac9d1eac783..b6102f5c245 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.php @@ -668,6 +668,9 @@ class Filesystem { return self::$defaultInstance->search($query); } + /** + * @param string $query + */ static public function searchByMime($query) { return self::$defaultInstance->searchByMime($query); } diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php index 923f53821b2..d9e0ddc2d61 100644 --- a/lib/private/files/node/folder.php +++ b/lib/private/files/node/folder.php @@ -9,7 +9,6 @@ namespace OC\Files\Node; use OC\Files\Cache\Cache; -use OC\Files\Cache\Scanner; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php index 643a587dfc2..bc075911749 100644 --- a/lib/private/files/node/node.php +++ b/lib/private/files/node/node.php @@ -8,8 +8,6 @@ namespace OC\Files\Node; -use OC\Files\Cache\Cache; -use OC\Files\Cache\Scanner; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php index a22a2aaf4e9..70135285b0d 100644 --- a/lib/private/files/node/root.php +++ b/lib/private/files/node/root.php @@ -9,7 +9,6 @@ namespace OC\Files\Node; use OC\Files\Cache\Cache; -use OC\Files\Cache\Scanner; use OC\Files\Mount\Manager; use OC\Files\Mount\Mount; use OCP\Files\NotFoundException; diff --git a/lib/private/files/storage/loader.php b/lib/private/files/storage/loader.php index 734131261c8..966234cb04d 100644 --- a/lib/private/files/storage/loader.php +++ b/lib/private/files/storage/loader.php @@ -33,6 +33,9 @@ class Loader { return $this->wrap($mountPoint, new $class($arguments)); } + /** + * @param string|boolean $mountPoint + */ public function wrap($mountPoint, $storage) { foreach ($this->storageWrappers as $wrapper) { $storage = $wrapper($mountPoint, $storage); diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php index c8b22cfb39f..1bab3489a28 100644 --- a/lib/private/files/storage/mappedlocal.php +++ b/lib/private/files/storage/mappedlocal.php @@ -326,12 +326,18 @@ class MappedLocal extends \OC\Files\Storage\Common{ return $this->filemtime($path)>$time; } + /** + * @param string $path + */ private function buildPath($path, $create=true) { $path = $this->stripLeading($path); $fullPath = $this->datadir.$path; return $this->mapper->logicToPhysical($fullPath, $create); } + /** + * @param string $path + */ private function cleanMapper($path, $isLogicPath=true, $recursive=true) { $fullPath = $path; if ($isLogicPath) { diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php index 558bc60cf06..a802a8fcb8b 100644 --- a/lib/private/files/utils/scanner.php +++ b/lib/private/files/utils/scanner.php @@ -69,6 +69,9 @@ class Scanner extends PublicEmitter { }); } + /** + * @param string $dir + */ public function backgroundScan($dir) { $mounts = $this->getMounts($dir); foreach ($mounts as $mount) { diff --git a/lib/private/geo.php b/lib/private/geo.php index ed01ad0b616..7094d885af6 100644 --- a/lib/private/geo.php +++ b/lib/private/geo.php @@ -12,6 +12,10 @@ class OC_Geo{ * @param (string) $longitude - Longitude * @return (string) $timezone - closest timezone */ + /** + * @param integer $latitude + * @param integer $longitude + */ public static function timezone($latitude, $longitude) { $alltimezones = DateTimeZone::listIdentifiers(); $variances = array(); diff --git a/lib/private/group.php b/lib/private/group.php index 444788c97f1..4c187b538af 100644 --- a/lib/private/group.php +++ b/lib/private/group.php @@ -243,7 +243,7 @@ class OC_Group { /** * @brief get a list of all users in several groups - * @param array $gids + * @param string[] $gids * @param string $search * @param int $limit * @param int $offset diff --git a/lib/private/group/dummy.php b/lib/private/group/dummy.php index 9516fd52ff8..da26e1b910e 100644 --- a/lib/private/group/dummy.php +++ b/lib/private/group/dummy.php @@ -28,7 +28,7 @@ class OC_Group_Dummy extends OC_Group_Backend { private $groups=array(); /** * @brief Try to create a new group - * @param $gid The name of the group to create + * @param string $gid The name of the group to create * @returns true/false * * Trys to create a new group. If the group name already exists, false will diff --git a/lib/private/image.php b/lib/private/image.php index 42afa35ea56..42685ddab5c 100644 --- a/lib/private/image.php +++ b/lib/private/image.php @@ -34,7 +34,7 @@ class OC_Image { /** * @brief Get mime type for an image file. - * @param $filepath The path to a local image file. + * @param string|null $filepath The path to a local image file. * @returns string The mime type if the it could be determined, otherwise an empty string. */ static public function getMimeTypeForFile($filePath) { @@ -163,6 +163,7 @@ class OC_Image { /** * @brief Saves the image. * @returns bool + * @param string $filePath */ public function save($filePath=null) { @@ -704,7 +705,7 @@ class OC_Image { /** * @brief Resizes the image preserving ratio. - * @param integer $maxsize The maximum size of either the width or height. + * @param integer $maxSize The maximum size of either the width or height. * @returns bool */ public function resize($maxSize) { @@ -852,8 +853,8 @@ class OC_Image { /** * @brief Resizes the image to fit within a boundry while preserving ratio. - * @param $maxWidth - * @param $maxHeight + * @param integer $maxWidth + * @param integer $maxHeight * @returns bool */ public function fitIn($maxWidth, $maxHeight) { diff --git a/lib/private/installer.php b/lib/private/installer.php index 1b974c6e5a5..11633a4d4a1 100644 --- a/lib/private/installer.php +++ b/lib/private/installer.php @@ -154,7 +154,7 @@ class OC_Installer{ }else{ $version = trim($info['version']); } - + if($version<>trim($data['appdata']['version'])) { OC_Helper::rmdirr($extractDir); throw new \Exception($l->t("App can't be installed because the version in info.xml/version is not the same as the version reported from the app store")); @@ -236,7 +236,6 @@ class OC_Installer{ /** * @brief Update an application - * @param array $data with all information * * This function installs an app. All information needed are passed in the * associative array $data. @@ -270,7 +269,6 @@ class OC_Installer{ /** * @brief Check if an update for the app is available - * @param string $name name of the application * @return string|false false or the version number of the update * * The function will check if an update for a version is available @@ -316,7 +314,7 @@ class OC_Installer{ * @brief Removes an app * @param string $name name of the application to remove * @param $options array with options - * @return boolean + * @return boolean|null * * This function removes an app. $options is an associative array. The * following keys are optional:ja diff --git a/lib/private/l10n.php b/lib/private/l10n.php index 1d8152c5844..ad979a92870 100644 --- a/lib/private/l10n.php +++ b/lib/private/l10n.php @@ -99,6 +99,9 @@ class OC_L10N implements \OCP\IL10N { $this->lang = $lang; } + /** + * @param string $transFile + */ public function load($transFile) { $this->app = true; include $transFile; @@ -115,7 +118,7 @@ class OC_L10N implements \OCP\IL10N { return; } $app = OC_App::cleanAppId($this->app); - $lang = $this->lang; + $lang = str_replace(array('\0', '/', '\\', '..'), '', $this->lang); $this->app = true; // Find the right language if(is_null($lang) || $lang == '') { @@ -160,7 +163,7 @@ class OC_L10N implements \OCP\IL10N { } } - if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')) { + if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php') && OC_Helper::issubdirectory(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php', OC::$SERVERROOT.'/core/l10n/')) { // Include the file, save the data from $CONFIG include OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php'; if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)) { diff --git a/lib/private/legacy/appconfig.php b/lib/private/legacy/appconfig.php index 46a8068c3b4..b6c3542a673 100644 --- a/lib/private/legacy/appconfig.php +++ b/lib/private/legacy/appconfig.php @@ -118,6 +118,8 @@ class OC_Appconfig { * * @param app * @param key + * @param string|false $app + * @param string|false $key * @return array */ public static function getValues($app, $key) { diff --git a/lib/private/legacy/preferences.php b/lib/private/legacy/preferences.php index a663db7598b..fcde12796ca 100644 --- a/lib/private/legacy/preferences.php +++ b/lib/private/legacy/preferences.php @@ -41,7 +41,7 @@ class OC_Preferences{ /** * @brief Get all apps of a user * @param string $user user - * @return array with app ids + * @return integer[] with app ids * * This function returns a list of all apps of the user that have at least * one entry in the preferences table. diff --git a/lib/private/migrate.php b/lib/private/migrate.php index b930b719289..3fb3e334ea2 100644 --- a/lib/private/migrate.php +++ b/lib/private/migrate.php @@ -431,6 +431,7 @@ class OC_Migrate{ /** * @brief connects to migration.db, or creates if not found * @param $db optional path to migration.db, defaults to user data dir + * @param string $path * @return bool whether the operation was successful */ static private function connectDB( $path=null ) { @@ -460,7 +461,7 @@ class OC_Migrate{ /** * @brief creates the tables in migration.db from an apps database.xml - * @param $appid string id of the app + * @param string $appid string id of the app * @return bool whether the operation was successful */ static private function createAppTables( $appid ) { diff --git a/lib/private/migration/content.php b/lib/private/migration/content.php index e7b6543171a..43eba89b8d5 100644 --- a/lib/private/migration/content.php +++ b/lib/private/migration/content.php @@ -34,9 +34,9 @@ class OC_Migration_Content{ /** * @brief sets up the - * @param $zip ZipArchive object + * @param ZipArchive $zip ZipArchive object * @param $db a database object (required for exporttype user) - * @return bool + * @return boolean|null */ public function __construct( $zip, $db=null ) { @@ -74,7 +74,7 @@ class OC_Migration_Content{ /** * @brief processes the db query - * @param $query the query to process + * @param string $query the query to process * @return string of processed query */ private function processQuery( $query ) { @@ -130,7 +130,7 @@ class OC_Migration_Content{ /** * @brief saves a sql data set into migration.db - * @param $data a sql data set returned from self::prepare()->query() + * @param OC_DB_StatementWrapper $data a sql data set returned from self::prepare()->query() * @param $options array of copyRows options * @return void */ diff --git a/lib/private/migration/provider.php b/lib/private/migration/provider.php index 234ab3351f3..2829a97a776 100644 --- a/lib/private/migration/provider.php +++ b/lib/private/migration/provider.php @@ -30,7 +30,7 @@ abstract class OC_Migration_Provider{ /** * @brief sets the OC_Migration_Content object to $this->content - * @param $content a OC_Migration_Content object + * @param OC_Migration_Content $content a OC_Migration_Content object */ public function setData( $uid, $content, $info=null ) { $this->content = $content; diff --git a/lib/private/ocs.php b/lib/private/ocs.php index 2305b3eccfe..bbe965ce561 100644 --- a/lib/private/ocs.php +++ b/lib/private/ocs.php @@ -23,9 +23,6 @@ * */ -use Symfony\Component\Routing\Exception\ResourceNotFoundException; -use Symfony\Component\Routing\Exception\MethodNotAllowedException; - /** * Class to handle open collaboration services API requests * @@ -38,7 +35,7 @@ class OC_OCS { * @param string $method HTTP method to read the key from * @param string $key Parameter to read * @param string $type Variable type to format data - * @param mixed $default Default value to return if the key is not found + * @param string $default Default value to return if the key is not found * @return string Data or if the key is not found and no default is set it will exit with a 400 Bad request */ public static function readData($method, $key, $type = 'raw', $default = null) { diff --git a/lib/private/preferences.php b/lib/private/preferences.php index 7ebbf7aa970..d45e6e77089 100644 --- a/lib/private/preferences.php +++ b/lib/private/preferences.php @@ -111,7 +111,7 @@ class Preferences { /** * @brief Get all apps of an user * @param string $user user - * @return array with app ids + * @return integer[] with app ids * * This function returns a list of all apps of the user that have at least * one entry in the preferences table. diff --git a/lib/private/request.php b/lib/private/request.php index a7e7bd0ea1d..0fd20b3cc1f 100755 --- a/lib/private/request.php +++ b/lib/private/request.php @@ -192,7 +192,7 @@ class OC_Request { /** * @brief Check if the requestor understands gzip - * @return boolean true for gzip encoding supported + * @return false|string true for gzip encoding supported */ static public function acceptGZip() { if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php new file mode 100644 index 00000000000..360376294cc --- /dev/null +++ b/lib/private/share/mailnotifications.php @@ -0,0 +1,160 @@ +<?php +/** +* ownCloud +* +* @author Bjoern Schiessle +* @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com> +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +* License as published by the Free Software Foundation; either +* version 3 of the License, or any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU AFFERO GENERAL PUBLIC LICENSE for more details. +* +* You should have received a copy of the GNU Affero General Public +* License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + +namespace OC\Share; + +class MailNotifications { + + private $senderId; // sender userId + private $from; // sender email address + private $senderDisplayName; + private $l; + + /** + * + * @param string $recipient user id + * @param string $sender user id (if nothing is set we use the currently logged-in user) + */ + public function __construct($sender = null) { + $this->l = \OC_L10N::get('core'); + + $this->senderId = $sender; + + $this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply'); + if ($this->senderId) { + $this->from = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from); + $this->senderDisplayName = \OCP\User::getDisplayName($this->senderId); + } else { + $this->senderDisplayName = \OCP\User::getDisplayName(); + } + } + + /** + * @brief inform users if a file was shared with them + * + * @param array $recipientList list of recipients + * @param type $itemSource shared item source + * @param type $itemType shared item type + * @return array list of user to whom the mail send operation failed + */ + public function sendInternalShareMail($recipientList, $itemSource, $itemType) { + + $noMail = array(); + + foreach ($recipientList as $recipient) { + $recipientDisplayName = \OCP\User::getDisplayName($recipient); + $to = \OC_Preferences::getValue($recipient, 'settings', 'email', ''); + + if ($to === '') { + $noMail[] = $recipientDisplayName; + continue; + } + + $items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient); + $filename = trim($items[0]['file_target'], '/'); + $subject = (string) $this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename)); + $expiration = null; + if (isset($items[0]['expiration'])) { + try { + $date = new DateTime($items[0]['expiration']); + $expiration = $date->getTimestamp(); + } catch (\Exception $e) { + \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR); + } + } + + if ($itemType === 'folder') { + $foldername = "/Shared/" . $filename; + } else { + // if it is a file we can just link to the Shared folder, + // that's the place where the user will find the file + $foldername = "/Shared"; + } + + $link = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername)); + + list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration); + + // send it out now + try { + \OCP\Util::sendMail($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail); + } catch (\Exception $e) { + \OCP\Util::writeLog('sharing', "Can't send mail to inform the user abaut an internal share: " . $e->getMessage() , \OCP\Util::ERROR); + $noMail[] = $recipientDisplayName; + } + } + + return $noMail; + + } + + /** + * @brief inform recipient about public link share + * + * @param string recipient recipient email address + * @param string $filename the shared file + * @param string $link the public link + * @param int $expiration expiration date (timestamp) + * @return mixed $result true or error message + */ + public function sendLinkShareMail($recipient, $filename, $link, $expiration) { + $subject = (string)$this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename)); + list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration); + try { + \OCP\Util::sendMail($recipient, $recipient, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail); + } catch (\Exception $e) { + \OCP\Util::writeLog('sharing', "Can't send mail with public link: " . $e->getMessage(), \OCP\Util::ERROR); + return $e->getMessage(); + } + + return true; + } + + /** + * @brief create mail body for plain text and html mail + * + * @param string $filename the shared file + * @param string $link link to the shared file + * @param int $expiration expiration date (timestamp) + * @return array with the html mail body and the plain text mail body + */ + private function createMailBody($filename, $link, $expiration) { + + $formatedDate = $expiration ? $this->l->l('date', $expiration) : null; + + $html = new \OC_Template("core", "mail", ""); + $html->assign ('link', $link); + $html->assign ('user_displayname', $this->senderDisplayName); + $html->assign ('filename', $filename); + $html->assign('expiration', $formatedDate); + $htmlMail = $html->fetchPage(); + + $alttext = new \OC_Template("core", "altmail", ""); + $alttext->assign ('link', $link); + $alttext->assign ('user_displayname', $this->senderDisplayName); + $alttext->assign ('filename', $filename); + $alttext->assign('expiration', $formatedDate); + $alttextMail = $alttext->fetchPage(); + + return array($htmlMail, $alttextMail); + } + +} diff --git a/lib/private/share/searchresultsorter.php b/lib/private/share/searchresultsorter.php index fbf77179097..76abbf30846 100644 --- a/lib/private/share/searchresultsorter.php +++ b/lib/private/share/searchresultsorter.php @@ -15,8 +15,8 @@ class SearchResultSorter { private $log; /** - * @param $search the search term as was given by the user - * @param $key the array key containing the value that should be compared + * @param string $search the search term as was given by the user + * @param string $key the array key containing the value that should be compared * against * @param $encoding optional, encoding to use, defaults to UTF-8 * @param $log optional, an \OC\Log instance diff --git a/lib/private/template/base.php b/lib/private/template/base.php index e698d855a91..232a29939cc 100644 --- a/lib/private/template/base.php +++ b/lib/private/template/base.php @@ -30,6 +30,8 @@ class Base { /** * @param string $serverroot * @param string|false $app_dir + * @param string $theme + * @param string $app */ protected function getAppTemplateDirs($theme, $app, $serverroot, $app_dir) { // Check if the app is in the app folder or in the root @@ -47,6 +49,7 @@ class Base { /** * @param string $serverroot + * @param string $theme */ protected function getCoreTemplateDirs($theme, $serverroot) { return array( @@ -119,6 +122,7 @@ class Base { /** * @brief doing the actual work + * @param string $file * @return string content * * Includes the template file, fetches its output diff --git a/lib/private/template/templatefilelocator.php b/lib/private/template/templatefilelocator.php index 05cd752cd4f..4676fceb37d 100644 --- a/lib/private/template/templatefilelocator.php +++ b/lib/private/template/templatefilelocator.php @@ -15,6 +15,7 @@ class TemplateFileLocator { /** * @param string[] $dirs + * @param string $form_factor */ public function __construct( $form_factor, $dirs ) { $this->form_factor = $form_factor; diff --git a/lib/private/user.php b/lib/private/user.php index a8e7967783e..86a01f96258 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -516,6 +516,8 @@ class OC_User { * @returns array with all uids * * Get a list of all users. + * @param integer $limit + * @param integer $offset */ public static function getUsers($search = '', $limit = null, $offset = null) { $users = self::getManager()->search($search, $limit, $offset); diff --git a/lib/private/user/database.php b/lib/private/user/database.php index 094a8f2e2a4..15e6643dfb3 100644 --- a/lib/private/user/database.php +++ b/lib/private/user/database.php @@ -256,7 +256,7 @@ class OC_User_Database extends OC_User_Backend { /** * counts the users in the database * - * @return int | bool + * @return false|string | bool */ public function countUsers() { $query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`'); diff --git a/lib/private/util.php b/lib/private/util.php index af39d983f67..b7856436527 100755 --- a/lib/private/util.php +++ b/lib/private/util.php @@ -218,7 +218,7 @@ class OC_Util { * @brief add a javascript file * * @param string $application - * @param mixed $file filename + * @param string|null $file filename * @return void */ public static function addScript( $application, $file = null ) { @@ -237,7 +237,7 @@ class OC_Util { * @brief add a css file * * @param string $application - * @param mixed $file filename + * @param string|null $file filename * @return void */ public static function addStyle( $application, $file = null ) { @@ -570,6 +570,7 @@ class OC_Util { /** * @brief Check if the app is enabled, redirects to home if not + * @param string $app * @return void */ public static function checkAppEnabled($app) { @@ -1154,4 +1155,25 @@ class OC_Util { } return $version; } + + /** + * Returns whether the given file name is valid + * @param $file string file name to check + * @return bool true if the file name is valid, false otherwise + */ + public static function isValidFileName($file) { + $trimmed = trim($file); + if ($trimmed === '') { + return false; + } + if ($trimmed === '.' || $trimmed === '..') { + return false; + } + foreach (str_split($trimmed) as $char) { + if (strpos(\OCP\FILENAME_INVALID_CHARS, $char) !== false) { + return false; + } + } + return true; + } } |