php: add ability to use custom path for files storage

This commit is contained in:
Oleg Sinizin
2021-10-17 15:37:44 +03:00
parent 375d916fe2
commit 5206171a70
4 changed files with 56 additions and 17 deletions

View File

@ -212,6 +212,7 @@
// get document history
function getHistory($filename, $filetype, $docKey, $fileuri) {
$storagePath = $GLOBALS['STORAGE_PATH'];
$histDir = getHistoryDir(getStoragePath($filename)); // get the path to the file history
if (getFileVersion($histDir) > 0) { // check if the file was modified (the file version is greater than 0)
@ -242,8 +243,12 @@
$prevFileName = $verDir . DIRECTORY_SEPARATOR . "prev." . $filetype;
$prevFileName = substr($prevFileName, strlen(getStoragePath("")));
$prevFileUrl = $i == $curVer ? $fileuri : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($prevFileName));
if (realpath($storagePath) === $storagePath) {
$prevFileUrl = $i == $curVer ? getDownloadUrl($filename) : getDownloadUrl($prevFileName);
}
$dataObj["key"] = $key;
$dataObj["url"] = $i == $curVer ? $fileuri : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($prevFileName)); // write file url to the data object
$dataObj["url"] = $prevFileUrl; // write file url to the data object
$dataObj["version"] = $i;
if ($i > 1) { // check if the version number is greater than 1 (the document was modified)
@ -260,11 +265,12 @@
"key" => $prev["key"],
"url" => $prev["url"]
];
$changesUrl = getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "diff.zip";
$changesUrl = substr($changesUrl, strlen(getStoragePath("")));
$changesPath = getVersionDir($histDir, $i - 1) . DIRECTORY_SEPARATOR . "diff.zip";
$changesPath = substr($changesPath, strlen(getStoragePath("")));
// write the path to the diff.zip archive with differences in this file version
$dataObj["changesUrl"] = getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($changesUrl));
$changesUrl = realpath($storagePath) === $storagePath ? getDownloadUrl($changesPath) : getVirtualPath(true) . str_replace("%5C", "/", rawurlencode($changesPath)) ;
$dataObj["changesUrl"] = $changesUrl;
}
if (isJwtEnabled()) {