From 2d0ad0625a1bc8bc54ad21d1a5ebb057b0afa357 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 31 Aug 2014 16:24:05 -0700 Subject: sql error in profile_activity --- include/activities.php | 2 +- include/zot.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/activities.php b/include/activities.php index 4502b758e..d978ebcd6 100644 --- a/include/activities.php +++ b/include/activities.php @@ -25,7 +25,7 @@ function profile_activity($changed, $value) { $arr['verb'] = ACTIVITY_UPDATE; $arr['obj_type'] = ACTIVITY_OBJ_PROFILE; - $arr['$plink'] = z_root() . '/channel/' . $self['channel_address'] . '/?f=&mid=' . $arr['mid']; + $arr['plink'] = z_root() . '/channel/' . $self['channel_address'] . '/?f=&mid=' . $arr['mid']; $A = '[url=' . z_root() . '/channel/' . $self['channel_address'] . ']' . $self['channel_name'] . '[/url]'; diff --git a/include/zot.php b/include/zot.php index 8627656c2..6ccee8c39 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1791,8 +1791,6 @@ function process_mail_delivery($sender,$arr,$deliveries) { function process_profile_delivery($sender,$arr,$deliveries) { - // deliveries is irrelevant, what to do about birthday notification....? - logger('process_profile_delivery', LOGGER_DEBUG); $r = q("select xchan_addr from xchan where xchan_hash = '%s' limit 1", @@ -1864,7 +1862,7 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = UPDATE_FLAGS_ $update = false; foreach($r[0] as $k => $v) { if((array_key_exists($k,$arr)) && ($arr[$k] != $v)) { - logger('import_directory_profile: update' . $k . ' => ' . $arr[$k]); + logger('import_directory_profile: update ' . $k . ' => ' . $arr[$k]); $update = true; break; } @@ -1906,7 +1904,7 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = UPDATE_FLAGS_ } else { $update = true; - logger('import_directory_profile: new profile'); + logger('import_directory_profile: new profile '); $x = q("insert into xprof (xprof_hash, xprof_desc, xprof_dob, xprof_age, xprof_gender, xprof_marital, xprof_sexual, xprof_locale, xprof_region, xprof_postcode, xprof_country, xprof_about, xprof_homepage, xprof_hometown, xprof_keywords) values ('%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", dbesc($arr['xprof_hash']), dbesc($arr['xprof_desc']), -- cgit v1.2.3 From f8e6395ef3a54d58c00153b032bbc1645e8b5627 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 31 Aug 2014 18:50:30 -0700 Subject: rss feed discovery --- include/follow.php | 21 ++++-- include/network.php | 182 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 178 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/follow.php b/include/follow.php index 55249db2b..1ef355208 100644 --- a/include/follow.php +++ b/include/follow.php @@ -35,10 +35,10 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if($arr['channel']['success']) $ret = $arr['channel']; - else + elseif(strpos($url,'://') === false) $ret = zot_finger($url,$channel); - if($ret['success']) { + if($ret && $ret['success']) { $is_red = true; $j = json_decode($ret['body'],true); } @@ -120,8 +120,10 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $my_perms = 0; $their_perms = 0; $xchan_hash = ''; + $is_http = false; - $r = q("select * from xchan where xchan_hash = '%s' limit 1", + $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", + dbesc($url), dbesc($url) ); @@ -130,9 +132,19 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if(strpos($url,'@')) { $r = discover_by_webbie($url); } + elseif(strpos($url,'://')) { + $r = discover_by_url($url); + $is_http = true; + } + if($r) { + $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", + dbesc($url), + dbesc($url) + ); + } } if($r) { - $xchan_hash = $url; + $xchan_hash = $r[0]['xchan_hash']; $their_perms = 0; $my_perms = PERMS_W_STREAM|PERMS_W_MAIL; } @@ -150,7 +162,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $hash = get_observer_hash(); $ch = $a->get_channel(); $default_group = $ch['channel_default_group']; - } else { $r = q("select * from channel where channel_id = %d limit 1", diff --git a/include/network.php b/include/network.php index ff0502f5a..89bcbdc25 100644 --- a/include/network.php +++ b/include/network.php @@ -819,6 +819,150 @@ function email_send($addr, $subject, $headers, $item) { } + +function discover_by_url($url,$arr = null) { + require_once('library/HTML5/Parser.php'); + + $x = scrape_feed($url); + if(! $x) { + if(! $arr) + return false; + $network = (($arr['network']) ? $arr['network'] : 'unknown'); + $name = (($arr['name']) ? $arr['name'] : 'unknown'); + $photo = (($arr['photo']) ? $arr['photo'] : ''); + $addr = (($arr['addr']) ? $arr['addr'] : ''); + $guid = $url; + } + + $profile = $url; + + logger('scrape_feed results: ' . print_r($x,true)); + + if($x['feed_atom']) + $guid = $x['feed_atom']; + if($x['feed_rss']) + $guid = $x['feed_rss']; + + if(! $guid) + return false; + + + // try and discover stuff from the feeed + + require_once('library/simplepie/simplepie.inc'); + $feed = new SimplePie(); + $level = 0; + $x = z_fetch_url($guid,false,$level,array('novalidate' => true)); + if(! $x['success']) { + logger('probe_url: feed fetch failed for ' . $poll); + return false; + } + $xml = $x['body']; + logger('probe_url: fetch feed: ' . $guid . ' returns: ' . $xml, LOGGER_DATA); + logger('probe_url: scrape_feed: headers: ' . $x['header'], LOGGER_DATA); + + // Don't try and parse an empty string + $feed->set_raw_data(($xml) ? $xml : ''); + + $feed->init(); + if($feed->error()) + logger('probe_url: scrape_feed: Error parsing XML: ' . $feed->error()); + + $photo = $feed->get_image_url(); + $author = $feed->get_author(); + + if($author) { + $name = unxmlify(trim($author->get_name())); + if(! $name) + $name = trim(unxmlify($author->get_email())); + if(strpos($name,'@') !== false) + $name = substr($name,0,strpos($name,'@')); + if(! $profile && $author->get_link()) + $profile = trim(unxmlify($author->get_link())); + if(! $photo) { + $rawtags = $feed->get_feed_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); + if($rawtags) { + $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; + if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo')) + $photo = $elems['link'][0]['attribs']['']['href']; + } + } + } + else { + $item = $feed->get_item(0); + if($item) { + $author = $item->get_author(); + if($author) { + $name = trim(unxmlify($author->get_name())); + if(! $name) + $name = trim(unxmlify($author->get_email())); + if(strpos($name,'@') !== false) + $name = substr($name,0,strpos($name,'@')); + if(! $profile && $author->get_link()) + $profile = trim(unxmlify($author->get_link())); + } + if(! $photo) { + $rawmedia = $item->get_item_tags('http://search.yahoo.com/mrss/','thumbnail'); + if($rawmedia && $rawmedia[0]['attribs']['']['url']) + $photo = unxmlify($rawmedia[0]['attribs']['']['url']); + } + if(! $photo) { + $rawtags = $item->get_item_tags( SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); + if($rawtags) { + $elems = $rawtags[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]; + if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo')) + $photo = $elems['link'][0]['attribs']['']['href']; + } + } + } + } + if($poll === $profile) + $lnk = $feed->get_permalink(); + if(isset($lnk) && strlen($lnk)) + $profile = $lnk; + + if(! $network) { + $network = 'rss'; + } + if(! $name) + $name = notags($feed->get_title()); + if(! $name) + $name = notags($feed->get_description()); + + if(! $guid) + return false; + + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($guid) + ); + if($r) + return true; + + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", + dbesc($guid), + dbesc($guid), + dbesc($pubkey), + dbesc($addr), + dbesc($profile), + dbesc($name), + dbesc($network), + dbesc(z_root()), + dbesc(datetime_convert()) + ); + + $photos = import_profile_photo($photo,$profile); + $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_hash = '%s' limit 1", + dbesc(datetime_convert('UTC','UTC',$arr['photo_updated'])), + dbesc($photos[0]), + dbesc($photos[1]), + dbesc($photos[2]), + dbesc($photos[3]), + dbesc($guid) + ); + return true; + +} + function discover_by_webbie($webbie) { require_once('library/HTML5/Parser.php'); @@ -882,14 +1026,12 @@ function discover_by_webbie($webbie) { } } - if($diaspora && $diaspora_base && $diaspora_guid) { + if($diaspora && $diaspora_base && $diaspora_guid && intval(get_config('system','diaspora_enabled'))) { $guid = $diaspora_guid; $diaspora_base = trim($diaspora_base,'/'); $notify = $diaspora_base . '/receive'; -// // '/users/' . $diaspora_guid; -// $batch = $diaspora_base . '/receive/public' ; if(strpos($webbie,'@')) { $addr = str_replace('acct:', '', $webbie); $hostname = substr($webbie,strpos($webbie,'@')+1); @@ -988,23 +1130,23 @@ function discover_by_webbie($webbie) { Array ( - [name] => Mike Macgirvin - [nick] => macgirvin - [guid] => a9174a618f8d269a - [url] => https://joindiaspora.com/u/macgirvin - [hostname] => joindiaspora.com - [addr] => macgirvin@joindiaspora.com - [batch] => - [notify] => https://joindiaspora.com/receive - [poll] => https://joindiaspora.com/public/macgirvin.atom - [request] => - [confirm] => - [poco] => - [photo] => https://joindiaspora.s3.amazonaws.com/uploads/images/thumb_large_fec4e6eef13ae5e56207.jpg - [priority] => - [network] => diaspora - [alias] => - [pubkey] => -----BEGIN PUBLIC KEY----- + [name] => Mike Macgirvin + [nick] => macgirvin + [guid] => a9174a618f8d269a + [url] => https://joindiaspora.com/u/macgirvin + [hostname] => joindiaspora.com + [addr] => macgirvin@joindiaspora.com + [batch] => + [notify] => https://joindiaspora.com/receive + [poll] => https://joindiaspora.com/public/macgirvin.atom + [request] => + [confirm] => + [poco] => + [photo] => https://joindiaspora.s3.amazonaws.com/uploads/images/thumb_large_fec4e6eef13ae5e56207.jpg + [priority] => + [network] => diaspora + [alias] => + [pubkey] => -----BEGIN PUBLIC KEY----- MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtihtyIuRDWkDpCA+I1UaQ jI4S7k625+A7EEJm+pL2ZVSJxeCKiFeEgHBQENjLMNNm8l8F6blxgQqE6ZJ9Spa7f tlaXYTRCrfxKzh02L3hR7sNA+JS/nXJaUAIo+IwpIEspmcIRbD9GB7Wv/rr+M28uH -- cgit v1.2.3 From 89d5c42df16ccef9c6c849a98d37e58bbf3dd49a Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 31 Aug 2014 19:30:35 -0700 Subject: service class check for feeds. Note limit is account based, not channel based. --- include/follow.php | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/follow.php b/include/follow.php index 1ef355208..8f14a5062 100644 --- a/include/follow.php +++ b/include/follow.php @@ -17,7 +17,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $a = get_app(); $is_red = false; - + $is_http = ((strpos($url,'://') !== false) ? true : false); if(! allowed_url($url)) { $result['message'] = t('Channel is blocked on this site.'); @@ -29,13 +29,29 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) return $result; } + + // check service class limits + + $r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ", + intval($uid), + intval(ABOOK_FLAG_SELF) + ); + if($r) + $total_channels = $r[0]['total']; + + if(! service_class_allows($uid,'total_channels',$total_channels)) { + $result['message'] = upgrade_message(); + return $result; + } + + $arr = array('url' => $url, 'channel' => array()); call_hooks('follow', $arr); if($arr['channel']['success']) $ret = $arr['channel']; - elseif(strpos($url,'://') === false) + elseif($is_http) $ret = zot_finger($url,$channel); if($ret && $ret['success']) { @@ -61,20 +77,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if(array_key_exists('connect_url',$j) && (! $confirm)) goaway(zid($j['connect_url'])); - // check service class limits - - $r = q("select count(*) as total from abook where abook_channel = %d and not (abook_flags & %d) ", - intval($uid), - intval(ABOOK_FLAG_SELF) - ); - if($r) - $total_channels = $r[0]['total']; - - if(! service_class_allows($uid,'total_channels',$total_channels)) { - $result['message'] = upgrade_message(); - return $result; - } - // do we have an xchan and hubloc? // If not, create them. @@ -120,7 +122,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $my_perms = 0; $their_perms = 0; $xchan_hash = ''; - $is_http = false; $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), @@ -132,9 +133,8 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if(strpos($url,'@')) { $r = discover_by_webbie($url); } - elseif(strpos($url,'://')) { + elseif($is_http) { $r = discover_by_url($url); - $is_http = true; } if($r) { $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", @@ -148,7 +148,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $their_perms = 0; $my_perms = PERMS_W_STREAM|PERMS_W_MAIL; } - } if(! $xchan_hash) { @@ -175,7 +174,20 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $hash = $r[0]['channel_hash']; $default_group = $r[0]['channel_default_group']; } - + + if($is_http) { + $r = q("select count(*) as total from abook where abook_account = %d and abook_network = 'rss'", + intval($aid) + ); + if($r) + $total_feeds = $r[0]['total']; + + if(! service_class_allows($uid,'total_feeds',$total_feeds)) { + $result['message'] = upgrade_message(); + return $result; + } + } + if($hash == $xchan_hash) { $result['message'] = t('Cannot connect to yourself.'); return $result; -- cgit v1.2.3 From a63de472cf1b5cff1ebda821d3a6ba39cf37f839 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 31 Aug 2014 20:51:05 -0700 Subject: various rss fixes --- include/items.php | 31 ++++++++++++++++++++----------- include/text.php | 5 +++++ 2 files changed, 25 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4614aa642..f489eeb0a 100755 --- a/include/items.php +++ b/include/items.php @@ -1499,6 +1499,9 @@ function get_atom_elements($feed,$item,&$author) { if($d2 > $d3) $res['edited'] = datetime_convert(); + $res['created'] = datetime_convert('UTC','UTC',$res['created']); + $res['edited'] = datetime_convert('UTC','UTC',$res['edited']); + $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if(! $rawowner) $rawowner = $item->get_item_tags(NAMESPACE_ZOT,'owner'); @@ -1560,7 +1563,7 @@ function get_atom_elements($feed,$item,&$author) { $termterm = notags(trim(unxmlify($term))); if($termterm) { - $terms = array( + $terms[] = array( 'otype' => TERM_OBJ_POST, 'type' => $termtype, 'url' => $termurl, @@ -1568,7 +1571,7 @@ function get_atom_elements($feed,$item,&$author) { ); } } - $res['term'] = implode(',', $tag_arr); + $res['term'] = $terms; } $attach = $item->get_enclosures(); @@ -1663,6 +1666,9 @@ function get_atom_elements($feed,$item,&$author) { $res['target'] = $obj; } + $res['public_policy'] = 'specific'; + $res['comment_policy'] = 'none'; + $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); call_hooks('parse_atom', $arr); @@ -3207,14 +3213,14 @@ function consume_feed($xml,$importer,&$contact,$pass = 0) { $datarray['uid'] = $importer['channel_id']; //FIXME - $datarray['author_xchan'] = $contact['xchan_hash']; + $datarray['owner_xchan'] = $datarray['author_xchan'] = $contact['xchan_hash']; // FIXME pull out the author and owner logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA); -// $xx = item_store($datarray); + $xx = item_store($datarray); $r = $xx['item_id']; continue; } @@ -3267,18 +3273,21 @@ function consume_feed($xml,$importer,&$contact,$pass = 0) { $datarray['parent_mid'] = $item_id; $datarray['uid'] = $importer['channel_id']; //FIXME - $datarray['author_xchan'] = $contact['author_xchan']; - + $datarray['owner_xchan'] = $datarray['author_xchan'] = $contact['xchan_hash']; + if(! link_compare($author['owner_link'],$contact['xchan_url'])) { logger('consume_feed: Correcting item owner.', LOGGER_DEBUG); - $author['owner-name'] = $contact['name']; - $author['owner-link'] = $contact['url']; - $author['owner-avatar'] = $contact['thumb']; + $author['owner_name'] = $contact['name']; + $author['owner_link'] = $contact['url']; + $author['owner_avatar'] = $contact['thumb']; } + logger('consume_feed: author ' . print_r($author,true)); + + logger('consume_feed: ' . print_r($datarray,true),LOGGER_DATA); -// $xx = item_store($datarray); + $xx = item_store($datarray); $r = $xx['item_id']; continue; @@ -3311,7 +3320,7 @@ function handle_feed($uid,$abook_id,$url) { $recurse = 0; $z = z_fetch_url($url,false,$recurse,array('novalidate' => true)); -logger('handle_feed:' . print_r($z,true)); +//logger('handle_feed:' . print_r($z,true)); if($z['success']) { consume_feed($z['body'],$channel,$x[0],0); diff --git a/include/text.php b/include/text.php index 410d9bc96..7da6a8f2b 100644 --- a/include/text.php +++ b/include/text.php @@ -1865,6 +1865,11 @@ function xchan_query(&$items,$abook = true) { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )"); } + $xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')"); + if(! $chans) + $chans = $xchans; + else + $chans = array_merge($xchans,$chans); } if($items && count($items) && $chans && count($chans)) { for($x = 0; $x < count($items); $x ++) { -- cgit v1.2.3 From 2a37d99958d5591d5b9ccfc9bc615ee0588a6036 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 31 Aug 2014 22:15:00 -0700 Subject: get out the sunnies --- include/follow.php | 5 +++-- include/items.php | 2 +- include/onepoll.php | 17 ++++++++++++++--- include/poller.php | 15 ++++++++++++++- 4 files changed, 32 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/follow.php b/include/follow.php index 8f14a5062..102d84605 100644 --- a/include/follow.php +++ b/include/follow.php @@ -204,11 +204,12 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) ); } else { - $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_their_perms, abook_my_perms, abook_created, abook_updated ) - values( %d, %d, '%s', %d, %d, '%s', '%s' ) ", + $r = q("insert into abook ( abook_account, abook_channel, abook_xchan, abook_flags, abook_their_perms, abook_my_perms, abook_created, abook_updated ) + values( %d, %d, '%s', %d, %d, %d, '%s', '%s' ) ", intval($aid), intval($uid), dbesc($xchan_hash), + intval(($is_http) ? ABOOK_FLAG_FEED : 0), intval($their_perms), intval($my_perms), dbesc(datetime_convert()), diff --git a/include/items.php b/include/items.php index f489eeb0a..7764d2f62 100755 --- a/include/items.php +++ b/include/items.php @@ -1558,7 +1558,7 @@ function get_atom_elements($feed,$item,&$author) { $termurl = unxmlify(substr($scheme,9)); } else { - $termtype = TERM_UNKNOWN; + $termtype = TERM_CATEGORY; } $termterm = notags(trim(unxmlify($term))); diff --git a/include/onepoll.php b/include/onepoll.php index 947e936ac..d64785f92 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -38,7 +38,7 @@ function onepoll_run($argv, $argc){ AND NOT ( abook_flags & %d ) AND (( account_flags = %d ) OR ( account_flags = %d )) limit 1", intval($contact_id), - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED), + intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED|ABOOK_FLAG_FEED), intval(0), intval(ABOOK_FLAG_ARCHIVED|ABOOK_FLAG_BLOCKED|ABOOK_FLAG_IGNORED), intval(ACCOUNT_OK), @@ -72,6 +72,19 @@ function onepoll_run($argv, $argc){ : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days') ); + if($contact['xchan_network'] === 'rss') { + logger('onepoll: processing feed ' . $contact['xchan_name'], LOGGER_DEBUG); + handle_feed($importer['channel_id'],$contact_id,$contact['xchan_hash']); + q("update abook set abook_connected = '%s' where abook_id = %d limit 1", + dbesc(datetime_convert()), + intval($contact['abook_id']) + ); + return; + } + + if($contact['xchan_network'] !== 'zot') + return; + // update permissions $x = zot_refresh($contact,$importer); @@ -130,11 +143,9 @@ function onepoll_run($argv, $argc){ } } - // fetch some items // set last updated timestamp - if($contact['xchan_connurl']) { $r = q("SELECT xlink_id from xlink where xlink_xchan = '%s' and xlink_updated > UTC_TIMESTAMP() - INTERVAL 1 DAY limit 1", diff --git a/include/poller.php b/include/poller.php index 546a2d6d1..52ca98c97 100644 --- a/include/poller.php +++ b/include/poller.php @@ -244,7 +244,7 @@ function poller_run($argv, $argc){ $sql_extra AND (( abook_flags & %d ) OR ( abook_flags = %d )) AND (( account_flags = %d ) OR ( account_flags = %d )) $abandon_sql ORDER BY RAND()", - intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED), + intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_UNCONNECTED|ABOOK_FLAG_FEED), intval(0), intval(ACCOUNT_OK), intval(ACCOUNT_UNVERIFIED) // FIXME @@ -260,6 +260,19 @@ function poller_run($argv, $argc){ $t = $contact['abook_updated']; $c = $contact['abook_connected']; + if($contact['abook_flags'] & ABOOK_FLAG_FEED) { + $min = intval(get_config('system','minimum_feedcheck_minutes')); + if(! $min) + $min = 60; + $x = datetime_convert('UTC','UTC',"now - $min minutes"); + if($c < $x) { + proc_run('php','include/onepoll.php',$contact['abook_id']); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); + } + continue; + } + if($c == $t) { if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) -- cgit v1.2.3 From 76a72a997d710f4cd53822313260fb259efb63cf Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 1 Sep 2014 04:17:10 -0700 Subject: honour the feed_contacts setting --- include/follow.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/follow.php b/include/follow.php index 102d84605..d1c6afbee 100644 --- a/include/follow.php +++ b/include/follow.php @@ -176,6 +176,11 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) } if($is_http) { + if(! intval(get_config('system','feed_contacts'))) { + $result['message'] = t('Protocol disabled.'); + return $result; + } + $r = q("select count(*) as total from abook where abook_account = %d and abook_network = 'rss'", intval($aid) ); -- cgit v1.2.3 From a2146021f3218ae66d32d6a28f3a79a2d1cee6ac Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 1 Sep 2014 16:32:35 -0700 Subject: use feed icon as default avatar for rss connections --- include/Contact.php | 2 +- include/network.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 66c94ef50..a9e737bde 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -323,7 +323,7 @@ function mark_orphan_hubsxchans() { return; $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d) - and hubloc_connected < utc_timestamp() - interval 36 day", + and hubloc_network != 'zot' and hubloc_connected < utc_timestamp() - interval 36 day", intval(HUBLOC_OFFLINE), intval(HUBLOC_OFFLINE) ); diff --git a/include/network.php b/include/network.php index 89bcbdc25..c44ed77c4 100644 --- a/include/network.php +++ b/include/network.php @@ -938,6 +938,9 @@ function discover_by_url($url,$arr = null) { if($r) return true; + if(! $photo) + $photo = z_root() . '/images/rss_icon.png'; + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_pubkey, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_instance_url, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", dbesc($guid), dbesc($guid), @@ -950,9 +953,9 @@ function discover_by_url($url,$arr = null) { dbesc(datetime_convert()) ); - $photos = import_profile_photo($photo,$profile); + $photos = import_profile_photo($photo,$guid); $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_hash = '%s' limit 1", - dbesc(datetime_convert('UTC','UTC',$arr['photo_updated'])), + dbesc(datetime_convert()), dbesc($photos[0]), dbesc($photos[1]), dbesc($photos[2]), -- cgit v1.2.3