aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/attach.php10
-rw-r--r--include/reddav.php9
2 files changed, 15 insertions, 4 deletions
diff --git a/include/attach.php b/include/attach.php
index e602af984..b48dd211a 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -188,13 +188,13 @@ function attach_by_hash($hash,$rev = 0) {
$sql_extra = permissions_sql($r[0]['uid']);
// Now we'll see if we can access the attachment
-dbg(1);
+
$r = q("SELECT * FROM attach WHERE hash = '%s' and uid = %d $sql_extra LIMIT 1",
dbesc($hash),
intval($r[0]['uid'])
);
-dbg(0);
+
if(! $r) {
$ret['message'] = t('Permission denied.');
return $ret;
@@ -672,3 +672,9 @@ function attach_change_permissions($channel_id,$resource,$allow_cid,$allow_gid,$
}
+function pipe_streams($in, $out) {
+ $size = 0;
+ while (!feof($in))
+ $size += fwrite($out,fread($in,8192));
+ return $size;
+} \ No newline at end of file
diff --git a/include/reddav.php b/include/reddav.php
index 543cdfeac..05a93b9f8 100644
--- a/include/reddav.php
+++ b/include/reddav.php
@@ -376,11 +376,16 @@ class RedFile extends DAV\Node implements DAV\IFile {
function get() {
logger('RedFile::get: ' . basename($this->name));
- $r = q("select data from attach where hash = '%s' and uid = %d limit 1",
+ $r = q("select data, flags from attach where hash = '%s' and uid = %d limit 1",
dbesc($this->data['hash']),
intval($this->data['uid'])
);
- if($r) return $r[0]['data'];
+ if($r) {
+ if($r[0]['flags'] & ATTACH_FLAG_OS ) {
+ return fopen($r[0]['data'],'rb');
+ }
+ return $r[0]['data'];
+ }
}