diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/attach.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/include/attach.php b/include/attach.php index 3524193a6..f14a2c61a 100644 --- a/include/attach.php +++ b/include/attach.php @@ -733,6 +733,51 @@ function attach_delete($channel_id,$resource) { +function get_cloudpath($arr) { + + $basepath = 'store/'; + if($arr['uid']) { + $r = q("select channel_address from channel where channel_id = %d limit 1", + intval($arr['uid']) + ); + if($r) + $basepath .= $r[0]['channel_address'] . '/'; + } + + + $path = $basepath; + + if($arr['folder']) { + + $lpath = ''; + $lfile = $arr['folder']; + + do { + $r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d ) + limit 1", + intval($arr['uid']), + dbesc($lfile), + intval(ATTACH_FLAG_DIR) + ); + + if(! $r) + break; + + if($lfile) + $lpath = $r[0]['filename'] . '/' . $lpath; + $lfile = $r[0]['folder']; + + } while ( ($r[0]['folder']) && ($r[0]['flags'] & ATTACH_FLAG_DIR)) ; + + $path .= $lpath; + + } + + $path .= $arr['filename']; + return $path; + +} + |