Beispiel #1
0
        } else {
            /* Delete the old chunks */
            $actualModification = getFileModification($path, $user);
            if ($modification != $actualModification) {
                $fileSize = getFileSize($path, $user);
                addUserSpaceUsage($user, -$fileSize);
                $space_used = getUserSpaceUsed($user);
                $space_limit = getUserSpaceLimit($user);
                if ($space_used + $size > $space_limit) {
                    addUserSpaceUsage($user, $fileSize);
                    $space_left = $space_limit - $space_used;
                    echo json_encode(array("result" => "notEnoughSpace", "spaceLeft" => $space_left));
                    return;
                }
                setFileSize($path, $user, 0);
                $status = getFileStatus($path, $user);
                setFileModificationDate($path, $user, $dateModified);
                if ($status != "pending") {
                    $who = getFileComputers($path, $user);
                    requestFileDelete($actualModification, $who);
                }
                setFileModification($path, $user, $modification);
                resetFileChunks($path, $user);
                setFileStatus($path, $user, "pending");
            }
            echo json_encode(array("result" => "ok"));
        }
    }
} else {
    echo json_encode(array("result" => "missingParams"));
}
Beispiel #2
0
 * DESCRIPTION: Updates the file status
 * PARAMETERS: api/files/setStatus.php <apikey> <path> <user> <status>
 */
if (isset($_GET['path']) and isset($_GET['user'])) {
    // --> begin authentication
    $havePermission = false;
    if (isset($_GET['apikey'])) {
        $auth = (string) $_GET['apikey'];
        $havePermission = $auth == $apikey;
    } else {
        $havePermission = $_SESSION["email"] == $_GET['user'];
    }
    // --> end authentication
    if (!$havePermission) {
        echo json_encode(array("result" => "permissionDenied"));
    } else {
        $path = (string) $_GET['path'];
        $user = (string) $_GET['user'];
        $modification = getFileModification($path, $user);
        $who = getFileComputers($path, $user);
        $size = getFileSize($path, $user);
        if (count($who) > 0) {
            requestFileDelete($modification, $who);
        }
        // please don't remove space from the usage
        removeFile($path, $user);
        echo json_encode(array("result" => "ok"));
    }
} else {
    echo json_encode(array("result" => "missingParams"));
}