summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Mueller <thomas.mueller@tmit.eu>2013-02-20 10:55:20 +0100
committerThomas Mueller <thomas.mueller@tmit.eu>2013-02-20 10:55:20 +0100
commit5062ae250b767867609f64c29ab4cde65f022b75 (patch)
treeba624bec5f2470fbaadb4b281c57386210e5708e /lib
parent2675290325dc6a67f6719febe5ed0a546bd7a32a (diff)
parent38782036798dbe0a34995a3fca0aa92583cb9099 (diff)
downloadnextcloud-server-5062ae250b767867609f64c29ab4cde65f022b75.tar.gz
nextcloud-server-5062ae250b767867609f64c29ab4cde65f022b75.zip
Merge branch 'master' into master-sqlserver
Conflicts: lib/files/cache/cache.php
Diffstat (limited to 'lib')
-rw-r--r--lib/arrayparser.php189
-rw-r--r--lib/fileproxy/quota.php15
-rw-r--r--lib/files/cache/cache.php11
-rw-r--r--lib/files/filesystem.php30
-rw-r--r--lib/files/mount.php6
-rw-r--r--lib/files/storage/common.php9
-rw-r--r--lib/helper.php8
-rw-r--r--lib/l10n/es_AR.php3
-rw-r--r--lib/l10n/uk.php20
9 files changed, 270 insertions, 21 deletions
diff --git a/lib/arrayparser.php b/lib/arrayparser.php
new file mode 100644
index 00000000000..3bb394a5163
--- /dev/null
+++ b/lib/arrayparser.php
@@ -0,0 +1,189 @@
+<?php
+
+/**
+ * @author Robin Appelman
+ * @copyright 2013 Robin Appelman icewind@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;
+
+class SyntaxException extends \Exception {
+}
+
+class ArrayParser {
+ const TYPE_NUM = 1;
+ const TYPE_BOOL = 2;
+ const TYPE_STRING = 3;
+ const TYPE_ARRAY = 4;
+
+ function parsePHP($string) {
+ $string = $this->stripPHPTags($string);
+ $string = $this->stripAssignAndReturn($string);
+ return $this->parse($string);
+ }
+
+ function stripPHPTags($string) {
+ $string = trim($string);
+ if (substr($string, 0, 5) === '<?php') {
+ $string = substr($string, 5);
+ }
+ if (substr($string, -2) === '?>') {
+ $string = substr($string, 0, -2);
+ }
+ return $string;
+ }
+
+ function stripAssignAndReturn($string) {
+ $string = trim($string);
+ if (substr($string, 0, 6) === 'return') {
+ $string = substr($string, 6);
+ }
+ if (substr($string, 0, 1) === '$') {
+ list(, $string) = explode('=', $string, 2);
+ }
+ return $string;
+ }
+
+ function parse($string) {
+ $string = trim($string);
+ $string = trim($string, ';');
+ switch ($this->getType($string)) {
+ case self::TYPE_NUM:
+ return $this->parseNum($string);
+ case self::TYPE_BOOL:
+ return $this->parseBool($string);
+ case self::TYPE_STRING:
+ return $this->parseString($string);
+ case self::TYPE_ARRAY:
+ return $this->parseArray($string);
+ }
+ return null;
+ }
+
+ function getType($string) {
+ $string = strtolower($string);
+ $first = substr($string, 0, 1);
+ $last = substr($string, -1, 1);
+ $arrayFirst = substr($string, 0, 5);
+ if (($first === '"' or $first === "'") and ($last === '"' or $last === "'")) {
+ return self::TYPE_STRING;
+ } elseif ($string === 'false' or $string === 'true') {
+ return self::TYPE_BOOL;
+ } elseif ($arrayFirst === 'array' and $last === ')') {
+ return self::TYPE_ARRAY;
+ } else {
+ return self::TYPE_NUM;
+ }
+ }
+
+ function parseString($string) {
+ return substr($string, 1, -1);
+ }
+
+ function parseNum($string) {
+ return intval($string);
+ }
+
+ function parseBool($string) {
+ $string = strtolower($string);
+ return $string === 'true';
+ }
+
+ function parseArray($string) {
+ $body = substr($string, 5);
+ $body = trim($body);
+ $body = substr($body, 1, -1);
+ $items = $this->splitArray($body);
+ $result = array();
+ $lastKey = -1;
+ foreach ($items as $item) {
+ $item = trim($item);
+ if ($item) {
+ if (strpos($item, '=>')) {
+ list($key, $value) = explode('=>', $item, 2);
+ $key = $this->parse($key);
+ $value = $this->parse($value);
+ } else {
+ $key = ++$lastKey;
+ $value = $item;
+ }
+
+ if (is_numeric($key)) {
+ $lastKey = $key;
+ }
+ $result[$key] = $value;
+ }
+ }
+ return $result;
+ }
+
+ function splitArray($body) {
+ $inSingleQuote = false;//keep track if we are inside quotes
+ $inDoubleQuote = false;
+ $bracketDepth = 0;//keep track if we are inside brackets
+ $parts = array();
+ $start = 0;
+ $escaped = false;//keep track if we are after an escape character
+ $skips = array();//keep track of the escape characters we need to remove from the result
+ if (substr($body, -1, 1) !== ',') {
+ $body .= ',';
+ }
+ for ($i = 0; $i < strlen($body); $i++) {
+ $char = substr($body, $i, 1);
+ if ($char === '\\') {
+ if ($escaped) {
+ array_unshift($skips, $i - 1);
+ }
+ $escaped = !$escaped;
+ } else {
+ if ($char === '"' and !$inSingleQuote) {
+ if ($escaped) {
+ array_unshift($skips, $i - 1);
+ } else {
+ $inDoubleQuote = !$inDoubleQuote;
+ }
+ } elseif ($char === "'" and !$inDoubleQuote) {
+ if ($escaped) {
+ array_unshift($skips, $i - 1);
+ } else {
+ $inSingleQuote = !$inSingleQuote;
+ }
+ } elseif (!$inDoubleQuote and !$inSingleQuote) {
+ if ($char === '(') {
+ $bracketDepth++;
+ } elseif ($char === ')') {
+ if ($bracketDepth <= 0) {
+ throw new SyntaxException;
+ } else {
+ $bracketDepth--;
+ }
+ } elseif ($bracketDepth === 0 and $char === ',') {
+ $part = substr($body, $start, $i - $start);
+ foreach ($skips as $skip) {
+ $part = substr($part, 0, $skip - $start) . substr($part, $skip - $start + 1);
+ }
+ $parts[] = $part;
+ $start = $i + 1;
+ $skips = array();
+ }
+ }
+ $escaped = false;
+ }
+ }
+ return $parts;
+ }
+}
diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php
index 07d1d250e4d..3dac3264fbe 100644
--- a/lib/fileproxy/quota.php
+++ b/lib/fileproxy/quota.php
@@ -62,21 +62,21 @@ class OC_FileProxy_Quota extends OC_FileProxy{
* @var string $internalPath
*/
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($path);
- $owner=$storage->getOwner($internalPath);
+ $owner = $storage->getOwner($internalPath);
if (!$owner) {
return -1;
}
- $totalSpace=$this->getQuota($owner);
- if($totalSpace==-1) {
+ $totalSpace = $this->getQuota($owner);
+ if($totalSpace == -1) {
return -1;
}
$view = new \OC\Files\View("/".$owner."/files");
- $rootInfo=$view->getFileInfo('/');
- $usedSpace=isset($rootInfo['size'])?$rootInfo['size']:0;
- return $totalSpace-$usedSpace;
+ $rootInfo = $view->getFileInfo('/');
+ $usedSpace = isset($rootInfo['size'])?$rootInfo['size']:0;
+ return $totalSpace - $usedSpace;
}
public function postFree_space($path, $space) {
@@ -84,6 +84,9 @@ class OC_FileProxy_Quota extends OC_FileProxy{
if($free==-1) {
return $space;
}
+ if ($space < 0){
+ return $free;
+ }
return min($free, $space);
}
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 77fc91b9379..01e6e788263 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -48,6 +48,9 @@ class Cache {
} else {
$this->storageId = $storage;
}
+ if (strlen($this->storageId) > 64) {
+ $this->storageId = md5($this->storageId);
+ }
$query = \OC_DB::prepare('SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?');
$result = $query->execute(array($this->storageId));
@@ -199,7 +202,7 @@ class Cache {
$valuesPlaceholder = array_fill(0, count($queryParts), '?');
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ')'
- .' VALUES(' . implode(', ', $valuesPlaceholder) . ')');
+ . ' VALUES(' . implode(', ', $valuesPlaceholder) . ')');
$query->execute($params);
return (int)\OC_DB::insertid('*PREFIX*filecache');
@@ -217,7 +220,7 @@ class Cache {
$params[] = $id;
$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=?'
- .' WHERE fileid = ?');
+ . ' WHERE fileid = ?');
$query->execute($params);
}
@@ -335,7 +338,7 @@ class Cache {
}
$query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =?'
- .' WHERE `fileid` = ?');
+ . ' WHERE `fileid` = ?');
$query->execute(array($target, md5($target), $newParentId, $sourceId));
}
@@ -496,7 +499,7 @@ class Cache {
*/
public function getIncomplete() {
$query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache`'
- .' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1');
+ . ' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1');
$result = $query->execute(array($this->numericId));
if ($row = $result->fetchRow()) {
return $row['path'];
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index f4530868077..875a9d6c5ee 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -29,6 +29,8 @@
namespace OC\Files;
+const FREE_SPACE_UNKNOWN = -2;
+
class Filesystem {
public static $loaded = false;
/**
@@ -215,9 +217,15 @@ class Filesystem {
if ($user == '') {
$user = \OC_User::getUser();
}
+ $parser = new \OC\ArrayParser();
+
// Load system mount points
- if (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
- $mountConfig = include 'config/mount.php';
+ if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file(\OC::$SERVERROOT . '/config/mount.json')) {
+ if(is_file(\OC::$SERVERROOT . '/config/mount.json')){
+ $mountConfig = json_decode(file_get_contents(\OC::$SERVERROOT . '/config/mount.json'), true);
+ }elseif(is_file(\OC::$SERVERROOT . '/config/mount.php')){
+ $mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
+ }
if (isset($mountConfig['global'])) {
foreach ($mountConfig['global'] as $mountPoint => $options) {
self::mount($options['class'], $options['options'], $mountPoint);
@@ -253,8 +261,12 @@ class Filesystem {
// Load personal mount points
$root = \OC_User::getHome($user);
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
- if (is_file($root . '/mount.php')) {
- $mountConfig = include $root . '/mount.php';
+ if (is_file($root . '/mount.php') or is_file($root . '/mount.json')) {
+ if (is_file($root . '/mount.json')){
+ $mountConfig = json_decode(file_get_contents($root . '/mount.json'), true);
+ } elseif (is_file($root . '/mount.php')){
+ $mountConfig = $parser->parsePHP(file_get_contents($root . '/mount.php'));
+ }
if (isset($mountConfig['user'][$user])) {
foreach ($mountConfig['user'][$user] as $mountPoint => $options) {
self::mount($options['class'], $options['options'], $mountPoint);
@@ -613,11 +625,11 @@ class Filesystem {
}
/**
- * Get the owner for a file or folder
- *
- * @param string $path
- * @return string
- */
+ * Get the owner for a file or folder
+ *
+ * @param string $path
+ * @return string
+ */
public static function getOwner($path) {
return self::$defaultInstance->getOwner($path);
}
diff --git a/lib/files/mount.php b/lib/files/mount.php
index 74ee483b1be..6e99d8eabb4 100644
--- a/lib/files/mount.php
+++ b/lib/files/mount.php
@@ -93,6 +93,9 @@ class Mount {
$this->storage = $this->createStorage();
}
$this->storageId = $this->storage->getId();
+ if (strlen($this->storageId) > 64) {
+ $this->storageId = md5($this->storageId);
+ }
}
return $this->storageId;
}
@@ -177,6 +180,9 @@ class Mount {
* @return \OC\Files\Storage\Storage[]
*/
public static function findById($id) {
+ if (strlen($id) > 64) {
+ $id = md5($id);
+ }
$result = array();
foreach (self::$mounts as $mount) {
if ($mount->getStorageId() === $id) {
diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php
index 4cdabf1c8a6..4e7a73e5d4a 100644
--- a/lib/files/storage/common.php
+++ b/lib/files/storage/common.php
@@ -301,4 +301,13 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
return implode('/', $output);
}
+
+ /**
+ * get the free space in the storage
+ * @param $path
+ * return int
+ */
+ public function free_space($path){
+ return \OC\Files\FREE_SPACE_UNKNOWN;
+ }
}
diff --git a/lib/helper.php b/lib/helper.php
index 0f810ffc0c2..add5c66e7be 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -762,9 +762,13 @@ class OC_Helper {
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace = \OC\Files\Filesystem::free_space($dir);
- $freeSpace = max($freeSpace, 0);
+ if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){
+ $freeSpace = max($freeSpace, 0);
- return min($maxUploadFilesize, $freeSpace);
+ return min($maxUploadFilesize, $freeSpace);
+ } else {
+ return $maxUploadFilesize;
+ }
}
/**
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
index a2391a45b23..cfe90f6bc1b 100644
--- a/lib/l10n/es_AR.php
+++ b/lib/l10n/es_AR.php
@@ -25,12 +25,15 @@
"%s set the database host." => "%s Especifique la dirección de la Base de Datos",
"PostgreSQL username and/or password not valid" => "Nombre de usuario o contraseña de PostgradeSQL no válido.",
"You need to enter either an existing account or the administrator." => "Debe ingresar una cuenta existente o el administrador",
+"Oracle username and/or password not valid" => "El nombre de usuario y contraseña no son válidos",
"MySQL username and/or password not valid" => "Usuario y/o contraseña MySQL no válido",
"DB Error: \"%s\"" => "Error DB: \"%s\"",
+"Offending command was: \"%s\"" => "El comando no comprendido es: \"%s\"",
"MySQL user '%s'@'localhost' exists already." => "Usuario MySQL '%s'@'localhost' ya existente",
"Drop this user from MySQL" => "Borrar este usuario de MySQL",
"MySQL user '%s'@'%%' already exists" => "Usuario MySQL '%s'@'%%' ya existente",
"Drop this user from MySQL." => "Borrar este usuario de MySQL",
+"Offending command was: \"%s\", name: %s, password: %s" => "El comando no comprendido es: \"%s\", nombre: \"%s\", contraseña: \"%s\"",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Tu servidor web no está configurado todavía para permitir sincronización de archivos porque la interfaz WebDAV parece no funcionar.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, comprobá nuevamente la <a href='%s'>guía de instalación</a>.",
"seconds ago" => "hace unos segundos",
diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php
index 053644ddede..415c0a80c27 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.php
@@ -16,6 +16,26 @@
"Files" => "Файли",
"Text" => "Текст",
"Images" => "Зображення",
+"Set an admin username." => "Встановіть ім'я адміністратора.",
+"Set an admin password." => "Встановіть пароль адміністратора.",
+"Specify a data folder." => "Вкажіть теку для даних.",
+"%s enter the database username." => "%s введіть ім'я користувача бази даних.",
+"%s enter the database name." => "%s введіть назву бази даних.",
+"%s you may not use dots in the database name" => "%s не можна використовувати крапки в назві бази даних",
+"%s set the database host." => "%s встановити хост бази даних.",
+"PostgreSQL username and/or password not valid" => "PostgreSQL ім'я користувача та/або пароль не дійсні",
+"You need to enter either an existing account or the administrator." => "Вам потрібно ввести або існуючий обліковий запис або administrator.",
+"Oracle username and/or password not valid" => "Oracle ім'я користувача та/або пароль не дійсні",
+"MySQL username and/or password not valid" => "MySQL ім'я користувача та/або пароль не дійсні",
+"DB Error: \"%s\"" => "Помилка БД: \"%s\"",
+"Offending command was: \"%s\"" => "Команда, що викликала проблему: \"%s\"",
+"MySQL user '%s'@'localhost' exists already." => "Користувач MySQL '%s'@'localhost' вже існує.",
+"Drop this user from MySQL" => "Видалити цього користувача з MySQL",
+"MySQL user '%s'@'%%' already exists" => "Користувач MySQL '%s'@'%%' вже існує",
+"Drop this user from MySQL." => "Видалити цього користувача з MySQL.",
+"Offending command was: \"%s\", name: %s, password: %s" => "Команда, що викликала проблему: \"%s\", ім'я: %s, пароль: %s",
+"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ваш Web-сервер ще не налаштований належним чином для того, щоб дозволити синхронізацію файлів, через те що інтерфейс WebDAV, здається, зламаний.",
+"Please double check the <a href='%s'>installation guides</a>." => "Будь ласка, перевірте <a href='%s'>інструкції по встановленню</a>.",
"seconds ago" => "секунди тому",
"1 minute ago" => "1 хвилину тому",
"%d minutes ago" => "%d хвилин тому",