summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authortomneedham <tom@owncloud.com>2013-12-11 09:12:47 +0000
committertomneedham <tom@owncloud.com>2013-12-11 09:12:47 +0000
commit7afe6b349352f90bec5a8409bf5c23494f808f1a (patch)
treec0e4294c123a42b519ac168259a113efadbebed7 /lib/private
parent37b07fe6a9e512214852584fb15056f008509882 (diff)
parent28180485d9d767a081656e403fe7c8210957f976 (diff)
downloadnextcloud-server-7afe6b349352f90bec5a8409bf5c23494f808f1a.tar.gz
nextcloud-server-7afe6b349352f90bec5a8409bf5c23494f808f1a.zip
Merge branch 'master' into fix-5388-master
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/appframework/app.php6
-rw-r--r--lib/private/appframework/routing/routeactionhandler.php2
-rw-r--r--lib/private/avatar.php10
-rw-r--r--lib/private/backgroundjob/job.php23
-rw-r--r--lib/private/backgroundjob/queuedjob.php5
-rw-r--r--lib/private/backgroundjob/timedjob.php6
-rw-r--r--lib/private/connector/sabre/file.php2
-rw-r--r--lib/private/connector/sabre/filesplugin.php12
-rw-r--r--lib/private/db/mdb2schemamanager.php2
-rw-r--r--lib/private/defaults.php50
-rw-r--r--lib/private/files.php3
-rw-r--r--lib/private/files/cache/cache.php4
-rw-r--r--lib/private/files/cache/scanner.php2
-rw-r--r--lib/private/files/cache/updater.php12
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php8
-rw-r--r--lib/private/files/view.php8
-rw-r--r--lib/private/installer.php3
-rw-r--r--lib/private/l10n.php2
-rw-r--r--lib/private/log/owncloud.php2
-rwxr-xr-xlib/private/preview.php41
-rw-r--r--lib/private/repair.php21
-rwxr-xr-xlib/private/request.php36
-rw-r--r--lib/private/setup/abstractdatabase.php4
-rw-r--r--lib/private/setup/oci.php63
-rw-r--r--lib/private/updater.php7
-rw-r--r--lib/private/user.php20
-rw-r--r--lib/private/user/backend.php15
-rw-r--r--lib/private/user/user.php12
-rwxr-xr-xlib/private/util.php29
29 files changed, 327 insertions, 83 deletions
diff --git a/lib/private/appframework/app.php b/lib/private/appframework/app.php
index 6d3effbf1fa..b835188661a 100644
--- a/lib/private/appframework/app.php
+++ b/lib/private/appframework/app.php
@@ -43,8 +43,12 @@ class App {
* stored in the DI container
* @param string $methodName the method that you want to call
* @param DIContainer $container an instance of a pimple container.
+ * @param array $urlParams list of URL parameters (optional)
*/
- public static function main($controllerName, $methodName, IAppContainer $container) {
+ public static function main($controllerName, $methodName, DIContainer $container, array $urlParams = null) {
+ if (!is_null($urlParams)) {
+ $container['urlParams'] = $urlParams;
+ }
$controller = $container[$controllerName];
// initialize the dispatcher and run all the middleware before the controller
diff --git a/lib/private/appframework/routing/routeactionhandler.php b/lib/private/appframework/routing/routeactionhandler.php
index 7fb56f14eab..2b9dc38dc43 100644
--- a/lib/private/appframework/routing/routeactionhandler.php
+++ b/lib/private/appframework/routing/routeactionhandler.php
@@ -37,6 +37,6 @@ class RouteActionHandler {
}
public function __invoke($params) {
- App::main($this->controllerName, $this->actionName, $params, $this->container);
+ App::main($this->controllerName, $this->actionName, $this->container, $params);
}
}
diff --git a/lib/private/avatar.php b/lib/private/avatar.php
index 814a9b22bed..e97f55eecaf 100644
--- a/lib/private/avatar.php
+++ b/lib/private/avatar.php
@@ -44,15 +44,19 @@ class OC_Avatar implements \OCP\IAvatar {
/**
* @brief sets the users avatar
- * @param $data mixed imagedata or path to set a new avatar
+ * @param $data mixed OC_Image, imagedata or path to set a new avatar
* @throws Exception if the provided file is not a jpg or png image
* @throws Exception if the provided image is not valid
* @throws \OC\NotSquareException if the image is not square
* @return void
*/
public function set ($data) {
-
- $img = new OC_Image($data);
+ if($data instanceOf OC_Image) {
+ $img = $data;
+ $data = $img->data();
+ } else {
+ $img = new OC_Image($data);
+ }
$type = substr($img->mimeType(), -3);
if ($type === 'peg') {
$type = 'jpg';
diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php
index 49fbffbd684..92bd0f8fdbd 100644
--- a/lib/private/backgroundjob/job.php
+++ b/lib/private/backgroundjob/job.php
@@ -9,16 +9,35 @@
namespace OC\BackgroundJob;
abstract class Job {
+ /**
+ * @var int $id
+ */
protected $id;
+
+ /**
+ * @var int $lastRun
+ */
protected $lastRun;
+
+ /**
+ * @var mixed $argument
+ */
protected $argument;
/**
* @param JobList $jobList
+ * @param \OC\Log $logger
*/
- public function execute($jobList) {
+ public function execute($jobList, $logger = null) {
$jobList->setLastRun($this);
- $this->run($this->argument);
+ try {
+ $this->run($this->argument);
+ } catch (\Exception $e) {
+ if ($logger) {
+ $logger->error('Error while running background job: ' . $e->getMessage());
+ }
+ $jobList->remove($this, $this->argument);
+ }
}
abstract protected function run($argument);
diff --git a/lib/private/backgroundjob/queuedjob.php b/lib/private/backgroundjob/queuedjob.php
index 1714182820d..799eac47848 100644
--- a/lib/private/backgroundjob/queuedjob.php
+++ b/lib/private/backgroundjob/queuedjob.php
@@ -20,9 +20,10 @@ abstract class QueuedJob extends Job {
* run the job, then remove it from the joblist
*
* @param JobList $jobList
+ * @param \OC\Log $logger
*/
- public function execute($jobList) {
+ public function execute($jobList, $logger = null) {
$jobList->remove($this);
- $this->run($this->argument);
+ parent::execute($jobList, $logger);
}
}
diff --git a/lib/private/backgroundjob/timedjob.php b/lib/private/backgroundjob/timedjob.php
index ae9f33505ab..09e05f1d846 100644
--- a/lib/private/backgroundjob/timedjob.php
+++ b/lib/private/backgroundjob/timedjob.php
@@ -31,11 +31,11 @@ abstract class TimedJob extends Job {
* run the job if
*
* @param JobList $jobList
+ * @param \OC\Log $logger
*/
- public function execute($jobList) {
+ public function execute($jobList, $logger = null) {
if ((time() - $this->lastRun) > $this->interval) {
- $jobList->setLastRun($this);
- $this->run($this->argument);
+ parent::execute($jobList, $logger);
}
}
}
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index 26b5d200bde..295575f0af6 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -249,7 +249,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
// allow sync clients to send the mtime along in a header
$mtime = OC_Request::hasModificationTime();
if ($mtime !== false) {
- if($fs->touch($this->path, $mtime)) {
+ if($fs->touch($targetPath, $mtime)) {
header('X-OC-MTime: accepted');
}
}
diff --git a/lib/private/connector/sabre/filesplugin.php b/lib/private/connector/sabre/filesplugin.php
index 1c80ebe8044..65231040fb5 100644
--- a/lib/private/connector/sabre/filesplugin.php
+++ b/lib/private/connector/sabre/filesplugin.php
@@ -78,7 +78,19 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin
* @throws Sabre_DAV_Exception_BadRequest
*/
public function sendFileIdHeader($filePath, Sabre_DAV_INode $node = null) {
+ // chunked upload handling
+ if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
+ list($path, $name) = \Sabre_DAV_URLUtil::splitPath($filePath);
+ $info = OC_FileChunking::decodeName($name);
+ if (!empty($info)) {
+ $filePath = $path . '/' . $info['name'];
+ }
+ }
+
// we get the node for the given $filePath here because in case of afterCreateFile $node is the parent folder
+ if (!$this->server->tree->nodeExists($filePath)) {
+ return;
+ }
$node = $this->server->tree->getNodeForPath($filePath);
if ($node instanceof OC_Connector_Sabre_Node) {
$fileId = $node->getFileId();
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 416e2f55426..6378c769055 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -19,6 +19,8 @@ class MDB2SchemaManager {
*/
public function __construct($conn) {
$this->conn = $conn;
+ $this->conn->close();
+ $this->conn->connect();
}
/**
diff --git a/lib/private/defaults.php b/lib/private/defaults.php
index 4951c6f50ae..cec9a65c7f3 100644
--- a/lib/private/defaults.php
+++ b/lib/private/defaults.php
@@ -1,15 +1,13 @@
<?php
-/**
- * Default strings and values which differ between the enterprise and the
- * community edition. Use the get methods to always get the right strings.
- */
-
-
if (file_exists(OC::$SERVERROOT . '/themes/' . OC_Util::getTheme() . '/defaults.php')) {
require_once 'themes/' . OC_Util::getTheme() . '/defaults.php';
}
+/**
+ * Default strings and values which differ between the enterprise and the
+ * community edition. Use the get methods to always get the right strings.
+ */
class OC_Defaults {
private $theme;
@@ -48,6 +46,10 @@ class OC_Defaults {
return false;
}
+ /**
+ * Returns the base URL
+ * @return string URL
+ */
public function getBaseUrl() {
if ($this->themeExist('getBaseUrl')) {
return $this->theme->getBaseUrl();
@@ -56,6 +58,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns the URL where the sync clients are listed
+ * @return string URL
+ */
public function getSyncClientUrl() {
if ($this->themeExist('getSyncClientUrl')) {
return $this->theme->getSyncClientUrl();
@@ -64,6 +70,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns the documentation URL
+ * @return string URL
+ */
public function getDocBaseUrl() {
if ($this->themeExist('getDocBaseUrl')) {
return $this->theme->getDocBaseUrl();
@@ -72,6 +82,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns the title
+ * @return string title
+ */
public function getTitle() {
if ($this->themeExist('getTitle')) {
return $this->theme->getTitle();
@@ -80,6 +94,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns the short name of the software
+ * @return string title
+ */
public function getName() {
if ($this->themeExist('getName')) {
return $this->theme->getName();
@@ -88,6 +106,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns entity (e.g. company name) - used for footer, copyright
+ * @return string entity name
+ */
public function getEntity() {
if ($this->themeExist('getEntity')) {
return $this->theme->getEntity();
@@ -96,6 +118,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns slogan
+ * @return string slogan
+ */
public function getSlogan() {
if ($this->themeExist('getSlogan')) {
return $this->theme->getSlogan();
@@ -104,6 +130,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns logo claim
+ * @return string logo claim
+ */
public function getLogoClaim() {
if ($this->themeExist('getLogoClaim')) {
return $this->theme->getLogoClaim();
@@ -112,6 +142,10 @@ class OC_Defaults {
}
}
+ /**
+ * Returns short version of the footer
+ * @return string short footer
+ */
public function getShortFooter() {
if ($this->themeExist('getShortFooter')) {
$footer = $this->theme->getShortFooter();
@@ -123,6 +157,10 @@ class OC_Defaults {
return $footer;
}
+ /**
+ * Returns long version of the footer
+ * @return string long footer
+ */
public function getLongFooter() {
if ($this->themeExist('getLongFooter')) {
$footer = $this->theme->getLongFooter();
diff --git a/lib/private/files.php b/lib/private/files.php
index 8b8ff81ec5e..6ffa14c0d91 100644
--- a/lib/private/files.php
+++ b/lib/private/files.php
@@ -109,6 +109,9 @@ class OC_Files {
$zip = false;
$filename = $dir . '/' . $files;
$name = $files;
+ if ($xsendfile && OC_App::isEnabled('files_encryption')) {
+ $xsendfile = false;
+ }
}
OC_Util::obEnd();
if ($zip or \OC\Files\Filesystem::isReadable($filename)) {
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index ac50a988e32..8e682a96b75 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -178,6 +178,10 @@ class Cache {
if ($file['storage_mtime'] == 0) {
$file['storage_mtime'] = $file['mtime'];
}
+ if ($file['encrypted']) {
+ $file['encrypted_size'] = $file['size'];
+ $file['size'] = $file['unencrypted_size'];
+ }
}
return $files;
} else {
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index 34184c68c64..a8c069ee99f 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -286,7 +286,7 @@ class Scanner extends BasicEmitter {
public function backgroundScan() {
$lastPath = null;
while (($path = $this->cache->getIncomplete()) !== false && $path !== $lastPath) {
- $this->scan($path);
+ $this->scan($path, self::SCAN_RECURSIVE, self::REUSE_ETAG);
$this->cache->correctFolderSize($path);
$lastPath = $path;
}
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index d45c5e17fc8..73bc30e538f 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -59,9 +59,13 @@ class Updater {
*/
list($storage, $internalPath) = self::resolvePath($path);
if ($storage) {
+ $parent = dirname($internalPath);
+ if ($parent === '.') {
+ $parent = '';
+ }
$cache = $storage->getCache($internalPath);
$cache->remove($internalPath);
- $cache->correctFolderSize($internalPath);
+ $cache->correctFolderSize($parent);
self::correctFolder($path, time());
self::correctParentStorageMtime($storage, $internalPath);
}
@@ -86,6 +90,12 @@ class Updater {
if ($storageFrom === $storageTo) {
$cache = $storageFrom->getCache($internalFrom);
$cache->move($internalFrom, $internalTo);
+ if (pathinfo($internalFrom, PATHINFO_EXTENSION) !== pathinfo($internalTo, PATHINFO_EXTENSION)) {
+ // redetect mime type change
+ $mimeType = $storageTo->getMimeType($internalTo);
+ $fileId = $storageTo->getCache()->getId($internalTo);
+ $storageTo->getCache()->update($fileId, array('mimetype' => $mimeType));
+ }
$cache->correctFolderSize($internalFrom);
$cache->correctFolderSize($internalTo);
self::correctFolder($from, time());
diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index 0336c27efa1..f9adda80314 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -424,4 +424,12 @@ class Wrapper implements \OC\Files\Storage\Storage {
public function getETag($path) {
return $this->storage->getETag($path);
}
+
+ /**
+ * Returns true
+ * @return true
+ */
+ public function test() {
+ return $this->storage->test();
+ }
}
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 8cb56ede91b..ac45a881331 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -159,7 +159,11 @@ class View {
}
public function rmdir($path) {
- return $this->basicOperation('rmdir', $path, array('delete'));
+ if ($this->is_dir($path)) {
+ return $this->basicOperation('rmdir', $path, array('delete'));
+ } else {
+ return false;
+ }
}
public function opendir($path) {
@@ -712,7 +716,7 @@ class View {
return false;
}
$defaultRoot = Filesystem::getRoot();
- if($this->fakeRoot === $defaultRoot){
+ if ($this->fakeRoot === $defaultRoot) {
return true;
}
return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 9b49543c3fb..8375b231e9b 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -460,8 +460,7 @@ class OC_Installer{
);
// is the code checker enabled?
- if(OC_Config::getValue('appcodechecker', false)) {
-
+ if(OC_Config::getValue('appcodechecker', true)) {
// check if grep is installed
$grep = exec('which grep');
if($grep=='') {
diff --git a/lib/private/l10n.php b/lib/private/l10n.php
index 2d440850459..98665c84c55 100644
--- a/lib/private/l10n.php
+++ b/lib/private/l10n.php
@@ -262,7 +262,7 @@ class OC_L10N implements \OCP\IL10N {
*/
public function n($text_singular, $text_plural, $count, $parameters = array()) {
$this->init();
- $identifier = "_${text_singular}__${text_plural}_";
+ $identifier = "_${text_singular}_::_${text_plural}_";
if( array_key_exists($identifier, $this->translations)) {
return new OC_L10N_String( $this, $identifier, $parameters, $count );
}
diff --git a/lib/private/log/owncloud.php b/lib/private/log/owncloud.php
index 15cace88f41..4c86d0e45e0 100644
--- a/lib/private/log/owncloud.php
+++ b/lib/private/log/owncloud.php
@@ -68,6 +68,8 @@ class OC_Log_Owncloud {
$timezone = new DateTimeZone('UTC');
}
$time = new DateTime(null, $timezone);
+ // remove username/passswords from URLs before writing the to the log file
+ $message = preg_replace('/\/\/(.*):(.*)@/', '//xxx:xxx@', $message);
$entry=array('app'=>$app, 'message'=>$message, 'level'=>$level, 'time'=> $time->format($format));
$entry = json_encode($entry);
$handle = @fopen(self::$logFile, 'a');
diff --git a/lib/private/preview.php b/lib/private/preview.php
index 266f7795f12..ff93f438f73 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -9,7 +9,7 @@
* Thumbnails:
* structure of filename:
* /data/user/thumbnails/pathhash/x-y.png
- *
+ *
*/
namespace OC;
@@ -40,6 +40,7 @@ class Preview {
private $maxX;
private $maxY;
private $scalingup;
+ private $mimetype;
//preview images object
/**
@@ -59,11 +60,18 @@ class Preview {
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
* @param bool $scalingUp Disable/Enable upscaling of previews
- * @return mixed (bool / string)
+ * @return mixed (bool / string)
* false if thumbnail does not exist
* path to thumbnail if thumbnail exists
*/
public function __construct($user='', $root='/', $file='', $maxX=1, $maxY=1, $scalingUp=true) {
+ //init fileviews
+ if($user === ''){
+ $user = \OC_User::getUser();
+ }
+ $this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
+ $this->userView = new \OC\Files\View('/' . $user);
+
//set config
$this->configMaxX = \OC_Config::getValue('preview_max_x', null);
$this->configMaxY = \OC_Config::getValue('preview_max_y', null);
@@ -75,13 +83,6 @@ class Preview {
$this->setMaxY($maxY);
$this->setScalingUp($scalingUp);
- //init fileviews
- if($user === ''){
- $user = \OC_User::getUser();
- }
- $this->fileView = new \OC\Files\View('/' . $user . '/' . $root);
- $this->userView = new \OC\Files\View('/' . $user);
-
$this->preview = null;
//check if there are preview backends
@@ -166,10 +167,21 @@ class Preview {
*/
public function setFile($file) {
$this->file = $file;
+ if ($file !== '') {
+ $this->mimetype = $this->fileView->getMimeType($this->file);
+ }
return $this;
}
/**
+ * @brief set mimetype explicitely
+ * @param string $mimetype
+ */
+ public function setMimetype($mimetype) {
+ $this->mimetype = $mimetype;
+ }
+
+ /**
* @brief set the the max width of the preview
* @param int $maxX
* @return $this
@@ -265,7 +277,7 @@ class Preview {
$fileInfo = $this->fileView->getFileInfo($file);
$fileId = $fileInfo['fileid'];
-
+
$previewPath = $this->getThumbnailsFolder() . '/' . $fileId . '/';
$this->userView->deleteAll($previewPath);
$this->userView->rmdir($previewPath);
@@ -274,7 +286,7 @@ class Preview {
/**
* @brief check if thumbnail or bigger version of thumbnail of file is cached
- * @return mixed (bool / string)
+ * @return mixed (bool / string)
* false if thumbnail does not exist
* path to thumbnail if thumbnail exists
*/
@@ -386,11 +398,10 @@ class Preview {
}
if(is_null($this->preview)) {
- $mimetype = $this->fileView->getMimeType($file);
$preview = null;
foreach(self::$providers as $supportedMimetype => $provider) {
- if(!preg_match($supportedMimetype, $mimetype)) {
+ if(!preg_match($supportedMimetype, $this->mimetype)) {
continue;
}
@@ -516,7 +527,7 @@ class Preview {
$cropY = 0;
$image->crop($cropX, $cropY, $x, $y);
-
+
$this->preview = $image;
return;
}
@@ -598,7 +609,7 @@ class Preview {
public static function post_write($args) {
self::post_delete($args);
}
-
+
public static function post_delete($args) {
$path = $args['path'];
if(substr($path, 0, 1) === '/') {
diff --git a/lib/private/repair.php b/lib/private/repair.php
new file mode 100644
index 00000000000..e9de3baa7ce
--- /dev/null
+++ b/lib/private/repair.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC;
+
+use OC\Hooks\BasicEmitter;
+
+class Repair extends BasicEmitter {
+ /**
+ * run a series of repair steps for common problems
+ * progress can be reported by emitting \OC\Repair::step events
+ */
+ public function run() {
+ $this->emit('\OC\Repair', 'step', array('No repair steps configured at the moment'));
+ }
+}
diff --git a/lib/private/request.php b/lib/private/request.php
index d11e5b16cfe..b2afda35922 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -136,12 +136,40 @@ class OC_Request {
* @returns string Path info or false when not found
*/
public static function getRawPathInfo() {
- $path_info = substr($_SERVER['REQUEST_URI'], strlen($_SERVER['SCRIPT_NAME']));
+ $requestUri = $_SERVER['REQUEST_URI'];
+ // remove too many leading slashes - can be caused by reverse proxy configuration
+ if (strpos($requestUri, '/') === 0) {
+ $requestUri = '/' . ltrim($requestUri, '/');
+ }
+
// Remove the query string from REQUEST_URI
- if ($pos = strpos($path_info, '?')) {
- $path_info = substr($path_info, 0, $pos);
+ if ($pos = strpos($requestUri, '?')) {
+ $requestUri = substr($requestUri, 0, $pos);
+ }
+
+ $scriptName = $_SERVER['SCRIPT_NAME'];
+ $path_info = $requestUri;
+
+ // strip off the script name's dir and file name
+ list($path, $name) = \Sabre_DAV_URLUtil::splitPath($scriptName);
+ if (!empty($path)) {
+ if( $path === $path_info || strpos($path_info, $path.'/') === 0) {
+ $path_info = substr($path_info, strlen($path));
+ } else {
+ throw new Exception("The requested uri($requestUri) cannot be processed by the script '$scriptName')");
+ }
+ }
+ if (strpos($path_info, '/'.$name) === 0) {
+ $path_info = substr($path_info, strlen($name) + 1);
+ }
+ if (strpos($path_info, $name) === 0) {
+ $path_info = substr($path_info, strlen($name));
+ }
+ if($path_info === '/'){
+ return '';
+ } else {
+ return $path_info;
}
- return $path_info;
}
/**
diff --git a/lib/private/setup/abstractdatabase.php b/lib/private/setup/abstractdatabase.php
index 0beada7bd29..84625a217ee 100644
--- a/lib/private/setup/abstractdatabase.php
+++ b/lib/private/setup/abstractdatabase.php
@@ -3,6 +3,10 @@
namespace OC\Setup;
abstract class AbstractDatabase {
+
+ /**
+ * @var \OC_L10N
+ */
protected $trans;
protected $dbDefinitionFile;
protected $dbuser;
diff --git a/lib/private/setup/oci.php b/lib/private/setup/oci.php
index 326d7a00531..24863b9e38a 100644
--- a/lib/private/setup/oci.php
+++ b/lib/private/setup/oci.php
@@ -29,10 +29,10 @@ class OCI extends AbstractDatabase {
\OC_Log::write('setup oracle', 'connect string: ' . $easy_connect_string, \OC_Log::DEBUG);
$connection = @oci_connect($this->dbuser, $this->dbpassword, $easy_connect_string);
if(!$connection) {
- $e = oci_error();
- if (is_array ($e) && isset ($e['message'])) {
+ $errorMessage = $this->getLastError();
+ if ($errorMessage) {
throw new \DatabaseSetupException($this->trans->t('Oracle connection could not be established'),
- $e['message'].' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
+ $errorMessage.' Check environment: ORACLE_HOME='.getenv('ORACLE_HOME')
.' ORACLE_SID='.getenv('ORACLE_SID')
.' LD_LIBRARY_PATH='.getenv('LD_LIBRARY_PATH')
.' NLS_LANG='.getenv('NLS_LANG')
@@ -51,7 +51,7 @@ class OCI extends AbstractDatabase {
." WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'";
$stmt = oci_parse($connection, $query);
if (!$stmt) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_last_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
@@ -68,25 +68,25 @@ class OCI extends AbstractDatabase {
$this->dbpassword=\OC_Util::generateRandomBytes(30);
//oracle passwords are treated as identifiers:
- // must start with aphanumeric char
+ // must start with alphanumeric char
// needs to be shortened to 30 bytes, as the two " needed to escape the identifier count towards the identifier length.
$this->dbpassword=substr($this->dbpassword, 0, 30);
$this->createDBUser($connection);
- \OC_Config::setValue('dbuser', $this->dbusername);
- \OC_Config::setValue('dbname', $this->dbusername);
+ \OC_Config::setValue('dbuser', $this->dbuser);
+ \OC_Config::setValue('dbname', $this->dbuser);
\OC_Config::setValue('dbpassword', $this->dbpassword);
- //create the database not neccessary, oracle implies user = schema
- //$this->createDatabase($this->dbname, $this->dbusername, $connection);
+ //create the database not necessary, oracle implies user = schema
+ //$this->createDatabase($this->dbname, $this->dbuser, $connection);
} else {
\OC_Config::setValue('dbuser', $this->dbuser);
\OC_Config::setValue('dbname', $this->dbname);
\OC_Config::setValue('dbpassword', $this->dbpassword);
- //create the database not neccessary, oracle implies user = schema
+ //create the database not necessary, oracle implies user = schema
//$this->createDatabase($this->dbname, $this->dbuser, $connection);
}
@@ -115,10 +115,10 @@ class OCI extends AbstractDatabase {
}
$query = "SELECT count(*) FROM user_tables WHERE table_name = :un";
$stmt = oci_parse($connection, $query);
- $un = $this->dbtableprefix.'users';
+ $un = $this->tableprefix.'users';
oci_bind_by_name($stmt, ':un', $un);
if (!$stmt) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
@@ -133,25 +133,22 @@ class OCI extends AbstractDatabase {
}
/**
- *
- * @param String $name
- * @param String $password
* @param resource $connection
*/
private function createDBUser($connection) {
$name = $this->dbuser;
- $password = $this->password;
+ $password = $this->dbpassword;
$query = "SELECT * FROM all_users WHERE USERNAME = :un";
$stmt = oci_parse($connection, $query);
if (!$stmt) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
oci_bind_by_name($stmt, ':un', $name);
$result = oci_execute($stmt);
if(!$result) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
@@ -162,14 +159,14 @@ class OCI extends AbstractDatabase {
$query = 'CREATE USER '.$name.' IDENTIFIED BY "'.$password.'" DEFAULT TABLESPACE '.$this->dbtablespace;
$stmt = oci_parse($connection, $query);
if (!$stmt) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
//oci_bind_by_name($stmt, ':un', $name);
$result = oci_execute($stmt);
if(!$result) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
array($query, $name, $password)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
@@ -178,7 +175,7 @@ class OCI extends AbstractDatabase {
$query = "ALTER USER :un IDENTIFIED BY :pw";
$stmt = oci_parse($connection, $query);
if (!$stmt) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
@@ -186,7 +183,7 @@ class OCI extends AbstractDatabase {
oci_bind_by_name($stmt, ':pw', $password);
$result = oci_execute($stmt);
if(!$result) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
@@ -195,16 +192,34 @@ class OCI extends AbstractDatabase {
$query = 'GRANT CREATE SESSION, CREATE TABLE, CREATE SEQUENCE, CREATE TRIGGER, UNLIMITED TABLESPACE TO '.$name;
$stmt = oci_parse($connection, $query);
if (!$stmt) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s"', array($query)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
$result = oci_execute($stmt);
if(!$result) {
- $entry = $this->trans->t('DB Error: "%s"', array(oci_error($connection))) . '<br />';
+ $entry = $this->trans->t('DB Error: "%s"', array($this->getLastError($connection))) . '<br />';
$entry .= $this->trans->t('Offending command was: "%s", name: %s, password: %s',
array($query, $name, $password)) . '<br />';
\OC_Log::write('setup.oci', $entry, \OC_Log::WARN);
}
}
+
+ /**
+ * @param resource $connection
+ * @return string
+ */
+ protected function getLastError($connection = null) {
+ if ($connection) {
+ $error = oci_error($connection);
+ } else {
+ $error = oci_error();
+ }
+ foreach (array('message', 'code') as $key) {
+ if (isset($error[$key])) {
+ return $error[$key];
+ }
+ }
+ return '';
+ }
}
diff --git a/lib/private/updater.php b/lib/private/updater.php
index 9827d8a8c12..764a0f14120 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -37,7 +37,7 @@ class Updater extends BasicEmitter {
/**
* Check if a new version is available
- * @param string $updateUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
+ * @param string $updaterUrl the url to check, i.e. 'http://apps.owncloud.com/updater.php'
* @return array | bool
*/
public function check($updaterUrl) {
@@ -58,6 +58,7 @@ class Updater extends BasicEmitter {
$version['updated'] = \OC_Appconfig::getValue('core', 'lastupdatedat');
$version['updatechannel'] = \OC_Util::getChannel();
$version['edition'] = \OC_Util::getEditionString();
+ $version['build'] = \OC_Util::getBuild();
$versionString = implode('x', $version);
//fetch xml data from updater
@@ -115,6 +116,10 @@ class Updater extends BasicEmitter {
\OC_App::checkAppsRequirements();
// load all apps to also upgrade enabled apps
\OC_App::loadApps();
+
+ $repair = new Repair();
+ $repair->run();
+
\OC_Config::setValue('maintenance', false);
$this->emit('\OC\Updater', 'maintenanceEnd');
}
diff --git a/lib/private/user.php b/lib/private/user.php
index 5bd36006750..e0d6b9f3f51 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -314,7 +314,7 @@ class OC_User {
* Checks if the user is logged in
*/
public static function isLoggedIn() {
- if (\OC::$session->get('user_id')) {
+ if (\OC::$session->get('user_id') && self::$incognitoMode === false) {
OC_App::loadApps(array('authentication'));
self::setupBackends();
return self::userExists(\OC::$session->get('user_id'));
@@ -353,7 +353,7 @@ class OC_User {
* @return bool
*/
public static function isAdminUser($uid) {
- if (OC_Group::inGroup($uid, 'admin')) {
+ if (OC_Group::inGroup($uid, 'admin') && self::$incognitoMode === false) {
return true;
}
return false;
@@ -425,6 +425,22 @@ class OC_User {
}
/**
+ * @brief Check whether user can change his avatar
+ * @param string $uid The username
+ * @return bool
+ *
+ * Check whether a specified user can change his avatar
+ */
+ public static function canUserChangeAvatar($uid) {
+ $user = self::getManager()->get($uid);
+ if ($user) {
+ return $user->canChangeAvatar();
+ } else {
+ return false;
+ }
+ }
+
+ /**
* @brief Check whether user can change his password
* @param string $uid The username
* @return bool
diff --git a/lib/private/user/backend.php b/lib/private/user/backend.php
index e9be08e429c..02c93d13bdf 100644
--- a/lib/private/user/backend.php
+++ b/lib/private/user/backend.php
@@ -31,13 +31,13 @@ define('OC_USER_BACKEND_NOT_IMPLEMENTED', -501);
/**
* actions that user backends can define
*/
-define('OC_USER_BACKEND_CREATE_USER', 0x000001);
-define('OC_USER_BACKEND_SET_PASSWORD', 0x000010);
-define('OC_USER_BACKEND_CHECK_PASSWORD', 0x000100);
-define('OC_USER_BACKEND_GET_HOME', 0x001000);
-define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x010000);
-define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x100000);
-
+define('OC_USER_BACKEND_CREATE_USER', 0x0000001);
+define('OC_USER_BACKEND_SET_PASSWORD', 0x0000010);
+define('OC_USER_BACKEND_CHECK_PASSWORD', 0x0000100);
+define('OC_USER_BACKEND_GET_HOME', 0x0001000);
+define('OC_USER_BACKEND_GET_DISPLAYNAME', 0x0010000);
+define('OC_USER_BACKEND_SET_DISPLAYNAME', 0x0100000);
+define('OC_USER_BACKEND_PROVIDE_AVATAR', 0x1000000);
/**
* Abstract base class for user management. Provides methods for querying backend
@@ -54,6 +54,7 @@ abstract class OC_User_Backend implements OC_User_Interface {
OC_USER_BACKEND_GET_HOME => 'getHome',
OC_USER_BACKEND_GET_DISPLAYNAME => 'getDisplayName',
OC_USER_BACKEND_SET_DISPLAYNAME => 'setDisplayName',
+ OC_USER_BACKEND_PROVIDE_AVATAR => 'canChangeAvatar',
);
/**
diff --git a/lib/private/user/user.php b/lib/private/user/user.php
index e5f842944f1..e773473ec41 100644
--- a/lib/private/user/user.php
+++ b/lib/private/user/user.php
@@ -140,6 +140,18 @@ class User {
}
/**
+ * check if the backend allows the user to change his avatar on Personal page
+ *
+ * @return bool
+ */
+ public function canChangeAvatar() {
+ if($this->backend->implementsActions(\OC_USER_BACKEND_PROVIDE_AVATAR)) {
+ return $this->backend->canChangeAvatar($this->uid);
+ }
+ return true;
+ }
+
+ /**
* check if the backend supports changing passwords
*
* @return bool
diff --git a/lib/private/util.php b/lib/private/util.php
index 426c5a025f3..a73564b3f68 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -437,11 +437,11 @@ class OC_Util {
);
$webServerRestart = true;
}
- if(floatval(phpversion()) < 5.3) {
+ if(version_compare(phpversion(), '5.3.3', '<')) {
$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.'
+ 'error'=>'PHP 5.3.3 or higher is required.',
+ 'hint'=>'Please ask your server administrator to update PHP to the latest version.'
+ .' Your PHP version is no longer supported by ownCloud and the PHP community.'
);
$webServerRestart = true;
}
@@ -875,6 +875,14 @@ class OC_Util {
}
/**
+ * @brief Check if a PHP version older then 5.3.8 is installed.
+ * @return bool
+ */
+ public static function isPHPoutdated() {
+ return version_compare(phpversion(), '5.3.8', '<');
+ }
+
+ /**
* @brief Check if the ownCloud server can connect to the internet
* @return bool
*/
@@ -1111,4 +1119,17 @@ class OC_Util {
$t = explode('/', $file);
return array_pop($t);
}
+
+ /**
+ * A human readable string is generated based on version, channel and build number
+ * @return string
+ */
+ public static function getHumanVersion() {
+ $version = OC_Util::getVersionString().' ('.OC_Util::getChannel().')';
+ $build = OC_Util::getBuild();
+ if(!empty($build) and OC_Util::getChannel() === 'daily') {
+ $version .= ' Build:' . $build;
+ }
+ return $version;
+ }
}