1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/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);
if($x['success']) {
$hash = $x['data']['hash'];
$sync = attach_export_data($channel,$hash);
if($sync) {
build_sync_packet($channel['channel_id'],array('file' => array($sync)));
}
}
|