From fa89b8f66d98f8d74ce9283314649d4916652df9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Mar 2017 22:02:28 -0700 Subject: add os_path and display_path to photos, fix some issues with multiple path separators after cloud/nickname in the content field of attach and photos --- include/photo/photo_driver.php | 88 +----------------------------------------- 1 file changed, 2 insertions(+), 86 deletions(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index c8b3c3782..923e34dbe 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -380,7 +380,7 @@ abstract class photo_driver { dbesc($p['album']), intval($this->getHeight()), intval($this->getWidth()), - (intval($p['os_storage']) ? dbescbin($p['os_path']) : dbescbin($this->imageString())), + (intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())), intval($p['os_storage']), intval(strlen($this->imageString())), intval($p['imgscale']), @@ -411,7 +411,7 @@ abstract class photo_driver { dbesc($p['album']), intval($this->getHeight()), intval($this->getWidth()), - (intval($p['os_storage']) ? dbescbin($p['os_path']) : dbescbin($this->imageString())), + (intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())), intval($p['os_storage']), intval(strlen($this->imageString())), intval($p['imgscale']), @@ -429,90 +429,6 @@ abstract class photo_driver { return $r; } - - // should be obsolete now - - public function store($aid, $uid, $xchan, $rid, $filename, $album, $scale, $usage = PHOTO_NORMAL, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') { - - $x = q("select id from photo where resource_id = '%s' and uid = %d and xchan = '%s' and imgscale = %d limit 1", - dbesc($rid), - intval($uid), - dbesc($xchan), - intval($scale) - ); - if(count($x)) { - $r = q("UPDATE photo - set aid = %d, - uid = %d, - xchan = '%s', - resource_id = '%s', - created = '%s', - edited = '%s', - filename = '%s', - mimetype = '%s', - album = '%s', - height = %d, - width = %d, - content = '%s', - filesize = %d, - imgscale = %d, - photo_usage = %d, - allow_cid = '%s', - allow_gid = '%s', - deny_cid = '%s', - deny_gid = '%s' - where id = %d", - - intval($aid), - intval($uid), - dbesc($xchan), - dbesc($rid), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(basename($filename)), - dbesc($this->getType()), - dbesc($album), - intval($this->getHeight()), - intval($this->getWidth()), - dbescbin($this->imageString()), - intval(strlen($this->imageString())), - intval($scale), - intval($photo_usage), - dbesc($allow_cid), - dbesc($allow_gid), - dbesc($deny_cid), - dbesc($deny_gid), - intval($x[0]['id']) - ); - } - else { - $r = q("INSERT INTO photo - ( aid, uid, xchan, resource_id, created, edited, filename, mimetype, album, height, width, content, filesize, imgscale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid ) - VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s', '%s' )", - intval($aid), - intval($uid), - dbesc($xchan), - dbesc($rid), - dbesc(datetime_convert()), - dbesc(datetime_convert()), - dbesc(basename($filename)), - dbesc($this->getType()), - dbesc($album), - intval($this->getHeight()), - intval($this->getWidth()), - dbescbin($this->imageString()), - intval(strlen($this->imageString())), - intval($scale), - intval($photo_usage), - dbesc($allow_cid), - dbesc($allow_gid), - dbesc($deny_cid), - dbesc($deny_gid) - ); - } - return $r; - } - } -- cgit v1.2.3 From 65e5894363e5cd5a9c8a61a0387f90068215f58e Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 7 Apr 2017 14:56:12 -0700 Subject: photo size-0 issue --- include/photo/photo_driver.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 923e34dbe..cc1f3b5d0 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -330,6 +330,7 @@ abstract class photo_driver { $p['photo_usage'] = intval($arr['photo_usage']); $p['os_storage'] = intval($arr['os_storage']); $p['os_path'] = $arr['os_path']; + $p['os_syspath'] = ((array_key_exists('os_syspath',$arr)) ? $arr['os_syspath'] : ''); $p['display_path'] = (($arr['display_path']) ? $arr['display_path'] : ''); if(! intval($p['imgscale'])) -- cgit v1.2.3 From cdfcb1ed24d950efa2a2054bec5267ecdae3fb68 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 31 May 2017 22:59:07 -0700 Subject: cleanup only --- include/photo/photo_driver.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index cc1f3b5d0..0bf09e4d8 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -252,11 +252,10 @@ abstract class photo_driver { */ if(! $this->is_valid()) - return FALSE; - + return false; if((! function_exists('exif_read_data')) || ($this->getType() !== 'image/jpeg')) - return; + return false; $exif = @exif_read_data($filename,null,true); -- cgit v1.2.3 From 83f8f8ebb8bc7e6cbbc3b71f664706e30dfe6c1c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 5 Jun 2017 15:57:43 -0700 Subject: whitespace --- include/photo/photo_driver.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 0bf09e4d8..eb61578e1 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -488,8 +488,10 @@ function guess_image_type($filename, $headers = '') { $ext = pathinfo($filename, PATHINFO_EXTENSION); $ph = photo_factory(''); $types = $ph->supportedTypes(); - foreach ($types as $m=>$e){ - if ($ext==$e) $type = $m; + foreach($types as $m => $e) { + if($ext === $e) { + $type = $m; + } } } @@ -501,7 +503,7 @@ function guess_image_type($filename, $headers = '') { } } - logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG); + logger('Photo: guess_image_type: type = ' . $type, LOGGER_DEBUG); return $type; } -- cgit v1.2.3 From 07d6472eea377a9be7e35cca823307382a43df46 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Jun 2017 18:07:07 -0700 Subject: mastodon reshares can be either posts or comments; silence warning from guess_image_type when handed a URL to a non-existent resource. --- include/photo/photo_driver.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index eb61578e1..9d27ef96e 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -495,12 +495,22 @@ function guess_image_type($filename, $headers = '') { } } - if(is_null($type)) { + if(is_null($type) && (strpos($filename,'http:') === false)) { $size = getimagesize($filename); $ph = photo_factory(''); $types = $ph->supportedTypes(); $type = ((array_key_exists($size['mime'], $types)) ? $size['mime'] : 'image/jpeg'); } + if(is_null($type)) { + if(strpos(strtolower($filename),'jpg') !== false) + $type = 'image/jpeg'; + elseif(strpos(strtolower($filename),'jpeg') !== false) + $type = 'image/jpeg'; + elseif(strpos(strtolower($filename),'gif') !== false) + $type = 'image/gif'; + elseif(strpos(strtolower($filename),'png') !== false) + $type = 'image/png'; + } } logger('Photo: guess_image_type: type = ' . $type, LOGGER_DEBUG); -- cgit v1.2.3 From 21542d1f9e66638ff9b4012a63a0070d1abe652a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 25 Jun 2017 18:09:34 -0700 Subject: guess_image_type - ignore scheme when checking for urls --- include/photo/photo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/photo') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 9d27ef96e..f47a9c878 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -495,7 +495,7 @@ function guess_image_type($filename, $headers = '') { } } - if(is_null($type) && (strpos($filename,'http:') === false)) { + if(is_null($type) && (strpos($filename,'http') === false)) { $size = getimagesize($filename); $ph = photo_factory(''); $types = $ph->supportedTypes(); -- cgit v1.2.3