summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2013-03-10 11:30:33 +0100
committerBart Visscher <bartv@thisnet.nl>2013-03-10 11:30:33 +0100
commit7af774cc9817bccc9f8244c61f1dae1ac36e0869 (patch)
tree0b53cb51065fbe4b4cf64b2fa3d13c98ee6a2315 /lib
parente1818675d24f37898f0c50d0804bc458d2acb72f (diff)
parent3c06020e3ec1e03aeb689c2e12600be1f95091a7 (diff)
downloadnextcloud-server-7af774cc9817bccc9f8244c61f1dae1ac36e0869.tar.gz
nextcloud-server-7af774cc9817bccc9f8244c61f1dae1ac36e0869.zip
Merge branch 'master' into doctrine
Conflicts: lib/db.php
Diffstat (limited to 'lib')
-rw-r--r--lib/api.php150
-rw-r--r--lib/app.php36
-rw-r--r--lib/base.php46
-rw-r--r--lib/config.php4
-rw-r--r--lib/connector/sabre/directory.php16
-rw-r--r--lib/connector/sabre/file.php8
-rw-r--r--lib/connector/sabre/quotaplugin.php3
-rw-r--r--lib/db.php210
-rw-r--r--lib/files.php31
-rw-r--r--lib/files/cache/cache.php7
-rw-r--r--lib/files/cache/legacy.php6
-rw-r--r--lib/files/cache/permissions.php25
-rw-r--r--lib/files/cache/upgrade.php9
-rw-r--r--lib/files/filesystem.php13
-rw-r--r--lib/files/mount.php26
-rw-r--r--lib/files/storage/common.php214
-rw-r--r--lib/files/view.php23
-rw-r--r--lib/group.php56
-rw-r--r--lib/group/backend.php36
-rw-r--r--lib/group/database.php34
-rw-r--r--lib/helper.php11
-rw-r--r--lib/hook.php16
-rw-r--r--lib/image.php13
-rw-r--r--lib/l10n/bg_BG.php12
-rw-r--r--lib/l10n/ca.php1
-rw-r--r--lib/l10n/cs_CZ.php1
-rw-r--r--lib/l10n/da.php1
-rw-r--r--lib/l10n/de.php1
-rw-r--r--lib/l10n/de_DE.php1
-rw-r--r--lib/l10n/el.php6
-rw-r--r--lib/l10n/es.php19
-rw-r--r--lib/l10n/es_AR.php1
-rw-r--r--lib/l10n/eu.php1
-rw-r--r--lib/l10n/fi_FI.php4
-rw-r--r--lib/l10n/fr.php1
-rw-r--r--lib/l10n/gl.php7
-rw-r--r--lib/l10n/hu_HU.php1
-rw-r--r--lib/l10n/it.php1
-rw-r--r--lib/l10n/ja_JP.php1
-rw-r--r--lib/l10n/ka.php15
-rw-r--r--lib/l10n/lv.php1
-rw-r--r--lib/l10n/my_MM.php1
-rw-r--r--lib/l10n/nl.php1
-rw-r--r--lib/l10n/pl.php21
-rw-r--r--lib/l10n/pt_BR.php1
-rw-r--r--lib/l10n/pt_PT.php1
-rw-r--r--lib/l10n/ru.php1
-rw-r--r--lib/l10n/sk_SK.php1
-rw-r--r--lib/l10n/sl.php28
-rw-r--r--lib/l10n/uk.php1
-rw-r--r--lib/l10n/ur_PK.php8
-rw-r--r--lib/mail.php8
-rw-r--r--lib/ocs/cloud.php60
-rw-r--r--lib/ocs/result.php48
-rw-r--r--lib/public/files.php3
-rw-r--r--lib/public/share.php34
-rw-r--r--lib/public/user.php34
-rw-r--r--lib/public/util.php11
-rwxr-xr-xlib/request.php17
-rw-r--r--lib/search.php4
-rw-r--r--lib/setup.php268
-rw-r--r--lib/template.php25
-rw-r--r--lib/templatelayout.php15
-rw-r--r--lib/user.php8
-rw-r--r--lib/user/backend.php4
-rw-r--r--lib/user/database.php12
-rwxr-xr-xlib/util.php102
-rw-r--r--lib/vcategories.php61
68 files changed, 1341 insertions, 505 deletions
diff --git a/lib/api.php b/lib/api.php
index 70e3028b68a..8d6bbb7cc09 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -33,21 +33,20 @@ class OC_API {
const USER_AUTH = 1;
const SUBADMIN_AUTH = 2;
const ADMIN_AUTH = 3;
-
- private static $server;
-
+
/**
- * initialises the OAuth store and server
+ * API Response Codes
*/
- private static function init() {
- self::$server = new OC_OAuth_Server(new OC_OAuth_Store());
- }
-
+ const RESPOND_UNAUTHORISED = 997;
+ const RESPOND_SERVER_ERROR = 996;
+ const RESPOND_NOT_FOUND = 998;
+ const RESPOND_UNKNOWN_ERROR = 999;
+
/**
* api actions
*/
protected static $actions = array();
-
+
/**
* registers an api call
* @param string $method the http method
@@ -58,7 +57,7 @@ class OC_API {
* @param array $defaults
* @param array $requirements
*/
- public static function register($method, $url, $action, $app,
+ public static function register($method, $url, $action, $app,
$authLevel = OC_API::USER_AUTH,
$defaults = array(),
$requirements = array()) {
@@ -71,9 +70,9 @@ class OC_API {
->action('OC_API', 'call');
self::$actions[$name] = array();
}
- self::$actions[$name] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel);
+ self::$actions[$name][] = array('app' => $app, 'action' => $action, 'authlevel' => $authLevel);
}
-
+
/**
* handles an api call
* @param array $parameters
@@ -86,29 +85,97 @@ class OC_API {
parse_str(file_get_contents("php://input"), $parameters['_delete']);
}
$name = $parameters['_route'];
- // Check authentication and availability
- if(self::isAuthorised(self::$actions[$name])) {
- if(is_callable(self::$actions[$name]['action'])) {
- $response = call_user_func(self::$actions[$name]['action'], $parameters);
- if(!($response instanceof OC_OCS_Result)) {
- $response = new OC_OCS_Result(null, 996, 'Internal Server Error');
- }
- } else {
- $response = new OC_OCS_Result(null, 998, 'Api method not found');
+ // Foreach registered action
+ $responses = array();
+ foreach(self::$actions[$name] as $action) {
+ // Check authentication and availability
+ if(!self::isAuthorised(self::$actions[$name])) {
+ $responses[] = array(
+ 'app' => $action['app'],
+ 'response' => new OC_OCS_Result(null, OC_API::RESPOND_UNAUTHORISED, 'Unauthorised'),
+ );
+ continue;
}
- } else {
- header('WWW-Authenticate: Basic realm="Authorization Required"');
- header('HTTP/1.0 401 Unauthorized');
- $response = new OC_OCS_Result(null, 997, 'Unauthorised');
+ if(!is_callable($action['action'])) {
+ $responses[] = array(
+ 'app' => $action['app'],
+ 'response' => new OC_OCS_Result(null, OC_API::RESPOND_NOT_FOUND, 'Api method not found'),
+ );
+ continue;
+ }
+ // Run the action
+ $responses[] = array(
+ 'app' => $action['app'],
+ 'response' => call_user_func($action['action'], $parameters),
+ );
}
- // Send the response
+ $response = self::mergeResponses($responses);
$formats = array('json', 'xml');
$format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml';
- self::respond($response, $format);
- // logout the user to be stateless
+ self::respond($response);
OC_User::logout();
}
+
+ /**
+ * merge the returned result objects into one response
+ * @param array $responses
+ */
+ private static function mergeResponses($responses) {
+ $response = array();
+ // Sort into shipped and thirdparty
+ $shipped = array(
+ 'succeeded' => array(),
+ 'failed' => array(),
+ );
+ $thirdparty = array(
+ 'succeeded' => array(),
+ 'failed' => array(),
+ );
+ foreach($responses as $response) {
+ if(OC_App::isShipped($response['app']) || ($response['app'] === 'core')) {
+ if($response['response']->succeeded()) {
+ $shipped['succeeded'][$response['app']] = $response['response'];
+ } else {
+ $shipped['failed'][$response['app']] = $response['response'];
+ }
+ } else {
+ if($response['response']->succeeded()) {
+ $thirdparty['succeeded'][$response['app']] = $response['response'];
+ } else {
+ $thirdparty['failed'][$response['app']] = $response['response'];
+ }
+ }
+ }
+ // Remove any error responses if there is one shipped response that succeeded
+ if(!empty($shipped['succeeded'])) {
+ $responses = array_merge($shipped['succeeded'], $thirdparty['succeeded']);
+ } else if(!empty($shipped['failed'])) {
+ // Which shipped response do we use if they all failed?
+ // They may have failed for different reasons (different status codes)
+ // Which reponse code should we return?
+ // Maybe any that are not OC_API::RESPOND_SERVER_ERROR
+ $response = $shipped['failed'][0];
+ return $response;
+ } else {
+ // Return the third party failure result
+ $response = $thirdparty['failed'][0];
+ return $response;
+ }
+ // Merge the successful responses
+ $meta = array();
+ $data = array();
+ foreach($responses as $app => $response) {
+ if(OC_App::isShipped($app)) {
+ $data = array_merge_recursive($response->getData(), $data);
+ } else {
+ $data = array_merge_recursive($data, $response->getData());
+ }
+ }
+ $result = new OC_OCS_Result($data, 100);
+ return $result;
+ }
+
/**
* authenticate the api call
* @param array $action the action details as supplied to OC_API::register()
@@ -132,7 +199,8 @@ class OC_API {
return false;
} else {
$subAdmin = OC_SubAdmin::isSubAdmin($user);
- if($subAdmin) {
+ $admin = OC_User::isAdminUser($user);
+ if($subAdmin || $admin) {
return true;
} else {
return false;
@@ -153,25 +221,35 @@ class OC_API {
return false;
break;
}
- }
-
+ }
+
/**
* http basic auth
* @return string|false (username, or false on failure)
*/
- private static function loginUser(){
+ private static function loginUser(){
$authUser = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '';
$authPw = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : '';
return OC_User::login($authUser, $authPw) ? $authUser : false;
}
-
+
/**
* respond to a call
- * @param int|array $result the result from the api method
+ * @param OC_OCS_Result $result
* @param string $format the format xml|json
*/
private static function respond($result, $format='xml') {
- $response = array('ocs' => $result->getResult());
+ // Send 401 headers if unauthorised
+ if($result->getStatusCode() === self::RESPOND_UNAUTHORISED) {
+ header('WWW-Authenticate: Basic realm="Authorisation Required"');
+ header('HTTP/1.0 401 Unauthorized');
+ }
+ $response = array(
+ 'ocs' => array(
+ 'meta' => $result->getMeta(),
+ 'data' => $result->getData(),
+ ),
+ );
if ($format == 'json') {
OC_JSON::encodedPrint($response);
} else if ($format == 'xml') {
@@ -203,5 +281,5 @@ class OC_API {
}
}
}
-
+
}
diff --git a/lib/app.php b/lib/app.php
index e653c30b2d9..55b4543ec9f 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -223,7 +223,7 @@ class OC_App{
// check if the app is compatible with this version of ownCloud
$info=OC_App::getAppInfo($app);
$version=OC_Util::getVersion();
- if(!isset($info['require']) or ($version[0]>$info['require'])) {
+ if(!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) {
OC_Log::write('core',
'App "'.$info['name'].'" can\'t be installed because it is'
.' not compatible with this version of ownCloud',
@@ -851,7 +851,7 @@ class OC_App{
foreach($apps as $app) {
// check if the app is compatible with this version of ownCloud
$info = OC_App::getAppInfo($app);
- if(!isset($info['require']) or (($version[0].'.'.$version[1])>$info['require'])) {
+ if(!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) {
OC_Log::write('core',
'App "'.$info['name'].'" ('.$app.') can\'t be used because it is'
.' not compatible with this version of ownCloud',
@@ -862,6 +862,38 @@ class OC_App{
}
}
+
+ /**
+ * Compares the app version with the owncloud version to see if the app
+ * requires a newer version than the currently active one
+ * @param array $owncloudVersions array with 3 entries: major minor bugfix
+ * @param string $appRequired the required version from the xml
+ * major.minor.bugfix
+ * @return boolean true if compatible, otherwise false
+ */
+ public static function isAppVersionCompatible($owncloudVersions, $appRequired){
+ $appVersions = explode('.', $appRequired);
+
+ for($i=0; $i<count($appVersions); $i++){
+ $appVersion = (int) $appVersions[$i];
+
+ if(isset($owncloudVersions[$i])){
+ $owncloudVersion = $owncloudVersions[$i];
+ } else {
+ $owncloudVersion = 0;
+ }
+
+ if($owncloudVersion < $appVersion){
+ return false;
+ } elseif ($owncloudVersion > $appVersion) {
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+
/**
* get the installed version of all apps
*/
diff --git a/lib/base.php b/lib/base.php
index 8a665603bb5..eb44b5e2087 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -166,9 +166,9 @@ class OC {
OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/');
OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/');
} else {
- echo("3rdparty directory not found! Please put the ownCloud 3rdparty'
+ echo('3rdparty directory not found! Please put the ownCloud 3rdparty'
.' folder in the ownCloud folder or the folder above.'
- .' You can also configure the location in the config.php file.");
+ .' You can also configure the location in the config.php file.');
exit;
}
// search the apps folder
@@ -192,8 +192,8 @@ class OC {
}
if (empty(OC::$APPSROOTS)) {
- echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder'
- .' or the folder above. You can also configure the location in the config.php file.");
+ echo('apps directory not found! Please put the ownCloud apps folder in the ownCloud folder'
+ .' or the folder above. You can also configure the location in the config.php file.');
exit;
}
$paths = array();
@@ -218,8 +218,8 @@ class OC {
$tmpl = new OC_Template('', 'error', 'guest');
$tmpl->assign('errors', array(1 => array(
'error' => "Can't write into config directory 'config'",
- 'hint' => "You can usually fix this by giving the webserver user write access'
- .' to the config directory in owncloud"
+ 'hint' => 'You can usually fix this by giving the webserver user write access'
+ .' to the config directory in owncloud'
)));
$tmpl->printPage();
exit();
@@ -281,6 +281,10 @@ class OC {
OC_Log::write('core',
'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion,
OC_Log::DEBUG);
+ $minimizerCSS = new OC_Minimizer_CSS();
+ $minimizerCSS->clearCache();
+ $minimizerJS = new OC_Minimizer_JS();
+ $minimizerJS->clearCache();
OC_Util::addscript('update');
$tmpl = new OC_Template('', 'update', 'guest');
$tmpl->assign('version', OC_Util::getVersionString());
@@ -324,19 +328,33 @@ class OC {
// set the session name to the instance id - which is unique
session_name(OC_Util::getInstanceId());
- // (re)-initialize session
- session_start();
+ // if session cant be started break with http 500 error
+ if (session_start() === false){
+ OC_Log::write('core', 'Session could not be initialized',
+ OC_Log::ERROR);
+
+ header('HTTP/1.1 500 Internal Server Error');
+ OC_Util::addStyle("styles");
+ $error = 'Session could not be initialized. Please contact your ';
+ $error .= 'system administrator';
+
+ $tmpl = new OC_Template('', 'error', 'guest');
+ $tmpl->assign('errors', array(1 => array('error' => $error)));
+ $tmpl->printPage();
+
+ exit();
+ }
// regenerate session id periodically to avoid session fixation
if (!isset($_SESSION['SID_CREATED'])) {
$_SESSION['SID_CREATED'] = time();
- } else if (time() - $_SESSION['SID_CREATED'] > 900) {
+ } else if (time() - $_SESSION['SID_CREATED'] > 60*60*12) {
session_regenerate_id(true);
$_SESSION['SID_CREATED'] = time();
}
// session timeout
- if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 3600)) {
+ if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 60*60*24)) {
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time() - 42000, '/');
}
@@ -529,7 +547,7 @@ class OC {
'setting locale to en_US.UTF-8/en_US.UTF8 failed. Support is probably not installed on your system',
OC_Log::ERROR);
}
- if (OC_Config::getValue('installed', false)) {
+ if (OC_Config::getValue('installed', false) && !self::checkUpgrade(false)) {
if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') {
OC_Util::addScript('backgroundjobs');
}
@@ -586,8 +604,10 @@ class OC {
if (!self::$CLI) {
try {
- OC_App::loadApps();
- OC::getRouter()->match(OC_Request::getPathInfo());
+ if (!OC_Config::getValue('maintenance', false)) {
+ OC_App::loadApps();
+ }
+ OC::getRouter()->match(OC_Request::getRawPathInfo());
return;
} catch (Symfony\Component\Routing\Exception\ResourceNotFoundException $e) {
//header('HTTP/1.0 404 Not Found');
diff --git a/lib/config.php b/lib/config.php
index a5c11b466f7..0bd497b8e50 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -166,8 +166,8 @@ class OC_Config{
$tmpl = new OC_Template( '', 'error', 'guest' );
$tmpl->assign('errors', array(1=>array(
'error'=>"Can't write into config directory 'config'",
- 'hint'=>"You can usually fix this by giving the webserver user write access'
- .' to the config directory in owncloud")));
+ 'hint'=>'You can usually fix this by giving the webserver user write access'
+ .' to the config directory in owncloud')));
$tmpl->printPage();
exit;
}
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index a9aa891d409..6ccb54b79ab 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -62,12 +62,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
}
} else {
$newPath = $this->path . '/' . $name;
-
+
// mark file as partial while uploading (ignored by the scanner)
$partpath = $newPath . '.part';
-
+
\OC\Files\Filesystem::file_put_contents($partpath, $data);
-
+
//detect aborted upload
if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
if (isset($_SERVER['CONTENT_LENGTH'])) {
@@ -80,10 +80,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
}
}
}
-
+
// rename to correct path
\OC\Files\Filesystem::rename($partpath, $newPath);
-
+
// allow sync clients to send the mtime along in a header
$mtime = OC_Request::hasModificationTime();
if ($mtime !== false) {
@@ -91,7 +91,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
header('X-OC-MTime: accepted');
}
}
-
+
return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath);
}
@@ -107,7 +107,9 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
public function createDirectory($name) {
$newPath = $this->path . '/' . $name;
- \OC\Files\Filesystem::mkdir($newPath);
+ if(!\OC\Files\Filesystem::mkdir($newPath)) {
+ throw new Sabre_DAV_Exception_Forbidden('Could not create directory '.$newPath);
+ }
}
diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php
index c4c27e92251..91646312e90 100644
--- a/lib/connector/sabre/file.php
+++ b/lib/connector/sabre/file.php
@@ -47,9 +47,9 @@ 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';
-
+
\OC\Files\Filesystem::file_put_contents($partpath, $data);
-
+
//detect aborted upload
if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) {
if (isset($_SERVER['CONTENT_LENGTH'])) {
@@ -62,10 +62,10 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
}
}
-
+
// rename to correct path
\OC\Files\Filesystem::rename($partpath, $this->path);
-
+
//allow sync clients to send the mtime along in a header
$mtime = OC_Request::hasModificationTime();
if ($mtime !== false) {
diff --git a/lib/connector/sabre/quotaplugin.php b/lib/connector/sabre/quotaplugin.php
index ce9a968eb3c..c80a33d04b1 100644
--- a/lib/connector/sabre/quotaplugin.php
+++ b/lib/connector/sabre/quotaplugin.php
@@ -50,7 +50,8 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
$uri='/'.$uri;
}
list($parentUri, $newName) = Sabre_DAV_URLUtil::splitPath($uri);
- if ($length > \OC\Files\Filesystem::free_space($parentUri)) {
+ $freeSpace = \OC\Files\Filesystem::free_space($parentUri);
+ if ($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN && $length > $freeSpace) {
throw new Sabre_DAV_Exception_InsufficientStorage();
}
}
diff --git a/lib/db.php b/lib/db.php
index 3b2590c3105..4a511908e5a 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -43,6 +43,7 @@ class OC_DB {
const BACKEND_DOCTRINE=2;
static private $preparedQueries = array();
+ static private $cachingEnabled = true;
/**
* @var \Doctrine\DBAL\Connection
@@ -160,6 +161,15 @@ class OC_DB {
'driver' => 'oci8',
);
break;
+ case 'mssql':
+ $dsn = array(
+ 'phptype' => 'sqlsrv',
+ 'username' => $user,
+ 'password' => $pass,
+ 'hostspec' => $host,
+ 'database' => $name
+ );
+ break;
default:
return false;
}
@@ -208,7 +218,7 @@ class OC_DB {
$query.=$limitsql;
}
} else {
- if (isset(self::$preparedQueries[$query])) {
+ if (isset(self::$preparedQueries[$query]) and self::$cachingEnabled) {
return self::$preparedQueries[$query];
}
}
@@ -227,8 +237,11 @@ class OC_DB {
}
$result=new DoctrineStatementWrapper($result);
}
- if (is_null($limit) || $limit == -1) {
- self::$preparedQueries[$rawQuery] = $result;
+ if ((is_null($limit) || $limit == -1) and self::$cachingEnabled ) {
+ $type = OC_Config::getValue( "dbtype", "sqlite" );
+ if( $type != 'sqlite' && $type != 'sqlite3' ) {
+ self::$preparedQueries[$rawQuery] = $result;
+ }
}
return $result;
}
@@ -250,6 +263,13 @@ class OC_DB {
$query = self::prepare('SELECT lastval() AS id');
$row = $query->execute()->fetchRow();
return $row['id'];
+ }
+ if( $type == 'mssql' ) {
+ if($table !== null) {
+ $prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
+ $table = str_replace( '*PREFIX*', $prefix, $table );
+ }
+ return self::$connection->lastInsertId($table);
} else {
if($table !== null) {
$prefix = OC_Config::getValue( "dbtableprefix", "oc_" );
@@ -276,7 +296,7 @@ class OC_DB {
return true;
}
- /**
+ /** else {
* @brief saves database scheme to xml file
* @param string $file name of file
* @param int $mode
@@ -385,7 +405,7 @@ class OC_DB {
} else {
return true;
}
- } elseif( $type == 'pgsql' || $type == 'oci' || $type == 'mysql') {
+ } elseif( $type == 'pgsql' || $type == 'oci' || $type == 'mysql' || $type == 'mssql') {
$query = 'INSERT INTO `' .$table . '` ('
. implode(',', array_keys($input)) . ') SELECT \''
. implode('\',\'', array_values($input)) . '\' FROM ' . $table . ' WHERE ';
@@ -445,7 +465,15 @@ class OC_DB {
} elseif( $type == 'oci' ) {
$query = str_replace( '`', '"', $query );
$query = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $query );
- }
+ }elseif( $type == 'mssql' ) {
+ $query = preg_replace( "/\`(.*?)`/", "[$1]", $query );
+ $query = str_replace( 'NOW()', 'CURRENT_TIMESTAMP', $query );
+ $query = str_replace( 'now()', 'CURRENT_TIMESTAMP', $query );
+ $query = str_replace( 'LENGTH(', 'LEN(', $query );
+ $query = str_replace( 'SUBSTR(', 'SUBSTRING(', $query );
+
+ $query = self::fixLimitClauseForMSSQL($query);
+ }
// replace table name prefix
$query = str_replace( '*PREFIX*', $prefix, $query );
@@ -453,6 +481,60 @@ class OC_DB {
return $query;
}
+ private static function fixLimitClauseForMSSQL($query) {
+ $limitLocation = stripos ($query, "LIMIT");
+
+ if ( $limitLocation === false ) {
+ return $query;
+ }
+
+ // total == 0 means all results - not zero results
+ //
+ // First number is either total or offset, locate it by first space
+ //
+ $offset = substr ($query, $limitLocation + 5);
+ $offset = substr ($offset, 0, stripos ($offset, ' '));
+ $offset = trim ($offset);
+
+ // check for another parameter
+ if (stripos ($offset, ',') === false) {
+ // no more parameters
+ $offset = 0;
+ $total = intval ($offset);
+ } else {
+ // found another parameter
+ $offset = intval ($offset);
+
+ $total = substr ($query, $limitLocation + 5);
+ $total = substr ($total, stripos ($total, ','));
+
+ $total = substr ($total, 0, stripos ($total, ' '));
+ $total = intval ($total);
+ }
+
+ $query = trim (substr ($query, 0, $limitLocation));
+
+ if ($offset == 0 && $total !== 0) {
+ if (strpos($query, "SELECT") === false) {
+ $query = "TOP {$total} " . $query;
+ } else {
+ $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP '.$total, $query);
+ }
+ } else if ($offset > 0) {
+ $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP(10000000) ', $query);
+ $query = 'SELECT *
+ FROM (SELECT sub2.*, ROW_NUMBER() OVER(ORDER BY sub2.line2) AS line3
+ FROM (SELECT 1 AS line2, sub1.* FROM (' . $query . ') AS sub1) as sub2) AS sub3';
+
+ if ($total > 0) {
+ $query .= ' WHERE line3 BETWEEN ' . ($offset + 1) . ' AND ' . ($offset + $total);
+ } else {
+ $query .= ' WHERE line3 > ' . $offset;
+ }
+ }
+ return $query;
+ }
+
/**
* @brief drop a table
* @param string $tableName the table to drop
@@ -540,6 +622,16 @@ class OC_DB {
}
return $msg;
}
+
+ /**
+ * @param bool $enabled
+ */
+ static public function enableCaching($enabled) {
+ if (!$enabled) {
+ self::$preparedQueries = array();
+ }
+ self::$cachingEnabled = $enabled;
+ }
}
/**
@@ -574,19 +666,119 @@ class DoctrineStatementWrapper {
* make execute return the result instead of a bool
*/
public function execute($input=array()) {
- $this->lastArguments=$input;
- if(count($input)>0) {
+ $this->lastArguments = $input;
+ if (count($input) > 0) {
+
+ if (!isset($type)) {
+ $type = OC_Config::getValue( "dbtype", "sqlite" );
+ }
+
+ if ($type == 'mssql') {
+ $input = $this->tryFixSubstringLastArgumentDataForMSSQL($input);
+ }
+
$result=$this->statement->execute($input);
} else {
$result=$this->statement->execute();
}
- if($result) {
+
+ if ($result) {
return $this;
} else {
return false;
}
}
+ private function tryFixSubstringLastArgumentDataForMSSQL($input) {
+ $query = $this->statement->queryString;
+ $pos = stripos ($query, 'SUBSTRING');
+
+ if ( $pos === false) {
+ return;
+ }
+
+ try {
+ $newQuery = '';
+
+ $cArg = 0;
+
+ $inSubstring = false;
+
+ // Create new query
+ for ($i = 0; $i < strlen ($query); $i++) {
+ if ($inSubstring == false) {
+ // Defines when we should start inserting values
+ if (substr ($query, $i, 9) == 'SUBSTRING') {
+ $inSubstring = true;
+ }
+ } else {
+ // Defines when we should stop inserting values
+ if (substr ($query, $i, 1) == ')') {
+ $inSubstring = false;
+ }
+ }
+
+ if (substr ($query, $i, 1) == '?') {
+ // We found a question mark
+ if ($inSubstring) {
+ $newQuery .= $input[$cArg];
+
+ //
+ // Remove from input array
+ //
+ array_splice ($input, $cArg, 1);
+ } else {
+ $newQuery .= substr ($query, $i, 1);
+ $cArg++;
+ }
+ } else {
+ $newQuery .= substr ($query, $i, 1);
+ }
+ }
+
+ // The global data we need
+ $name = OC_Config::getValue( "dbname", "owncloud" );
+ $host = OC_Config::getValue( "dbhost", "" );
+ $user = OC_Config::getValue( "dbuser", "" );
+ $pass = OC_Config::getValue( "dbpassword", "" );
+ if (strpos($host,':')) {
+ list($host, $port) = explode(':', $host, 2);
+ } else {
+ $port = false;
+ }
+ $opts = array();
+
+ if ($port) {
+ $dsn = 'sqlsrv:Server='.$host.','.$port.';Database='.$name;
+ } else {
+ $dsn = 'sqlsrv:Server='.$host.';Database='.$name;
+ }
+
+ $PDO = new PDO($dsn, $user, $pass, $opts);
+ $PDO->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
+ $PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+ $this->statement = $PDO->prepare($newQuery);
+
+ $this->lastArguments = $input;
+
+ return $input;
+ } catch (PDOException $e){
+ $entry = 'PDO DB Error: "'.$e->getMessage().'"<br />';
+ $entry .= 'Offending command was: '.$this->statement->queryString .'<br />';
+ $entry .= 'Input parameters: ' .print_r($input, true).'<br />';
+ $entry .= 'Stack trace: ' .$e->getTraceAsString().'<br />';
+ OC_Log::write('core', $entry, OC_Log::FATAL);
+ OC_User::setUserId(null);
+
+ // send http status 503
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ OC_Template::printErrorPage('Failed to connect to database');
+ die ($entry);
+ }
+ }
+
/**
* provide an alias for fetch
*/
diff --git a/lib/files.php b/lib/files.php
index b594b78c4b7..2433502444c 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -49,8 +49,9 @@ class OC_Files {
isset($_SERVER['MOD_X_ACCEL_REDIRECT_ENABLED'])) {
$xsendfile = true;
}
- if(strpos($files, ';')) {
- $files=explode(';', $files);
+
+ if (count($files) == 1) {
+ $files = $files[0];
}
if (is_array($files)) {
@@ -77,7 +78,13 @@ class OC_Files {
}
}
$zip->close();
- $name = basename($dir) . '.zip';
+ $basename = basename($dir);
+ if ($basename) {
+ $name = $basename . '.zip';
+ } else {
+ $name = 'owncloud.zip';
+ }
+
set_time_limit($executionTime);
} elseif (\OC\Files\Filesystem::is_dir($dir . '/' . $files)) {
self::validateZipDownload($dir, $files);
@@ -121,7 +128,7 @@ class OC_Files {
header('Content-Type: '.\OC\Files\Filesystem::getMimeType($filename));
header("Content-Length: ".\OC\Files\Filesystem::filesize($filename));
list($storage) = \OC\Files\Filesystem::resolvePath($filename);
- if ($storage instanceof \OC\File\Storage\Local) {
+ if ($storage instanceof \OC\Files\Storage\Local) {
self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
}
}
@@ -212,12 +219,18 @@ class OC_Files {
$zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
if ($zipLimit > 0) {
$totalsize = 0;
- if (is_array($files)) {
- foreach ($files as $file) {
- $totalsize += \OC\Files\Filesystem::filesize($dir . '/' . $file);
+ if(!is_array($files)) {
+ $files = array($files);
+ }
+ foreach ($files as $file) {
+ $path = $dir . '/' . $file;
+ if(\OC\Files\Filesystem::is_dir($path)) {
+ foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
+ $totalsize += $i['size'];
+ }
+ } else {
+ $totalsize += \OC\Files\Filesystem::filesize($path);
}
- } else {
- $totalsize += \OC\Files\Filesystem::filesize($dir . '/' . $files);
}
if ($totalsize > $zipLimit) {
$l = OC_L10N::get('lib');
diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php
index 3652dc7cf23..f288919df74 100644
--- a/lib/files/cache/cache.php
+++ b/lib/files/cache/cache.php
@@ -313,6 +313,9 @@ class Cache {
}
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*filecache` WHERE `fileid` = ?');
$query->execute(array($entry['fileid']));
+
+ $permissionsCache = new Permissions($this->storageId);
+ $permissionsCache->remove($entry['fileid']);
}
/**
@@ -500,8 +503,8 @@ 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');
- $query->execute(array($this->numericId));
- if ($row = $query->fetchRow()) {
+ $result = $query->execute(array($this->numericId));
+ if ($row = $result->fetchRow()) {
return $row['path'];
} else {
return false;
diff --git a/lib/files/cache/legacy.php b/lib/files/cache/legacy.php
index 6d1ffa7b40b..2b8689fcbda 100644
--- a/lib/files/cache/legacy.php
+++ b/lib/files/cache/legacy.php
@@ -51,12 +51,12 @@ class Legacy {
$this->cacheHasItems = false;
return false;
}
-
+
if ($result === false || property_exists($result, 'error_message_prefix')) {
$this->cacheHasItems = false;
return false;
- }
-
+ }
+
$this->cacheHasItems = (bool)$result->fetchRow();
return $this->cacheHasItems;
}
diff --git a/lib/files/cache/permissions.php b/lib/files/cache/permissions.php
index e1735831b94..a5c9c144054 100644
--- a/lib/files/cache/permissions.php
+++ b/lib/files/cache/permissions.php
@@ -17,10 +17,10 @@ class Permissions {
/**
* @param \OC\Files\Storage\Storage|string $storage
*/
- public function __construct($storage){
- if($storage instanceof \OC\Files\Storage\Storage) {
+ public function __construct($storage) {
+ if ($storage instanceof \OC\Files\Storage\Storage) {
$this->storageId = $storage->getId();
- }else{
+ } else {
$this->storageId = $storage;
}
}
@@ -52,10 +52,10 @@ class Permissions {
public function set($fileId, $user, $permissions) {
if (self::get($fileId, $user) !== -1) {
$query = \OC_DB::prepare('UPDATE `*PREFIX*permissions` SET `permissions` = ?'
- .' WHERE `user` = ? AND `fileid` = ?');
+ . ' WHERE `user` = ? AND `fileid` = ?');
} else {
$query = \OC_DB::prepare('INSERT INTO `*PREFIX*permissions`(`permissions`, `user`, `fileid`)'
- .' VALUES(?, ?,? )');
+ . ' VALUES(?, ?,? )');
}
$query->execute(array($permissions, $user, $fileId));
}
@@ -76,7 +76,7 @@ class Permissions {
$inPart = implode(', ', array_fill(0, count($fileIds), '?'));
$query = \OC_DB::prepare('SELECT `fileid`, `permissions` FROM `*PREFIX*permissions`'
- .' WHERE `fileid` IN (' . $inPart . ') AND `user` = ?');
+ . ' WHERE `fileid` IN (' . $inPart . ') AND `user` = ?');
$result = $query->execute($params);
$filePermissions = array();
while ($row = $result->fetchRow()) {
@@ -91,14 +91,19 @@ class Permissions {
* @param int $fileId
* @param string $user
*/
- public function remove($fileId, $user) {
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*permissions` WHERE `fileid` = ? AND `user` = ?');
- $query->execute(array($fileId, $user));
+ public function remove($fileId, $user = null) {
+ if (is_null($user)) {
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*permissions` WHERE `fileid` = ?');
+ $query->execute(array($fileId));
+ } else {
+ $query = \OC_DB::prepare('DELETE FROM `*PREFIX*permissions` WHERE `fileid` = ? AND `user` = ?');
+ $query->execute(array($fileId, $user));
+ }
}
public function removeMultiple($fileIds, $user) {
$query = \OC_DB::prepare('DELETE FROM `*PREFIX*permissions` WHERE `fileid` = ? AND `user` = ?');
- foreach($fileIds as $fileId){
+ foreach ($fileIds as $fileId) {
$query->execute(array($fileId, $user));
}
}
diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php
index 1fe4c584686..811d82d7437 100644
--- a/lib/files/cache/upgrade.php
+++ b/lib/files/cache/upgrade.php
@@ -64,7 +64,7 @@ class Upgrade {
* @param array $data the data for the new cache
*/
function insert($data) {
- if (!$this->inCache($data['storage'], $data['path_hash'])) {
+ if (!$this->inCache($data['storage'], $data['path_hash'], $data['id'])) {
$insertQuery = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`
( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` )
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
@@ -78,11 +78,12 @@ class Upgrade {
/**
* @param string $storage
* @param string $pathHash
+ * @param string $id
* @return bool
*/
- function inCache($storage, $pathHash) {
- $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `path_hash` = ?');
- $result = $query->execute(array($storage, $pathHash));
+ function inCache($storage, $pathHash, $id) {
+ $query = \OC_DB::prepare('SELECT `fileid` FROM `*PREFIX*filecache` WHERE (`storage` = ? AND `path_hash` = ?) OR `fileid` = ?');
+ $result = $query->execute(array($storage, $pathHash, $id));
return (bool)$result->fetchRow();
}
diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php
index 401ee8417e5..40fef674a00 100644
--- a/lib/files/filesystem.php
+++ b/lib/files/filesystem.php
@@ -221,11 +221,16 @@ class Filesystem {
$root = \OC_User::getHome($user);
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
-
+ $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
+
+ //move config file to it's new position
+ if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
+ rename(\OC::$SERVERROOT . '/config/mount.json', $datadir . '/mount.json');
+ }
// Load system mount points
- 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);
+ if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($datadir . '/mount.json')) {
+ if (is_file($datadir . '/mount.json')) {
+ $mountConfig = json_decode(file_get_contents($datadir . '/mount.json'), true);
} elseif (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
$mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
}
diff --git a/lib/files/mount.php b/lib/files/mount.php
index 6e99d8eabb4..1c9382d78e7 100644
--- a/lib/files/mount.php
+++ b/lib/files/mount.php
@@ -176,10 +176,12 @@ class Mount {
}
/**
+ * Find mounts by storage id
+ *
* @param string $id
- * @return \OC\Files\Storage\Storage[]
+ * @return Mount[]
*/
- public static function findById($id) {
+ public static function findByStorageId($id) {
if (strlen($id) > 64) {
$id = md5($id);
}
@@ -191,4 +193,24 @@ class Mount {
}
return $result;
}
+
+ /**
+ * Find mounts by numeric storage id
+ *
+ * @param string $id
+ * @return Mount
+ */
+ public static function findByNumericId($id) {
+ $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?');
+ $result = $query->execute(array($id))->fetchOne();
+ if ($result) {
+ $id = $result;
+ foreach (self::$mounts as $mount) {
+ if ($mount->getStorageId() === $id) {
+ return $mount;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php
index 4e7a73e5d4a..8aa227ec0b7 100644
--- a/lib/files/storage/common.php
+++ b/lib/files/storage/common.php
@@ -22,83 +22,104 @@ namespace OC\Files\Storage;
abstract class Common implements \OC\Files\Storage\Storage {
- public function __construct($parameters) {}
+ public function __construct($parameters) {
+ }
+
public function is_dir($path) {
- return $this->filetype($path)=='dir';
+ return $this->filetype($path) == 'dir';
}
+
public function is_file($path) {
- return $this->filetype($path)=='file';
+ return $this->filetype($path) == 'file';
}
+
public function filesize($path) {
- if($this->is_dir($path)) {
- return 0;//by definition
- }else{
+ if ($this->is_dir($path)) {
+ return 0; //by definition
+ } else {
$stat = $this->stat($path);
- return $stat['size'];
+ if (isset($stat['size'])) {
+ return $stat['size'];
+ } else {
+ return 0;
+ }
}
}
+
public function isCreatable($path) {
if ($this->is_dir($path) && $this->isUpdatable($path)) {
return true;
}
return false;
}
+
public function isDeletable($path) {
return $this->isUpdatable($path);
}
+
public function isSharable($path) {
return $this->isReadable($path);
}
- public function getPermissions($path){
+
+ public function getPermissions($path) {
$permissions = 0;
- if($this->isCreatable($path)) {
+ if ($this->isCreatable($path)) {
$permissions |= \OCP\PERMISSION_CREATE;
}
- if($this->isReadable($path)) {
+ if ($this->isReadable($path)) {
$permissions |= \OCP\PERMISSION_READ;
}
- if($this->isUpdatable($path)) {
+ if ($this->isUpdatable($path)) {
$permissions |= \OCP\PERMISSION_UPDATE;
}
- if($this->isDeletable($path)) {
+ if ($this->isDeletable($path)) {
$permissions |= \OCP\PERMISSION_DELETE;
}
- if($this->isSharable($path)) {
+ if ($this->isSharable($path)) {
$permissions |= \OCP\PERMISSION_SHARE;
}
return $permissions;
}
+
public function filemtime($path) {
$stat = $this->stat($path);
- return $stat['mtime'];
+ if (isset($stat['mtime'])) {
+ return $stat['mtime'];
+ } else {
+ return 0;
+ }
}
+
public function file_get_contents($path) {
$handle = $this->fopen($path, "r");
- if(!$handle) {
+ if (!$handle) {
return false;
}
- $size=$this->filesize($path);
- if($size==0) {
+ $size = $this->filesize($path);
+ if ($size == 0) {
return '';
}
return fread($handle, $size);
}
+
public function file_put_contents($path, $data) {
$handle = $this->fopen($path, "w");
return fwrite($handle, $data);
}
+
public function rename($path1, $path2) {
- if($this->copy($path1, $path2)) {
+ if ($this->copy($path1, $path2)) {
return $this->unlink($path1);
- }else{
+ } else {
return false;
}
}
+
public function copy($path1, $path2) {
- $source=$this->fopen($path1, 'r');
- $target=$this->fopen($path2, 'w');
- $count=\OC_Helper::streamCopy($source, $target);
- return $count>0;
+ $source = $this->fopen($path1, 'r');
+ $target = $this->fopen($path2, 'w');
+ list($count, $result) = \OC_Helper::streamCopy($source, $target);
+ return $result;
}
/**
@@ -110,29 +131,30 @@ abstract class Common implements \OC\Files\Storage\Storage {
* @note By default the directory specified by $directory will be
* deleted together with its contents. To avoid this set $empty to true
*/
- public function deleteAll( $directory, $empty = false ) {
+ public function deleteAll($directory, $empty = false) {
$directory = trim($directory, '/');
- if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory )
- || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) {
+ if (!$this->file_exists(\OCP\USER::getUser() . '/' . $directory)
+ || !$this->is_dir(\OCP\USER::getUser() . '/' . $directory)
+ ) {
return false;
- } elseif( !$this->isReadable( \OCP\USER::getUser() . '/' . $directory ) ) {
+ } elseif (!$this->isReadable(\OCP\USER::getUser() . '/' . $directory)) {
return false;
} else {
- $directoryHandle = $this->opendir( \OCP\USER::getUser() . '/' . $directory );
- while ( $contents = readdir( $directoryHandle ) ) {
- if ( $contents != '.' && $contents != '..') {
+ $directoryHandle = $this->opendir(\OCP\USER::getUser() . '/' . $directory);
+ while ($contents = readdir($directoryHandle)) {
+ if ($contents != '.' && $contents != '..') {
$path = $directory . "/" . $contents;
- if ( $this->is_dir( $path ) ) {
- $this->deleteAll( $path );
+ if ($this->is_dir($path)) {
+ $this->deleteAll($path);
} else {
- $this->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir
+ $this->unlink(\OCP\USER::getUser() . '/' . $path); // TODO: make unlink use same system path as is_dir
}
}
}
//$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV
- if ( $empty == false ) {
- if ( !$this->rmdir( $directory ) ) {
+ if ($empty == false) {
+ if (!$this->rmdir($directory)) {
return false;
}
}
@@ -140,88 +162,95 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
}
+
public function getMimeType($path) {
- if(!$this->file_exists($path)) {
+ if (!$this->file_exists($path)) {
return false;
}
- if($this->is_dir($path)) {
+ if ($this->is_dir($path)) {
return 'httpd/unix-directory';
}
- $source=$this->fopen($path, 'r');
- if(!$source) {
+ $source = $this->fopen($path, 'r');
+ if (!$source) {
return false;
}
- $head=fread($source, 8192);//8kb should suffice to determine a mimetype
- if($pos=strrpos($path, '.')) {
- $extension=substr($path, $pos);
- }else{
- $extension='';
+ $head = fread($source, 8192); //8kb should suffice to determine a mimetype
+ if ($pos = strrpos($path, '.')) {
+ $extension = substr($path, $pos);
+ } else {
+ $extension = '';
}
- $tmpFile=\OC_Helper::tmpFile($extension);
+ $tmpFile = \OC_Helper::tmpFile($extension);
file_put_contents($tmpFile, $head);
- $mime=\OC_Helper::getMimeType($tmpFile);
+ $mime = \OC_Helper::getMimeType($tmpFile);
unlink($tmpFile);
return $mime;
}
+
public function hash($type, $path, $raw = false) {
- $tmpFile=$this->getLocalFile($path);
- $hash=hash($type, $tmpFile, $raw);
+ $tmpFile = $this->getLocalFile($path);
+ $hash = hash($type, $tmpFile, $raw);
unlink($tmpFile);
return $hash;
}
+
public function search($query) {
return $this->searchInDir($query);
}
+
public function getLocalFile($path) {
return $this->toTmpFile($path);
}
- private function toTmpFile($path) {//no longer in the storage api, still useful here
- $source=$this->fopen($path, 'r');
- if(!$source) {
+
+ private function toTmpFile($path) { //no longer in the storage api, still useful here
+ $source = $this->fopen($path, 'r');
+ if (!$source) {
return false;
}
- if($pos=strrpos($path, '.')) {
- $extension=substr($path, $pos);
- }else{
- $extension='';
+ if ($pos = strrpos($path, '.')) {
+ $extension = substr($path, $pos);
+ } else {
+ $extension = '';
}
- $tmpFile=\OC_Helper::tmpFile($extension);
- $target=fopen($tmpFile, 'w');
+ $tmpFile = \OC_Helper::tmpFile($extension);
+ $target = fopen($tmpFile, 'w');
\OC_Helper::streamCopy($source, $target);
return $tmpFile;
}
+
public function getLocalFolder($path) {
- $baseDir=\OC_Helper::tmpFolder();
+ $baseDir = \OC_Helper::tmpFolder();
$this->addLocalFolder($path, $baseDir);
return $baseDir;
}
+
private function addLocalFolder($path, $target) {
- if($dh=$this->opendir($path)) {
- while($file=readdir($dh)) {
- if($file!=='.' and $file!=='..') {
- if($this->is_dir($path.'/'.$file)) {
- mkdir($target.'/'.$file);
- $this->addLocalFolder($path.'/'.$file, $target.'/'.$file);
- }else{
- $tmp=$this->toTmpFile($path.'/'.$file);
- rename($tmp, $target.'/'.$file);
+ if ($dh = $this->opendir($path)) {
+ while ($file = readdir($dh)) {
+ if ($file !== '.' and $file !== '..') {
+ if ($this->is_dir($path . '/' . $file)) {
+ mkdir($target . '/' . $file);
+ $this->addLocalFolder($path . '/' . $file, $target . '/' . $file);
+ } else {
+ $tmp = $this->toTmpFile($path . '/' . $file);
+ rename($tmp, $target . '/' . $file);
}
}
}
}
}
- protected function searchInDir($query, $dir='') {
- $files=array();
- $dh=$this->opendir($dir);
- if($dh) {
- while($item=readdir($dh)) {
+ protected function searchInDir($query, $dir = '') {
+ $files = array();
+ $dh = $this->opendir($dir);
+ if ($dh) {
+ while ($item = readdir($dh)) {
if ($item == '.' || $item == '..') continue;
- if(strstr(strtolower($item), strtolower($query))!==false) {
- $files[]=$dir.'/'.$item;
+ if (strstr(strtolower($item), strtolower($query)) !== false) {
+ $files[] = $dir . '/' . $item;
}
- if($this->is_dir($dir.'/'.$item)) {
- $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item));
+ if ($this->is_dir($dir . '/' . $item)) {
+ $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item));
}
}
}
@@ -230,32 +259,34 @@ abstract class Common implements \OC\Files\Storage\Storage {
/**
* check if a file or folder has been updated since $time
+ *
* @param string $path
* @param int $time
* @return bool
*/
public function hasUpdated($path, $time) {
- return $this->filemtime($path)>$time;
+ return $this->filemtime($path) > $time;
}
- public function getCache($path=''){
+ public function getCache($path = '') {
return new \OC\Files\Cache\Cache($this);
}
- public function getScanner($path=''){
+ public function getScanner($path = '') {
return new \OC\Files\Cache\Scanner($this);
}
- public function getPermissionsCache($path=''){
+ public function getPermissionsCache($path = '') {
return new \OC\Files\Cache\Permissions($this);
}
- public function getWatcher($path=''){
+ public function getWatcher($path = '') {
return new \OC\Files\Cache\Watcher($this);
}
/**
* get the owner of a path
+ *
* @param string $path The path to get the owner
* @return string uid or false
*/
@@ -269,19 +300,20 @@ abstract class Common implements \OC\Files\Storage\Storage {
* @param string $path
* @return string
*/
- public function getETag($path){
+ public function getETag($path) {
$ETagFunction = \OC_Connector_Sabre_Node::$ETagFunction;
- if($ETagFunction) {
+ if ($ETagFunction) {
$hash = call_user_func($ETagFunction, $path);
return $hash;
- }else{
+ } else {
return uniqid();
}
}
-
+
/**
* clean a path, i.e. remove all redundant '.' and '..'
* making sure that it can't point to higher than '/'
+ *
* @param $path The path to clean
* @return string cleaned path
*/
@@ -289,7 +321,7 @@ abstract class Common implements \OC\Files\Storage\Storage {
if (strlen($path) == 0 or $path[0] != '/') {
$path = '/' . $path;
}
-
+
$output = array();
foreach (explode('/', $path) as $chunk) {
if ($chunk == '..') {
@@ -302,12 +334,20 @@ abstract class Common implements \OC\Files\Storage\Storage {
return implode('/', $output);
}
+ public function test() {
+ if ($this->stat('')) {
+ return true;
+ }
+ return false;
+ }
+
/**
* get the free space in the storage
+ *
* @param $path
* return int
*/
- public function free_space($path){
+ public function free_space($path) {
return \OC\Files\FREE_SPACE_UNKNOWN;
}
}
diff --git a/lib/files/view.php b/lib/files/view.php
index 9ac08c98082..19f33ad64a2 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -199,7 +199,7 @@ class View {
@ob_end_clean();
$handle = $this->fopen($path, 'rb');
if ($handle) {
- $chunkSize = 8192; // 8 MB chunks
+ $chunkSize = 8192; // 8 kB chunks
while (!feof($handle)) {
echo fread($handle, $chunkSize);
flush();
@@ -245,7 +245,14 @@ class View {
if (!is_null($mtime) and !is_numeric($mtime)) {
$mtime = strtotime($mtime);
}
- return $this->basicOperation('touch', $path, array('write'), $mtime);
+
+ $hooks = array('touch');
+
+ if (!$this->file_exists($path)) {
+ $hooks[] = 'write';
+ }
+
+ return $this->basicOperation('touch', $path, $hooks, $mtime);
}
public function file_get_contents($path) {
@@ -285,7 +292,7 @@ class View {
}
$target = $this->fopen($path, 'w');
if ($target) {
- $count = \OC_Helper::streamCopy($data, $target);
+ list ($count, $result) = \OC_Helper::streamCopy($data, $target);
fclose($target);
fclose($data);
if ($this->fakeRoot == Filesystem::getRoot()) {
@@ -303,7 +310,7 @@ class View {
);
}
\OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count);
- return $count > 0;
+ return $result;
} else {
return false;
}
@@ -361,10 +368,9 @@ class View {
} else {
$source = $this->fopen($path1 . $postFix1, 'r');
$target = $this->fopen($path2 . $postFix2, 'w');
- $count = \OC_Helper::streamCopy($source, $target);
+ list($count, $result) = \OC_Helper::streamCopy($source, $target);
list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1);
$storage1->unlink($internalPath1);
- $result = $count > 0;
}
if ($this->fakeRoot == Filesystem::getRoot()) {
\OC_Hook::emit(
@@ -444,7 +450,7 @@ class View {
} else {
$source = $this->fopen($path1 . $postFix1, 'r');
$target = $this->fopen($path2 . $postFix2, 'w');
- $result = \OC_Helper::streamCopy($source, $target);
+ list($count, $result) = \OC_Helper::streamCopy($source, $target);
}
if ($this->fakeRoot == Filesystem::getRoot()) {
\OC_Hook::emit(
@@ -597,6 +603,7 @@ class View {
if ($path == null) {
return false;
}
+
$run = $this->runHooks($hooks, $path);
list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
if ($run and $storage) {
@@ -961,7 +968,7 @@ class View {
*/
public function getPath($id) {
list($storage, $internalPath) = Cache\Cache::getById($id);
- $mounts = Mount::findById($storage);
+ $mounts = Mount::findByStorageId($storage);
foreach ($mounts as $mount) {
/**
* @var \OC\Files\Mount $mount
diff --git a/lib/group.php b/lib/group.php
index 8c06ddc0fd0..d1a830730b7 100644
--- a/lib/group.php
+++ b/lib/group.php
@@ -286,31 +286,37 @@ class OC_Group {
}
return $users;
}
-
- /**
- * @brief get a list of all display names in a group
- * @returns array with display names (value) and user ids(key)
- */
- public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $displayNames=array();
- foreach(self::$_usedBackends as $backend) {
- $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames);
- }
- return $displayNames;
+
+ /**
+ * @brief get a list of all display names in a group
+ * @returns array with display names (value) and user ids(key)
+ */
+ public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames=array();
+ foreach(self::$_usedBackends as $backend) {
+ if($backend->implementsActions(OC_GROUP_BACKEND_GET_DISPLAYNAME)) {
+ $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames);
+ } else {
+ $users = $backend->usersInGroup($gid, $search, $limit, $offset);
+ $names = array_combine($users, $users);
+ $displayNames = array_merge($names, $displayNames);
+ }
+ }
+ return $displayNames;
}
-
- /**
- * @brief get a list of all display names in several groups
- * @param array $gids
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array with display names (Key) user ids (value)
- */
- public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
+
+ /**
+ * @brief get a list of all display names in several groups
+ * @param array $gids
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (Key) user ids (value)
+ */
+ public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) {
$displayNames = array();
- foreach ($gids as $gid) {
- // TODO Need to apply limits to groups as total
+ foreach ($gids as $gid) {
+ // TODO Need to apply limits to groups as total
$diff = array_diff(
self::displayNamesInGroup($gid, $search, $limit, $offset),
$displayNames
@@ -318,7 +324,7 @@ class OC_Group {
if ($diff) {
$displayNames = array_merge($diff, $displayNames);
}
- }
- return $displayNames;
+ }
+ return $displayNames;
}
}
diff --git a/lib/group/backend.php b/lib/group/backend.php
index 4f6570c3be3..2e17b5d0b7f 100644
--- a/lib/group/backend.php
+++ b/lib/group/backend.php
@@ -33,6 +33,7 @@ define('OC_GROUP_BACKEND_CREATE_GROUP', 0x00000001);
define('OC_GROUP_BACKEND_DELETE_GROUP', 0x00000010);
define('OC_GROUP_BACKEND_ADD_TO_GROUP', 0x00000100);
define('OC_GROUP_BACKEND_REMOVE_FROM_GOUP', 0x00001000);
+define('OC_GROUP_BACKEND_GET_DISPLAYNAME', 0x00010000);
/**
* Abstract base class for user management
@@ -43,6 +44,7 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
OC_GROUP_BACKEND_DELETE_GROUP => 'deleteGroup',
OC_GROUP_BACKEND_ADD_TO_GROUP => 'addToGroup',
OC_GROUP_BACKEND_REMOVE_FROM_GOUP => 'removeFromGroup',
+ OC_GROUP_BACKEND_GET_DISPLAYNAME => 'displayNamesInGroup',
);
/**
@@ -133,23 +135,23 @@ abstract class OC_Group_Backend implements OC_Group_Interface {
public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
return array();
}
-
- /**
- * @brief get a list of all display names in a group
- * @param string $gid
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array with display names (value) and user ids (key)
- */
- public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $displayNames = '';
- $users = $this->usersInGroup($gid, $search, $limit, $offset);
- foreach ( $users as $user ) {
- $DisplayNames[$user] = $user;
- }
-
- return $DisplayNames;
+
+ /**
+ * @brief get a list of all display names in a group
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (value) and user ids (key)
+ */
+ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames = array();
+ $users = $this->usersInGroup($gid, $search, $limit, $offset);
+ foreach ($users as $user) {
+ $displayNames[$user] = $user;
+ }
+
+ return $displayNames;
}
}
diff --git a/lib/group/database.php b/lib/group/database.php
index 93dc05c53a1..d0974685ff6 100644
--- a/lib/group/database.php
+++ b/lib/group/database.php
@@ -210,17 +210,17 @@ class OC_Group_Database extends OC_Group_Backend {
}
return $users;
}
-
- /**
- * @brief get a list of all display names in a group
- * @param string $gid
- * @param string $search
- * @param int $limit
- * @param int $offset
- * @return array with display names (value) and user ids (key)
- */
- public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
- $displayNames = '';
+
+ /**
+ * @brief get a list of all display names in a group
+ * @param string $gid
+ * @param string $search
+ * @param int $limit
+ * @param int $offset
+ * @return array with display names (value) and user ids (key)
+ */
+ public function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) {
+ $displayNames = array();
$stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname`'
.' FROM `*PREFIX*users`'
@@ -228,12 +228,12 @@ class OC_Group_Database extends OC_Group_Backend {
.' WHERE `gid` = ? AND `*PREFIX*group_user`.`uid` LIKE ?',
$limit,
$offset);
- $result = $stmt->execute(array($gid, $search.'%'));
- $users = array();
+ $result = $stmt->execute(array($gid, $search.'%'));
+ $users = array();
while ($row = $result->fetchRow()) {
- $displayName = trim($row['displayname'], ' ');
- $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
- }
- return $displayNames;
+ $displayName = trim($row['displayname'], ' ');
+ $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName;
+ }
+ return $displayNames;
}
}
diff --git a/lib/helper.php b/lib/helper.php
index add5c66e7be..41985ca57a7 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -513,11 +513,16 @@ class OC_Helper {
if(!$source or !$target) {
return false;
}
- $count=0;
+ $result = true;
+ $count = 0;
while(!feof($source)) {
- $count+=fwrite($target, fread($source, 8192));
+ if ( ( $c = fwrite($target, fread($source, 8192)) ) === false) {
+ $result = false;
+ } else {
+ $count += $c;
+ }
}
- return $count;
+ return array($count, $result);
}
/**
diff --git a/lib/hook.php b/lib/hook.php
index 554381251d6..8516cf0dcff 100644
--- a/lib/hook.php
+++ b/lib/hook.php
@@ -20,23 +20,23 @@ class OC_Hook{
* TODO: write example
*/
static public function connect( $signalclass, $signalname, $slotclass, $slotname ) {
- // If we're trying to connect to an emitting class that isn't
+ // If we're trying to connect to an emitting class that isn't
// yet registered, register it
if( !array_key_exists( $signalclass, self::$registered )) {
self::$registered[$signalclass] = array();
}
- // If we're trying to connect to an emitting method that isn't
+ // If we're trying to connect to an emitting method that isn't
// yet registered, register it with the emitting class
- if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
+ if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
self::$registered[$signalclass][$signalname] = array();
}
-
+
// Connect the hook handler to the requested emitter
self::$registered[$signalclass][$signalname][] = array(
"class" => $slotclass,
"name" => $slotname
);
-
+
// No chance for failure ;-)
return true;
}
@@ -53,19 +53,19 @@ class OC_Hook{
* TODO: write example
*/
static public function emit( $signalclass, $signalname, $params = array()) {
-
+
// Return false if no hook handlers are listening to this
// emitting class
if( !array_key_exists( $signalclass, self::$registered )) {
return false;
}
-
+
// Return false if no hook handlers are listening to this
// emitting method
if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
return false;
}
-
+
// Call all slots
foreach( self::$registered[$signalclass][$signalname] as $i ) {
try {
diff --git a/lib/image.php b/lib/image.php
index dc1c6df85ae..c1b187608a6 100644
--- a/lib/image.php
+++ b/lib/image.php
@@ -35,7 +35,13 @@ class OC_Image {
* @returns string The mime type if the it could be determined, otherwise an empty string.
*/
static public function getMimeTypeForFile($filepath) {
- $imagetype = exif_imagetype($filepath);
+ // exif_imagetype throws "read error!" if file is less than 12 byte
+ if (filesize($filepath) > 11) {
+ $imagetype = exif_imagetype($filepath);
+ }
+ else {
+ $imagetype = false;
+ }
return $imagetype ? image_type_to_mime_type($imagetype) : '';
}
@@ -385,7 +391,8 @@ class OC_Image {
* @returns An image resource or false on error
*/
public function loadFromFile($imagepath=false) {
- if(!is_file($imagepath) || !file_exists($imagepath) || !is_readable($imagepath)) {
+ // exif_imagetype throws "read error!" if file is less than 12 byte
+ if(!is_file($imagepath) || !file_exists($imagepath) || filesize($imagepath) < 12 || !is_readable($imagepath)) {
// Debug output disabled because this method is tried before loadFromBase64?
OC_Log::write('core', 'OC_Image->loadFromFile, couldn\'t load: '.$imagepath, OC_Log::DEBUG);
return false;
@@ -765,7 +772,7 @@ class OC_Image {
imagealphablending($process, false);
imagesavealpha($process, true);
}
-
+
imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height);
if ($process == false) {
OC_Log::write('core',
diff --git a/lib/l10n/bg_BG.php b/lib/l10n/bg_BG.php
index d80e03608a2..d32e2aadfc5 100644
--- a/lib/l10n/bg_BG.php
+++ b/lib/l10n/bg_BG.php
@@ -21,6 +21,18 @@
"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, не можете да ползвате точки в името на базата от данни",
+"PostgreSQL username and/or password not valid" => "Невалидно PostgreSQL потребителско име и/или парола",
+"You need to enter either an existing account or the administrator." => "Необходимо е да влезете в всъществуващ акаунт или като администратора",
+"Oracle username and/or password not valid" => "Невалидно Oracle потребителско име и/или парола",
+"MySQL username and/or password not valid" => "Невалидно MySQL потребителско име и/или парола",
+"DB Error: \"%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.",
+"MS SQL username and/or password not valid: %s" => "Невалидно MS SQL потребителско име и/или парола: %s",
+"Please double check the <a href='%s'>installation guides</a>." => "Моля направете повторна справка с <a href='%s'>ръководството за инсталиране</a>.",
"seconds ago" => "преди секунди",
"1 minute ago" => "преди 1 минута",
"%d minutes ago" => "преди %d минути",
diff --git a/lib/l10n/ca.php b/lib/l10n/ca.php
index 3e3938aa6cb..108bb5c09be 100644
--- a/lib/l10n/ca.php
+++ b/lib/l10n/ca.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "L'usuari MySQL '%s'@'%%' ja existeix",
"Drop this user from MySQL." => "Elimina aquest usuari de MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "L'ordre en conflicte és: \"%s\", nom: %s, contrasenya: %s",
+"MS SQL username and/or password not valid: %s" => "Nom d'usuari i/o contrasenya MS SQL no vàlids: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "El servidor web no està configurat correctament per permetre la sincronització de fitxers perquè la interfície WebDAV sembla no funcionar correctament.",
"Please double check the <a href='%s'>installation guides</a>." => "Comproveu les <a href='%s'>guies d'instal·lació</a>.",
"seconds ago" => "segons enrere",
diff --git a/lib/l10n/cs_CZ.php b/lib/l10n/cs_CZ.php
index d99f259cb0f..d9ec3d82cf7 100644
--- a/lib/l10n/cs_CZ.php
+++ b/lib/l10n/cs_CZ.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "Uživatel '%s'@'%%' již v MySQL existuje",
"Drop this user from MySQL." => "Zahodit uživatele z MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Podezřelý příkaz byl: \"%s\", jméno: %s, heslo: %s",
+"MS SQL username and/or password not valid: %s" => "Uživatelské jméno, či heslo MSSQL není platné: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Váš webový server není správně nastaven pro umožnění synchronizace, protože rozhraní WebDAV je rozbité.",
"Please double check the <a href='%s'>installation guides</a>." => "Zkonzultujte, prosím, <a href='%s'>průvodce instalací</a>.",
"seconds ago" => "před vteřinami",
diff --git a/lib/l10n/da.php b/lib/l10n/da.php
index e61fba30ff3..38ccbbe8e21 100644
--- a/lib/l10n/da.php
+++ b/lib/l10n/da.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQL brugeren '%s'@'%%' eksisterer allerede.",
"Drop this user from MySQL." => "Slet denne bruger fra MySQL",
"Offending command was: \"%s\", name: %s, password: %s" => "Fejlende kommando var: \"%s\", navn: %s, password: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL brugernavn og/eller adgangskode ikke er gyldigt: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Din webserver er endnu ikke sat op til at tillade fil synkronisering fordi WebDAV grænsefladen virker ødelagt.",
"Please double check the <a href='%s'>installation guides</a>." => "Dobbelttjek venligst <a href='%s'>installations vejledningerne</a>.",
"seconds ago" => "sekunder siden",
diff --git a/lib/l10n/de.php b/lib/l10n/de.php
index 87b0b29469c..3c2069d4637 100644
--- a/lib/l10n/de.php
+++ b/lib/l10n/de.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQL Benutzer '%s'@'%%' existiert bereits",
"Drop this user from MySQL." => "Lösche diesen Benutzer aus MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Fehlerhafter Befehl war: \"%s\", Name: %s, Passwort: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL Benutzername und/oder Password ungültig: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Dein Web-Server ist noch nicht für Datei-Synchronisation bereit, weil die WebDAV-Schnittstelle vermutlich defekt ist.",
"Please double check the <a href='%s'>installation guides</a>." => "Bitte prüfe die <a href='%s'>Instalationsanleitungen</a>.",
"seconds ago" => "Gerade eben",
diff --git a/lib/l10n/de_DE.php b/lib/l10n/de_DE.php
index d04c691f7ec..9978cdf8b31 100644
--- a/lib/l10n/de_DE.php
+++ b/lib/l10n/de_DE.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQL Benutzer '%s'@'%%' existiert bereits",
"Drop this user from MySQL." => "Lösche diesen Benutzer aus MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Fehlerhafter Befehl war: \"%s\", Name: %s, Passwort: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL Benutzername und/oder Passwort ungültig: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ihr Web-Server ist noch nicht für Datei-Synchronisation bereit, weil die WebDAV-Schnittstelle vermutlich defekt ist.",
"Please double check the <a href='%s'>installation guides</a>." => "Bitte prüfen Sie die <a href='%s'>Instalationsanleitungen</a>.",
"seconds ago" => "Gerade eben",
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index e2e86edc4da..c17a33dfee1 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -19,7 +19,11 @@
"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 μάλλον δεν χρησιμοποιείτε τελείες στο όνομα της βάσης δεδομένων",
"PostgreSQL username and/or password not valid" => "Μη έγκυρος χρήστης και/ή συνθηματικό της PostgreSQL",
+"You need to enter either an existing account or the administrator." => "Χρειάζεται να εισάγετε είτε έναν υπάρχον λογαριασμό ή του διαχειριστή.",
"Oracle username and/or password not valid" => "Μη έγκυρος χρήστης και/ή συνθηματικό της Oracle",
"MySQL username and/or password not valid" => "Μη έγκυρος χρήστης και/ή συνθηματικό της MySQL",
"DB Error: \"%s\"" => "Σφάλμα Βάσης Δεδομένων: \"%s\"",
@@ -41,7 +45,7 @@
"%d months ago" => "%d μήνες πριν",
"last year" => "τον προηγούμενο χρόνο",
"years ago" => "χρόνια πριν",
-"%s is available. Get <a href=\"%s\">more information</a>" => "%s είναι διαθέσιμα. Δείτε <a href=\"%s\">περισσότερες πληροφορίες</a>",
+"%s is available. Get <a href=\"%s\">more information</a>" => "%s είναι διαθέσιμο. Δείτε <a href=\"%s\">περισσότερες πληροφορίες</a>",
"up to date" => "ενημερωμένο",
"updates check is disabled" => "ο έλεγχος ενημερώσεων είναι απενεργοποιημένος",
"Could not find category \"%s\"" => "Αδυναμία εύρεσης κατηγορίας \"%s\""
diff --git a/lib/l10n/es.php b/lib/l10n/es.php
index f3b03b56652..37b15a375c4 100644
--- a/lib/l10n/es.php
+++ b/lib/l10n/es.php
@@ -16,6 +16,25 @@
"Files" => "Archivos",
"Text" => "Texto",
"Images" => "Imágenes",
+"Set an admin username." => "Configurar un nombre de usuario del administrador",
+"Set an admin password." => "Configurar la contraseña del administrador.",
+"Specify a data folder." => "Especificar la carpeta de datos.",
+"%s enter the database username." => "%s ingresar el usuario de la base de datos.",
+"%s enter the database name." => "%s ingresar el nombre de la base de datos",
+"%s you may not use dots in the database name" => "%s no se puede utilizar puntos en el nombre de la base de datos",
+"%s set the database host." => "%s ingresar el host de la base de datos.",
+"PostgreSQL username and/or password not valid" => "Usuario y/o contraseña de PostgreSQL no válidos",
+"You need to enter either an existing account or the administrator." => "Tiene que ingresar una cuenta existente o la del administrador.",
+"Oracle username and/or password not valid" => "Usuario y/o contraseña de Oracle no válidos",
+"MySQL username and/or password not valid" => "Usuario y/o contraseña de MySQL no válidos",
+"DB Error: \"%s\"" => "Error BD: \"%s\"",
+"Offending command was: \"%s\"" => "Comando infractor: \"%s\"",
+"MySQL user '%s'@'localhost' exists already." => "Usuario MySQL '%s'@'localhost' ya existe.",
+"Drop this user from MySQL" => "Eliminar este usuario de MySQL",
+"MySQL user '%s'@'%%' already exists" => "Usuario MySQL '%s'@'%%' ya existe",
+"Drop this user from MySQL." => "Eliminar este usuario de MySQL.",
+"Offending command was: \"%s\", name: %s, password: %s" => "Comando infractor: \"%s\", nombre: %s, contraseña: %s",
+"MS SQL username and/or password not valid: %s" => "Usuario y/o contraseña de MS SQL no válidos: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Su servidor web aún no está configurado adecuadamente para permitir sincronización de archivos ya que la interfaz WebDAV parece no estar funcionando.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, vuelva a comprobar las <a href='%s'>guías de instalación</a>.",
"seconds ago" => "hace segundos",
diff --git a/lib/l10n/es_AR.php b/lib/l10n/es_AR.php
index cfe90f6bc1b..ff3d47285fc 100644
--- a/lib/l10n/es_AR.php
+++ b/lib/l10n/es_AR.php
@@ -34,6 +34,7 @@
"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\"",
+"MS SQL username and/or password not valid: %s" => "Nombre de usuario y contraseña de MS SQL no son válidas: %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/eu.php b/lib/l10n/eu.php
index 97eb6511198..36eb397e425 100644
--- a/lib/l10n/eu.php
+++ b/lib/l10n/eu.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQL '%s'@'%%' erabiltzailea dagoeneko existitzen da",
"Drop this user from MySQL." => "Ezabatu erabiltzaile hau MySQLtik.",
"Offending command was: \"%s\", name: %s, password: %s" => "Errorea komando honek sortu du: \"%s\", izena: %s, pasahitza: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL erabiltzaile izena edota pasahitza ez dira egokiak: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Zure web zerbitzaria ez dago oraindik ongi konfiguratuta fitxategien sinkronizazioa egiteko, WebDAV interfazea ongi ez dagoela dirudi.",
"Please double check the <a href='%s'>installation guides</a>." => "Mesedez begiratu <a href='%s'>instalazio gidak</a>.",
"seconds ago" => "orain dela segundu batzuk",
diff --git a/lib/l10n/fi_FI.php b/lib/l10n/fi_FI.php
index c3ff3e9a2bf..89a584d389d 100644
--- a/lib/l10n/fi_FI.php
+++ b/lib/l10n/fi_FI.php
@@ -19,12 +19,16 @@
"Set an admin username." => "Aseta ylläpitäjän käyttäjätunnus.",
"Set an admin password." => "Aseta ylläpitäjän salasana.",
"Specify a data folder." => "Määritä datakansio.",
+"%s enter the database username." => "%s anna tietokannan käyttäjätunnus.",
+"%s enter the database name." => "%s anna tietokannan nimi.",
+"%s you may not use dots in the database name" => "%s et voi käyttää pisteitä tietokannan nimessä",
"PostgreSQL username and/or password not valid" => "PostgreSQL:n käyttäjätunnus ja/tai salasana on väärin",
"Oracle username and/or password not valid" => "Oraclen käyttäjätunnus ja/tai salasana on väärin",
"MySQL username and/or password not valid" => "MySQL:n käyttäjätunnus ja/tai salasana on väärin",
"DB Error: \"%s\"" => "Tietokantavirhe: \"%s\"",
"MySQL user '%s'@'localhost' exists already." => "MySQL-käyttäjä '%s'@'localhost' on jo olemassa.",
"MySQL user '%s'@'%%' already exists" => "MySQL-käyttäjä '%s'@'%%' on jo olemassa",
+"MS SQL username and/or password not valid: %s" => "MS SQL -käyttäjätunnus ja/tai -salasana on väärin: %s",
"Please double check the <a href='%s'>installation guides</a>." => "Lue tarkasti <a href='%s'>asennusohjeet</a>.",
"seconds ago" => "sekuntia sitten",
"1 minute ago" => "1 minuutti sitten",
diff --git a/lib/l10n/fr.php b/lib/l10n/fr.php
index fc44f976084..9448502df6a 100644
--- a/lib/l10n/fr.php
+++ b/lib/l10n/fr.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "L'utilisateur MySQL '%s'@'%%' existe déjà",
"Drop this user from MySQL." => "Retirer cet utilisateur de la base MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "La requête en cause est : \"%s\", nom : %s, mot de passe : %s",
+"MS SQL username and/or password not valid: %s" => "Le nom d'utilisateur et/ou le mot de passe de la base MS SQL est invalide : %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Votre serveur web, n'est pas correctement configuré pour permettre la synchronisation des fichiers, car l'interface WebDav ne fonctionne pas comme il faut.",
"Please double check the <a href='%s'>installation guides</a>." => "Veuillez vous référer au <a href='%s'>guide d'installation</a>.",
"seconds ago" => "à l'instant",
diff --git a/lib/l10n/gl.php b/lib/l10n/gl.php
index 9673bb65fc1..a11724fef43 100644
--- a/lib/l10n/gl.php
+++ b/lib/l10n/gl.php
@@ -23,10 +23,10 @@
"%s enter the database name." => "%s introduza o nome da base de datos",
"%s you may not use dots in the database name" => "%s non se poden empregar puntos na base de datos",
"%s set the database host." => "%s estabeleza o servidor da base de datos",
-"PostgreSQL username and/or password not valid" => "Nome de usuario e/ou contrasinal PostgreSQL incorrecto",
+"PostgreSQL username and/or password not valid" => "Nome de usuario e/ou contrasinal de PostgreSQL incorrecto",
"You need to enter either an existing account or the administrator." => "Deberá introducir unha conta existente ou o administrador.",
-"Oracle username and/or password not valid" => "Nome de usuario e/ou contrasinal Oracle incorrecto",
-"MySQL username and/or password not valid" => "Nome de usuario e/ou contrasinal MySQL incorrecto",
+"Oracle username and/or password not valid" => "Nome de usuario e/ou contrasinal de Oracle incorrecto",
+"MySQL username and/or password not valid" => "Nome de usuario e/ou contrasinal de MySQL incorrecto",
"DB Error: \"%s\"" => "Produciuse un erro na base de datos: «%s»",
"Offending command was: \"%s\"" => "A orde ofensiva foi: «%s»",
"MySQL user '%s'@'localhost' exists already." => "O usuario MySQL '%s'@'localhost' xa existe.",
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "O usuario MySQL «%s»@«%%» xa existe.",
"Drop this user from MySQL." => "Omitir este usuario de MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "A orde ofensiva foi: «%s», nome: %s, contrasinal: %s",
+"MS SQL username and/or password not valid: %s" => "Nome de usuario e/ou contrasinal de MS SQL incorrecto: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "O seu servidor web non está aínda configurado adecuadamente para permitir a sincronización de ficheiros xa que semella que a interface WebDAV non está a funcionar.",
"Please double check the <a href='%s'>installation guides</a>." => "Volva comprobar as <a href='%s'>guías de instalación</a>",
"seconds ago" => "segundos atrás",
diff --git a/lib/l10n/hu_HU.php b/lib/l10n/hu_HU.php
index d1aeb621e23..537066c6fea 100644
--- a/lib/l10n/hu_HU.php
+++ b/lib/l10n/hu_HU.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "A '%s'@'%%' MySQL felhasználó már létezik",
"Drop this user from MySQL." => "Törölje ezt a felhasználót a MySQL-ből.",
"Offending command was: \"%s\", name: %s, password: %s" => "A hibát okozó parancs ez volt: \"%s\", login név: %s, jelszó: %s",
+"MS SQL username and/or password not valid: %s" => "Az MS SQL felhasználónév és/vagy jelszó érvénytelen: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Az Ön webkiszolgálója nincs megfelelően beállítva az állományok szinkronizálásához, mert a WebDAV-elérés úgy tűnik, nem működik.",
"Please double check the <a href='%s'>installation guides</a>." => "Kérjük tüzetesen tanulmányozza át a <a href='%s'>telepítési útmutatót</a>.",
"seconds ago" => "másodperce",
diff --git a/lib/l10n/it.php b/lib/l10n/it.php
index fa4bac8ec46..297f1efde05 100644
--- a/lib/l10n/it.php
+++ b/lib/l10n/it.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "L'utente MySQL '%s'@'%%' esiste già",
"Drop this user from MySQL." => "Elimina questo utente da MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Il comando non consentito era: \"%s\", nome: %s, password: %s",
+"MS SQL username and/or password not valid: %s" => "Nome utente e/o password MS SQL non validi: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Il tuo server web non è configurato correttamente per consentire la sincronizzazione dei file poiché l'interfaccia WebDAV sembra essere danneggiata.",
"Please double check the <a href='%s'>installation guides</a>." => "Leggi attentamente le <a href='%s'>guide d'installazione</a>.",
"seconds ago" => "secondi fa",
diff --git a/lib/l10n/ja_JP.php b/lib/l10n/ja_JP.php
index 51b5b40940a..529eec3ac52 100644
--- a/lib/l10n/ja_JP.php
+++ b/lib/l10n/ja_JP.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQLのユーザ '%s'@'%%' はすでに存在します。",
"Drop this user from MySQL." => "MySQLからこのユーザを削除する。",
"Offending command was: \"%s\", name: %s, password: %s" => "違反コマンド: \"%s\"、名前: %s、パスワード: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL サーバーのユーザー名/パスワードが正しくありません: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "WebDAVインタフェースが動作していないと考えられるため、あなたのWEBサーバはまだファイルの同期を許可するように適切な設定がされていません。",
"Please double check the <a href='%s'>installation guides</a>." => "<a href='%s'>インストールガイド</a>をよく確認してください。",
"seconds ago" => "秒前",
diff --git a/lib/l10n/ka.php b/lib/l10n/ka.php
new file mode 100644
index 00000000000..e5a3e659668
--- /dev/null
+++ b/lib/l10n/ka.php
@@ -0,0 +1,15 @@
+<?php $TRANSLATIONS = array(
+"Help" => "შველა",
+"Personal" => "პერსონა",
+"Users" => "მომხმარებლები",
+"Admin" => "ადმინისტრატორი",
+"ZIP download is turned off." => "ZIP გადმოწერა გამორთულია",
+"Files" => "ფაილები",
+"seconds ago" => "წამის წინ",
+"1 minute ago" => "1 წუთის წინ",
+"%d minutes ago" => "%d წუთის წინ",
+"1 hour ago" => "1 საათის წინ",
+"today" => "დღეს",
+"yesterday" => "გუშინ",
+"%d days ago" => "%d დღის წინ"
+);
diff --git a/lib/l10n/lv.php b/lib/l10n/lv.php
index 5ec9ddd9693..c73d306ca0a 100644
--- a/lib/l10n/lv.php
+++ b/lib/l10n/lv.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQL lietotājs '%s'@'%%' jau eksistē",
"Drop this user from MySQL." => "Izmest šo lietotāju no MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Vainīgā komanda bija \"%s\", vārds: %s, parole: %s",
+"MS SQL username and/or password not valid: %s" => "Nav derīga MySQL parole un/vai lietotājvārds — %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Jūsu serveris vēl nav pareizi iestatīts, lai ļautu sinhronizēt datnes, jo izskatās, ka WebDAV saskarne ir salauzta.",
"Please double check the <a href='%s'>installation guides</a>." => "Lūdzu, vēlreiz pārbaudiet <a href='%s'>instalēšanas palīdzību</a>.",
"seconds ago" => "sekundes atpakaļ",
diff --git a/lib/l10n/my_MM.php b/lib/l10n/my_MM.php
index cee6f65d22e..d725a06a3a9 100644
--- a/lib/l10n/my_MM.php
+++ b/lib/l10n/my_MM.php
@@ -2,6 +2,7 @@
"Help" => "အကူအညီ",
"Users" => "သုံးစွဲသူ",
"Apps" => "Apps",
+"Admin" => "အက်ဒမင်",
"ZIP download is turned off." => "ZIP ဒေါင်းလုတ်ကိုပိတ်ထားသည်",
"Files need to be downloaded one by one." => "ဖိုင်များသည် တစ်ခုပြီး တစ်ခုဒေါင်းလုတ်ချရန်လိုအပ်သည်",
"Back to Files" => "ဖိုင်သို့ပြန်သွားမည်",
diff --git a/lib/l10n/nl.php b/lib/l10n/nl.php
index 4a357889fdc..e26a663e9cc 100644
--- a/lib/l10n/nl.php
+++ b/lib/l10n/nl.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "MySQL gebruiker '%s'@'%%' bestaat al",
"Drop this user from MySQL." => "Verwijder deze gebruiker uit MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Onjuiste commando was: \"%s\", naam: %s, wachtwoord: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL gebruikersnaam en/of wachtwoord niet geldig: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Uw webserver is nog niet goed ingesteld voor bestandssynchronisatie omdat de WebDAV interface verbroken lijkt.",
"Please double check the <a href='%s'>installation guides</a>." => "Conntroleer de <a href='%s'>installatie handleiding</a> goed.",
"seconds ago" => "seconden geleden",
diff --git a/lib/l10n/pl.php b/lib/l10n/pl.php
index 6ec35445bc2..9a1a5e836c9 100644
--- a/lib/l10n/pl.php
+++ b/lib/l10n/pl.php
@@ -16,6 +16,27 @@
"Files" => "Pliki",
"Text" => "Połączenie tekstowe",
"Images" => "Obrazy",
+"Set an admin username." => "Ustaw nazwę administratora.",
+"Set an admin password." => "Ustaw hasło administratora.",
+"Specify a data folder." => "Określ folder danych.",
+"%s enter the database username." => "%s wpisz nazwę użytkownika do bazy",
+"%s enter the database name." => "%s wpisz nazwę bazy.",
+"%s you may not use dots in the database name" => "%s nie można używać kropki w nazwie bazy danych",
+"%s set the database host." => "%s ustaw hosta bazy danych.",
+"PostgreSQL username and/or password not valid" => "PostgreSQL: Nazwa użytkownika i/lub hasło jest niepoprawne",
+"You need to enter either an existing account or the administrator." => "Należy wprowadzić istniejące konto użytkownika lub administratora.",
+"Oracle username and/or password not valid" => "Oracle: Nazwa użytkownika i/lub hasło jest niepoprawne",
+"MySQL username and/or password not valid" => "MySQL: Nazwa użytkownika i/lub hasło jest niepoprawne",
+"DB Error: \"%s\"" => "Błąd DB: \"%s\"",
+"Offending command was: \"%s\"" => "Niepoprawna komenda: \"%s\"",
+"MySQL user '%s'@'localhost' exists already." => "Użytkownik MySQL '%s'@'localhost' już istnieje",
+"Drop this user from MySQL" => "Usuń tego użytkownika z MySQL",
+"MySQL user '%s'@'%%' already exists" => "Użytkownik MySQL '%s'@'%%t' już istnieje",
+"Drop this user from MySQL." => "Usuń tego użytkownika z MySQL.",
+"Offending command was: \"%s\", name: %s, password: %s" => "Niepoprawne polecania: \"%s\", nazwa: %s, hasło: %s",
+"MS SQL username and/or password not valid: %s" => "Nazwa i/lub hasło serwera MS SQL jest niepoprawne: %s.",
+"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Serwer www nie jest jeszcze poprawnie ustawiony, aby umożliwić synchronizację plików, ponieważ interfejs WebDAV wydaje się być uszkodzony. Sprawdź ustawienia serwera.",
+"Please double check the <a href='%s'>installation guides</a>." => "Proszę sprawdź ponownie <a href='%s'>przewodnik instalacji</a>.",
"seconds ago" => "sekund temu",
"1 minute ago" => "1 minutę temu",
"%d minutes ago" => "%d minut temu",
diff --git a/lib/l10n/pt_BR.php b/lib/l10n/pt_BR.php
index 25645b1dcd9..d4f410d8885 100644
--- a/lib/l10n/pt_BR.php
+++ b/lib/l10n/pt_BR.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "Usuário MySQL '%s'@'%%' já existe",
"Drop this user from MySQL." => "Derrube este usuário do MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Comando ofensivo era: \"%s\", nome: %s, senha: %s",
+"MS SQL username and/or password not valid: %s" => "Nome de usuário e/ou senha MS SQL inválido(s): %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Seu servidor web não está configurado corretamente para permitir sincronização de arquivos porque a interface WebDAV parece estar quebrada.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor, confira os <a href='%s'>guias de instalação</a>.",
"seconds ago" => "segundos atrás",
diff --git a/lib/l10n/pt_PT.php b/lib/l10n/pt_PT.php
index 9bdcfcc9ced..2c813f5b07c 100644
--- a/lib/l10n/pt_PT.php
+++ b/lib/l10n/pt_PT.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "O utilizador '%s'@'%%' do MySQL já existe",
"Drop this user from MySQL." => "Eliminar este utilizador do MySQL",
"Offending command was: \"%s\", name: %s, password: %s" => "O comando gerador de erro foi: \"%s\", nome: %s, password: %s",
+"MS SQL username and/or password not valid: %s" => "Nome de utilizador/password do MySQL é inválido: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "O seu servidor web não está configurado correctamente para autorizar sincronização de ficheiros, pois o interface WebDAV parece estar com problemas.",
"Please double check the <a href='%s'>installation guides</a>." => "Por favor verifique <a href='%s'>installation guides</a>.",
"seconds ago" => "há alguns segundos",
diff --git a/lib/l10n/ru.php b/lib/l10n/ru.php
index 7f1111376ef..25a88d5efc2 100644
--- a/lib/l10n/ru.php
+++ b/lib/l10n/ru.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "Пользователь MySQL '%s'@'%%' уже существует",
"Drop this user from MySQL." => "Удалить этого пользователя из MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Вызываемая команда была: \"%s\", имя: %s, пароль: %s",
+"MS SQL username and/or password not valid: %s" => "Имя пользователя и/или пароль MS SQL не подходит: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Ваш веб сервер до сих пор не настроен правильно для возможности синхронизации файлов, похоже что проблема в неисправности интерфейса WebDAV.",
"Please double check the <a href='%s'>installation guides</a>." => "Пожалуйста, дважды просмотрите <a href='%s'>инструкции по установке</a>.",
"seconds ago" => "менее минуты",
diff --git a/lib/l10n/sk_SK.php b/lib/l10n/sk_SK.php
index 97a4999407f..8c9ce61622c 100644
--- a/lib/l10n/sk_SK.php
+++ b/lib/l10n/sk_SK.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "Používateľ '%s'@'%%' už v MySQL existuje",
"Drop this user from MySQL." => "Zahodiť používateľa z MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Podozrivý príkaz bol: \"%s\", meno: %s, heslo: %s",
+"MS SQL username and/or password not valid: %s" => "Používateľské meno, alebo heslo MS SQL nie je platné: %s",
"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Váš webový server nie je správne nastavený na synchronizáciu, pretože rozhranie WebDAV je poškodené.",
"Please double check the <a href='%s'>installation guides</a>." => "Prosím skontrolujte <a href='%s'>inštalačnú príručku</a>.",
"seconds ago" => "pred sekundami",
diff --git a/lib/l10n/sl.php b/lib/l10n/sl.php
index 391d932c4ee..58c3ddf141d 100644
--- a/lib/l10n/sl.php
+++ b/lib/l10n/sl.php
@@ -6,15 +6,37 @@
"Apps" => "Programi",
"Admin" => "Skrbništvo",
"ZIP download is turned off." => "Prejem datotek ZIP je onemogočen.",
-"Files need to be downloaded one by one." => "Datoteke je mogoče prejeti le posamič.",
+"Files need to be downloaded one by one." => "Datoteke je mogoče prejeti le posamično.",
"Back to Files" => "Nazaj na datoteke",
"Selected files too large to generate zip file." => "Izbrane datoteke so prevelike za ustvarjanje datoteke arhiva zip.",
+"couldn't be determined" => "ni mogoče določiti",
"Application is not enabled" => "Program ni omogočen",
"Authentication error" => "Napaka overitve",
-"Token expired. Please reload page." => "Žeton je potekel. Spletišče je traba znova naložiti.",
+"Token expired. Please reload page." => "Žeton je potekel. Stran je treba ponovno naložiti.",
"Files" => "Datoteke",
"Text" => "Besedilo",
"Images" => "Slike",
+"Set an admin username." => "Nastavi uporabniško ime skrbnika.",
+"Set an admin password." => "Nastavi geslo skrbnika.",
+"Specify a data folder." => "Določi podatkovno mapo.",
+"%s enter the database username." => "%s - vnos uporabniškega imena podatkovne zbirke.",
+"%s enter the database name." => "%s - vnos imena podatkovne zbirke.",
+"%s you may not use dots in the database name" => "%s - v imenu podatkovne zbirke ni dovoljeno vpisati pik.",
+"%s set the database host." => "%s - vnos gostitelja podatkovne zbirke.",
+"PostgreSQL username and/or password not valid" => "Uporabniško ime ali geslo PostgreSQL ni pravilno",
+"You need to enter either an existing account or the administrator." => "Prijaviti se je treba v obstoječi ali pa skrbniški račun.",
+"Oracle username and/or password not valid" => "Uporabniško ime ali geslo Oracle ni pravilno",
+"MySQL username and/or password not valid" => "Uporabniško ime ali geslo MySQL ni pravilno",
+"DB Error: \"%s\"" => "Napaka podatkovne zbirke: \"%s\"",
+"Offending command was: \"%s\"" => "Napačni ukaz je: \"%s\"",
+"MySQL user '%s'@'localhost' exists already." => "Uporabnik MySQL '%s'@'localhost' že obstaja.",
+"Drop this user from MySQL" => "Odstrani uporabnika s podatkovne zbirke MySQL",
+"MySQL user '%s'@'%%' already exists" => "Uporabnik MySQL '%s'@'%%' že obstaja.",
+"Drop this user from MySQL." => "Odstrani uporabnika s podatkovne zbirke MySQL",
+"Offending command was: \"%s\", name: %s, password: %s" => "Napačni ukaz je: \"%s\", ime: %s, geslo: %s",
+"MS SQL username and/or password not valid: %s" => "Uporabniško ime ali geslo MS SQL ni pravilno: %s",
+"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "Spletni stražnik še ni ustrezno nastavljen in ne omogoča usklajevanja, saj je nastavitev WebDAV okvarjena.",
+"Please double check the <a href='%s'>installation guides</a>." => "Preverite <a href='%s'>navodila namestitve</a>.",
"seconds ago" => "pred nekaj sekundami",
"1 minute ago" => "pred minuto",
"%d minutes ago" => "pred %d minutami",
@@ -30,5 +52,5 @@
"%s is available. Get <a href=\"%s\">more information</a>" => "%s je na voljo. <a href=\"%s\">Več podrobnosti.</a>",
"up to date" => "posodobljeno",
"updates check is disabled" => "preverjanje za posodobitve je onemogočeno",
-"Could not find category \"%s\"" => "Kategorije \"%s\" ni bilo mogoče najti."
+"Could not find category \"%s\"" => "Kategorije \"%s\" ni mogoče najti."
);
diff --git a/lib/l10n/uk.php b/lib/l10n/uk.php
index 415c0a80c27..68f7151d15e 100644
--- a/lib/l10n/uk.php
+++ b/lib/l10n/uk.php
@@ -34,6 +34,7 @@
"MySQL user '%s'@'%%' already exists" => "Користувач MySQL '%s'@'%%' вже існує",
"Drop this user from MySQL." => "Видалити цього користувача з MySQL.",
"Offending command was: \"%s\", name: %s, password: %s" => "Команда, що викликала проблему: \"%s\", ім'я: %s, пароль: %s",
+"MS SQL username and/or password not valid: %s" => "MS SQL ім'я користувача та/або пароль не дійсні: %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" => "секунди тому",
diff --git a/lib/l10n/ur_PK.php b/lib/l10n/ur_PK.php
new file mode 100644
index 00000000000..7e09d79bc68
--- /dev/null
+++ b/lib/l10n/ur_PK.php
@@ -0,0 +1,8 @@
+<?php $TRANSLATIONS = array(
+"Help" => "مدد",
+"Personal" => "ذاتی",
+"Settings" => "سیٹینگز",
+"Users" => "یوزرز",
+"Apps" => "ایپز",
+"Admin" => "ایڈمن"
+);
diff --git a/lib/mail.php b/lib/mail.php
index 22194045a76..61634632efc 100644
--- a/lib/mail.php
+++ b/lib/mail.php
@@ -119,4 +119,12 @@ class OC_Mail {
return($txt);
}
+
+ /**
+ * @param string $emailAddress a given email address to be validated
+ * @return bool
+ */
+ public static function ValidateAddress($emailAddress) {
+ return PHPMailer::ValidateAddress($emailAddress);
+ }
}
diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php
index 5553ae38215..132d923d960 100644
--- a/lib/ocs/cloud.php
+++ b/lib/ocs/cloud.php
@@ -24,49 +24,23 @@
class OC_OCS_Cloud {
- public static function getSystemWebApps() {
- OC_Util::checkLoggedIn();
- $apps = OC_App::getEnabledApps();
- $values = array();
- foreach($apps as $app) {
- $info = OC_App::getAppInfo($app);
- if(isset($info['standalone'])) {
- $newValue = array('name'=>$info['name'], 'url'=>OC_Helper::linkToAbsolute($app, ''), 'icon'=>'');
- $values[] = $newValue;
- }
- }
- return new OC_OCS_Result($values);
- }
-
- public static function getUserQuota($parameters) {
- $user = OC_User::getUser();
- if(OC_User::isAdminUser($user) or ($user==$parameters['user'])) {
-
- if(OC_User::userExists($parameters['user'])) {
- // calculate the disc space
- $userDir = '/'.$parameters['user'].'/files';
- \OC\Files\Filesystem::init($parameters['user'], $userDir);
- $rootInfo = \OC\Files\Filesystem::getFileInfo('');
- $sharedInfo = \OC\Files\Filesystem::getFileInfo('/Shared');
- $used = $rootInfo['size'] - $sharedInfo['size'];
- $free = \OC\Files\Filesystem::free_space();
- $total = $free + $used;
- if($total===0) $total = 1; // prevent division by zero
- $relative = round(($used/$total)*10000)/100;
-
- $xml = array();
- $xml['quota'] = $total;
- $xml['free'] = $free;
- $xml['used'] = $used;
- $xml['relative'] = $relative;
-
- return new OC_OCS_Result($xml);
- } else {
- return new OC_OCS_Result(null, 300);
- }
- } else {
- return new OC_OCS_Result(null, 300);
- }
+ public static function getCapabilities($parameters) {
+ $result = array();
+ list($major, $minor, $micro) = OC_Util::getVersion();
+ $result['version'] = array(
+ 'major' => $major,
+ 'minor' => $minor,
+ 'micro' => $micro,
+ 'string' => OC_Util::getVersionString(),
+ 'edition' => OC_Util::getEditionString(),
+ );
+
+ $result['capabilities'] = array(
+ 'core' => array(
+ 'pollinterval' => OC_Config::getValue('pollinterval', 60),
+ ),
+ );
+ return new OC_OCS_Result($result);
}
public static function getUserPublickey($parameters) {
diff --git a/lib/ocs/result.php b/lib/ocs/result.php
index 65b2067fc3f..8ab378d79c5 100644
--- a/lib/ocs/result.php
+++ b/lib/ocs/result.php
@@ -49,26 +49,48 @@ class OC_OCS_Result{
public function setItemsPerPage(int $items) {
$this->perPage = $items;
}
-
+
+ /**
+ * get the status code
+ * @return int
+ */
+ public function getStatusCode() {
+ return $this->statusCode;
+ }
+
/**
- * returns the data associated with the api result
+ * get the meta data for the result
* @return array
*/
- public function getResult() {
- $return = array();
- $return['meta'] = array();
- $return['meta']['status'] = ($this->statusCode === 100) ? 'ok' : 'failure';
- $return['meta']['statuscode'] = $this->statusCode;
- $return['meta']['message'] = $this->message;
+ public function getMeta() {
+ $meta = array();
+ $meta['status'] = ($this->statusCode === 100) ? 'ok' : 'failure';
+ $meta['statuscode'] = $this->statusCode;
+ $meta['message'] = $this->message;
if(isset($this->items)) {
- $return['meta']['totalitems'] = $this->items;
+ $meta['totalitems'] = $this->items;
}
if(isset($this->perPage)) {
- $return['meta']['itemsperpage'] = $this->perPage;
+ $meta['itemsperpage'] = $this->perPage;
}
- $return['data'] = $this->data;
- // Return the result data.
- return $return;
+ return $meta;
+
+ }
+
+ /**
+ * get the result data
+ * @return array|string|int
+ */
+ public function getData() {
+ return $this->data;
+ }
+
+ /**
+ * return bool if the method succedded
+ * @return bool
+ */
+ public function succeeded() {
+ return (substr($this->statusCode, 0, 1) === '1');
}
diff --git a/lib/public/files.php b/lib/public/files.php
index c2945b200e8..700bf574537 100644
--- a/lib/public/files.php
+++ b/lib/public/files.php
@@ -62,7 +62,8 @@ class Files {
* @return int the number of bytes copied
*/
public static function streamCopy( $source, $target ) {
- return(\OC_Helper::streamCopy( $source, $target ));
+ list($count, $result) = \OC_Helper::streamCopy( $source, $target );
+ return $count;
}
/**
diff --git a/lib/public/share.php b/lib/public/share.php
index c0f35333e83..59f41a9bfd6 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -61,6 +61,7 @@ class Share {
private static $shareTypeGroupUserUnique = 2;
private static $backends = array();
private static $backendTypes = array();
+ private static $isResharingAllowed;
/**
* @brief Register a sharing backend class that implements OCP\Share_Backend for an item type
@@ -384,7 +385,7 @@ class Share {
'itemSource' => $itemSource,
'shareType' => $shareType,
'shareWith' => $shareWith,
- ));
+ ));
self::delete($item['id']);
return true;
}
@@ -404,7 +405,7 @@ class Share {
'itemType' => $itemType,
'itemSource' => $itemSource,
'shares' => $shares
- ));
+ ));
foreach ($shares as $share) {
self::delete($share['id']);
}
@@ -568,6 +569,24 @@ class Share {
}
/**
+ * @brief Check if resharing is allowed
+ * @return Returns true if allowed or false
+ *
+ * Resharing is allowed by default if not configured
+ *
+ */
+ private static function isResharingAllowed() {
+ if (!isset(self::$isResharingAllowed)) {
+ if (\OC_Appconfig::getValue('core', 'shareapi_allow_resharing', 'yes') == 'yes') {
+ self::$isResharingAllowed = true;
+ } else {
+ self::$isResharingAllowed = false;
+ }
+ }
+ return self::$isResharingAllowed;
+ }
+
+ /**
* @brief Get a list of collection item types for the specified item type
* @param string Item type
* @return array
@@ -767,7 +786,7 @@ class Share {
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`,
`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,
- `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`';
+ `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`';
}
} else {
$select = '*';
@@ -840,7 +859,10 @@ class Share {
continue;
}
}
-
+ // Check if resharing is allowed, if not remove share permission
+ if (isset($row['permissions']) && !self::isResharingAllowed()) {
+ $row['permissions'] &= ~PERMISSION_SHARE;
+ }
// Add display names to result
if ( isset($row['share_with']) && $row['share_with'] != '') {
$row['share_with_displayname'] = \OCP\User::getDisplayName($row['share_with']);
@@ -848,7 +870,7 @@ class Share {
if ( isset($row['uid_owner']) && $row['uid_owner'] != '') {
$row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']);
}
-
+
$items[$row['id']] = $row;
}
if (!empty($items)) {
@@ -978,7 +1000,7 @@ class Share {
throw new \Exception($message);
}
// Check if share permissions is granted
- if ((int)$checkReshare['permissions'] & PERMISSION_SHARE) {
+ if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & PERMISSION_SHARE) {
if (~(int)$checkReshare['permissions'] & $permissions) {
$message = 'Sharing '.$itemSource
.' failed, because the permissions exceed permissions granted to '.$uidOwner;
diff --git a/lib/public/user.php b/lib/public/user.php
index 86d1d0ccde8..9edebe0e7cf 100644
--- a/lib/public/user.php
+++ b/lib/public/user.php
@@ -52,25 +52,25 @@ class User {
public static function getUsers($search = '', $limit = null, $offset = null) {
return \OC_USER::getUsers();
}
-
- /**
- * @brief get the user display name of the user currently logged in.
- * @return string display name
- */
- public static function getDisplayName($user=null) {
- return \OC_USER::getDisplayName($user);
+
+ /**
+ * @brief get the user display name of the user currently logged in.
+ * @return string display name
+ */
+ public static function getDisplayName($user=null) {
+ return \OC_USER::getDisplayName($user);
}
-
- /**
- * @brief Get a list of all display names
- * @returns array with all display names (value) and the correspondig uids (key)
- *
- * Get a list of all display names and user ids.
- */
- public static function getDisplayNames($search = '', $limit = null, $offset = null) {
- return \OC_USER::getDisplayNames($search, $limit, $offset);
+
+ /**
+ * @brief Get a list of all display names
+ * @returns array with all display names (value) and the correspondig uids (key)
+ *
+ * Get a list of all display names and user ids.
+ */
+ public static function getDisplayNames($search = '', $limit = null, $offset = null) {
+ return \OC_USER::getDisplayNames($search, $limit, $offset);
}
-
+
/**
* @brief Check if the user is logged in
* @returns true/false
diff --git a/lib/public/util.php b/lib/public/util.php
index 13498b260ef..db07cbcfff3 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -217,11 +217,14 @@ class Util {
*/
public static function getDefaultEmailAddress($user_part) {
$host_name = self::getServerHostName();
- // handle localhost installations
- if ($host_name === 'localhost') {
- $host_name = "example.com";
+ $defaultEmailAddress = $user_part.'@'.$host_name;
+
+ if (\OC_Mail::ValidateAddress($defaultEmailAddress)) {
+ return $defaultEmailAddress;
}
- return $user_part.'@'.$host_name;
+
+ // in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
+ return $user_part.'@localhost.localdomain';
}
/**
diff --git a/lib/request.php b/lib/request.php
index 3af93289670..9f74cf9beb5 100755
--- a/lib/request.php
+++ b/lib/request.php
@@ -107,7 +107,7 @@ class OC_Request {
if (array_key_exists('PATH_INFO', $_SERVER)) {
$path_info = $_SERVER['PATH_INFO'];
}else{
- $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
+ $path_info = self::getRawPathInfo();
// following is taken from Sabre_DAV_URLUtil::decodePathSegment
$path_info = rawurldecode($path_info);
$encoding = mb_detect_encoding($path_info, array('UTF-8', 'ISO-8859-1'));
@@ -124,6 +124,19 @@ class OC_Request {
}
/**
+ * @brief get Path info from request, not urldecoded
+ * @returns string Path info or false when not found
+ */
+ public static function getRawPathInfo() {
+ $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
+ // Remove the query string from REQUEST_URI
+ if ($pos = strpos($path_info, '?')) {
+ $path_info = substr($path_info, 0, $pos);
+ }
+ return $path_info;
+ }
+
+ /**
* @brief Check if this is a no-cache request
* @returns true for no-cache
*/
@@ -149,7 +162,7 @@ class OC_Request {
return 'gzip';
return false;
}
-
+
/**
* @brief Check if the requester sent along an mtime
* @returns false or an mtime
diff --git a/lib/search.php b/lib/search.php
index e5a65f7157d..b9c75dfc333 100644
--- a/lib/search.php
+++ b/lib/search.php
@@ -57,14 +57,14 @@ class OC_Search{
}
return $results;
}
-
+
/**
* remove an existing search provider
* @param string $provider class name of a OC_Search_Provider
*/
public static function removeProvider($provider) {
self::$registeredProviders = array_filter(
- self::$registeredProviders,
+ self::$registeredProviders,
function ($element) use ($provider) {
return ($element['class'] != $provider);
}
diff --git a/lib/setup.php b/lib/setup.php
index faf011fccb1..8814447f52f 100644
--- a/lib/setup.php
+++ b/lib/setup.php
@@ -40,11 +40,13 @@ class OC_Setup {
$error[] = $l->t('Specify a data folder.');
}
- if($dbtype=='mysql' or $dbtype == 'pgsql' or $dbtype == 'oci') { //mysql and postgresql needs more config options
- if($dbtype=='mysql')
+ if($dbtype == 'mysql' or $dbtype == 'pgsql' or $dbtype == 'oci' or $dbtype == 'mssql') { //mysql and postgresql needs more config options
+ if($dbtype == 'mysql')
$dbprettyname = 'MySQL';
- else if($dbtype=='pgsql')
+ else if($dbtype == 'pgsql')
$dbprettyname = 'PostgreSQL';
+ else if ($dbtype == 'mssql')
+ $dbprettyname = 'MS SQL Server';
else
$dbprettyname = 'Oracle';
@@ -98,7 +100,7 @@ class OC_Setup {
$error[] = array(
'error' => $e->getMessage(),
'hint' => $e->getHint()
- );
+ );
return($error);
} catch (Exception $e) {
$error[] = array(
@@ -152,6 +154,29 @@ class OC_Setup {
return $error;
}
}
+ elseif ($dbtype == 'mssql') {
+ $dbuser = $options['dbuser'];
+ $dbpass = $options['dbpass'];
+ $dbname = $options['dbname'];
+ $dbhost = $options['dbhost'];
+ $dbtableprefix = isset($options['dbtableprefix']) ? $options['dbtableprefix'] : 'oc_';
+
+ OC_Config::setValue('dbname', $dbname);
+ OC_Config::setValue('dbhost', $dbhost);
+ OC_Config::setValue('dbuser', $dbuser);
+ OC_Config::setValue('dbpassword', $dbpass);
+ OC_Config::setValue('dbtableprefix', $dbtableprefix);
+
+ try {
+ self::setupMSSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix);
+ } catch (Exception $e) {
+ $error[] = array(
+ 'error' => 'MS SQL username and/or password not valid',
+ 'hint' => 'You need to enter either an existing account or the administrator.'
+ );
+ return $error;
+ }
+ }
else {
//delete the old sqlite database first, might cause infinte loops otherwise
if(file_exists("$datadir/owncloud.db")) {
@@ -174,7 +199,7 @@ class OC_Setup {
OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true));
OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php');
OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php');
-
+
OC_Group::createGroup('admin');
OC_Group::addToGroup($username, 'admin');
OC_User::login($username, $password);
@@ -236,8 +261,8 @@ class OC_Setup {
}
//fill the database if needed
- $query="select count(*) from information_schema.tables'
- .' where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';";
+ $query='select count(*) from information_schema.tables'
+ ." where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';";
$result = mysql_query($query, $connection);
if($result) {
$row=mysql_fetch_row($result);
@@ -256,11 +281,12 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(mysql_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
}
$query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'";
- //this query will fail if there aren't the right permissons, ignore the error
- $result = mysql_query($query, $connection);
+
+ //this query will fail if there aren't the right permissions, ignore the error
+ mysql_query($query, $connection);
}
private static function createDBUser($name, $password, $connection) {
@@ -276,7 +302,7 @@ class OC_Setup {
$query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
$result = mysql_query($query, $connection);
if (!$result) {
- throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)),
+ throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)),
$l->t("Drop this user from MySQL."));
}
}
@@ -359,7 +385,7 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
}
if(! pg_fetch_row($result)) {
//The database does not exists... let's create it
@@ -368,11 +394,11 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
}
else {
$query = "REVOKE ALL PRIVILEGES ON DATABASE \"$e_name\" FROM PUBLIC";
- $result = pg_query($connection, $query);
+ pg_query($connection, $query);
}
}
}
@@ -386,7 +412,7 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
}
if(! pg_fetch_row($result)) {
@@ -396,7 +422,7 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
}
}
else { // change password of the existing role
@@ -405,7 +431,7 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(pg_last_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.pg', $entry, \OC_Log::WARN);
}
}
}
@@ -428,13 +454,13 @@ class OC_Setup {
}
//check for roles creation rights in oracle
- $query="SELECT count(*) FROM user_role_privs, role_sys_privs'
- .' WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
+ $query='SELECT count(*) FROM user_role_privs, role_sys_privs'
+ ." WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
$stmt = oci_parse($connection, $query);
if (!$stmt) {
$entry = $l->t('DB Error: "%s"', array(oci_last_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
$result = oci_execute($stmt);
if($result) {
@@ -498,9 +524,9 @@ class OC_Setup {
$un = $dbtableprefix.'users';
oci_bind_by_name($stmt, ':un', $un);
if (!$stmt) {
- $entry = $l->t('DB Error: "%s"', array(oci_last_error($connection))) . '<br />';
+ $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
$result = oci_execute($stmt);
@@ -526,14 +552,14 @@ class OC_Setup {
if (!$stmt) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
oci_bind_by_name($stmt, ':un', $name);
$result = oci_execute($stmt);
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
if(! oci_fetch_row($stmt)) {
@@ -544,15 +570,15 @@ class OC_Setup {
if (!$stmt) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
//oci_bind_by_name($stmt, ':un', $name);
$result = oci_execute($stmt);
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
- $entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
+ $entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
array($query, $name, $password)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
} else { // change password of the existing role
$query = "ALTER USER :un IDENTIFIED BY :pw";
@@ -560,7 +586,7 @@ class OC_Setup {
if (!$stmt) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
oci_bind_by_name($stmt, ':un', $name);
oci_bind_by_name($stmt, ':pw', $password);
@@ -568,26 +594,200 @@ class OC_Setup {
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
}
- // grant neccessary roles
+ // grant necessary roles
$query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name;
$stmt = oci_parse($connection, $query);
if (!$stmt) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
$entry .= $l->t('Offending command was: "%s"', array($query)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
$result = oci_execute($stmt);
if(!$result) {
$entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
- $entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
+ $entry .= $l->t('Offending command was: "%s", name: %s, password: %s',
array($query, $name, $password)) . '<br />';
- echo($entry);
+ \OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
}
+ private static function setupMSSQLDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix) {
+ $l = self::getTrans();
+
+ //check if the database user has admin right
+ $masterConnectionInfo = array( "Database" => "master", "UID" => $dbuser, "PWD" => $dbpass);
+
+ $masterConnection = @sqlsrv_connect($dbhost, $masterConnectionInfo);
+ if(!$masterConnection) {
+ $entry = null;
+ if( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ throw new Exception($l->t('MS SQL username and/or password not valid: %s', array($entry)));
+ }
+
+ OC_Config::setValue('dbuser', $dbuser);
+ OC_Config::setValue('dbpassword', $dbpass);
+
+ self::mssql_createDBLogin($dbuser, $dbpass, $masterConnection);
+
+ self::mssql_createDatabase($dbname, $masterConnection);
+
+ self::mssql_createDBUser($dbuser, $dbname, $masterConnection);
+
+ sqlsrv_close($masterConnection);
+
+ self::mssql_createDatabaseStructure($dbhost, $dbname, $dbuser, $dbpass, $dbtableprefix);
+ }
+
+ private static function mssql_createDBLogin($name, $password, $connection) {
+ $query = "SELECT * FROM master.sys.server_principals WHERE name = '".$name."';";
+ $result = sqlsrv_query($connection, $query);
+ if ($result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ } else {
+ $row = sqlsrv_fetch_array($result);
+
+ if ($row === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ } else {
+ if ($row == null) {
+ $query = "CREATE LOGIN [".$name."] WITH PASSWORD = '".$password."';";
+ $result = sqlsrv_query($connection, $query);
+ if (!$result or $result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ }
+ }
+ }
+ }
+ }
+
+ private static function mssql_createDBUser($name, $dbname, $connection) {
+ $query = "SELECT * FROM [".$dbname."].sys.database_principals WHERE name = '".$name."';";
+ $result = sqlsrv_query($connection, $query);
+ if ($result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ } else {
+ $row = sqlsrv_fetch_array($result);
+
+ if ($row === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ } else {
+ if ($row == null) {
+ $query = "USE [".$dbname."]; CREATE USER [".$name."] FOR LOGIN [".$name."];";
+ $result = sqlsrv_query($connection, $query);
+ if (!$result || $result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry = 'DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ }
+ }
+
+ $query = "USE [".$dbname."]; EXEC sp_addrolemember 'db_owner', '".$name."';";
+ $result = sqlsrv_query($connection, $query);
+ if (!$result || $result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ }
+ }
+ }
+ }
+
+ private static function mssql_createDatabase($dbname, $connection) {
+ $query = "CREATE DATABASE [".$dbname."];";
+ $result = sqlsrv_query($connection, $query);
+ if (!$result || $result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ }
+ }
+
+ private static function mssql_createDatabaseStructure($dbhost, $dbname, $dbuser, $dbpass, $dbtableprefix) {
+ $connectionInfo = array( "Database" => $dbname, "UID" => $dbuser, "PWD" => $dbpass);
+
+ $connection = @sqlsrv_connect($dbhost, $connectionInfo);
+
+ //fill the database if needed
+ $query = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{$dbname}' AND TABLE_NAME = '{$dbtableprefix}users'";
+ $result = sqlsrv_query($connection, $query);
+ if ($result === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ } else {
+ $row = sqlsrv_fetch_array($result);
+
+ if ($row === false) {
+ if ( ($errors = sqlsrv_errors() ) != null) {
+ $entry='DB Error: "'.print_r(sqlsrv_errors()).'"<br />';
+ } else {
+ $entry = '';
+ }
+ $entry.='Offending command was: '.$query.'<br />';
+ \OC_Log::write('setup.mssql', $entry, \OC_Log::WARN);
+ } else {
+ if ($row == null) {
+ OC_DB::createDbFromStructure('db_structure.xml');
+ }
+ }
+ }
+
+ sqlsrv_close($connection);
+ }
+
/**
* create .htaccess files for apache hosts
*/
@@ -651,7 +851,7 @@ class OC_Setup {
'http://doc.owncloud.org/server/5.0/admin_manual/installation.html');
$tmpl = new OC_Template('', 'error', 'guest');
- $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false);
+ $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)));
$tmpl->printPage();
exit();
}
diff --git a/lib/template.php b/lib/template.php
index 3df5a24f946..434c1e9e990 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -147,7 +147,7 @@ function html_select_options($options, $selected, $params=array()) {
$label = $label[$label_name];
}
$select = in_array($value, $selected) ? ' selected="selected"' : '';
- $html .= '<option value="' . $value . '"' . $select . '>' . $label . '</option>'."\n";
+ $html .= '<option value="' . OC_Util::sanitizeHTML($value) . '"' . $select . '>' . OC_Util::sanitizeHTML($label) . '</option>'."\n";
}
return $html;
}
@@ -200,7 +200,6 @@ class OC_Template{
.'img-src *; '
.'font-src \'self\' data:');
header('Content-Security-Policy:'.$policy); // Standard
- header('X-WebKit-CSP:'.$policy); // Older webkit browsers
$this->findTemplate($name);
}
@@ -341,7 +340,6 @@ class OC_Template{
* @brief Assign variables
* @param string $key key
* @param string $value value
- * @param bool $sanitizeHTML false, if data shouldn't get passed through htmlentities
* @return bool
*
* This function assigns a variable. It can be accessed via $_[$key] in
@@ -349,8 +347,7 @@ class OC_Template{
*
* If the key existed before, it will be overwritten
*/
- public function assign( $key, $value, $sanitizeHTML=true ) {
- if($sanitizeHTML == true) $value=OC_Util::sanitizeHTML($value);
+ public function assign( $key, $value) {
$this->vars[$key] = $value;
return true;
}
@@ -413,11 +410,6 @@ class OC_Template{
if( $this->renderas ) {
$page = new OC_TemplateLayout($this->renderas);
- if($this->renderas == 'user') {
- $page->assign('requesttoken', $this->vars['requesttoken']);
- $user = OC_User::getUser();
- $page->assign('displayname', OCP\User::getDisplayName($user));
- }
// Add custom headers
$page->assign('headers', $this->headers, false);
@@ -489,7 +481,7 @@ class OC_Template{
public static function printUserPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "user" );
foreach( $parameters as $key => $value ) {
- $content->assign( $key, $value, false );
+ $content->assign( $key, $value );
}
print $content->printPage();
}
@@ -504,7 +496,7 @@ class OC_Template{
public static function printAdminPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "admin" );
foreach( $parameters as $key => $value ) {
- $content->assign( $key, $value, false );
+ $content->assign( $key, $value );
}
return $content->printPage();
}
@@ -519,7 +511,7 @@ class OC_Template{
public static function printGuestPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "guest" );
foreach( $parameters as $key => $value ) {
- $content->assign( $key, $value, false );
+ $content->assign( $key, $value );
}
return $content->printPage();
}
@@ -527,11 +519,14 @@ class OC_Template{
/**
* @brief Print a fatal error page and terminates the script
* @param string $error The error message to show
- * @param string $hint An option hint message
+ * @param string $hint An optional hint message
+ * Warning: All data passed to $hint needs to get sanitized using OC_Util::sanitizeHTML
*/
public static function printErrorPage( $error_msg, $hint = '' ) {
+ $content = new OC_Template( '', 'error', 'error' );
$errors = array(array('error' => $error_msg, 'hint' => $hint));
- OC_Template::printGuestPage("", "error", array("errors" => $errors));
+ $content->assign( 'errors', $errors );
+ $content->printPage();
die();
}
}
diff --git a/lib/templatelayout.php b/lib/templatelayout.php
index 25d4033d9ee..29f120a6041 100644
--- a/lib/templatelayout.php
+++ b/lib/templatelayout.php
@@ -13,25 +13,26 @@ class OC_TemplateLayout extends OC_Template {
if( $renderas == 'user' ) {
parent::__construct( 'core', 'layout.user' );
if(in_array(OC_APP::getCurrentApp(), array('settings','admin', 'help'))!==false) {
- $this->assign('bodyid', 'body-settings', false);
+ $this->assign('bodyid', 'body-settings');
}else{
- $this->assign('bodyid', 'body-user', false);
+ $this->assign('bodyid', 'body-user');
}
// Add navigation entry
$this->assign( 'application', '', false );
$navigation = OC_App::getNavigation();
- $this->assign( 'navigation', $navigation, false);
- $this->assign( 'settingsnavigation', OC_App::getSettingsNavigation(), false);
+ $this->assign( 'navigation', $navigation);
+ $this->assign( 'settingsnavigation', OC_App::getSettingsNavigation());
foreach($navigation as $entry) {
if ($entry['active']) {
- $this->assign( 'application', $entry['name'], false );
+ $this->assign( 'application', $entry['name'] );
break;
}
}
$user_displayname = OC_User::getDisplayName();
$this->assign( 'user_displayname', $user_displayname );
- } else if ($renderas == 'guest') {
+ $this->assign( 'user_uid', OC_User::getUser() );
+ } else if ($renderas == 'guest' || $renderas == 'error') {
parent::__construct('core', 'layout.guest');
} else {
parent::__construct('core', 'layout.base');
@@ -39,7 +40,7 @@ class OC_TemplateLayout extends OC_Template {
// Add the js files
$jsfiles = self::findJavascriptFiles(OC_Util::$scripts);
$this->assign('jsfiles', array(), false);
- if (OC_Config::getValue('installed', false)) {
+ if (OC_Config::getValue('installed', false) && $renderas!='error') {
$this->append( 'jsfiles', OC_Helper::linkToRoute('js_config'));
}
if (!empty(OC_Util::$core_scripts)) {
diff --git a/lib/user.php b/lib/user.php
index e69fef95a13..6144f0f6bf9 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -437,7 +437,7 @@ class OC_User {
}
return false;
}
-
+
/**
* @brief Check whether user can change his display name
* @param $uid The username
@@ -530,7 +530,7 @@ class OC_User {
$displayNames = array_merge($displayNames, $backendDisplayNames);
}
}
- ksort($displayNames);
+ asort($displayNames);
return $displayNames;
}
@@ -589,8 +589,8 @@ class OC_User {
* @param string $userid
*/
public static function enableUser($userid) {
- $sql = "DELETE FROM `*PREFIX*preferences`'
- .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
+ $sql = 'DELETE FROM `*PREFIX*preferences`'
+ ." WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
$stmt = OC_DB::prepare($sql);
if ( ! OC_DB::isError($stmt) ) {
$result = $stmt->execute(array($userid, 'core', 'enabled', 'false'));
diff --git a/lib/user/backend.php b/lib/user/backend.php
index 60b3cc6c5e4..93e8f17ca98 100644
--- a/lib/user/backend.php
+++ b/lib/user/backend.php
@@ -124,7 +124,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
public function getHome($uid) {
return false;
}
-
+
/**
* @brief get display name of the user
* @param $uid user ID of the user
@@ -133,7 +133,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
public function getDisplayName($uid) {
return $uid;
}
-
+
/**
* @brief Get a list of all display names
* @returns array with all displayNames (value) and the corresponding uids (key)
diff --git a/lib/user/database.php b/lib/user/database.php
index a0ad03fe0a0..210c7f3e1eb 100644
--- a/lib/user/database.php
+++ b/lib/user/database.php
@@ -110,7 +110,7 @@ class OC_User_Database extends OC_User_Backend {
return false;
}
}
-
+
/**
* @brief Set display name
* @param $uid The username
@@ -146,7 +146,7 @@ class OC_User_Database extends OC_User_Backend {
}
}
}
-
+
/**
* @brief Get a list of all display names
* @returns array with all displayNames (value) and the correspondig uids (key)
@@ -162,7 +162,7 @@ class OC_User_Database extends OC_User_Backend {
while ($row = $result->fetchRow()) {
$displayNames[$row['uid']] = $row['displayname'];
}
-
+
// let's see if we can also find some users who don't have a display name yet
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`'
.' WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset);
@@ -173,11 +173,11 @@ class OC_User_Database extends OC_User_Backend {
$displayNames[$row['uid']] = $row['uid'];
}
}
-
-
+
+
return $displayNames;
}
-
+
/**
* @brief Check if the password is correct
* @param $uid The username
diff --git a/lib/util.php b/lib/util.php
index ab47e404c97..d8adfd99a47 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -75,7 +75,7 @@ class OC_Util {
public static function getVersion() {
// hint: We only can count up. Reset minor/patchlevel when
// updating major/minor version number.
- return array(4, 93, 10);
+ return array(4, 97, 10);
}
/**
@@ -83,7 +83,7 @@ class OC_Util {
* @return string
*/
public static function getVersionString() {
- return '5.0 beta 1';
+ return '5.0 RC 3';
}
/**
@@ -172,20 +172,20 @@ class OC_Util {
if(!(is_callable('sqlite_open') or class_exists('SQLite3'))
and !is_callable('mysql_connect')
and !is_callable('pg_connect')) {
- $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.<br/>',
+ $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.',
'hint'=>'');//TODO: sane hint
$web_server_restart= true;
}
//common hint for all file permissons error messages
- $permissionsHint="Permissions can usually be fixed by giving the webserver write access'
- .' to the ownCloud directory";
+ $permissionsHint='Permissions can usually be fixed by giving the webserver write access'
+ .' to the ownCloud directory';
// Check if config folder is writable.
if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) {
$errors[]=array('error'=>"Can't write into config directory 'config'",
- 'hint'=>"You can usually fix this by giving the webserver user write access'
- .' to the config directory in owncloud");
+ 'hint'=>'You can usually fix this by giving the webserver user write access'
+ .' to the config directory in owncloud');
}
// Check if there is a writable install folder.
@@ -194,8 +194,8 @@ class OC_Util {
|| !is_writable(OC_App::getInstallPath())
|| !is_readable(OC_App::getInstallPath()) ) {
$errors[]=array('error'=>"Can't write into apps directory",
- 'hint'=>"You can usually fix this by giving the webserver user write access'
- .' to the apps directory in owncloud or disabling the appstore in the config file.");
+ 'hint'=>'You can usually fix this by giving the webserver user write access'
+ .' to the apps directory in owncloud or disabling the appstore in the config file.');
}
}
$CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
@@ -211,80 +211,81 @@ class OC_Util {
."'chown -R www-data:www-data /path/to/your/owncloud/install/data' ");
}
} else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) {
- $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud<br/>',
+ $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud',
'hint'=>$permissionsHint);
} else {
$errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY));
}
// check if all required php modules are present
if(!class_exists('ZipArchive')) {
- $errors[]=array('error'=>'PHP module zip not installed.<br/>',
+ $errors[]=array('error'=>'PHP module zip not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
-
+ if(!class_exists('DOMDocument')) {
+ $errors[] = array('error' => 'PHP module dom not installed.',
+ 'hint' => 'Please ask your server administrator to install the module.');
+ $web_server_restart = false;
+ }
+ if(!function_exists('xml_parser_create')) {
+ $errors[] = array('error' => 'PHP module libxml not installed.',
+ 'hint' => 'Please ask your server administrator to install the module.');
+ $web_server_restart = false;
+ }
if(!function_exists('mb_detect_encoding')) {
- $errors[]=array('error'=>'PHP module mb multibyte not installed.<br/>',
+ $errors[]=array('error'=>'PHP module mb multibyte not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('ctype_digit')) {
- $errors[]=array('error'=>'PHP module ctype is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module ctype is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('json_encode')) {
- $errors[]=array('error'=>'PHP module JSON is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module JSON is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('imagepng')) {
- $errors[]=array('error'=>'PHP module GD is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module GD is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('gzencode')) {
- $errors[]=array('error'=>'PHP module zlib is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module zlib is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('iconv')) {
- $errors[]=array('error'=>'PHP module iconv is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module iconv is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(!function_exists('simplexml_load_string')) {
- $errors[]=array('error'=>'PHP module SimpleXML is not installed.<br/>',
+ $errors[]=array('error'=>'PHP module SimpleXML is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
if(floatval(phpversion())<5.3) {
- $errors[]=array('error'=>'PHP 5.3 is required.<br/>',
+ $errors[]=array('error'=>'PHP 5.3 is required.',
'hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher.'
.' PHP 5.2 is no longer supported by ownCloud and the PHP community.');
$web_server_restart= false;
}
if(!defined('PDO::ATTR_DRIVER_NAME')) {
- $errors[]=array('error'=>'PHP PDO module is not installed.<br/>',
+ $errors[]=array('error'=>'PHP PDO module is not installed.',
'hint'=>'Please ask your server administrator to install the module.');
$web_server_restart= false;
}
-
- $handler = ini_get("session.save_handler");
- if($handler == "files") {
- $tmpDir = session_save_path();
- if($tmpDir != "") {
- if(!@is_writable($tmpDir)) {
- $errors[]=array('error' => 'The temporary folder used by PHP to save the session data'
- .' is either incorrect or not writable! Please check : '.session_save_path().'<br/>',
- 'hint'=>'Please ask your server administrator to grant write access'
- .' or define another temporary folder.');
- }
- }
+ if(ini_get('safe_mode')) {
+ $errors[]=array('error'=>'PHP Safe Mode is enabled. ownCloud requires that it is disabled to work properly.',
+ 'hint'=>'PHP Safe Mode is a deprecated and mostly useless setting that should be disabled. Please ask your server administrator to disable it in php.ini or in your webserver config.');
+ $web_server_restart= false;
}
if($web_server_restart) {
- $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?<br/>',
+ $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?',
'hint'=>'Please ask your server administrator to restart the web server.');
}
@@ -308,7 +309,7 @@ class OC_Util {
clearstatcache();
$prems = substr(decoct(@fileperms($dataDirectory)), -3);
if (substr($prems, 2, 1) != '0') {
- $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users<br/>',
+ $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users',
'hint' => $permissionsModHint);
}
}
@@ -322,14 +323,14 @@ class OC_Util {
$parameters[$value] = true;
}
if (!empty($_POST['user'])) {
- $parameters["username"] = OC_Util::sanitizeHTML($_POST['user']).'"';
+ $parameters["username"] = $_POST['user'];
$parameters['user_autofocus'] = false;
} else {
$parameters["username"] = '';
$parameters['user_autofocus'] = true;
}
if (isset($_REQUEST['redirect_url'])) {
- $redirect_url = OC_Util::sanitizeHTML($_REQUEST['redirect_url']);
+ $redirect_url = $_REQUEST['redirect_url'];
$parameters['redirect_url'] = urlencode($redirect_url);
}
@@ -463,13 +464,17 @@ class OC_Util {
* @see OC_Util::callRegister()
*/
public static function isCallRegistered() {
+ if(!isset($_SESSION['requesttoken'])) {
+ return false;
+ }
+
if(isset($_GET['requesttoken'])) {
$token=$_GET['requesttoken'];
- }elseif(isset($_POST['requesttoken'])) {
+ } elseif(isset($_POST['requesttoken'])) {
$token=$_POST['requesttoken'];
- }elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])) {
+ } elseif(isset($_SERVER['HTTP_REQUESTTOKEN'])) {
$token=$_SERVER['HTTP_REQUESTTOKEN'];
- }else{
+ } else {
//no token found.
return false;
}
@@ -504,10 +509,10 @@ class OC_Util {
* @return array with sanitized strings or a single sanitized string, depends on the input parameter.
*/
public static function sanitizeHTML( &$value ) {
- if (is_array($value) || is_object($value)) {
+ if (is_array($value)) {
array_walk_recursive($value, 'OC_Util::sanitizeHTML');
} else {
- $value = htmlentities($value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4
+ $value = htmlentities((string)$value, ENT_QUOTES, 'UTF-8'); //Specify encoding for PHP<5.4
}
return $value;
}
@@ -564,13 +569,21 @@ class OC_Util {
if (!function_exists('curl_init')) {
return true;
}
-
$settings = array(
'baseUri' => OC_Helper::linkToRemote('webdav'),
);
+ // save the old timeout so that we can restore it later
+ $old_timeout=ini_get("default_socket_timeout");
+
+ // use a 5 sec timeout for the check. Should be enough for local requests.
+ ini_set("default_socket_timeout", 5);
+
$client = new \Sabre_DAV_Client($settings);
+ // for this self test we don't care if the ssl certificate is self signed and the peer cannot be verified.
+ $client->setVerifyPeer(false);
+
$return = true;
try {
// test PROPFIND
@@ -582,6 +595,9 @@ class OC_Util {
$return = false;
}
+ // restore the original timeout
+ ini_set("default_socket_timeout", $old_timeout);
+
return $return;
}
diff --git a/lib/vcategories.php b/lib/vcategories.php
index 8de497a6191..2f990c5d2d2 100644
--- a/lib/vcategories.php
+++ b/lib/vcategories.php
@@ -306,12 +306,18 @@ class OC_VCategories {
OCP\Util::writeLog('core', __METHOD__.', name: ' . $name. ' exists already', OCP\Util::DEBUG);
return false;
}
- OCP\DB::insertIfNotExist(self::CATEGORY_TABLE,
- array(
- 'uid' => $this->user,
- 'type' => $this->type,
- 'category' => $name,
- ));
+ try {
+ OCP\DB::insertIfNotExist(self::CATEGORY_TABLE,
+ array(
+ 'uid' => $this->user,
+ 'type' => $this->type,
+ 'category' => $name,
+ ));
+ } catch(Exception $e) {
+ OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ OCP\Util::ERROR);
+ return false;
+ }
$id = OCP\DB::insertid(self::CATEGORY_TABLE);
OCP\Util::writeLog('core', __METHOD__.', id: ' . $id, OCP\Util::DEBUG);
$this->categories[$id] = $name;
@@ -342,12 +348,11 @@ class OC_VCategories {
self::$relations[] = array('objid' => $id, 'category' => $name);
}
}
- if(count($newones) > 0) {
- $this->categories = array_merge($this->categories, $newones);
- if($sync === true) {
- $this->save();
- }
+ $this->categories = array_merge($this->categories, $newones);
+ if($sync === true) {
+ $this->save();
}
+
return true;
}
@@ -436,12 +441,17 @@ class OC_VCategories {
private function save() {
if(is_array($this->categories)) {
foreach($this->categories as $category) {
- OCP\DB::insertIfNotExist(self::CATEGORY_TABLE,
- array(
- 'uid' => $this->user,
- 'type' => $this->type,
- 'category' => $category,
- ));
+ try {
+ OCP\DB::insertIfNotExist(self::CATEGORY_TABLE,
+ array(
+ 'uid' => $this->user,
+ 'type' => $this->type,
+ 'category' => $category,
+ ));
+ } catch(Exception $e) {
+ OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ OCP\Util::ERROR);
+ }
}
// reload categories to get the proper ids.
$this->loadCategories();
@@ -454,12 +464,17 @@ class OC_VCategories {
$catid = $this->array_searchi($relation['category'], $categories);
OC_Log::write('core', __METHOD__ . 'catid, ' . $relation['category'] . ' ' . $catid, OC_Log::DEBUG);
if($catid) {
- OCP\DB::insertIfNotExist(self::RELATION_TABLE,
- array(
- 'objid' => $relation['objid'],
- 'categoryid' => $catid,
- 'type' => $this->type,
- ));
+ try {
+ OCP\DB::insertIfNotExist(self::RELATION_TABLE,
+ array(
+ 'objid' => $relation['objid'],
+ 'categoryid' => $catid,
+ 'type' => $this->type,
+ ));
+ } catch(Exception $e) {
+ OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(),
+ OCP\Util::ERROR);
+ }
}
}
self::$relations = array(); // reset