From a84695bb866574f0e66471dbbd70668e8f9c2b41 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 22 Apr 2017 23:15:00 -0700 Subject: if there is no site record, site_dead won't be 0, in a left join it will in fact be null. As long as it isn't 1, we should attempt delivery. --- Zotlabs/Daemon/Notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php index 48f1d2757..3afe1a5dc 100644 --- a/Zotlabs/Daemon/Notifier.php +++ b/Zotlabs/Daemon/Notifier.php @@ -480,7 +480,7 @@ class Notifier { // Let's reduce this to a set of hubs; checking that the site is not dead. $r = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash in (" . implode(',',$recipients) . ") - and hubloc_error = 0 and hubloc_deleted = 0 and site_dead = 0" + and hubloc_error = 0 and hubloc_deleted = 0 and ( site_dead = 0 OR site_dead is null ) " ); -- cgit v1.2.3 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 +++++++++ view/tpl/page_display_empty.tpl | 1 + 2 files changed, 10 insertions(+) create mode 100644 view/tpl/page_display_empty.tpl 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'; diff --git a/view/tpl/page_display_empty.tpl b/view/tpl/page_display_empty.tpl new file mode 100644 index 000000000..9f000dee8 --- /dev/null +++ b/view/tpl/page_display_empty.tpl @@ -0,0 +1 @@ +{{$body}} \ No newline at end of file -- 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 --- Zotlabs/Module/Mail.php | 20 ++++++++++---------- boot.php | 2 +- include/message.php | 6 ++++-- install/schema_mysql.sql | 2 ++ install/schema_postgres.sql | 2 ++ install/update.php | 13 ++++++++++++- 6 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php index 2fb89fed5..52f1ddf32 100644 --- a/Zotlabs/Module/Mail.php +++ b/Zotlabs/Module/Mail.php @@ -113,18 +113,18 @@ class Mail extends \Zotlabs\Web\Controller { if($preview) { $mail = [ - 'mailbox' => 'outbox', - 'id' => 0, - 'mid' => 'M0', - 'from_name' => $channel['xchan_name'], - 'from_url' => $channel['xchan_url'], - 'from_photo' => $channel['xchan_photo_s'], - 'subject' => zidify_links(smilies(bbcode($subject))), - 'body' => zidify_links(smilies(bbcode($body))), + 'mailbox' => 'outbox', + 'id' => 0, + 'mid' => 'M0', + 'from_name' => $channel['xchan_name'], + 'from_url' => $channel['xchan_url'], + 'from_photo' => $channel['xchan_photo_s'], + 'subject' => zidify_links(smilies(bbcode($subject))), + 'body' => zidify_links(smilies(bbcode($body))), 'attachments' => '', - 'can_recall' => false, + 'can_recall' => false, 'is_recalled' => '', - 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c') + 'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c') ]; echo replace_macros(get_markup_template('mail_conv.tpl'), [ '$mail' => $mail ] ); diff --git a/boot.php b/boot.php index 38de30d6e..a61d12f26 100755 --- a/boot.php +++ b/boot.php @@ -52,7 +52,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'STD_VERSION', '2.3.4' ); define ( 'ZOT_REVISION', '1.2' ); -define ( 'DB_UPDATE_VERSION', 1189 ); +define ( 'DB_UPDATE_VERSION', 1190 ); define ( 'PROJECT_BASE', __DIR__ ); 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), diff --git a/install/schema_mysql.sql b/install/schema_mysql.sql index e075006e1..b64c1ae61 100644 --- a/install/schema_mysql.sql +++ b/install/schema_mysql.sql @@ -763,6 +763,7 @@ CREATE TABLE IF NOT EXISTS `mail` ( `to_xchan` char(255) NOT NULL DEFAULT '', `account_id` int(10) unsigned NOT NULL DEFAULT '0', `channel_id` int(10) unsigned NOT NULL DEFAULT '0', + `mail_mimetype` char(64) NOT NULL DEFAULT 'text/bbcode', `title` text NOT NULL, `body` mediumtext NOT NULL, `sig` text NOT NULL, @@ -775,6 +776,7 @@ CREATE TABLE IF NOT EXISTS `mail` ( `mail_seen` tinyint(4) NOT NULL DEFAULT '0', `mail_recalled` tinyint(4) NOT NULL DEFAULT '0', `mail_obscured` smallint(6) NOT NULL DEFAULT '0', + `mail_raw` tinyint(4) NOT NULL DEFAULT '0', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `expires` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY (`id`), diff --git a/install/schema_postgres.sql b/install/schema_postgres.sql index be72a85e1..0328040f4 100644 --- a/install/schema_postgres.sql +++ b/install/schema_postgres.sql @@ -751,6 +751,7 @@ CREATE TABLE "mail" ( "to_xchan" text NOT NULL DEFAULT '', "account_id" bigint NOT NULL DEFAULT '0', "channel_id" bigint NOT NULL DEFAULT '0', + "mail_mimetype char(64) NOT NULL DEFAULT '0', "title" text NOT NULL, "body" text NOT NULL, "sig" text NOT NULL, @@ -763,6 +764,7 @@ CREATE TABLE "mail" ( "mail_seen" smallint NOT NULL DEFAULT '0', "mail_recalled" smallint NOT NULL DEFAULT '0', "mail_obscured" smallint NOT NULL DEFAULT '0', + "mail_raw" smallint NOT NULL DEFAULT '0', "created" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', "expires" timestamp NOT NULL DEFAULT '0001-01-01 00:00:00', PRIMARY KEY ("id") diff --git a/install/update.php b/install/update.php index b37af9cef..84f1a799c 100644 --- a/install/update.php +++ b/install/update.php @@ -1,6 +1,6 @@ Date: Wed, 26 Apr 2017 01:08:03 -0700 Subject: Attribution is required --- images/emoji/README | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 images/emoji/README diff --git a/images/emoji/README b/images/emoji/README new file mode 100644 index 000000000..ab478b753 --- /dev/null +++ b/images/emoji/README @@ -0,0 +1,2 @@ +These files supplied by emojione. License is CC BY 4.0. Attribution is required for commercial use. +See http://emojione.com -- 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(-) 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(-) 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 --- Zotlabs/Module/Feed.php | 49 +++++++++++++++---------------- Zotlabs/Module/Wfinger.php | 18 ++++++++---- Zotlabs/Module/Xrd.php | 2 +- include/feedutils.php | 73 +++++++++++++++++++++++++--------------------- include/items.php | 4 +++ view/tpl/atom_feed.tpl | 7 ++--- 6 files changed, 83 insertions(+), 70 deletions(-) diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php index 47871eafb..06637b6d2 100644 --- a/Zotlabs/Module/Feed.php +++ b/Zotlabs/Module/Feed.php @@ -1,40 +1,41 @@ 1) { - $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", - dbesc(argv(1)) - ); - if(!($r && count($r))) + + if(observer_prohibited(true)) { killme(); - - $channel = $r[0]; - - if(observer_prohibited(true)) + } + + $channel = channelx_by_nick(argv(1)); + if(! $channel) { killme(); + } + - logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']); + logger('public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['channel_address']); echo get_public_feed($channel,$params); @@ -43,6 +44,4 @@ class Feed extends \Zotlabs\Web\Controller { } - - } diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 5c22772c4..3fdff691b 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -94,33 +94,39 @@ class Wfinger extends \Zotlabs\Web\Controller { $result['links'] = [ [ - 'rel' => 'http://webfinger.net/rel/avatar', + 'rel' => 'http://webfinger.net/rel/avatar', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_l'] ], [ - 'rel' => 'http://webfinger.net/rel/profile-page', + 'rel' => 'http://webfinger.net/rel/profile-page', 'href' => z_root() . '/profile/' . $r[0]['channel_address'], ], [ - 'rel' => 'http://webfinger.net/rel/blog', + 'rel' => 'http://schemas.google.com/g/2010#updates-from', + 'type' => 'application/atom+xml', + 'href' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1' + ], + + [ + 'rel' => 'http://webfinger.net/rel/blog', 'href' => z_root() . '/channel/' . $r[0]['channel_address'], ], [ - 'rel' => 'http://ostatus.org/schema/1.0/subscribe', + 'rel' => 'http://ostatus.org/schema/1.0/subscribe', 'template' => z_root() . '/follow/url={uri}', ], [ - 'rel' => 'http://purl.org/zot/protocol', + 'rel' => 'http://purl.org/zot/protocol', 'href' => z_root() . '/.well-known/zot-info' . '?address=' . $r[0]['xchan_addr'], ], [ - 'rel' => 'magic-public-key', + 'rel' => 'magic-public-key', 'href' => 'data:application/magic-public-key,' . salmon_key($r[0]['channel_pubkey']), ] ]; diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index 3ed19962b..ba650be55 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -57,7 +57,7 @@ class Xrd extends \Zotlabs\Web\Controller { '$aliases' => $aliases, '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], - '$atom' => z_root() . '/feed/' . $r[0]['channel_address'], + '$atom' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1', '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'], '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], 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'])))); } diff --git a/view/tpl/atom_feed.tpl b/view/tpl/atom_feed.tpl index fb606af27..ba50867ff 100755 --- a/view/tpl/atom_feed.tpl +++ b/view/tpl/atom_feed.tpl @@ -16,11 +16,8 @@ {{$red}} -{{if $hub}} - {{$hub}} -{{/if}} -{{if $salmon}} - {{$salmon}} +{{if $author}} +{{$author}} {{/if}} {{$feed_updated}} -- 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(-) 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 d48bda88e61026930866f947523f1c0cbe1659d2 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 20 Apr 2017 19:52:50 -0700 Subject: In the rare case where a default channel is not selected but channels actually exist, you should be able to visit /manage and set a default channel. Originally I believe this may have been possible but the ability was lost when delegation was added to the interface - which requires an active channel. Remove the active channel restriction so that the rest of the interface works (channel selections can be made and the ability to set a default is provided) however delegation info isn't presented unless there is an active channel. --- Zotlabs/Module/Manage.php | 160 ++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 78 deletions(-) diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index 3b7b3c3dd..e541ee077 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -46,107 +46,111 @@ class Manage extends \Zotlabs\Web\Controller { $channels = null; - if(local_channel()) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", - intval(get_account_id()) - ); + $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and channel_removed = 0 order by channel_name ", + intval(get_account_id()) + ); - $account = \App::get_account(); + $account = \App::get_account(); - if($r && count($r)) { - $channels = $r; - for($x = 0; $x < count($channels); $x ++) { - $channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']); - $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : ''); - $channels[$x]['default_links'] = '1'; + if($r && count($r)) { + $channels = $r; + for($x = 0; $x < count($channels); $x ++) { + $channels[$x]['link'] = 'manage/' . intval($channels[$x]['channel_id']); + $channels[$x]['default'] = (($channels[$x]['channel_id'] == $account['account_default_channel']) ? "1" : ''); + $channels[$x]['default_links'] = '1'; - $c = q("SELECT id, item_wall FROM item - WHERE item_unseen = 1 and uid = %d " . item_normal(), - intval($channels[$x]['channel_id']) - ); + $c = q("SELECT id, item_wall FROM item + WHERE item_unseen = 1 and uid = %d " . item_normal(), + intval($channels[$x]['channel_id']) + ); - if($c) { - foreach ($c as $it) { - if(intval($it['item_wall'])) - $channels[$x]['home'] ++; - else - $channels[$x]['network'] ++; - } + if($c) { + foreach ($c as $it) { + if(intval($it['item_wall'])) + $channels[$x]['home'] ++; + else + $channels[$x]['network'] ++; } + } - $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", - intval($channels[$x]['channel_id']) - ); + $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and abook_pending = 1 and abook_self = 0 and abook_ignored = 0 and xchan_deleted = 0 and xchan_orphan = 0 ", + intval($channels[$x]['channel_id']) + ); - if($intr) - $channels[$x]['intros'] = intval($intr[0]['total']); + if($intr) + $channels[$x]['intros'] = intval($intr[0]['total']); - $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", - intval($channels[$x]['channel_id']), - dbesc($channels[$x]['channel_hash']) - ); + $mails = q("SELECT count(id) as total from mail WHERE channel_id = %d AND mail_seen = 0 and from_xchan != '%s' ", + intval($channels[$x]['channel_id']), + dbesc($channels[$x]['channel_hash']) + ); - if($mails) - $channels[$x]['mail'] = intval($mails[0]['total']); + if($mails) + $channels[$x]['mail'] = intval($mails[0]['total']); - $events = q("SELECT etype, dtstart, adjust FROM event - WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 - ORDER BY dtstart ASC ", - intval($channels[$x]['channel_id']), - dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), - dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) - ); - - if($events) { - $channels[$x]['all_events'] = count($events); - - if($channels[$x]['all_events']) { - $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); - foreach($events as $e) { - $bd = false; - if($e['etype'] === 'birthday') { - $channels[$x]['birthdays'] ++; - $bd = true; - } - else { - $channels[$x]['events'] ++; - } - if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) { - $channels[$x]['all_events_today'] ++; - if($bd) - $channels[$x]['birthdays_today'] ++; - else - $channels[$x]['events_today'] ++; - } + $events = q("SELECT etype, dtstart, adjust FROM event + WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 + ORDER BY dtstart ASC ", + intval($channels[$x]['channel_id']), + dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), + dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) + ); + + if($events) { + $channels[$x]['all_events'] = count($events); + + if($channels[$x]['all_events']) { + $str_now = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y-m-d'); + foreach($events as $e) { + $bd = false; + if($e['etype'] === 'birthday') { + $channels[$x]['birthdays'] ++; + $bd = true; + } + else { + $channels[$x]['events'] ++; + } + if(datetime_convert('UTC', ((intval($e['adjust'])) ? date_default_timezone_get() : 'UTC'), $e['dtstart'], 'Y-m-d') === $str_now) { + $channels[$x]['all_events_today'] ++; + if($bd) + $channels[$x]['birthdays_today'] ++; + else + $channels[$x]['events_today'] ++; } } } } } - - $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0", - intval(get_account_id()) - ); - $limit = account_service_class_fetch(get_account_id(),'total_identities'); - if($limit !== false) { - $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit); - } - else { - $channel_usage_message = ''; - } + + } + + $r = q("select count(channel_id) as total from channel where channel_account_id = %d and channel_removed = 0", + intval(get_account_id()) + ); + $limit = account_service_class_fetch(get_account_id(),'total_identities'); + if($limit !== false) { + $channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit); } + else { + $channel_usage_message = ''; + } + $create = array( 'new_channel', t('Create a new channel'), t('Create New')); - $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where - abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )", - intval(local_channel()), - intval(local_channel()) - ); + $delegates = null; + + if(local_channel()) { + $delegates = q("select * from abook left join xchan on abook_xchan = xchan_hash where + abook_channel = %d and abook_xchan in ( select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'delegate' and v = '1' )", + intval(local_channel()), + intval(local_channel()) + ); + } if($delegates) { for($x = 0; $x < count($delegates); $x ++) { -- 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. --- Zotlabs/Module/Editpost.php | 13 ++++--------- Zotlabs/Module/Editwebpage.php | 13 ++++--------- Zotlabs/Module/Item.php | 1 + Zotlabs/Module/Viewsrc.php | 2 +- include/items.php | 35 +++++++++-------------------------- include/text.php | 15 +-------------- 6 files changed, 20 insertions(+), 59 deletions(-) diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index d7612b165..629bdd3fd 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -31,7 +31,10 @@ class Editpost extends \Zotlabs\Web\Controller { dbesc(get_observer_hash()) ); - if(! count($itm)) { + // don't allow web editing of potentially binary content (item_obscured = 1) + // @FIXME how do we do it instead? + + if((! $itm) || intval($itm[0]['item_obscured'])) { notice( t('Item is not editable') . EOL); return; } @@ -44,14 +47,6 @@ class Editpost extends \Zotlabs\Web\Controller { $channel = \App::get_channel(); - if(intval($itm[0]['item_obscured'])) { - $key = get_config('system','prvkey'); - if($itm[0]['title']) - $itm[0]['title'] = crypto_unencapsulate(json_decode($itm[0]['title'],true),$key); - if($itm[0]['body']) - $itm[0]['body'] = crypto_unencapsulate(json_decode($itm[0]['body'],true),$key); - } - $category = ''; $catsenabled = ((feature_enabled($owner_uid,'categories')) ? 'categories' : ''); diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 03b2aeab9..db33cd1db 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -100,19 +100,14 @@ class Editwebpage extends \Zotlabs\Web\Controller { intval($owner) ); - if(! $itm) { + // don't allow web editing of potentially binary content (item_obscured = 1) + // @FIXME how do we do it instead? + + if((! $itm) || intval($itm[0]['item_obscured'])) { notice( t('Permission denied.') . EOL); return; } - if(intval($itm[0]['item_obscured'])) { - $key = get_config('system','prvkey'); - if($itm[0]['title']) - $itm[0]['title'] = crypto_unencapsulate(json_decode($itm[0]['title'],true),$key); - if($itm[0]['body']) - $itm[0]['body'] = crypto_unencapsulate(json_decode($itm[0]['body'],true),$key); - } - $item_id = q("select * from iconfig where cat = 'system' and k = 'WEBPAGE' and iid = %d limit 1", intval($itm[0]['id']) ); diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 71f410b2a..9fddafee6 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -110,6 +110,7 @@ class Item extends \Zotlabs\Web\Controller { $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); $categories = ((x($_REQUEST,'category')) ? escape_tags($_REQUEST['category']) : ''); $webpage = ((x($_REQUEST,'webpage')) ? intval($_REQUEST['webpage']) : 0); + $item_obscured = ((x($_REQUEST,'obscured')) ? intval($_REQUEST['obscured']) : 0); $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags(urlencode($_REQUEST['pagetitle'])) : ''); $layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): ''); $plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : ''); diff --git a/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php index f84eddc69..54ab89e81 100644 --- a/Zotlabs/Module/Viewsrc.php +++ b/Zotlabs/Module/Viewsrc.php @@ -36,7 +36,7 @@ class Viewsrc extends \Zotlabs\Web\Controller { if($r) { if(intval($r[0]['item_obscured'])) - $r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'],true),get_config('system','prvkey')); + $dload = true; if($dload) { header('Content-type: ' . $r[0]['mimetype']); 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 --- Zotlabs/Module/Wfinger.php | 2 +- Zotlabs/Module/Xrd.php | 2 +- include/text.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zotlabs/Module/Wfinger.php b/Zotlabs/Module/Wfinger.php index 3fdff691b..118ec5e7c 100644 --- a/Zotlabs/Module/Wfinger.php +++ b/Zotlabs/Module/Wfinger.php @@ -107,7 +107,7 @@ class Wfinger extends \Zotlabs\Web\Controller { [ 'rel' => 'http://schemas.google.com/g/2010#updates-from', 'type' => 'application/atom+xml', - 'href' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1' + 'href' => z_root() . '/feed/' . $r[0]['channel_address'] . '/?compat=1' ], [ diff --git a/Zotlabs/Module/Xrd.php b/Zotlabs/Module/Xrd.php index ba650be55..7fd81e490 100644 --- a/Zotlabs/Module/Xrd.php +++ b/Zotlabs/Module/Xrd.php @@ -57,7 +57,7 @@ class Xrd extends \Zotlabs\Web\Controller { '$aliases' => $aliases, '$profile_url' => z_root() . '/channel/' . $r[0]['channel_address'], '$hcard_url' => z_root() . '/hcard/' . $r[0]['channel_address'], - '$atom' => z_root() . '/feed/' . $r[0]['channel_address'] . '?f=&compat=1', + '$atom' => z_root() . '/feed/' . $r[0]['channel_address'] . '/?compat=1', '$zot_post' => z_root() . '/post/' . $r[0]['channel_address'], '$poco_url' => z_root() . '/poco/' . $r[0]['channel_address'], '$photo' => z_root() . '/photo/profile/l/' . $r[0]['channel_id'], 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