aboutsummaryrefslogtreecommitdiffstats
path: root/util/dmkdir
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-08-20 21:02:09 -0700
committerzotlabs <mike@macgirvin.com>2017-08-20 21:02:09 -0700
commit52c6ea51152b6255b45ffb68181fa63413a6fffc (patch)
treea6acffaaaeab0cdef3e9f531f769d93778819390 /util/dmkdir
parentf15d96bebe754d9cb38b1e043a30521d9fbcd668 (diff)
downloadvolse-hubzilla-52c6ea51152b6255b45ffb68181fa63413a6fffc.tar.gz
volse-hubzilla-52c6ea51152b6255b45ffb68181fa63413a6fffc.tar.bz2
volse-hubzilla-52c6ea51152b6255b45ffb68181fa63413a6fffc.zip
add dmkdir
Diffstat (limited to 'util/dmkdir')
-rwxr-xr-xutil/dmkdir48
1 files changed, 48 insertions, 0 deletions
diff --git a/util/dmkdir b/util/dmkdir
new file mode 100755
index 000000000..ffb1932e5
--- /dev/null
+++ b/util/dmkdir
@@ -0,0 +1,48 @@
+#!/usr/bin/env php
+<?php
+
+// file import to DAV utility
+
+if(!file_exists('include/cli_startup.php')) {
+ echo 'Run dmkdir from the top level Hubzilla web directory, as util/dmkdir <args>' . PHP_EOL;
+ exit(1);
+}
+
+require_once('include/cli_startup.php');
+require_once('include/attach.php');
+
+cli_startup();
+
+$dstfile = $argv[1];
+
+if($argc != 2) {
+ echo "Usage: " . $argv[0] . ' directory' . "\n";
+ echo 'Always run from the toplevel web directory.' . "\n";
+ echo 'directory should begin with store/$nickname/desired/path or $nickname/desired/path' . "\n";
+ echo 'Example: util/dmkdir store/bob/photos/2017' . "\n";
+ exit;
+}
+
+
+
+ if(strpos($dstfile,'store/') === 0)
+ $dstfile = substr($dstfile,6);
+
+ $nick = substr($dstfile,0,strpos($dstfile,'/'));
+
+ $dstfile = substr($dstfile,strlen($nick)+1);
+
+ $channel = channelx_by_nick($nick);
+ if(! $channel)
+ return;
+
+
+ $arr = [
+ 'pathname' => $dstfile,
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
+ 'deny_gid' => $channel['channel_deny_gid'],
+ ];
+
+ $x = attach_mkdirp($channel,$channel['channel_hash'],$arr);