aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-02-17 14:30:02 -0800
committerfriendica <info@friendica.com>2014-02-17 14:30:02 -0800
commit08b571c9d0843b19115bd9bb892cb141c508ea3b (patch)
treeb713024b783dcdcef264167822e7004c254e8689 /include
parentf38ab0904101366bf536d46ab460dcd5cf4f60ca (diff)
downloadvolse-hubzilla-08b571c9d0843b19115bd9bb892cb141c508ea3b.tar.gz
volse-hubzilla-08b571c9d0843b19115bd9bb892cb141c508ea3b.tar.bz2
volse-hubzilla-08b571c9d0843b19115bd9bb892cb141c508ea3b.zip
project "snakebite"
Diffstat (limited to 'include')
-rwxr-xr-xinclude/items.php50
-rw-r--r--include/photo/photo_driver.php16
2 files changed, 59 insertions, 7 deletions
diff --git a/include/items.php b/include/items.php
index c90bfb41c..7e15e9411 100755
--- a/include/items.php
+++ b/include/items.php
@@ -725,14 +725,60 @@ function import_author_xchan($x) {
return $arr['xchan_hash'];
if((! array_key_exists('network', $x)) || ($x['network'] === 'zot')) {
- return import_author_zot($x);
+ $y = import_author_zot($x);
}
- // TODO: create xchans for other common and/or aligned networks
+ if($x['network'] === 'rss') {
+ $y = import_author_rss($x);
+ }
+
+ return(($y) ? $y : false);
+}
+
+function import_author_rss($x) {
+
+ if(! $x['url'])
+ return false;
+
+ $r = q("select xchan_hash from xchan where xchan_network = 'rss' and xchan_url = '%s' limit 1",
+ dbesc($x['url'])
+ );
+ if($r) {
+ logger('import_author_rss: in cache' , LOGGER_DEBUG);
+ return $r[0]['xchan_hash'];
+ }
+ $name = trim($x['name']);
+
+ $r = q("insert into xchan ( xchan_hash, xchan_url, xchan_name, xchan_network )
+ values ( '%s', '%s', '%s', '%s' )",
+ dbesc($x['url']),
+ dbesc($x['url']),
+ dbesc(($name) ? $name : t('Unknown')),
+ dbesc('rss')
+ );
+ if($r) {
+
+ $photos = import_profile_photo($x['photo'],$x['url']);
+
+ if($photos) {
+ $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' where xchan_url = '%s' and xchan_network = 'rss' limit 1",
+ dbesc(datetime_convert('UTC','UTC',$arr['photo_updated'])),
+ dbesc($photos[0]),
+ dbesc($photos[1]),
+ dbesc($photos[2]),
+ dbesc($photos[3]),
+ dbesc($x['url'])
+ );
+ if($r)
+ return $x['url'];
+ }
+ }
return false;
+
}
+
function encode_item($item) {
$x = array();
$x['type'] = 'activity';
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index c2eeafa54..484550cb7 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -538,14 +538,20 @@ function import_profile_photo($photo,$xchan,$thing = false) {
}
$photo_failure = false;
+ $img_str = '';
+ if($photo) {
+ $filename = basename($photo);
+ $type = guess_image_type($photo,true);
- $filename = basename($photo);
- $type = guess_image_type($photo,true);
- $result = z_fetch_url($photo,true);
+ if(! $type)
+ $type = 'image/jpeg';
- if($result['success'])
- $img_str = $result['body'];
+ $result = z_fetch_url($photo,true);
+
+ if($result['success'])
+ $img_str = $result['body'];
+ }
$img = photo_factory($img_str, $type);
if($img->is_valid()) {