From 21f85b32ecaa89a584c29cdf1ef7726cbbb70bb3 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Jan 2015 17:46:16 -0800 Subject: [PATCH 01/13] we need to actually ask for the id from the DB if we want to use it. --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index 2fcada429..3cf54e54e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1485,7 +1485,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque // As a side effect we will also do a preliminary check that we have the top-level-post, otherwise // processing it is pointless. - $r = q("select route from item where mid = '%s' and uid = %d limit 1", + $r = q("select route, id from item where mid = '%s' and uid = %d limit 1", dbesc($arr['parent_mid']), intval($channel['channel_id']) ); From 85b359e25c733deeadac4c3c8f8b073fe578f0d3 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Jan 2015 17:53:19 -0800 Subject: [PATCH 02/13] ignore route mismatches on firehose posts to the sys channel. Use whatever parent route we have. By definition we aren't going to have permission issues with these things. --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index 3cf54e54e..43a7ad6ba 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1539,7 +1539,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash']; - if($last_hop && $last_hop != $sender['hash']) { + if($last_hop && $last_hop != $sender['hash'] && $sender['hash'] != 'undefined') { logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG); logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG); $result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); From 145b30adfc21b7f29d1431ebd1e2e0f4ebd853bf Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Jan 2015 18:34:18 -0800 Subject: [PATCH 03/13] allow RSS connections in the type 'a' autocomplete results as that is used for channel sources. Without it a feed cannot be selected as a channel source. --- mod/acl.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mod/acl.php b/mod/acl.php index d406942c3..8eff93a9a 100644 --- a/mod/acl.php +++ b/mod/acl.php @@ -33,7 +33,7 @@ function acl_init(&$a){ $sql_extra2 = "AND ( xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " OR xchan_addr LIKE " . protect_sprintf( "'%" . dbesc($search) . ((strpos($search,'@') === false) ? "%@%'" : "%'")) . ") "; // This horrible mess is needed because position also returns 0 if nothing is found. W/ould be MUCH easier if it instead returned a very large value - // Otherwise we could just order by LEAST(POSTION($search IN xchan_name),POSITION($search IN xchan_addr)). + // Otherwise we could just order by LEAST(POSITION($search IN xchan_name),POSITION($search IN xchan_addr)). $order_extra2 = "CASE WHEN xchan_name LIKE " . protect_sprintf( "'%" . dbesc($search) . "%'" ) ." then POSITION('".dbesc($search)."' IN xchan_name) else position('".dbesc($search)."' IN xchan_addr) end, "; $col = ((strpos($search,'@') !== false) ? 'xchan_addr' : 'xchan_name' ); $sql_extra3 = "AND $col like " . protect_sprintf( "'%" . dbesc($search) . "%'" ) . " "; @@ -171,6 +171,7 @@ function acl_init(&$a){ ); } elseif(($type == 'a') || ($type == 'p')) { + $r = q("SELECT abook_id as id, xchan_name as name, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_network as network, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not (xchan_flags & %d)>0 @@ -180,6 +181,7 @@ function acl_init(&$a){ intval(XCHAN_FLAGS_DELETED) ); + } elseif($type == 'x') { $r = navbar_complete($a); @@ -209,7 +211,7 @@ function acl_init(&$a){ foreach($r as $g){ // remove RSS feeds from ACLs - they are inaccessible - if(strpos($g['hash'],'/')) + if(strpos($g['hash'],'/') && $type != 'a') continue; if(($g['abook_their_perms'] & PERMS_W_TAGWALL) && $type == 'c' && (! $noforums)) { @@ -233,7 +235,7 @@ function acl_init(&$a){ "id" => $g['id'], "xid" => $g['hash'], "link" => $g['nick'], - "nick" => substr($g['nick'],0,strpos($g['nick'],'@')), + "nick" => (($g['nick']) ? substr($g['nick'],0,strpos($g['nick'],'@')) : t('RSS')), "self" => (($g['abook_flags'] & ABOOK_FLAG_SELF) ? 'abook-self' : ''), "taggable" => '', "label" => '', @@ -248,6 +250,8 @@ function acl_init(&$a){ 'count' => $count, 'items' => $items, ); + + echo json_encode($o); From 87814670c19667d211e8087242d9473ab9f4a46b Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 28 Jan 2015 08:56:56 +0100 Subject: [PATCH 04/13] no need for new line here - spacing is done via css --- mod/share.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/share.php b/mod/share.php index 78a25ee10..d70336ed1 100644 --- a/mod/share.php +++ b/mod/share.php @@ -53,7 +53,7 @@ function share_init(&$a) { "' avatar='".$r[0]['author']['xchan_photo_s']. "' link='".$r[0]['plink']. "' posted='".$r[0]['created']. - "' message_id='".$r[0]['mid']."']\n"; + "' message_id='".$r[0]['mid']."']"; if($r[0]['title']) $o .= '[b]'.$r[0]['title'].'[/b]'."\n"; $o .= $r[0]['body']; From f455036905d83a7983998835b24bfcaf1bed1045 Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 28 Jan 2015 09:49:36 +0100 Subject: [PATCH 05/13] show shared button only to local user --- include/RedDAV/RedBrowser.php | 3 ++- view/tpl/cloud_header.tpl | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/RedDAV/RedBrowser.php b/include/RedDAV/RedBrowser.php index e893d6ebd..8093aebc9 100644 --- a/include/RedDAV/RedBrowser.php +++ b/include/RedDAV/RedBrowser.php @@ -252,7 +252,8 @@ class RedBrowser extends DAV\Browser\Plugin { '$actionspanel' => $output, '$shared' => t('Shared'), '$create' => t('Create'), - 'upload' => t('Upload') + '$upload' => t('Upload'), + '$is_owner' => $is_owner )); $html .= replace_macros(get_markup_template('cloud_directory.tpl'), array( diff --git a/view/tpl/cloud_header.tpl b/view/tpl/cloud_header.tpl index 403323085..c75815d07 100644 --- a/view/tpl/cloud_header.tpl +++ b/view/tpl/cloud_header.tpl @@ -1,7 +1,9 @@
{{if $actionspanel}}
+ {{if $is_owner}}  {{$shared}} + {{/if}}
From 9feb300f47eaff46ea78ef66379de654d3365dae Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 01:06:56 -0800 Subject: [PATCH 06/13] more minor tweaks to the route mismatch algorithm after watching it all day. --- include/zot.php | 7 +++++-- version.inc | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/zot.php b/include/zot.php index 43a7ad6ba..f12d1a8a8 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1524,7 +1524,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque // sent it to us originally. Ignore it if it came from another source // (with potentially different permissions). // only compare the last hop since it could have arrived at the last location any number of ways. - // Always accept empty routes. + // Always accept empty routes and firehose items (route contains 'undefined') . $existing_route = explode(',', $r[0]['route']); $routes = count($existing_route); @@ -1536,10 +1536,13 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $last_hop = ''; $last_prior_route = ''; } + + if($last_hop == 'undefined' || $sender['hash'] == 'undefined') + $last_hop = ''; $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash']; - if($last_hop && $last_hop != $sender['hash'] && $sender['hash'] != 'undefined') { + if($last_hop && $last_hop != $sender['hash']) { logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG); logger('comment route mismatch: parent msg = ' . $r[0]['id'],LOGGER_DEBUG); $result[] = array($d['hash'],'comment route mismatch',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); diff --git a/version.inc b/version.inc index f140c0f66..8b85b7799 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-01-27.929 +2015-01-28.930 From 6c7269be94c7524cce4d5d14f0b330f36ed6d9a4 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 01:13:32 -0800 Subject: [PATCH 07/13] add yet another firehose check --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/zot.php b/include/zot.php index f12d1a8a8..33ac16abf 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1537,7 +1537,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $last_prior_route = ''; } - if($last_hop == 'undefined' || $sender['hash'] == 'undefined') + if(in_array('undefined',$existing_route) || $last_hop == 'undefined' || $sender['hash'] == 'undefined') $last_hop = ''; $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender['hash']; From c826f005e4d8672cd964fafa657026d4f82db883 Mon Sep 17 00:00:00 2001 From: marijus Date: Wed, 28 Jan 2015 10:44:48 +0100 Subject: [PATCH 08/13] fix /view/de/lostpass_eml.tpl --- view/de/lostpass_eml.tpl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/view/de/lostpass_eml.tpl b/view/de/lostpass_eml.tpl index 2175d2e5d..02a71b77a 100644 --- a/view/de/lostpass_eml.tpl +++ b/view/de/lostpass_eml.tpl @@ -1,6 +1,6 @@ Hallo {{$username}}, - auf {{$sitename} wurde eine Rücksetzung Deines Passwortes angefordert. +auf {{$sitename}} wurde eine Rücksetzung Deines Passwortes angefordert. Bitte klicke auf den Link unten, um diese Anforderung zu bestätigen, oder kopiere den Link und füge ihn in die Adresszeile Deines Browsers ein. @@ -27,6 +27,4 @@ Username: {{$email}} Viele Grüße, - der Administrator von {{$sitename}} - - \ No newline at end of file +der Administrator von {{$sitename}} From 3e8fa8c8a2cd125dd7aa0a9482e98ae39db61e52 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 01:48:07 -0800 Subject: [PATCH 09/13] issue with de email template (lostpass_eml.tpl) --- view/de/lostpass_eml.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/de/lostpass_eml.tpl b/view/de/lostpass_eml.tpl index 2175d2e5d..18787d6e4 100644 --- a/view/de/lostpass_eml.tpl +++ b/view/de/lostpass_eml.tpl @@ -1,6 +1,6 @@ Hallo {{$username}}, - auf {{$sitename} wurde eine Rücksetzung Deines Passwortes angefordert. + auf {{$sitename}} wurde eine Rücksetzung Deines Passwortes angefordert. Bitte klicke auf den Link unten, um diese Anforderung zu bestätigen, oder kopiere den Link und füge ihn in die Adresszeile Deines Browsers ein. From 42816f10def942d17542ad8605ba0ca2de8d6ee0 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 02:23:19 -0800 Subject: [PATCH 10/13] Revert "issue with de email template (lostpass_eml.tpl)" This reverts commit 3e8fa8c8a2cd125dd7aa0a9482e98ae39db61e52. --- view/de/lostpass_eml.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/de/lostpass_eml.tpl b/view/de/lostpass_eml.tpl index 18787d6e4..2175d2e5d 100644 --- a/view/de/lostpass_eml.tpl +++ b/view/de/lostpass_eml.tpl @@ -1,6 +1,6 @@ Hallo {{$username}}, - auf {{$sitename}} wurde eine Rücksetzung Deines Passwortes angefordert. + auf {{$sitename} wurde eine Rücksetzung Deines Passwortes angefordert. Bitte klicke auf den Link unten, um diese Anforderung zu bestätigen, oder kopiere den Link und füge ihn in die Adresszeile Deines Browsers ein. From db1998e0c8f3050c4d93c26a5af69773a55c17d2 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 14:22:52 -0800 Subject: [PATCH 11/13] limit the number of forums that can be tagged in a single post - default is 2. The reason is simple - count how many posts would be in transit simultaneously if this was unlimited and somebody tagged 40-50 forums. In practice when used legitimately - we've rarely seen more than two, in fact I don't recall seeing more than two ever. Typically it is one and occasionally two. Changing the default is tricky - a client system cannot do it, but the site hosting a forum can choose to. Since not all sites that host forums will choose to do so, the ordering of the mentions would then be important. --- include/items.php | 54 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/include/items.php b/include/items.php index 70802404a..756625d85 100755 --- a/include/items.php +++ b/include/items.php @@ -2852,12 +2852,27 @@ function tag_deliver($uid,$item_id) { if(preg_match($pattern,$body,$matches)) $tagged = true; - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; - if(preg_match($pattern,$body,$matches)) - $plustagged = true; + $pattern = '/@\!?\[zrl\=(.*?)\](.*?)\+\[\/zrl\]/'; + + if(preg_match_all($pattern,$body,$matches,PREG_SET_ORDER)) { + $max_forums = get_config('system','max_tagged_forums'); + if(! $max_forums) + $max_forums = 2; + $matched_forums = 0; + foreach($matches as $match) { + $matched_forums ++; + if($term['url'] === $match[1] && $term['term'] === $match[2]) { + if($matched_forums <= $max_forums) { + $plustagged = true; + break; + } + logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring'); + } + } + } if(! ($tagged || $plustagged)) { - logger('tag_deliver: mention was in a reshare - ignoring'); + logger('tag_deliver: mention was in a reshare or exceeded max_tagged_forums - ignoring'); return; } @@ -2974,6 +2989,7 @@ function tgroup_check($uid,$item) { } } + if($mention) { logger('tgroup_check: mention found for ' . $u[0]['channel_name']); } @@ -2982,6 +2998,7 @@ function tgroup_check($uid,$item) { // At this point we've determined that the person receiving this post was mentioned in it. // Now let's check if this mention was inside a reshare so we don't spam a forum + // note: $term has been set to the matching term $body = $item['body']; @@ -2993,13 +3010,34 @@ function tgroup_check($uid,$item) { $body = preg_replace('/\[share(.*?)\[\/share\]/','',$body); - $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; + +// $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; - if(! preg_match($pattern,$body,$matches)) { - logger('tgroup_check: mention was in a reshare - ignoring'); - return false; + $pattern = '/@\!?\[zrl\=(.*?)\](.*?)\+\[\/zrl\]/'; + + $found = false; + + if(preg_match_all($pattern,$body,$matches,PREG_SET_ORDER)) { + $max_forums = get_config('system','max_tagged_forums'); + if(! $max_forums) + $max_forums = 2; + $matched_forums = 0; + foreach($matches as $match) { + $matched_forums ++; + if($term['url'] === $match[1] && $term['term'] === $match[2]) { + if($matched_forums <= $max_forums) { + $found = true; + break; + } + logger('forum ' . $term['term'] . ' exceeded max_tagged_forums - ignoring'); + } + } } + if(! $found) { + logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring'); + return false; + } return true; From 2c02f1184cc576eaced4b72ae7ec6fd54c347ea7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 15:23:00 -0800 Subject: [PATCH 12/13] allow diaspora posts to be delivered to the discover channel unless prohibited from doing so. --- include/diaspora.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/diaspora.php b/include/diaspora.php index e494aac0f..655f5750a 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -15,8 +15,10 @@ function diaspora_dispatch_public($msg) { return; } - // find everybody following or allowing this author + $sys_disabled = get_config('system','disable_diaspora_discover_tab'); + $sys = (($sys_disabled) ? null : get_sys_channel()); + // find everybody following or allowing this author $r = q("SELECT * from channel where channel_id in ( SELECT abook_channel from abook left join xchan on abook_xchan = xchan_hash WHERE xchan_network like '%%diaspora%%' and xchan_addr = '%s' )", dbesc($msg['author']) @@ -29,6 +31,8 @@ function diaspora_dispatch_public($msg) { logger('diaspora_public: delivering to: ' . $rr['channel_name'] . ' (' . $rr['channel_address'] . ') '); diaspora_dispatch($rr,$msg); } + if($sys) + diaspora_dispatch($sys,$msg); } else logger('diaspora_public: no subscribers'); From 54fd8b21db2d8f3841cf590f88611a1d4f44ce48 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Jan 2015 15:27:58 -0800 Subject: [PATCH 13/13] make sure we honour the disable_discover_tab pref --- include/diaspora.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/diaspora.php b/include/diaspora.php index 655f5750a..767758164 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -15,7 +15,11 @@ function diaspora_dispatch_public($msg) { return; } - $sys_disabled = get_config('system','disable_diaspora_discover_tab'); + $sys_disabled = true; + + if(! get_config('system','disable_discover_tab')) { + $sys_disabled = get_config('system','disable_diaspora_discover_tab'); + } $sys = (($sys_disabled) ? null : get_sys_channel()); // find everybody following or allowing this author