Proper fix for shared links
This commit is contained in:
parent
c6985d6cd4
commit
8e3b8c7f47
|
@ -390,7 +390,7 @@ class Shared extends \OC\Files\Storage\Common {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setup($options) {
|
public static function setup($options) {
|
||||||
if (\OCP\Share::getItemsSharedWith('file')) {
|
if (!\OCP\User::isLoggedIn() || \OCP\User::getUser() != $options['user'] || \OCP\Share::getItemsSharedWith('file')) {
|
||||||
$user_dir = $options['user_dir'];
|
$user_dir = $options['user_dir'];
|
||||||
\OC\Files\Filesystem::mount('\OC\Files\Storage\Shared', array('sharedFolder' => '/Shared'), $user_dir.'/Shared/');
|
\OC\Files\Filesystem::mount('\OC\Files\Storage\Shared', array('sharedFolder' => '/Shared'), $user_dir.'/Shared/');
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,26 @@ if (isset($_GET['t'])) {
|
||||||
$type = $linkItem['item_type'];
|
$type = $linkItem['item_type'];
|
||||||
$fileSource = $linkItem['file_source'];
|
$fileSource = $linkItem['file_source'];
|
||||||
$shareOwner = $linkItem['uid_owner'];
|
$shareOwner = $linkItem['uid_owner'];
|
||||||
if (OCP\User::userExists($shareOwner) && $fileSource != -1) {
|
$fileOwner = null;
|
||||||
OC_Util::setupFS($shareOwner);
|
$path = null;
|
||||||
$path = $linkItem['file_target'];
|
if (isset($linkItem['parent'])) {
|
||||||
|
$parent = $linkItem['parent'];
|
||||||
|
while (isset($parent)) {
|
||||||
|
$query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
|
||||||
|
$item = $query->execute(array($parent))->fetchRow();
|
||||||
|
if (isset($item['parent'])) {
|
||||||
|
$parent = $item['parent'];
|
||||||
|
} else {
|
||||||
|
$fileOwner = $item['uid_owner'];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
header('HTTP/1.0 404 Not Found');
|
$fileOwner = $shareOwner;
|
||||||
$tmpl = new OCP\Template('', '404', 'guest');
|
}
|
||||||
$tmpl->printPage();
|
if (isset($fileOwner)) {
|
||||||
exit();
|
OC_Util::setupFS($fileOwner);
|
||||||
|
$path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,7 +67,7 @@ if (isset($_GET['t'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($linkItem) {
|
if (isset($path)) {
|
||||||
if (!isset($linkItem['item_type'])) {
|
if (!isset($linkItem['item_type'])) {
|
||||||
OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
|
OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
|
@ -123,20 +135,12 @@ if ($linkItem) {
|
||||||
$file = basename($path);
|
$file = basename($path);
|
||||||
// Download the file
|
// Download the file
|
||||||
if (isset($_GET['download'])) {
|
if (isset($_GET['download'])) {
|
||||||
if (isset($_GET['path']) && $_GET['path'] !== '') {
|
if (isset($_GET['files'])) { // download selected files
|
||||||
if (isset($_GET['files'])) { // download selected files
|
OC_Files::get($dir, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
|
||||||
OC_Files::get($path, $_GET['files'], $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
|
} else {
|
||||||
} else {
|
|
||||||
if (isset($_GET['path']) && $_GET['path'] != '') { // download a file from a shared directory
|
|
||||||
OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
|
|
||||||
} else { // download the whole shared directory
|
|
||||||
OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else { // download a single shared file
|
|
||||||
OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
|
OC_Files::get($dir, $file, $_SERVER['REQUEST_METHOD'] == 'HEAD' ? true : false);
|
||||||
}
|
}
|
||||||
|
exit();
|
||||||
} else {
|
} else {
|
||||||
OCP\Util::addStyle('files_sharing', 'public');
|
OCP\Util::addStyle('files_sharing', 'public');
|
||||||
OCP\Util::addScript('files_sharing', 'public');
|
OCP\Util::addScript('files_sharing', 'public');
|
||||||
|
@ -147,6 +151,7 @@ if ($linkItem) {
|
||||||
$tmpl->assign('dir', $dir);
|
$tmpl->assign('dir', $dir);
|
||||||
$tmpl->assign('filename', $file);
|
$tmpl->assign('filename', $file);
|
||||||
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
|
$tmpl->assign('mimetype', \OC\Files\Filesystem::getMimeType($path));
|
||||||
|
$tmpl->assign('fileTarget', basename($linkItem['file_target']));
|
||||||
$urlLinkIdentifiers= (isset($token)?'&t='.$token:'')
|
$urlLinkIdentifiers= (isset($token)?'&t='.$token:'')
|
||||||
.(isset($_GET['dir'])?'&dir='.$_GET['dir']:'')
|
.(isset($_GET['dir'])?'&dir='.$_GET['dir']:'')
|
||||||
.(isset($_GET['file'])?'&file='.$_GET['file']:'');
|
.(isset($_GET['file'])?'&file='.$_GET['file']:'');
|
||||||
|
|
|
@ -190,14 +190,14 @@ class Filesystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function init($root) {
|
static public function init($user, $root) {
|
||||||
if (self::$defaultInstance) {
|
if (self::$defaultInstance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self::$defaultInstance = new View($root);
|
self::$defaultInstance = new View($root);
|
||||||
|
|
||||||
//load custom mount config
|
//load custom mount config
|
||||||
self::initMountPoints();
|
self::initMountPoints($user);
|
||||||
|
|
||||||
self::$loaded = true;
|
self::$loaded = true;
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class OC_Util {
|
||||||
mkdir( $userdirectory, 0755, true );
|
mkdir( $userdirectory, 0755, true );
|
||||||
}
|
}
|
||||||
//jail the user into his "home" directory
|
//jail the user into his "home" directory
|
||||||
\OC\Files\Filesystem::init($user_dir);
|
\OC\Files\Filesystem::init($user, $user_dir);
|
||||||
|
|
||||||
$quotaProxy=new OC_FileProxy_Quota();
|
$quotaProxy=new OC_FileProxy_Quota();
|
||||||
$fileOperationProxy = new OC_FileProxy_FileOperations();
|
$fileOperationProxy = new OC_FileProxy_FileOperations();
|
||||||
|
|
Loading…
Reference in New Issue