summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-16 15:36:35 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-16 15:36:35 +0200
commit8c2b0b13941b090140ad5634df6602a180afbc03 (patch)
tree47b3ee8572c67c9975a21f0c79f9cdd3b105f22a /lib
parent8e97752bf76aa3b7fb15d734259a9dcd0d82cc73 (diff)
parentdb31541fe13510ca4d1b752d7ac5a08ea8e89310 (diff)
downloadnextcloud-server-8c2b0b13941b090140ad5634df6602a180afbc03.tar.gz
nextcloud-server-8c2b0b13941b090140ad5634df6602a180afbc03.zip
Merge branch 'master' into activities-api
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php10
-rw-r--r--lib/l10n/pt_PT.php7
-rw-r--r--lib/l10n/sv.php3
-rw-r--r--lib/l10n/tr.php3
-rw-r--r--lib/private/app.php33
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php5
-rw-r--r--lib/private/avatar.php4
-rw-r--r--lib/private/cache/file.php18
-rw-r--r--lib/private/connector/sabre/auth.php6
-rw-r--r--lib/private/connector/sabre/directory.php2
-rw-r--r--lib/private/connector/sabre/exception/entitytoolarge.php22
-rw-r--r--lib/private/connector/sabre/exception/unsupportedmediatype.php22
-rw-r--r--lib/private/connector/sabre/file.php67
-rw-r--r--lib/private/connector/sabre/node.php6
-rw-r--r--lib/private/filechunking.php23
-rw-r--r--lib/private/files/storage/storage.php279
-rw-r--r--lib/private/files/view.php15
-rw-r--r--lib/private/group.php2
-rw-r--r--lib/private/helper.php4
-rw-r--r--lib/private/log/owncloud.php6
-rw-r--r--lib/private/session/session.php35
-rw-r--r--lib/private/user.php2
-rw-r--r--lib/public/files/entitytoolargeexception.php11
-rw-r--r--lib/public/files/invalidcontentexception.php11
-rw-r--r--lib/public/files/invalidpathexception.php11
-rw-r--r--lib/public/share.php8
26 files changed, 253 insertions, 362 deletions
diff --git a/lib/base.php b/lib/base.php
index b0b2dca502f..9068fe76981 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -304,9 +304,8 @@ class OC {
self::$session = new \OC\Session\Internal(OC_Util::getInstanceId());
// if session cant be started break with http 500 error
} catch (Exception $e) {
- OC_Log::write('core', 'Session could not be initialized',
+ OC_Log::write('core', 'Session could not be initialized. Exception message: '.$e->getMessage(),
OC_Log::ERROR);
-
header('HTTP/1.1 500 Internal Server Error');
OC_Util::addStyle("styles");
$error = 'Session could not be initialized. Please contact your ';
@@ -760,6 +759,13 @@ class OC {
// logon via web form
elseif (OC::tryFormLogin()) {
$error[] = 'invalidpassword';
+ if ( OC_Config::getValue('log_authfailip', false) ) {
+ OC_Log::write('core', 'Login failed: user \''.$_POST["user"].'\' , wrong password, IP:'.$_SERVER['REMOTE_ADDR'],
+ OC_Log::WARN);
+ } else {
+ OC_Log::write('core', 'Login failed: user \''.$_POST["user"].'\' , wrong password, IP:set log_authfailip=true in conf',
+ OC_Log::WARN);
+ }
}
OC_Util::displayLoginPage(array_unique($error));
diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php
index bc298a3f33f..cb990aed110 100644
--- a/lib/l10n/pt_PT.php
+++ b/lib/l10n/pt_PT.php
@@ -1,5 +1,7 @@
<?php
$TRANSLATIONS = array(
+"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "A aplicação \"%s\" não pode ser instaladas por não ser compatível com esta versão da ownCloud.",
+"No app name specified" => "O nome da aplicação não foi especificado",
"Help" => "Ajuda",
"Personal" => "Pessoal",
"Settings" => "Configurações",
@@ -15,6 +17,11 @@ $TRANSLATIONS = array(
"Back to Files" => "Voltar a Ficheiros",
"Selected files too large to generate zip file." => "Os ficheiros seleccionados são grandes demais para gerar um ficheiro zip.",
"Download the files in smaller chunks, seperately or kindly ask your administrator." => "Descarregue os ficheiros em partes menores, separados ou peça gentilmente ao seu administrador.",
+"Archives of type %s are not supported" => "Arquivos do tipo %s não são suportados",
+"App does not provide an info.xml file" => "A aplicação não disponibiliza um ficheiro info.xml",
+"App can't be installed because of not allowed code in the App" => "A aplicação não pode ser instalado devido a código não permitido dentro da aplicação",
+"App directory already exists" => "A directoria da aplicação já existe",
+"Can't create app folder. Please fix permissions. %s" => "Não foi possível criar a pasta da aplicação. Por favor verifique as permissões. %s",
"Application is not enabled" => "A aplicação não está activada",
"Authentication error" => "Erro na autenticação",
"Token expired. Please reload page." => "O token expirou. Por favor recarregue a página.",
diff --git a/lib/l10n/sv.php b/lib/l10n/sv.php
index 37f2e1d8c08..8ce6d005ca4 100644
--- a/lib/l10n/sv.php
+++ b/lib/l10n/sv.php
@@ -8,6 +8,9 @@ $TRANSLATIONS = array(
"Users" => "Användare",
"Admin" => "Admin",
"Failed to upgrade \"%s\"." => "Misslyckades med att uppgradera \"%s\".",
+"Custom profile pictures don't work with encryption yet" => "Anpassningsbara profilbilder fungerar inte med kryptering ännu.",
+"Unknown filetype" => "Okänd filtyp",
+"Invalid image" => "Ogiltig bild",
"web services under your control" => "webbtjänster under din kontroll",
"cannot open \"%s\"" => "Kan inte öppna \"%s\"",
"ZIP download is turned off." => "Nerladdning av ZIP är avstängd.",
diff --git a/lib/l10n/tr.php b/lib/l10n/tr.php
index 01f48517aec..80288ed0516 100644
--- a/lib/l10n/tr.php
+++ b/lib/l10n/tr.php
@@ -8,6 +8,9 @@ $TRANSLATIONS = array(
"Users" => "Kullanıcılar",
"Admin" => "Yönetici",
"Failed to upgrade \"%s\"." => "\"%s\" yükseltme başarısız oldu.",
+"Custom profile pictures don't work with encryption yet" => "Hala özel profil resminiz şifreleme ile çalışmıyor",
+"Unknown filetype" => "Bilinmeyen dosya türü",
+"Invalid image" => "Geçersiz resim",
"web services under your control" => "Bilgileriniz güvenli ve şifreli",
"cannot open \"%s\"" => "\"%s\" açılamıyor",
"ZIP download is turned off." => "ZIP indirmeleri kapatılmıştır.",
diff --git a/lib/private/app.php b/lib/private/app.php
index b4a71992178..1a242ad968e 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -752,10 +752,43 @@ class OC_App{
} else {
$combinedApps = $appList;
}
+ // bring the apps into the right order with a custom sort funtion
+ usort( $combinedApps, '\OC_App::customSort' );
+
return $combinedApps;
}
/**
+ * @brief: Internal custom sort funtion to bring the app into the right order. Should only be called by listAllApps
+ * @return array
+ */
+ private static function customSort($a, $b) {
+
+ // prio 1: active
+ if ($a['active'] != $b['active']) {
+ return $b['active'] - $a['active'];
+ }
+
+ // prio 2: shipped
+ if ($a['shipped'] != $b['shipped']) {
+ $atemp = ($a['shipped'] == true ? 1 : 0);
+ $btemp = ($b['shipped'] == true ? 1 : 0);
+ return ($btemp - $atemp);
+ }
+
+ // prio 3: recommended
+ if ($a['internalclass'] != $b['internalclass']) {
+ $atemp = ($a['internalclass'] == 'recommendedapp' ? 1 : 0);
+ $btemp = ($b['internalclass'] == 'recommendedapp' ? 1 : 0);
+ return ($btemp - $atemp);
+ }
+
+ // prio 4: alphabetical
+ return strcasecmp($a['name'], $b['name']);
+
+ }
+
+ /**
* @brief: get a list of all apps on apps.owncloud.com
* @return array, multi-dimensional array of apps.
* Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index 3755d45fa09..e62b72fd973 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -89,11 +89,12 @@ class DIContainer extends SimpleContainer implements IAppContainer{
return new SecurityMiddleware($c['API'], $c['Request']);
});
- $this['MiddlewareDispatcher'] = $this->share(function($c){
+ $middleWares = $this->middleWares;
+ $this['MiddlewareDispatcher'] = $this->share(function($c) use ($middleWares) {
$dispatcher = new MiddlewareDispatcher();
$dispatcher->registerMiddleware($c['SecurityMiddleware']);
- foreach($this->middleWares as $middleWare) {
+ foreach($middleWares as $middleWare) {
$dispatcher->registerMiddleware($middleWare);
}
diff --git a/lib/private/avatar.php b/lib/private/avatar.php
index f20980c364b..720740569df 100644
--- a/lib/private/avatar.php
+++ b/lib/private/avatar.php
@@ -51,10 +51,6 @@ class OC_Avatar {
* @return void
*/
public function set ($data) {
- if (\OC_App::isEnabled('files_encryption')) {
- $l = \OC_L10N::get('lib');
- throw new \Exception($l->t("Custom profile pictures don't work with encryption yet"));
- }
$img = new OC_Image($data);
$type = substr($img->mimeType(), -3);
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
index 2ab914d17b8..b0738d2a92b 100644
--- a/lib/private/cache/file.php
+++ b/lib/private/cache/file.php
@@ -41,6 +41,24 @@ class File {
return $result;
}
+ /**
+ * Returns the size of the stored/cached data
+ *
+ * @param $key
+ * @return int
+ */
+ public function size($key) {
+ $result = 0;
+ $proxyStatus = \OC_FileProxy::$enabled;
+ \OC_FileProxy::$enabled = false;
+ if ($this->hasKey($key)) {
+ $storage = $this->getStorage();
+ $result = $storage->filesize($key);
+ }
+ \OC_FileProxy::$enabled = $proxyStatus;
+ return $result;
+ }
+
public function set($key, $value, $ttl=0) {
$storage = $this->getStorage();
$result = false;
diff --git a/lib/private/connector/sabre/auth.php b/lib/private/connector/sabre/auth.php
index d2fd74c44f9..0c84fa6b757 100644
--- a/lib/private/connector/sabre/auth.php
+++ b/lib/private/connector/sabre/auth.php
@@ -73,11 +73,7 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
*/
public function authenticate(Sabre_DAV_Server $server, $realm) {
- if (OC_User::handleApacheAuth()) {
- return true;
- }
-
- if (OC_User::isLoggedIn()) {
+ if (OC_User::handleApacheAuth() || OC_User::isLoggedIn()) {
$user = OC_User::getUser();
OC_Util::setupFS($user);
$this->currentUser = $user;
diff --git a/lib/private/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php
index d0334780361..c51f84bf67c 100644
--- a/lib/private/connector/sabre/directory.php
+++ b/lib/private/connector/sabre/directory.php
@@ -71,7 +71,6 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$path = $this->path . '/' . $name;
$node = new OC_Connector_Sabre_File($path);
return $node->put($data);
-
}
/**
@@ -229,4 +228,5 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
}
return $props;
}
+
}
diff --git a/lib/private/connector/sabre/exception/entitytoolarge.php b/lib/private/connector/sabre/exception/entitytoolarge.php
new file mode 100644
index 00000000000..2bda51f2f3e
--- /dev/null
+++ b/lib/private/connector/sabre/exception/entitytoolarge.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Entity Too Large
+ *
+ * This exception is thrown whenever a user tries to upload a file which exceeds hard limitations
+ *
+ */
+class OC_Connector_Sabre_Exception_EntityTooLarge extends Sabre_DAV_Exception {
+
+ /**
+ * Returns the HTTP status code for this exception
+ *
+ * @return int
+ */
+ public function getHTTPCode() {
+
+ return 413;
+
+ }
+
+}
diff --git a/lib/private/connector/sabre/exception/unsupportedmediatype.php b/lib/private/connector/sabre/exception/unsupportedmediatype.php
new file mode 100644
index 00000000000..95d6a8cc651
--- /dev/null
+++ b/lib/private/connector/sabre/exception/unsupportedmediatype.php
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * Unsupported Media Type
+ *
+ * This exception is thrown whenever a user tries to upload a file which holds content which is not allowed
+ *
+ */
+class OC_Connector_Sabre_Exception_UnsupportedMediaType extends Sabre_DAV_Exception {
+
+ /**
+ * Returns the HTTP status code for this exception
+ *
+ * @return int
+ */
+ public function getHTTPCode() {
+
+ return 415;
+
+ }
+
+}
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 037dba7f37b..3402946a136 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -60,23 +60,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// chunked handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
-
- list($path, $name) = \Sabre_DAV_URLUtil::splitPath($this->path);
-
- $info = OC_FileChunking::decodeName($name);
- if (empty($info)) {
- throw new Sabre_DAV_Exception_NotImplemented();
- }
-
- $chunk_handler = new OC_FileChunking($info);
- $chunk_handler->store($info['index'], $data);
- if ($chunk_handler->isComplete()) {
- $newPath = $path . '/' . $info['name'];
- $chunk_handler->file_assemble($newPath);
- return $this->getETagPropertyForPath($newPath);
- }
-
- return null;
+ return $this->createFileChunked($data);
}
// mark file as partial while uploading (ignored by the scanner)
@@ -98,7 +82,21 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
throw new Sabre_DAV_Exception();
}
} catch (\OCP\Files\NotPermittedException $e) {
- throw new Sabre_DAV_Exception_Forbidden();
+ // a more general case - due to whatever reason the content could not be written
+ throw new Sabre_DAV_Exception_Forbidden($e->getMessage());
+
+ } catch (\OCP\Files\EntityTooLargeException $e) {
+ // the file is too big to be stored
+ throw new OC_Connector_Sabre_Exception_EntityTooLarge($e->getMessage());
+
+ } catch (\OCP\Files\InvalidContentException $e) {
+ // the file content is not permitted
+ throw new OC_Connector_Sabre_Exception_UnsupportedMediaType($e->getMessage());
+
+ } catch (\OCP\Files\InvalidPathException $e) {
+ // the path for the file was not valid
+ // TODO: find proper http status code for this case
+ throw new Sabre_DAV_Exception_Forbidden($e->getMessage());
}
// rename to correct path
@@ -200,4 +198,37 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
return \OC\Files\Filesystem::getMimeType($this->path);
}
+
+ private function createFileChunked($data)
+ {
+ list($path, $name) = \Sabre_DAV_URLUtil::splitPath($this->path);
+
+ $info = OC_FileChunking::decodeName($name);
+ if (empty($info)) {
+ throw new Sabre_DAV_Exception_NotImplemented();
+ }
+ $chunk_handler = new OC_FileChunking($info);
+ $bytesWritten = $chunk_handler->store($info['index'], $data);
+
+ //detect aborted upload
+ if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
+ if (isset($_SERVER['CONTENT_LENGTH'])) {
+ $expected = $_SERVER['CONTENT_LENGTH'];
+ if ($bytesWritten != $expected) {
+ $chunk_handler->cleanup();
+ throw new Sabre_DAV_Exception_BadRequest(
+ 'expected filesize ' . $expected . ' got ' . $bytesWritten);
+ }
+ }
+ }
+
+ if ($chunk_handler->isComplete()) {
+ $newPath = $path . '/' . $info['name'];
+ $chunk_handler->file_assemble($newPath);
+ return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
+ }
+
+ return null;
+ }
+
}
diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php
index fa27abb381a..c38e9f86375 100644
--- a/lib/private/connector/sabre/node.php
+++ b/lib/private/connector/sabre/node.php
@@ -147,12 +147,6 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* Even if the modification time is set to a custom value the access time is set to now.
*/
public function touch($mtime) {
-
- // touch is only allowed if the update privilege is granted
- if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
- throw new \Sabre_DAV_Exception_Forbidden();
- }
-
\OC\Files\Filesystem::touch($this->path, $mtime);
}
diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php
index 313a6ee87d2..0dfce696cda 100644
--- a/lib/private/filechunking.php
+++ b/lib/private/filechunking.php
@@ -34,10 +34,19 @@ class OC_FileChunking {
return $this->cache;
}
+ /**
+ * Stores the given $data under the given $key - the number of stored bytes is returned
+ *
+ * @param $index
+ * @param $data
+ * @return int
+ */
public function store($index, $data) {
$cache = $this->getCache();
$name = $this->getPrefix().$index;
$cache->set($name, $data);
+
+ return $cache->size($name);
}
public function isComplete() {
@@ -58,12 +67,24 @@ class OC_FileChunking {
$count = 0;
for($i=0; $i < $this->info['chunkcount']; $i++) {
$chunk = $cache->get($prefix.$i);
- $cache->remove($prefix.$i);
$count += fwrite($f, $chunk);
}
+
+ $this->cleanup();
return $count;
}
+ /**
+ * Removes all chunks which belong to this transmission
+ */
+ public function cleanup() {
+ $cache = $this->getCache();
+ $prefix = $this->getPrefix();
+ for($i=0; $i < $this->info['chunkcount']; $i++) {
+ $cache->remove($prefix.$i);
+ }
+ }
+
public function signature_split($orgfile, $input) {
$info = unpack('n', fread($input, 2));
$blocksize = $info[1];
diff --git a/lib/private/files/storage/storage.php b/lib/private/files/storage/storage.php
index b673bb9a32d..5be90f24756 100644
--- a/lib/private/files/storage/storage.php
+++ b/lib/private/files/storage/storage.php
@@ -14,278 +14,6 @@ namespace OC\Files\Storage;
* All paths passed to the storage are relative to the storage and should NOT have a leading slash.
*/
interface Storage extends \OCP\Files\Storage {
- /**
- * $parameters is a free form array with the configuration options needed to construct the storage
- *
- * @param array $parameters
- */
- public function __construct($parameters);
-
- /**
- * Get the identifier for the storage,
- * the returned id should be the same for every storage object that is created with the same parameters
- * and two storage objects with the same id should refer to two storages that display the same files.
- *
- * @return string
- */
- public function getId();
-
- /**
- * see http://php.net/manual/en/function.mkdir.php
- *
- * @param string $path
- * @return bool
- */
- public function mkdir($path);
-
- /**
- * see http://php.net/manual/en/function.rmdir.php
- *
- * @param string $path
- * @return bool
- */
- public function rmdir($path);
-
- /**
- * see http://php.net/manual/en/function.opendir.php
- *
- * @param string $path
- * @return resource
- */
- public function opendir($path);
-
- /**
- * see http://php.net/manual/en/function.is_dir.php
- *
- * @param string $path
- * @return bool
- */
- public function is_dir($path);
-
- /**
- * see http://php.net/manual/en/function.is_file.php
- *
- * @param string $path
- * @return bool
- */
- public function is_file($path);
-
- /**
- * see http://php.net/manual/en/function.stat.php
- * only the following keys are required in the result: size and mtime
- *
- * @param string $path
- * @return array
- */
- public function stat($path);
-
- /**
- * see http://php.net/manual/en/function.filetype.php
- *
- * @param string $path
- * @return bool
- */
- public function filetype($path);
-
- /**
- * see http://php.net/manual/en/function.filesize.php
- * The result for filesize when called on a folder is required to be 0
- *
- * @param string $path
- * @return int
- */
- public function filesize($path);
-
- /**
- * check if a file can be created in $path
- *
- * @param string $path
- * @return bool
- */
- public function isCreatable($path);
-
- /**
- * check if a file can be read
- *
- * @param string $path
- * @return bool
- */
- public function isReadable($path);
-
- /**
- * check if a file can be written to
- *
- * @param string $path
- * @return bool
- */
- public function isUpdatable($path);
-
- /**
- * check if a file can be deleted
- *
- * @param string $path
- * @return bool
- */
- public function isDeletable($path);
-
- /**
- * check if a file can be shared
- *
- * @param string $path
- * @return bool
- */
- public function isSharable($path);
-
- /**
- * get the full permissions of a path.
- * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php
- *
- * @param string $path
- * @return int
- */
- public function getPermissions($path);
-
- /**
- * see http://php.net/manual/en/function.file_exists.php
- *
- * @param string $path
- * @return bool
- */
- public function file_exists($path);
-
- /**
- * see http://php.net/manual/en/function.filemtime.php
- *
- * @param string $path
- * @return int
- */
- public function filemtime($path);
-
- /**
- * see http://php.net/manual/en/function.file_get_contents.php
- *
- * @param string $path
- * @return string
- */
- public function file_get_contents($path);
-
- /**
- * see http://php.net/manual/en/function.file_put_contents.php
- *
- * @param string $path
- * @param string $data
- * @return bool
- */
- public function file_put_contents($path, $data);
-
- /**
- * see http://php.net/manual/en/function.unlink.php
- *
- * @param string $path
- * @return bool
- */
- public function unlink($path);
-
- /**
- * see http://php.net/manual/en/function.rename.php
- *
- * @param string $path1
- * @param string $path2
- * @return bool
- */
- public function rename($path1, $path2);
-
- /**
- * see http://php.net/manual/en/function.copy.php
- *
- * @param string $path1
- * @param string $path2
- * @return bool
- */
- public function copy($path1, $path2);
-
- /**
- * see http://php.net/manual/en/function.fopen.php
- *
- * @param string $path
- * @param string $mode
- * @return resource
- */
- public function fopen($path, $mode);
-
- /**
- * get the mimetype for a file or folder
- * The mimetype for a folder is required to be "httpd/unix-directory"
- *
- * @param string $path
- * @return string
- */
- public function getMimeType($path);
-
- /**
- * see http://php.net/manual/en/function.hash.php
- *
- * @param string $type
- * @param string $path
- * @param bool $raw
- * @return string
- */
- public function hash($type, $path, $raw = false);
-
- /**
- * see http://php.net/manual/en/function.free_space.php
- *
- * @param string $path
- * @return int
- */
- public function free_space($path);
-
- /**
- * search for occurrences of $query in file names
- *
- * @param string $query
- * @return array
- */
- public function search($query);
-
- /**
- * see http://php.net/manual/en/function.touch.php
- * If the backend does not support the operation, false should be returned
- *
- * @param string $path
- * @param int $mtime
- * @return bool
- */
- public function touch($path, $mtime = null);
-
- /**
- * get the path to a local version of the file.
- * The local version of the file can be temporary and doesn't have to be persistent across requests
- *
- * @param string $path
- * @return string
- */
- public function getLocalFile($path);
-
- /**
- * get the path to a local version of the folder.
- * The local version of the folder can be temporary and doesn't have to be persistent across requests
- *
- * @param string $path
- * @return string
- */
- public function getLocalFolder($path);
- /**
- * check if a file or folder has been updated since $time
- *
- * @param string $path
- * @param int $time
- * @return bool
- *
- * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed.
- * returning true for other changes in the folder is optional
- */
- public function hasUpdated($path, $time);
/**
* get a cache instance for the storage
@@ -333,11 +61,4 @@ interface Storage extends \OCP\Files\Storage {
*/
public function getStorageCache();
- /**
- * get the ETag for a file or folder
- *
- * @param string $path
- * @return string
- */
- public function getETag($path);
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index aa08a5f7cc9..c0b9f0fc9c8 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -110,7 +110,9 @@ class View {
* @return array consisting of the storage and the internal path
*/
public function resolvePath($path) {
- return Filesystem::resolvePath($this->getAbsolutePath($path));
+ $a = $this->getAbsolutePath($path);
+ $p = Filesystem::normalizePath($a);
+ return Filesystem::resolvePath($p);
}
/**
@@ -324,7 +326,8 @@ class View {
return false;
}
} else {
- return $this->basicOperation('file_put_contents', $path, array('create', 'write'), $data);
+ $hooks = ($this->file_exists($path)) ? array('write') : array('create', 'write');
+ return $this->basicOperation('file_put_contents', $path, $hooks, $data);
}
}
@@ -709,7 +712,10 @@ class View {
return false;
}
$defaultRoot = Filesystem::getRoot();
- return (strlen($this->fakeRoot) >= strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot)) === $defaultRoot);
+ if($this->fakeRoot === $defaultRoot){
+ return true;
+ }
+ return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
}
private function runHooks($hooks, $path, $post = false) {
@@ -898,7 +904,8 @@ class View {
$permissions = $subStorage->getPermissions($rootEntry['path']);
$subPermissionsCache->set($rootEntry['fileid'], $user, $permissions);
}
- $rootEntry['permissions'] = $permissions;
+ // do not allow renaming/deleting the mount point
+ $rootEntry['permissions'] = $permissions & (\OCP\PERMISSION_ALL - (\OCP\PERMISSION_UPDATE | \OCP\PERMISSION_DELETE));
//remove any existing entry with the same name
foreach ($files as $i => $file) {
diff --git a/lib/private/group.php b/lib/private/group.php
index ba93dc129a1..9144ef683b6 100644
--- a/lib/private/group.php
+++ b/lib/private/group.php
@@ -265,7 +265,7 @@ class OC_Group {
public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$group = self::getManager()->get($gid);
if ($group) {
- $users = $group->searchDisplayName($search . $limit, $offset);
+ $users = $group->searchDisplayName($search, $limit, $offset);
$displayNames = array();
foreach ($users as $user) {
$displayNames[] = $user->getDisplayName();
diff --git a/lib/private/helper.php b/lib/private/helper.php
index a34640d8e36..1236e748256 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -509,11 +509,11 @@ class OC_Helper {
*
* @param resource $source
* @param resource $target
- * @return int the number of bytes copied
+ * @return array the number of bytes copied and result
*/
public static function streamCopy($source, $target) {
if (!$source or !$target) {
- return false;
+ return array(0, false);
}
$result = true;
$count = 0;
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index f3b43584409..a408e3830d6 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -59,10 +59,14 @@ class OC_Log_Owncloud {
}
$time = new DateTime(null, $timezone);
$entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time->format($format));
+ $entry = json_encode($entry);
$handle = @fopen(self::$logFile, 'a');
if ($handle) {
- fwrite($handle, json_encode($entry)."\n");
+ fwrite($handle, $entry."\n");
fclose($handle);
+ } else {
+ // Fall back to error_log
+ error_log($entry);
}
}
}
diff --git a/lib/private/session/session.php b/lib/private/session/session.php
index c55001eccac..fe160faa267 100644
--- a/lib/private/session/session.php
+++ b/lib/private/session/session.php
@@ -8,7 +8,10 @@
namespace OC\Session;
-abstract class Session implements \ArrayAccess, \OCP\ISession {
+use OCP\ISession;
+
+abstract class Session implements \ArrayAccess, ISession {
+
/**
* $name serves as a namespace for the session keys
*
@@ -17,36 +20,6 @@ abstract class Session implements \ArrayAccess, \OCP\ISession {
abstract public function __construct($name);
/**
- * @param string $key
- * @param mixed $value
- */
- abstract public function set($key, $value);
-
- /**
- * @param string $key
- * @return mixed should return null if $key does not exist
- */
- abstract public function get($key);
-
- /**
- * @param string $key
- * @return bool
- */
- abstract public function exists($key);
-
- /**
- * should not throw any errors if $key does not exist
- *
- * @param string $key
- */
- abstract public function remove($key);
-
- /**
- * removes all entries within the cache namespace
- */
- abstract public function clear();
-
- /**
* @param mixed $offset
* @return bool
*/
diff --git a/lib/private/user.php b/lib/private/user.php
index b68786c773c..6b350d4cf1b 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -325,7 +325,7 @@ class OC_User {
return $backend->getLogoutAttribute();
}
- return "href=" . link_to('', 'index.php') . "?logout=true";
+ return 'href="' . link_to('', 'index.php') . '?logout=true"';
}
/**
diff --git a/lib/public/files/entitytoolargeexception.php b/lib/public/files/entitytoolargeexception.php
new file mode 100644
index 00000000000..3dff41bca02
--- /dev/null
+++ b/lib/public/files/entitytoolargeexception.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\Files;
+
+class EntityTooLargeException extends \Exception {}
diff --git a/lib/public/files/invalidcontentexception.php b/lib/public/files/invalidcontentexception.php
new file mode 100644
index 00000000000..184ec4d06d6
--- /dev/null
+++ b/lib/public/files/invalidcontentexception.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\Files;
+
+class InvalidContentException extends \Exception {}
diff --git a/lib/public/files/invalidpathexception.php b/lib/public/files/invalidpathexception.php
new file mode 100644
index 00000000000..36090ae5b48
--- /dev/null
+++ b/lib/public/files/invalidpathexception.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Copyright (c) 2013 Thomas Müller <thomas.mueller@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OCP\Files;
+
+class InvalidPathException extends \Exception {}
diff --git a/lib/public/share.php b/lib/public/share.php
index 59bda042485..b2873d22f43 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -155,13 +155,13 @@ class Share {
while ($source !== -1) {
- // Fetch all shares of this file path from DB
+ // Fetch all shares with another user
$query = \OC_DB::prepare(
'SELECT `share_with`
FROM
`*PREFIX*share`
WHERE
- `item_source` = ? AND `share_type` = ?'
+ `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')'
);
$result = $query->execute(array($source, self::SHARE_TYPE_USER));
@@ -180,7 +180,7 @@ class Share {
FROM
`*PREFIX*share`
WHERE
- `item_source` = ? AND `share_type` = ?'
+ `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')'
);
$result = $query->execute(array($source, self::SHARE_TYPE_GROUP));
@@ -201,7 +201,7 @@ class Share {
FROM
`*PREFIX*share`
WHERE
- `item_source` = ? AND `share_type` = ?'
+ `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')'
);
$result = $query->execute(array($source, self::SHARE_TYPE_LINK));