From 02a36948685737afdbbb9a292a338b304bb5cc04 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 Aug 2013 19:51:58 -0700 Subject: fix superblock for comments --- include/ItemObject.php | 4 ++-- include/conversation.php | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 8c8c0ee2a..22b191e79 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -39,10 +39,10 @@ class Item extends BaseObject { foreach($data['children'] as $item) { /* - * Only add thos that will be displayed + * Only add those that will be displayed */ - if(! visible_activity($item)) { + if((! visible_activity($item)) || array_key_exists('author_blocked',$item)) { continue; } diff --git a/include/conversation.php b/include/conversation.php index aade06b8a..9dab5931b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -712,6 +712,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { $threads = array(); foreach($items as $item) { + // Check for any blocked authors + if($arr_blocked) { $blocked = false; foreach($arr_blocked as $b) { @@ -724,6 +726,18 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { continue; } + // Check all the kids too + + if($arr_blocked && $item['children']) { + for($d = 0; $d < count($item['children']); $d ++) { + foreach($arr_blocked as $b) { + if(($b) && ($item['children'][$d]['author_xchan'] == $b)) + $item['children'][$d]['author_blocked'] = true; + } + } + } + + // Can we put this after the visibility check? like_puller($a,$item,$alike,'like'); -- cgit v1.2.3 From 5083aa3cbd9434b7ec63cf5bbbc2122e3da49696 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 Aug 2013 17:34:04 -0700 Subject: implement premium channel discovery --- include/zot.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index bddbc9bee..ff69a119e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -441,6 +441,9 @@ function import_xchan($arr) { dbesc($xchan_hash) ); + if(! array_key_exists('connect_url', $arr)) + $arr['connect_url'] = ''; + if($r) { if($r[0]['xchan_photo_date'] != $arr['photo_updated']) @@ -462,18 +465,22 @@ function import_xchan($arr) { $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN; else $new_flags = $r[0]['xchan_flags']; - - + if(($r[0]['xchan_name_date'] != $arr['name_updated']) || ($r[0]['xchan_connurl'] != $arr['connections_url']) || ($r[0]['xchan_flags'] != $new_flags) || ($r[0]['xchan_addr'] != $arr['address']) + || ($r[0]['xchan_follow'] != $arr['follow_url']) + || ($r[0]['xchan_connpage'] != $arr['connect_url']) || ($r[0]['xchan_url'] != $arr['url'])) { - $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_flags = %d, + $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s', + xchan_connpage = '%s', xchan_flags = %d, xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s' limit 1", dbesc($arr['name']), dbesc($arr['name_updated']), dbesc($arr['connections_url']), + dbesc($arr['follow_url']), + dbesc($arr['connect_url']), intval($new_flags), dbesc($arr['address']), dbesc($arr['url']), @@ -503,8 +510,8 @@ function import_xchan($arr) { $new_flags = 0; $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, - xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags) - values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ", + xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags) + values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ", dbesc($xchan_hash), dbesc($arr['guid']), dbesc($arr['guid_sig']), @@ -514,6 +521,8 @@ function import_xchan($arr) { dbesc($arr['address']), dbesc($arr['url']), dbesc($arr['connections_url']), + dbesc($arr['follow_url']), + dbesc($arr['connect_url']), dbesc($arr['name']), dbesc('zot'), dbesc($arr['photo_updated']), -- cgit v1.2.3 From 6cea04eb440c2bb08bcb81ae13749c08d09b755c Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 Aug 2013 20:05:55 -0700 Subject: progress on generic sellpage - is not yet linked from existing connect buttons and editing has not been completed --- include/identity.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 5f210c456..1658669d6 100644 --- a/include/identity.php +++ b/include/identity.php @@ -182,7 +182,7 @@ function create_identity($arr) { $newuid = $ret['channel']['channel_id']; - $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_name, xchan_network, xchan_photo_date, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", dbesc($hash), dbesc($guid), dbesc($sig), @@ -192,6 +192,7 @@ function create_identity($arr) { dbesc($a->get_baseurl() . "/photo/profile/s/{$newuid}"), dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()), dbesc(z_root() . '/channel/' . $ret['channel']['channel_address']), + dbesc(z_root() . '/follow?f=&url=%s'), dbesc($ret['channel']['channel_name']), dbesc('zot'), dbesc(datetime_convert()), -- cgit v1.2.3 From 925b046794b77345c1321a3c74e4561d5c10ec95 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 Aug 2013 22:10:08 -0700 Subject: premium/restricted channel connections implemented, configure at yoursite/channel/nickname - this basically redirects "follow" requests to a premium channel's sell page if it has one configured. You can still click through and create a connection request (introduction), but this provides a means for the channel owner to state their terms. If you don't abide by the terms, you will likely be blocked or the channel deleted. This facility is extensible in a number of ways. --- include/Contact.php | 9 ++++++++- include/follow.php | 7 ++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index bf536ccd5..46d356f3f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -15,13 +15,20 @@ function rconnect_url($channel_id,$xchan) { if($r) return ''; + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($xchan) + ); + + if(($r) && ($r[0]['xchan_follow'])) + return $r[0]['xchan_follow']; + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) limit 1", dbesc($xchan), intval(HUBLOC_FLAGS_PRIMARY) ); if($r) - return $r[0]['hubloc_url']; + return $r[0]['hubloc_url'] . '/follow?f=&url=%s'; return ''; } diff --git a/include/follow.php b/include/follow.php index ce550b07f..510c6cd7e 100644 --- a/include/follow.php +++ b/include/follow.php @@ -11,7 +11,7 @@ require_once('include/zot.php'); -function new_contact($uid,$url,$channel,$interactive = false) { +function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) { $result = array('success' => false,'message' => ''); @@ -60,6 +60,11 @@ function new_contact($uid,$url,$channel,$interactive = false) { return $result; } + // Premium channel, set confirm before callback to avoid recursion + + if(array_key_exists('connect_url',$j) && (! $confirm)) + goaway($j['connect_url']); + // check service class limits -- cgit v1.2.3 From 22b6ddef9457e5ed3d38cf03be4b4451ec9d150c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Aug 2013 00:44:24 -0700 Subject: add zid to connect_url --- include/follow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/follow.php b/include/follow.php index 510c6cd7e..10bcddf2b 100644 --- a/include/follow.php +++ b/include/follow.php @@ -63,7 +63,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) // Premium channel, set confirm before callback to avoid recursion if(array_key_exists('connect_url',$j) && (! $confirm)) - goaway($j['connect_url']); + goaway(zid($j['connect_url'])); // check service class limits -- cgit v1.2.3 From af72f40759418275abae575176f43d27388bfcd6 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Aug 2013 01:00:54 -0700 Subject: make premium channels a feature --- include/features.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/features.php b/include/features.php index 757f719df..6272b33ea 100644 --- a/include/features.php +++ b/include/features.php @@ -27,8 +27,7 @@ function get_features() { //FIXME - needs a description, but how the hell do we explain this to normals? array('sendzid', t('Extended Identity Sharing'), t(' ')), array('expert', t('Expert Mode'), t('Enable Expert Mode to provide advanced configuration options')), - - + array('premium_channel', t('Premium Channel'), t('Allows you to set restrictions and terms on those that connect with your channel')), ), // Post composition -- cgit v1.2.3 From 32ff0932bf3b596e68ae7f4100bebbccdc1eae00 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Aug 2013 03:24:50 -0700 Subject: add detailed logging to public recips - find out why some public recipients are getting bypassed (David Benfells' problem with tagging groups, etc.) --- include/zot.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index ff69a119e..37d2a03bd 100644 --- a/include/zot.php +++ b/include/zot.php @@ -928,6 +928,8 @@ function public_recips($msg) { if(! $col) return NULL; + logger('__public_recips'); +dbg(1); if($msg['notify']['sender']['url'] === z_root()) $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) "; else @@ -945,6 +947,7 @@ function public_recips($msg) { if(! $x) $x = array(); +dbg(0); $r = array_merge($r,$x); logger('public_recips: ' . print_r($r,true), LOGGER_DATA); -- cgit v1.2.3 From 141c8ccb1f94b9ce80466aa6be178d97e3f290bf Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Aug 2013 05:50:15 -0700 Subject: possible fix for mention tags not posting to mentioned forum (when send stream permission is blocked) --- include/zot.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 37d2a03bd..c7049dee6 100644 --- a/include/zot.php +++ b/include/zot.php @@ -838,6 +838,7 @@ function zot_import($arr) { // and who are allowed to see them based on the sender's permissions $deliveries = allowed_public_recips($i); + } if(! $deliveries) { logger('zot_import: no deliveries on this site'); @@ -910,10 +911,12 @@ function zot_import($arr) { function public_recips($msg) { + $check_mentions = false; if($msg['message']['type'] === 'activity') { if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) { $col = 'channel_w_stream'; $field = PERMS_W_STREAM; + $check_mentions = true; } else { $col = 'channel_w_comment'; @@ -928,8 +931,7 @@ function public_recips($msg) { if(! $col) return NULL; - logger('__public_recips'); -dbg(1); + if($msg['notify']['sender']['url'] === z_root()) $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) "; else @@ -947,9 +949,29 @@ dbg(1); if(! $x) $x = array(); -dbg(0); $r = array_merge($r,$x); + + // look for any public mentions on this site + // They will get filtered by tgroup_check() so we don't need to check permissions now + + if($check_mentions && $msg['message']['tags']) { + if(is_array($msg['message']['tags']) && $msg['message']['tags']) { + foreach($msg['message']['tags'] as $tag) { + if(($tag['type'] === 'mention') && (strpos($tag['url'],z_root()) !== false)) { + $address = basename($tag['url']); + if($address) { + $z = q("select channel_hash as hash from channel where channel_address = '%s' limit 1", + dbesc($address) + ); + if($z) + $r = array_merge($r,$z); + } + } + } + } + } + logger('public_recips: ' . print_r($r,true), LOGGER_DATA); return $r; } -- cgit v1.2.3 From 99a9aee03e55af84f6963bbdbe3e365a7721e93d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Aug 2013 06:15:00 -0700 Subject: extra logging for translating likes in notification emails - which is still failing on occasion. --- include/conversation.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 9dab5931b..6e6ffef94 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -162,6 +162,9 @@ function localize_item(&$item){ $item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]'; } + else { + logger('localize_item like failed: link ' . $author_link . ' name ' . $author_name . ' url ' . $item_url); + } } -- cgit v1.2.3 From 754611738865eacba7f4acc235c03bad85dfa2c3 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 25 Aug 2013 20:11:49 -0700 Subject: Try to ensure full paths don't leak into xchan_addr and hubloc_addr --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index c7049dee6..051fa5078 100644 --- a/include/zot.php +++ b/include/zot.php @@ -138,7 +138,7 @@ function zot_finger($webbie,$channel) { $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where xchan_addr = '%s' and (hubloc_flags & %d) limit 1", - dbesc($xchan_address), + dbesc($xchan_addr), intval(HUBLOC_FLAGS_PRIMARY) ); -- cgit v1.2.3 From e9125ce06534736290e461508b5f5092ca73b02d Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 25 Aug 2013 20:17:45 -0700 Subject: try to fix bad addresses that got into the network --- include/zot.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 051fa5078..be5b0d9c0 100644 --- a/include/zot.php +++ b/include/zot.php @@ -444,6 +444,8 @@ function import_xchan($arr) { if(! array_key_exists('connect_url', $arr)) $arr['connect_url'] = ''; + if(strpos($arr['address'],'/') !== false) + $arr['address'] = substr($arr['address'],0,strpos($arr['address'],'/')); if($r) { if($r[0]['xchan_photo_date'] != $arr['photo_updated']) @@ -466,6 +468,7 @@ function import_xchan($arr) { else $new_flags = $r[0]['xchan_flags']; + if(($r[0]['xchan_name_date'] != $arr['name_updated']) || ($r[0]['xchan_connurl'] != $arr['connections_url']) || ($r[0]['xchan_flags'] != $new_flags) -- cgit v1.2.3 From 2f2a316b27221759d433a786fb3485238f032a37 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Aug 2013 03:54:27 -0700 Subject: regex patch --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index a0a53a310..9f9489893 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -271,7 +271,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $urlchars = '[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]'; if (strpos($Text,'http') !== false) { - $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); + $Text = preg_replace("/([^\"\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); } if (strpos($Text,'[/share]') !== false) { $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text); -- cgit v1.2.3 From 7a8363c328d69b53a0c949bc2d8a047d2536d911 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Aug 2013 17:06:19 -0700 Subject: more cleanup from the mess yesterday - you might have a look for xchan_addr and hubloc_addr with slashes in them and fix them - especially getting rid of ip addresses and the /channel/xyz in the addr fields --- include/zot.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index be5b0d9c0..b74892b19 100644 --- a/include/zot.php +++ b/include/zot.php @@ -606,6 +606,9 @@ function import_xchan($arr) { continue; } + if(strpos($location['address'],'/') !== false) + $location['address'] = substr($location['address'],0,strpos($location['address'],'/')); + // new hub claiming to be primary. Make it so. if(intval($location['primary'])) { -- cgit v1.2.3 From 2e72b136c558652ca9a9b755b29cdb99ee27ee7f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Aug 2013 17:48:05 -0700 Subject: fix profile change activity where the change is a solitary url - and includes a stray right quote --- include/activities.php | 2 ++ include/bbcode.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/activities.php b/include/activities.php index 10a01792f..7ef26abeb 100644 --- a/include/activities.php +++ b/include/activities.php @@ -45,6 +45,8 @@ function profile_activity($changed, $value) { $prof = '[url=' . z_root() . '/profile/' . $self['channel_address'] . ']' . t('public profile') . '[/url]'; if($t == 1 && strlen($value)) { + // if it's a url, the HTML quotes will mess it up, so link it and don't try and zidify it because we don't know what it points to. + $value = linkify($value); $message = sprintf( t('%1$s changed %2$s to “%3$s”'), $A, $changes, $value); $message .= "\n\n" . sprintf( t('Visit %1$s\'s %2$s'), $A, $prof); } diff --git a/include/bbcode.php b/include/bbcode.php index 9f9489893..a0a53a310 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -271,7 +271,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $urlchars = '[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]'; if (strpos($Text,'http') !== false) { - $Text = preg_replace("/([^\"\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); + $Text = preg_replace("/([^\]\='".'"'."]|^)(https?\:\/\/$urlchars+)/ism", '$1$2', $Text); } if (strpos($Text,'[/share]') !== false) { $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text); -- cgit v1.2.3 From 31b934eb5e65abc0181918cb21b8e51390966a3d Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Aug 2013 20:58:07 -0700 Subject: clone sync was trying to update xchan info in the abook loop. --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index b74892b19..beff1b139 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1715,7 +1715,7 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) { $clean = array(); foreach($arr['abook'] as $abook) { foreach($abook as $k => $v) { - if(in_array($k,$disallowed)) + if(in_array($k,$disallowed) || (strpos($k,'abook') !== 0)) continue; $clean[$k] = $v; } -- cgit v1.2.3 From 6a2cb837afc41dfe2e535164edb1865d4b0278a4 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 02:27:36 -0700 Subject: get rid of ssl_policy - it's implicit in the site url --- include/items.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 10bdcb38f..c695a9b72 100755 --- a/include/items.php +++ b/include/items.php @@ -2320,21 +2320,21 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $ssl_val = intval(get_config('system','ssl_policy')); - $ssl_policy = ''; - - switch($ssl_val){ - case SSL_POLICY_FULL: - $ssl_policy = 'full'; - break; - case SSL_POLICY_SELFSIGN: - $ssl_policy = 'self'; - break; - case SSL_POLICY_NONE: - default: - $ssl_policy = 'none'; - break; - } +// $ssl_val = intval(get_config('system','ssl_policy')); +// $ssl_policy = ''; + +// switch($ssl_val){ +// case SSL_POLICY_FULL: +// $ssl_policy = 'full'; +// break; +// case SSL_POLICY_SELFSIGN: +// $ssl_policy = 'self'; +// break; +// case SSL_POLICY_NONE: +// default: +// $ssl_policy = 'none'; +// break; +// } $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); @@ -2423,7 +2423,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { $postvars['perm'] = 'r'; } - $postvars['ssl_policy'] = $ssl_policy; +// $postvars['ssl_policy'] = $ssl_policy; if($page) $postvars['page'] = $page; -- cgit v1.2.3 From c6e527f6fec7f3a5350f8cf794decfd35cea134a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 05:02:40 -0700 Subject: when using the bbcode mimetype a space is just a space. A return is a return. But as opposed to HTML, two spaces are now non-breaking. A tab (assuming you can figure out how to enter one in a text field) is now four non-breaking spaces. This should let us insert code snippets with much more readable indentation. --- include/bbcode.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index a0a53a310..4647b8567 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -259,6 +259,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $Text = str_replace(array("\n","\r"), array('',''),$Text); + $Text = str_replace(array("\t"," "),array("    ","  "),$Text); // Set up the parameters for a URL search string $URLSearchString = "^\[\]"; -- cgit v1.2.3 From c8e27b54ecbbe2e22919d51d8d6f646977a8452c Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 17:08:59 -0700 Subject: update hubloc_timestamps --- include/zot.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index beff1b139..49f58c3bd 100644 --- a/include/zot.php +++ b/include/zot.php @@ -589,10 +589,16 @@ function import_xchan($arr) { ); if($r) { logger('import_xchan: hub exists: ' . $location['url']); + // update connection timestamp + q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d limit 1", + dbesc(datetime_convert()), + intval($r[0]['hubloc_id']) + ); if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) { - $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1", + $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_id = %d limit 1", intval(HUBLOC_FLAGS_PRIMARY), + dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); update_modtime($xchan_hash); @@ -612,15 +618,16 @@ function import_xchan($arr) { // new hub claiming to be primary. Make it so. if(intval($location['primary'])) { - $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_hash = '%s' and (hubloc_flags & %d )", + $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_hash = '%s' and (hubloc_flags & %d )", intval(HUBLOC_FLAGS_PRIMARY), + dbesc(datetime_convert()), dbesc($xchan_hash), intval(HUBLOC_FLAGS_PRIMARY) ); } logger('import_xchan: new hub: ' . $location['url']); - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey) - values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s')", + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected) + values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s','%s','%s')", dbesc($arr['guid']), dbesc($arr['guid_sig']), dbesc($xchan_hash), @@ -630,7 +637,9 @@ function import_xchan($arr) { dbesc($location['url_sig']), dbesc($location['host']), dbesc($location['callback']), - dbesc($location['sitekey']) + dbesc($location['sitekey']), + dbesc(datetime_convert()), + dbesc(datetime_convert()) ); update_modtime($xchan_hash); $changed = true; -- cgit v1.2.3 From b77eaebb3a424247ca3fc7bef5c79b775a2db0e2 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 17:19:52 -0700 Subject: force webbies to lowercase --- include/identity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 1658669d6..8db6355c0 100644 --- a/include/identity.php +++ b/include/identity.php @@ -81,7 +81,7 @@ function create_identity($arr) { return $ret; } - $nick = trim($arr['nickname']); + $nick = mb_strtolower(trim($arr['nickname'])); $name = escape_tags($arr['name']); $pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL); -- cgit v1.2.3 From 390a1ce552d57fe5eea6bc2ed43ea0b8bb07c77b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 18:40:33 -0700 Subject: more loose ends --- include/conversation.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 6e6ffef94..f6a5b90da 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -93,7 +93,10 @@ function localize_item(&$item){ if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ - $obj = json_decode_plus($item['object']); + if(is_array($item['object'])) + $obj = $item['object']; + else + $obj = json_decode_plus($item['object']); if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); -- cgit v1.2.3 From 7bb92899218a2a0de261d3caeed1d723a508cc13 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 21:06:11 -0700 Subject: Preparatory work for photo conversations (third time). Also take away unused "post new activity" preferences until they actually do something. --- include/conversation.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index f6a5b90da..bd1e12c4e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -93,10 +93,7 @@ function localize_item(&$item){ if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ - if(is_array($item['object'])) - $obj = $item['object']; - else - $obj = json_decode_plus($item['object']); + $obj = json_decode_plus($item['object']); if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); @@ -397,6 +394,7 @@ function visible_activity($item) { function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { $tstart = dba_timer(); + $content_html = ''; require_once('bbcode.php'); @@ -494,10 +492,16 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { } - else if($mode === 'search') { + elseif($mode === 'search') { $live_update_div = '' . "\r\n"; } - + elseif($mode === 'photos') { + $profile_onwer = $a->profile['profile_uid']; + $page_writeable = ($profile_owner == local_user()); + $live_update_div = '
' . "\r\n"; + // for photos we've already formatted the top-level item (the photo) + $content_html = $a->data['photo_html']; + } $page_dropping = ((local_user() && local_user() == $profile_owner) ? true : false); @@ -801,8 +805,9 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { // logger('nouveau: ' . print_r($threads,true)); - $o = replace_macros($page_template, array( + $o .= replace_macros($page_template, array( '$baseurl' => $a->get_baseurl($ssl_state), + '$photo_item' => $content_html, '$live_update' => $live_update_div, '$remove' => t('remove'), '$mode' => $mode, -- cgit v1.2.3 From e8cd3b70407b4c33d82d21cc3a470b2a58852e4f Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Aug 2013 22:30:06 -0700 Subject: bring back mail list and cleanup some issues which popped out with full PHP warnings --- include/contact_widgets.php | 4 ++-- include/dba/dba_mysqli.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index ca212796f..e5f778e49 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -70,11 +70,11 @@ function fileas_widget($baseurl,$selected = '') { function categories_widget($baseurl,$selected = '') { + $a = get_app(); + if(! feature_enabled($a->profile['profile_uid'],'categories')) return ''; - $a = get_app(); - $terms = array(); $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", intval($a->profile['profile_uid']), diff --git a/include/dba/dba_mysqli.php b/include/dba/dba_mysqli.php index f1a50cc3f..19907705b 100755 --- a/include/dba/dba_mysqli.php +++ b/include/dba/dba_mysqli.php @@ -70,7 +70,7 @@ class dba_mysqli extends dba_driver { function close() { if($this->db) $this->db->close(); - $this->connected = flase; + $this->connected = false; } } \ No newline at end of file -- cgit v1.2.3 From 95fcf773be12a9307eeefe7f392277bf44036946 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Aug 2013 16:39:43 -0700 Subject: right - here's how we're going to link comanche with webpages --- include/comanche.php | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 include/comanche.php (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php new file mode 100644 index 000000000..33e93d2c9 --- /dev/null +++ b/include/comanche.php @@ -0,0 +1,48 @@ + $uid, 'current' => $current, 'entries' => $r); + call_hooks('pdl_selector',$arr); + + $entries = $arr['entries']; + $current = $arr['current']; + + $o .= "'; + return $o; +} + -- cgit v1.2.3 From c877d8f9fae246812930c2f2c45db40a52b09366 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Aug 2013 17:57:45 -0700 Subject: It's a wretched mess, but at least photo comments show up again when viewing the photo. This is just temporary until these conversations are merged into the common conversation viewer, so it's not worth spending a lot of time cleaning up the remnants. --- include/conversation.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index bd1e12c4e..8648209e9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1150,6 +1150,7 @@ function conv_sort($arr,$order) { elseif(stristr($order,'ascending')) usort($parents,'sort_thr_created_rev'); + if(count($parents)) foreach($parents as $i=>$_x) $parents[$i]['children'] = get_item_children($arr, $_x); -- cgit v1.2.3 From 03e1a0cc152ec8ea8fccefa746686d05758c7f5b Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Aug 2013 20:03:01 -0700 Subject: really truly bare-bones comanche --- include/comanche.php | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/menu.php | 1 + 2 files changed, 59 insertions(+) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 33e93d2c9..21182175e 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -46,3 +46,61 @@ function pdl_selector($uid,$current="") { return $o; } + + +function comanche_parser(&$a,$s) { + + + $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $matches, $s); + if($cnt) + $a->page['template'] = trim($matches[1]); + + $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $matches, $s); + if($cnt) + $a->layout['theme'] = trim($matches[1]); + + $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $matches, $s, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); + } + } + +} + + +function comanche_menu($name) { + $a = get_app(); + $m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash()); + return render_menu($m); +} + +function comanche_widget($name) { + $a = get_app(); + // placeholder for now + $m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash()); + return render_menu($m); +} + + +function comanche_region(&$a,$s) { + + + $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $matches, $s, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s); + } + } + + // need to modify this to accept parameters + + $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $matches, $s, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s); + } + } + + return $s; +} \ No newline at end of file diff --git a/include/menu.php b/include/menu.php index 8d4664385..6d614055a 100644 --- a/include/menu.php +++ b/include/menu.php @@ -40,6 +40,7 @@ function menu_render($menu) { } + function menu_fetch_id($menu_id,$channel_id) { $r = q("select * from menu where menu_id = %d and menu_channel_id = %d limit 1", -- cgit v1.2.3 From b4bd518e4032661cdfba4e17acdb94e19b23fdd2 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 Aug 2013 21:56:01 -0700 Subject: silence some warnings at php E_ALL levels --- include/conversation.php | 2 ++ include/friendica_smarty.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 8648209e9..82010b153 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -394,7 +394,9 @@ function visible_activity($item) { function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { $tstart = dba_timer(); + $t0 = $t1 = $t2 = $t3 = $t4 = $t5 = $t6 = null; $content_html = ''; + $o = ''; require_once('bbcode.php'); diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php index 1e8ef5406..12a789c9a 100755 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -49,7 +49,7 @@ class FriendicaSmartyEngine implements ITemplateEngine { public function __construct(){ $a = get_app(); - $basecompiledir = $a->config['system']['smarty3_folder']; + $basecompiledir = ((array_key_exists('smarty3_folder',$a->config['system'])) ? $a->config['system']['smarty3_folder'] : ''); if (!$basecompiledir) $basecompiledir = dirname(__dir__)."/view/tpl/smarty3"; if (!is_dir($basecompiledir)) { echo "ERROR: folder $basecompiledir does not exist."; killme(); -- cgit v1.2.3 From 85e291f5357bc28b108378816af97b545aacca3f Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 Aug 2013 18:17:15 -0700 Subject: figure out why poller isn't picking up old posts which failed to deliver --- include/onepoll.php | 9 +++++---- include/poller.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/onepoll.php b/include/onepoll.php index a225edfd8..50c2566be 100644 --- a/include/onepoll.php +++ b/include/onepoll.php @@ -69,7 +69,7 @@ function onepoll_run($argv, $argc){ $last_update = (($contact['abook_updated'] === '0000-00-00 00:00:00') ? datetime_convert('UTC','UTC','now - 7 days') - : datetime_convert('UTC','UTC',$contact['abook_updated']) + : datetime_convert('UTC','UTC',$contact['abook_updated'] . ' - 2 days') ); // update permissions @@ -98,11 +98,12 @@ function onepoll_run($argv, $argc){ return; if($contact['xchan_connurl']) { - $feedurl = str_replace('/poco/','/zotfeed/',$channel['xchan_connurl']); - - $x = z_fetch_url($feedurl . '?f=$mindate=' . $last_update); + $feedurl = str_replace('/poco/','/zotfeed/',$channel['xchan_connurl']); + $x = z_fetch_url($feedurl . '?f=&mindate=' . $last_update); if($x['success']) { $total = 0; + logger('onepoll: feed update ' . $contact['xchan_name']); + $j = json_decode($x['body'],true); if($j['success'] && $j['messages']) { foreach($j['messages'] as $message) { diff --git a/include/poller.php b/include/poller.php index 7a6aaeb22..bdb0388ac 100644 --- a/include/poller.php +++ b/include/poller.php @@ -224,7 +224,7 @@ function poller_run($argv, $argc){ $update = true; } } -dbg(0); + if((! $update) && (! $force)) continue; -- cgit v1.2.3 From 74582630177b104f35113cee77d2c7ac5f74f412 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 Aug 2013 20:54:42 -0700 Subject: I've got a pretty good idea of how to bootstrap, parse and render Comanche now. This does not mean it's close to being presentable - far from it. --- include/comanche.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 21182175e..cf7ecd7c5 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -75,11 +75,21 @@ function comanche_menu($name) { return render_menu($m); } -function comanche_widget($name) { +function comanche_replace_region($match) { $a = get_app(); - // placeholder for now - $m = menu_fetch($name,$a->profile['profile_uid'],get_observer_hash()); - return render_menu($m); + if(array_key_exists($match[1],$a->page)) + return $a->page[$match[1]]; +} + +// Widgets will have to get any operational arguments from the session, +// the global app environment, or config storage until we implement argument passing + + +function comanche_widget($name,$args = null) { + $a = get_app(); + $func = 'widget_' . trim($name); + if(function_exists($func)) + return $func($args); } @@ -103,4 +113,11 @@ function comanche_region(&$a,$s) { } return $s; -} \ No newline at end of file +} + + +function widget_profile($args) { + $a = get_app(); + $block = (((get_config('system','block_public')) && (! local_user()) && (! remote_user())) ? true : false); + return profile_sidebar($a->profile, $block, true); +} -- cgit v1.2.3 From d43a7659854c4bb6052c05a932b257883ea72748 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Aug 2013 04:19:26 -0700 Subject: more debugging on localize_item top find out why likes are not translated in notifications, but are in displayed posts (using 'new' on matrix page) - in one case we're successfully pulling stuff from item['object'] and in the other we aren't - and it's the same object. --- include/conversation.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 82010b153..2157f8291 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -92,8 +92,14 @@ function item_redir_and_replace_images($body, $images, $cid) { function localize_item(&$item){ if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)){ - + + if(! $item['object']) + return; + $obj = json_decode_plus($item['object']); + if((! $obj) && ($item['object'])) { + logger('localize_item: failed to decode object: ' . print_r($item['object'],true)); + } if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); -- cgit v1.2.3 From 02fe2d488155b0907c950eb3118c523940c6827f Mon Sep 17 00:00:00 2001 From: Christian Vogeley Date: Sat, 31 Aug 2013 18:20:34 +0200 Subject: More mobile theme fixes If user is logged in personal settings are used else use admin settings. Only show toggle link if there is something to switch between. --- include/auth.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index 143a16de8..d04ebbe43 100644 --- a/include/auth.php +++ b/include/auth.php @@ -15,6 +15,7 @@ function nuke_session() { unset($_SESSION['cid']); unset($_SESSION['theme']); unset($_SESSION['mobile_theme']); + unset($_SESSION['show_mobile']); unset($_SESSION['page_flags']); unset($_SESSION['submanage']); unset($_SESSION['my_url']); -- cgit v1.2.3 From a1906482dc3323f747744a1447aace78b494ddbd Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Sep 2013 18:36:14 -0700 Subject: rework the pdl_selector a bit since we've slightly changed the way layouts are stored. --- include/comanche.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index cf7ecd7c5..bdce0c5e2 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -17,16 +17,10 @@ function pdl_selector($uid,$current="") { $o = ''; - // You can use anybody's Comanche layouts on this site that haven't been protected in some way - $sql_extra = item_permissions_sql($uid); - // By default order by title (therefore at this time pdl's need a unique title across this system), - // though future work may allow categorisation - // based on taxonomy terms - - $r = q("select title, mid from item where (item_restrict & %d) $sql_extra order by title", - intval(ITEM_PDL) + $r = q("select item_id.*, mid from item_id left join item on iid = item.id where item_id.uid = %d and item_id.uid = item.uid and service = 'PDL' order by sid asc", + intval($owner) ); $arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r); @@ -39,7 +33,7 @@ function pdl_selector($uid,$current="") { $entries[] = array('title' => t('Default'), 'mid' => ''); foreach($entries as $selection) { $selected = (($selection == $current) ? ' selected="selected" ' : ''); - $o .= ""; + $o .= ""; } $o .= ''; -- cgit v1.2.3 From caa148c1e3736b6d51327883b04405b00a4cda0b Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Sep 2013 19:15:08 -0700 Subject: Sheesh. Three lines of Javascript. All you have to do is find which of the three lines is doing something wrong. Or FILE A BUG. Or use a different browser (not *try* a different browser, *use* a different browser), or turn off freaking tinymce. But no - let's argue about browsers instead. --- include/items.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index c695a9b72..712c416de 100755 --- a/include/items.php +++ b/include/items.php @@ -1361,6 +1361,17 @@ function item_store($arr,$allow_exec = false) { return 0; } + // If a page layout is provided, ensure it exists and belongs to us. + + if(array_key_exists('layout_mid',$arr) && $arr['layout_mid']) { + $l = q("select item_restrict from item where mid = '%s' and uid = %d limit 1", + dbesc($arr['layout_mid']), + intval($arr['uid']) + ); + if((! $l) || (! ($l[0]['item_restrict'] & ITEM_PDL))) + unset($arr['layout_mid']); + } + // Don't let anybody set these, either intentionally or accidentally if(array_key_exists('id',$arr)) -- cgit v1.2.3 From a35d440ff1fee806a8aa17a0297e1163db6a3ba5 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Sep 2013 20:11:04 -0700 Subject: Add Comanche layouts to the things that don't go offsite. --- include/notifier.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 2a0301357..5dcd7b58c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -257,6 +257,10 @@ function notifier_run($argv, $argc){ return; } + if($target_item['item_restrict'] & ITEM_PDL) { + logger('notifier: target item ITEM_PDL', LOGGER_DEBUG); + return; + } $s = q("select * from channel where channel_id = %d limit 1", intval($target_item['uid']) -- cgit v1.2.3 From 8b7757e033c4483da24700722c186057bb431164 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 01:38:17 -0700 Subject: webpage content-type -- needs cleaning up and a security check once all the important bits are in place. --- include/conversation.php | 8 +++++++ include/items.php | 10 +++----- include/text.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 2157f8291..a357e1480 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1009,9 +1009,16 @@ function status_editor($a,$x,$popup=false) { $geotag = (($x['allow_location']) ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''); $plaintext = true; + if(feature_enabled(local_user(),'richtext')) $plaintext = false; + if(intval($x['plaintext'])) + $plaintext = true; + + if(intval($x['mimeselect'])) + $mimeselect = mimetype_select($x['profile_uid']); + $tpl = get_markup_template('jot-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( @@ -1079,6 +1086,7 @@ function status_editor($a,$x,$popup=false) { '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], + '$mimeselect' => $mimeselect, '$showacl' => ((array_key_exists('showacl',$x)) ? $x['showacl'] : 'yes'), '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], diff --git a/include/items.php b/include/items.php index 712c416de..66172ade3 100755 --- a/include/items.php +++ b/include/items.php @@ -1397,14 +1397,10 @@ function item_store($arr,$allow_exec = false) { $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 ); $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 ); - // this is a bit messy - we really need an input filter chain that temporarily undoes obscuring - if($arr['mimetype'] != 'text/html' && $arr['mimetype'] != 'application/x-php') { - if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) - $arr['body'] = escape_tags($arr['body']); - if((strpos($arr['title'],'<') !== false) || (strpos($arr['title'],'>') !== false)) - $arr['title'] = escape_tags($arr['title']); - } + $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']); + $arr['title'] = escape_tags($arr['title']); + // only detect language if we have text content, and if the post is private but not yet // obscured, make it so. diff --git a/include/text.php b/include/text.php index 99d5c9d78..606ef421c 100755 --- a/include/text.php +++ b/include/text.php @@ -81,6 +81,34 @@ function escape_tags($string) { } +function z_input_filter($channel_id,$s,$type = 'text/bbcode') { + + if($type === 'text/bbcode') + return escape_tags($s); + if($type === 'text/markdown') + return escape_tags($s); + if($type == 'text/plain') + return escape_tags($s); + $r = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", + intval($channel_id) + ); + if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWEXEC)) { + if(local_user() && (get_account_id() == $r[0]['account_id'])) { + return $s; + } + } + + if($type === 'text/html') + return purify_html($s); + + return escape_tags($s); + +} + + + + + function purify_html($s) { require_once('library/HTMLPurifier.auto.php'); require_once('include/html2bbcode.php'); @@ -1127,6 +1155,7 @@ function prepare_body(&$item,$attach = false) { function prepare_text($text,$content_type = 'text/bbcode') { + switch($content_type) { case 'text/plain': @@ -1291,6 +1320,37 @@ function unamp($s) { } +function mimetype_select($channel_id, $current = 'text/bbcode') { + + $x = array( + 'text/bbcode', + 'text/html', + 'text/markdown', + 'text/plain' + ); + + $r = q("select account_flags from account left join channel on account_id = channel_account_id where + channel_id = %d limit 1", + intval($channel_id) + ); + + if($r) { + if($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) { + $x[] = 'application/x-php'; + } + } + + $o = t('Page content type: '); + $o .= ''; + + return $o; + +} -- cgit v1.2.3 From f44274bfca6137795ee878a076d5aeed0b330f64 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 13:31:59 -0700 Subject: allow a channel owner to define a default mimetype on webpages (otherwise default to "choose") - also fix the selector w/r/t php code. There is no ui for setting either at the moment, but for instance with wiki pages we probably don't want to have multiple choice of the mimetype. Keep it simple. --- include/conversation.php | 10 ++++++++-- include/text.php | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index a357e1480..31bfdbef9 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1016,8 +1016,14 @@ function status_editor($a,$x,$popup=false) { if(intval($x['plaintext'])) $plaintext = true; - if(intval($x['mimeselect'])) - $mimeselect = mimetype_select($x['profile_uid']); + $mimeselct = ''; + if(array_key_exists('mimetype',$x) && $x['mimetype']) { + if($x['mimetype'] === 'choose') + $mimeselect = mimetype_select($x['profile_uid']); + else + $mimeselect = ''; + } + $tpl = get_markup_template('jot-header.tpl'); diff --git a/include/text.php b/include/text.php index 606ef421c..71374f1f9 100755 --- a/include/text.php +++ b/include/text.php @@ -1329,14 +1329,15 @@ function mimetype_select($channel_id, $current = 'text/bbcode') { 'text/plain' ); - $r = q("select account_flags from account left join channel on account_id = channel_account_id where + $r = q("select account_id, account_roles from account left join channel on account_id = channel_account_id where channel_id = %d limit 1", intval($channel_id) ); if($r) { if($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) { - $x[] = 'application/x-php'; + if(local_user() && get_account_id() == $r[0]['account_id']) + $x[] = 'application/x-php'; } } -- cgit v1.2.3 From 5f2a7573d5423e82b3a73ca91a4e72a56dab1a14 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 13:39:13 -0700 Subject: only allow richtext editor on pages if bbcode is the default mimetype, otherwise use plaintext editor. This will eventually need work to support a visual editor for html or other types. --- include/conversation.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 31bfdbef9..c40691bba 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1013,17 +1013,17 @@ function status_editor($a,$x,$popup=false) { if(feature_enabled(local_user(),'richtext')) $plaintext = false; - if(intval($x['plaintext'])) - $plaintext = true; - $mimeselct = ''; if(array_key_exists('mimetype',$x) && $x['mimetype']) { - if($x['mimetype'] === 'choose') + if($x['mimetype'] != 'text/bbcode') + $plaintext = true; + if($x['mimetype'] === 'choose') { $mimeselect = mimetype_select($x['profile_uid']); + } else - $mimeselect = ''; + $mimeselect = ''; } - + $tpl = get_markup_template('jot-header.tpl'); -- cgit v1.2.3 From 7c775db9d6b9dc68bc05cded7ab93357aeeb9c3f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 16:01:29 -0700 Subject: fix webpage storage --- include/conversation.php | 2 +- include/text.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index c40691bba..8cee4f34f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1055,7 +1055,7 @@ function status_editor($a,$x,$popup=false) { '$return_path' => $a->query_string, '$action' => $a->get_baseurl(true) . '/item', '$share' => (x($x,'button') ? $x['button'] : t('Share')), - '$webpage' => (x($x,'webpage') ? '1' : ''), + '$webpage' => (x($x,'webpage') ? $x['webpage'] : ''), '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => (x($x,'pagetitle') ? $x['pagetitle'] : ''), '$upload' => t('Upload photo'), diff --git a/include/text.php b/include/text.php index 71374f1f9..b0b519851 100755 --- a/include/text.php +++ b/include/text.php @@ -92,7 +92,7 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') { $r = q("select account_id, account_roles from account left join channel on channel_account_id = account_id where channel_id = %d limit 1", intval($channel_id) ); - if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWEXEC)) { + if($r && ($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE)) { if(local_user() && (get_account_id() == $r[0]['account_id'])) { return $s; } -- cgit v1.2.3 From 56e408f4679862a0d7d9d8fa46a1875f2cbf3574 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 16:29:52 -0700 Subject: pass execflag - Working for preview but not yet executing on page render --- include/text.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index b0b519851..53471f460 100755 --- a/include/text.php +++ b/include/text.php @@ -1199,6 +1199,7 @@ function prepare_text($text,$content_type = 'text/bbcode') { $s = zidify_links($s); break; } +//logger('prepare: ' . $s); return $s; } -- cgit v1.2.3 From dfa2efcecf976783c4fa06f4301a851eca8e97c6 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 16:37:54 -0700 Subject: oh that's why --- include/conversation.php | 3 ++- include/text.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 8cee4f34f..299cc1431 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1248,12 +1248,13 @@ function render_location_default($item) { function prepare_page($item) { + return replace_macros(get_markup_template('page_display.tpl'),array( '$author' => $item['author']['xchan_name'], '$auth_url' => $item['author']['xchan_url'], '$date' => datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i'), '$title' => smilies(bbcode($item['title'])), - '$body' => smilies(bbcode($item['body'])) + '$body' => prepare_text($item['body'],$item['mimetype']) )); } diff --git a/include/text.php b/include/text.php index 53471f460..bbd538f15 100755 --- a/include/text.php +++ b/include/text.php @@ -1199,7 +1199,8 @@ function prepare_text($text,$content_type = 'text/bbcode') { $s = zidify_links($s); break; } -//logger('prepare: ' . $s); + +//logger('prepare_text: ' . $s); return $s; } -- cgit v1.2.3 From a32d86f0a07e244faeb3fde36c002d9657b3552d Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 17:48:48 -0700 Subject: preserve mimetype on page edits --- include/conversation.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 299cc1431..43de9fc8d 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1013,7 +1013,7 @@ function status_editor($a,$x,$popup=false) { if(feature_enabled(local_user(),'richtext')) $plaintext = false; - $mimeselct = ''; + $mimeselect = ''; if(array_key_exists('mimetype',$x) && $x['mimetype']) { if($x['mimetype'] != 'text/bbcode') $plaintext = true; @@ -1021,9 +1021,10 @@ function status_editor($a,$x,$popup=false) { $mimeselect = mimetype_select($x['profile_uid']); } else - $mimeselect = ''; + $mimeselect = ''; } + $webpage = ((x($x,'webpage')) ? $x['webpage'] : ''); $tpl = get_markup_template('jot-header.tpl'); @@ -1055,7 +1056,7 @@ function status_editor($a,$x,$popup=false) { '$return_path' => $a->query_string, '$action' => $a->get_baseurl(true) . '/item', '$share' => (x($x,'button') ? $x['button'] : t('Share')), - '$webpage' => (x($x,'webpage') ? $x['webpage'] : ''), + '$webpage' => $webpage, '$placeholdpagetitle' => t('Page link title'), '$pagetitle' => (x($x,'pagetitle') ? $x['pagetitle'] : ''), '$upload' => t('Upload photo'), @@ -1074,7 +1075,7 @@ function status_editor($a,$x,$popup=false) { '$shortnoloc' => t('clear location'), '$title' => "", '$placeholdertitle' => t('Set title'), - '$catsenabled' => ((feature_enabled($x['profile_uid'],'categories')) ? 'categories' : ''), + '$catsenabled' => ((feature_enabled($x['profile_uid'],'categories') && (! $webpage)) ? 'categories' : ''), '$category' => "", '$placeholdercategory' => t('Categories (comma-separated list)'), '$wait' => t('Please wait'), -- cgit v1.2.3 From 1a7bb1fb75084fbcd4d81c8c24820631e3df4d64 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 19:40:21 -0700 Subject: The triple linebreaks in notification emails finally bothered me enough to do something about it. --- include/enotify.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index a15e42b73..b2a4f5856 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -379,11 +379,9 @@ function notification($params) { logger('notification: sending notification email'); - $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r", "\\n"), "\n", - $body))),ENT_QUOTES,'UTF-8')); + $textversion = strip_tags(html_entity_decode(bbcode(stripslashes(str_replace(array("\\r", "\\n"), array( "", "\n"), $body))),ENT_QUOTES,'UTF-8')); - $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r\\n", "\\r","\\n\\n" ,"\\n"), - "
\n",$body))), ENT_QUOTES,'UTF-8'); + $htmlversion = html_entity_decode(bbcode(stripslashes(str_replace(array("\\r","\\n"), array("","
\n"),$body))), ENT_QUOTES,'UTF-8'); // use $_SESSION['zid_override'] to force zid() to use -- cgit v1.2.3 From 615bf237330519f0d21fccfe6a8f69b5bb4c0f69 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Sep 2013 20:25:33 -0700 Subject: add a layout selector --- include/conversation.php | 12 ++++++++++++ include/text.php | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 43de9fc8d..45a744dd8 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1023,7 +1023,18 @@ function status_editor($a,$x,$popup=false) { else $mimeselect = ''; } + + $layoutselect = ''; + if(array_key_exists('layout',$x) && $x['layout']) { + if($x['layout'] === 'choose') { + $layoutselect = layout_select($x['profile_uid']); + } + else + $layoutselect = ''; + } + + $webpage = ((x($x,'webpage')) ? $x['webpage'] : ''); $tpl = get_markup_template('jot-header.tpl'); @@ -1094,6 +1105,7 @@ function status_editor($a,$x,$popup=false) { '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$mimeselect' => $mimeselect, + '$layoutselect' => $layoutselect, '$showacl' => ((array_key_exists('showacl',$x)) ? $x['showacl'] : 'yes'), '$bang' => $x['bang'], '$profile_uid' => $x['profile_uid'], diff --git a/include/text.php b/include/text.php index bbd538f15..004efc08d 100755 --- a/include/text.php +++ b/include/text.php @@ -1321,6 +1321,29 @@ function unamp($s) { return str_replace('&', '&', $s); } +function layout_select($channel_id, $current = '') { + $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and (item_restrict & %d)", + intval($channel_id), + intval(ITEM_PDL) + ); + if($r) { + $o = t('Select a page layout: '); + $o .= ''; + } + + return $o; +} + + + + function mimetype_select($channel_id, $current = 'text/bbcode') { -- cgit v1.2.3 From 0be8e4061c42372a60e0274e7947edcb81625eaa Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 01:57:11 -0700 Subject: testing Comanche --- include/comanche.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index bdce0c5e2..3b50a5d85 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -45,15 +45,15 @@ function pdl_selector($uid,$current="") { function comanche_parser(&$a,$s) { - $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $matches, $s); + $cnt = preg_match("/\[layout\](.*?)\[\/layout\]/ism", $s, $matches); if($cnt) $a->page['template'] = trim($matches[1]); - $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $matches, $s); + $cnt = preg_match("/\[theme\](.*?)\[\/theme\]/ism", $s, $matches); if($cnt) $a->layout['theme'] = trim($matches[1]); - $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $matches, $s, PREG_SET_ORDER); + $cnt = preg_match_all("/\[region=(.*?)\](.*?)\[\/region\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $a->layout['region_' . $mtch[1]] = comanche_region($a,$mtch[2]); @@ -71,8 +71,9 @@ function comanche_menu($name) { function comanche_replace_region($match) { $a = get_app(); - if(array_key_exists($match[1],$a->page)) + if(array_key_exists($match[1],$a->page)) { return $a->page[$match[1]]; + } } // Widgets will have to get any operational arguments from the session, @@ -90,7 +91,7 @@ function comanche_widget($name,$args = null) { function comanche_region(&$a,$s) { - $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $matches, $s, PREG_SET_ORDER); + $cnt = preg_match_all("/\[menu\](.*?)\[\/menu\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s); @@ -99,7 +100,7 @@ function comanche_region(&$a,$s) { // need to modify this to accept parameters - $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $matches, $s, PREG_SET_ORDER); + $cnt = preg_match_all("/\[widget\](.*?)\[\/widget\]/ism", $s, $matches, PREG_SET_ORDER); if($cnt) { foreach($matches as $mtch) { $s = str_replace($mtch[0],comanche_widget(trim($mtch[1])),$s); -- cgit v1.2.3 From c360bf3252d3a6ec330a80ba70c19af9848a44e1 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 17:49:47 -0700 Subject: personal config to just show the page content without author info - probably this needs to be a page option --- include/conversation.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 45a744dd8..5888d3679 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1262,10 +1262,12 @@ function render_location_default($item) { function prepare_page($item) { + $naked = ((pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); + return replace_macros(get_markup_template('page_display.tpl'),array( - '$author' => $item['author']['xchan_name'], - '$auth_url' => $item['author']['xchan_url'], - '$date' => datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i'), + '$author' => (($naked) ? '' : $item['author']['xchan_name']), + '$auth_url' => (($naked) ? '' : $item['author']['xchan_url'], + '$date' => (($naked) ? '' : datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i')), '$title' => smilies(bbcode($item['title'])), '$body' => prepare_text($item['body'],$item['mimetype']) )); -- cgit v1.2.3 From bac2dcd46a6c5ebc7ba63fc60e0a90bfe48b8d87 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 17:55:25 -0700 Subject: typo --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 5888d3679..176dc33d4 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1266,7 +1266,7 @@ function prepare_page($item) { return replace_macros(get_markup_template('page_display.tpl'),array( '$author' => (($naked) ? '' : $item['author']['xchan_name']), - '$auth_url' => (($naked) ? '' : $item['author']['xchan_url'], + '$auth_url' => (($naked) ? '' : $item['author']['xchan_url']), '$date' => (($naked) ? '' : datetime_convert('UTC',date_default_timezone_get(),$item['created'],'Y-m-d H:i')), '$title' => smilies(bbcode($item['title'])), '$body' => prepare_text($item['body'],$item['mimetype']) -- cgit v1.2.3 From 879ac359523623d779f3097e5aa02937d6518950 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 18:00:09 -0700 Subject: my bad --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 176dc33d4..2b568c35e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1262,7 +1262,7 @@ function render_location_default($item) { function prepare_page($item) { - $naked = ((pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); + $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); return replace_macros(get_markup_template('page_display.tpl'),array( '$author' => (($naked) ? '' : $item['author']['xchan_name']), -- cgit v1.2.3 From c6df954fc00e4fdc7e2888e7dc3fe3a7c8f930e4 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 18:48:01 -0700 Subject: make displaying the language selector configurable --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 626caf981..dd11f10d5 100644 --- a/include/nav.php +++ b/include/nav.php @@ -200,7 +200,7 @@ EOT; $a->page['nav'] .= replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), - '$langselector' => lang_selector(), + '$langselector' => ((get_config('system','select_language')) ? lang_selector() : ''), '$sitelocation' => $sitelocation, '$nav' => $nav, '$banner' => $banner, -- cgit v1.2.3 From ab1c9dc9c9ecc1f382b6c7512b014c11f08b6e5e Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 19:55:26 -0700 Subject: add design tool menu to appropriate pages --- include/text.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 004efc08d..ac82e4429 100755 --- a/include/text.php +++ b/include/text.php @@ -1826,4 +1826,20 @@ function json_decode_plus($s) { $x = json_decode(str_replace(array('\\"','\\\\'),array('"','\\'),$s),true); return $x; -} \ No newline at end of file +} + + +function design_tools() { +// FIXME - this should be a template + + $o = '
'; + $o .= '

' . t('Design') . '

'; + $o .= '' . t('Blocks') . '' . EOL; + $o .= '' . t('Menus') . '' . EOL; + $o .= '' . t('Layouts') . '' . EOL; + $o .= '' . t('Pages') . '' . EOL; + $o .= '
'; + return $o; + +} + -- cgit v1.2.3 From a0668c8bbba43cb8b3b28d5a75d7d48f321e30f5 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 3 Sep 2013 22:48:08 -0700 Subject: fix private message encryption since the input_filter mangled it --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 66172ade3..c15bf8205 100755 --- a/include/items.php +++ b/include/items.php @@ -1398,15 +1398,15 @@ function item_store($arr,$allow_exec = false) { $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 ); - $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']); $arr['title'] = escape_tags($arr['title']); - // only detect language if we have text content, and if the post is private but not yet // obscured, make it so. if(! ($arr['item_flags'] & ITEM_OBSCURED)) { $arr['lang'] = detect_language($arr['body']); + // apply the input filter here - if it is obscured it has been filtered already + $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']); $allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages'); -- cgit v1.2.3 From a8f99df7770e6154ac4e0bc405974fde22357af6 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Sep 2013 00:50:47 -0700 Subject: render blocks - yes these should be templates, but I've got too much to do at the moment and just want everything to fall into place quickly. The clerical work will have to wait. --- include/comanche.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 3b50a5d85..c3a513332 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -76,6 +76,23 @@ function comanche_replace_region($match) { } } +function comanche_block($name) { + $o = ''; + $r = q("select * from item left join item_id on iid = item_id and item_id.uid = item.uid and service = 'BUILDBLOCK' and sid = '%s' limit 1", + dbesc($name) + ); + if($r) { + $o = '
'; + if($r[0]['title']) + $o .= '

' . $r[0]['title'] . '

'; + $o .= prepare_text($r[0]['body'],$r[0]['mimetype']); + $o .= '
'; + + } + return $o; +} + + // Widgets will have to get any operational arguments from the session, // the global app environment, or config storage until we implement argument passing @@ -97,6 +114,12 @@ function comanche_region(&$a,$s) { $s = str_replace($mtch[0],comanche_menu(trim($mtch[1])),$s); } } + $cnt = preg_match_all("/\[block\](.*?)\[\/block\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $s = str_replace($mtch[0],comanche_block(trim($mtch[1])),$s); + } + } // need to modify this to accept parameters -- cgit v1.2.3 From 99ea251b12f9bf361daf8abd96f6b3fab7023aa7 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Sep 2013 21:24:57 -0700 Subject: provide templating options in comanche for the underlying webpage element - in this case the way the author is displayed. Leave this open for other forms templating options. --- include/comanche.php | 27 +++++++++++++++++++++++++++ include/conversation.php | 6 ++++++ 2 files changed, 33 insertions(+) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index c3a513332..56a16fd3b 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -60,6 +60,14 @@ function comanche_parser(&$a,$s) { } } + $cnt = preg_match_all("/\[webpage\](.*?)\[\/webpage\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + // only the last webpage definition is used if there is more than one + foreach($matches as $mtch) { + $a->layout['webpage'] = comanche_webpage($a,$mtch[1]); + } + } + } @@ -92,6 +100,25 @@ function comanche_block($name) { return $o; } +// This doesn't really belong in Comanche, but it could also be argued that it is the perfect place. +// We need to be able to select what kind of template and decoration to use for the webpage at the heart of our content. +// For now we'll allow an '[authored]' element which defaults to name and date, or 'none' to remove these, and perhaps +// 'full' to provide a social network style profile photo. +// But leave it open to have richer templating options and perhaps ultimately discard this one, once we have a better idea +// of what template and webpage options we might desire. + +function comanche_webpage(&$a,$s) { + + $ret = array(); + $cnt = preg_match_all("/\[authored\](.*?)\[\/authored\]/ism", $s, $matches, PREG_SET_ORDER); + if($cnt) { + foreach($matches as $mtch) { + $ret['authored'] = $mtch[1]; + } + } + return $ret; +} + // Widgets will have to get any operational arguments from the session, // the global app environment, or config storage until we implement argument passing diff --git a/include/conversation.php b/include/conversation.php index 2b568c35e..0c1479356 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1262,7 +1262,13 @@ function render_location_default($item) { function prepare_page($item) { + $a = get_app(); $naked = ((get_pconfig($item['uid'],'system','nakedpage')) ? 1 : 0); + if(array_key_exists('webpage',$a->layout) && array_key_exists('authored',$a->layout['webpage'])) { + if($a->layout['webpage']['authored'] === 'none') + $naked = 1; + // ... other possible options + } return replace_macros(get_markup_template('page_display.tpl'),array( '$author' => (($naked) ? '' : $item['author']['xchan_name']), -- cgit v1.2.3 From f1d875c3e181ce02020830ed9e40b0ffb38ccc85 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Sep 2013 23:15:53 -0700 Subject: issue #59 - this is a real bugger. Might seem fixed but read the code. This could potentially create a security/permissions issue --- include/items.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index c15bf8205..a2300c2e0 100755 --- a/include/items.php +++ b/include/items.php @@ -2010,8 +2010,13 @@ function tag_deliver($uid,$item_id) { intval($item['parent']), intval($uid) ); - if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK) && ($x[0]['author_xchan'] == $item['author_xchan'])) { - logger('tag_deliver: creating second delivery chain for owner comment.'); + +// issue #59 +// FIXME - check security on post and allowed senders, right now we just allow it. The author *may* be foreign and the original owner is lost on our copy of the post. So this could be very hard to verify. For instance what happens if the top-level post was a wall-to-wall? +// if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK) && ($x[0]['author_xchan'] == $item['author_xchan'])) { + if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK)) { +// logger('tag_deliver: creating second delivery chain for owner comment.'); + logger('tag_deliver: creating second delivery chain for comment to tagged post.'); // now change this copy of the post to a forum head message and deliver to all the tgroup members // also reset all the privacy bits to the forum default permissions -- cgit v1.2.3 From 4df0aad6ab84c177fe2f9b7e5746fd20dbe9eb2b Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Sep 2013 19:31:26 -0700 Subject: pages feed --- include/items.php | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a2300c2e0..cd3ef7f68 100755 --- a/include/items.php +++ b/include/items.php @@ -220,16 +220,18 @@ function get_public_feed($channel,$params) { $start = 0; $records = 40; $direction = 'desc'; + $pages = 0; if(! $params) $params = array(); - $params['type'] = ((x($params,'type')) ? $params['type'] : 'xml'); - $params['begin'] = ((x($params,'begin')) ? $params['begin'] : '0000-00-00 00:00:00'); - $params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now')); - $params['start'] = ((x($params,'start')) ? $params['start'] : 0); - $params['records'] = ((x($params,'records')) ? $params['records'] : 40); - $params['direction'] = ((x($params,'direction')) ? $params['direction'] : 'desc'); + $params['type'] = ((x($params,'type')) ? $params['type'] : 'xml'); + $params['begin'] = ((x($params,'begin')) ? $params['begin'] : '0000-00-00 00:00:00'); + $params['end'] = ((x($params,'end')) ? $params['end'] : datetime_convert('UTC','UTC','now')); + $params['start'] = ((x($params,'start')) ? $params['start'] : 0); + $params['records'] = ((x($params,'records')) ? $params['records'] : 40); + $params['direction'] = ((x($params,'direction')) ? $params['direction'] : 'desc'); + $params['pages'] = ((x($params,'pages')) ? intval($params['pages']) : 0); switch($params['type']) { case 'json': @@ -250,9 +252,15 @@ function get_feed_for($channel, $observer_hash, $params) { if(! channel) http_status_exit(401); - if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream')) - http_status_exit(403); + if($params['pages']) { + if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_pages')) + http_status_exit(403); + } + else { + if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream')) + http_status_exit(403); + } $items = items_fetch(array( 'wall' => '1', 'datequery' => $params['begin'], @@ -260,6 +268,7 @@ function get_feed_for($channel, $observer_hash, $params) { 'start' => $params['start'], // FIXME 'records' => $params['records'], // FIXME 'direction' => $params['direction'], // FIXME + 'pages' => $params['pages'], 'order' => 'post' ), $channel, $observer_hash, CLIENT_MODE_NORMAL, get_app()->module); @@ -2938,9 +2947,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) { $o .= '' . xmlify($item['title']) . '' . "\r\n"; $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; $o .= '' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '' . "\r\n"; - $o .= '' . base64url_encode($body, true) . '' . "\r\n"; - // FIXME for other content types - $o .= '' . xmlify((($type === 'html') ? bbcode($body) : $body)) . '' . "\r\n"; + + $o .= '' . xmlify(prepare_text($body,$item['mimetype'])) . '' . "\r\n"; $o .= '' . "\r\n"; if($item['location']) { @@ -3710,11 +3718,17 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C require_once('include/security.php'); $sql_extra .= item_permissions_sql($channel['channel_id']); + if($arr['pages']) + $item_restrict = " AND (item_restrict & " . ITEM_WEBPAGE . ") "; + else + $item_restrict = " AND item_restrict = 0 "; + + if($arr['nouveau'] && ($client_mode & CLIENT_MODELOAD) && $channel) { // "New Item View" - show all items unthreaded in reverse created date order $items = q("SELECT item.*, item.id AS item_id FROM item - WHERE $item_uids AND item_restrict = 0 + WHERE $item_uids $item_restrict $simple_update $sql_extra $sql_nets ORDER BY item.received DESC $pager_sql " @@ -3741,7 +3755,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $r = q("SELECT distinct item.id AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE $item_uids AND item.item_restrict = 0 + WHERE $item_uids $item_restrict AND item.parent = item.id and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets @@ -3754,7 +3768,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // update $r = q("SELECT item.parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan - WHERE $item_uids AND item.item_restrict = 0 $simple_update + WHERE $item_uids $item_restrict $simple_update and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets ", intval(ABOOK_FLAG_BLOCKED) @@ -3770,7 +3784,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $parents_str = ids_to_querystr($r,'item_id'); $items = q("SELECT item.*, item.id AS item_id FROM item - WHERE $item_uids AND item.item_restrict = 0 + WHERE $item_uids $item_restrict AND item.parent IN ( %s ) $sql_extra ", dbesc($parents_str) -- cgit v1.2.3 From c65ea0b97b2dc6fcefa0d2da489f32bdd7d05b65 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 5 Sep 2013 22:00:06 -0700 Subject: public site list (will take a few days to populate, assuming folks have updated their site access policy which old sites do not have) --- include/zot.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 49f58c3bd..33522b485 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1523,10 +1523,22 @@ function import_site($arr,$pubkey) { if($arr['register_policy'] == 'approve') $register_policy = REGISTER_APPROVE; + $access_policy = 0; + if(array_key_exists('access_policy',$arr)) { + if($arr['access_policy'] === 'private') + $access_policy = ACCESS_PRIVATE; + if($arr['access_policy'] === 'paid') + $access_policy = ACCESS_PAID; + if($arr['access_policy'] === 'free') + $access_policy = ACCESS_FREE; + } + + if($update) { - $r = q("update site set site_flags = %d, site_directory = '%s', site_register = %d, site_update = '%s' + $r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s' where site_url = '%s' limit 1", intval($site_directory), + intval($access_policy), dbesc(htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false)), intval($register_policy), dbesc(datetime_convert()), @@ -1537,10 +1549,11 @@ function import_site($arr,$pubkey) { } } else { - $r = q("insert into site ( site_url, site_flags, site_update, site_directory, site_register ) - values ( '%s', %d, '%s', '%s', %d )", + $r = q("insert into site ( site_url, site_acccess, site_flags, site_update, site_directory, site_register ) + values ( '%s', %d, %d, '%s', '%s', %d )", dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)), intval($site_directory), + intval($access_policy), dbesc(datetime_convert()), dbesc(htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false)), intval($register_policy) -- cgit v1.2.3 From d194ee091af0ee15c7f63def7e8c07ee29e38f39 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 6 Sep 2013 05:25:10 -0700 Subject: encode and decode channel names containing HTML special characters and quotes so they will survive a reshare without mangling --- include/bbcode.php | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 4647b8567..997cbac2e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -106,48 +106,28 @@ function bb_ShareAttributes($match) { $author = ""; preg_match("/author='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") - $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8'); - - preg_match('/author="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $author = $matches[1]; + $author = urldecode($matches[1]); $link = ""; preg_match("/link='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $link = $matches[1]; - preg_match('/link="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $link = $matches[1]; - $avatar = ""; preg_match("/avatar='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $avatar = $matches[1]; - preg_match('/avatar="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $avatar = $matches[1]; - $profile = ""; preg_match("/profile='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $profile = $matches[1]; - preg_match('/profile="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $profile = $matches[1]; - $posted = ""; preg_match("/posted='(.*?)'/ism", $attributes, $matches); if ($matches[1] != "") $posted = $matches[1]; - preg_match('/posted="(.*?)"/ism', $attributes, $matches); - if ($matches[1] != "") - $posted = $matches[1]; - // FIXME - this should really be a wall-item-ago so it will get updated on the client $reldate = (($posted) ? relative_date($posted) : ''); -- cgit v1.2.3 From 94fb9c240661a9cd2b7199a648e9c5b4f9b69e8d Mon Sep 17 00:00:00 2001 From: Christian Vogeley Date: Sun, 8 Sep 2013 00:21:42 +0200 Subject: Service class identity, follow, photo upload, att upload --- include/contact_widgets.php | 19 +++++++++++++++++-- include/identity.php | 7 +++++-- include/plugin.php | 19 ++++++++++++------- 3 files changed, 34 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index e5f778e49..cc7d92508 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -1,12 +1,27 @@ channel['channel_id']; + $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']; + $limit = service_class_fetch($uid,'total_channels'); + if($limit !== false) { + $abook_usage_message = sprintf( t("You have %1$.0f of %2$.0f allowed connections."), $total_channels, $limit); + } + else { + $abook_usage_message = ''; + } return replace_macros(get_markup_template('follow.tpl'),array( '$connect' => t('Add New Connection'), '$desc' => t('Enter the channel address'), '$hint' => t('Example: bob@example.com, http://example.com/barbara'), - '$follow' => t('Connect') + '$follow' => t('Connect'), + '$abook_usage_message' => $abook_usage_message )); } diff --git a/include/identity.php b/include/identity.php index 8db6355c0..98209c8ae 100644 --- a/include/identity.php +++ b/include/identity.php @@ -7,7 +7,7 @@ require_once('include/crypto.php'); function identity_check_service_class($account_id) { $ret = array('success' => false, $message => ''); - $r = q("select count(channel_id) as total from channel were channel_account_id = %d ", + $r = q("select count(channel_id) as total from channel where channel_account_id = %d ", intval($account_id) ); if(! ($r && count($r))) { @@ -80,7 +80,10 @@ function create_identity($arr) { $ret['message'] = t('No account identifier'); return $ret; } - + $ret=identity_check_service_class($arr['account_id']); + if (!$ret['success']) { + return $ret; + } $nick = mb_strtolower(trim($arr['nickname'])); $name = escape_tags($arr['name']); $pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL); diff --git a/include/plugin.php b/include/plugin.php index 01ee99786..ea88a61df 100755 --- a/include/plugin.php +++ b/include/plugin.php @@ -374,12 +374,14 @@ function get_theme_screenshot($theme) { function service_class_allows($uid,$property,$usage = false) { - + $a = get_app(); if($uid == local_user()) { - $service_class = $a->user['service_class']; + $service_class = $a->account['account_service_class']; } else { - $r = q("select service_class from user where uid = %d limit 1", + $r = q("select account_service_class as service_class + from channel c, account a + where c.channel_account_id=a.account_id and c.channel_id= %d limit 1", intval($uid) ); if($r !== false and count($r)) { @@ -404,13 +406,15 @@ function service_class_allows($uid,$property,$usage = false) { function service_class_fetch($uid,$property) { - + $a = get_app(); if($uid == local_user()) { - $service_class = $a->user['service_class']; + $service_class = $a->account['account_service_class']; } else { - $r = q("select service_class from user where uid = %d limit 1", - intval($uid) + $r = q("select account_service_class as service_class + from channel c, account a + where c.channel_account_id=a.account_id and c.channel_id= %d limit 1", + intval($uid) ); if($r !== false and count($r)) { $service_class = $r[0]['service_class']; @@ -420,6 +424,7 @@ function service_class_fetch($uid,$property) { return false; // everything is allowed $arr = get_config('service_class',$service_class); + if(! is_array($arr) || (! count($arr))) return false; -- cgit v1.2.3 From f4dfb90dbc9b7590d9b8bf84df9ca746f1aa1d6f Mon Sep 17 00:00:00 2001 From: Christian Vogeley Date: Sun, 8 Sep 2013 17:19:09 +0200 Subject: Service class items Items / webpages /attachment message --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 46d406f4b..da08154c6 100644 --- a/include/attach.php +++ b/include/attach.php @@ -339,7 +339,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { intval($channel_id) ); if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { - $ret['message'] = upgrade_message(true); + $ret['message'] = upgrade_message(true).sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."),$limit / 1024000); @unlink($src); return $ret; } -- cgit v1.2.3 From a1b3a72f9ee893f648daffa818fc61706da0842f Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 8 Sep 2013 13:55:37 -0400 Subject: only show categories this channel has used --- include/contact_widgets.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index e5f778e49..6bebf96e3 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -76,9 +76,16 @@ function categories_widget($baseurl,$selected = '') { return ''; $terms = array(); - $r = q("select distinct(term) from term where uid = %d and type = %d order by term asc", + $r = q("select distinct(term.term) + from term join item on term.oid = item.id + where item.uid = %d + and term.uid = item.uid + and term.type = %d + and item.author_xchan = '%s' + order by term.term asc", intval($a->profile['profile_uid']), - intval(TERM_CATEGORY) + intval(TERM_CATEGORY), + $a->profile['channel_hash'] ); if($r && count($r)) { foreach($r as $rr) -- cgit v1.2.3 From a36abb764d04a92d97507b368b1b622a9483348a Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sun, 8 Sep 2013 14:53:14 -0400 Subject: added dbesc --- include/contact_widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 6bebf96e3..18c9d6510 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -85,7 +85,7 @@ function categories_widget($baseurl,$selected = '') { order by term.term asc", intval($a->profile['profile_uid']), intval(TERM_CATEGORY), - $a->profile['channel_hash'] + dbesc($a->profile['channel_hash']) ); if($r && count($r)) { foreach($r as $rr) -- cgit v1.2.3 From e11f2a9b022cbca170e3f1ce5fcd4d17ec63d3c6 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 8 Sep 2013 20:38:15 -0700 Subject: make sure new contacts who are not yet in the address book are sync'd across clone instances --- include/zot.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 33522b485..46c894351 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1745,6 +1745,20 @@ function process_channel_sync_delivery($sender,$arr,$deliveries) { if(! array_key_exists('abook_xchan',$clean)) continue; + $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", + dbesc($clean['abook_xchan']), + intval($channel['channel_id']) + ); + + // make sure we have an abook entry for this xchan on this system + + if(! $r) { + q("insert into abook ( abook_xchan, abook_channel ) values ('%s', %d ) ", + dbesc($clean['abook_xchan']), + intval($channel['channel_id']) + ); + } + if(count($clean)) { foreach($clean as $k => $v) { $r = dbq("UPDATE abook set " . dbesc($k) . " = '" . dbesc($v) -- cgit v1.2.3 From a09829a1ee62ec33904348979c5d5fbc6eb1bd6c Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 8 Sep 2013 21:05:39 -0700 Subject: perform a refresh_all when an import has completed so that all your connections get a fresh update. --- include/notifier.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/notifier.php b/include/notifier.php index 5dcd7b58c..e813f7951 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -208,9 +208,8 @@ function notifier_run($argv, $argc){ $channel = $s[0]; $uid = $item_id; $recipients = array(); - $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d)", - intval($item_id), - intval(ABOOK_FLAG_SELF) + $r = q("select abook_xchan from abook where abook_channel = %d", + intval($item_id) ); if($r) { foreach($r as $rr) { -- cgit v1.2.3 From 25a5a5ff4dd457398d762f0ff92f01b134b92eaa Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 9 Sep 2013 01:05:29 -0700 Subject: some alteration to the way directory sync was originally supposed to work. I'm making this up as I go and not exactly certain where to go next but it makes more sense now and I think the basic idea will actually work. I'll just have to keep making it up until it does work. --- include/zot.php | 39 ++++++++++++++------------------------- 1 file changed, 14 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 46c894351..88a7f4529 100644 --- a/include/zot.php +++ b/include/zot.php @@ -493,7 +493,6 @@ function import_xchan($arr) { logger('import_xchan: existing: ' . print_r($r[0],true), LOGGER_DATA); logger('import_xchan: new: ' . print_r($arr,true), LOGGER_DATA); - update_modtime($xchan_hash); $changed = true; } } @@ -532,7 +531,7 @@ function import_xchan($arr) { dbesc($arr['name_updated']), intval($new_flags) ); - update_modtime($xchan_hash); + $changed = true; } @@ -553,7 +552,7 @@ function import_xchan($arr) { dbesc($xchan_hash) ); - update_modtime($xchan_hash); + $changed = true; } @@ -601,7 +600,7 @@ function import_xchan($arr) { dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); - update_modtime($xchan_hash); + $changed = true; } continue; @@ -641,7 +640,7 @@ function import_xchan($arr) { dbesc(datetime_convert()), dbesc(datetime_convert()) ); - update_modtime($xchan_hash); + $changed = true; } @@ -653,7 +652,7 @@ function import_xchan($arr) { $r = q("delete from hubloc where hubloc_id = %d limit 1", intval($x['hubloc_id']) ); - update_modtime($xchan_hash); + $changed = true; } } @@ -667,7 +666,7 @@ function import_xchan($arr) { if(array_key_exists('profile',$arr) && is_array($arr['profile'])) { $profile_changed = import_directory_profile($xchan_hash,$arr['profile']); if($profile_changed) { - update_modtime($xchan_hash); + $changed = true; } } @@ -686,7 +685,6 @@ function import_xchan($arr) { if(array_key_exists('site',$arr) && is_array($arr['site'])) { $profile_changed = import_site($arr['site'],$arr['key']); if($profile_changed) { - update_modtime($xchan_hash); $changed = true; } } @@ -694,9 +692,8 @@ function import_xchan($arr) { if($changed) { - // send out a directory mirror update packet if we're a directory server or some kind - - + $guid = random_string() . '@' . get_app()->get_hostname(); + update_modtime($xchan_hash,$guid); } if(! x($ret,'message')) { @@ -1431,7 +1428,7 @@ function import_directory_profile($hash,$profile) { call_hooks('import_directory_profile', $d); if($d['update']) - update_modtime($arr['xprof_hash']); + update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname()); return $d['update']; } @@ -1470,20 +1467,12 @@ function import_directory_keywords($hash,$keywords) { } -function update_modtime($hash) { - $r = q("select * from updates where ud_hash = '%s' limit 1", - dbesc($hash) +function update_modtime($hash,$guid) { + q("insert into updates (ud_hash, ud_guid, ud_date) values ( '%s', '%s', '%s' )", + dbesc($hash), + dbesc($guid), + dbesc(datetime_convert()) ); - if($r) - q("update updates set ud_date = '%s' where ud_hash = '%s' limit 1", - dbesc(datetime_convert()), - dbesc($hash) - ); - else - q("insert into updates (ud_hash, ud_date) values ( '%s', '%s' )", - dbesc($hash), - dbesc(datetime_convert()) - ); } -- cgit v1.2.3 From fd540cd5969f1c1d7234874340daa1aeb007ecfe Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Mon, 9 Sep 2013 10:30:37 +0200 Subject: just a typo --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 88a7f4529..e9084496c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1538,7 +1538,7 @@ function import_site($arr,$pubkey) { } } else { - $r = q("insert into site ( site_url, site_acccess, site_flags, site_update, site_directory, site_register ) + $r = q("insert into site ( site_url, site_access, site_flags, site_update, site_directory, site_register ) values ( '%s', %d, %d, '%s', '%s', %d )", dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)), intval($site_directory), -- cgit v1.2.3 From 72f562c190630e69fa5a223855cd6f3a3bc66e49 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Sep 2013 17:09:10 -0700 Subject: z_fetch_url - include curl debug info in return array and log it (at logger_data level) on failure This should probably be at a lower log level, but unsuccessful connections could happen a lot on a busy production site so we'll try to keep the log noise down unless somebody really needs to track this info. --- include/network.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/network.php b/include/network.php index 8b9a8a6a6..00d931f19 100644 --- a/include/network.php +++ b/include/network.php @@ -312,8 +312,13 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { $rc = intval($http_code); $ret['return_code'] = $rc; $ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false); + if(! $ret['success']) { + $ret['debug'] = $curl_info; + logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA); + } $ret['body'] = substr($s,strlen($header)); $ret['header'] = $header; + @curl_close($ch); return($ret); } @@ -407,6 +412,11 @@ function z_post_url($url,$params, $redirects = 0, $opts = array()) { $rc = intval($http_code); $ret['return_code'] = $rc; $ret['success'] = (($rc >= 200 && $rc <= 299) ? true : false); + if(! $ret['success']) { + $ret['debug'] = $curl_info; + logger('z_fetch_url: debug:' . print_r($curl_info,true), LOGGER_DATA); + } + $ret['body'] = substr($s,strlen($header)); $ret['header'] = $header; curl_close($ch); -- cgit v1.2.3 From 3e5414cf35f3781297490e058c6d366bca45748e Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Sep 2013 19:06:06 -0700 Subject: provide detailed error to remote site for the myriad of things that can go wrong inside item_store(), !! this changes the return of item_store !! --- include/activities.php | 3 ++- include/event.php | 3 ++- include/items.php | 63 +++++++++++++++++++++++++++++++++++--------------- include/photos.php | 6 +++-- include/zot.php | 12 ++++++---- 5 files changed, 60 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/activities.php b/include/activities.php index 7ef26abeb..73180eae0 100644 --- a/include/activities.php +++ b/include/activities.php @@ -75,7 +75,8 @@ function profile_activity($changed, $value) { $arr['deny_cid'] = $self['channel_deny_cid']; $arr['deny_gid'] = $self['channel_deny_gid']; - $i = item_store($arr); + $res = item_store($arr); + $i = $res['item_id']; if($i) { // FIXME - limit delivery in notifier.php to those specificed in the perms argument diff --git a/include/event.php b/include/event.php index 29ada2e96..7873de1ef 100644 --- a/include/event.php +++ b/include/event.php @@ -360,7 +360,8 @@ function event_store($arr) { } - $item_id = item_store($item_arr); + $res = item_store($item_arr); + $item_id = $res['item_id']; call_hooks("event_created", $event['id']); diff --git a/include/items.php b/include/items.php index cd3ef7f68..2648a0629 100755 --- a/include/items.php +++ b/include/items.php @@ -193,7 +193,9 @@ function post_activity_item($arr) { } - $post_id = item_store($arr); + $post = item_store($arr); + if($post['result']) + $post_id = $post['item_id']; if($post_id) { $arr['id'] = $post_id; @@ -1365,9 +1367,12 @@ function encode_rel_links($links) { function item_store($arr,$allow_exec = false) { + $ret = array('result' => false, 'item_id' => 0); + if(! $arr['uid']) { logger('item_store: no uid'); - return 0; + $ret['message'] = 'No uid.'; + return ret; } // If a page layout is provided, ensure it exists and belongs to us. @@ -1392,7 +1397,8 @@ function item_store($arr,$allow_exec = false) { if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) { logger('item_store: php mimetype but allow_exec is denied.'); - return 0; + $ret['message'] = 'exec denied.'; + return $ret; } @@ -1424,7 +1430,8 @@ function item_store($arr,$allow_exec = false) { call_hooks('item_translate', $translate); if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) { logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']); - return; + $ret['message'] = 'language not accepted'; + return $ret; } $arr = $translate['item']; } @@ -1570,7 +1577,8 @@ function item_store($arr,$allow_exec = false) { } else { logger('item_store: item parent was not found - ignoring item'); - return 0; + $ret['message'] = 'parent not found.'; + return $ret; } } @@ -1584,14 +1592,16 @@ function item_store($arr,$allow_exec = false) { ); if($r) { logger('item-store: duplicate item ignored. ' . print_r($arr,true)); - return 0; + $ret['message'] = 'duplicate post.'; + return $ret; } call_hooks('post_remote',$arr); if(x($arr,'cancel')) { logger('item_store: post cancelled by plugin.'); - return 0; + $ret['message'] = 'cancelled.'; + return $ret; } // pull out all the taxonomy stuff for separate storage @@ -1625,7 +1635,8 @@ function item_store($arr,$allow_exec = false) { } else { logger('item_store: could not locate created item'); - return 0; + $ret['message'] = 'unable to retrieve.'; + return $ret; } if(count($r) > 1) { logger('item_store: duplicated post occurred. Removing duplicates.'); @@ -1697,21 +1708,26 @@ function item_store($arr,$allow_exec = false) { send_status_notifications($current_post,$arr); tag_deliver($arr['uid'],$current_post); + $ret['success'] = true; + $ret['item_id'] = $current_post; - return $current_post; + return $ret; } function item_store_update($arr,$allow_exec = false) { + $ret = array('result' => false, 'item_id' => 0); if(! intval($arr['uid'])) { logger('item_store_update: no uid'); - return 0; + $ret['message'] = 'no uid.'; + return $ret; } if(! intval($arr['id'])) { logger('item_store_update: no id'); - return 0; + $ret['message'] = 'no id.'; + return $ret; } $orig_post_id = $arr['id']; @@ -1729,7 +1745,8 @@ function item_store_update($arr,$allow_exec = false) { call_hooks('item_translate', $translate); if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) { logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']); - return; + $ret['message'] = 'language not accepted'; + return $ret; } $arr = $translate['item']; } @@ -1738,7 +1755,8 @@ function item_store_update($arr,$allow_exec = false) { if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) { logger('item_store: php mimetype but allow_exec is denied.'); - return 0; + $ret['message'] = 'exec denied.'; + return $ret; } @@ -1771,7 +1789,8 @@ function item_store_update($arr,$allow_exec = false) { ); if(! $orig) { logger('item_store_update: original post not found: ' . $orig_post_id); - return 0; + $ret['message'] = 'no original'; + return $ret; } unset($arr['aid']); @@ -1814,7 +1833,8 @@ function item_store_update($arr,$allow_exec = false) { if(x($arr,'cancel')) { logger('item_store_update: post cancelled by plugin.'); - return 0; + $ret['message'] = 'cancelled.'; + return $ret; } // pull out all the taxonomy stuff for separate storage @@ -1842,7 +1862,8 @@ function item_store_update($arr,$allow_exec = false) { logger('item_store_update: updated item ' . $orig_post_id, LOGGER_DEBUG); else { logger('item_store_update: could not update item'); - return 0; + $ret['message'] = 'DB update failed.'; + return $ret; } $r = q("delete from term where oid = %d and otype = %d", @@ -1871,8 +1892,10 @@ function item_store_update($arr,$allow_exec = false) { send_status_notifications($orig_post_id,$arr); tag_deliver($uid,$orig_post_id); + $ret['success'] = true; + $ret['item_id'] = $orig_post_id; - return $orig_post_id; + return $ret; } @@ -2749,7 +2772,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } } - $r = item_store($datarray); + $xx = item_store($datarray); + $r = $xx['item_id']; continue; } @@ -2879,7 +2903,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) continue; - $r = item_store($datarray); + $xx = item_store($datarray); + $r = $xx['item_id']; continue; } diff --git a/include/photos.php b/include/photos.php index c670bd90c..517212e57 100644 --- a/include/photos.php +++ b/include/photos.php @@ -222,7 +222,8 @@ function photo_upload($channel, $observer, $args) { . '[zmg]' . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' . '[/zrl]'; - $item_id = item_store($arr); + $result = item_store($arr); + $item_id = $result['item_id']; if($visible) proc_run('php', "include/notifier.php", 'wall-new', $item_id); @@ -402,7 +403,8 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' . '[/zrl]'; - $item_id = item_store($arr); + $result = item_store($arr); + $item_id = $result['item_id']; return $item_id; } \ No newline at end of file diff --git a/include/zot.php b/include/zot.php index e9084496c..6deee4d52 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1154,8 +1154,9 @@ function process_delivery($sender,$arr,$deliveries,$relay) { else { $arr['aid'] = $channel['channel_account_id']; $arr['uid'] = $channel['channel_id']; - $item_id = item_store($arr); - $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed'),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); + $item_result = item_store($arr); + $item_id = $item_result['item_id']; + $result[] = array($d['hash'],(($item_id) ? 'posted' : 'storage failed:' . $item_result['message']),$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>'); } if($relay && $item_id) { @@ -1238,8 +1239,11 @@ function remove_community_tag($sender,$arr,$uid) { function update_imported_item($sender,$item,$uid) { - item_store_update($item); - logger('update_imported_item'); + $x = item_store_update($item); + if(! $x['item_id']) + logger('update_imported_item: failed: ' . $x['message']); + else + logger('update_imported_item'); } -- cgit v1.2.3 From 46c66e2e4cc5c2f02bcbd4f92c78520a3d029ed8 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Sep 2013 20:14:12 -0700 Subject: change wording on item_store message so we can find failures fast with grep item_store logfile | grep -v created --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 2648a0629..b1aa493b5 100755 --- a/include/items.php +++ b/include/items.php @@ -1634,7 +1634,7 @@ function item_store($arr,$allow_exec = false) { logger('item_store: created item ' . $current_post, LOGGER_DEBUG); } else { - logger('item_store: could not locate created item'); + logger('item_store: could not locate stored item'); $ret['message'] = 'unable to retrieve.'; return $ret; } -- cgit v1.2.3 From 3c328083d25d2e6a2d901c4ea32f8a593ac78262 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Sep 2013 21:10:56 -0700 Subject: this should fix the foreign language like notifications (again) --- include/items.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index b1aa493b5..5a5dfdba1 100755 --- a/include/items.php +++ b/include/items.php @@ -1479,7 +1479,7 @@ function item_store($arr,$allow_exec = false) { $arr['changed'] = datetime_convert(); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : ''); $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : ''); - $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : ''); + $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : $arr['mid']); $arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ''); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ''); @@ -1591,7 +1591,7 @@ function item_store($arr,$allow_exec = false) { intval($arr['uid']) ); if($r) { - logger('item-store: duplicate item ignored. ' . print_r($arr,true)); + logger('item_store: duplicate item ignored. ' . print_r($arr,true)); $ret['message'] = 'duplicate post.'; return $ret; } @@ -1631,6 +1631,7 @@ function item_store($arr,$allow_exec = false) { if($r && count($r)) { $current_post = $r[0]['id']; + $arr = $r[0]; // This will gives us a fresh copy of what's now in the DB and undo the db escaping, which really messes up the notifications logger('item_store: created item ' . $current_post, LOGGER_DEBUG); } else { @@ -1668,6 +1669,7 @@ function item_store($arr,$allow_exec = false) { intval($current_post) ); + // These are probably redundant now that we've queried the just stored post $arr['id'] = $current_post; $arr['parent'] = $parent_id; $arr['allow_cid'] = $allow_cid; -- cgit v1.2.3 From 5e230edb85a2f10c43486e8d12b96e2a6ed1109c Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Sep 2013 22:45:04 -0700 Subject: well that really stuffed things up... --- include/items.php | 2 +- include/zot.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 5a5dfdba1..60a678d1b 100755 --- a/include/items.php +++ b/include/items.php @@ -1479,7 +1479,7 @@ function item_store($arr,$allow_exec = false) { $arr['changed'] = datetime_convert(); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : ''); $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : ''); - $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : $arr['mid']); + $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : ''); $arr['thr_parent'] = ((x($arr,'thr_parent')) ? notags(trim($arr['thr_parent'])) : $arr['parent_mid']); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ''); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ''); diff --git a/include/zot.php b/include/zot.php index 6deee4d52..dd6d1842c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -945,9 +945,9 @@ function public_recips($msg) { if($msg['notify']['sender']['url'] === z_root()) - $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " )) "; + $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_SITE . " ) or ( " . $col . " & " . PERMS_PUBLIC . ")) "; else - $sql = " where ( " . $col . " & " . PERMS_NETWORK . " ) " ; + $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_PUBLIC . ")) "; $r = q("select channel_hash as hash from channel " . $sql ); -- cgit v1.2.3 From 5fbe4c187695a02118039e3056ee471e93c858b1 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Sep 2013 23:25:56 -0700 Subject: make comments work again --- include/items.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 60a678d1b..304dab316 100755 --- a/include/items.php +++ b/include/items.php @@ -1624,11 +1624,12 @@ function item_store($arr,$allow_exec = false) { // find the item we just created - $r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC ", + $r = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC ", $arr['mid'], // already dbesc'd intval($arr['uid']) ); + if($r && count($r)) { $current_post = $r[0]['id']; $arr = $r[0]; // This will gives us a fresh copy of what's now in the DB and undo the db escaping, which really messes up the notifications -- cgit v1.2.3 From d593b40d9a31d00ec4374c60d509812996ff32d9 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Sep 2013 02:03:37 -0700 Subject: assuming this doesn't blow up the internet like the last fix - this is a very old bug that's been reported time and time again and nobody every bothered to debug or even report it somewhere where we could monitor it. It's buried somewhere in my stream, but basically is "things don't work right if you've got 'everybody in my address book' permissions" on "can send me their channel stream and posts". I think this is Michelle's problem and anybody else who has en empty matrix after making lots of connections. --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index dd6d1842c..9e8dd3dfa 100644 --- a/include/zot.php +++ b/include/zot.php @@ -955,7 +955,7 @@ function public_recips($msg) { $r = array(); $x = q("select channel_hash as hash from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' - and (( " . $col . " & " . PERMS_SPECIFIC . " ) OR ( " . $col . " & " . PERMS_CONTACTS . " )) and ( abook_my_perms & " . $field . " ) ", + and (( " . $col . " & " . PERMS_SPECIFIC . " ) and ( abook_my_perms & " . $field . " )) OR ( " . $col . " & " . PERMS_CONTACTS . " ) ", dbesc($msg['notify']['sender']['hash']) ); -- cgit v1.2.3 From 22282647720da3f84759130655a3095642d931fe Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Wed, 11 Sep 2013 13:59:45 +0200 Subject: flag failed auth attempts in DB table hubloc --- include/zot.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index dd6d1842c..ee4fe940f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -903,8 +903,10 @@ function zot_import($arr) { $result = process_channel_sync_delivery($i['notify']['sender'],$arr,$deliveries); } } - if($result) + if($result){ + logger('delivery result: ' . print_r($result,tue) ); $return = array_merge($return,$result); + } } } -- cgit v1.2.3 From 82f4b1767e5af692b25ca6cff9cec64ed6cb7ec6 Mon Sep 17 00:00:00 2001 From: Michael Meer Date: Wed, 11 Sep 2013 14:05:33 +0200 Subject: delete logger line; was the wrong place. --- include/zot.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index ee4fe940f..248a1419b 100644 --- a/include/zot.php +++ b/include/zot.php @@ -904,7 +904,6 @@ function zot_import($arr) { } } if($result){ - logger('delivery result: ' . print_r($result,tue) ); $return = array_merge($return,$result); } } -- cgit v1.2.3 From 816d764aecbd6105c41d591e2d7c0160758f1779 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Sep 2013 03:26:24 -0700 Subject: remove some debugging stuff now that the problem they were trying to locate down has been solved. --- include/items.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 304dab316..e987a69b1 100755 --- a/include/items.php +++ b/include/items.php @@ -1446,15 +1446,10 @@ function item_store($arr,$allow_exec = false) { } - if($arr['object']) - logger('item_store: input object: ' . print_r($arr['object'],true), LOGGER_DATA); - if((x($arr,'object')) && is_array($arr['object'])) { activity_sanitise($arr['object']); - logger('item_store: sanitised object: ' . print_r($arr['object'],true), LOGGER_DATA); $arr['object'] = json_encode($arr['object']); - logger('item_store: encoded object: ' . print_r($arr['object'],true), LOGGER_DATA); } if((x($arr,'target')) && is_array($arr['target'])) { -- cgit v1.2.3 From 3a2d11bde1581b8ee1e2a07c04370ce9eae9ea55 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Sep 2013 20:11:56 -0700 Subject: so public_recips and allowed_public_recips is working so much better than before, but was still not quite right. We seem to be getting all the right results for top-level posts now, but comments aren't getting through on channels for which we've allowed them to send us their stream, but not comment on our posts. The reason is we were seeing if they could comment - and we only need to do that if we own the post. If they own the post, we only need to check if they can send us their stream. --- include/zot.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index cdbfd2185..e395e88f6 100644 --- a/include/zot.php +++ b/include/zot.php @@ -926,14 +926,22 @@ function public_recips($msg) { $check_mentions = false; if($msg['message']['type'] === 'activity') { + $col = 'channel_w_stream'; + $field = PERMS_W_STREAM; if(array_key_exists('flags',$msg['message']) && in_array('thread_parent', $msg['message']['flags'])) { - $col = 'channel_w_stream'; - $field = PERMS_W_STREAM; + // check mention recipient permissions on top level posts only $check_mentions = true; } else { - $col = 'channel_w_comment'; - $field = PERMS_W_COMMENT; + // if this is a comment and it wasn't sent by the post owner, check to see who is allowing them to comment. + // We should have one specific recipient and this step shouldn't be needed unless somebody stuffed up their software. + // We may need this step to protect us from bad guys intentionally stuffing up their software. + // If it is sent by the post owner, we don't need to do this. We only need to see who is receiving the + // owner's stream (which was already set above) - as they control the comment permissions + if($msg['notify']['sender']['guid_sig'] != $msg['message']['owner']['guid_sig']) { + $col = 'channel_w_comment'; + $field = PERMS_W_COMMENT; + } } } elseif($msg['message']['type'] === 'mail') { -- cgit v1.2.3 From e9ea80f2f62a2ab53f5b6d74792de6b08fd98a03 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Sep 2013 21:54:15 -0700 Subject: No point beating a dead horse --- include/poller.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/poller.php b/include/poller.php index bdb0388ac..f084005c7 100644 --- a/include/poller.php +++ b/include/poller.php @@ -158,7 +158,7 @@ function poller_run($argv, $argc){ ); - $contacts = q("SELECT abook_id, abook_updated, abook_connected, abook_closeness, abook_channel + $contacts = q("SELECT abook_id, abook_flags, abook_updated, abook_connected, abook_closeness, abook_channel FROM abook LEFT JOIN account on abook_account = account_id where 1 $sql_extra AND (( abook_flags = %d ) OR ( abook_flags = %d )) @@ -210,6 +210,11 @@ function poller_run($argv, $argc){ continue; } + if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) { + $update = false; + continue; + } + // might be dead, so maybe don't poll quite so often // recently deceased, so keep up the regular schedule for 3 days @@ -223,6 +228,8 @@ function poller_run($argv, $argc){ if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 2 day")) > 0) { $update = true; } + + } if((! $update) && (! $force)) -- cgit v1.2.3 From cf87653a922f3b7f6132a00bb77293ae9e7a66c1 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Sep 2013 22:50:41 -0700 Subject: need to figure out what's causing this --- include/zot.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index e395e88f6..f34344739 100644 --- a/include/zot.php +++ b/include/zot.php @@ -844,6 +844,12 @@ function zot_import($arr) { } else { + if((array_key_exists('flags',$i['message'])) && (in_array('private',$i['message']['flags']))) { + // This should not happen but until we can stop it... + logger('private message was delivered with no recipients.'); + continue; + } + logger('public post'); // Public post. look for any site members who are or may be accepting posts from this sender -- cgit v1.2.3 From 83e086edcd4d13b2e8508eb17a24a849c8e3aa06 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 13 Sep 2013 04:51:55 -0700 Subject: doc update, put more telemetry on notifier and try to ensure that private posts have recipients. --- include/items.php | 3 +++ include/notifier.php | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index e987a69b1..c83eceabe 100755 --- a/include/items.php +++ b/include/items.php @@ -18,6 +18,9 @@ function collect_recipients($item,&$private) { require_once('include/group.php'); + if($item['item_private']) + $private = true; + if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) { $allow_people = expand_acl($item['allow_cid']); $allow_groups = expand_groups(expand_acl($item['allow_gid'])); diff --git a/include/notifier.php b/include/notifier.php index e813f7951..e1f150bf2 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -372,6 +372,10 @@ function notifier_run($argv, $argc){ } } + if(($private) && (! $env_recips)) { + // shouldn't happen + logger('notifier: private message with no envelope recipients.' . print_r($argv,true)); + } logger('notifier: recipients (may be delivered to more if public): ' . print_r($recip_list,true), LOGGER_DEBUG); -- cgit v1.2.3 From 94417eecbae6ca678f402458373406d64efde3d6 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Sep 2013 01:56:25 -0700 Subject: import_xchan - check every known hubloc/location field and create a new hubloc if anything at all changed anywhere. --- include/zot.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index f34344739..a690d8346 100644 --- a/include/zot.php +++ b/include/zot.php @@ -578,13 +578,18 @@ function import_xchan($arr) { } } - $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s' - and hubloc_url = '%s' and hubloc_url_sig = '%s' limit 1", + // match as many fields as possible in case anything at all changed. + + $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_url = '%s' and hubloc_url_sig = '%s' and hubloc_host = '%s' and hubloc_addr = '%s' and hubloc_callback = '%s' and hubloc_sitekey = '%s' limit 1", dbesc($xchan_hash), dbesc($arr['guid']), dbesc($arr['guid_sig']), dbesc($location['url']), - dbesc($location['url_sig']) + dbesc($location['url_sig']), + dbesc($location['host']), + dbesc($location['address']), + dbesc($location['callback']), + dbesc($location['sitekey']) ); if($r) { logger('import_xchan: hub exists: ' . $location['url']); @@ -600,7 +605,6 @@ function import_xchan($arr) { dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); - $changed = true; } continue; -- cgit v1.2.3 From 095939f0d8653fbb0a33444fbfcddfdef1419b26 Mon Sep 17 00:00:00 2001 From: mrjive Date: Sat, 14 Sep 2013 20:28:56 +0200 Subject: First try to tell a comment from a like/dislike in notification system --- include/enotify.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 92 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index b2a4f5856..88d5e7744 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -152,7 +152,14 @@ function notification($params) { // differents subjects for messages on the same thread. $subject = sprintf( t('[Red:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); - $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $sender['xchan_name']); + // Let's try to tell if it is a comment or a like/dislike + // of course this is stupid, we should know if the like/dislike has been given to the post + // or to a comment to the post... + if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)) { + $preamble = sprintf( t('%s gave a like/dislike to the converation you have been following.' $dender['xchan_name']); + } else { + $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $sender['xchan_name']); + } $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); @@ -265,7 +272,90 @@ function notification($params) { $tsitelink = sprintf( $sitelink, $siteurl ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); $itemlink = $params['link']; - } + }263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 + $sitelink = t('Please visit %s to approve or reject the suggestion.'); + $tsitelink = sprintf( $sitelink, $siteurl ); + $hsitelink = sprintf( $sitelink, '' . $sitename . ''); + $itemlink = $params['link']; + } + if($params['type'] == NOTIFY_CONFIRM) { + } + if($params['type'] == NOTIFY_SYSTEM) { + + } + $h = array( + 'params' => $params, + 'subject' => $subject, + 'preamble' => $preamble, + 'epreamble' => $epreamble, + 'body' => $body, + 'sitelink' => $sitelink, + 'tsitelink' => $tsitelink, + 'hsitelink' => $hsitelink, + 'itemlink' => $itemlink + ); + + call_hooks('enotify',$h); + $subject = $h['subject']; + $preamble = $h['preamble']; + $epreamble = $h['epreamble']; + $body = $h['body']; + $sitelink = $h['sitelink']; + $tsitelink = $h['tsitelink']; + $hsitelink = $h['hsitelink']; + $itemlink = $h['itemlink']; + require_once('include/html2bbcode.php'); + do { + $dups = false; + $hash = random_string(); + $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1", +Commit summary: Extended description: (optional) +mrjive mrjive@mrjive.it + if($params['type'] == NOTIFY_CONFIRM) { -- cgit v1.2.3 From 05649fa33acfa405f6be75f8d423d7a10ec5b817 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Sat, 14 Sep 2013 23:39:40 +0200 Subject: Revert broken commit --- include/enotify.php | 94 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 92 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index 88d5e7744..b2a4f5856 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -152,14 +152,7 @@ function notification($params) { // differents subjects for messages on the same thread. $subject = sprintf( t('[Red:Notify] Comment to conversation #%1$d by %2$s'), $parent_id, $sender['xchan_name']); - // Let's try to tell if it is a comment or a like/dislike - // of course this is stupid, we should know if the like/dislike has been given to the post - // or to a comment to the post... - if (activity_match($item['verb'],ACTIVITY_LIKE) || activity_match($item['verb'],ACTIVITY_DISLIKE)) { - $preamble = sprintf( t('%s gave a like/dislike to the converation you have been following.' $dender['xchan_name']); - } else { - $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $sender['xchan_name']); - } + $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $sender['xchan_name']); $epreamble = $dest_str; $sitelink = t('Please visit %s to view and/or reply to the conversation.'); @@ -272,90 +265,7 @@ function notification($params) { $tsitelink = sprintf( $sitelink, $siteurl ); $hsitelink = sprintf( $sitelink, '' . $sitename . ''); $itemlink = $params['link']; - }263 -264 -265 -266 -267 -268 -269 -270 -271 -272 -273 -274 -275 -276 -277 -278 -279 -280 -281 -282 -283 -284 -285 -286 -287 -288 -289 -290 -291 -292 -293 -294 -295 -296 -297 -298 -299 -300 -301 -302 -303 -304 -305 -306 -307 - $sitelink = t('Please visit %s to approve or reject the suggestion.'); - $tsitelink = sprintf( $sitelink, $siteurl ); - $hsitelink = sprintf( $sitelink, '' . $sitename . ''); - $itemlink = $params['link']; - } - if($params['type'] == NOTIFY_CONFIRM) { - } - if($params['type'] == NOTIFY_SYSTEM) { - - } - $h = array( - 'params' => $params, - 'subject' => $subject, - 'preamble' => $preamble, - 'epreamble' => $epreamble, - 'body' => $body, - 'sitelink' => $sitelink, - 'tsitelink' => $tsitelink, - 'hsitelink' => $hsitelink, - 'itemlink' => $itemlink - ); - - call_hooks('enotify',$h); - $subject = $h['subject']; - $preamble = $h['preamble']; - $epreamble = $h['epreamble']; - $body = $h['body']; - $sitelink = $h['sitelink']; - $tsitelink = $h['tsitelink']; - $hsitelink = $h['hsitelink']; - $itemlink = $h['itemlink']; - require_once('include/html2bbcode.php'); - do { - $dups = false; - $hash = random_string(); - $r = q("SELECT `id` FROM `notify` WHERE `hash` = '%s' LIMIT 1", -Commit summary: Extended description: (optional) -mrjive mrjive@mrjive.it - + } if($params['type'] == NOTIFY_CONFIRM) { -- cgit v1.2.3 From 0c4857e1a9f0fbfece2ac90ea90d6670a0d4ba41 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sat, 14 Sep 2013 17:54:32 -0400 Subject: let me edit menu_desc even if menu_name has not changed --- include/menu.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/menu.php b/include/menu.php index 6d614055a..0e98f3a84 100644 --- a/include/menu.php +++ b/include/menu.php @@ -141,14 +141,16 @@ function menu_edit($arr) { } - $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d limit 1", + $r = q("select * from menu where menu_name = '%s' and menu_channel_id = %d and menu_desc = '%s' limit 1", dbesc($menu_name), - intval($menu_channel_id) + intval($menu_channel_id), + dbesc($menu_desc) ); if($r) return false; + return q("update menu set menu_name = '%s', menu_desc = '%s' where menu_id = %d and menu_channel_id = %d limit 1", dbesc($menu_name), -- cgit v1.2.3 From ec7b462b1876eb47e38d545bcbcbd05097c31cd5 Mon Sep 17 00:00:00 2001 From: Michael Johnston Date: Sat, 14 Sep 2013 18:16:54 -0400 Subject: set menu_channel_id before we use it in a query --- include/menu.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/menu.php b/include/menu.php index 0e98f3a84..900b48e65 100644 --- a/include/menu.php +++ b/include/menu.php @@ -118,6 +118,8 @@ function menu_edit($arr) { return false; + $menu_channel_id = intval($arr['menu_channel_id']); + $r = q("select menu_id from menu where menu_name = '%s' and menu_channel_id = %d limit 1", dbesc($menu_name), intval($menu_channel_id) @@ -128,9 +130,6 @@ function menu_edit($arr) { } - - $menu_channel_id = intval($arr['menu_channel_id']); - $r = q("select * from menu where menu_id = %d and menu_channel_id = %d limit 1", intval($menu_id), intval($menu_channel_id) -- cgit v1.2.3 From 053893b0673d15c255718e5328fbbdb9af29f715 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Sep 2013 17:20:24 -0700 Subject: some fixes to directory keyword searches --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index a690d8346..53031a6c5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1383,8 +1383,8 @@ function import_directory_profile($hash,$profile) { foreach($profile['keywords'] as $kw) { $kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8',false)); $kw = trim($kw,','); + $clean[] = $kw; } - $clean[] = $kw; } $arr['xprof_keywords'] = implode(' ',$clean); -- cgit v1.2.3 From 129a119c84d87bffe099cea7ac5b0ed511c26f80 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Sep 2013 03:48:43 -0700 Subject: implement what I hope will now be the server side of directory sync, add viewsrc to item_photo_menu, and log what changed in import_xchan update objects so we can find out why there are so many updates when nothing _obvious_ has changed that should trigger it. --- include/conversation.php | 20 ++++++++++++-------- include/zot.php | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 0c1479356..e7c7831c0 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -876,6 +876,12 @@ function item_photo_menu($item){ $ssl_state = false; + $sub_link=""; + $poke_link=""; + $contact_url=""; + $pm_url=""; + $vsrc_link = ""; + if(local_user()) { $ssl_state = true; if(! count($a->contacts)) @@ -884,14 +890,11 @@ function item_photo_menu($item){ $channel_hash = (($channel) ? $channel['channel_hash'] : ''); } - $sub_link=""; - $poke_link=""; - $contact_url=""; - $pm_url=""; - - if((local_user()) && local_user() == $item['uid'] && $item['parent'] == $item['id'] - && $channel && ($channel_hash != $item['author_xchan'])) { - $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; + if((local_user()) && local_user() == $item['uid']) { + $vsrc_link = $a->get_baseurl() . '/viewsrc/' . $item['id']; + if($item['parent'] == $item['id'] && $channel && ($channel_hash != $item['author_xchan'])) { + $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; + } } $profile_link = z_root() . "/chanview/?f=&hash=" . $item['author_xchan']; @@ -910,6 +913,7 @@ function item_photo_menu($item){ } $menu = Array( + t("View Source") => $vsrc_link, t("Follow Thread") => $sub_link, t("View Status") => $status_link, t("View Profile") => $profile_link, diff --git a/include/zot.php b/include/zot.php index 53031a6c5..c461486f0 100644 --- a/include/zot.php +++ b/include/zot.php @@ -417,6 +417,7 @@ function import_xchan($arr) { $dirmode = intval(get_config('system','directory_mode')); $changed = false; + $what = ''; if(! (is_array($arr) && array_key_exists('success',$arr) && $arr['success'])) { logger('import_xchan: invalid data packet: ' . print_r($arr,true)); @@ -492,7 +493,7 @@ function import_xchan($arr) { logger('import_xchan: existing: ' . print_r($r[0],true), LOGGER_DATA); logger('import_xchan: new: ' . print_r($arr,true), LOGGER_DATA); - + $what .= 'xchan '; $changed = true; } } @@ -532,6 +533,7 @@ function import_xchan($arr) { intval($new_flags) ); + $what .= 'new_xchan'; $changed = true; } @@ -552,7 +554,7 @@ function import_xchan($arr) { dbesc($xchan_hash) ); - + $what .= 'photo '; $changed = true; } @@ -605,6 +607,7 @@ function import_xchan($arr) { dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); + $what = 'primary_hub '; $changed = true; } continue; @@ -644,7 +647,7 @@ function import_xchan($arr) { dbesc(datetime_convert()), dbesc(datetime_convert()) ); - + $what .= 'newhub '; $changed = true; } @@ -656,7 +659,7 @@ function import_xchan($arr) { $r = q("delete from hubloc where hubloc_id = %d limit 1", intval($x['hubloc_id']) ); - + $what .= 'removed_hub'; $changed = true; } } @@ -670,7 +673,7 @@ function import_xchan($arr) { if(array_key_exists('profile',$arr) && is_array($arr['profile'])) { $profile_changed = import_directory_profile($xchan_hash,$arr['profile']); if($profile_changed) { - + $what .= 'profile '; $changed = true; } } @@ -689,6 +692,7 @@ function import_xchan($arr) { if(array_key_exists('site',$arr) && is_array($arr['site'])) { $profile_changed = import_site($arr['site'],$arr['key']); if($profile_changed) { + $what .= 'site '; $changed = true; } } @@ -698,6 +702,7 @@ function import_xchan($arr) { if($changed) { $guid = random_string() . '@' . get_app()->get_hostname(); update_modtime($xchan_hash,$guid); + logger('import_xchan: changed: ' . $what,LOGGER_DEBUG); } if(! x($ret,'message')) { @@ -1396,6 +1401,7 @@ function import_directory_profile($hash,$profile) { $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]); $update = true; break; } @@ -1431,6 +1437,7 @@ function import_directory_profile($hash,$profile) { } else { $update = true; + 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_keywords) values ('%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", dbesc($arr['xprof_hash']), dbesc($arr['xprof_desc']), -- cgit v1.2.3 From b3575484c7c8577f1ea648364fd979d7c551d4b9 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Sep 2013 19:04:11 -0700 Subject: don't create a directory sync notification (entry in the updates table) if the site record was updated - without checking first to see if anything changed. This is causing lots of sync entries when nothing changed to warrant it. --- include/zot.php | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index c461486f0..df3b79f80 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1516,12 +1516,15 @@ function import_site($arr,$pubkey) { } $update = false; + $exists = false; $r = q("select * from site where site_url = '%s' limit 1", dbesc($arr['url']) ); - if($r) - $update = true; + if($r) { + $exists = true; + $siterecord = $r[0]; + } $site_directory = 0; if($arr['directory_mode'] == 'normal') @@ -1552,29 +1555,39 @@ function import_site($arr,$pubkey) { $access_policy = ACCESS_FREE; } - - if($update) { - $r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s' - where site_url = '%s' limit 1", - intval($site_directory), - intval($access_policy), - dbesc(htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false)), - intval($register_policy), - dbesc(datetime_convert()), - dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)) - ); - if(! $r) { - logger('import_site: update failed. ' . print_r($arr,true)); + $directory_url = htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false); + $url = htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false); + + if($exists) { + if(($siterecord['site_flags'] != $site_directory) + || ($siterecord['site_access'] != $access_policy) + || ($siterecord['site_directory'] != $directory_url) + || ($siterecord['site_register'] != $register_policy)) { + $update = true; + + $r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s' + where site_url = '%s' limit 1", + intval($site_directory), + intval($access_policy), + dbesc($directory_url), + intval($register_policy), + dbesc(datetime_convert()), + dbesc($url) + ); + if(! $r) { + logger('import_site: update failed. ' . print_r($arr,true)); + } } } else { + $update = true; $r = q("insert into site ( site_url, site_access, site_flags, site_update, site_directory, site_register ) values ( '%s', %d, %d, '%s', '%s', %d )", - dbesc(htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false)), + dbesc($url), intval($site_directory), intval($access_policy), dbesc(datetime_convert()), - dbesc(htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false)), + dbesc($directory_url), intval($register_policy) ); if(! $r) { -- cgit v1.2.3 From 4decbacda1cceb80af4b96309c6d74947595a1e5 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Sep 2013 22:19:24 -0700 Subject: more logging --- include/zot.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index df3b79f80..91fc03a3a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1565,6 +1565,9 @@ function import_site($arr,$pubkey) { || ($siterecord['site_register'] != $register_policy)) { $update = true; + logger('import_site: input: ' . print_r($arr,true)); + logger('import_site: stored: ' . print_r($siterecord,true)); + $r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s' where site_url = '%s' limit 1", intval($site_directory), -- cgit v1.2.3 From 4b5d91ccb5e42bbd1d379b8963d932bbc8615634 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Sep 2013 23:02:18 -0700 Subject: found it --- include/zot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 91fc03a3a..0f42ddc7f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1565,8 +1565,8 @@ function import_site($arr,$pubkey) { || ($siterecord['site_register'] != $register_policy)) { $update = true; - logger('import_site: input: ' . print_r($arr,true)); - logger('import_site: stored: ' . print_r($siterecord,true)); +// logger('import_site: input: ' . print_r($arr,true)); +// logger('import_site: stored: ' . print_r($siterecord,true)); $r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s' where site_url = '%s' limit 1", @@ -1598,7 +1598,7 @@ function import_site($arr,$pubkey) { } } - return $r; + return $update; } -- cgit v1.2.3 From 9bff739d9624d3a4ba1fb488673ec1a18bc6d395 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Sep 2013 21:35:52 -0700 Subject: several oauth fixes - shred doesn't completely work yet, but it also doesn't completely NOT work, so at least there's some improvement --- include/api.php | 11 ++++++--- include/oauth.php | 67 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/api.php b/include/api.php index a49258d18..d76d82626 100644 --- a/include/api.php +++ b/include/api.php @@ -1823,9 +1823,13 @@ require_once('include/photos.php'); function api_oauth_request_token(&$a, $type){ try{ $oauth = new FKOAuth1(); - $r = $oauth->fetch_request_token(OAuthRequest::from_request()); + $req = OAuthRequest::from_request(); +logger('Req: ' . var_export($req,true)); + $r = $oauth->fetch_request_token($req); }catch(Exception $e){ - echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme(); + logger('oauth_exception: ' . print_r($e->getMessage(),true)); + echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); + killme(); } echo $r; killme(); @@ -1833,7 +1837,8 @@ require_once('include/photos.php'); function api_oauth_access_token(&$a, $type){ try{ $oauth = new FKOAuth1(); - $r = $oauth->fetch_access_token(OAuthRequest::from_request()); + $req = OAuthRequest::from_request(); + $r = $oauth->fetch_access_token($req); }catch(Exception $e){ echo "error=". OAuthUtil::urlencode_rfc3986($e->getMessage()); killme(); } diff --git a/include/oauth.php b/include/oauth.php index 6ec5285e4..b10802ecd 100644 --- a/include/oauth.php +++ b/include/oauth.php @@ -18,11 +18,12 @@ class FKOAuthDataStore extends OAuthDataStore { function lookup_consumer($consumer_key) { logger(__function__.":".$consumer_key); - //echo "
"; var_dump($consumer_key); killme();
-	  
+//      echo "
"; var_dump($consumer_key); killme();
+
 		$r = q("SELECT client_id, pw, redirect_uri FROM clients WHERE client_id='%s'",
 			dbesc($consumer_key)
 		);
+
 		if (count($r))
 			return new OAuthConsumer($r[0]['client_id'],$r[0]['pw'],$r[0]['redirect_uri']);
 		return null;
@@ -30,11 +31,13 @@ class FKOAuthDataStore extends OAuthDataStore {
 
   function lookup_token($consumer, $token_type, $token) {
 		logger(__function__.":".$consumer.", ". $token_type.", ".$token);
+
 		$r = q("SELECT id, secret,scope, expires, uid  FROM tokens WHERE client_id='%s' AND scope='%s' AND id='%s'",
 			dbesc($consumer->key),
 			dbesc($token_type),
 			dbesc($token)
 		);
+
 		if (count($r)){
 			$ot=new OAuthToken($r[0]['id'],$r[0]['secret']);
 			$ot->scope=$r[0]['scope'];
@@ -46,12 +49,14 @@ class FKOAuthDataStore extends OAuthDataStore {
   }
 
   function lookup_nonce($consumer, $token, $nonce, $timestamp) {
-		//echo __file__.":".__line__."
"; var_dump($consumer,$key); killme();
+//		echo __file__.":".__line__."
"; var_dump($consumer,$key); killme();
+
 		$r = q("SELECT id, secret  FROM tokens WHERE client_id='%s' AND id='%s' AND expires=%d",
 			dbesc($consumer->key),
 			dbesc($nonce),
 			intval($timestamp)
 		);
+
 		if (count($r))
 			return new OAuthToken($r[0]['id'],$r[0]['secret']);
 		return null;
@@ -67,13 +72,14 @@ class FKOAuthDataStore extends OAuthDataStore {
 		} else {
 			$k = $consumer;
 		}
-		
+
 		$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d)",
 				dbesc($key),
 				dbesc($sec),
 				dbesc($k),
 				'request',
 				intval(REQUEST_TOKEN_DURATION));
+
 		if (!$r) return null;
 		return new OAuthToken($key,$sec);
   }
@@ -95,6 +101,7 @@ class FKOAuthDataStore extends OAuthDataStore {
 		
 		$key = $this->gen_token();
 		$sec = $this->gen_token();
+
 		$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d, %d)",
 				dbesc($key),
 				dbesc($sec),
@@ -102,6 +109,7 @@ class FKOAuthDataStore extends OAuthDataStore {
 				'access',
 				intval(ACCESS_TOKEN_DURATION),
 				intval($uverifier));
+
 		if ($r)
 			$ret = new OAuthToken($key,$sec);		
 	}
@@ -131,9 +139,9 @@ class FKOAuth1 extends OAuthServer {
 	}
 	
 	function loginUser($uid){
-		logger("FKOAuth1::loginUser $uid");
+		logger("RedOAuth1::loginUser $uid");
 		$a = get_app();
-		$r = q("SELECT * FROM `user` WHERE uid=%d AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
+		$r = q("SELECT * FROM channel WHERE channel_id = %d LIMIT 1",
 			intval($uid)
 		);
 		if(count($r)){
@@ -143,35 +151,36 @@ class FKOAuth1 extends OAuthServer {
 		    header('HTTP/1.0 401 Unauthorized');
 		    die('This api requires login');
 		}
-		$_SESSION['uid'] = $record['uid'];
-		$_SESSION['theme'] = $record['theme'];
-		$_SESSION['mobile_theme'] = get_pconfig($record['uid'], 'system', 'mobile_theme');
+		$_SESSION['uid'] = $record['channel_id'];
+		$_SESSION['theme'] = $record['channel_theme'];
+		$_SESSION['account_id'] = $record['channel_account_id'];
+		$_SESSION['mobile_theme'] = get_pconfig($record['channel_id'], 'system', 'mobile_theme');
 		$_SESSION['authenticated'] = 1;
-		$_SESSION['page_flags'] = $record['page-flags'];
-		$_SESSION['my_url'] = $a->get_baseurl() . '/channel/' . $record['nickname'];
+//		$_SESSION['page_flags'] = $record['page-flags'];
+		$_SESSION['my_url'] = $a->get_baseurl() . '/channel/' . $record['channel_address'];
 		$_SESSION['addr'] = $_SERVER['REMOTE_ADDR'];
+		$_SESSION['allow_api'] = true;
 
-		//notice( t("Welcome back ") . $record['username'] . EOL);
-		$a->user = $record;
+		$a->channel = $record;
 
-		if(strlen($a->user['timezone'])) {
-			date_default_timezone_set($a->user['timezone']);
-			$a->timezone = $a->user['timezone'];
+		if(strlen($a->channel['channel_timezone'])) {
+			date_default_timezone_set($a->channel['channel_timezone']);
+//			$a->timezone = $a->user['timezone'];
 		}
 
-		$r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
-			intval($_SESSION['uid']));
-		if(count($r)) {
-			$a->contact = $r[0];
-			$a->cid = $r[0]['id'];
-			$_SESSION['cid'] = $a->cid;
-		}
-		q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d LIMIT 1",
-			dbesc(datetime_convert()),
-			intval($_SESSION['uid'])
-		);
-
-		call_hooks('logged_in', $a->user);		
+//		$r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1",
+//			intval($_SESSION['uid']));
+//		if(count($r)) {
+//			$a->contact = $r[0];
+//			$a->cid = $r[0]['id'];
+//			$_SESSION['cid'] = $a->cid;
+//		}
+//		q("UPDATE `user` SET `login_date` = '%s' WHERE `uid` = %d LIMIT 1",
+//			dbesc(datetime_convert()),
+//			intval($_SESSION['uid'])
+//		);
+//
+//		call_hooks('logged_in', $a->user);		
 	}
 	
 }
-- 
cgit v1.2.3


From c6d6c01fb619b37fa47f19966421a6636155180c Mon Sep 17 00:00:00 2001
From: friendica 
Date: Mon, 16 Sep 2013 22:40:53 -0700
Subject: use prepare_body in api calls to properly render content, add 'mode'
 to conversation templates so that themes can use the module context to
 suppress or show comments as desired

---
 include/ItemObject.php   |  4 +++-
 include/api.php          | 14 +++++++-------
 include/conversation.php |  1 +
 3 files changed, 11 insertions(+), 8 deletions(-)

(limited to 'include')

diff --git a/include/ItemObject.php b/include/ItemObject.php
index 22b191e79..0256160e9 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -88,6 +88,8 @@ class Item extends BaseObject {
 			: false);
 		$shareable = ((($conv->get_profile_owner() == local_user()) && ($item['item_private'] != 1)) ? true : false);
 
+		$mode = $conv->get_mode();
+
 		if(local_user() && $observer['xchan_hash'] === $item['author_xchan'])
 			$edpost = array($a->get_baseurl($ssl_state)."/editpost/".$item['id'], t("Edit"));
 		else
@@ -183,7 +185,7 @@ class Item extends BaseObject {
 
 		$tmp_item = array(
 			'template' => $this->get_template(),
-			
+			'mode' => $mode,			
 			'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
 			'tags' => array(),
 			'body' => $body,
diff --git a/include/api.php b/include/api.php
index d76d82626..0ca8393c1 100644
--- a/include/api.php
+++ b/include/api.php
@@ -732,7 +732,7 @@ require_once('include/photos.php');
 				}
 			}  
 			$status_info = array(
-				'text' => html2plain(bbcode($lastwall['body']), 0),
+				'text' => html2plain(prepare_text($lastwall['body'],$lastwall['mimetype']), 0),
 				'truncated' => false,
 				'created_at' => api_date($lastwall['created']),
 				'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -804,7 +804,7 @@ require_once('include/photos.php');
 				}
 			}  
 			$user_info['status'] = array(
-				'text' => html2plain(bbcode($lastwall['body']), 0),
+				'text' => html2plain(prepare_text($lastwall['body'],$lastwall['mimetype']), 0),
 				'truncated' => false,
 				'created_at' => api_date($lastwall['created']),
 				'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -1374,14 +1374,14 @@ require_once('include/photos.php');
 		if (x($_GET, 'getText')) {
 			$ret['title'] = $item['title'] ;
 			if ($_GET["getText"] == "html") {
-				$ret['text'] = bbcode($item['body']);
+				$ret['text'] = prepare_text($item['body'],$item['mimetype']);
 			}
 			elseif ($_GET["getText"] == "plain") {
-				$ret['text'] = html2plain(bbcode($item['body']), 0);
+				$ret['text'] = html2plain(prepare_text($item['body'],$item['mimetype']), 0);
 			}
 		}
 		else {
-			$ret['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
+			$ret['text'] = $item['title']."\n".html2plain(prepare_text($item['body'],$item['mimetype']), 0);
 		}
 		if (isset($_GET["getUserObjects"]) && $_GET["getUserObjects"] == "false") {
 			unset($ret['sender']);
@@ -1427,7 +1427,7 @@ require_once('include/photos.php');
 			}
 
 			// Workaround for ostatus messages where the title is identically to the body
-			$statusbody = trim(html2plain(bbcode($item['body']), 0));
+			$statusbody = trim(html2plain(prepare_text($item['body'],$item['mimetype']), 0));
 			$statustitle = trim($item['title']);
 
 			if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
@@ -1448,7 +1448,7 @@ require_once('include/photos.php');
 				'geo'                       => '',
 				'favorited'                 => (($item['item_flags'] & ITEM_STARRED) ? true : false),
 				'user'                      =>  $status_user ,
-				'statusnet_html'		    => trim(bbcode($item['body'])),
+				'statusnet_html'		    => trim(prepare_text($item['body']),$item['mimetype']),
 				'statusnet_conversation_id'	=> $item['parent'],
 			);
 
diff --git a/include/conversation.php b/include/conversation.php
index e7c7831c0..c3f29295e 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -651,6 +651,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
 				$tmp_item = array(
 					'template' => $tpl,
 					'toplevel' => 'toplevel_item',
+					'mode' => $mode,
 					'id' => (($preview) ? 'P0' : $item['item_id']),
 					'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_url),
 					'profile_url' => $profile_link,
-- 
cgit v1.2.3


From a78b76d3938b6747da97bc729521c58f9491105f Mon Sep 17 00:00:00 2001
From: friendica 
Date: Mon, 16 Sep 2013 22:51:39 -0700
Subject: more work on viewing obscured api posts

---
 include/api.php  |  8 +++++---
 include/text.php | 19 ++++++++++++-------
 2 files changed, 17 insertions(+), 10 deletions(-)

(limited to 'include')

diff --git a/include/api.php b/include/api.php
index 0ca8393c1..2760914e9 100644
--- a/include/api.php
+++ b/include/api.php
@@ -730,7 +730,8 @@ require_once('include/photos.php');
 					$in_reply_to_user_id = $user_info['id'];
 					$in_reply_to_screen_name = $user_info['screen_name'];
 				}
-			}  
+			}
+			unobscure($lastwall);  
 			$status_info = array(
 				'text' => html2plain(prepare_text($lastwall['body'],$lastwall['mimetype']), 0),
 				'truncated' => false,
@@ -803,6 +804,7 @@ require_once('include/photos.php');
 					$in_reply_to_screen_name = $user_info['screen_name'];
 				}
 			}  
+			unobscure($lastwall);
 			$user_info['status'] = array(
 				'text' => html2plain(prepare_text($lastwall['body'],$lastwall['mimetype']), 0),
 				'truncated' => false,
@@ -1369,7 +1371,7 @@ require_once('include/photos.php');
 				'recipient_screen_name' => $recipient['screen_name'],
 				'recipient'             => $recipient,
 		);
-
+		unobscure($item);
 		//don't send title to regular StatusNET requests to avoid confusing these apps
 		if (x($_GET, 'getText')) {
 			$ret['title'] = $item['title'] ;
@@ -1425,7 +1427,7 @@ require_once('include/photos.php');
 				$in_reply_to_user_id = 0;
 				$in_reply_to_status_id = 0;
 			}
-
+			unobscure($item);
 			// Workaround for ostatus messages where the title is identically to the body
 			$statusbody = trim(html2plain(prepare_text($item['body'],$item['mimetype']), 0));
 			$statustitle = trim($item['title']);
diff --git a/include/text.php b/include/text.php
index ac82e4429..e1f0a4e00 100755
--- a/include/text.php
+++ b/include/text.php
@@ -1004,6 +1004,17 @@ function link_compare($a,$b) {
 // If attach is true, also add icons for item attachments
 
 
+function unobscure(&$item) {
+	if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+		$key = get_config('system','prvkey');
+		if($item['title'])
+			$item['title'] = aes_unencapsulate(json_decode_plus($item['title']),$key);
+		if($item['body'])
+			$item['body'] = aes_unencapsulate(json_decode_plus($item['body']),$key);
+	}
+
+}
+
 
 function prepare_body(&$item,$attach = false) {
 
@@ -1013,13 +1024,7 @@ function prepare_body(&$item,$attach = false) {
 
 	call_hooks('prepare_body_init', $item); 
 
-	if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
-		$key = get_config('system','prvkey');
-		if($item['title'])
-			$item['title'] = aes_unencapsulate(json_decode_plus($item['title']),$key);
-		if($item['body'])
-			$item['body'] = aes_unencapsulate(json_decode_plus($item['body']),$key);
-	}
+	unobscure($item);
 
 	$s = prepare_text($item['body'],$item['mimetype']);
 
-- 
cgit v1.2.3


From 4fa68c7f3de68dda519f12719c552df7b62bf17f Mon Sep 17 00:00:00 2001
From: friendica 
Date: Tue, 17 Sep 2013 17:53:44 -0700
Subject: missing verb on items linked to photos

---
 include/photos.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'include')

diff --git a/include/photos.php b/include/photos.php
index 517212e57..ea4b494e0 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -216,7 +216,7 @@ function photo_upload($channel, $observer, $args) {
 	$arr['allow_gid']     = $str_group_allow;
 	$arr['deny_cid']      = $str_contact_deny;
 	$arr['deny_gid']      = $str_group_deny;
-
+	$arr['verb']          = ACTIVITY_POST;
 
 	$arr['body']          = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' 
 				. '[zmg]' . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' 
-- 
cgit v1.2.3


From ff2ada207a7c90f095d1fad1513440eb08d3840a Mon Sep 17 00:00:00 2001
From: friendica 
Date: Tue, 17 Sep 2013 20:50:09 -0700
Subject: Pieces we'll need to tie together chanman and account/channel
 deletion and directory sync. Please do not mess with any of this. Please do
 not mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this. Please do not
 mess with any of this. Please do not mess with any of this.

OK? Understood?
---
 include/Contact.php  | 59 +++++++++++++++++++++++++++++++++++++++-------------
 include/notifier.php | 35 ++++++++++++++++++++++++++-----
 include/zot.php      | 10 +++++++++
 3 files changed, 84 insertions(+), 20 deletions(-)

(limited to 'include')

diff --git a/include/Contact.php b/include/Contact.php
index 46d356f3f..b9e879bcf 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -147,7 +147,9 @@ function user_remove($uid) {
 
 }
 
-function account_remove($account_id) {
+function account_remove($account_id,$local = true) {
+
+	logger('account_remove: ' . $account_id);
 
 	if(! intval($account_id)) {
 		logger('account_remove: no account.');
@@ -179,7 +181,7 @@ function account_remove($account_id) {
 	);
 	if($x) {
 		foreach($x as $xx) {
-			channel_remove($xx['channel_id']);
+			channel_remove($xx['channel_id'],$local);
 		}
 	}
 
@@ -191,7 +193,7 @@ function account_remove($account_id) {
 
 }
 
-function channel_remove($channel_id) {
+function channel_remove($channel_id, $local = true) {
 
 	if(! $channel_id)
 		return;
@@ -199,13 +201,38 @@ function channel_remove($channel_id) {
 	logger('Removing channel: ' . $channel_id);
 
 	$r = q("select * from channel where channel_id = %d limit 1", intval($channel_id));
+	if(! $r) {
+		logger('channel_remove: channel not found: ' . $channel_id);
+		return;
+	}
+
+	$channel = $r[0];
 
 	call_hooks('channel_remove',$r[0]);
 
+	if(! $local) {
+
 	// FIXME notify the directory
 	
 	// FIXME notify all contacts
 
+		$r = q("update channel set channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0,
+			channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0,
+			channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0,
+			channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0 where channel_id = %d limit 1",
+			intval(PAGE_REMOVED),
+			intval($channel_id)
+		);
+
+		$r = q("update hubloc set hubloc_flags = hubloc_flags | %d where hubloc_hash = '%s'",
+			intval(HUBLOC_FLAGS_DELETED),
+			dbesc($channel['channel_hash'])
+		);
+
+		proc_run('php','include/notifier.php','purge_all',$channel_id);
+
+
+	}
 
 	q("DELETE FROM `group` WHERE `uid` = %d", intval($channel_id));
 	q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id));
@@ -278,18 +305,20 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
 		);
 
 
-		$r = q("delete from xchan where xchan_hash = '%s' limit 1",
-			dbesc($xchan)
-		);
-		$r = q("delete from hubloc where hubloc_hash = '%s'",
-			dbesc($xchan)
-		);
-		$r = q("delete from abook where abook_xchan = '%s'",
-			dbesc($xchan)
-		);
-		$r = q("delete from xtag where xtag_hash = '%s'",
-			dbesc($xchan)
-		);
+// This could get sticky with directories
+
+//		$r = q("delete from xchan where xchan_hash = '%s' limit 1",
+//			dbesc($xchan)
+//		);
+//		$r = q("delete from hubloc where hubloc_hash = '%s'",
+//			dbesc($xchan)
+//		);
+//		$r = q("delete from abook where abook_xchan = '%s'",
+//			dbesc($xchan)
+//		);
+//		$r = q("delete from xtag where xtag_hash = '%s'",
+//			dbesc($xchan)
+//		);
 
 	}
 }
diff --git a/include/notifier.php b/include/notifier.php
index e1f150bf2..0c7ac5264 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -54,6 +54,7 @@ require_once('include/html2plain.php');
  * ZOT 
  *       permission_update      abook_id
  *       refresh_all            channel_id
+ *       purge_all              channel_id
  *       expire                 channel_id
  *       relay					item_id (item was relayed to owner, we will deliver it as owner)
  *
@@ -219,6 +220,26 @@ function notifier_run($argv, $argc){
 		$private = false;
 		$packet_type = 'refresh';
 	}
+	elseif($cmd === 'purge_all') {
+		logger('notifier: purge_all: ' . $item_id);
+		$s = q("select * from channel where channel_id = %d limit 1",
+			intval($item_id)
+		);
+		if($s)
+			$channel = $s[0];
+		$uid = $item_id;
+		$recipients = array();
+		$r = q("select abook_xchan from abook where abook_channel = %d",
+			intval($item_id)
+		);
+		if($r) {
+			foreach($r as $rr) {
+				$recipients[] = $rr['abook_xchan'];
+			}
+		}
+		$private = false;
+		$packet_type = 'purge';
+	}
 	else {
 
 		// Normal items
@@ -388,7 +409,7 @@ function notifier_run($argv, $argc){
 
 	$sql_extra = (($private) ? "" : " or hubloc_url = '" . z_root() . "' ");
 
-	$r = q("select distinct hubloc_sitekey, hubloc_callback, hubloc_host from hubloc 
+	$r = q("select distinct hubloc_sitekey, hubloc_flags, hubloc_callback, hubloc_host from hubloc 
 		where hubloc_hash in (" . implode(',',$recipients) . ") $sql_extra group by hubloc_sitekey");
 	if(! $r) {
 		logger('notifier: no hubs');
@@ -397,8 +418,12 @@ function notifier_run($argv, $argc){
 	$hubs = $r;
 
 	$hublist = array();
-	foreach($hubs as $hub)
-		$hublist[] = $hub['hubloc_host'];
+	foreach($hubs as $hub) {
+		// don't try to deliver to deleted hublocs
+		if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) {
+			$hublist[] = $hub['hubloc_host'];
+		}
+	}
 
 	logger('notifier: will notify/deliver to these hubs: ' . print_r($hublist,true), LOGGER_DEBUG);
 			 
@@ -414,8 +439,8 @@ function notifier_run($argv, $argc){
 
 	foreach($hubs as $hub) {
 		$hash = random_string();
-		if($packet_type === 'refresh') {
-			$n = zot_build_packet($channel,'refresh');
+		if($packet_type === 'refresh' || $packet_type === 'purge') {
+			$n = zot_build_packet($channel,$packet_type);
 			q("insert into outq ( outq_hash, outq_account, outq_channel, outq_posturl, outq_async, outq_created, outq_updated, outq_notify, outq_msg ) values ( '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s' )",
 				dbesc($hash),
 				intval($channel['channel_account']),
diff --git a/include/zot.php b/include/zot.php
index 0f42ddc7f..74ac6d015 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -610,6 +610,16 @@ function import_xchan($arr) {
 					$what = 'primary_hub ';
 					$changed = true;
 				}
+				if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted']))
+					|| ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) {
+					$r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d), hubloc_updated = '%s' where hubloc_id = %d limit 1",
+						intval(HUBLOC_FLAGS_DELETED),
+						dbesc(datetime_convert()),
+						intval($r[0]['hubloc_id'])
+					);
+					$what = 'delete_hub ';
+					$changed = true;
+				}
 				continue;
 			}
 
-- 
cgit v1.2.3


From d3aa31be4d84764e4d119343d8bc5eba5a84272b Mon Sep 17 00:00:00 2001
From: friendica 
Date: Tue, 17 Sep 2013 22:27:51 -0700
Subject: site sellpage links

---
 include/zot.php | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'include')

diff --git a/include/zot.php b/include/zot.php
index 74ac6d015..c416d18f9 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1567,24 +1567,27 @@ function import_site($arr,$pubkey) {
 
 	$directory_url = htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false);
 	$url = htmlentities($arr['url'],ENT_COMPAT,'UTF-8',false);
+	$sellpage = htmlentities($arr['sellpage'],ENT_COMPAT,'UTF-8',false);
 
 	if($exists) {
 		if(($siterecord['site_flags'] != $site_directory)
 			|| ($siterecord['site_access'] != $access_policy)
 			|| ($siterecord['site_directory'] != $directory_url)
+			|| ($siterecord['site_sellpage'] != $sellpage)
 			|| ($siterecord['site_register'] != $register_policy)) {
 			$update = true;
 
 //			logger('import_site: input: ' . print_r($arr,true));
 //			logger('import_site: stored: ' . print_r($siterecord,true));
 
-			$r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s'
+			$r = q("update site set site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s'
 				where site_url = '%s' limit 1",
 				intval($site_directory),
 				intval($access_policy),
 				dbesc($directory_url),
 				intval($register_policy),
 				dbesc(datetime_convert()),
+				dbesc($sellpage),
 				dbesc($url)
 			);
 			if(! $r) {
@@ -1594,14 +1597,15 @@ function import_site($arr,$pubkey) {
 	}
 	else {
 		$update = true;
-		$r = q("insert into site ( site_url, site_access, site_flags, site_update, site_directory, site_register )
-			values ( '%s', %d, %d, '%s', '%s', %d )",
+		$r = q("insert into site ( site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage )
+			values ( '%s', %d, %d, '%s', '%s', %d, '%s' )",
 			dbesc($url),
 			intval($site_directory),
 			intval($access_policy),
 			dbesc(datetime_convert()),
 			dbesc($directory_url),
-			intval($register_policy)
+			intval($register_policy),
+			dbesc($sellpage)
 		);
 		if(! $r) {
 			logger('import_site: record create failed. ' . print_r($arr,true));
-- 
cgit v1.2.3


From f7acc94bfedae6f23e0bc883541ca23132e95a06 Mon Sep 17 00:00:00 2001
From: friendica 
Date: Tue, 17 Sep 2013 22:52:46 -0700
Subject: provide the back-end for a directory tag cloud

---
 include/taxonomy.php | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

(limited to 'include')

diff --git a/include/taxonomy.php b/include/taxonomy.php
index b6803743a..b8180f7c8 100644
--- a/include/taxonomy.php
+++ b/include/taxonomy.php
@@ -99,6 +99,7 @@ function format_term_for_display($term) {
 function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $type = TERM_HASHTAG) {
 
 	$sql_options = '';
+	$count = intval($count);
 
 	if($flags)
 		$sql_options .= " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") ";
@@ -157,6 +158,47 @@ function tags_sort($a,$b) {
 }
 
 
+function dir_tagadelic($count = 0) {
+
+	$sql_options = '';
+	$count = intval($count);
+
+	// Fetch tags
+	$r = q("select xtag_term, count(xtag_term) as total from xtag
+		group by term order by total desc %s",
+		((intval($count)) ? "limit $count" : '')
+	);
+
+	if(! $r)
+		return array();
+  
+  	// Find minimum and maximum log-count.
+	$tags = array();
+	$min = 1e9;
+	$max = -1e9;
+
+	$x = 0;
+	foreach($r as $rr) {
+		$tags[$x][0] = $rr['xtag_term'];
+		$tags[$x][1] = log($rr['total']);
+		$tags[$x][2] = 0;
+		$min = min($min,$tags[$x][1]);
+		$max = max($max,$tags[$x][1]);
+		$x ++;
+	}
+
+	usort($tags,'tags_sort');
+
+	$range = max(.01, $max - $min) * 1.0001;
+
+	for($x = 0; $x < count($tags); $x ++) {
+		$tags[$x][2] = 1 + floor(5 * ($tags[$x][1] - $min) / $range);
+	}
+
+	return $tags;
+}
+
+
 function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$type = TERM_HASHTAG) {
   $o = '';
   $tab = 0;
@@ -172,6 +214,24 @@ function tagblock($link,$uid,$count = 0,$authors = '',$flags = 0,$type = TERM_HA
 	return $o;
 }
 
+function dir_tagblock($link,$r) {
+  $o = '';
+  $tab = 0;
+
+  if($r) {
+	$o = '

' . t('Keywords') . '

'; + foreach($r as $rr) { + $o .= ''.$rr['term'].' ' . "\r\n"; + } + $o .= '
'; + } + return $o; +} + + + + + /** * verbs: [0] = first person singular, e.g. "I want", [1] = 3rd person singular, e.g. "Bill wants" -- cgit v1.2.3 From b0a4f1b30ab9bf5de2182b475ab5639f63a8e53f Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Sep 2013 22:56:09 -0700 Subject: fix sql for directory tagcloud --- include/taxonomy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/taxonomy.php b/include/taxonomy.php index b8180f7c8..30eb08f65 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -165,7 +165,7 @@ function dir_tagadelic($count = 0) { // Fetch tags $r = q("select xtag_term, count(xtag_term) as total from xtag - group by term order by total desc %s", + group by xtag_term order by total desc %s", ((intval($count)) ? "limit $count" : '') ); -- cgit v1.2.3 From 98e87b2149cec4179bf8d6677a600e8f7564402e Mon Sep 17 00:00:00 2001 From: Olivier Migeot Date: Wed, 18 Sep 2013 12:11:46 +0200 Subject: Changed CSS class "selected" to "active" in navbar, according to https://abcentric.net/display/f17b319c6d4b616a0d0a639e177969c6ae084248f1ee2bec9d8147c9291bf495@abcentric.net --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index dd11f10d5..812c90537 100644 --- a/include/nav.php +++ b/include/nav.php @@ -235,5 +235,5 @@ function nav_set_selected($item){ 'manage' => null, 'register' => null, ); - $a->nav_sel[$item] = 'selected'; + $a->nav_sel[$item] = 'active'; } -- cgit v1.2.3 From e4d2e2200e04c8df699d9a8efade661123ef7ac8 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 18 Sep 2013 17:47:26 -0700 Subject: add "tiered" access policy, add tagcloud to directory pages --- include/taxonomy.php | 2 +- include/zot.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/taxonomy.php b/include/taxonomy.php index 30eb08f65..a3c3fc7b4 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -221,7 +221,7 @@ function dir_tagblock($link,$r) { if($r) { $o = '

' . t('Keywords') . '

'; foreach($r as $rr) { - $o .= ''.$rr['term'].' ' . "\r\n"; + $o .= ''.$rr['term'].' ' . "\r\n"; } $o .= '
'; } diff --git a/include/zot.php b/include/zot.php index c416d18f9..58b3d74d3 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1563,6 +1563,8 @@ function import_site($arr,$pubkey) { $access_policy = ACCESS_PAID; if($arr['access_policy'] === 'free') $access_policy = ACCESS_FREE; + if($arr['access_policy'] === 'tiered') + $access_policy = ACCESS_TIERED; } $directory_url = htmlentities($arr['directory_url'],ENT_COMPAT,'UTF-8',false); -- cgit v1.2.3 From 14f6bf06e7d0dd7a851715bb081e2f2a55d79c2a Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 18 Sep 2013 21:20:54 -0700 Subject: set default charset of email_header_encode, add ud_flags to indicate which (directory sync) updates have been processed in some way. --- include/network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index 00d931f19..99a0a8e2b 100644 --- a/include/network.php +++ b/include/network.php @@ -1336,7 +1336,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority = } -function email_header_encode($in_str, $charset) { +function email_header_encode($in_str, $charset = 'UTF-8') { $out_str = $in_str; $need_to_convert = false; -- cgit v1.2.3 From 63fc92b9e5d75f0dda0aecaaa0e1feb56d2b9744 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Sep 2013 01:01:51 -0700 Subject: sync item_search with yesterday's network fix for collections. Add ud_addr to update table to store the target address since it's possible the mirroring directory won't yet have an xchan or hubloc they can link the ud_hash to and therefore mayn't know how to contact them. --- include/items.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index c83eceabe..a60e3fdd6 100755 --- a/include/items.php +++ b/include/items.php @@ -3645,16 +3645,22 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C return $result; } - $contacts = expand_groups(array($arr['group'])); - if((is_array($contacts)) && count($contacts)) { - $contact_str = implode(',',$contacts); + + $contact_str = ''; + $contacts = group_get_members($group); + if($contacts) { + foreach($contacts as $c) { + if($contact_str) + $contact_str .= ','; + $contact_str .= "'" . $c['xchan'] . "'"; + } } else { - $contact_str = ' 0 '; - $result['message'] = t('Collection has no members.'); + $contact_str = ' 0 '; + info( t('Group is empty')); } - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND ( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and item_restrict = 0 ) "; + $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and item_restrict = 0 ) "; } elseif($arr['cid'] && $uid) { -- cgit v1.2.3 From a5656c350dd2a1329ef8ddb4e6eea82e341920c3 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Sep 2013 01:45:06 -0700 Subject: trim commas from keywords --- include/zot.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 58b3d74d3..c0b53bdc1 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1487,6 +1487,7 @@ function import_directory_keywords($hash,$keywords) { $clean = array(); foreach($keywords as $kw) { $kw = trim(htmlentities($kw,ENT_COMPAT,'UTF-8',false)); + $kw = trim($kw,','); $clean[] = $kw; } -- cgit v1.2.3 From 54abed8457c504e69e3d139238d2ff09b0ec6cc8 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Sep 2013 19:50:13 -0700 Subject: provide a "safe search" backend and allow for self-censorship using nsfw or adult profile keywords. Eventually the directories will be forced to mark adult profiles and sync this knowledge between them. At the moment there's no way to do an unsafe search, but we really just need a checkbox and pass the value through directory to dirsearch on the back end, and some will want this as a pconfig. --- include/text.php | 6 ++++++ include/zot.php | 10 ++++++++++ 2 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index e1f0a4e00..40df8bd89 100755 --- a/include/text.php +++ b/include/text.php @@ -1848,3 +1848,9 @@ function design_tools() { } +/* case insensitive in_array() */ + +function in_arrayi($needle, $haystack) { + return in_array(strtolower($needle), array_map('strtolower', $haystack)); +} + diff --git a/include/zot.php b/include/zot.php index c0b53bdc1..3929fa4c1 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1404,6 +1404,16 @@ function import_directory_profile($hash,$profile) { $arr['xprof_keywords'] = implode(' ',$clean); + // Self censored, make it so + // These are not translated, so the German "erwachsenen" keyword will not censor the directory profile. Only the English form - "adult". + + if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) { + q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_CENSORED) + ); + } + + $r = q("select * from xprof where xprof_hash = '%s' limit 1", dbesc($hash) ); -- cgit v1.2.3 From 876a9d1850ec6fc2aa26f530e8ab554028158734 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Sep 2013 21:13:45 -0700 Subject: missing hash --- include/taxonomy.php | 2 +- include/zot.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/taxonomy.php b/include/taxonomy.php index a3c3fc7b4..85396a51d 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -221,7 +221,7 @@ function dir_tagblock($link,$r) { if($r) { $o = '

' . t('Keywords') . '

'; foreach($r as $rr) { - $o .= ''.$rr['term'].' ' . "\r\n"; + $o .= ''.$rr['term'].' ' . "\r\n"; } $o .= '
'; } diff --git a/include/zot.php b/include/zot.php index 3929fa4c1..a98aca711 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1409,7 +1409,8 @@ function import_directory_profile($hash,$profile) { if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) { q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1", - intval(XCHAN_FLAGS_CENSORED) + intval(XCHAN_FLAGS_CENSORED), + dbesc($hash) ); } -- cgit v1.2.3 From e6d93b251606e7261db3a5048cf730c2e69a28e3 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Sep 2013 05:45:11 -0700 Subject: is_commentable() had some major issues when applied to the atrocity known as ConversationObject, hopefully this won't destabilise the network as it's a somewhat major permission tweak related to comments; also add any local clones to allowed_public_recips() as they should always be allowed recipients. Not sure what to do about host permissions in the event of clones. They have more than one host, and it isn't spelled out in the sent message. All of this stuff will make your head hurt. --- include/ConversationObject.php | 23 +++++++++++++---------- include/ItemObject.php | 14 +++++++++++++- include/zot.php | 5 ++++- 3 files changed, 30 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 30026e908..5157dad05 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -138,22 +138,25 @@ class Conversation extends BaseObject { return false; } - if(local_user() && $item->get_data_value('uid') == local_user()) - $this->commentable = true; +// if(local_user() && $item->get_data_value('uid') == local_user()) +// $this->commentable = true; - if($this->writable) - $this->commentable = true; +// if($this->writable) +// $this->commentable = true; + + $item->set_commentable(false); + $ob_hash = (($this->observer) ? $this->observer['xchan_hash'] : ''); + + if(($item->get_data_value('author_xchan') === $ob_hash) || ($item->get_data_value('owner_xchan') === $ob_hash)) + $item->set_commentable(true); if($item->get_data_value('item_flags') & ITEM_NOCOMMENT) { - $this->commentable = false; + $item->set_commentable(false); } - elseif(($this->observer) && (! $this->writable)) { - $this->commentable = can_comment_on_post($this->observer['xchan_hash'],$item->data); + elseif(($this->observer) && (! $item->is_commentable())) { + $item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data)); } - - - $item->set_conversation($this); $this->threads[] = $item; return end($this->threads); diff --git a/include/ItemObject.php b/include/ItemObject.php index 0256160e9..681757a09 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -14,6 +14,7 @@ class Item extends BaseObject { public $data = array(); private $template = 'conv_item.tpl'; private $comment_box_template = 'comment_item.tpl'; + private $commentable = false; private $toplevel = false; private $children = array(); private $parent = null; @@ -295,6 +296,15 @@ class Item extends BaseObject { return $this->threaded; } + + public function set_commentable($val) { + $this->commentable = $val; + } + + public function is_commentable() { + return $this->commentable; + } + /** * Add a child item */ @@ -480,7 +490,9 @@ class Item extends BaseObject { $comment_box = ''; $conv = $this->get_conversation(); - if(! $conv->is_commentable()) +// logger('Commentable conv: ' . $conv->is_commentable()); + + if(! $this->is_commentable()) return; $template = get_markup_template($this->get_comment_box_template()); diff --git a/include/zot.php b/include/zot.php index a98aca711..efcc4abaa 100644 --- a/include/zot.php +++ b/include/zot.php @@ -983,7 +983,10 @@ function public_recips($msg) { else $sql = " where (( " . $col . " & " . PERMS_NETWORK . " ) or ( " . $col . " & " . PERMS_PUBLIC . ")) "; - $r = q("select channel_hash as hash from channel " . $sql ); + + $r = q("select channel_hash as hash from channel $sql or channel_hash = '%s' ", + dbesc($msg['notify']['sender']['hash']) + ); if(! $r) $r = array(); -- cgit v1.2.3 From 35993bcfecb12b4dfb8507b1989b1ddc3c2e4182 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Fri, 20 Sep 2013 21:58:20 +0200 Subject: Enable likes again on posts --- include/ItemObject.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 681757a09..62a8c9c42 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -164,7 +164,7 @@ class Item extends BaseObject { ); } - if($conv->is_commentable()) { + if($this->is_commentable()) { $like = array( t("I like this \x28toggle\x29"), t("like")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); if ($shareable) -- cgit v1.2.3 From b520f3547f3543805110bfe9d5e5828d310df208 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Fri, 20 Sep 2013 23:50:23 +0200 Subject: Mark child posts as commentable when parent is set to commentable --- include/ItemObject.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 62a8c9c42..6c43d4e9e 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -296,9 +296,10 @@ class Item extends BaseObject { return $this->threaded; } - public function set_commentable($val) { $this->commentable = $val; + foreach($this->get_children() as $child) + $child->set_commentable($val); } public function is_commentable() { -- cgit v1.2.3 From 1126d8f2e3ee8356cf619e9e817fb448079634e6 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Sep 2013 17:58:11 -0700 Subject: hopefully this will go over a bit better - check post owner permissions as well as local owner permissions for comments during submission, since the comment was being blindly accepted on the local system due to only checking the profile owner. Also change collections query to include only top-level posts by a member of the collection. --- include/items.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a60e3fdd6..4e8a5c46f 100755 --- a/include/items.php +++ b/include/items.php @@ -68,6 +68,8 @@ function can_comment_on_post($observer_xchan,$item) { return false; if($item['comment_policy'] === 'none') return false; + if($observer_xchan === $item['author_xchan'] || $observer_xchan === $item['owner_xchan']) + return true; switch($item['comment_policy']) { case 'self': if($observer_xchan === $item['author_xchan'] || $observer_xchan === $item['owner_xchan']) @@ -3660,7 +3662,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C info( t('Group is empty')); } - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and item_restrict = 0 ) "; + $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent and item_restrict = 0 ) "; } elseif($arr['cid'] && $uid) { -- cgit v1.2.3 From fb03195c3f0dd461a0e8b809814f3cfbef515980 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Sep 2013 18:07:16 -0700 Subject: OK, sure. --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index c3f29295e..254453ad1 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -919,7 +919,7 @@ function item_photo_menu($item){ t("View Status") => $status_link, t("View Profile") => $profile_link, t("View Photos") => $photos_link, - t("Network Posts") => $posts_link, + t("Matrix Activity") => $posts_link, t("Edit Contact") => $contact_url, t("Send PM") => $pm_url, t("Poke") => $poke_link -- cgit v1.2.3 From 15ae108832aa94fdc098703de183bbf61baba58a Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Sep 2013 18:41:15 -0700 Subject: missing uid check on comanche_block to ensure we get the block with that name that we own --- include/comanche.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 56a16fd3b..eb0de96c7 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -86,7 +86,8 @@ function comanche_replace_region($match) { function comanche_block($name) { $o = ''; - $r = q("select * from item left join item_id on iid = item_id and item_id.uid = item.uid and service = 'BUILDBLOCK' and sid = '%s' limit 1", + $r = q("select * from item left join item_id on iid = item_id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", + intval($a->profile['profile_uid']), dbesc($name) ); if($r) { -- cgit v1.2.3 From 43e290f4c05e9b558abd8118f2282898f3d488f8 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Sep 2013 19:14:57 -0700 Subject: fix contact comment permissions --- include/items.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4e8a5c46f..37ff7db3c 100755 --- a/include/items.php +++ b/include/items.php @@ -80,8 +80,13 @@ function can_comment_on_post($observer_xchan,$item) { break; case 'contacts': case '': - if(($item['owner']['abook_xchan']) && ($item['owner']['abook_their_perms'] & PERMS_W_COMMENT)) + if(array_key_exists('owner',$item)) { + if(($item['owner']['abook_xchan']) && ($item['owner']['abook_their_perms'] & PERMS_W_COMMENT)) + return true; + } + else { return true; + } break; default: break; -- cgit v1.2.3 From fd2379530cd879861c3abab747bddffd3b3e3fdf Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 20 Sep 2013 20:15:53 -0700 Subject: hopefully(?) the final word on remote comment permissions --- include/items.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 37ff7db3c..44917233f 100755 --- a/include/items.php +++ b/include/items.php @@ -63,6 +63,7 @@ function collect_recipients($item,&$private) { } + function can_comment_on_post($observer_xchan,$item) { if(! $observer_xchan) return false; @@ -84,9 +85,6 @@ function can_comment_on_post($observer_xchan,$item) { if(($item['owner']['abook_xchan']) && ($item['owner']['abook_their_perms'] & PERMS_W_COMMENT)) return true; } - else { - return true; - } break; default: break; -- cgit v1.2.3 From cdfb5f9dc740734fbd95363a026ab44ae1dd9d94 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Sep 2013 20:38:24 -0700 Subject: adult channel setting --- include/zot.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index efcc4abaa..ba55880ee 100644 --- a/include/zot.php +++ b/include/zot.php @@ -469,6 +469,11 @@ function import_xchan($arr) { else $new_flags = $r[0]['xchan_flags']; + $adult = (($r[0]['xchan_flags'] & XCHAN_FLAGS_SELFCENSORED) ? true : false); + $adult_changed = ((intval($adult) != intval($arr['adult_content'])) ? true : false); + if($adult_changed) + $new_flags = $new_flags ^ XCHAN_FLAGS_SELFCENSORED; + if(($r[0]['xchan_name_date'] != $arr['name_updated']) || ($r[0]['xchan_connurl'] != $arr['connections_url']) @@ -511,6 +516,8 @@ function import_xchan($arr) { $new_flags = XCHAN_FLAGS_HIDDEN; else $new_flags = 0; + if($arr['adult_content']) + $new_flags |= XCHAN_FLAGS_SELFCENSORED; $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags) -- cgit v1.2.3 From 44354c1aa82796fae1e0180703ae335b394a8adf Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Sep 2013 20:55:55 -0700 Subject: bug #150, if deny access is present but nobody has been allowed, create an allow list containing everybody in your address book. Then subtract those who are denied. --- include/items.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 44917233f..4aecf9174 100755 --- a/include/items.php +++ b/include/items.php @@ -24,10 +24,31 @@ function collect_recipients($item,&$private) { if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) { $allow_people = expand_acl($item['allow_cid']); $allow_groups = expand_groups(expand_acl($item['allow_gid'])); + + $recipients = array_unique(array_merge($allow_people,$allow_groups)); + + // if you specifically deny somebody but haven't allowed anybody, we'll allow everybody in your + // address book minus the denied connections. The post is still private and can't be seen publicly + // as that would allow the denied person to see the post by logging out. + + if((! $item['allow_cid']) && (! $item['allow_gid'])) { + $r = q("select * from abook where abook_channel = %d and not (abook_flags & %d) and not (abook_flags & %d) and not (abook_flags & %d)", + intval($item['uid']), + intval(ABOOK_FLAG_SELF), + intval(ABOOK_FLAG_PENDING), + intval(ABOOK_FLAG_ARCHIVED) + ); + + if($r) { + foreach($r as $rr) { + $recipients[] = $rr['abook_xchan']; + } + } + } + $deny_people = expand_acl($item['deny_cid']); $deny_groups = expand_groups(expand_acl($item['deny_gid'])); - $recipients = array_unique(array_merge($allow_people,$allow_groups)); $deny = array_unique(array_merge($deny_people,$deny_groups)); $recipients = array_diff($recipients,$deny); $private = true; -- cgit v1.2.3 From 956d275693c451c4d9ba60751704b80257f37433 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Sep 2013 22:52:48 -0700 Subject: fixes for display and search privacy enforcement --- include/security.php | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index 4738e473b..632b8d607 100644 --- a/include/security.php +++ b/include/security.php @@ -302,16 +302,19 @@ function public_permissions_sql($observer_hash) { foreach($groups as $g) $gs .= '|<' . $g . '>'; } - $sql = sprintf( - " OR (( NOT (deny_cid like '%s' OR deny_gid REGEXP '%s') - AND ( allow_cid like '%s' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '') ) - )) - ", - dbesc(protect_sprintf( '%<' . $observer_hash . '>%')), - dbesc($gs), - dbesc(protect_sprintf( '%<' . $observer_hash . '>%')), - dbesc($gs) - ); + $sql = ''; + if($observer_hash) { + $sql = sprintf( + " OR (( NOT (deny_cid like '%s' OR deny_gid REGEXP '%s') + AND ( allow_cid like '%s' OR allow_gid REGEXP '%s' OR ( allow_cid = '' AND allow_gid = '') ) + )) + ", + dbesc(protect_sprintf( '%<' . $observer_hash . '>%')), + dbesc($gs), + dbesc(protect_sprintf( '%<' . $observer_hash . '>%')), + dbesc($gs) + ); + } return $sql; } @@ -424,6 +427,29 @@ function stream_perms_api_uids($perms_min = PERMS_SITE) { $str .= ','; $str .= intval($rr); } +logger('stream_perms_api_uids: ' . $str); return $str; } +function stream_perms_xchans($perms_min = PERMS_SITE) { + $ret = array(); + if(local_user()) + $ret[] = get_observer_hash(); + $r = q("select channel_hash from channel where channel_r_stream <= %d", + intval($perms_min) + ); + if($r) + foreach($r as $rr) + if(! in_array($rr['channel_hash'],$ret)) + $ret[] = $rr['channel_hash']; + + $str = ''; + if($ret) + foreach($ret as $rr) { + if($str) + $str .= ','; + $str .= "'" . dbesc($rr) . "'"; + } +logger('stream_perms_xchans: ' . $str); + return $str; +} -- cgit v1.2.3 From a2b20bd58f0b1c466235a96c41846aba613ea31b Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Sep 2013 22:58:59 -0700 Subject: one more edge case in the public perms - don't match perms = 0 which is private, this and prior checkin are for issue #114 --- include/security.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index 632b8d607..1181e6bf2 100644 --- a/include/security.php +++ b/include/security.php @@ -412,7 +412,7 @@ function stream_perms_api_uids($perms_min = PERMS_SITE) { $ret = array(); if(local_user()) $ret[] = local_user(); - $r = q("select channel_id from channel where channel_r_stream <= %d", + $r = q("select channel_id from channel where channel_r_stream > 0 and channel_r_stream <= %d", intval($perms_min) ); if($r) @@ -435,7 +435,8 @@ function stream_perms_xchans($perms_min = PERMS_SITE) { $ret = array(); if(local_user()) $ret[] = get_observer_hash(); - $r = q("select channel_hash from channel where channel_r_stream <= %d", + + $r = q("select channel_hash from channel where channel_r_stream > 0 and channel_r_stream <= %d", intval($perms_min) ); if($r) -- cgit v1.2.3 From e79bc2924422578a9eb8fc44be59e619a1c158b5 Mon Sep 17 00:00:00 2001 From: zottel Date: Mon, 23 Sep 2013 13:26:23 +0200 Subject: add [observer] tags and [observer.baseurl] --- include/bbcode.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 997cbac2e..30bfdad56 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -217,6 +217,18 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $ev = bbtoevent($Text); + // process [observer] tags before we do anything else because we might + // be stripping away stuff that then doesn't need to be worked on anymore + $observer = $a->get_observer(); + if (strpos($Text,'[/observer]') !== false) { + if ($observer) { + $Text = preg_replace("/\[observer(\=1)?\](.*?)\[\/observer\]/ism", '$2', $Text); + $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); + } else { + $Text = preg_replace("/\[observer(\=1)?\].*?\[\/observer\]/ism", '', $Text); + $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); + } + } // Replace any html brackets with HTML Entities to prevent executing HTML or script // Don't use strip_tags here because it breaks [url] search by replacing & with amp @@ -246,6 +258,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { // Set up the parameters for a MAIL search string $MAILSearchString = $URLSearchString; + // replace [observer.baseurl] + if ($observer) { + $obsBaseURL = $observer['xchan_url']; + $obsBaseURL = preg_replace("/\/channel\/.*$/", '', $obsBaseURL); + $Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text); + } else { + $Text = str_replace('[observer.baseurl]', '', $Text); + } // Perform URL Search -- cgit v1.2.3 From 1f916adfb889c877ff975be75274fb7f3ac37b1f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 23 Sep 2013 18:38:08 -0700 Subject: spice this up a little bit... --- include/bbcode.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 30bfdad56..7d7bf1de4 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -263,8 +263,16 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $obsBaseURL = $observer['xchan_url']; $obsBaseURL = preg_replace("/\/channel\/.*$/", '', $obsBaseURL); $Text = str_replace('[observer.baseurl]', $obsBaseURL, $Text); + $Text = str_replace('[observer.url]',$observer['xchan_url'], $Text); + $Text = str_replace('[observer.name]',$observer['xchan_name'], $Text); + $Text = str_replace('[observer.address]',$observer['xchan_addr'], $Text); + $Text = str_replace('[observer.photo]','[zmg]'.$observer['xchan_photo_l'].'[/zmg]', $Text); } else { $Text = str_replace('[observer.baseurl]', '', $Text); + $Text = str_replace('[observer.url]','', $Text); + $Text = str_replace('[observer.name]','', $Text); + $Text = str_replace('[observer.address]','', $Text); + $Text = str_replace('[observer.photo]','', $Text); } // Perform URL Search -- cgit v1.2.3 From d4ea56a77ef408347a9d73b36e8066334b8835ea Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Sep 2013 05:20:29 -0700 Subject: reduce susceptibility to bleichenberger attack --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 40df8bd89..be5e2338d 100755 --- a/include/text.php +++ b/include/text.php @@ -1312,7 +1312,7 @@ function get_plink($item) { $a = get_app(); if (x($item,'plink') && ($item['item_private'] != 1)) { return array( - 'href' => $item['plink'], + 'href' => zid($item['plink']), 'title' => t('link to source'), ); } -- cgit v1.2.3 From 5092ae9e2bd5edfc67a82c56e803bdcb203386f8 Mon Sep 17 00:00:00 2001 From: zottel Date: Tue, 24 Sep 2013 14:35:47 +0200 Subject: Fix observer=1 tag. Using only observer without =1 won't work anymore now. --- include/bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 7d7bf1de4..9b9c954c1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -222,10 +222,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) { $observer = $a->get_observer(); if (strpos($Text,'[/observer]') !== false) { if ($observer) { - $Text = preg_replace("/\[observer(\=1)?\](.*?)\[\/observer\]/ism", '$2', $Text); + $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); } else { - $Text = preg_replace("/\[observer(\=1)?\].*?\[\/observer\]/ism", '', $Text); + $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text); $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); } } -- cgit v1.2.3 From d62508072c714305e991b46cc388fbf4bd4be98e Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Sep 2013 19:43:28 -0700 Subject: don't send email notifications for likes (as comment notifications). We'll need a separate preference for whether you want notifications for likes. --- include/enotify.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index b2a4f5856..147023f41 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -51,9 +51,9 @@ function notification($params) { $additional_mail_header = ""; if(array_key_exists('item',$params)) { + require_once('include/conversation.php'); // if it's a normal item... if(array_key_exists('verb',$params['item'])) { - require_once('include/conversation.php'); // localize_item() alters the original item so make a copy first $i = $params['item']; logger('calling localize'); @@ -89,6 +89,11 @@ function notification($params) { if($params['type'] == NOTIFY_COMMENT) { // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); + // ignore like/unlike activity on posts - they probably require a sepearate notification preference + + if(array_key_exists('item',$params) && (! visible_activity($params['item']))) + return; + $parent_id = $params['parent']; // Check to see if there was already a notify for this post. -- cgit v1.2.3 From 00e5ded1c892a94c79a854327b44d8673cc43274 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 24 Sep 2013 20:13:53 -0700 Subject: populate the new fields in the directory updates table --- include/zot.php | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index ba55880ee..ae470b70b 100644 --- a/include/zot.php +++ b/include/zot.php @@ -411,7 +411,7 @@ function zot_register_hub($arr) { // If the xchan already exists, update the name and photo if these have changed. // -function import_xchan($arr) { +function import_xchan($arr,$ud_flags = 1) { $ret = array('success' => false); $dirmode = intval(get_config('system','directory_mode')); @@ -688,7 +688,7 @@ function import_xchan($arr) { if($dirmode != DIRECTORY_MODE_NORMAL) { if(array_key_exists('profile',$arr) && is_array($arr['profile'])) { - $profile_changed = import_directory_profile($xchan_hash,$arr['profile']); + $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags); if($profile_changed) { $what .= 'profile '; $changed = true; @@ -718,7 +718,7 @@ function import_xchan($arr) { if($changed) { $guid = random_string() . '@' . get_app()->get_hostname(); - update_modtime($xchan_hash,$guid); + update_modtime($xchan_hash,$guid,$arr['address'],$ud_flags); logger('import_xchan: changed: ' . $what,LOGGER_DEBUG); } @@ -1371,7 +1371,12 @@ function process_profile_delivery($sender,$arr,$deliveries) { // deliveries is irrelevant, what to do about birthday notification....? logger('process_profile_delivery', LOGGER_DEBUG); - import_directory_profile($sender['hash'],$arr); + + $r = q("select xchan_addr from xchan where xchan_hash = '%s' limit 1", + dbesc($sender['hash']) + ); + if($r) + import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1); } @@ -1382,7 +1387,7 @@ function process_profile_delivery($sender,$arr,$deliveries) { * */ -function import_directory_profile($hash,$profile) { +function import_directory_profile($hash,$profile,$addr,$ud_flags = 1) { logger('import_directory_profile', LOGGER_DEBUG); if(! $hash) @@ -1489,7 +1494,7 @@ function import_directory_profile($hash,$profile) { call_hooks('import_directory_profile', $d); if($d['update']) - update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname()); + update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname(), $addr, $ud_flags); return $d['update']; } @@ -1529,11 +1534,14 @@ function import_directory_keywords($hash,$keywords) { } -function update_modtime($hash,$guid) { - q("insert into updates (ud_hash, ud_guid, ud_date) values ( '%s', '%s', '%s' )", +function update_modtime($hash,$guid,$addr,$flags = 0) { + + q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )", dbesc($hash), dbesc($guid), - dbesc(datetime_convert()) + dbesc(datetime_convert()), + intval($flags), + dbesc($addr) ); } -- cgit v1.2.3 From 6519433301a571d8e12ffa24b56534bb2e3afe5f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Sep 2013 21:22:36 -0700 Subject: suppress creating the directory update record for profile updates which are part of the normal import_xchan sequence - otherwise we get two for every change. Create it normally if we are called with a profile_update message and don't go through the whole import_xchan thing. --- include/config.php | 9 +++++++++ include/zot.php | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/config.php b/include/config.php index 38840f5e4..ccd907424 100644 --- a/include/config.php +++ b/include/config.php @@ -24,6 +24,15 @@ function load_config($family) { if(! array_key_exists('config_loaded',$a->config[$family])) { $r = q("SELECT * FROM config WHERE cat = '%s'", dbesc($family)); + + // This is often one of the earliest database calls in the life of the page. + // If the DB was successfully opened, but we can't read from it, + // we must assume catastrophic failure of the DB. Report the system down. + + if($r === false) { + system_unavailable(); + } + if($r !== false) { if($r) { foreach($r as $rr) { diff --git a/include/zot.php b/include/zot.php index ae470b70b..0290bc402 100644 --- a/include/zot.php +++ b/include/zot.php @@ -688,7 +688,7 @@ function import_xchan($arr,$ud_flags = 1) { if($dirmode != DIRECTORY_MODE_NORMAL) { if(array_key_exists('profile',$arr) && is_array($arr['profile'])) { - $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags); + $profile_changed = import_directory_profile($xchan_hash,$arr['profile'],$arr['address'],$ud_flags, 1); if($profile_changed) { $what .= 'profile '; $changed = true; @@ -1376,7 +1376,7 @@ function process_profile_delivery($sender,$arr,$deliveries) { dbesc($sender['hash']) ); if($r) - import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1); + import_directory_profile($sender['hash'],$arr,$r[0]['xchan_addr'], 1, 0); } @@ -1387,7 +1387,7 @@ function process_profile_delivery($sender,$arr,$deliveries) { * */ -function import_directory_profile($hash,$profile,$addr,$ud_flags = 1) { +function import_directory_profile($hash,$profile,$addr,$ud_flags = 1, $suppress_update = 0) { logger('import_directory_profile', LOGGER_DEBUG); if(! $hash) @@ -1493,7 +1493,7 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = 1) { $d = array('xprof' => $arr, 'profile' => $profile, 'update' => $update); call_hooks('import_directory_profile', $d); - if($d['update']) + if(($d['update']) && (! $suppress_update)) update_modtime($arr['xprof_hash'],random_string() . '@' . get_app()->get_hostname(), $addr, $ud_flags); return $d['update']; } -- cgit v1.2.3 From 689cea3170968e1e488fb6fe84505ca7c9f6a2bf Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Thu, 26 Sep 2013 18:26:03 +0100 Subject: Typo --- include/page_widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/page_widgets.php b/include/page_widgets.php index 23d6d25ba..d70281afc 100644 --- a/include/page_widgets.php +++ b/include/page_widgets.php @@ -5,7 +5,7 @@ function writepages_widget ($who,$which){ return replace_macros(get_markup_template('write_pages.tpl'), array( '$new' => t('New Page'), '$newurl' => "webpages/$who", - '$edit' => t('edit'), + '$edit' => t('Edit'), '$editurl' => "editwebpage/$who/$which" )); } -- cgit v1.2.3 From 26492b3ad486bbcd7e5bb96289a7ade1bd00a186 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Wed, 25 Sep 2013 21:43:21 +0200 Subject: Add explanation why public comments are disabled. --- include/items.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 4aecf9174..25bcf0253 100755 --- a/include/items.php +++ b/include/items.php @@ -98,6 +98,10 @@ function can_comment_on_post($observer_xchan,$item) { return true; break; case 'public': + # We don't allow public comments yet, until a policy + # for dealing with anonymous comments is in place with + # a means to moderate comments. Until that time, return + # false. return false; break; case 'contacts': @@ -3874,4 +3878,4 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } return $items; -} \ No newline at end of file +} -- cgit v1.2.3 From edc5566f79c94f7ad994eccc7a8bb0e586961cf4 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Sep 2013 16:25:28 -0700 Subject: structure for channel unions --- include/identity.php | 2 +- include/zot.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/identity.php b/include/identity.php index 98209c8ae..d6b6735f6 100644 --- a/include/identity.php +++ b/include/identity.php @@ -48,7 +48,7 @@ function validate_channelname($name) { function create_dir_account() { - create_account(array( + create_identity(array( 'account_id' => 'xxx', // This will create an identity with an (integer) account_id of 0, but account_id is required 'nickname' => 'dir', 'name' => 'Directory', diff --git a/include/zot.php b/include/zot.php index 0290bc402..0658f1738 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1422,9 +1422,10 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = 1, $suppress_ // Self censored, make it so // These are not translated, so the German "erwachsenen" keyword will not censor the directory profile. Only the English form - "adult". + if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) { q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1", - intval(XCHAN_FLAGS_CENSORED), + intval(XCHAN_FLAGS_SELFCENSORED), dbesc($hash) ); } -- cgit v1.2.3 From 017db2994714b95c974ee87b841017a6da0b6557 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Sep 2013 19:34:45 -0700 Subject: aggregate channels --- include/items.php | 112 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 86 insertions(+), 26 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 25bcf0253..0e38de319 100755 --- a/include/items.php +++ b/include/items.php @@ -2063,6 +2063,12 @@ function tag_deliver($uid,$item_id) { logger('tag_deliver: tag permission denied for ' . $u[0]['channel_address']); } + + $union = check_item_source($uid,$item); + if($union) + logger('check_item_source returns true'); + + // This might be a followup by the original post author to a tagged forum // If so setup a second delivery chain @@ -2129,42 +2135,44 @@ function tag_deliver($uid,$item_id) { intval(ITEM_MENTIONSME), intval($item_id) ); - } - else - return; - // 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 + // At this point we've determined that the person receiving this post was mentioned in it or it is a union. + // Now let's check if this mention was inside a reshare so we don't spam a forum - $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']); + $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']); - $pattern = '/@\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'],'/') . '\[\/zrl\]/'; + $pattern = '/@\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($u[0]['channel_name'],'/') . '\[\/zrl\]/'; - if(! preg_match($pattern,$body,$matches)) { - logger('tag_deliver: mention was in a reshare - ignoring'); - return; - } + if(! preg_match($pattern,$body,$matches)) { + logger('tag_deliver: mention was in a reshare - ignoring'); + return; + } - // All good. - // Send a notification + // All good. + // Send a notification - require_once('include/enotify.php'); - notification(array( - 'to_xchan' => $u[0]['channel_hash'], - 'from_xchan' => $item['author_xchan'], - 'type' => NOTIFY_TAGSELF, - 'item' => $item, - 'link' => $i[0]['llink'], - 'verb' => ACTIVITY_TAG, - 'otype' => 'item' - )); + require_once('include/enotify.php'); + notification(array( + 'to_xchan' => $u[0]['channel_hash'], + 'from_xchan' => $item['author_xchan'], + 'type' => NOTIFY_TAGSELF, + 'item' => $item, + 'link' => $i[0]['llink'], + 'verb' => ACTIVITY_TAG, + 'otype' => 'item' + )); + + + if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) { + logger('tag_delivery denied for uid ' . $uid . ' and xchan ' . $item['author_xchan']); + return; + } + } - if(! perm_is_allowed($uid,$item['author_xchan'],'tag_deliver')) { - logger('tag_delivery denied for uid ' . $uid . ' and xchan ' . $item['author_xchan']); + if((! $mention) && (! $union)) return; - } // tgroup delivery - setup a second delivery chain @@ -2273,6 +2281,58 @@ function tgroup_check($uid,$item) { } +/** + * @function check_item_source($uid,$item) + * @param $uid + * @param $item + * + * @description + * Checks to see if this item owner is referenced as a source for this channel and if the post + * matches the rules for inclusion in this channel. Returns true if we should create a second delivery + * chain and false if none of the rules apply, or if the item is private. + */ + + +function check_item_source($uid,$item) { + + if($item['item_private']) + return false; + + + $r = q("select * from source where src_channel_id = %d and src_xchan = '%s' limit 1", + intval($uid), + dbesc($item['owner_xchan']) + ); + + if(! $r) + return false; + + if($r[0]['src_channel_xchan'] === $item['owner_xchan']) + return false; + + if(! $r[0]['src_patt']) + return true; + + $tags = ((count($items['term'])) ? $items['term'] : false); + + $words = explode("\n",$r[0]['src_patt']); + if($words) { + foreach($words as $word) { + if(substr($word,0,1) === '#' && $tags) { + foreach($tags as $t) + if($t['type'] == TERM_HASHTAG && substr($t,1) === $word) + return true; + } + if(stristr($item['body'],$word) !== false) + return true; + } + } + return false; +} + + + + function mail_store($arr) { if(! $arr['channel_id']) { -- cgit v1.2.3 From 4b3c56517446aa4f04c78887794cb49bda20c086 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Sep 2013 19:58:24 -0700 Subject: convert to plaintext before matching words in body. Otherwise every post I make with a link in it is going to match a test for zot. --- include/items.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 0e38de319..79229acfe 100755 --- a/include/items.php +++ b/include/items.php @@ -2313,6 +2313,10 @@ function check_item_source($uid,$item) { if(! $r[0]['src_patt']) return true; + require_once('include/html2plain.php'); + $text = prepare_text($item['body'],$item['mimetype']); + $text = html2plain($text); + $tags = ((count($items['term'])) ? $items['term'] : false); $words = explode("\n",$r[0]['src_patt']); @@ -2323,7 +2327,7 @@ function check_item_source($uid,$item) { if($t['type'] == TERM_HASHTAG && substr($t,1) === $word) return true; } - if(stristr($item['body'],$word) !== false) + if(stristr($text,$word) !== false) return true; } } -- cgit v1.2.3 From 110974eb55d58db26f1312d19ae4cdf09bbc796f Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Sep 2013 04:41:12 -0700 Subject: fix can_comment_on_post when viewing wall-to-wall --- include/ConversationObject.php | 5 ++++- include/items.php | 21 ++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 5157dad05..bf4300cb1 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -154,7 +154,10 @@ class Conversation extends BaseObject { $item->set_commentable(false); } elseif(($this->observer) && (! $item->is_commentable())) { - $item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data)); + if((array_key_exists('owner',$item->data)) && ($item->data['owner']['abook_flags'] & ABOOK_FLAG_SELF)) + $item->set_commentable(perm_is_allowed($this->profile_owner,$this->observer['xchan_hash'],'post_comments')); + else + $item->set_commentable(can_comment_on_post($this->observer['xchan_hash'],$item->data)); } $item->set_conversation($this); diff --git a/include/items.php b/include/items.php index 79229acfe..b58b4415e 100755 --- a/include/items.php +++ b/include/items.php @@ -83,9 +83,20 @@ function collect_recipients($item,&$private) { } - +/** + * @function can_comment_on_post($observer_xchan,$item); + * + * This function examines the comment_policy attached to an item and decides if the current observer has + * sufficient privileges to comment. This will normally be called on a remote site where perm_is_allowed() + * will not be suitable because the post owner does not have a local channel_id. + * Generally we should look at the item - in particular the author['book_flags'] and see if ABOOK_FLAG_SELF is set. + * If it is, you should be able to use perm_is_allowed( ... 'post_comments'), and if it isn't you need to call + * can_comment_on_post() function can_comment_on_post($observer_xchan,$item) { + +// logger('can_comment_on_post: comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG); + if(! $observer_xchan) return false; if($item['comment_policy'] === 'none') @@ -98,10 +109,10 @@ function can_comment_on_post($observer_xchan,$item) { return true; break; case 'public': - # We don't allow public comments yet, until a policy - # for dealing with anonymous comments is in place with - # a means to moderate comments. Until that time, return - # false. + // We don't allow public comments yet, until a policy + // for dealing with anonymous comments is in place with + // a means to moderate comments. Until that time, return + // false. return false; break; case 'contacts': -- cgit v1.2.3 From 6ca6bc2dd8cadb509ad84e184a11a80c6441921f Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 28 Sep 2013 05:03:58 -0700 Subject: close comment --- include/ConversationObject.php | 1 + include/items.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/ConversationObject.php b/include/ConversationObject.php index bf4300cb1..bb144d893 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -7,6 +7,7 @@ require_once('boot.php'); require_once('include/BaseObject.php'); require_once('include/ItemObject.php'); require_once('include/text.php'); +require_once('include/items.php'); /** * A list of threads diff --git a/include/items.php b/include/items.php index b58b4415e..45d9d28fc 100755 --- a/include/items.php +++ b/include/items.php @@ -92,7 +92,7 @@ function collect_recipients($item,&$private) { * Generally we should look at the item - in particular the author['book_flags'] and see if ABOOK_FLAG_SELF is set. * If it is, you should be able to use perm_is_allowed( ... 'post_comments'), and if it isn't you need to call * can_comment_on_post() - + */ function can_comment_on_post($observer_xchan,$item) { // logger('can_comment_on_post: comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG); -- cgit v1.2.3 From 3cf5e5effd059feb708cde7e97966b00c23134e8 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Sat, 28 Sep 2013 19:05:50 +0100 Subject: Fix Comanche menus --- include/comanche.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index eb0de96c7..42c8e045c 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -1,7 +1,7 @@ profile['profile_uid'],get_observer_hash()); - return render_menu($m); + return menu_render($m); } function comanche_replace_region($match) { -- cgit v1.2.3 From a06f1f95944ffa578296268ecde3d77f42b69229 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Sep 2013 02:47:36 -0700 Subject: Issue #158 --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 45d9d28fc..0d51946e4 100755 --- a/include/items.php +++ b/include/items.php @@ -3770,9 +3770,9 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } elseif($arr['cid'] && $uid) { - $r = q("SELECT * from abook where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ") limit 1", + $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and not ( abook_flags & " . intval(ABOOK_FLAG_BLOCKED) . ") limit 1", intval($arr['cid']), - intval($uid) + intval(local_user()) ); if($r) { $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) "; -- cgit v1.2.3 From 9212fd0ecc4f740704279ea896a0105e48dc70fa Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Sun, 29 Sep 2013 16:40:15 +0100 Subject: Issue #117 --- include/text.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index be5e2338d..afd46f396 100755 --- a/include/text.php +++ b/include/text.php @@ -1835,16 +1835,17 @@ function json_decode_plus($s) { function design_tools() { -// FIXME - this should be a template - - $o = '
'; - $o .= '

' . t('Design') . '

'; - $o .= '' . t('Blocks') . '' . EOL; - $o .= '' . t('Menus') . '' . EOL; - $o .= '' . t('Layouts') . '' . EOL; - $o .= '' . t('Pages') . '' . EOL; - $o .= '
'; - return $o; +$channel = $channel = get_app()->get_channel(); +$who = $channel['channel_address']; + +return replace_macros(get_markup_template('design_tools.tpl'), array( + '$title' => t('Design'), + '$who' => $who, + '$blocks' => t('Blocks'), + '$menus' => t('Menus'), + '$layout' => t('Layouts'), + '$pages' => t('Pages') + )); } -- cgit v1.2.3 From 3c42989fc44802b005b6687c7879d389eec0eaac Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Sun, 29 Sep 2013 16:45:21 +0100 Subject: Typo --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index afd46f396..69c258488 100755 --- a/include/text.php +++ b/include/text.php @@ -1835,7 +1835,7 @@ function json_decode_plus($s) { function design_tools() { -$channel = $channel = get_app()->get_channel(); +$channel = get_app()->get_channel(); $who = $channel['channel_address']; return replace_macros(get_markup_template('design_tools.tpl'), array( -- cgit v1.2.3 From a26e48b013f6674e0cb96c143739b0d5c3f71f63 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Sep 2013 18:18:05 -0700 Subject: sources management page --- include/features.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/features.php b/include/features.php index 6272b33ea..9950039c0 100644 --- a/include/features.php +++ b/include/features.php @@ -35,6 +35,7 @@ function get_features() { t('Post Composition Features'), array('richtext', t('Richtext Editor'), t('Enable richtext editor')), array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')), + array('channel_sources', t('Channel Sources'), t('Automatically import channel content from other channels or feeds')), ), // Network Tools -- cgit v1.2.3 From bd0b4d8487484a1a6c4bbba9a6a382f7ff6ba4b4 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Sep 2013 18:34:41 -0700 Subject: remove the "Similar Interests" link until somebody makes it work --- include/contact_widgets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index bc7faebc3..af05f8c9f 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -47,7 +47,7 @@ function findpeople_widget() { '$hint' => t('Examples: Robert Morgenstein, Fishing'), '$findthem' => t('Find'), '$suggest' => t('Channel Suggestions'), - '$similar' => t('Similar Interests'), + '$similar' => '', // FIXME and uncomment when mod/match working // t('Similar Interests'), '$random' => t('Random Profile'), '$inv' => t('Invite Friends') )); -- cgit v1.2.3 From 0e95bae3d2338f8a3421eff13d1bce26568be4d3 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 29 Sep 2013 20:34:05 -0700 Subject: RSS feeds as channel sources. It's feasible and within reach, however there's a lot of work left to do. How bad does anybody want it? Let's find out... --- include/items.php | 80 ++++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 45 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 0d51946e4..dcd9eb6fc 100755 --- a/include/items.php +++ b/include/items.php @@ -1301,14 +1301,9 @@ function get_atom_elements($feed,$item) { $res['object'] .= '' . xmlify($body) . '' . "\n"; if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { - $body = html2bb_video($body); - - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - - $purifier = new HTMLPurifier($config); - $body = $purifier->purify($body); + $body = purify_html($body); $body = html2bbcode($body); + } $res['object'] .= '' . $body . '' . "\n"; @@ -1339,13 +1334,7 @@ function get_atom_elements($feed,$item) { $res['target'] .= '' . xmlify($body) . '' . "\n"; if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) { - $body = html2bb_video($body); - - $config = HTMLPurifier_Config::createDefault(); - $config->set('Cache.DefinitionImpl', null); - - $purifier = new HTMLPurifier($config); - $body = $purifier->purify($body); + $body = purify_html($body); $body = html2bbcode($body); } @@ -1384,6 +1373,7 @@ function get_atom_elements($feed,$item) { $arr = array('feed' => $feed, 'item' => $item, 'result' => $res); call_hooks('parse_atom', $arr); + logger('get_atom_elements: ' . print_r($res,true)); return $res; } @@ -2676,6 +2666,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) logger('consume_feed: empty input'); return; } + + // Want to see this work as a content source for the matrix? + // Read this: https://github.com/friendica/red/wiki/Service_Federation $feed = new SimplePie(); $feed->set_raw_data($xml); @@ -2692,12 +2685,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) // Check at the feed level for updated contact name and/or photo - $name_updated = ''; - $new_name = ''; - $photo_timestamp = ''; - $photo_url = ''; - $birthday = ''; - // process any deleted entries @@ -2719,7 +2706,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) /* $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` WHERE `mid` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", dbesc($mid), - intval($importer['uid']), + intval($importer['channel_id']), intval($contact['id']) ); */ @@ -2737,7 +2724,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) dbesc($when), dbesc(datetime_convert()), dbesc($item['mid']), - intval($importer['uid']) + intval($importer['channel_id']) ); } else { @@ -2748,7 +2735,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) dbesc($when), dbesc(datetime_convert()), dbesc($mid), - intval($importer['uid']) + intval($importer['channel_id']) ); } } @@ -2773,6 +2760,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $is_reply = false; $item_id = $item->get_id(); + +logger('consume_feed: processing ' . $item_id); + $rawthread = $item->get_item_tags( NAMESPACE_THREAD,'in-reply-to'); if(isset($rawthread[0]['attribs']['']['ref'])) { $is_reply = true; @@ -2784,11 +2774,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if($pass == 1) continue; - // not allowed to post -// FIXME - check permissions -// if($contact['rel'] == CONTACT_IS_FOLLOWER) -// continue; - // Have we seen it? If not, import it. @@ -2810,12 +2795,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), - intval($importer['uid']) + intval($importer['channel_id']) ); // Update content if 'updated' changes - if(count($r)) { + if($r) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. @@ -2827,7 +2812,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) dbesc($datarray['body']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc($item_id), - intval($importer['uid']) + intval($importer['channel_id']) ); } @@ -2836,7 +2821,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['parent_mid'] = $parent_mid; - $datarray['uid'] = $importer['uid']; + $datarray['uid'] = $importer['channel_id']; $datarray['contact-id'] = $contact['id']; if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) { $datarray['type'] = 'activity'; @@ -2860,7 +2845,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if($xt->type == ACTIVITY_OBJ_NOTE) { $r = q("select * from item where `mid` = '%s' AND `uid` = %d limit 1", dbesc($xt->id), - intval($importer['importer_uid']) + intval($importer['channel_id']) ); if(! count($r)) continue; @@ -2878,7 +2863,9 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } } - $xx = item_store($datarray); +logger('consume_feed: ' . print_r($datarray,true)); + +// $xx = item_store($datarray); $r = $xx['item_id']; continue; } @@ -2910,7 +2897,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if((x($datarray,'obj_type')) && ($datarray['obj_type'] === ACTIVITY_OBJ_EVENT)) { $ev = bbtoevent($datarray['body']); if(x($ev,'desc') && x($ev,'start')) { - $ev['uid'] = $importer['uid']; + $ev['uid'] = $importer['channel_id']; $ev['mid'] = $item_id; $ev['edited'] = $datarray['edited']; $ev['private'] = $datarray['private']; @@ -2919,23 +2906,23 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $ev['cid'] = $contact['id']; $r = q("SELECT * FROM `event` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), - intval($importer['uid']) + intval($importer['channel_id']) ); if(count($r)) $ev['id'] = $r[0]['id']; - $xyz = event_store($ev); +// $xyz = event_store($ev); continue; } } $r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), - intval($importer['uid']) + intval($importer['channel_id']) ); // Update content if 'updated' changes - if(count($r)) { + if($r) { if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) { // do not accept (ignore) an earlier edit than one we currently have. @@ -2947,7 +2934,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) dbesc($datarray['body']), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc($item_id), - intval($importer['uid']) + intval($importer['channel_id']) ); } @@ -2975,8 +2962,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } - if(! is_array($contact)) - return; +// if(! is_array($contact)) +// return; // This is my contact on another system, but it's really me. @@ -2987,7 +2974,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) } $datarray['parent_mid'] = $item_id; - $datarray['uid'] = $importer['uid']; + $datarray['uid'] = $importer['channel_id']; $datarray['contact-id'] = $contact['id']; if(! link_compare($datarray['owner-link'],$contact['url'])) { @@ -3005,17 +2992,20 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) // posting an @-tag delivery, which followers are allowed to do for certain // page types. Now that we've parsed the post, let's check if it is legit. Otherwise ignore it. - if(($contact['rel'] == CONTACT_IS_FOLLOWER) && (! tgroup_check($importer['uid'],$datarray))) + if(($contact['rel'] == CONTACT_IS_FOLLOWER) && (! tgroup_check($importer['channel_id'],$datarray))) continue; +logger('consume_feed: ' . print_r($datarray,true)); - $xx = item_store($datarray); +// $xx = item_store($datarray); $r = $xx['item_id']; continue; } } } + + } -- cgit v1.2.3 From 0497c441df7feabdbfeea41f2d7b5dca8fd16989 Mon Sep 17 00:00:00 2001 From: Olaf Conradi Date: Mon, 30 Sep 2013 09:59:22 +0200 Subject: ret_secret is not used --- include/zot.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 0658f1738..1a90481ff 100644 --- a/include/zot.php +++ b/include/zot.php @@ -788,10 +788,6 @@ function zot_fetch($arr) { logger('zot_fetch: no hub: ' . print_r($arr['sender'],true)); return; } - - - $ret_secret = json_encode(array($arr['secret'],'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey'))))); - $data = array( 'type' => 'pickup', @@ -802,7 +798,6 @@ function zot_fetch($arr) { 'secret_sig' => base64url_encode(rsa_sign($arr['secret'],get_config('system','prvkey'))) ); - $datatosend = json_encode(aes_encapsulate(json_encode($data),$ret_hub['hubloc_sitekey'])); $fetch = zot_zot($url,$datatosend); -- cgit v1.2.3 From e0391de90674e759a73d08517641e6207606493f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 13:42:29 -0700 Subject: there's no $a in comanche_block() (zottel) --- include/comanche.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 42c8e045c..526819572 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -85,9 +85,10 @@ function comanche_replace_region($match) { } function comanche_block($name) { + $o = ''; $r = q("select * from item left join item_id on iid = item_id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", - intval($a->profile['profile_uid']), + intval(get_app()->profile['profile_uid']), dbesc($name) ); if($r) { -- cgit v1.2.3 From e992cfeca9a80583b7cde12776fcfe279be02996 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 18:33:27 -0700 Subject: directory sync - this will either work, or it won't work, or it will possibly recurse and blow up the matrix. Hard to say. Do you feel lucky? Well do ya' ... punk? Rule #1 - don't mess with anything unless it's blowing up the matrix. If it doesn't blow up the matrix, but doesn't work, just let it go and let's figure out what it is doing and what it isn't doing. The flow is as follows: Once a day go out to all the directory servers besides yourself and grab a list of updates. This happens in the poller. If we've never seen them before add them to the updates table. The poller also looks to see if we're a directory server and have updates that haven't yet been processed. It calls onedirsync.php to process each one. If we contact the channel to update and don't find anything (we're just doing a basic zot_finger), set a ud_last timestamp. If this is set we will only try once a day for seven days. Then we stop trying to update. This will probably cause a spike the first time through because you haven't seen any updates before, but we spread out the load over your delivery interval. --- include/dir_fns.php | 64 +++++++++++++++++++++++-- include/onedirsync.php | 42 ++++++++++++++++ include/poller.php | 128 ++++++++++++++++++++++++++++--------------------- include/zot.php | 22 ++++++--- 4 files changed, 192 insertions(+), 64 deletions(-) create mode 100644 include/onedirsync.php (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 0b678fd91..585121434 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -13,7 +13,7 @@ function sync_directories($dirmode) { return; $r = q("select * from site where (site_flags & %d) and site_url != '%s'", - intval(DIRECTORY_MODE_PRIMARY), + intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY), dbesc(z_root()) ); @@ -34,21 +34,79 @@ function sync_directories($dirmode) { dbesc($r[0]['site_directory']) ); + $r = q("select * from site where (site_flags & %d) and site_url != '%s'", + intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY), + dbesc(z_root()) + ); + } + if(! $r) + return; + foreach($r as $rr) { + if(! $rr['site_directory']) + continue; + $x = z_fetch_url($rr['site_directory'] . '?f=&sync=' . urlencode($rr['site_sync'])); + if(! $x['success']) + continue; + $j = json_decode($x['body'],true); + if((! $j['transactions']) || (! is_array($j['transactions']))) + continue; + + q("update site set site_sync = '%s' where site_url = '%s' limit 1", + dbesc(datetime_convert()), + dbesc($rr['site_url']) + ); + logger('sync_directories: ' . $rr['site_url'] . ': ' . print_r($j,true), LOGGER_DATA); + + if(count($j['transactions'])) { + foreach($j['transactions'] as $t) { + $r = q("select * from updates where ud_guid = '%s' limit 1", + dbesc($t['transaction_id']) + ); + if($r) + continue; + $ud_flags = 0; + if(is_array($t['flags']) && in_array('deleted',$t['flags'])) + $ud_flags |= UPDATE_FLAGS_DELETED; + $z = q("insert into updates ( ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) + values ( '%s', '%s', '%s', '%d, '%s' ) ", + dbesc($t['hash']), + dbesc($t['transaction_id']), + dbesc($t['timestamp']), + intval($ud_flags), + dbesc($t['address']) + ); + } + } + } +} +function update_directory_entry($ud) { + logger('update_directory_entry: ' . print_r($ud,true), LOGGER_DATA); + if($ud['ud_addr'] && (! ($ud['ud_flags'] & UPDATE_FLAGS_DELETED))) { + $x = zot_finger($ud['ud_addr'],''); + if($x['success']) { + $j = json_decode($x['body'],true); + $y = import_xchan($j,0); + } + else { + $r = q("update updates set ud_last = '%s' where ud_addr = '%s'", + dbesc(datetime_convert()), + dbesc($ud['ud_addr']) + ); + } + } } - - function syncdirs($uid) { logger('syncdirs', LOGGER_DEBUG); diff --git a/include/onedirsync.php b/include/onedirsync.php new file mode 100644 index 000000000..b9c17628a --- /dev/null +++ b/include/onedirsync.php @@ -0,0 +1,42 @@ + 1) && (intval($argv[1]))) + $update_id = intval($argv[1]); + + if(! $update_id) { + logger('onedirsync: no update'); + return; + } + + $r = q("select * from updates where ud_id = %d limit 1", + intval($update_id) + ); + + if(! $r) + return; + if($r['ud_flags'] & UPDATE_FLAGS_UPDATED) + return; + + update_directory_entry($r[0]); + + return; +} + +if (array_search(__file__,get_included_files())===0){ + onedirsync_run($argv,$argc); + killme(); +} diff --git a/include/poller.php b/include/poller.php index f084005c7..05584a05d 100644 --- a/include/poller.php +++ b/include/poller.php @@ -69,6 +69,8 @@ function poller_run($argv, $argc){ $d1 = get_config('system','last_expire_day'); $d2 = intval(datetime_convert('UTC','UTC','now','d')); + $dirmode = get_config('system','directory_mode'); + if($d2 != intval($d1)) { // If this is a directory server, request a sync with an upstream @@ -76,7 +78,6 @@ function poller_run($argv, $argc){ // Pull remote changes and push local changes. // potential issue: how do we keep from creating an endless update loop? - $dirmode = get_config('system','directory_mode'); if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { require_once('include/dir_fns.php'); sync_directories($dirmode); @@ -171,76 +172,95 @@ function poller_run($argv, $argc){ ); - if(! $contacts) { - return; - } + if($contacts) { - foreach($contacts as $contact) { + foreach($contacts as $contact) { - $update = false; + $update = false; - $t = $contact['abook_updated']; - $c = $contact['abook_connected']; + $t = $contact['abook_updated']; + $c = $contact['abook_connected']; - if($c == $t) { - if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) - $update = true; - } - else { - // if we've never connected with them, start the mark for death countdown from now - - if($c == '0000-00-00 00:00:00') { - $r = q("update abook set abook_connected = '%s' where abook_id = %d limit 1", - dbesc(datetime_convert()), - intval($contact['abook_id']) - ); - $c = datetime_convert(); - $update = true; + if($c == $t) { + if(datetime_convert('UTC','UTC', 'now') > datetime_convert('UTC','UTC', $t . " + 1 day")) + $update = true; } + else { + // if we've never connected with them, start the mark for death countdown from now + + if($c == '0000-00-00 00:00:00') { + $r = q("update abook set abook_connected = '%s' where abook_id = %d limit 1", + dbesc(datetime_convert()), + intval($contact['abook_id']) + ); + $c = datetime_convert(); + $update = true; + } + + // He's dead, Jim + + if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) { + $r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d limit 1", + intval(ABOOK_FLAG_ARCHIVED), + intval($contact['abook_id']) + ); + $update = false; + continue; + } + + if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) { + $update = false; + continue; + } + + // might be dead, so maybe don't poll quite so often + + // recently deceased, so keep up the regular schedule for 3 days + + if((strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 3 day")) > 0) + && (strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 1 day")) > 0)) + $update = true; - // He's dead, Jim + // After that back off and put them on a morphine drip + + if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 2 day")) > 0) { + $update = true; + } - if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 30 day")) > 0) { - $r = q("update abook set abook_flags = (abook_flags | %d) where abook_id = %d limit 1", - intval(ABOOK_FLAG_ARCHIVED), - intval($contact['abook_id']) - ); - $update = false; - continue; - } - if($contact['abook_flags'] & ABOOK_FLAG_ARCHIVED) { - $update = false; - continue; } - // might be dead, so maybe don't poll quite so often + if((! $update) && (! $force)) + continue; - // recently deceased, so keep up the regular schedule for 3 days - - if((strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $c . " + 3 day")) > 0) - && (strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 1 day")) > 0)) - $update = true; + proc_run('php','include/onepoll.php',$contact['abook_id']); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); - // After that back off and put them on a morphine drip + } + } - if(strcmp(datetime_convert('UTC','UTC', 'now'),datetime_convert('UTC','UTC', $t . " + 2 day")) > 0) { - $update = true; + if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { + $r = q("select ud_id from updates where not ( ud_flags & %d ) and ( ud_last = '0000-00-00 00:00:00' OR ud_last > UTC_TIMESTAMP() - INTERVAL 7 DAYS) ", + intval(UPDATE_FLAGS_UPDATED) + ); + if($r) { + foreach($r as $rr) { + + // If they didn't respond when we attempted before, back off to once a day + // After 7 days we won't bother anymore + + if($rr['ud_last'] != '0000-00-00 00:00:00') + if($rr['ud_last'] > datetime_convert('UTC','UTC', 'now - 1 day')) + continue; + proc_run('php','include/onedirsync.php',$rr['ud_id']); + if($interval) + @time_sleep_until(microtime(true) + (float) $interval); } - - } - - if((! $update) && (! $force)) - continue; - - proc_run('php','include/onepoll.php',$contact['abook_id']); - if($interval) - @time_sleep_until(microtime(true) + (float) $interval); - } - + return; } diff --git a/include/zot.php b/include/zot.php index 1a90481ff..33bb60c0f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1532,13 +1532,21 @@ function import_directory_keywords($hash,$keywords) { function update_modtime($hash,$guid,$addr,$flags = 0) { - q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )", - dbesc($hash), - dbesc($guid), - dbesc(datetime_convert()), - intval($flags), - dbesc($addr) - ); + if($flags) { + q("insert into updates (ud_hash, ud_guid, ud_date, ud_flags, ud_addr ) values ( '%s', '%s', '%s', %d, '%s' )", + dbesc($hash), + dbesc($guid), + dbesc(datetime_convert()), + intval($flags), + dbesc($addr) + ); + } + else { + q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not (ud_flags & %d) ", + intval(UPDATE_FLAGS_UPDATED), + intval(UPDATE_FLAGS_UPDATED) + ); + } } -- cgit v1.2.3 From dffce63662c54db7ebb61786d39db6a900d1381f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 21:49:26 -0700 Subject: implement republish permission for use in sourced channels --- include/Contact.php | 3 ++- include/items.php | 11 +++++++++++ include/permissions.php | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index b9e879bcf..46c84aab6 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -219,7 +219,8 @@ function channel_remove($channel_id, $local = true) { $r = q("update channel set channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0, channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0, channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, - channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0 where channel_id = %d limit 1", + channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0 + where channel_id = %d limit 1", intval(PAGE_REMOVED), intval($channel_id) ); diff --git a/include/items.php b/include/items.php index dcd9eb6fc..18736f974 100755 --- a/include/items.php +++ b/include/items.php @@ -2308,6 +2308,17 @@ function check_item_source($uid,$item) { if(! $r) return false; + $x = q("select abook_their_perms from abook where abook_channel = %d and abook_xchan = '%s' limit 1", + intval($uid), + dbesc($item['owner_xchan']) + ); + + if(! $x) + return false; + + if(! ($x[0]['abook_their_perms'] & PERMS_A_REPUBLISH)) + return false; + if($r[0]['src_channel_xchan'] === $item['owner_xchan']) return false; diff --git a/include/permissions.php b/include/permissions.php index bf50ebdd1..45ea7c3eb 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -28,6 +28,7 @@ function get_perms() { 'write_storage' => array('channel_w_storage', intval(PERMS_W_STORAGE), false, t('Can write to my "public" file storage'), ''), 'write_pages' => array('channel_w_pages', intval(PERMS_W_PAGES), false, t('Can edit my "public" pages'), ''), + 'republish' => array('channel_a_republish', intval(PERMS_A_REPUBLISH), false, t('Can source my "public" posts in derived channels'), t('Somewhat advanced - very useful in open communities')), 'delegate' => array('channel_a_delegate', intval(PERMS_A_DELEGATE), false, t('Can administer my channel resources'), t('Extremely advanced. Leave this alone unless you know what you are doing')), ); $ret = array('global_permissions' => $global_perms); -- cgit v1.2.3 From d7b81b1afd150ebc0abfcd12f6ab23d65b61a0af Mon Sep 17 00:00:00 2001 From: zottel Date: Tue, 1 Oct 2013 09:36:28 +0200 Subject: Add possibility to use a block a channel menu (set channel_menublock to the lowercase title of the block without special chars) Fix comanche_block() SQL --- include/comanche.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/comanche.php b/include/comanche.php index 526819572..f1dd0e521 100644 --- a/include/comanche.php +++ b/include/comanche.php @@ -87,7 +87,7 @@ function comanche_replace_region($match) { function comanche_block($name) { $o = ''; - $r = q("select * from item left join item_id on iid = item_id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", + $r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1", intval(get_app()->profile['profile_uid']), dbesc($name) ); -- cgit v1.2.3 From 7b6530fed5a35ecb3f8b699de9a0ec32a6cf7f82 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 1 Oct 2013 20:10:09 -0700 Subject: add the auto form submit even though it doesn't seem to work. Will debug it later. --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 69c258488..8efa1e925 100755 --- a/include/text.php +++ b/include/text.php @@ -726,7 +726,7 @@ function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); $o = '
'; $o .= '
'; - $o .= ''; + $o .= ''; $o .= ''; if($save) $o .= ''; -- cgit v1.2.3 From b25d2e0d12046786290b95b465643b8cb9bc8c12 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Wed, 2 Oct 2013 05:03:09 +0100 Subject: Slightly modify reshares so they can be themed as a whole. --- include/bbcode.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 9b9c954c1..756d73aba 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -131,7 +131,7 @@ function bb_ShareAttributes($match) { // FIXME - this should really be a wall-item-ago so it will get updated on the client $reldate = (($posted) ? relative_date($posted) : ''); - $headline = '
'; + $headline = '
'; if ($avatar != "") $headline .= '' . $author . ''; @@ -146,7 +146,7 @@ function bb_ShareAttributes($match) { $headline .= '' . $fmt . '
'; - $text = $headline . '
' . trim($match[2]) . '
'; + $text = $headline . '
' . trim($match[2]) . '
'; return($text); } -- cgit v1.2.3 From 494090a3b7de23686d96530afd9509e50bff6362 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 1 Oct 2013 22:20:09 -0700 Subject: in probe diagnostic - note https failure as diagnostic info - this also changes zot_finger so you can tell it not to fallback. This could be useful in corporate environments that are off the grid or other high security situations (as much as anything could be considered high security which relies on SSL). --- include/zot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 33bb60c0f..3ea7fa90b 100644 --- a/include/zot.php +++ b/include/zot.php @@ -116,7 +116,7 @@ function zot_zot($url,$data) { */ -function zot_finger($webbie,$channel) { +function zot_finger($webbie,$channel,$autofallback = true) { if(strpos($webbie,'@') === false) { @@ -165,7 +165,7 @@ function zot_finger($webbie,$channel) { $result = z_post_url($url . $rhs,$postvars); - if(! $result['success']) { + if((! $result['success']) && ($autofallback)) { if($https) { logger('zot_finger: https failed. falling back to http'); $result = z_post_url('http://' . $host . $rhs,$postvars); @@ -176,7 +176,7 @@ function zot_finger($webbie,$channel) { $rhs .= '?f=&address=' . urlencode($address); $result = z_fetch_url($url . $rhs); - if(! $result['success']) { + if((! $result['success']) && ($autofallback)) { if($https) { logger('zot_finger: https failed. falling back to http'); $result = z_fetch_url('http://' . $host . $rhs); -- cgit v1.2.3 From de9aee8a079a3e2dd236c3739568ccb044d26f02 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 Oct 2013 02:50:02 -0700 Subject: block forgeries --- include/deliver.php | 2 +- include/zot.php | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/deliver.php b/include/deliver.php index 547d009cc..b1314ce39 100644 --- a/include/deliver.php +++ b/include/deliver.php @@ -26,7 +26,7 @@ function deliver_run($argv, $argc) { // If there is no outq_msg, this is a refresh_all message which does not require local handling if($r[0]['outq_msg']) { $msg = array('body' => json_encode(array('pickup' => array(array('notify' => json_decode($r[0]['outq_notify'],true),'message' => json_decode($r[0]['outq_msg'],true)))))); - zot_import($msg); + zot_import($msg,z_root()); $r = q("delete from outq where outq_hash = '%s' limit 1", dbesc($argv[$x]) ); diff --git a/include/zot.php b/include/zot.php index 3ea7fa90b..71aa27a81 100644 --- a/include/zot.php +++ b/include/zot.php @@ -801,8 +801,7 @@ function zot_fetch($arr) { $datatosend = json_encode(aes_encapsulate(json_encode($data),$ret_hub['hubloc_sitekey'])); $fetch = zot_zot($url,$datatosend); - - $result = zot_import($fetch); + $result = zot_import($fetch, $arr['sender']['url']); return $result; } @@ -815,7 +814,7 @@ function zot_fetch($arr) { * The message types handled here are 'activity' (e.g. posts), 'mail' and 'profile' */ -function zot_import($arr) { +function zot_import($arr, $sender_url) { $data = json_decode($arr['body'],true); @@ -842,6 +841,13 @@ function zot_import($arr) { logger('zot_import: notify: ' . print_r($i['notify'],true), LOGGER_DATA); + $hub = zot_gethub($i['notify']['sender']); + if((! $hub) || ($hub['hubloc_url'] != $sender_url)) { + logger('zot_import: potential forgery: wrong site for sender: ' . $sender_url . ' != ' . print_r($i['notify'],true)); + continue; + } + + $i['notify']['sender']['hash'] = base64url_encode(hash('whirlpool',$i['notify']['sender']['guid'] . $i['notify']['sender']['guid_sig'], true)); $deliveries = null; @@ -1093,6 +1099,15 @@ function allowed_public_recips($msg) { function process_delivery($sender,$arr,$deliveries,$relay) { $result = array(); + + + // We've validated the sender. Now make sure that the sender is the owner or author + // This needs to be done in each process_xxxx function because the data arrays and conditions will be different. + + if($sender['hash'] != $arr['owner_xchan'] && $sender_hash != $arr['author_xchan']) { + logger('process_delivery: sender is not owner or author'); + return; + } foreach($deliveries as $d) { $r = q("select * from channel where channel_hash = '%s' limit 1", -- cgit v1.2.3 From 266c701034be20cccf42e18cdc336dc896c53d77 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 Oct 2013 04:04:37 -0700 Subject: directory sync typo --- include/poller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/poller.php b/include/poller.php index 05584a05d..95eb810a0 100644 --- a/include/poller.php +++ b/include/poller.php @@ -242,7 +242,7 @@ function poller_run($argv, $argc){ } if($dirmode == DIRECTORY_MODE_SECONDARY || $dirmode == DIRECTORY_MODE_PRIMARY) { - $r = q("select ud_id from updates where not ( ud_flags & %d ) and ( ud_last = '0000-00-00 00:00:00' OR ud_last > UTC_TIMESTAMP() - INTERVAL 7 DAYS) ", + $r = q("select ud_id from updates where not ( ud_flags & %d ) and ( ud_last = '0000-00-00 00:00:00' OR ud_last > UTC_TIMESTAMP() - INTERVAL 7 DAY ) ", intval(UPDATE_FLAGS_UPDATED) ); if($r) { -- cgit v1.2.3 From 6e2695f94ae726228072037d5007c9e72c0d1fe0 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 Oct 2013 04:13:35 -0700 Subject: that would've messed it up --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 71aa27a81..945ea0cf9 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1104,7 +1104,7 @@ function process_delivery($sender,$arr,$deliveries,$relay) { // We've validated the sender. Now make sure that the sender is the owner or author // This needs to be done in each process_xxxx function because the data arrays and conditions will be different. - if($sender['hash'] != $arr['owner_xchan'] && $sender_hash != $arr['author_xchan']) { + if($sender['hash'] != $arr['owner_xchan'] && $sender['hash'] != $arr['author_xchan']) { logger('process_delivery: sender is not owner or author'); return; } -- cgit v1.2.3 From 78a8d176acae142cac9d20315672772eccd6c683 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 Oct 2013 21:04:48 -0700 Subject: post signatures --- include/ItemObject.php | 8 +++ include/conversation.php | 7 +++ include/items.php | 137 +++++++++++++++++++++++++++++++---------------- include/zot.php | 8 +++ 4 files changed, 114 insertions(+), 46 deletions(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index 6c43d4e9e..bf55b484a 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -156,6 +156,12 @@ class Item extends BaseObject { $indent = 'comment'; } + + $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message is verified') : ''); + $unverified = '' ; // (($this->is_wall_to_wall() && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message cannot be verified') : ''); + + + // FIXME - check this permission if($conv->get_profile_owner() == local_user()) { $tagger = array( @@ -210,6 +216,8 @@ class Item extends BaseObject { 'isotime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'c'), 'localtime' => datetime_convert('UTC', date_default_timezone_get(), $item['created'], 'r'), 'lock' => $lock, + 'verified' => $verified, + 'unverified' => $unverified, 'location' => $location, 'indent' => $indent, 'owner_url' => $this->get_owner_url(), diff --git a/include/conversation.php b/include/conversation.php index 254453ad1..bcd9ae51a 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -638,6 +638,11 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { $likebuttons = false; $shareable = false; + $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message is verified') : ''); + $unverified = ''; + + + $tags=array(); $terms = get_terms_oftype($item['term'],array(TERM_HASHTAG,TERM_MENTION,TERM_UNKNOWN)); if(count($terms)) @@ -665,6 +670,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { 'tags' => $tags, 'hashtags' => $hashtags, 'mentions' => $mentions, + 'verified' => $verified, + 'unverified' => $unverified, 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => ((count($categories)) ? 'true' : ''), diff --git a/include/items.php b/include/items.php index 18736f974..7cc08197e 100755 --- a/include/items.php +++ b/include/items.php @@ -546,6 +546,7 @@ function title_is_body($title, $body) { function get_item_elements($x) { +// logger('get_item_elements'); $arr = array(); $arr['body'] = (($x['body']) ? htmlentities($x['body'],ENT_COMPAT,'UTF-8',false) : ''); @@ -579,6 +580,9 @@ function get_item_elements($x) { $arr['obj_type'] = (($x['object_type']) ? htmlentities($x['object_type'], ENT_COMPAT,'UTF-8',false) : ''); $arr['tgt_type'] = (($x['target_type']) ? htmlentities($x['target_type'], ENT_COMPAT,'UTF-8',false) : ''); $arr['comment_policy'] = (($x['comment_scope']) ? htmlentities($x['comment_scope'], ENT_COMPAT,'UTF-8',false) : 'contacts'); + + $arr['sig'] = (($x['signature']) ? htmlentities($x['signature'], ENT_COMPAT,'UTF-8',false) : ''); + $arr['object'] = activity_sanitise($x['object']); $arr['target'] = activity_sanitise($x['target']); @@ -590,18 +594,6 @@ function get_item_elements($x) { $arr['item_flags'] = 0; - // if it's a private post, encrypt it in the DB. - // We have to do that here because we need to cleanse the input and prevent bad stuff from getting in, - // and we need plaintext to do that. - - if(intval($arr['item_private'])) { - $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; - $key = get_config('system','pubkey'); - if($arr['title']) - $arr['title'] = json_encode(aes_encapsulate($arr['title'],$key)); - if($arr['body']) - $arr['body'] = json_encode(aes_encapsulate($arr['body'],$key)); - } if(array_key_exists('flags',$x) && in_array('deleted',$x['flags'])) $arr['item_restrict'] = ITEM_DELETED; @@ -628,6 +620,31 @@ function get_item_elements($x) { } + if($arr['sig']) { + $r = q("select xchan_pubkey from xchan where xchan_hash = '%s' limit 1", + dbesc($arr['author_xchan']) + ); + if($r && rsa_verify($x['body'],base64url_decode($arr['sig']),$r[0]['xchan_pubkey'])) + $arr['item_flags'] |= ITEM_VERIFIED; + else + logger('get_item_elements: message verification failed.'); + } + + + // if it's a private post, encrypt it in the DB. + // We have to do that here because we need to cleanse the input and prevent bad stuff from getting in, + // and we need plaintext to do that. + + if(intval($arr['item_private'])) { + $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; + $key = get_config('system','pubkey'); + if($arr['title']) + $arr['title'] = json_encode(aes_encapsulate($arr['title'],$key)); + if($arr['body']) + $arr['body'] = json_encode(aes_encapsulate($arr['body'],$key)); + } + + return $arr; } @@ -656,7 +673,7 @@ function encode_item($item) { $x = array(); $x['type'] = 'activity'; - logger('encode_item: ' . print_r($item,true)); +// logger('encode_item: ' . print_r($item,true)); $r = q("select channel_r_stream, channel_w_comment from channel where channel_id = %d limit 1", intval($item['uid']) @@ -707,6 +724,7 @@ function encode_item($item) { $x['permalink'] = $item['plink']; $x['location'] = $item['location']; $x['longlat'] = $item['coord']; + $x['signature'] = $item['sig']; $x['owner'] = encode_item_xchan($item['owner']); $x['author'] = encode_item_xchan($item['author']); @@ -730,6 +748,8 @@ function encode_item($item) { if($item['term']) $x['tags'] = encode_item_terms($item['term']); + logger('encode_item: ' . print_r($x,true)); + return $x; } @@ -1445,18 +1465,28 @@ function item_store($arr,$allow_exec = false) { $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 ); $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 ); - $arr['title'] = escape_tags($arr['title']); + // only detect language if we have text content, and if the post is private but not yet // obscured, make it so. if(! ($arr['item_flags'] & ITEM_OBSCURED)) { + $arr['lang'] = detect_language($arr['body']); // apply the input filter here - if it is obscured it has been filtered already $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']); + + if(local_user() && (! $arr['sig'])) { + $channel = get_app()->get_channel(); + if($channel['channel_hash'] === $arr['author_xchan']) { + $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey'])); + $arr['item_flags'] |= ITEM_VERIFIED; + } + } + $allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages'); if((is_array($allowed_languages)) && ($arr['lang']) && (! array_key_exists($arr['lang'],$allowed_languages))) { @@ -1767,22 +1797,6 @@ function item_store_update($arr,$allow_exec = false) { $uid = $arr['uid']; unset($arr['uid']); - - $arr['lang'] = detect_language($arr['body']); - - $allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages'); - - if((is_array($allowed_languages)) && ($arr['lang']) && (! array_key_exists($arr['lang'],$allowed_languages))) { - $translate = array('item' => $arr, 'from' => $arr['lang'], 'to' => $allowed_languages, 'translated' => false); - call_hooks('item_translate', $translate); - if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) { - logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']); - $ret['message'] = 'language not accepted'; - return $ret; - } - $arr = $translate['item']; - } - $arr['mimetype'] = ((x($arr,'mimetype')) ? notags(trim($arr['mimetype'])) : 'text/bbcode'); if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) { @@ -1791,30 +1805,60 @@ function item_store_update($arr,$allow_exec = false) { return $ret; } + if(! ($arr['item_flags'] & ITEM_OBSCURED)) { + + $arr['lang'] = detect_language($arr['body']); + // apply the input filter here - if it is obscured it has been filtered already + $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']); + + if(local_user() && (! $arr['sig'])) { + $channel = get_app()->get_channel(); + if($channel['channel_hash'] === $arr['author_xchan']) { + $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey'])); + $arr['item_flags'] |= ITEM_VERIFIED; + } + } - // Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin. + $allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages'); + + if((is_array($allowed_languages)) && ($arr['lang']) && (! array_key_exists($arr['lang'],$allowed_languages))) { + $translate = array('item' => $arr, 'from' => $arr['lang'], 'to' => $allowed_languages, 'translated' => false); + call_hooks('item_translate', $translate); + if((! $translate['translated']) && (intval(get_pconfig($arr['uid'],'system','reject_disallowed_languages')))) { + logger('item_store: language ' . $arr['lang'] . ' not accepted for uid ' . $arr['uid']); + $ret['message'] = 'language not accepted'; + return $ret; + } + $arr = $translate['item']; + } + if($arr['item_private']) { + $key = get_config('system','pubkey'); + $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED; + if($arr['title']) + $arr['title'] = json_encode(aes_encapsulate($arr['title'],$key)); + if($arr['body']) + $arr['body'] = json_encode(aes_encapsulate($arr['body'],$key)); + } - if($arr['mimetype'] != 'text/html' && $arr['mimetype'] != 'application/x-php') { + } - if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) - $arr['body'] = escape_tags($arr['body']); - if((x($arr,'object')) && is_array($arr['object'])) { - activity_sanitise($arr['object']); - $arr['object'] = json_encode($arr['object']); - } + if((x($arr,'object')) && is_array($arr['object'])) { + activity_sanitise($arr['object']); + $arr['object'] = json_encode($arr['object']); + } - if((x($arr,'target')) && is_array($arr['target'])) { - activity_sanitise($arr['target']); - $arr['target'] = json_encode($arr['target']); - } + if((x($arr,'target')) && is_array($arr['target'])) { + activity_sanitise($arr['target']); + $arr['target'] = json_encode($arr['target']); + } - if((x($arr,'attach')) && is_array($arr['attach'])) { - activity_sanitise($arr['attach']); - $arr['attach'] = json_encode($arr['attach']); - } + if((x($arr,'attach')) && is_array($arr['attach'])) { + activity_sanitise($arr['attach']); + $arr['attach'] = json_encode($arr['attach']); } + $orig = q("select * from item where id = %d and uid = %d limit 1", intval($orig_post_id), intval($uid) @@ -1860,6 +1904,7 @@ function item_store_update($arr,$allow_exec = false) { $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] ); $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] ); + $arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); call_hooks('post_remote_update',$arr); diff --git a/include/zot.php b/include/zot.php index 945ea0cf9..8df57bb51 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1327,6 +1327,14 @@ function process_mail_delivery($sender,$arr,$deliveries) { $result = array(); + + + if($sender['hash'] != $arr['from_xchan']) { + logger('process_mail_delivery: sender is not mail author'); + return; + } + + foreach($deliveries as $d) { $r = q("select * from channel where channel_hash = '%s' limit 1", -- cgit v1.2.3 From e1fb45bc4a17fe4b16b6f4d49f620d56009baa96 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 2 Oct 2013 22:59:58 -0700 Subject: bring back photo shadows (via theme settings) --- include/zot.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 8df57bb51..b250557e6 100644 --- a/include/zot.php +++ b/include/zot.php @@ -111,6 +111,8 @@ function zot_zot($url,$data) { * does not have to be host qualified e.g. 'foo' is treated as 'foo@thishub' * @param: array $channel * (optional), if supplied permissions will be enumerated specifically for $channel + * @param: boolean $autofallback + * fallback/failover to http if https connection cannot be established. Default is true. * * @returns: array => see z_post_url and mod/zfinger.php */ @@ -1102,7 +1104,6 @@ function process_delivery($sender,$arr,$deliveries,$relay) { // We've validated the sender. Now make sure that the sender is the owner or author - // This needs to be done in each process_xxxx function because the data arrays and conditions will be different. if($sender['hash'] != $arr['owner_xchan'] && $sender['hash'] != $arr['author_xchan']) { logger('process_delivery: sender is not owner or author'); -- cgit v1.2.3 From ff7182f441907065b852b24cbf86547752a9b9ad Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 4 Oct 2013 04:47:41 -0700 Subject: fix a bunch of post editing bugs - though this consolidates some disparate code and may create some new bugs due to regression --- include/items.php | 56 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 7cc08197e..800684ae2 100755 --- a/include/items.php +++ b/include/items.php @@ -1793,10 +1793,28 @@ function item_store_update($arr,$allow_exec = false) { } $orig_post_id = $arr['id']; - unset($arr['id']); $uid = $arr['uid']; + + $orig = q("select * from item where id = %d and uid = %d limit 1", + intval($orig_post_id), + intval($uid) + ); + if(! $orig) { + logger('item_store_update: original post not found: ' . $orig_post_id); + $ret['message'] = 'no original'; + return $ret; + } + + if($orig[0]['item_flags'] & ITEM_VERIFIED) + $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_VERIFIED; + + $arr['item_flags'] = intval($arr['item_flags']) | $orig[0]['item_flags']; + $arr['item_restrict'] = intval($arr['item_restrict']) | $orig[0]['item_restrict']; + + unset($arr['id']); unset($arr['uid']); - + if(array_key_exists('edit',$arr)) + unset($arr['edit']); $arr['mimetype'] = ((x($arr,'mimetype')) ? notags(trim($arr['mimetype'])) : 'text/bbcode'); if(($arr['mimetype'] == 'application/x-php') && (! $allow_exec)) { @@ -1859,15 +1877,6 @@ function item_store_update($arr,$allow_exec = false) { } - $orig = q("select * from item where id = %d and uid = %d limit 1", - intval($orig_post_id), - intval($uid) - ); - if(! $orig) { - logger('item_store_update: original post not found: ' . $orig_post_id); - $ret['message'] = 'no original'; - return $ret; - } unset($arr['aid']); unset($arr['mid']); @@ -1885,13 +1894,13 @@ function item_store_update($arr,$allow_exec = false) { $arr['received'] = datetime_convert(); $arr['changed'] = datetime_convert(); $arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : ''); - $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : ''); - $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : ''); - $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ''); - $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ''); - $arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : ''); - $arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : ''); - $arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : ''); + $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']); + $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : $orig[0]['coord']); + $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : $orig[0]['verb']); + $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : $orig[0]['obj_type']); + $arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : $orig[0]['object']); + $arr['tgt_type'] = ((x($arr,'tgt_type')) ? notags(trim($arr['tgt_type'])) : $orig[0]['tgt_type']); + $arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : $orig[0]['target']); $arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : $orig[0]['plink']); $arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : $orig[0]['allow_cid']); $arr['allow_gid'] = ((x($arr,'allow_gid')) ? trim($arr['allow_gid']) : $orig[0]['allow_gid']); @@ -1899,12 +1908,13 @@ function item_store_update($arr,$allow_exec = false) { $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : $orig[0]['deny_gid']); $arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : $orig[0]['item_private']); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); - $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : ''); - $arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : ''); - $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] ); - $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] ); + $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : $orig[0]['attach']); + $arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : $orig[0]['app']); +// $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] ); +// $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] ); - $arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); + $arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : ''); + $arr['layout_mid'] = ((x($arr,'layout_mid')) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] ); call_hooks('post_remote_update',$arr); -- cgit v1.2.3 From e369e5ddc53e6a0d489ceaed0bd13849c7d031f1 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 4 Oct 2013 14:42:18 -0700 Subject: The check for f*cked database (which otherwise sends out zillions of update failed emails) interferes with install. So what else can we do about f*cked databases which open successfully but don't actually read/write data? It would of course be nice if we didn't have to deal with them, but apparently we do. For now we're not doing anything until I can figure out how to take the site offline when it happens without affecting install. --- include/config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/config.php b/include/config.php index ccd907424..bccf0737f 100644 --- a/include/config.php +++ b/include/config.php @@ -29,9 +29,9 @@ function load_config($family) { // If the DB was successfully opened, but we can't read from it, // we must assume catastrophic failure of the DB. Report the system down. - if($r === false) { - system_unavailable(); - } +// if($r === false) { +// system_unavailable(); +// } if($r !== false) { if($r) { -- cgit v1.2.3 From 0e793dea9bfc21a7c1c369d1db727d7ff900c90a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 8 Oct 2013 21:17:11 -0700 Subject: replace a bunch of graphic icons with vector icons --- include/ItemObject.php | 4 ++-- include/conversation.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index bf55b484a..df9386232 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -75,7 +75,7 @@ class Item extends BaseObject { $buttons = ''; $dropping = false; $star = false; - $isstarred = "unstarred"; + $isstarred = "unstarred icon-star-empty"; $indent = ''; $osparkle = ''; $total_children = $this->count_descendants(); @@ -147,7 +147,7 @@ class Item extends BaseObject { 'toggle' => t("toggle star status"), 'classdo' => (($item['item_flags'] & ITEM_STARRED) ? "hidden" : ""), 'classundo' => (($item['item_flags'] & ITEM_STARRED) ? "" : "hidden"), - 'isstarred' => (($item['item_flags'] & ITEM_STARRED) ? "starred" : "unstarred"), + 'isstarred' => (($item['item_flags'] & ITEM_STARRED) ? "starred icon-star" : "unstarred icon-star-empty"), 'starred' => t('starred'), ); diff --git a/include/conversation.php b/include/conversation.php index bcd9ae51a..1820a8568 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -632,7 +632,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') { ); $star = false; - $isstarred = "unstarred"; + $isstarred = "unstarred icon-star-empty"; $lock = false; $likebuttons = false; -- cgit v1.2.3 From 1e7034c4da11bd46cafad471de714ace3c0b5ab8 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 9 Oct 2013 03:26:24 -0700 Subject: nav icons --- include/nav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 812c90537..f1e47b576 100644 --- a/include/nav.php +++ b/include/nav.php @@ -141,11 +141,11 @@ EOT; if(local_user()) { - $nav['network'] = array('network', t('Matrix'), "", t('Conversations from your grid')); + $nav['network'] = array('network', t('Matrix'), "", t('Conversations from your matrix')); $nav['network']['all']=array('notifications/network', t('See all matrix notifications'), "", ""); $nav['network']['mark'] = array('', t('Mark all matrix notifications seen'), '',''); - $nav['home'] = array('channel/' . $channel['channel_address'], t('Home'), "", t('Your posts and conversations')); + $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Your posts and conversations')); $nav['home']['all']=array('notifications/channel', t('See all channel notifications'), "", ""); $nav['home']['mark'] = array('', t('Mark all channel notifications seen'), '',''); -- cgit v1.2.3 From 1aa69604fc9aaf87eacccabf73ba4d3600c8dcd5 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 9 Oct 2013 18:33:33 -0700 Subject: more redbasic icon work --- include/nav.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index f1e47b576..a16d8d078 100644 --- a/include/nav.php +++ b/include/nav.php @@ -95,12 +95,16 @@ EOT; ); } - if($observer) + if($observer) { + $nav['locked'] = true; $nav['lock'] = array('logout','','lock', sprintf( t('%s - click to logout'), $observer['xchan_addr'])); - else + } + else { + $nav['locked'] = false; $nav['lock'] = array('rmagic','','unlock', t('Click to authenticate to your home hub')); + } /** * "Home" should also take you home from an authenticated remote profile connection @@ -141,11 +145,11 @@ EOT; if(local_user()) { - $nav['network'] = array('network', t('Matrix'), "", t('Conversations from your matrix')); + $nav['network'] = array('network', t('Matrix'), "", t('Your matrix')); $nav['network']['all']=array('notifications/network', t('See all matrix notifications'), "", ""); $nav['network']['mark'] = array('', t('Mark all matrix notifications seen'), '',''); - $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Your posts and conversations')); + $nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home')); $nav['home']['all']=array('notifications/channel', t('See all channel notifications'), "", ""); $nav['home']['mark'] = array('', t('Mark all channel notifications seen'), '',''); -- cgit v1.2.3 From 3985aa07b4d81474615a3bb8e5a94a0217715267 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 10 Oct 2013 02:15:44 -0700 Subject: more icon tweaks - this could be going on for some time; try to get icon code (and all theme stuff) out of main code and into templates, but on the short term provide both so nothing breaks. --- include/text.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 8efa1e925..8f700458c 100755 --- a/include/text.php +++ b/include/text.php @@ -726,7 +726,7 @@ function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); $o = '
'; $o .= ''; - $o .= ''; + $o .= ''; $o .= ''; if($save) $o .= ''; -- cgit v1.2.3