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

Commit

Permalink
Do not purge the expired links automatically anymore. Instead, displa…
Browse files Browse the repository at this point in the history
…y a clear indication to the user. Better error display when loading an expired or invalid link. Fix #696
  • Loading branch information
cdujeu committed Nov 10, 2014
1 parent fe2b9b1 commit 1031d8b
Show file tree
Hide file tree
Showing 14 changed files with 201 additions and 62 deletions.
55 changes: 34 additions & 21 deletions core/src/plugins/action.share/class.ShareCenter.js
Expand Up @@ -263,6 +263,8 @@ Class.create("ShareCenter", {
oForm.removeClassName('share_leaf');
oForm.removeClassName('readonly_mode');
oForm.removeClassName('type-ws');
oForm.removeClassName('share_expired');
oForm.removeClassName("share_edit");
var pluginConfigs = ajaxplorer.getPluginConfigs("action.share");
if(this.currentNode.isLeaf()) oForm.addClassName('share_leaf');
if(this.readonlyMode) oForm.addClassName('readonly_mode');
Expand Down Expand Up @@ -342,7 +344,6 @@ Class.create("ShareCenter", {


var nodeMeta = this.currentNode.getMetadata();
oForm.removeClassName("share_edit");
if(nodeMeta.get("ajxp_shared")) oForm.addClassName("share_edit");
oForm.down("div#target_repository_toggle").select("a").invoke( "observe", "click", function(){
oForm.toggleClassName("edit_parameters");
Expand Down Expand Up @@ -432,6 +433,9 @@ Class.create("ShareCenter", {
container.insert(chooser);
chooser.setValue(json['minisite_layout']);
}
if(json['is_expired']){
oForm.addClassName('share_expired');
}
}catch(e){}
oForm.down('#complete_indicator').hide();
if(json.minisite){
Expand Down Expand Up @@ -638,7 +642,11 @@ Class.create("ShareCenter", {
actions.insert({top:new Element('span', {className:'icon-key simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.85"]}).update(' '+MessageHash["share_center.84"])});
}
if(linkData["expire_time"]){
actions.insert({top:new Element('span', {className:'icon-calendar simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.87"]}).update(' '+linkData["expire_time"])});
if(linkData['is_expired'] && linkData['expire_after'] === 0 && (linkData['download_limit'] && linkData['download_limit'] != linkData['download_counter'])){
actions.insert({top:new Element('span', {className:'icon-calendar simple_tooltip_observer SF_horizontal_action_destructive',"data-tooltipTitle":MessageHash["share_center.169"]}).update(' '+linkData["expire_time"])});
}else{
actions.insert({top:new Element('span', {className:'icon-calendar simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.87"]}).update(' '+linkData["expire_time"])});
}
}
var dlC = new Element('span', {className:'icon-download-alt simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.89"]}).update(' '+MessageHash["share_center.88"]+' '+linkData['download_counter']+'/'+linkData['download_limit']);
actions.insert({top:dlC});
Expand Down Expand Up @@ -833,39 +841,33 @@ Class.create("ShareCenter", {

if(node.isLeaf()){
// LEAF SHARE
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.140"]+'</div>');
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.140"+(jsonData['is_expired']?'b':'')]+'</div>');
mainCont.insert('<div class="infoPanelRow">\
<div class="infoPanelLabel">'+MessageHash['share_center.121']+'</div>\
<div class="infoPanelValue"><input type="text" class="share_info_panel_link" readonly="true" value="'+ jsonData.minisite.public_link +'"></div>\
<div class="infoPanelValue"><input type="text" class="share_info_panel_link'+(jsonData['is_expired']?' share_info_panel_link_expired':'')+'" readonly="true" value="'+ jsonData.minisite.public_link +'"></div>\
</div>\
');

}else if(jsonData.minisite){
// MINISITE FOLDER SHARE
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.138"]+'</div>');
// Label
/*
mainCont.insert('\
<div class="infoPanelRow">\
<div class="infoPanelLabel">'+MessageHash['share_center.35']+'</div>\
<div class="infoPanelValue">'+ jsonData.label +'</div>\
</div>');
*/
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.138"+(jsonData['is_expired']?'b':'')]+'</div>');
// Links textearea
mainCont.insert('\
<div class="infoPanelRow">\
<div class="infoPanelLabel">'+MessageHash['share_center.62']+'</div>\
<div class="infoPanelValue"><input type="text" class="share_info_panel_link" readonly="true" value="'+ jsonData.minisite.public_link +'"></div>\
</div>\
<div class="infoPanelRow">\
<div class="infoPanelValue"><input type="text" class="share_info_panel_link'+(jsonData['is_expired']?' share_info_panel_link_expired':'')+'" readonly="true" value="'+ jsonData.minisite.public_link +'"></div>\
</div>');
if(!jsonData['is_expired']){
mainCont.insert(
'<div class="infoPanelRow">\
<div class="infoPanelLabel">'+MessageHash['share_center.61']+'</div>\
<div class="infoPanelValue"><textarea style="padding: 4px;width:97%;height: 80px;" id="embed_code" readonly="true"></textarea></div>\
</div>\
');
</div>');
}
mainCont.down("#embed_code").setValue("<iframe height='500' width='600' style='border:1px solid black;' src='"+jsonData.minisite.public_link+"'></iframe>");
}else{
// WORKSPACE FOLDER
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.139"]+'</div>');
mainCont.update('<div class="share_info_panel_main_legend">'+MessageHash["share_center.139"+(jsonData['is_expired']?'b':'')]+'</div>');
mainCont.insert('<div class="infoPanelRow">\
<div class="infoPanelLabel">'+MessageHash['share_center.54']+'</div>\
<div class="infoPanelValue">'+ entries.join(', ') +'</div>\
Expand Down Expand Up @@ -1158,7 +1160,14 @@ Class.create("ShareCenter", {
// DOWNLOAD COUNTER BUTTON
if(jsonData && jsonData["download_limit"]){

var dlC = new Element('span', {className:'simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.89"]}).update('<span class="icon-download-alt"></span> '+MessageHash["share_center.88"]+' '+jsonData['download_counter']+'/'+jsonData['download_limit']);
var dlC;
if(jsonData['is_expired'] && jsonData['download_limit'] && jsonData['download_limit'] == jsonData['download_counter']){
dlC = new Element('span', {className:'simple_tooltip_observer SF_horizontal_action_destructive',"data-tooltipTitle":MessageHash["share_center.168"]}).update('<span class="icon-download-alt"></span> '+MessageHash["share_center.88"]+' '+jsonData['download_counter']+'/'+jsonData['download_limit']);
}else{
dlC = new Element('span', {className:'simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.89"]}).update('<span class="icon-download-alt"></span> '+MessageHash["share_center.88"]+' '+jsonData['download_counter']+'/'+jsonData['download_limit']);
}


dialogButtonsOrRow.down('.SF_horizontal_actions').insert({bottom:dlC});
dlC.observe("click", function(){
if(window.confirm(MessageHash['share_center.106'])){
Expand All @@ -1177,7 +1186,11 @@ Class.create("ShareCenter", {

// EXPIRATION TIME
if(jsonData && jsonData["expire_time"]){
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({top:new Element('span', {className:'simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.87"]}).update('<span class="icon-calendar"></span> '+jsonData["expire_time"])});
if(jsonData['is_expired'] && jsonData['expire_after'] === 0 && (jsonData['download_limit'] && jsonData['download_limit'] != jsonData['download_counter'])){
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({top:new Element('span', {className:'simple_tooltip_observer SF_horizontal_action_destructive',"data-tooltipTitle":MessageHash["share_center.169"]}).update('<span class="icon-calendar"></span> '+ jsonData["expire_time"])});
}else{
dialogButtonsOrRow.down('.SF_horizontal_actions').insert({top:new Element('span', {className:'simple_tooltip_observer',"data-tooltipTitle":MessageHash["share_center.87"]}).update('<span class="icon-calendar"></span> '+jsonData["expire_time"])});
}
}

if(updateFunc){
Expand Down
37 changes: 23 additions & 14 deletions core/src/plugins/action.share/class.ShareCenter.php
Expand Up @@ -950,11 +950,11 @@ public function initPublicFolder($downloadFolder)

}

public static function loadMinisite($data, $hash = '')
public static function loadMinisite($data, $hash = '', $error = null)
{
if(isset($data["SECURITY_MODIFIED"]) && $data["SECURITY_MODIFIED"] === true){
header("HTTP/1.0 401 Not allowed, script was modified");
die("Not allowed");
$mess = ConfService::getMessages();
$error = $mess['share_center.164'];
}
$repository = $data["REPOSITORY"];
AJXP_PluginsService::getInstance()->initActivePlugins();
Expand All @@ -980,8 +980,11 @@ public static function loadMinisite($data, $hash = '')
$html = str_replace("AJXP_MINISITE_LOGO", $minisiteLogo, $html);
$html = str_replace("AJXP_APPLICATION_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $html);
$html = str_replace("PYDIO_APP_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $html);
$html = str_replace("AJXP_START_REPOSITORY", $repository, $html);
$html = str_replace("AJXP_REPOSITORY_LABEL", ConfService::getRepositoryById($repository)->getDisplay(), $html);
if(isSet($repository)){
$html = str_replace("AJXP_START_REPOSITORY", $repository, $html);
$html = str_replace("AJXP_REPOSITORY_LABEL", ConfService::getRepositoryById($repository)->getDisplay(), $html);
}
$html = str_replace('AJXP_HASH_LOAD_ERROR', isSet($error)?$error:'', $html);
$html = str_replace("AJXP_TEMPLATE_NAME", $templateName, $html);
$html = str_replace("AJXP_LINK_HASH", $hash, $html);
$guiConfigs = AJXP_PluginsService::findPluginById("gui.ajax")->getConfigs();
Expand Down Expand Up @@ -1015,6 +1018,7 @@ public static function loadMinisite($data, $hash = '')
AJXP_PluginsService::deferBuildingRegistry();
AJXP_PluginsService::getInstance()->initActivePlugins();
AJXP_PluginsService::flushDeferredRegistryBuilding();
$errMessage = null;
try {
$params = $_GET;
$ACTION = "download";
Expand All @@ -1038,9 +1042,10 @@ public static function loadMinisite($data, $hash = '')
AJXP_Controller::registryReset();
AJXP_Controller::findActionAndApply($ACTION, $params, null);
} catch (Exception $e) {
die($e->getMessage());
$errMessage = $e->getMessage();
}
return;
if($errMessage == null) return;
$html = str_replace('AJXP_HASH_LOAD_ERROR', $errMessage, $html);
}

if (isSet($_GET["lang"])) {
Expand Down Expand Up @@ -1074,13 +1079,16 @@ public static function loadShareByHash($hash){
AJXP_PluginsService::getInstance()->initActivePlugins();
$shareCenter = self::getShareCenter();
$data = $shareCenter->loadPublicletData($hash);
$mess = ConfService::getMessages();
if($shareCenter->getShareStore()->isShareExpired($hash, $data)){
// Remove the publiclet, it's done
/*
if (strstr(realpath($_SERVER["SCRIPT_FILENAME"]),realpath(ConfService::getCoreConf("PUBLIC_DOWNLOAD_FOLDER"))) !== FALSE) {
$shareCenter->deleteExpiredPubliclet($hash, $data);
AuthService::disconnect();
}
die('Link expired!');
*/
AuthService::disconnect();
self::loadMinisite(array(), $hash, $mess["share_center.165"]);
return;
}
if(!empty($data) && is_array($data)){
if(isSet($data["SECURITY_MODIFIED"]) && $data["SECURITY_MODIFIED"] === true){
Expand All @@ -1093,7 +1101,7 @@ public static function loadShareByHash($hash){
self::loadPubliclet($data);
}
}else{
echo 'Cannot find link';
self::loadMinisite(array(), $hash, $mess["share_center.166"]);
}

}
Expand Down Expand Up @@ -1123,8 +1131,8 @@ private function deleteExpiredPubliclet($elementId, $data){
public static function loadPubliclet($data)
{
if(isset($data["SECURITY_MODIFIED"]) && $data["SECURITY_MODIFIED"] === true){
header("HTTP/1.0 401 Not allowed, script was modified");
die("Not allowed");
self::loadMinisite($data, "false");
return;
}
// create driver from $data
$className = $data["DRIVER"]."AccessDriver";
Expand Down Expand Up @@ -1218,7 +1226,7 @@ public static function loadPubliclet($data)
}
$filePath = AJXP_INSTALL_PATH."/plugins/access.".$data["DRIVER"]."/class.".$className.".php";
if (!is_file($filePath)) {
die("Warning, cannot find driver for conf storage! ($className, $filePath)");
die("Warning, cannot find driver for conf storage! ($className, $filePath)");
}
require_once($filePath);
$driver = new $className($data["PLUGIN_ID"], $data["BASE_DIR"]);
Expand Down Expand Up @@ -2304,6 +2312,7 @@ public function shareToJson($shareId, $shareData, $node = null){
}else{
$jsonData["expire_after"] = 0;
}
$jsonData["is_expired"] = $this->shareStore->isShareExpired($shareId, $minisiteData);
if(isSet($minisiteData["AJXP_TEMPLATE_NAME"])){
$jsonData["minisite_layout"] = $minisiteData["AJXP_TEMPLATE_NAME"];
}
Expand Down
1 change: 1 addition & 0 deletions core/src/plugins/action.share/manifest.xml
Expand Up @@ -107,6 +107,7 @@
<input type="text" id="share_container" style="clear:left; width: 95%; margin:15px 5px 0; font-size:13px;"/>
<div class="non_macos">AJXP_MESSAGE[share_center.143]</div>
<div class="macos_only" style="display:none;">AJXP_MESSAGE[share_center.144]</div>
<div class="link_expired_div"><span class="icon-sign-warning"></span> AJXP_MESSAGE[share_center.167]</div>
<div class="share_qrcode" style="margin-top:5px; clear:left; display:none;"></div>
</div>
</div>
Expand Down
11 changes: 10 additions & 1 deletion core/src/plugins/action.share/res/i18n/ca.php
Expand Up @@ -171,6 +171,15 @@
"160" => "You are not allowed to delete this shared item",
"161" => "Deprecated Link",
"162" => "You have one or more legacy link on this file. Please replace this with a new share link by stopping this share and recreating a new one. Copy the share 'hash' (the last part of the link, e.g. http://yourpydio.com/data/public/<em style='color:red;'>206a51</em>.php) and use it in the new sharing dialog to make sure the link will still be active after migration.",
"163" => "Drop Files Here (for upload-enabled minisites)"
"163" => "Drop Files Here (for upload-enabled minisites)",
"138b" => "You have shared this folder as a public link, but it is currently inactive (expired).",
"139b" => "You have shared this folder as a workspace with application users, but it is currently inactive (expired).",
"140b" => "You have shared this file via a public link, but it is currently inactive (expired).",
"164" => "Not allowed: script was modified!",
"165" => "Sorry, this link is expired!",
"166" => "Cannot find specified link!",
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",

);
11 changes: 10 additions & 1 deletion core/src/plugins/action.share/res/i18n/de.php
Expand Up @@ -170,6 +170,15 @@
"160" => "Es ist Ihnen nicht erlaubt dieses geteilte Item zu löschen.",
"161" => "Deprecated Link",
"162" => "You have one or more legacy link on this file. Please replace this with a new share link by stopping this share and recreating a new one. Copy the share 'hash' (the last part of the link, e.g. http://yourpydio.com/data/public/<em style='color:red;'>206a51</em>.php) and use it in the new sharing dialog to make sure the link will still be active after migration.",
"163" => "Drag'n'Drop (Für Miniseiten mit aktivierten Upload)"
"163" => "Drag'n'Drop (Für Miniseiten mit aktivierten Upload)",
"138b" => "You have shared this folder as a public link, but it is currently inactive (expired).",
"139b" => "You have shared this folder as a workspace with application users, but it is currently inactive (expired).",
"140b" => "You have shared this file via a public link, but it is currently inactive (expired).",
"164" => "Not allowed: script was modified!",
"165" => "Sorry, this link is expired!",
"166" => "Cannot find specified link!",
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",

);
11 changes: 10 additions & 1 deletion core/src/plugins/action.share/res/i18n/en.php
Expand Up @@ -172,5 +172,14 @@
"160" => "You are not allowed to delete this shared item",
"161" => "Deprecated Link",
"162" => "You have one or more legacy link on this file. Links are still active, but you can replace them with a new share link by stopping this share and recreating a new one. Copy the share 'hash' (the last part of the link, e.g. http://yourpydio.com/data/public/<em style='color:red;'>206a51</em>.php) and apply it to the new link using the 'Change Parameters' form.",
"163" => "Drop Files Here (for upload-enabled minisites)"
"163" => "Drop Files Here (for upload-enabled minisites)",
"138b" => "You have shared this folder as a public link, but it is currently inactive (expired).",
"139b" => "You have shared this folder as a workspace with application users, but it is currently inactive (expired).",
"140b" => "You have shared this file via a public link, but it is currently inactive (expired).",
"164" => "Not allowed: script was modified!",
"165" => "Sorry, this link is expired!",
"166" => "Cannot find specified link!",
"167" => "Link is expired!",
"168" => "The number of authorized downloads have been reached. Click to reset the counter and reactivate the link.",
"169" => "The expiration date was reached. Change the parameters with a new date if you want to reactivate the link.",
);

0 comments on commit 1031d8b

Please sign in to comment.