Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix #496 : clear metadata when a shared link is expired (by date or n…
Browse files Browse the repository at this point in the history
…umber of downloads)
  • Loading branch information
cdujeu committed Apr 15, 2014
1 parent f3c067c commit 1cd9d42
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -1002,11 +1002,36 @@ public static function loadPubliclet($data)
{
// Remove the publiclet, it's done
if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]),realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"))) !== FALSE) {
PublicletCounter::delete($shortHash);
unlink($_SERVER["SCRIPT_FILENAME"]);

AuthService::logUser($data["OWNER_ID"], "", true);
$repoObject = $data["REPOSITORY"];
$nodePath = "ajxp.".$repoObject->getAccessType()."://".$repoObject->getId().$data["FILE_PATH"];
$ajxpNode = new AJXP_Node($nodePath);
$metadata = $ajxpNode->retrieveMetadata(
"ajxp_shared",
true,
AJXP_METADATA_SCOPE_REPOSITORY
);
if (count($metadata)) {
$eType = "file";
$elementId = $shortHash;
$updateMeta = false;
if (is_array($metadata["element"]) && isSet($metadata["element"][$elementId])) {
unset($metadata["element"][$elementId]);
if(count($metadata["element"]) > 0) $updateMeta = true;
}
self::deleteSharedElement($eType, $elementId, AuthService::getLoggedUser());
if ($updateMeta) {
$ajxpNode->setMetadata("ajxp_shared", $metadata, true, AJXP_METADATA_SCOPE_REPOSITORY, true);
} else {
$ajxpNode->removeMetadata("ajxp_shared", true, AJXP_METADATA_SCOPE_REPOSITORY, true);
}
}
}

echo "Link is expired, sorry.";
//echo "Link is expired, sorry.";
header("HTTP/1.0 404 Not Found");
echo '404 File not found';
exit();
}
// Load language messages
Expand Down

0 comments on commit 1cd9d42

Please sign in to comment.