aboutsummaryrefslogtreecommitdiffstats
path: root/include/photo
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2017-10-25 13:29:19 +0200
committerMario <mario@mariovavti.com>2017-10-25 13:29:19 +0200
commit344aa13c64f0fa7a246f3284bf9cdb267e6101d3 (patch)
tree943809c01164dda7b6e4a26bc3d6c7e8c48bd6eb /include/photo
parent61c86212b944efa0d78dcc0364b81bfb8a0d19bc (diff)
parent69b22e3f7916b5ba19b5ed03a55ad72bf5995291 (diff)
downloadvolse-hubzilla-344aa13c64f0fa7a246f3284bf9cdb267e6101d3.tar.gz
volse-hubzilla-344aa13c64f0fa7a246f3284bf9cdb267e6101d3.tar.bz2
volse-hubzilla-344aa13c64f0fa7a246f3284bf9cdb267e6101d3.zip
Merge branch '2.8RC'
Diffstat (limited to 'include/photo')
-rw-r--r--include/photo/photo_driver.php56
1 files changed, 54 insertions, 2 deletions
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index f47a9c878..5eb1f9113 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -446,7 +446,7 @@ abstract class photo_driver {
*/
function guess_image_type($filename, $headers = '') {
- logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG);
+// logger('Photo: guess_image_type: '.$filename . ($headers?' from curl headers':''), LOGGER_DEBUG);
$type = null;
if ($headers) {
@@ -513,11 +513,32 @@ function guess_image_type($filename, $headers = '') {
}
}
- logger('Photo: guess_image_type: type = ' . $type, LOGGER_DEBUG);
+ logger('Photo: guess_image_type: filename = ' . $filename . ' type = ' . $type, LOGGER_DEBUG);
return $type;
}
+
+function delete_thing_photo($url,$ob_hash) {
+
+ $hash = basename($url);
+ $hash = substr($hash,0,strpos($hash,'-'));
+
+ // hashes should be 32 bytes.
+
+ if((! $ob_hash) || (strlen($hash) < 16))
+ return;
+
+ $r = q("delete from photo where xchan = '%s' and photo_usage = %d and resource_id = '%s'",
+ dbesc($ob_hash),
+ intval(PHOTO_THING),
+ dbesc($hash)
+ );
+
+}
+
+
+
function import_xchan_photo($photo,$xchan,$thing = false) {
$flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN);
@@ -637,6 +658,37 @@ function import_xchan_photo($photo,$xchan,$thing = false) {
}
+function import_channel_photo_from_url($photo,$aid,$uid) {
+
+ if($photo) {
+ $filename = basename($photo);
+
+ $result = z_fetch_url($photo,true);
+
+ if($result['success']) {
+ $img_str = $result['body'];
+ $type = guess_image_type($photo, $result['header']);
+
+ $h = explode("\n",$result['header']);
+ if($h) {
+ foreach($h as $hl) {
+ if(stristr($hl,'content-type:')) {
+ if(! stristr($hl,'image/')) {
+ $photo_failure = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ else {
+ $photo_failure = true;
+ }
+
+ import_channel_photo($img_str,$type,$aid,$uid);
+
+ return $type;
+}
function import_channel_photo($photo,$type,$aid,$uid) {