Fixes to links and forward URLs in filestorage

This commit is contained in:
tuscanhobbit
2014-06-24 12:05:11 +02:00
parent b2b47dcd7c
commit cc4001fce7
4 changed files with 69 additions and 64 deletions

View File

@@ -834,6 +834,45 @@ function get_cloudpath($arr) {
return $path;
}
function get_parent_cloudpath($channel_id, $channel_name, $attachHash) {
//Build directory tree and redirect
$parentHash = $attachHash;
do {
$parentHash = findFolderHashByAttachHash($channel_id, $parentHash);
if ($parentHash) {
$parentName = findFilenameByHash($channel_id, $parentHash);
$parentFullPath = $parentName."/".$parentFullPath;
}
} while ($parentHash);
$parentFullPath = z_root() . "/cloud/" . $channel_name . "/" . $parentFullPath;
goaway($parentFullPath);
}
function findFolderHashByAttachHash($channel_id, $attachHash) {
$r = q("select * from attach where uid = %d and hash = '%s' limit 1",
intval($channel_id), dbesc($attachHash)
);
$hash = "";
if($r) {
foreach($r as $rr) {
$hash = $rr['folder'];
}
}
return $hash;
}
function findFilenameByHash($channel_id, $attachHash) {
$r = q("select * from attach where uid = %d and hash = '%s' limit 1",
intval($channel_id), dbesc($attachHash)
);
$filename = "";
if($r) {
foreach($r as $rr) {
$filename = $rr['filename'];
}
}
return $filename;
}
/**
*
* @param $in