From 8ad2b3e7a13fccab2e508ce944e0b02c3d259711 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Sun, 23 Apr 2017 21:22:40 -0400 Subject: When template "none" is used in a webpage layout, then the contents of the page should be the sole output, with no other code before or after the page element content. --- include/conversation.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 5b2d60583..0f940b1a3 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1541,6 +1541,15 @@ function prepare_page($item) { // the template will get passed an unobscured title. $body = prepare_body($item, true); + if(App::$page['template'] == 'none') { + $tpl = 'page_display_empty.tpl'; + + return replace_macros(get_markup_template($tpl), array( + '$body' => $body['html'] + )); + + } + $tpl = get_pconfig($item['uid'], 'system', 'pagetemplate'); if (! $tpl) $tpl = 'page_display.tpl'; -- cgit v1.2.3 From 7d5ee81628a08dd560f7fdaa5b4d5a3f5ce3fb95 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 25 Apr 2017 21:52:24 -0700 Subject: database support for client side e2ee for private mail --- include/message.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/message.php b/include/message.php index da3514184..e7db98d7e 100644 --- a/include/message.php +++ b/include/message.php @@ -188,9 +188,10 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep $body = str_rot47(base64url_encode($body)); $sig = ''; // placeholder + $mimetype = ''; //placeholder - $r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply ) - VALUES ( %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", + $r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply ) + VALUES ( %d, '%s', %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d )", intval($channel['channel_account_id']), dbesc($conv_guid), intval(1), @@ -198,6 +199,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep dbesc($channel['channel_hash']), dbesc($recipient), dbesc($subject), + dbesc(($mimetype)? $mimetype : 'text/bbcode'), dbesc($body), dbesc($sig), dbesc($jattach), -- cgit v1.2.3 From 803bff4043dae142999a34e7d706eea176328c69 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 25 Apr 2017 16:36:37 -0700 Subject: smilies - add param to only list default emoticons --- include/text.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index fa9dadc31..1fa03edab 100644 --- a/include/text.php +++ b/include/text.php @@ -1166,7 +1166,7 @@ function get_mood_verbs() { * * @return Returns array with keys 'texts' and 'icons' */ -function list_smilies() { +function list_smilies($default_only = false) { $texts = array( '<3', @@ -1242,10 +1242,15 @@ function list_smilies() { ); $params = array('texts' => $texts, 'icons' => $icons); + + if($default_only) + return $params; + call_hooks('smilie', $params); return $params; } + /** * @brief Replaces text emoticons with graphical images. * -- cgit v1.2.3 From 97458b288534d2270a592af141bacdcade84d12c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Apr 2017 21:25:37 -0700 Subject: make it easier to hook into feed headers in the future --- include/feedutils.php | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index af382be44..d38f60113 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -73,19 +73,6 @@ function get_feed_for($channel, $observer_hash, $params) { if(! perm_is_allowed($channel['channel_id'],$observer_hash,'view_stream')) http_status_exit(403); } - $items = items_fetch(array( - 'wall' => '1', - 'datequery' => $params['end'], - 'datequery2' => $params['begin'], - 'start' => $params['start'], // FIXME - 'records' => $params['records'], // FIXME - 'direction' => $params['direction'], // FIXME - 'pages' => $params['pages'], - 'order' => 'post', - 'top' => $params['top'], - 'cat' => $params['cat'] - ), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module); - $feed_template = get_markup_template('atom_feed.tpl'); @@ -112,8 +99,27 @@ function get_feed_for($channel, $observer_hash, $params) { )); + $x = [ 'xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params ]; + call_hooks('atom_feed_top',$x); + + $atom = $x['xml']; + + // a much simpler interface call_hooks('atom_feed', $atom); + $items = items_fetch(array( + 'wall' => '1', + 'datequery' => $params['end'], + 'datequery2' => $params['begin'], + 'start' => $params['start'], // FIXME + 'records' => $params['records'], // FIXME + 'direction' => $params['direction'], // FIXME + 'pages' => $params['pages'], + 'order' => 'post', + 'top' => $params['top'], + 'cat' => $params['cat'] + ), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module); + if($items) { $type = 'html'; foreach($items as $item) { -- cgit v1.2.3 From 7667c630a4a682ba5a48d1ece173cdcdff575e00 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 25 Apr 2017 20:48:38 -0700 Subject: provide a broken feed for services which require a broken feed --- include/feedutils.php | 73 ++++++++++++++++++++++++++++----------------------- include/items.php | 4 +++ 2 files changed, 44 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index d38f60113..ed3308829 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -22,24 +22,20 @@ function get_public_feed($channel, $params) { */ if(! $params) - $params = array(); + $params = []; - $params['type'] = ((x($params,'type')) ? $params['type'] : 'xml'); - $params['begin'] = ((x($params,'begin')) ? $params['begin'] : NULL_DATE); - $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); - $params['top'] = ((x($params,'top')) ? intval($params['top']) : 0); - $params['cat'] = ((x($params,'cat')) ? $params['cat'] : ''); + $params['type'] = ((x($params,'type')) ? $params['type'] : 'xml'); + $params['begin'] = ((x($params,'begin')) ? $params['begin'] : NULL_DATE); + $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); + $params['top'] = ((x($params,'top')) ? intval($params['top']) : 0); + $params['cat'] = ((x($params,'cat')) ? $params['cat'] : ''); + $params['compat'] = ((x($params,'compat')) ? intval($params['compat']) : 0); - // put a sane lower limit on feed requests if not specified - -// if($params['begin'] <= NULL_DATE) -// $params['begin'] = datetime_convert('UTC','UTC','now - 1 month'); - switch($params['type']) { case 'json': header("Content-type: application/atom+json"); @@ -61,6 +57,7 @@ function get_public_feed($channel, $params) { * @param array $params * @return string with an atom feed */ + function get_feed_for($channel, $observer_hash, $params) { if(! $channel) @@ -74,18 +71,24 @@ function get_feed_for($channel, $observer_hash, $params) { http_status_exit(403); } + // logger('params: ' . print_r($params,true)); + $feed_template = get_markup_template('atom_feed.tpl'); $atom = ''; + $feed_author = ''; + if(intval($params['compat']) === 1) { + $feed_author = atom_author('author',$channel['channel_address'],$channel['xchan_url'],300,300,$channel['xchan_photo_mimetype'],$channel['xchan_photo_l']); + } + $atom .= replace_macros($feed_template, array( '$version' => xmlify(Zotlabs\Lib\System::get_project_version()), '$red' => xmlify(Zotlabs\Lib\System::get_platform_name()), '$feed_id' => xmlify($channel['xchan_url']), '$feed_title' => xmlify($channel['channel_name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 'now', ATOM_TIME)), - '$hub' => '', // feed_hublinks(), - '$salmon' => '', // feed_salmonlinks($channel['channel_address']), + '$author' => $feed_author, '$name' => xmlify($channel['channel_name']), '$profile_page' => xmlify($channel['xchan_url']), '$mimephoto' => xmlify($channel['xchan_photo_mimetype']), @@ -107,18 +110,21 @@ function get_feed_for($channel, $observer_hash, $params) { // a much simpler interface call_hooks('atom_feed', $atom); - $items = items_fetch(array( - 'wall' => '1', - 'datequery' => $params['end'], - 'datequery2' => $params['begin'], - 'start' => $params['start'], // FIXME - 'records' => $params['records'], // FIXME - 'direction' => $params['direction'], // FIXME - 'pages' => $params['pages'], - 'order' => 'post', - 'top' => $params['top'], - 'cat' => $params['cat'] - ), $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module); + $items = items_fetch( + [ + 'wall' => '1', + 'datequery' => $params['end'], + 'datequery2' => $params['begin'], + 'start' => intval($params['start']), + 'records' => intval($params['records']), + 'direction' => dbesc($params['direction']), + 'pages' => $params['pages'], + 'order' => dbesc('post'), + 'top' => $params['top'], + 'cat' => $params['cat'], + 'compat' => $params['compat'] + ], $channel, $observer_hash, CLIENT_MODE_NORMAL, App::$module + ); if($items) { $type = 'html'; @@ -1247,10 +1253,11 @@ function atom_author($tag, $name, $uri, $h, $w, $type, $photo) { $photo = xmlify($photo); $o .= "<$tag>\r\n"; - $o .= "$name\r\n"; - $o .= "$uri\r\n"; - $o .= '' . "\r\n"; - $o .= '' . "\r\n"; + $o .= " $uri\r\n"; + $o .= " $name\r\n"; + $o .= " $uri\r\n"; + $o .= ' ' . "\r\n"; + $o .= ' ' . "\r\n"; call_hooks('atom_author', $o); diff --git a/include/items.php b/include/items.php index 2e46ee3bd..d183ea815 100755 --- a/include/items.php +++ b/include/items.php @@ -3969,6 +3969,10 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } } + if(intval($arr['compat']) === 1) { + $sql_extra = " AND author_xchan = owner_xchan and item_wall = 1 and item_private = 0 "; + } + if ($arr['datequery']) { $sql_extra3 .= protect_sprintf(sprintf(" AND item.created <= '%s' ", dbesc(datetime_convert('UTC','UTC',$arr['datequery'])))); } -- cgit v1.2.3 From 4ca24f114b525004fc56e98cebb73a48e43e6c48 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 19 Apr 2017 20:48:10 -0700 Subject: support reverse magic-auth in oembed requests. --- include/oembed.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/oembed.php b/include/oembed.php index aac7d15b4..5865c95d5 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -149,7 +149,14 @@ function oembed_fetch_url($embedurl){ if ($action !== 'block') { // try oembed autodiscovery $redirects = 0; - $result = z_fetch_url($furl, false, $redirects, array('timeout' => 30, 'accept_content' => "text/*", 'novalidate' => true )); + $result = z_fetch_url($furl, false, $redirects, + [ + 'timeout' => 30, + 'accept_content' => "text/*", + 'novalidate' => true, + 'session' => ((local_channel() && $zrl) ? true : false) + ] + ); if($result['success']) $html_text = $result['body']; @@ -200,7 +207,7 @@ function oembed_fetch_url($embedurl){ if ($txt[0]!="{") $txt='{"type":"error"}'; - //save in cache + // save in cache if(! get_config('system','oembed_cache_disable')) Zlib\Cache::set('[' . App::$videowidth . '] ' . $furl, $txt); -- cgit v1.2.3 From c904bd3a628e4bf3c2420ee314277da69828c3b2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Apr 2017 20:19:15 -0700 Subject: The rest of the library and backend changes to support client-side e2ee and deprecate previous uses of item_obscured. --- include/items.php | 35 +++++++++-------------------------- include/text.php | 15 +-------------- 2 files changed, 10 insertions(+), 40 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index d183ea815..a94805bbc 100755 --- a/include/items.php +++ b/include/items.php @@ -612,6 +612,9 @@ function get_item_elements($x,$allow_code = false) { if(in_array('notshown',$x['flags'])) $arr['item_notshown'] = 1; + if(in_array('obscured',$x['flags'])) + $arr['item_obscured'] = 1; + // hidden item are no longer propagated - notshown may be a suitable alternative if(in_array('hidden',$x['flags'])) @@ -714,7 +717,7 @@ function get_item_elements($x,$allow_code = false) { // local only $arr['item_relay'] = $x['item_relay']; $arr['item_mentionsme'] = $x['item_mentionsme']; $arr['item_nocomment'] = $x['item_nocomment']; - // local only $arr['item_obscured'] = $x['item_obscured']; + $arr['item_obscured'] = $x['item_obscured']; // local only $arr['item_verified'] = $x['item_verified']; $arr['item_retained'] = $x['item_retained']; $arr['item_rss'] = $x['item_rss']; @@ -961,13 +964,6 @@ function encode_item($item,$mirror = false) { $key = get_config('system','prvkey'); - if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) { - if($item['title']) - $item['title'] = crypto_unencapsulate(json_decode($item['title'],true),$key); - if($item['body']) - $item['body'] = crypto_unencapsulate(json_decode($item['body'],true),$key); - } - // If we're trying to backup an item so that it's recoverable or for export/imprt, // add all the attributes we need to recover it @@ -1325,7 +1321,9 @@ function encode_item_flags($item) { $ret[] = 'nsfw'; if(intval($item['item_consensus'])) $ret[] = 'consensus'; - if(intval($item['item_private'])) + if(intval($item['item_obscured'])) + $ret[] = 'obscured'; + if(intval($item['item_privat'])) $ret[] = 'private'; return $ret; @@ -2546,15 +2544,7 @@ function tag_deliver($uid, $item_id) { // Now let's check if this mention was inside a reshare so we don't spam a forum // If it's private we may have to unobscure it momentarily so that we can parse it. - $body = ''; - - if(intval($item['item_obscured'])) { - $key = get_config('system','prvkey'); - if($item['body']) - $body = crypto_unencapsulate(json_decode($item['body'],true),$key); - } - else - $body = $item['body']; + $body = $item['body']; $body = preg_replace('/\[share(.*?)\[\/share\]/','',$body); @@ -2705,11 +2695,6 @@ function tgroup_check($uid,$item) { $body = $item['body']; - if(array_key_exists('item_obscured',$item) && intval($item['item_obscured']) && $body) { - $key = get_config('system','prvkey'); - $body = crypto_unencapsulate(json_decode($body,true),$key); - } - $body = preg_replace('/\[share(.*?)\[\/share\]/','',$body); // $pattern = '/@\!?\[zrl\=' . preg_quote($term['url'],'/') . '\]' . preg_quote($term['term'] . '+','/') . '\[\/zrl\]/'; @@ -2803,7 +2788,6 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { $item_origin = 1; $item_uplink = 0; $item_nocomment = 0; - $item_obscured = 0; $flag_bits = $item['item_flags']; @@ -2826,11 +2810,10 @@ function start_delivery_chain($channel, $item, $item_id, $parent) { $title = $item['title']; $body = $item['body']; - $r = q("update item set item_uplink = %d, item_nocomment = %d, item_obscured = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', + $r = q("update item set item_uplink = %d, item_nocomment = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d", intval($item_uplink), intval($item_nocomment), - intval($item_obscured), intval($flag_bits), dbesc($channel['channel_hash']), dbesc($channel['channel_allow_cid']), diff --git a/include/text.php b/include/text.php index 1fa03edab..24c2896ad 100644 --- a/include/text.php +++ b/include/text.php @@ -1379,20 +1379,7 @@ function link_compare($a, $b) { function unobscure(&$item) { - if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) { - $key = get_config('system','prvkey'); - if($item['title']) - $item['title'] = crypto_unencapsulate(json_decode($item['title'],true),$key); - if($item['body']) - $item['body'] = crypto_unencapsulate(json_decode($item['body'],true),$key); - if(get_config('system','item_cache')) { - q("update item set title = '%s', body = '%s', item_obscured = 0 where id = %d", - dbesc($item['title']), - dbesc($item['body']), - intval($item['id']) - ); - } - } + return; } function unobscure_mail(&$item) { -- cgit v1.2.3 From 1c304eb8ba5395e62c0245133d58a3f00adaeaac Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 26 Apr 2017 22:16:23 +0200 Subject: make mastodon happy args --- 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 24c2896ad..46509aabf 100644 --- a/include/text.php +++ b/include/text.php @@ -3140,4 +3140,4 @@ function ellipsify($s,$maxlen) { return $s; return mb_substr($s,0,$maxlen / 2) . '...' . mb_substr($s,mb_strlen($s) - ($maxlen / 2)); -} \ No newline at end of file +} -- cgit v1.2.3