예제 #1
0
    exit;
}
$linkedItem = \OCP\Share::getShareByToken($token);
if ($linkedItem === false || $linkedItem['item_type'] !== 'file' && $linkedItem['item_type'] !== 'folder') {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\Util::writeLog('core-preview', 'Passed token parameter is not valid', \OCP\Util::DEBUG);
    exit;
}
if (!isset($linkedItem['uid_owner']) || !isset($linkedItem['file_source'])) {
    \OC_Response::setStatus(\OC_Response::STATUS_INTERNAL_SERVER_ERROR);
    \OCP\Util::writeLog('core-preview', 'Passed token seems to be valid, but it does not contain all necessary information . ("' . $token . '")', \OCP\Util::WARN);
    exit;
}
$rootLinkItem = OCP\Share::resolveReShare($linkedItem);
$userId = $rootLinkItem['uid_owner'];
OCP\JSON::checkUserExists($rootLinkItem['uid_owner']);
\OC_Util::setupFS($userId);
\OC\Files\Filesystem::initMountPoints($userId);
$view = new \OC\Files\View('/' . $userId . '/files');
$pathId = $linkedItem['file_source'];
$path = $view->getPath($pathId);
if ($path === null) {
    \OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
    \OCP\Util::writeLog('core-preview', 'Could not resolve file for shared item', \OCP\Util::WARN);
    exit;
}
$pathInfo = $view->getFileInfo($path);
$sharedFile = null;
if ($linkedItem['item_type'] === 'folder') {
    $isValid = \OC\Files\Filesystem::isValidPath($file);
    if (!$isValid) {
예제 #2
0
 * See the COPYING-README file.
 */
OCP\JSON::checkAppEnabled('gallery');
if (isset($_GET['token'])) {
    $token = $_GET['token'];
    $linkItem = \OCP\Share::getShareByToken($token);
    if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
        // seems to be a valid share
        $type = $linkItem['item_type'];
        $fileSource = $linkItem['file_source'];
        $shareOwner = $linkItem['uid_owner'];
        $path = null;
        $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
        $fileOwner = $rootLinkItem['uid_owner'];
        // Setup FS with owner
        OCP\JSON::checkUserExists($fileOwner);
        OC_Util::tearDownFS();
        OC_Util::setupFS($fileOwner);
        // The token defines the target directory (security reasons)
        $path = \OC\Files\Filesystem::getPath($linkItem['file_source']);
        $view = new \OC\Files\View(\OC\Files\Filesystem::getView()->getAbsolutePath($path));
        $images = $view->searchByMime('image');
        $result = array();
        foreach ($images as $image) {
            $result[] = $token . $image['path'];
        }
        OCP\JSON::setContentTypeHeader();
        echo json_encode(array('images' => $result, 'users' => array(), 'displayNames' => array()));
        exit;
    }
}
예제 #3
0
 * See the COPYING-README file.
 */
OCP\JSON::checkAppEnabled('gallery');
$square = isset($_GET['square']) ? (bool) $_GET['square'] : false;
$scale = isset($_GET['scale']) ? $_GET['scale'] : 1;
$images = explode(';', $_GET['image']);
if (!empty($_GET['token'])) {
    $linkItem = \OCP\Share::getShareByToken($_GET['token']);
    if (!(is_array($linkItem) && isset($linkItem['uid_owner']))) {
        exit;
    }
    // seems to be a valid share
    $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
    $user = $rootLinkItem['uid_owner'];
    // Setup filesystem
    OCP\JSON::checkUserExists($user);
    OC_Util::tearDownFS();
    OC_Util::setupFS($user);
    $root = \OC\Files\Filesystem::getPath($linkItem['file_source']) . '/';
    $images = array_map(function ($image) use($root) {
        return $root . $image;
    }, $images);
} else {
    $root = '';
    OCP\JSON::checkLoggedIn();
    $user = OCP\User::getUser();
}
session_write_close();
$eventSource = new OC_EventSource();
foreach ($images as $image) {
    $height = 200 * $scale;
예제 #4
0
OCP\JSON::checkAppEnabled('gallery');
list($token, $img) = explode('/', $_GET['file'], 2);
$linkItem = \OCP\Share::getShareByToken($token);
if (is_array($linkItem) && isset($linkItem['uid_owner'])) {
    // seems to be a valid share
    $rootLinkItem = \OCP\Share::resolveReShare($linkItem);
    $owner = $rootLinkItem['uid_owner'];
    OCP\JSON::checkUserExists($owner);
    OC_Util::tearDownFS();
    OC_Util::setupFS($owner);
    \OC_User::setIncognitoMode(true);
} else {
    OCP\JSON::checkLoggedIn();
    list($owner, $img) = explode('/', $_GET['file'], 2);
    if ($owner !== OCP\User::getUser()) {
        OCP\JSON::checkUserExists($owner);
        OC_Util::tearDownFS();
        OC_Util::setupFS($owner);
        $view = new \OC\Files\View('/' . $owner . '/files');
        // second part is the (duplicated) share name
        list($folderId, , $img) = explode('/', $img, 3);
        $shareInfo = \OCP\Share::getItemSharedWithBySource('file', $folderId);
        if ($shareInfo) {
            $sharedFolder = $view->getPath($folderId);
            if ($sharedFolder) {
                $img = $sharedFolder . '/' . $img;
            } else {
                \OC_Response::setStatus(404);
                exit;
            }
        } else {
예제 #5
0
파일: update.php 프로젝트: hjimmy/owncloud
             $shareWith = substr($row['uid_shared_with'], 0, $pos);
             if (isset($groupShares[$shareWith][$itemSource])) {
                 continue;
             } else {
                 $groupShares[$shareWith][$itemSource] = true;
             }
         } else {
             if ($row['uid_shared_with'] == 'public') {
                 $shareType = OCP\Share::SHARE_TYPE_LINK;
                 $shareWith = null;
             } else {
                 $shareType = OCP\Share::SHARE_TYPE_USER;
                 $shareWith = $row['uid_shared_with'];
             }
         }
         OCP\JSON::checkUserExists($row['uid_owner']);
         OC_User::setUserId($row['uid_owner']);
         //we need to setup the filesystem for the user, otherwise OC_FileSystem::getRoot will fail and break
         OC_Util::setupFS($row['uid_owner']);
         try {
             OCP\Share::shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions);
         } catch (Exception $e) {
             $update_error = true;
             OCP\Util::writeLog('files_sharing', 'Upgrade Routine: Skipping sharing "' . $row['source'] . '" to "' . $shareWith . '" (error is "' . $e->getMessage() . '")', OCP\Util::WARN);
         }
         OC_Util::tearDownFS();
     }
 }
 OC_User::setUserId(null);
 if ($update_error) {
     OCP\Util::writeLog('files_sharing', 'There were some problems upgrading the sharing of files', OCP\Util::ERROR);