aboutsummaryrefslogtreecommitdiffstats
path: root/include/RedDAV/RedDirectory.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/RedDAV/RedDirectory.php')
-rw-r--r--include/RedDAV/RedDirectory.php52
1 files changed, 35 insertions, 17 deletions
diff --git a/include/RedDAV/RedDirectory.php b/include/RedDAV/RedDirectory.php
index 922be378d..dba857cdc 100644
--- a/include/RedDAV/RedDirectory.php
+++ b/include/RedDAV/RedDirectory.php
@@ -200,9 +200,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$mimetype = z_mime_content_type($name);
- $c = q("SELECT * FROM channel WHERE channel_id = %d AND NOT (channel_pageflags & %d)>0 LIMIT 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $c = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
+ intval($this->auth->owner_id)
);
if (! $c) {
@@ -213,18 +212,22 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$filesize = 0;
$hash = random_string();
- $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, flags, filetype, filesize, revision, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
+ $f = 'store/' . $this->auth->owner_nick . '/' . (($this->os_path) ? $this->os_path . '/' : '') . $hash;
+
+
+ $r = q("INSERT INTO attach ( aid, uid, hash, creator, filename, folder, os_storage, filetype, filesize, revision, is_photo, data, created, edited, allow_cid, allow_gid, deny_cid, deny_gid )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
intval($c[0]['channel_account_id']),
intval($c[0]['channel_id']),
dbesc($hash),
dbesc($this->auth->observer),
dbesc($name),
dbesc($this->folder_hash),
- dbesc(ATTACH_FLAG_OS),
+ intval(1),
dbesc($mimetype),
intval($filesize),
intval(0),
+ intval($is_photo),
dbesc($this->os_path . '/' . $hash),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
@@ -234,7 +237,7 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
dbesc($c[0]['channel_deny_gid'])
);
- $f = 'store/' . $this->auth->owner_nick . '/' . (($this->os_path) ? $this->os_path . '/' : '') . $hash;
+
// returns the number of bytes that were written to the file, or FALSE on failure
$size = file_put_contents($f, $data);
@@ -248,9 +251,20 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
// returns now
$edited = datetime_convert();
+
+
+ $is_photo = 0;
+ $x = @getimagesize($f);
+ logger('getimagesize: ' . print_r($x,true), LOGGER_DATA);
+ if(($x) && ($x[2] === IMAGETYPE_GIF || $x[2] === IMAGETYPE_JPEG || $x[2] === IMAGETYPE_PNG)) {
+ $is_photo = 1;
+ }
+
+
// updates entry with filesize and timestamp
- $d = q("UPDATE attach SET filesize = '%s', edited = '%s' WHERE hash = '%s' AND uid = %d",
+ $d = q("UPDATE attach SET filesize = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d",
dbesc($size),
+ intval($is_photo),
dbesc($edited),
dbesc($hash),
intval($c[0]['channel_id'])
@@ -281,6 +295,13 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
return;
}
}
+
+ if($is_photo) {
+ require_once('include/photos.php');
+ $args = array( 'data' => @file_get_contents($f));
+ $p = photo_upload($c[0],get_app()->get_observer(),$args);
+ }
+
}
/**
@@ -296,9 +317,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
throw new DAV\Exception\Forbidden('Permission denied.');
}
- $r = q("SELECT * FROM channel WHERE channel_id = %d AND NOT (channel_pageflags & %d)>0 LIMIT 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $r = q("SELECT * FROM channel WHERE channel_id = %d AND channel_removed = 0 LIMIT 1",
+ intval($this->auth->owner_id)
);
if ($r) {
@@ -367,9 +387,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$channel_name = $path_arr[0];
- $r = q("SELECT channel_id FROM channel WHERE channel_address = '%s' AND NOT ( channel_pageflags & %d )>0 LIMIT 1",
- dbesc($channel_name),
- intval(PAGE_REMOVED)
+ $r = q("SELECT channel_id FROM channel WHERE channel_address = '%s' AND channel_removed = 0 LIMIT 1",
+ dbesc($channel_name)
);
if (! $r) {
@@ -445,9 +464,8 @@ class RedDirectory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$free = disk_free_space('store');
if ($this->auth->owner_id) {
- $c = q("select * from channel where channel_id = %d and not (channel_pageflags & %d)>0 limit 1",
- intval($this->auth->owner_id),
- intval(PAGE_REMOVED)
+ $c = q("select * from channel where channel_id = %d and channel_removed = 0 limit 1",
+ intval($this->auth->owner_id)
);
$ulimit = service_class_fetch($c[0]['channel_id'], 'attach_upload_limit');