Ejemplo n.º 1
0
function addUserSpaceUsage($email, $space)
{
    global $users;
    $limit = getUserSpaceLimit($email);
    if ($space <= $limit) {
        $newdata = array('$inc' => array("space.used" => $space));
        $users->update(array("email" => $email), $newdata);
        return true;
    }
    return false;
}
Ejemplo n.º 2
0
 } else {
     $path = (string) $_GET['path'];
     $user = (string) $_GET['user'];
     $modification = (string) $_GET['modification'];
     $dateModified = (string) $_GET['dateModified'];
     $size = intval($_GET['size']);
     if (!fileExists($path, $user)) {
         echo json_encode(array("result" => "invalidFile"));
     } 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);