aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/account.php1
-rw-r--r--include/attach.php59
-rw-r--r--include/reddav.php17
3 files changed, 62 insertions, 15 deletions
diff --git a/include/account.php b/include/account.php
index ab442ab39..b3dbb7023 100644
--- a/include/account.php
+++ b/include/account.php
@@ -111,6 +111,7 @@ function create_account($arr) {
$expires = ((x($arr,'expires')) ? intval($arr['expires']) : '0000-00-00 00:00:00');
$default_service_class = get_config('system','default_service_class');
+
if($default_service_class === false)
$default_service_class = '';
diff --git a/include/attach.php b/include/attach.php
index c05c39020..93c9a5424 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -569,16 +569,19 @@ function attach_mkdir($channel,$observer_hash,$arr = null) {
$lpath = '';
$lfile = $arr['folder'];
- $sql_options = permissions_sql($channel);
+ $sql_options = permissions_sql($channel['channel_id']);
do {
+
$r = q("select filename, hash, flags, folder from attach where uid = %d and hash = '%s' and ( flags & %d )
$sql_options limit 1",
intval($channel['channel_id']),
dbesc($lfile),
intval(ATTACH_FLAG_DIR)
);
+
if(! $r) {
+ logger('attach_mkdir: hash ' . $lfile . ' not found in ' . $lpath);
$ret['message'] = t('Path not found.');
return $ret;
}
@@ -606,8 +609,8 @@ function attach_mkdir($channel,$observer_hash,$arr = null) {
intval(0),
intval(0),
dbesc($arr['folder']),
- intval(ATTACH_FLAG_DIR),
- dbesc(''),
+ intval(ATTACH_FLAG_DIR|ATTACH_FLAG_OS),
+ dbesc($path),
dbesc($created),
dbesc($created),
dbesc(($arr && array_key_exists('allow_cid',$arr)) ? $arr['allow_cid'] : $channel['channel_allow_cid']),
@@ -672,6 +675,56 @@ function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$
}
+
+function attach_delete($channel_id,$resource) {
+
+
+ $r = q("select hash, flags from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ if(! $r)
+ return;
+
+ if($r[0]['flags'] & ATTACH_FLAG_DIR) {
+ $x = q("select hash, flags from attach where folder = '%s' and uid = %d",
+ dbesc($resource),
+ intval($channel_id)
+ );
+ if($x) {
+ foreach($x as $xx) {
+ attach_delete($channel_id,$xx['hash']);
+ }
+ }
+ }
+ if($r[0]['flags'] & ATTACH_FLAG_OS) {
+ $y = q("select data from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ if($y) {
+ if(is_dir($y[0]['data']))
+ @rmdir($y[0]['data']);
+ elseif(file_exists($y[0]['data']))
+ unlink($y[0]['data']);
+ }
+ }
+
+ $z = q("delete from attach where hash = '%s' and uid = %d limit 1",
+ dbesc($resource),
+ intval($channel_id)
+ );
+
+ return;
+}
+
+
+
+
+
+
function pipe_streams($in, $out) {
$size = 0;
while (!feof($in))
diff --git a/include/reddav.php b/include/reddav.php
index 3bf670711..62208368c 100644
--- a/include/reddav.php
+++ b/include/reddav.php
@@ -21,7 +21,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection {
if(! $this->red_path)
$this->red_path = '/';
$this->auth = $auth_plugin;
- logger('Red_Directory: ' . print_r($this,true));
+// logger('Red_Directory: ' . print_r($this,true));
$this->folder_hash = '';
$this->getDir();
@@ -414,19 +414,12 @@ class RedFile extends DAV\Node implements DAV\IFile {
function delete() {
- if($this->data['flags'] & ATTACH_FLAG_OS) {
- // FIXME delete physical file
- }
- if($this->data['flags'] & ATTACH_FLAG_DIR) {
- // FIXME delete contents (recursive?)
+ if((! $this->auth->owner_id) || (! perm_is_allowed($this->auth->owner_id,$this->auth->observer,'write_storage'))) {
+ throw new DAV\Exception\Forbidden('Permission denied.');
+ return;
}
-
-// q("delete from attach where id = %d limit 1",
-// intval($this->data['id'])
-// );
-
-
+ attach_delete($this->auth->owner_id,$this->data['hash']);
}
}