diff options
author | mrjive <mrjive@mrjive.it> | 2018-04-13 10:23:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-13 10:23:30 +0200 |
commit | db586e0c2747a5c222c6ab394c53245aeba60c8b (patch) | |
tree | 20aca8e4b419bf4d970e2e1185388989a2597a9c /util | |
parent | ea36ebd0df3d7612e5a524b7a287f9c57b8783b3 (diff) | |
parent | 4aaea422bc78b351f055df66b1491e476bf65e12 (diff) | |
download | volse-hubzilla-db586e0c2747a5c222c6ab394c53245aeba60c8b.tar.gz volse-hubzilla-db586e0c2747a5c222c6ab394c53245aeba60c8b.tar.bz2 volse-hubzilla-db586e0c2747a5c222c6ab394c53245aeba60c8b.zip |
Merge pull request #6 from redmatrix/dev
Dev
Diffstat (limited to 'util')
-rwxr-xr-x | util/dcp | 64 |
1 files changed, 38 insertions, 26 deletions
@@ -28,9 +28,14 @@ if($argc < 3) { if(strpos($dstfile,'store/') === 0) $dstfile = substr($dstfile,6); - $nick = substr($dstfile,0,strpos($dstfile,'/')); - - $dstfile = substr($dstfile,strlen($nick)+1); + if(strpos($dstfile,'/')) + $nick = substr($dstfile,0,strpos($dstfile,'/')); + $dstfile = substr($dstfile,strlen($nick)+1); + } + else { + $nick = $dstfile; + $dstfile = ''; + } $channel = channelx_by_nick($nick); if(! $channel) @@ -43,38 +48,45 @@ if($argc < 3) { } } - + $rootdir = ((strlen(trim($dstfile,'/'))) ? false : true); + $isadir = false; if(($recursive) || ($argc > 3)) $isadir = true; - $r = q("select * from attach where display_path = '%s' and uid = %d limit 1", - dbesc($dstfile), - intval($channel['channel_id']) - ); - - if($r && $r[0]['is_dir']) { - $isadir = true; - $basepath = $dstfile; - $folder = $r[0]['hash']; + if($rootdir) { + $folder = ''; } else { - $pathname = (($isadir) ? $dstfile : dirname($dstfile)); - $arr = [ - 'pathname' => $pathname, - 'allow_cid' => $channel['channel_allow_cid'], - 'allow_gid' => $channel['channel_allow_gid'], - 'deny_cid' => $channel['channel_deny_cid'], - 'deny_gid' => $channel['channel_deny_gid'], - ]; - $folder = ''; - if($pathname && $isadir) { - $x = attach_mkdirp($channel,$channel['channel_hash'],$arr); - if($x['success']) - $folder = $x['data']['hash']; + $r = q("select * from attach where display_path = '%s' and uid = %d limit 1", + dbesc($dstfile), + intval($channel['channel_id']) + ); + + if($r && $r[0]['is_dir']) { + $isadir = true; + $basepath = $dstfile; + $folder = $r[0]['hash']; + } + else { + $pathname = (($isadir) ? $dstfile : dirname($dstfile)); + $arr = [ + 'pathname' => $pathname, + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'], + ]; + + $folder = ''; + if($pathname && $isadir) { + $x = attach_mkdirp($channel,$channel['channel_hash'],$arr); + if($x['success']) + $folder = $x['data']['hash']; + } } } |