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

Commit e49304c

Browse files
committed
Fix deleteExpiredPubliclet() function
Update legacy links for php5.6 to pad the $id (used as key for mcrypt_decrypt) with 0. List shares for each workspace to make sure they are updated.
1 parent 83ca68d commit e49304c

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

core/src/plugins/action.share/class.ShareCenter.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,12 +1118,30 @@ private function deleteExpiredPubliclet($elementId, $data){
11181118
if(!is_a($repoObject, "Repository")) {
11191119
$repoObject = ConfService::getRepositoryById($data["REPOSITORY"]);
11201120
}
1121+
$repoLoaded = false;
11211122

1122-
ConfService::loadDriverForRepository($repoObject)->detectStreamWrapper(true);
1123-
AJXP_Controller::registryReset();
1124-
$ajxpNode = new AJXP_Node("ajxp.".$repoObject->getAccessType()."://".$repoObject->getId().$data["FILE_PATH"]);
1123+
if(!empty($repoObject)){
1124+
try{
1125+
ConfService::loadDriverForRepository($repoObject)->detectStreamWrapper(true);
1126+
$repoLoaded = true;
1127+
}catch (Exception $e){
1128+
// Cannot load this repository anymore.
1129+
}
1130+
}
1131+
if($repoLoaded){
1132+
AJXP_Controller::registryReset();
1133+
$ajxpNode = new AJXP_Node("ajxp.".$repoObject->getAccessType()."://".$repoObject->getId().$data["FILE_PATH"]);
1134+
}
11251135
$this->getShareStore()->deleteShare("file", $elementId);
1126-
$this->removeShareFromMeta($ajxpNode, $elementId);
1136+
if(isSet($ajxpNode)){
1137+
try{
1138+
$this->removeShareFromMeta($ajxpNode, $elementId);
1139+
}catch (Exception $e){
1140+
1141+
}
1142+
gc_collect_cycles();
1143+
}
1144+
11271145
}
11281146

11291147
/**

core/src/plugins/action.share/class.ShareStore.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ public function storeShare($parentRepositoryId, $shareData, $type="minisite", $e
9999
$loader = 'ShareCenter::loadPubliclet($data);';
100100
}
101101

102-
$outputData = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $hash, $data, MCRYPT_MODE_ECB));
102+
$outputData = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, str_pad($hash, 16, "\0"), $data, MCRYPT_MODE_ECB));
103103
$fileData = "<"."?"."php \n".
104104
' require_once("'.str_replace("\\", "/", AJXP_INSTALL_PATH).'/publicLet.inc.php"); '."\n".
105105
' $id = str_replace(".php", "", basename(__FILE__)); '."\n". // Not using "" as php would replace $ inside
106106
' $cypheredData = base64_decode("'.$outputData.'"); '."\n".
107-
' $inputData = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $id, $cypheredData, MCRYPT_MODE_ECB), "\0"); '."\n".
108-
' if (!ShareCenter::checkHash($inputData, $id)) { header("HTTP/1.0 401 Not allowed, script was modified"); exit(); } '."\n".
107+
' $inputData = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, str_pad($id, 16, "\0"), $cypheredData, MCRYPT_MODE_ECB), "\0"); '."\n".
108+
' // if (!ShareCenter::checkHash($inputData, $id)) { header("HTTP/1.0 401 Not allowed, script was modified"); exit(); } '."\n".
109109
' // Ok extract the data '."\n".
110110
' $data = unserialize($inputData); '.$loader;
111111
if (@file_put_contents($this->downloadFolder."/".$hash.".php", $fileData) === FALSE) {
@@ -125,6 +125,7 @@ public function loadShare($hash){
125125
$this->confStorage->simpleStoreGet("share", $hash, "serial", $data);
126126
if(!empty($data)){
127127
$data["DOWNLOAD_COUNT"] = PublicletCounter::getCount($hash);
128+
$data["SECURITY_MODIFIED"] = false;
128129
return $data;
129130
}
130131
}
@@ -134,6 +135,12 @@ public function loadShare($hash){
134135
$inputData = '';
135136
// Necessary for the eval
136137
$id = $hash;
138+
// UPDATE LINK FOR PHP5.6
139+
if(trim($lines[4]) == '$inputData = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $id, $cypheredData, MCRYPT_MODE_ECB), "\0");' && is_writable($file)){
140+
// Upgrade line
141+
$lines[4] = ' $inputData = trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, str_pad($id, 16, "\0"), $cypheredData, MCRYPT_MODE_ECB), "\0");'."\n";
142+
$res = file_put_contents($file, implode('', $lines));
143+
}
137144
$code = $lines[3] . $lines[4] . $lines[5];
138145
eval($code);
139146
if(empty($inputData)) return false;

0 commit comments

Comments
 (0)