aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-01-20 03:11:04 +0100
committerRobin Appelman <icewind@owncloud.com>2013-01-20 03:11:04 +0100
commit83d622132224fa61b1518e6bca430518cf138401 (patch)
tree53f79474af81e07f1304a1cf10e866b2d8af652b /lib
parent8ca30d244c19b33e7e3b0da247b70160a3acc44f (diff)
parentebc0c4b85bc382efcf64ad0b2613d70a193b18f2 (diff)
downloadnextcloud-server-83d622132224fa61b1518e6bca430518cf138401.tar.gz
nextcloud-server-83d622132224fa61b1518e6bca430518cf138401.zip
merge master into filesytem
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php2
-rw-r--r--lib/app.php2
-rw-r--r--lib/base.php25
-rw-r--r--lib/helper.php24
-rw-r--r--lib/l10n/ca.php1
-rw-r--r--lib/l10n/cs_CZ.php1
-rw-r--r--lib/l10n/de_DE.php1
-rw-r--r--lib/l10n/el.php1
-rw-r--r--lib/l10n/eu.php1
-rw-r--r--lib/l10n/fi_FI.php1
-rw-r--r--lib/l10n/hu_HU.php3
-rw-r--r--lib/l10n/it.php1
-rw-r--r--lib/l10n/ja_JP.php1
-rw-r--r--lib/l10n/lb.php2
-rw-r--r--lib/l10n/ms_MY.php1
-rw-r--r--lib/l10n/nl.php1
-rw-r--r--lib/l10n/pt_PT.php1
-rw-r--r--lib/l10n/uk.php1
-rw-r--r--lib/public/util.php10
-rw-r--r--lib/setup.php40
20 files changed, 109 insertions, 11 deletions
diff --git a/lib/api.php b/lib/api.php
index 8d728d4311f..0fce109a423 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -94,6 +94,8 @@ class OC_API {
$response = new OC_OCS_Result(null, 998, 'Api method not found');
}
} else {
+ header('WWW-Authenticate: Basic realm="Authorization Required"');
+ header('HTTP/1.0 401 Unauthorized');
$response = new OC_OCS_Result(null, 997, 'Unauthorised');
}
// Send the response
diff --git a/lib/app.php b/lib/app.php
index 68e1bc6a6ca..0f1fa2c5ec2 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -748,7 +748,7 @@ class OC_App{
}
return new \OC\Files\View('/'.OC_User::getUser().'/'.$appid);
}else{
- OC_Log::write('core', 'Can\'t get app storage, app, user not logged in', OC_Log::ERROR);
+ OC_Log::write('core', 'Can\'t get app storage, app '.$appid.', user not logged in', OC_Log::ERROR);
return false;
}
}else{
diff --git a/lib/base.php b/lib/base.php
index 6f537cf0893..dd5eef52fe3 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -30,7 +30,7 @@ require_once 'public/constants.php';
class OC
{
/**
- * Assoziative array for autoloading. classname => filename
+ * Associative array for autoloading. classname => filename
*/
public static $CLASSPATH = array();
/**
@@ -233,6 +233,12 @@ class OC
public static function checkMaintenanceMode() {
// Allow ajax update script to execute without being stopped
if (OC_Config::getValue('maintenance', false) && OC::$SUBURI != '/core/ajax/update.php') {
+ // send http status 503
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ header('Retry-After: 120');
+
+ // render error page
$tmpl = new OC_Template('', 'error', 'guest');
$tmpl->assign('errors', array(1 => array('error' => 'ownCloud is in maintenance mode')));
$tmpl->printPage();
@@ -323,6 +329,18 @@ class OC
return OC::$router;
}
+
+ public static function loadAppClassPaths()
+ {
+ foreach(OC_APP::getEnabledApps() as $app) {
+ $file = OC_App::getAppPath($app).'/appinfo/classpath.php';
+ if(file_exists($file)) {
+ require_once $file;
+ }
+ }
+ }
+
+
public static function init()
{
// register autoloader
@@ -539,6 +557,11 @@ class OC
header('location: ' . OC_Helper::linkToRemote('webdav'));
return;
}
+
+ // load all the classpaths from the enabled apps so they are available
+ // in the routing files of each app
+ OC::loadAppClassPaths();
+
try {
OC::getRouter()->match(OC_Request::getPathInfo());
return;
diff --git a/lib/helper.php b/lib/helper.php
index 6b1eaa4e6ee..d7b57d381dc 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -193,8 +193,9 @@ class OC_Helper {
if(isset($alias[$mimetype])) {
$mimetype=$alias[$mimetype];
}
- // Replace slash with a minus
+ // Replace slash and backslash with a minus
$mimetype = str_replace( "/", "-", $mimetype );
+ $mimetype = str_replace( "\\", "-", $mimetype );
// Is it a dir?
if( $mimetype == "dir" ) {
@@ -679,8 +680,8 @@ class OC_Helper {
$start = intval($start);
$length = intval($length);
$string = mb_substr($string, 0, $start, $encoding) .
- $replacement .
- mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
+ $replacement .
+ mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
return $string;
}
@@ -749,6 +750,23 @@ class OC_Helper {
}
/**
+ * @brief calculates the maximum upload size respecting system settings, free space and user quota
+ *
+ * @param $dir the current folder where the user currently operates
+ * @return number of bytes representing
+ */
+ public static function maxUploadFilesize($dir) {
+ $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+ $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
+ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+
+ $freeSpace = OC_Filesystem::free_space($dir);
+ $freeSpace = max($freeSpace, 0);
+
+ return min($maxUploadFilesize, $freeSpace);
+ }
+
+ /**
* Checks if a function is available
* @param string $function_name
* @return bool
diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php
index b3321ef82e1..f6401fa39b6 100644
--- a/lib/l10n/ca.php
+++ b/lib/l10n/ca.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Els fitxers s'han de baixar d'un en un.",
"Back to Files" => "Torna a Fitxers",
"Selected files too large to generate zip file." => "Els fitxers seleccionats son massa grans per generar un fitxer zip.",
+"couldn't be determined" => "no s'ha pogut determinar",
"Application is not enabled" => "L'aplicació no està habilitada",
"Authentication error" => "Error d'autenticació",
"Token expired. Please reload page." => "El testimoni ha expirat. Torneu a carregar la pàgina.",
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php
index fa11e886774..2c823194b96 100644
--- a/lib/l10n/cs_CZ.php
+++ b/lib/l10n/cs_CZ.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Soubory musí být stahovány jednotlivě.",
"Back to Files" => "Zpět k souborům",
"Selected files too large to generate zip file." => "Vybrané soubory jsou příliš velké pro vytvoření zip souboru.",
+"couldn't be determined" => "nelze zjistit",
"Application is not enabled" => "Aplikace není povolena",
"Authentication error" => "Chyba ověření",
"Token expired. Please reload page." => "Token vypršel. Obnovte prosím stránku.",
diff --git a/lib/l10n/de_DE.php b/lib/l10n/de_DE.php
index e9f0f34a0e1..625ba2ecf20 100644
--- a/lib/l10n/de_DE.php
+++ b/lib/l10n/de_DE.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Die Dateien müssen einzeln heruntergeladen werden.",
"Back to Files" => "Zurück zu \"Dateien\"",
"Selected files too large to generate zip file." => "Die gewählten Dateien sind zu groß, um eine ZIP-Datei zu erstellen.",
+"couldn't be determined" => "konnte nicht ermittelt werden",
"Application is not enabled" => "Die Anwendung ist nicht aktiviert",
"Authentication error" => "Authentifizierungs-Fehler",
"Token expired. Please reload page." => "Token abgelaufen. Bitte laden Sie die Seite neu.",
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index 315b995ecc9..cf0be24b432 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Τα αρχεία πρέπει να ληφθούν ένα-ένα.",
"Back to Files" => "Πίσω στα Αρχεία",
"Selected files too large to generate zip file." => "Τα επιλεγμένα αρχεία είναι μεγάλα ώστε να δημιουργηθεί αρχείο zip.",
+"couldn't be determined" => "δεν μπορούσε να προσδιορισθεί",
"Application is not enabled" => "Δεν ενεργοποιήθηκε η εφαρμογή",
"Authentication error" => "Σφάλμα πιστοποίησης",
"Token expired. Please reload page." => "Το αναγνωριστικό έληξε. Παρακαλώ φορτώστε ξανά την σελίδα.",
diff --git a/lib/l10n/eu.php b/lib/l10n/eu.php
index 5d47ecbda23..1941551b176 100644
--- a/lib/l10n/eu.php
+++ b/lib/l10n/eu.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Fitxategiak banan-banan deskargatu behar dira.",
"Back to Files" => "Itzuli fitxategietara",
"Selected files too large to generate zip file." => "Hautatuko fitxategiak oso handiak dira zip fitxategia sortzeko.",
+"couldn't be determined" => "ezin izan da zehaztu",
"Application is not enabled" => "Aplikazioa ez dago gaituta",
"Authentication error" => "Autentikazio errorea",
"Token expired. Please reload page." => "Tokena iraungitu da. Mesedez birkargatu orria.",
diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php
index 6a5734e978d..b8d4b137431 100644
--- a/lib/l10n/fi_FI.php
+++ b/lib/l10n/fi_FI.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Tiedostot on ladattava yksittäin.",
"Back to Files" => "Takaisin tiedostoihin",
"Selected files too large to generate zip file." => "Valitut tiedostot ovat liian suurikokoisia mahtuakseen zip-tiedostoon.",
+"couldn't be determined" => "ei voitu määrittää",
"Application is not enabled" => "Sovellusta ei ole otettu käyttöön",
"Authentication error" => "Todennusvirhe",
"Token expired. Please reload page." => "Valtuutus vanheni. Lataa sivu uudelleen.",
diff --git a/lib/l10n/hu_HU.php b/lib/l10n/hu_HU.php
index 3dcf0646d06..c95358011f0 100644
--- a/lib/l10n/hu_HU.php
+++ b/lib/l10n/hu_HU.php
@@ -8,7 +8,8 @@
"ZIP download is turned off." => "A ZIP-letöltés nem engedélyezett.",
"Files need to be downloaded one by one." => "A fájlokat egyenként kell letölteni",
"Back to Files" => "Vissza a Fájlokhoz",
-"Selected files too large to generate zip file." => "A kiválasztott fájlok túl nagy a zip tömörítéshez.",
+"Selected files too large to generate zip file." => "A kiválasztott fájlok túl nagyok a zip tömörítéshez.",
+"couldn't be determined" => "nem sikerült azonosítani",
"Application is not enabled" => "Az alkalmazás nincs engedélyezve",
"Authentication error" => "Hitelesítési hiba",
"Token expired. Please reload page." => "A token lejárt. Frissítse az oldalt.",
diff --git a/lib/l10n/it.php b/lib/l10n/it.php
index c0fb0babfb3..eb404db7fb5 100644
--- a/lib/l10n/it.php
+++ b/lib/l10n/it.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "I file devono essere scaricati uno alla volta.",
"Back to Files" => "Torna ai file",
"Selected files too large to generate zip file." => "I file selezionati sono troppo grandi per generare un file zip.",
+"couldn't be determined" => "non può essere determinato",
"Application is not enabled" => "L'applicazione non è abilitata",
"Authentication error" => "Errore di autenticazione",
"Token expired. Please reload page." => "Token scaduto. Ricarica la pagina.",
diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php
index 854734c9764..11cefe900c2 100644
--- a/lib/l10n/ja_JP.php
+++ b/lib/l10n/ja_JP.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "ファイルは1つずつダウンロードする必要があります。",
"Back to Files" => "ファイルに戻る",
"Selected files too large to generate zip file." => "選択したファイルはZIPファイルの生成には大きすぎます。",
+"couldn't be determined" => "測定できませんでした",
"Application is not enabled" => "アプリケーションは無効です",
"Authentication error" => "認証エラー",
"Token expired. Please reload page." => "トークンが無効になりました。ページを再読込してください。",
diff --git a/lib/l10n/lb.php b/lib/l10n/lb.php
index baee630e897..a5a9adca187 100644
--- a/lib/l10n/lb.php
+++ b/lib/l10n/lb.php
@@ -1,6 +1,8 @@
<?php $TRANSLATIONS = array(
+"Help" => "Hëllef",
"Personal" => "Perséinlech",
"Settings" => "Astellungen",
"Authentication error" => "Authentifikatioun's Fehler",
+"Files" => "Dateien",
"Text" => "SMS"
);
diff --git a/lib/l10n/ms_MY.php b/lib/l10n/ms_MY.php
index 86c7e51b486..5afee1cb5a8 100644
--- a/lib/l10n/ms_MY.php
+++ b/lib/l10n/ms_MY.php
@@ -1,4 +1,5 @@
<?php $TRANSLATIONS = array(
+"Help" => "Bantuan",
"Personal" => "Peribadi",
"Settings" => "Tetapan",
"Users" => "Pengguna",
diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php
index 087cf23a627..7ce134e3621 100644
--- a/lib/l10n/nl.php
+++ b/lib/l10n/nl.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Bestanden moeten één voor één worden gedownload.",
"Back to Files" => "Terug naar bestanden",
"Selected files too large to generate zip file." => "De geselecteerde bestanden zijn te groot om een zip bestand te maken.",
+"couldn't be determined" => "kon niet worden vastgesteld",
"Application is not enabled" => "De applicatie is niet actief",
"Authentication error" => "Authenticatie fout",
"Token expired. Please reload page." => "Token verlopen. Herlaad de pagina.",
diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php
index 84867c4c37c..e35bb489c49 100644
--- a/lib/l10n/pt_PT.php
+++ b/lib/l10n/pt_PT.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Os ficheiros precisam de ser descarregados um por um.",
"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.",
+"couldn't be determined" => "Não foi possível determinar",
"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/uk.php b/lib/l10n/uk.php
index f5d52f8682d..053644ddede 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.php
@@ -9,6 +9,7 @@
"Files need to be downloaded one by one." => "Файли повинні бути завантаженні послідовно.",
"Back to Files" => "Повернутися до файлів",
"Selected files too large to generate zip file." => "Вибрані фали завеликі для генерування zip файлу.",
+"couldn't be determined" => "не може бути визначено",
"Application is not enabled" => "Додаток не увімкнений",
"Authentication error" => "Помилка автентифікації",
"Token expired. Please reload page." => "Строк дії токена скінчився. Будь ласка, перезавантажте сторінку.",
diff --git a/lib/public/util.php b/lib/public/util.php
index 8197482c0dd..413dbcccd28 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -367,4 +367,14 @@ class Util {
public static function recursiveArraySearch($haystack, $needle, $index = null) {
return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
}
+
+ /**
+ * @brief calculates the maximum upload size respecting system settings, free space and user quota
+ *
+ * @param $dir the current folder where the user currently operates
+ * @return number of bytes representing
+ */
+ public static function maxUploadFilesize($dir) {
+ return \OC_Helper::maxUploadFilesize($dir);
+ }
}
diff --git a/lib/setup.php b/lib/setup.php
index b88bc4b52ce..28882b6bede 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -1,5 +1,23 @@
<?php
+class DatabaseSetupException extends Exception
+{
+ private $hint;
+
+ public function __construct($message, $hint, $code = 0, Exception $previous = null) {
+ $this->hint = $hint;
+ parent::__construct($message, $code, $previous);
+ }
+
+ public function __toString() {
+ return __CLASS__ . ": [{$this->code}]: {$this->message} ({$this->hint})\n";
+ }
+
+ public function getHint() {
+ return $this->hint;
+ }
+}
+
class OC_Setup {
public static function install($options) {
$error = array();
@@ -19,9 +37,9 @@ class OC_Setup {
if($dbtype=='mysql')
$dbprettyname = 'MySQL';
else if($dbtype=='pgsql')
- $dbprettyname = 'PostgreSQL';
+ $dbprettyname = 'PostgreSQL';
else
- $dbprettyname = 'Oracle';
+ $dbprettyname = 'Oracle';
if(empty($options['dbuser'])) {
@@ -69,10 +87,16 @@ class OC_Setup {
try {
self::setupMySQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username);
+ } catch (DatabaseSetupException $e) {
+ $error[] = array(
+ 'error' => $e->getMessage(),
+ 'hint' => $e->getHint()
+ );
+ return($error);
} catch (Exception $e) {
$error[] = array(
- 'error' => 'MySQL username and/or password not valid',
- 'hint' => 'You need to enter either an existing account or the administrator.'
+ 'error' => $e->getMessage(),
+ 'hint' => ''
);
return($error);
}
@@ -166,7 +190,7 @@ class OC_Setup {
//check if the database user has admin right
$connection = @mysql_connect($dbhost, $dbuser, $dbpass);
if(!$connection) {
- throw new Exception('MySQL username and/or password not valid');
+ throw new DatabaseSetupException('MySQL username and/or password not valid','You need to enter either an existing account or the administrator.');
}
$oldUser=OC_Config::getValue('dbuser', false);
@@ -229,8 +253,14 @@ class OC_Setup {
// the anonymous user would take precedence when there is one.
$query = "CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
$result = mysql_query($query, $connection);
+ if (!$result) {
+ throw new DatabaseSetupException("MySQL user '" . "$name" . "'@'localhost' already exists","Delete this user from MySQL.");
+ }
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
$result = mysql_query($query, $connection);
+ if (!$result) {
+ throw new DatabaseSetupException("MySQL user '" . "$name" . "'@'%' already exists","Delete this user from MySQL.");
+ }
}
private static function setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $username) {