From e812836a601f5fda32b520e9af29f89ae2227524 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 18 Sep 2017 17:46:34 -0700 Subject: provide rel=alternate link if no reshare content in post --- include/feedutils.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 145d4361c..4cc194fb1 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -811,6 +811,7 @@ function feed_get_reshare(&$res,$item) { } $attach = $share['links']; + if($attach) { foreach($attach as $att) { if($att['rel'] === 'alternate') { @@ -845,6 +846,10 @@ function feed_get_reshare(&$res,$item) { } } + if((! $body) && ($share['alternate'])) { + $body = $share['alternate']; + } + $res['body'] = "[share author='" . urlencode($share['author']) . "' profile='" . $share['profile'] . "' avatar='" . $share['avatar'] . -- cgit v1.2.3 From c6bcea0f82a03657611621c338a6c01059ae8ec6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 18 Sep 2017 21:55:45 -0700 Subject: pubcrawl: make a good faith effort to handle multi-media content --- include/feedutils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 4cc194fb1..112e10155 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1711,7 +1711,7 @@ function compat_photos_list($s) { $found = preg_match_all('/\[[zi]mg(.*?)\](.*?)\[/ism',$s,$matches,PREG_SET_ORDER); if($found) { - foreach($matches as $match) { + foreach($matches as $match) { $ret[] = [ 'href' => $match[2], 'length' => 0, -- cgit v1.2.3 From 72a19a14aff7a13a8c1fb10e773784643f68d234 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 19 Sep 2017 17:35:57 -0700 Subject: turn common friends into a widget --- include/contact_widgets.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index aac756a46..e5bb696f8 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -143,7 +143,7 @@ function cardcategories_widget($baseurl,$selected = '') { -function common_friends_visitor_widget($profile_uid) { +function common_friends_visitor_widget($profile_uid,$cnt = 10) { if(local_channel() == $profile_uid) return; @@ -156,19 +156,20 @@ function common_friends_visitor_widget($profile_uid) { require_once('include/socgraph.php'); $t = count_common_friends($profile_uid,$observer_hash); + if(! $t) return; - $r = common_friends($profile_uid,$observer_hash,0,5,true); + $r = common_friends($profile_uid,$observer_hash,0,$cnt,true); return replace_macros(get_markup_template('remote_friends_common.tpl'), array( - '$desc' => sprintf( tt("%d connection in common", "%d connections in common", $t), $t), - '$base' => z_root(), - '$uid' => $profile_uid, - '$cid' => $observer, - '$linkmore' => (($t > 5) ? 'true' : ''), - '$more' => t('show more'), - '$items' => $r + '$desc' => sprintf( t('Common connections: %d'), $t), + '$base' => z_root(), + '$uid' => $profile_uid, + '$cid' => $observer, + '$linkmore' => (($t > $cnt) ? 'true' : ''), + '$more' => t('show more'), + '$items' => $r )); }; -- cgit v1.2.3 From b0cdec0c35136db8cbb0cf13135a1f5cc8d1bc05 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 19 Sep 2017 19:15:15 -0700 Subject: perform caching of jsonld schemas --- include/network.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include') diff --git a/include/network.php b/include/network.php index da1afc3ac..7e2dbf4cf 100644 --- a/include/network.php +++ b/include/network.php @@ -1943,4 +1943,35 @@ function getBestSupportedMimeType($mimeTypes = null, $acceptedTypes = false) { } // no mime-type found return null; +} + + +function jsonld_document_loader($url) { + + // perform caching for jsonld normaliser + + require_once('library/jsonld/jsonld.php'); + + $cachepath = 'store/[data]/ldcache'; + if(! is_dir($cachepath)) + os_mkdir($cachepath,STORAGE_DEFAULT_PERMISSIONS,true); + + $filename = $cachepath . '/' . urlencode($url); + if(file_exists($filename) && filemtime($filename) > time() - (12 * 60 * 60)) { + return json_decode(file_get_contents($filename)); + } + + $r = jsonld_default_document_loader($url); + if($r) { + file_put_contents($filename,json_encode($r)); + return $r; + } + + logger('not found'); + if(file_exists($filename)) { + return json_decode(file_get_contents($filename)); + } + + return []; + } \ No newline at end of file -- cgit v1.2.3 From 61d9b34929adc831eb780fd3410660eb98c114a9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 19 Sep 2017 23:30:52 -0700 Subject: use mimetype text description rather than technical name in dropdown choices, found bug in mimetype selection option code --- include/text.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index c4d441e85..49cc2d6c5 100644 --- a/include/text.php +++ b/include/text.php @@ -1789,21 +1789,21 @@ function layout_select($channel_id, $current = '') { function mimetype_select($channel_id, $current = 'text/bbcode', $choices = null, $element = 'mimetype') { $x = (($choices) ? $choices : [ - 'text/bbcode', - 'text/html', - 'text/markdown', - 'text/plain', - 'application/x-pdl' + 'text/bbcode' => t('BBcode'), + 'text/html' => t('HTML'), + 'text/markdown' => t('Markdown'), + 'text/plain' => t('Text'), + 'application/x-pdl' => t('Comanche Layout') ]); if((App::$is_sys) || (channel_codeallowed($channel_id) && $channel_id == local_channel())){ - $x[] = 'application/x-php'; + $x['application/x-php'] = t('PHP'); } - foreach($x as $y) { + foreach($x as $y => $z) { $selected = (($y == $current) ? ' selected="selected" ' : ''); - $options .= ''; + $options .= ''; } $o = replace_macros(get_markup_template('field_select_raw.tpl'), array( -- cgit v1.2.3 From 9e46472ca26f2bd38d2e71c221a9fbf5618b5822 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 20 Sep 2017 00:00:26 -0700 Subject: provide default photo mimetype --- include/channel.php | 5 ++++- include/perm_upgrade.php | 3 +++ include/photo/photo_driver.php | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 7072bb4ce..fef933ba7 100644 --- a/include/channel.php +++ b/include/channel.php @@ -278,11 +278,13 @@ function create_identity($arr) { intval($arr['account_id']) ); + $photo_type = null; + $z = [ 'account' => $a[0], 'channel' => $r[0], 'photo_url' => '' ]; call_hooks('create_channel_photo',$z); if($z['photo_url']) { - import_channel_photo_from_url($z['photo_url'],$arr['account_id'],$r[0]['channel_id']); + $photo_type = import_channel_photo_from_url($z['photo_url'],$arr['account_id'],$r[0]['channel_id']); } if($role_permissions && array_key_exists('limits',$role_permissions)) @@ -330,6 +332,7 @@ function create_identity($arr) { 'xchan_guid' => $guid, 'xchan_guid_sig' => $sig, 'xchan_pubkey' => $key['pubkey'], + 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'), 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", 'xchan_photo_m' => z_root() . "/photo/profile/m/{$newuid}", 'xchan_photo_s' => z_root() . "/photo/profile/s/{$newuid}", diff --git a/include/perm_upgrade.php b/include/perm_upgrade.php index 5be1ffbb2..9eb1efba2 100644 --- a/include/perm_upgrade.php +++ b/include/perm_upgrade.php @@ -135,6 +135,9 @@ function translate_abook_perms_outbound(&$abook) { $my_perms = 0; $their_perms = 0; + if(! $abook) + return; + if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && $abook['abconfig']) { foreach($abook['abconfig'] as $p) { if($p['cat'] === 'their_perms') { diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index c6c023147..17ca81419 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -666,6 +666,7 @@ function import_channel_photo_from_url($photo,$aid,$uid) { import_channel_photo($img_str,$type,$aid,$uid); + return $type; } -- cgit v1.2.3 From 3456c192feeab9495693e2cbdcff16fe99bff932 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 21 Sep 2017 23:37:13 -0700 Subject: encrypt delivery reports. This will cause a bit of consternation because this is not backward compatible and older sites will see some incorrect delivery reports from newer sites until the next upgrade; as their systems will not know how to read the ecnrypted final reports. --- include/zot.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index c8321c2ae..f03445781 100644 --- a/include/zot.php +++ b/include/zot.php @@ -977,6 +977,18 @@ function zot_process_response($hub, $arr, $outq) { } if(is_array($x) && array_key_exists('delivery_report',$x) && is_array($x['delivery_report'])) { + + if(array_key_exists('iv',$x['delivery_report'])) { + $j = crypto_unencapsulate($x['delivery_report'],get_config('system','prvkey')); + if($j) { + $x['delivery_report'] = json_decode($j,true); + } + if(! (is_array($x['delivery_report']) && count($x['delivery_report']))) { + logger('encrypted delivery report could not be decrypted'); + return; + } + } + foreach($x['delivery_report'] as $xx) { if(is_array($xx) && array_key_exists('message_id',$xx) && delivery_report_is_storable($xx)) { q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s','%s','%s','%s','%s' ) ", @@ -1048,13 +1060,15 @@ function zot_fetch($arr) { foreach($ret_hubs as $ret_hub) { + $secret = substr(preg_replace('/[^0-9a-fA-F]/','',$arr['secret']),0,64); + $data = [ 'type' => 'pickup', 'url' => z_root(), 'callback_sig' => base64url_encode(rsa_sign(z_root() . '/post', get_config('system','prvkey'))), 'callback' => z_root() . '/post', - 'secret' => $arr['secret'], - 'secret_sig' => base64url_encode(rsa_sign($arr['secret'], get_config('system','prvkey'))) + 'secret' => $secret, + 'secret_sig' => base64url_encode(rsa_sign($secret, get_config('system','prvkey'))) ]; $algorithm = zot_best_algorithm($ret_hub['site_crypto']); @@ -1064,8 +1078,11 @@ function zot_fetch($arr) { $result = zot_import($fetch, $arr['sender']['url']); - if($result) + if($result) { + $result = crypto_encapsulate(json_encode($result),$ret_hub['hubloc_sitekey'], $algorithm); return $result; + } + } return; -- cgit v1.2.3