aboutsummaryrefslogtreecommitdiffstats
path: root/util/dcp
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2018-05-04 09:46:27 +0200
committerMario Vavti <mario@mariovavti.com>2018-05-04 09:46:27 +0200
commitbe4c9a9598350fb4333480f0c7b302acebcddfd4 (patch)
treefb0c2606ad4ca0bc1a710d6fdf82f55c326b3427 /util/dcp
parentf15c12376adad6534c8c0ea547a7548697eb8379 (diff)
parentbe852ba857f4cb8e75574a762945b50c8bddcff9 (diff)
downloadvolse-hubzilla-be4c9a9598350fb4333480f0c7b302acebcddfd4.tar.gz
volse-hubzilla-be4c9a9598350fb4333480f0c7b302acebcddfd4.tar.bz2
volse-hubzilla-be4c9a9598350fb4333480f0c7b302acebcddfd4.zip
Merge branch '3.4RC'3.4
Diffstat (limited to 'util/dcp')
-rwxr-xr-xutil/dcp64
1 files changed, 38 insertions, 26 deletions
diff --git a/util/dcp b/util/dcp
index 677882193..ecef67804 100755
--- a/util/dcp
+++ b/util/dcp
@@ -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'];
+ }
}
}