summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php43
-rw-r--r--lib/l10n/ast.php7
-rw-r--r--lib/l10n/el.php2
-rw-r--r--lib/l10n/en_GB.php1
-rw-r--r--lib/private/app.php8
-rw-r--r--lib/private/files/cache/scanner.php8
-rw-r--r--lib/private/files/storage/common.php52
-rw-r--r--lib/private/files/storage/local.php52
-rw-r--r--lib/private/files/storage/mappedlocal.php179
-rw-r--r--lib/private/files/view.php23
-rw-r--r--lib/private/mail.php2
-rw-r--r--lib/private/updater.php5
-rw-r--r--lib/private/user.php11
-rw-r--r--lib/private/user/manager.php6
-rw-r--r--lib/private/user/session.php37
-rw-r--r--lib/private/user/user.php25
16 files changed, 317 insertions, 144 deletions
diff --git a/lib/base.php b/lib/base.php
index a022b9d005b..882b587a6fd 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -284,11 +284,26 @@ class OC {
public static function checkUpgrade($showTemplate = true) {
if (self::needUpgrade()) {
if ($showTemplate && !OC_Config::getValue('maintenance', false)) {
+ $version = OC_Util::getVersion();
+ $oldTheme = OC_Config::getValue('theme');
OC_Config::setValue('theme', '');
OC_Util::addScript('config'); // needed for web root
OC_Util::addScript('update');
$tmpl = new OC_Template('', 'update.admin', 'guest');
$tmpl->assign('version', OC_Util::getVersionString());
+
+ // get third party apps
+ $apps = OC_App::getEnabledApps();
+ $incompatibleApps = array();
+ foreach ($apps as $appId) {
+ $info = OC_App::getAppInfo($appId);
+ if(!OC_App::isAppCompatible($version, $info)) {
+ $incompatibleApps[] = $info;
+ }
+ }
+ $tmpl->assign('appList', $incompatibleApps);
+ $tmpl->assign('productName', 'ownCloud'); // for now
+ $tmpl->assign('oldTheme', $oldTheme);
$tmpl->printPage();
exit();
} else {
@@ -637,8 +652,8 @@ class OC {
*/
public static function registerFilesystemHooks() {
// Check for blacklisted files
- OC_Hook::connect('OC_Filesystem', 'write', 'OC_Filesystem', 'isBlacklisted');
- OC_Hook::connect('OC_Filesystem', 'rename', 'OC_Filesystem', 'isBlacklisted');
+ OC_Hook::connect('OC_Filesystem', 'write', 'OC\Files\Filesystem', 'isBlacklisted');
+ OC_Hook::connect('OC_Filesystem', 'rename', 'OC\Files\Filesystem', 'isBlacklisted');
}
/**
@@ -884,30 +899,24 @@ class OC {
if (defined("DEBUG") && DEBUG) {
OC_Log::write('core', 'Trying to login from cookie', OC_Log::DEBUG);
}
- // confirm credentials in cookie
- if (isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username'])) {
- // delete outdated cookies
+
+ if(OC_User::userExists($_COOKIE['oc_username'])) {
self::cleanupLoginTokens($_COOKIE['oc_username']);
- // get stored tokens
- $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token');
- // test cookies token against stored tokens
- if (in_array($_COOKIE['oc_token'], $tokens, true)) {
- // replace successfully used token with a new one
- OC_Preferences::deleteKey($_COOKIE['oc_username'], 'login_token', $_COOKIE['oc_token']);
- $token = OC_Util::generateRandomBytes(32);
- OC_Preferences::setValue($_COOKIE['oc_username'], 'login_token', $token, time());
- OC_User::setMagicInCookie($_COOKIE['oc_username'], $token);
- // login
- OC_User::setUserId($_COOKIE['oc_username']);
+ // verify whether the supplied "remember me" token was valid
+ $granted = OC_User::loginWithCookie(
+ $_COOKIE['oc_username'], $_COOKIE['oc_token']);
+ if($granted === true) {
OC_Util::redirectToDefaultPage();
// doesn't return
}
+ OC_Log::write('core', 'Authentication cookie rejected for user ' .
+ $_COOKIE['oc_username'], OC_Log::WARN);
// if you reach this point you have changed your password
// or you are an attacker
// we can not delete tokens here because users may reach
// this point multiple times after a password change
- OC_Log::write('core', 'Authentication cookie rejected for user ' . $_COOKIE['oc_username'], OC_Log::WARN);
}
+
OC_User::unsetMagicInCookie();
return true;
}
diff --git a/lib/l10n/ast.php b/lib/l10n/ast.php
index c6aa43e9b59..5819cf25639 100644
--- a/lib/l10n/ast.php
+++ b/lib/l10n/ast.php
@@ -1,15 +1,19 @@
<?php
$TRANSLATIONS = array(
+"You are accessing the server from an untrusted domain." => "Tas accediendo al sirvidor dende un dominiu non confiáu.",
"App \"%s\" can't be installed because it is not compatible with this version of ownCloud." => "Nun pue instalase l'aplicación \"%s\" porque nun ye compatible con esta versión d'ownCloud.",
"Help" => "Ayuda",
"Personal" => "Personal",
"Settings" => "Axustes",
"Users" => "Usuarios",
+"Admin" => "Almin",
"Failed to upgrade \"%s\"." => "Fallu al anovar \"%s\".",
"Unknown filetype" => "Triba de ficheru desconocida",
"Invalid image" => "Imaxe inválida",
"web services under your control" => "servicios web baxo'l to control",
+"ZIP download is turned off." => "Tan deshabilitaes les descargues de ZIP.",
"Files need to be downloaded one by one." => "Los ficheros necesiten descargase ún a ún",
+"Selected files too large to generate zip file." => "Los ficheros esbillaos son milenta grandes pa xenerar un ficheru zip.",
"App does not provide an info.xml file" => "L'aplicación nun apurre un ficheru info.xml",
"App can't be installed because it is not compatible with this version of ownCloud" => "Nun pue instalase l'aplicación porque nun ye compatible con esta versión d'ownCloud.",
"Can't create app folder. Please fix permissions. %s" => "Nun pue crease la carpeta de l'aplicación. Por favor, igua los permisos. %s",
@@ -23,8 +27,9 @@ $TRANSLATIONS = array(
"Oracle connection could not be established" => "Nun pudo afitase la conexón d'Oracle",
"Set an admin username." => "Afitar nome d'usuariu p'almin",
"Set an admin password." => "Afitar contraseña p'almin",
-"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "El sirvidor web entá nun ta configurado pa permitir la sincronización de ficheros yá que la interface WebDAV paez nun tar funcionando.",
+"Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken." => "El to sirvidor web entá nun ta configuráu afayadizamente pa permitir la sincronización de ficheros porque la interfaz WebDAV paez tar rota.",
"%s shared »%s« with you" => "%s compartió »%s« contigo",
+"You need to provide a password to create a public link, only protected links are allowed" => "Necesites apurrir una contraseña pa crear un enllaz públicu, namái tan permitíos los enllaces protexíos",
"Share type %s is not valid for %s" => "La triba de compartición %s nun ye válida pa %s",
"Sharing backend %s not found" => "Nun s'alcontró'l botón de compartición %s",
"Sharing backend for %s not found" => "Nun s'alcontró'l botón de partición pa %s",
diff --git a/lib/l10n/el.php b/lib/l10n/el.php
index 716b2694d45..546fb6347b5 100644
--- a/lib/l10n/el.php
+++ b/lib/l10n/el.php
@@ -59,12 +59,14 @@ $TRANSLATIONS = array(
"Please double check the <a href='%s'>installation guides</a>." => "Ελέγξτε ξανά τις <a href='%s'>οδηγίες εγκατάστασης</a>.",
"%s shared »%s« with you" => "Ο %s διαμοιράστηκε μαζί σας το »%s«",
"Sharing %s failed, because the file does not exist" => "Ο διαμοιρασμός του %s απέτυχε, γιατί το αρχείο δεν υπάρχει",
+"You are not allowed to share %s" => "Δεν επιτρέπεται να διαμοιράσετε τον πόρο %s",
"Sharing %s failed, because the user %s is the item owner" => "Ο διαμοιρασμός του %s απέτυχε, γιατί ο χρήστης %s είναι ο ιδιοκτήτης του αντικειμένου",
"Sharing %s failed, because the user %s does not exist" => "Ο διαμοιρασμός του %s απέτυχε, γιατί ο χρήστης %s δεν υπάρχει",
"Sharing %s failed, because the user %s is not a member of any groups that %s is a member of" => "Ο διαμοιρασμός του %s απέτυχε, γιατί ο χρήστης %s δεν είναι μέλος καμίας ομάδας στην οποία ο χρήστης %s είναι μέλος",
"Sharing %s failed, because this item is already shared with %s" => "Ο διαμοιρασμός του %s απέτυχε, γιατί το αντικείμενο είναι διαμοιρασμένο ήδη με τον χρήστη %s",
"Sharing %s failed, because the group %s does not exist" => "Ο διαμοιρασμός του %s απέτυχε, γιατί η ομάδα χρηστών %s δεν υπάρχει",
"Sharing %s failed, because %s is not a member of the group %s" => "Ο διαμοιρασμός του %s απέτυχε, γιατί ο χρήστης %s δεν είναι μέλος της ομάδας %s",
+"You need to provide a password to create a public link, only protected links are allowed" => "Πρέπει να εισάγετε έναν κωδικό για να δημιουργήσετε έναν δημόσιο σύνδεσμο. Μόνο προστατευμένοι σύνδεσμοι επιτρέπονται",
"Sharing %s failed, because sharing with links is not allowed" => "Ο διαμοιρασμός του %s απέτυχε, γιατί δεν επιτρέπεται ο διαμοιρασμός με συνδέσμους",
"Share type %s is not valid for %s" => "Ο τύπος διαμοιρασμού %s δεν είναι έγκυρος για το %s",
"Setting permissions for %s failed, because the permissions exceed permissions granted to %s" => "Ο ορισμός δικαιωμάτων για το %s απέτυχε, γιατί τα δικαιώματα υπερτερούν αυτά που είναι ορισμένα για το %s",
diff --git a/lib/l10n/en_GB.php b/lib/l10n/en_GB.php
index 5aa4f0f356e..9a5e9bb831f 100644
--- a/lib/l10n/en_GB.php
+++ b/lib/l10n/en_GB.php
@@ -59,6 +59,7 @@ $TRANSLATIONS = array(
"Please double check the <a href='%s'>installation guides</a>." => "Please double check the <a href='%s'>installation guides</a>.",
"%s shared »%s« with you" => "%s shared \"%s\" with you",
"Sharing %s failed, because the file does not exist" => "Sharing %s failed, because the file does not exist",
+"You are not allowed to share %s" => "You are not allowed to share %s",
"Sharing %s failed, because the user %s is the item owner" => "Sharing %s failed, because the user %s is the item owner",
"Sharing %s failed, because the user %s does not exist" => "Sharing %s failed, because the user %s does not exist",
"Sharing %s failed, because the user %s is not a member of any groups that %s is a member of" => "Sharing %s failed, because the user %s is not a member of any groups that %s is a member of",
diff --git a/lib/private/app.php b/lib/private/app.php
index 50065197eb4..ea0453e58ea 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -889,8 +889,14 @@ class OC_App{
* ownCloud version. disable them if not.
* This is important if you upgrade ownCloud and have non ported 3rd
* party apps installed.
+ *
+ * @param array $apps optional app id list to check, uses all enabled apps
+ * when not specified
+ *
+ * @return array containing the list of ids of the disabled apps
*/
public static function checkAppsRequirements($apps = array()) {
+ $disabledApps = array();
if (empty($apps)) {
$apps = OC_App::getEnabledApps();
}
@@ -905,8 +911,10 @@ class OC_App{
OC_Log::ERROR);
OC_App::disable( $app );
OC_Hook::emit('update', 'success', 'Disabled '.$info['name'].' app because it is not compatible');
+ $disabledApps[] = $app;
}
}
+ return $disabledApps;
}
/**
diff --git a/lib/private/files/cache/scanner.php b/lib/private/files/cache/scanner.php
index b3ab94f4599..61b22ea75a0 100644
--- a/lib/private/files/cache/scanner.php
+++ b/lib/private/files/cache/scanner.php
@@ -26,22 +26,22 @@ class Scanner extends BasicEmitter {
/**
* @var \OC\Files\Storage\Storage $storage
*/
- private $storage;
+ protected $storage;
/**
* @var string $storageId
*/
- private $storageId;
+ protected $storageId;
/**
* @var \OC\Files\Cache\Cache $cache
*/
- private $cache;
+ protected $cache;
/**
* @var \OC\Files\Cache\Permissions $permissionsCache
*/
- private $permissionsCache;
+ protected $permissionsCache;
const SCAN_RECURSIVE = true;
const SCAN_SHALLOW = false;
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index cfca8ca008c..1ed0d79817b 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -7,6 +7,7 @@
*/
namespace OC\Files\Storage;
+use OC\Files\Filesystem;
use OC\Files\Cache\Watcher;
/**
@@ -36,6 +37,22 @@ abstract class Common implements \OC\Files\Storage\Storage {
public function __construct($parameters) {
}
+ /**
+ * Remove a file of folder
+ *
+ * @param string $path
+ * @return bool
+ */
+ protected function remove($path) {
+ if ($this->is_dir($path)) {
+ return $this->rmdir($path);
+ } else if($this->is_file($path)) {
+ return $this->unlink($path);
+ } else {
+ return false;
+ }
+ }
+
public function is_dir($path) {
return $this->filetype($path) == 'dir';
}
@@ -137,20 +154,33 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
public function rename($path1, $path2) {
- if ($this->copy($path1, $path2)) {
- $this->removeCachedFile($path1);
- return $this->unlink($path1);
- } else {
- return false;
- }
+ $this->remove($path2);
+
+ $this->removeCachedFile($path1);
+ return $this->copy($path1, $path2) and $this->remove($path1);
}
public function copy($path1, $path2) {
- $source = $this->fopen($path1, 'r');
- $target = $this->fopen($path2, 'w');
- list($count, $result) = \OC_Helper::streamCopy($source, $target);
- $this->removeCachedFile($path2);
- return $result;
+ if ($this->is_dir($path1)) {
+ $this->remove($path2);
+ $dir = $this->opendir($path1);
+ $this->mkdir($path2);
+ while ($file = readdir($dir)) {
+ if (!Filesystem::isIgnoredDir($file)) {
+ if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
+ return false;
+ }
+ }
+ }
+ closedir($dir);
+ return true;
+ } else {
+ $source = $this->fopen($path1, 'r');
+ $target = $this->fopen($path2, 'w');
+ list(, $result) = \OC_Helper::streamCopy($source, $target);
+ $this->removeCachedFile($path2);
+ return $result;
+ }
}
public function getMimeType($path) {
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index de940fc7cdb..943c4163088 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -164,7 +164,14 @@ if (\OC_Util::runningOnWindows()) {
}
public function unlink($path) {
- return $this->delTree($path);
+ if ($this->is_dir($path)) {
+ return $this->rmdir($path);
+ } else if ($this->is_file($path)) {
+ return unlink($this->datadir . $path);
+ } else {
+ return false;
+ }
+
}
public function rename($path1, $path2) {
@@ -177,20 +184,21 @@ if (\OC_Util::runningOnWindows()) {
return false;
}
- if ($return = rename($this->datadir . $path1, $this->datadir . $path2)) {
+ if ($this->is_dir($path2)) {
+ $this->rmdir($path2);
+ } else if ($this->is_file($path2)) {
+ $this->unlink($path2);
}
- return $return;
+
+ return rename($this->datadir . $path1, $this->datadir . $path2);
}
public function copy($path1, $path2) {
- if ($this->is_dir($path2)) {
- if (!$this->file_exists($path2)) {
- $this->mkdir($path2);
- }
- $source = substr($path1, strrpos($path1, '/') + 1);
- $path2 .= $source;
+ if ($this->is_dir($path1)) {
+ return parent::copy($path1, $path2);
+ } else {
+ return copy($this->datadir . $path1, $this->datadir . $path2);
}
- return copy($this->datadir . $path1, $this->datadir . $path2);
}
public function fopen($path, $mode) {
@@ -213,30 +221,6 @@ if (\OC_Util::runningOnWindows()) {
}
/**
- * @param string $dir
- */
- private function delTree($dir) {
- $dirRelative = $dir;
- $dir = $this->datadir . $dir;
- if (!file_exists($dir)) return true;
- if (!is_dir($dir) || is_link($dir)) return unlink($dir);
- foreach (scandir($dir) as $item) {
- if ($item == '.' || $item == '..') continue;
- if (is_file($dir . '/' . $item)) {
- if (unlink($dir . '/' . $item)) {
- }
- } elseif (is_dir($dir . '/' . $item)) {
- if (!$this->delTree($dirRelative . "/" . $item)) {
- return false;
- };
- }
- }
- if ($return = rmdir($dir)) {
- }
- return $return;
- }
-
- /**
* @param string $fullPath
*/
private static function getFileSizeFromOS($fullPath) {
diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php
index 07691661644..3ebdcf9538f 100644
--- a/lib/private/files/storage/mappedlocal.php
+++ b/lib/private/files/storage/mappedlocal.php
@@ -10,29 +10,33 @@ namespace OC\Files\Storage;
/**
* for local filestore, we only have to map the paths
*/
-class MappedLocal extends \OC\Files\Storage\Common{
+class MappedLocal extends \OC\Files\Storage\Common {
protected $datadir;
private $mapper;
public function __construct($arguments) {
- $this->datadir=$arguments['datadir'];
- if(substr($this->datadir, -1)!=='/') {
- $this->datadir.='/';
+ $this->datadir = $arguments['datadir'];
+ if (substr($this->datadir, -1) !== '/') {
+ $this->datadir .= '/';
}
- $this->mapper= new \OC\Files\Mapper($this->datadir);
+ $this->mapper = new \OC\Files\Mapper($this->datadir);
}
+
public function __destruct() {
if (defined('PHPUNIT_RUN')) {
$this->mapper->removePath($this->datadir, true, true);
}
}
- public function getId(){
- return 'local::'.$this->datadir;
+
+ public function getId() {
+ return 'local::' . $this->datadir;
}
+
public function mkdir($path) {
return @mkdir($this->buildPath($path), 0777, true);
}
+
public function rmdir($path) {
try {
$it = new \RecursiveIteratorIterator(
@@ -68,9 +72,10 @@ class MappedLocal extends \OC\Files\Storage\Common{
return false;
}
}
+
public function opendir($path) {
$files = array('.', '..');
- $physicalPath= $this->buildPath($path);
+ $physicalPath = $this->buildPath($path);
$logicalPath = $this->mapper->physicalToLogic($physicalPath);
$dh = opendir($physicalPath);
@@ -80,7 +85,7 @@ class MappedLocal extends \OC\Files\Storage\Common{
continue;
}
- $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.'/'.$file);
+ $logicalFilePath = $this->mapper->physicalToLogic($physicalPath . '/' . $file);
$file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath);
$file = $this->stripLeading($file);
@@ -88,18 +93,21 @@ class MappedLocal extends \OC\Files\Storage\Common{
}
}
- \OC\Files\Stream\Dir::register('local-win32'.$path, $files);
- return opendir('fakedir://local-win32'.$path);
+ \OC\Files\Stream\Dir::register('local-win32' . $path, $files);
+ return opendir('fakedir://local-win32' . $path);
}
+
public function is_dir($path) {
- if(substr($path, -1)=='/') {
- $path=substr($path, 0, -1);
+ if (substr($path, -1) == '/') {
+ $path = substr($path, 0, -1);
}
return is_dir($this->buildPath($path));
}
+
public function is_file($path) {
return is_file($this->buildPath($path));
}
+
public function stat($path) {
$fullPath = $this->buildPath($path);
$statResult = stat($fullPath);
@@ -111,17 +119,19 @@ class MappedLocal extends \OC\Files\Storage\Common{
}
return $statResult;
}
+
public function filetype($path) {
- $filetype=filetype($this->buildPath($path));
- if($filetype=='link') {
- $filetype=filetype(realpath($this->buildPath($path)));
+ $filetype = filetype($this->buildPath($path));
+ if ($filetype == 'link') {
+ $filetype = filetype(realpath($this->buildPath($path)));
}
return $filetype;
}
+
public function filesize($path) {
- if($this->is_dir($path)) {
+ if ($this->is_dir($path)) {
return 0;
- }else{
+ } else {
$fullPath = $this->buildPath($path);
$fileSize = filesize($fullPath);
if ($fileSize < 0) {
@@ -131,78 +141,106 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $fileSize;
}
}
+
public function isReadable($path) {
return is_readable($this->buildPath($path));
}
+
public function isUpdatable($path) {
return is_writable($this->buildPath($path));
}
+
public function file_exists($path) {
return file_exists($this->buildPath($path));
}
+
public function filemtime($path) {
return filemtime($this->buildPath($path));
}
- public function touch($path, $mtime=null) {
+
+ public function touch($path, $mtime = null) {
// sets the modification time of the file to the given value.
// If mtime is nil the current time is set.
// note that the access time of the file always changes to the current time.
- if(!is_null($mtime)) {
- $result=touch( $this->buildPath($path), $mtime );
- }else{
- $result=touch( $this->buildPath($path));
+ if (!is_null($mtime)) {
+ $result = touch($this->buildPath($path), $mtime);
+ } else {
+ $result = touch($this->buildPath($path));
}
- if( $result ) {
- clearstatcache( true, $this->buildPath($path) );
+ if ($result) {
+ clearstatcache(true, $this->buildPath($path));
}
return $result;
}
+
public function file_get_contents($path) {
return file_get_contents($this->buildPath($path));
}
+
public function file_put_contents($path, $data) {
return file_put_contents($this->buildPath($path), $data);
}
+
public function unlink($path) {
return $this->delTree($path);
}
+
public function rename($path1, $path2) {
if (!$this->isUpdatable($path1)) {
- \OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, \OC_Log::ERROR);
+ \OC_Log::write('core', 'unable to rename, file is not writable : ' . $path1, \OC_Log::ERROR);
return false;
}
- if(! $this->file_exists($path1)) {
- \OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, \OC_Log::ERROR);
+ if (!$this->file_exists($path1)) {
+ \OC_Log::write('core', 'unable to rename, file does not exists : ' . $path1, \OC_Log::ERROR);
return false;
}
+ if ($this->is_dir($path2)) {
+ $this->rmdir($path2);
+ } else if ($this->is_file($path2)) {
+ $this->unlink($path2);
+ }
+
$physicPath1 = $this->buildPath($path1);
$physicPath2 = $this->buildPath($path2);
- if($return=rename($physicPath1, $physicPath2)) {
+ if ($return = rename($physicPath1, $physicPath2)) {
// mapper needs to create copies or all children
$this->copyMapping($path1, $path2);
$this->cleanMapper($physicPath1, false, true);
}
return $return;
}
+
public function copy($path1, $path2) {
- if($this->is_dir($path2)) {
- if(!$this->file_exists($path2)) {
- $this->mkdir($path2);
+ if ($this->is_dir($path1)) {
+ if ($this->is_dir($path2)) {
+ $this->rmdir($path2);
+ } else if ($this->is_file($path2)) {
+ $this->unlink($path2);
}
- $source=substr($path1, strrpos($path1, '/')+1);
- $path2.=$source;
- }
- if($return=copy($this->buildPath($path1), $this->buildPath($path2))) {
- // mapper needs to create copies or all children
- $this->copyMapping($path1, $path2);
+ $dir = $this->opendir($path1);
+ $this->mkdir($path2);
+ while ($file = readdir($dir)) {
+ if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
+ if (!$this->copy($path1 . '/' . $file, $path2 . '/' . $file)) {
+ return false;
+ }
+ }
+ }
+ closedir($dir);
+ return true;
+ } else {
+ if ($return = copy($this->buildPath($path1), $this->buildPath($path2))) {
+ $this->copyMapping($path1, $path2);
+ }
+ return $return;
}
- return $return;
}
+
public function fopen($path, $mode) {
- if($return=fopen($this->buildPath($path), $mode)) {
- switch($mode) {
+ if ($return = fopen($this->buildPath($path), $mode)) {
+ switch ($mode) {
case 'r':
break;
case 'r+':
@@ -223,15 +261,15 @@ class MappedLocal extends \OC\Files\Storage\Common{
* @param string $dir
*/
private function delTree($dir, $isLogicPath=true) {
- $dirRelative=$dir;
+ $dirRelative = $dir;
if ($isLogicPath) {
- $dir=$this->buildPath($dir);
+ $dir = $this->buildPath($dir);
}
if (!file_exists($dir)) {
return true;
}
if (!is_dir($dir) || is_link($dir)) {
- if($return=unlink($dir)) {
+ if ($return = unlink($dir)) {
$this->cleanMapper($dir, false);
return $return;
}
@@ -240,17 +278,17 @@ class MappedLocal extends \OC\Files\Storage\Common{
if ($item == '.' || $item == '..') {
continue;
}
- if(is_file($dir.'/'.$item)) {
- if(unlink($dir.'/'.$item)) {
- $this->cleanMapper($dir.'/'.$item, false);
+ if (is_file($dir . '/' . $item)) {
+ if (unlink($dir . '/' . $item)) {
+ $this->cleanMapper($dir . '/' . $item, false);
}
- }elseif(is_dir($dir.'/'.$item)) {
- if (!$this->delTree($dir. "/" . $item, false)) {
+ } elseif (is_dir($dir . '/' . $item)) {
+ if (!$this->delTree($dir . "/" . $item, false)) {
return false;
};
}
}
- if($return=rmdir($dir)) {
+ if ($return = rmdir($dir)) {
$this->cleanMapper($dir, false);
}
return $return;
@@ -278,14 +316,14 @@ class MappedLocal extends \OC\Files\Storage\Common{
}
} else {
\OC_Log::write('core',
- 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name,
+ 'Unable to determine file size of "' . $fullPath . '". Unknown OS: ' . $name,
\OC_Log::ERROR);
}
return 0;
}
- public function hash($type, $path, $raw=false) {
+ public function hash($type, $path, $raw = false) {
return hash_file($type, $this->buildPath($path), $raw);
}
@@ -296,9 +334,11 @@ class MappedLocal extends \OC\Files\Storage\Common{
public function search($query) {
return $this->searchInDir($query);
}
+
public function getLocalFile($path) {
return $this->buildPath($path);
}
+
public function getLocalFolder($path) {
return $this->buildPath($path);
}
@@ -306,20 +346,20 @@ class MappedLocal extends \OC\Files\Storage\Common{
/**
* @param string $query
*/
- protected function searchInDir($query, $dir='') {
- $files=array();
+ protected function searchInDir($query, $dir = '') {
+ $files = array();
$physicalDir = $this->buildPath($dir);
foreach (scandir($physicalDir) as $item) {
if ($item == '.' || $item == '..')
continue;
- $physicalItem = $this->mapper->physicalToLogic($physicalDir.'/'.$item);
- $item = substr($physicalItem, strlen($physicalDir)+1);
+ $physicalItem = $this->mapper->physicalToLogic($physicalDir . '/' . $item);
+ $item = substr($physicalItem, strlen($physicalDir) + 1);
- if(strstr(strtolower($item), strtolower($query)) !== false) {
- $files[]=$dir.'/'.$item;
+ if (strstr(strtolower($item), strtolower($query)) !== false) {
+ $files[] = $dir . '/' . $item;
}
- if(is_dir($physicalItem)) {
- $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item));
+ if (is_dir($physicalItem)) {
+ $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item));
}
}
return $files;
@@ -327,30 +367,31 @@ class MappedLocal extends \OC\Files\Storage\Common{
/**
* 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;
}
/**
* @param string $path
*/
- private function buildPath($path, $create=true) {
+ private function buildPath($path, $create = true) {
$path = $this->stripLeading($path);
- $fullPath = $this->datadir.$path;
+ $fullPath = $this->datadir . $path;
return $this->mapper->logicToPhysical($fullPath, $create);
}
/**
* @param string $path
*/
- private function cleanMapper($path, $isLogicPath=true, $recursive=true) {
+ private function cleanMapper($path, $isLogicPath = true, $recursive=true) {
$fullPath = $path;
if ($isLogicPath) {
- $fullPath = $this->datadir.$path;
+ $fullPath = $this->datadir . $path;
}
$this->mapper->removePath($fullPath, $isLogicPath, $recursive);
}
@@ -363,8 +404,8 @@ class MappedLocal extends \OC\Files\Storage\Common{
$path1 = $this->stripLeading($path1);
$path2 = $this->stripLeading($path2);
- $fullPath1 = $this->datadir.$path1;
- $fullPath2 = $this->datadir.$path2;
+ $fullPath1 = $this->datadir . $path1;
+ $fullPath2 = $this->datadir . $path2;
$this->mapper->copy($fullPath1, $fullPath2);
}
@@ -373,10 +414,10 @@ class MappedLocal extends \OC\Files\Storage\Common{
* @param string $path
*/
private function stripLeading($path) {
- if(strpos($path, '/') === 0) {
+ if (strpos($path, '/') === 0) {
$path = substr($path, 1);
}
- if(strpos($path, '\\') === 0) {
+ if (strpos($path, '\\') === 0) {
$path = substr($path, 1);
}
if ($path === false) {
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 940f31fe420..0b8d336f260 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -29,14 +29,13 @@ use OC\Files\Cache\Updater;
class View {
private $fakeRoot = '';
- private $internal_path_cache = array();
- private $storage_cache = array();
public function __construct($root = '') {
$this->fakeRoot = $root;
}
public function getAbsolutePath($path = '/') {
+ $this->assertPathLength($path);
if ($path === '') {
$path = '/';
}
@@ -77,6 +76,7 @@ class View {
* @return string
*/
public function getRelativePath($path) {
+ $this->assertPathLength($path);
if ($this->fakeRoot == '') {
return $path;
}
@@ -208,6 +208,7 @@ class View {
}
public function readfile($path) {
+ $this->assertPathLength($path);
@ob_end_clean();
$handle = $this->fopen($path, 'rb');
if ($handle) {
@@ -432,7 +433,7 @@ class View {
if ($this->is_dir($path1)) {
$result = $this->copy($path1, $path2);
if ($result === true) {
- $result = $storage1->unlink($internalPath1);
+ $result = $storage1->rmdir($internalPath1);
}
} else {
$source = $this->fopen($path1 . $postFix1, 'r');
@@ -595,6 +596,7 @@ class View {
}
public function toTmpFile($path) {
+ $this->assertPathLength($path);
if (Filesystem::isValidPath($path)) {
$source = $this->fopen($path, 'r');
if ($source) {
@@ -611,7 +613,7 @@ class View {
}
public function fromTmpFile($tmpFile, $path) {
-
+ $this->assertPathLength($path);
if (Filesystem::isValidPath($path)) {
// Get directory that the file is going into
@@ -640,6 +642,7 @@ class View {
}
public function getMimeType($path) {
+ $this->assertPathLength($path);
return $this->basicOperation('getMimeType', $path);
}
@@ -669,6 +672,7 @@ class View {
}
public function free_space($path = '/') {
+ $this->assertPathLength($path);
return $this->basicOperation('free_space', $path);
}
@@ -808,6 +812,7 @@ class View {
* @return \OC\Files\FileInfo|false
*/
public function getFileInfo($path, $includeMountPoints = true) {
+ $this->assertPathLength($path);
$data = array();
if (!Filesystem::isValidPath($path)) {
return $data;
@@ -878,6 +883,7 @@ class View {
* @return FileInfo[]
*/
public function getDirectoryContent($directory, $mimetype_filter = '') {
+ $this->assertPathLength($directory);
$result = array();
if (!Filesystem::isValidPath($directory)) {
return $result;
@@ -1006,6 +1012,7 @@ class View {
* returns the fileid of the updated file
*/
public function putFileInfo($path, $data) {
+ $this->assertPathLength($path);
if ($data instanceof FileInfo) {
$data = $data->getData();
}
@@ -1153,4 +1160,12 @@ class View {
}
return null;
}
+
+ private function assertPathLength($path) {
+ $maxLen = min(PHP_MAXPATHLEN, 4000);
+ $pathLen = strlen($path);
+ if ($pathLen > $maxLen) {
+ throw new \OCP\Files\InvalidPathException("Path length($pathLen) exceeds max path length($maxLen): $path");
+ }
+ }
}
diff --git a/lib/private/mail.php b/lib/private/mail.php
index f9083cc4e64..81bcb3d8deb 100644
--- a/lib/private/mail.php
+++ b/lib/private/mail.php
@@ -12,8 +12,6 @@
* A class to handle mail sending.
*/
-require_once 'class.phpmailer.php';
-
class OC_Mail {
/**
diff --git a/lib/private/updater.php b/lib/private/updater.php
index d8694ac6ed5..58d3cab73aa 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -134,7 +134,10 @@ class Updater extends BasicEmitter {
$this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
}
\OC_Config::setValue('version', implode('.', \OC_Util::getVersion()));
- \OC_App::checkAppsRequirements();
+ $disabledApps = \OC_App::checkAppsRequirements();
+ if (!empty($disabledApps)) {
+ $this->emit('\OC\Updater', 'disabledApps', array($disabledApps));
+ }
// load all apps to also upgrade enabled apps
\OC_App::loadApps();
diff --git a/lib/private/user.php b/lib/private/user.php
index 9276d7923c9..5d3ebb57c8c 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -236,6 +236,17 @@ class OC_User {
}
/**
+ * Try to login a user using the magic cookie (remember login)
+ *
+ * @param string $uid The username of the user to log in
+ * @param string $token
+ * @return bool
+ */
+ public static function loginWithCookie($uid, $token) {
+ return self::getUserSession()->loginWithCookie($uid, $token);
+ }
+
+ /**
* Try to login a user, assuming authentication
* has already happened (e.g. via Single Sign On).
*
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 0fcf1ceb6ab..f2964fecca3 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -52,6 +52,12 @@ class Manager extends PublicEmitter {
unset($cachedUsers[$i]);
}
});
+ $this->listen('\OC\User', 'postLogin', function ($user) {
+ $user->updateLastLoginTimestamp();
+ });
+ $this->listen('\OC\User', 'postRememberedLogin', function ($user) {
+ $user->updateLastLoginTimestamp();
+ });
}
/**
diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index 3d10b134b83..5f0dee607ae 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -22,7 +22,9 @@ use OC\Hooks\Emitter;
* - preCreateUser(string $uid, string $password)
* - postCreateUser(\OC\User\User $user)
* - preLogin(string $user, string $password)
- * - postLogin(\OC\User\User $user)
+ * - postLogin(\OC\User\User $user, string $password)
+ * - preRememberedLogin(string $uid)
+ * - postRememberedLogin(\OC\User\User $user)
* - logout()
*
* @package OC\User
@@ -171,6 +173,39 @@ class Session implements Emitter, \OCP\IUserSession {
}
/**
+ * perform login using the magic cookie (remember login)
+ *
+ * @param string $uid the username
+ * @param string $currentToken
+ * @return bool
+ */
+ public function loginWithCookie($uid, $currentToken) {
+ $this->manager->emit('\OC\User', 'preRememberedLogin', array($uid));
+ $user = $this->manager->get($uid);
+ if(is_null($user)) {
+ // user does not exist
+ return false;
+ }
+
+ // get stored tokens
+ $tokens = \OC_Preferences::getKeys($uid, 'login_token');
+ // test cookies token against stored tokens
+ if(!in_array($currentToken, $tokens, true)) {
+ return false;
+ }
+ // replace successfully used token with a new one
+ \OC_Preferences::deleteKey($uid, 'login_token', $currentToken);
+ $newToken = \OC_Util::generateRandomBytes(32);
+ \OC_Preferences::setValue($uid, 'login_token', $newToken, time());
+ $this->setMagicInCookie($user->getUID(), $newToken);
+
+ //login
+ $this->setUser($user);
+ $this->manager->emit('\OC\User', 'postRememberedLogin', array($user));
+ return true;
+ }
+
+ /**
* logout the user from the session
*/
public function logout() {
diff --git a/lib/private/user/user.php b/lib/private/user/user.php
index bc5c541e521..8aba7188e24 100644
--- a/lib/private/user/user.php
+++ b/lib/private/user/user.php
@@ -43,6 +43,11 @@ class User {
private $home;
/**
+ * @var int $lastLogin
+ */
+ private $lastLogin;
+
+ /**
* @var \OC\AllConfig $config
*/
private $config;
@@ -64,6 +69,7 @@ class User {
} else {
$this->enabled = true;
}
+ $this->lastLogin = \OC_Preferences::getValue($uid, 'login', 'lastLogin', 0);
}
/**
@@ -108,6 +114,25 @@ class User {
}
/**
+ * returns the timestamp of the user's last login or 0 if the user did never
+ * login
+ *
+ * @return int
+ */
+ public function getLastLogin() {
+ return $this->lastLogin;
+ }
+
+ /**
+ * updates the timestamp of the most recent login of this user
+ */
+ public function updateLastLoginTimestamp() {
+ $this->lastLogin = time();
+ \OC_Preferences::setValue(
+ $this->uid, 'login', 'lastLogin', $this->lastLogin);
+ }
+
+ /**
* Delete the user
*
* @return bool