summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-10-14 10:56:50 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2013-10-14 10:56:50 +0200
commita5e808defc5a6afd38df429768d76c283305a4f2 (patch)
tree7676d5b9f3e45967a6f9031c4829f47762079b8a /lib
parent61a534fb60eb275344e6cf7890fdfe88657e53a6 (diff)
parentf3336f8877771e53d303f6f939f0005fa9692b7a (diff)
downloadnextcloud-server-a5e808defc5a6afd38df429768d76c283305a4f2.tar.gz
nextcloud-server-a5e808defc5a6afd38df429768d76c283305a4f2.zip
Merge branch 'master' into fixing-4546-master
Conflicts: lib/private/connector/sabre/file.php
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php10
-rw-r--r--lib/l10n/ady.php8
-rw-r--r--lib/l10n/mk.php1
-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.php13
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php5
-rw-r--r--lib/private/connector/sabre/directory.php18
-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.php25
-rw-r--r--lib/private/connector/sabre/node.php6
-rw-r--r--lib/private/connector/sabre/objecttree.php3
-rw-r--r--lib/private/files/storage/storage.php279
-rw-r--r--lib/private/files/view.php12
-rw-r--r--lib/private/group.php2
-rw-r--r--lib/private/legacy/config.php12
-rw-r--r--lib/private/log/owncloud.php16
-rw-r--r--lib/private/session/session.php35
-rw-r--r--lib/private/user.php4
-rw-r--r--lib/private/user/dummy.php4
-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, 202 insertions, 349 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/ady.php b/lib/l10n/ady.php
new file mode 100644
index 00000000000..15f78e0bce6
--- /dev/null
+++ b/lib/l10n/ady.php
@@ -0,0 +1,8 @@
+<?php
+$TRANSLATIONS = array(
+"_%n minute ago_::_%n minutes ago_" => array("",""),
+"_%n hour ago_::_%n hours ago_" => array("",""),
+"_%n day go_::_%n days ago_" => array("",""),
+"_%n month ago_::_%n months ago_" => array("","")
+);
+$PLURAL_FORMS = "nplurals=2; plural=(n != 1);";
diff --git a/lib/l10n/mk.php b/lib/l10n/mk.php
index 285dfd682a4..19e36c868d0 100644
--- a/lib/l10n/mk.php
+++ b/lib/l10n/mk.php
@@ -5,6 +5,7 @@ $TRANSLATIONS = array(
"Settings" => "Подесувања",
"Users" => "Корисници",
"Admin" => "Админ",
+"Invalid image" => "Невалидна фотографија",
"web services under your control" => "веб сервиси под Ваша контрола",
"ZIP download is turned off." => "Преземање во ZIP е исклучено",
"Files need to be downloaded one by one." => "Датотеките треба да се симнат една по една.",
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 0ab1ee57f63..b4a71992178 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -165,10 +165,14 @@ class OC_App{
/**
* get all enabled apps
*/
+ private static $enabledAppsCache = array();
public static function getEnabledApps() {
if(!OC_Config::getValue('installed', false)) {
return array();
}
+ if(!empty(self::$enabledAppsCache)) {
+ return self::$enabledAppsCache;
+ }
$apps=array('files');
$sql = 'SELECT `appid` FROM `*PREFIX*appconfig`'
.' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'';
@@ -187,6 +191,7 @@ class OC_App{
$apps[]=$row['appid'];
}
}
+ self::$enabledAppsCache = $apps;
return $apps;
}
@@ -198,11 +203,11 @@ class OC_App{
* This function checks whether or not an app is enabled.
*/
public static function isEnabled( $app ) {
- if( 'files'==$app or ('yes' == OC_Appconfig::getValue( $app, 'enabled' ))) {
+ if('files' == $app) {
return true;
}
-
- return false;
+ $enabledApps = self::getEnabledApps();
+ return in_array($app, $enabledApps);
}
/**
@@ -214,6 +219,7 @@ class OC_App{
* This function set an app as enabled in appconfig.
*/
public static function enable( $app ) {
+ self::$enabledAppsCache = array(); // flush
if(!OC_Installer::isInstalled($app)) {
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
if(!is_numeric($app)) {
@@ -257,6 +263,7 @@ class OC_App{
* This function set an app as disabled in appconfig.
*/
public static function disable( $app ) {
+ self::$enabledAppsCache = array(); // flush
// check if app is a shipped app or not. if not delete
\OC_Hook::emit('OC_App', 'pre_disable', array('app' => $app));
OC_Appconfig::setValue( $app, 'enabled', 'no' );
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/connector/sabre/directory.php b/lib/private/connector/sabre/directory.php
index 531b0a807bf..c51f84bf67c 100644
--- a/lib/private/connector/sabre/directory.php
+++ b/lib/private/connector/sabre/directory.php
@@ -50,8 +50,22 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
*/
public function createFile($name, $data = null) {
- if (!\OC\Files\Filesystem::isCreatable($this->path)) {
- throw new \Sabre_DAV_Exception_Forbidden();
+ // for chunked upload also updating a existing file is a "createFile"
+ // because we create all the chunks before reasamble them to the existing file.
+ if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+
+ // exit if we can't create a new file and we don't updatable existing file
+ $info = OC_FileChunking::decodeName($name);
+ if (!\OC\Files\Filesystem::isCreatable($this->path) &&
+ !\OC\Files\Filesystem::isUpdatable($this->path . '/' . $info['name'])) {
+ throw new \Sabre_DAV_Exception_Forbidden();
+ }
+
+ } else {
+ // For non-chunked upload it is enough to check if we can create a new file
+ if (!\OC\Files\Filesystem::isCreatable($this->path)) {
+ throw new \Sabre_DAV_Exception_Forbidden();
+ }
}
$path = $this->path . '/' . $name;
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 f2191732c0d..3402946a136 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -45,7 +45,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @return string|null
*/
public function put($data) {
+
$fs = $this->getFS();
+
if ($fs->file_exists($this->path) &&
!$fs->isUpdatable($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
@@ -64,6 +66,13 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// mark file as partial while uploading (ignored by the scanner)
$partpath = $this->path . '.part';
+ // if file is located in /Shared we write the part file to the users
+ // root folder because we can't create new files in /shared
+ // we extend the name with a random number to avoid overwriting a existing file
+ if (dirname($partpath) === 'Shared') {
+ $partpath = pathinfo($partpath, PATHINFO_FILENAME) . rand() . '.part';
+ }
+
try {
$putOkay = $fs->file_put_contents($partpath, $data);
if ($putOkay === false) {
@@ -73,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
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/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index 80c3840b99d..df8902f66e2 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -87,6 +87,9 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
if (!$fs->isUpdatable($destinationDir)) {
throw new \Sabre_DAV_Exception_Forbidden();
}
+ if (!$fs->isDeletable($sourcePath)) {
+ throw new \Sabre_DAV_Exception_Forbidden();
+ }
}
$renameOkay = $fs->rename($sourcePath, $destinationPath);
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..a56135d9b3c 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) {
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/legacy/config.php b/lib/private/legacy/config.php
index 7e498013737..c457979113e 100644
--- a/lib/private/legacy/config.php
+++ b/lib/private/legacy/config.php
@@ -83,11 +83,7 @@ class OC_Config {
*
*/
public static function setValue($key, $value) {
- try {
- self::$object->setValue($key, $value);
- } catch (\OC\HintException $e) {
- \OC_Template::printErrorPage($e->getMessage(), $e->getHint());
- }
+ self::$object->setValue($key, $value);
}
/**
@@ -98,10 +94,6 @@ class OC_Config {
*
*/
public static function deleteKey($key) {
- try {
- self::$object->deleteKey($key);
- } catch (\OC\HintException $e) {
- \OC_Template::printErrorPage($e->getMessage(), $e->getHint());
- }
+ self::$object->deleteKey($key);
}
}
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index d16b9537a16..a408e3830d6 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -51,12 +51,22 @@ class OC_Log_Owncloud {
if($level>=$minLevel) {
// default to ISO8601
$format = OC_Config::getValue('logdateformat', 'c');
- $time = date($format, time());
- $entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time);
+ $logtimezone=OC_Config::getValue( "logtimezone", 'UTC' );
+ try {
+ $timezone = new DateTimeZone($logtimezone);
+ } catch (Exception $e) {
+ $timezone = new DateTimeZone('UTC');
+ }
+ $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 04cd06b08bd..b68786c773c 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -198,6 +198,10 @@ class OC_User {
// Delete user files in /data/
OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/');
+
+ return true;
+ } else {
+ return false;
}
}
diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php
index b5b7a6c3c7a..52be7edfa75 100644
--- a/lib/private/user/dummy.php
+++ b/lib/private/user/dummy.php
@@ -88,8 +88,8 @@ class OC_User_Dummy extends OC_User_Backend {
* returns the user id or false
*/
public function checkPassword($uid, $password) {
- if (isset($this->users[$uid])) {
- return ($this->users[$uid] == $password);
+ if (isset($this->users[$uid]) && $this->users[$uid] === $password) {
+ return $uid;
} else {
return false;
}
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 e6a74117aa2..66605dafee5 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));