コード例 #1
0
ファイル: public.php プロジェクト: noci2012/owncloud
// Enf of backward compatibility
if (isset($_GET['file']) || isset($_GET['dir'])) {
    if (isset($_GET['dir'])) {
        $type = 'folder';
        $path = $_GET['dir'];
        $baseDir = $path;
        $dir = $baseDir;
    } else {
        $type = 'file';
        $path = $_GET['file'];
    }
    $uidOwner = substr($path, 1, strpos($path, '/', 1) - 1);
    if (OCP\User::userExists($uidOwner)) {
        OC_Util::setupFS($uidOwner);
        $fileSource = OC_Filecache::getId($path, '');
        if ($fileSource != -1 && ($linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $uidOwner))) {
            // TODO Fix in the getItems
            if (!isset($linkItem['item_type']) || $linkItem['item_type'] != $type) {
                header('HTTP/1.0 404 Not Found');
                $tmpl = new OCP\Template('', '404', 'guest');
                $tmpl->printPage();
                exit;
            }
            if (isset($linkItem['share_with'])) {
                // Check password
                if (isset($_POST['password'])) {
                    $password = $_POST['password'];
                    $storedHash = $linkItem['share_with'];
                    $forcePortable = CRYPT_BLOWFISH != 1;
                    $hasher = new PasswordHash(8, $forcePortable);
                    if (!$hasher->CheckPassword($password . OC_Config::getValue('passwordsalt', ''), $storedHash)) {
コード例 #2
0
ファイル: public.php プロジェクト: ryanshoover/core
            }
            $baseDir = $path;
            $dir = $baseDir;
        } else {
            $type = 'file';
            $path = $_GET['file'];
            if (strlen($path) > 1 and substr($path, -1, 1) === '/') {
                $path = substr($path, 0, -1);
            }
        }
        $shareOwner = substr($path, 1, strpos($path, '/', 1) - 1);
        if (OCP\User::userExists($shareOwner)) {
            OC_Util::setupFS($shareOwner);
            $fileSource = getId($path);
            if ($fileSource != -1) {
                $linkItem = OCP\Share::getItemSharedWithByLink($type, $fileSource, $shareOwner);
                $pathAndUser['path'] = $path;
                $path_parts = explode('/', $path, 5);
                $pathAndUser['user'] = $path_parts[1];
                $fileOwner = $path_parts[1];
            }
        }
    }
}
if ($linkItem) {
    if (!isset($linkItem['item_type'])) {
        OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR);
        header('HTTP/1.0 404 Not Found');
        $tmpl = new OCP\Template('', '404', 'guest');
        $tmpl->printPage();
        exit;