diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/photos.php | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/mod/photos.php b/mod/photos.php index e484880e3..0442a5d24 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -244,9 +244,25 @@ function photos_post(&$a) { $width = $ph->getWidth(); $height = $ph->getHeight(); + + if(intval($r[0]['os_storage'])) { + @file_put_contents($r[0]['data'],$ph->imageString()); + $data = $r[0]['data']; + $fsize = @filesize($r[0]['data']); + q("update attach set filesize = %d where hash = '%s' and uid = %d limit 1", + intval($fsize), + dbesc($resource_id), + intval($page_owner_uid) + ); + } + else { + $data = $ph->imageString(); + $fsize = strlen($data); + } - $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 0", - dbescbin($ph->imageString()), + $x = q("update photo set data = '%s', `size` = %d, height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 0", + dbescbin($data), + intval($fsize), intval($height), intval($width), dbesc($resource_id), @@ -300,10 +316,7 @@ function photos_post(&$a) { } } - // @FIXME This query includes data of all thumbnails and could probably - // be made much more memory efficient. - - $p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ORDER BY `scale` DESC", + $p = q("SELECT type, is_nsfw, description, resource_id, scale, allow_cid, allow_gid, deny_cid, deny_gid FROM photo WHERE resource_id = '%s' AND uid = %d ORDER BY scale DESC", dbesc($resource_id), intval($page_owner_uid) ); |