From b033597ada02ef045bc9fbdb2237f81935b73e47 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 11 Nov 2019 21:30:38 +0100 Subject: sse notifications --- include/channel.php | 5 +++++ include/event.php | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 29835eac6..32bd596fc 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2953,3 +2953,8 @@ function pchan_to_chan($pchan) { function channel_url($channel) { return (($channel) ? z_root() . '/channel/' . $channel['channel_address'] : z_root()); } + +function get_channel_hashes() { + $r = q("SELECT channel_hash FROM channel WHERE channel_removed = 0"); + return flatten_array_recursive($r); +} diff --git a/include/event.php b/include/event.php index 6be1b6705..9d76aabd6 100644 --- a/include/event.php +++ b/include/event.php @@ -553,9 +553,19 @@ function event_store_event($arr) { dbesc($hash), intval($arr['uid']) ); - if($r) + if($r) { + + /** + * @hooks event_store_event_end + * Called after an event record was stored. + * * \e array \b event + */ + call_hooks('event_store_event_end', $r[0]); + return $r[0]; + } + return false; } -- cgit v1.2.3 From 2f4c619d510e64eeda05366e485d50f490cefebe Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 12 Nov 2019 20:25:25 -0800 Subject: wildcard tag issue --- include/text.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index daa3c4c94..44af40810 100644 --- a/include/text.php +++ b/include/text.php @@ -2789,6 +2789,9 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) // select someone by attag or nick and the name passed in if(! $r) { + // strip user-supplied wildcards before running a wildcard search + $newname = str_replace('%','',$newname); + $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash WHERE xchan_addr like ('%s') AND abook_channel = %d ", dbesc(((strpos($newname,'@')) ? $newname : $newname . '@%')), -- cgit v1.2.3 From de9a7f0fa909792656d26d369f2ff21c57fc1e4d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 09:55:44 +0000 Subject: make inline pdf a security option, move thumbnail security to security options from admin/site --- include/oembed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/oembed.php b/include/oembed.php index ee9e57c3f..eeae7a174 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -146,7 +146,7 @@ function oembed_fetch_url($embedurl){ $txt = Cache::get('[' . App::$videowidth . '] ' . $furl); } - if(strpos(strtolower($embedurl),'.pdf') !== false) { + if(strpos(strtolower($embedurl),'.pdf') !== false && get_config('system','inline_pdf')) { $action = 'allow'; $j = [ 'html' => '', -- cgit v1.2.3 From 5a6b14f8787927ee6ea99c622d02875811d3a74a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 15 Nov 2019 10:01:21 +0000 Subject: onepoll: do not update dead feeds --- include/feedutils.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 9f4d732bb..6d14eb5c4 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -1760,7 +1760,11 @@ function handle_feed($uid, $abook_id, $url) { if($z['success']) { consume_feed($z['body'], $channel, $x[0], 1); consume_feed($z['body'], $channel, $x[0], 2); + return true; } + + return false; + } -- cgit v1.2.3 From dc2f29308959895349ac34b154c14d0f3078bd43 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 18 Nov 2019 15:42:14 +0100 Subject: Update opengraph.php --- include/opengraph.php | 123 ++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 63 deletions(-) (limited to 'include') diff --git a/include/opengraph.php b/include/opengraph.php index 9de021d54..4c88570d3 100644 --- a/include/opengraph.php +++ b/include/opengraph.php @@ -3,73 +3,70 @@ * @file include/opengraph.php * @brief Add Opengraph metadata and related functions. */ - - + + /** * @brief Adds Opengraph meta tags into HTML head * * @param array $item - * @param array $profile + * @param array $channel * */ - - function opengraph_add_meta($item, $profile) { - - if(! empty($item)) { - - if(! empty($item['title'])) - $ogtitle = $item['title']; - - // find first image if exist - if(preg_match("/\[[zi]mg(=[0-9]+x[0-9]+)?\]([^\[]+)/is", $item['body'], $matches)) { - $ogimage = $matches[2]; - $ogimagetype = guess_image_type($ogimage); - } - - // use summary as description if exist - $ogdesc = (empty($item['summary']) ? $item['body'] : $item['summary'] ); - - $ogdesc = str_replace("#^[", "[", $ogdesc); - - $ogdesc = bbcode($ogdesc, [ 'tryoembed' => false ]); - $ogdesc = trim(html2plain($ogdesc, 0, true)); - $ogdesc = html_entity_decode($ogdesc, ENT_QUOTES, 'UTF-8'); - - // remove all URLs - $ogdesc = preg_replace("/https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+/", "", $ogdesc); - - // shorten description - $ogdesc = substr($ogdesc, 0, 300); - $ogdesc = str_replace("\n", " ", $ogdesc); - while (strpos($ogdesc, " ") !== false) - $ogdesc = str_replace(" ", " ", $ogdesc); - $ogdesc = (strlen($ogdesc) < 298 ? $ogdesc : rtrim(substr($ogdesc, 0, strrpos($ogdesc, " ")), "?.,:;!-") . "..."); - - $ogtype = "article"; - } - - $channel = channelx_by_n($profile['profile_uid']); - - if(! isset($ogdesc)) { - if($profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) { - $ogdesc = $profile['about']; - } - else { - $ogdesc = sprintf( t('This is the home page of %s.'), $channel['channel_name']); - } - } - - if(! isset($ogimage)) { - $ogimage = $channel['xchan_photo_l']; - $ogimagetype = $channel['xchan_photo_mimetype']; - } - - App::$page['htmlhead'] .= '' . "\r\n"; - App::$page['htmlhead'] .= '' . "\r\n"; - App::$page['htmlhead'] .= '' . "\r\n"; - App::$page['htmlhead'] .= '' . "\r\n"; - App::$page['htmlhead'] .= '' . "\r\n"; - - return true; + + function opengraph_add_meta($item, $channel) { + + if(! empty($item)) { + + if(! empty($item['title'])) + $ogtitle = $item['title']; + + // find first image if exist + if(preg_match("/\[[zi]mg(=[0-9]+x[0-9]+)?\]([^\[]+)/is", $item['body'], $matches)) { + $ogimage = $matches[2]; + $ogimagetype = guess_image_type($ogimage); + } + + // use summary as description if exist + $ogdesc = (empty($item['summary']) ? $item['body'] : $item['summary'] ); + + $ogdesc = str_replace("#^[", "[", $ogdesc); + + $ogdesc = bbcode($ogdesc, [ 'tryoembed' => false ]); + $ogdesc = trim(html2plain($ogdesc, 0, true)); + $ogdesc = html_entity_decode($ogdesc, ENT_QUOTES, 'UTF-8'); + + // remove all URLs + $ogdesc = preg_replace("/https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+/", "", $ogdesc); + + // shorten description + $ogdesc = substr($ogdesc, 0, 300); + $ogdesc = str_replace("\n", " ", $ogdesc); + while (strpos($ogdesc, " ") !== false) + $ogdesc = str_replace(" ", " ", $ogdesc); + $ogdesc = (strlen($ogdesc) < 298 ? $ogdesc : rtrim(substr($ogdesc, 0, strrpos($ogdesc, " ")), "?.,:;!-") . "..."); + + $ogtype = "article"; + } + + if(! isset($ogdesc)) { + if(App::$profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) { + $ogdesc = App::$profile['about']; + } + else { + $ogdesc = sprintf( t('This is the home page of %s.'), $channel['channel_name']); + } + } + + if(! isset($ogimage)) { + $ogimage = $channel['xchan_photo_l']; + $ogimagetype = $channel['xchan_photo_mimetype']; + } + + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + App::$page['htmlhead'] .= '' . "\r\n"; + + return true; } - \ No newline at end of file -- cgit v1.2.3 From 23c47f78eada85c1f897bbf348a4f802db9ef2f9 Mon Sep 17 00:00:00 2001 From: "M. Dent" Date: Fri, 22 Nov 2019 14:59:45 +0100 Subject: More descriptive connection status icons --- include/text.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 44af40810..d19f4b782 100644 --- a/include/text.php +++ b/include/text.php @@ -1016,10 +1016,27 @@ function contact_block() { // There is no setting to discover if you are bi-directionally connected // Use the ability to post comments as an indication that this relationship is more // than wishful thinking; even though soapbox channels and feeds will disable it. + $rr['perminfo']['connpermcount']=0; + $rr['perminfo']['connperms']=t('Accepts').': '; + if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { + $rr['perminfo']['connpermcount']++; + $rr['perminfo']['connperms'] .= t('Comments'); + } + if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','send_stream'))) { + $rr['perminfo']['connpermcount']++; + $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ',' : $rr['perminfo']['connperms'] ; + $rr['perminfo']['connperms'] .= t('Stream items'); + } + if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_wall'))) { + $rr['perminfo']['connpermcount']++; + $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ',' : $rr['perminfo']['connperms'] ; + $rr['perminfo']['connperms'] .= t('Wall posts'); + } - if(! intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_comments'))) { - $rr['oneway'] = true; + if ($rr['perminfo']['connpermcount'] == 0) { + $rr['perminfo']['connperms'] .= t('nothing'); } + $micropro[] = micropro($rr,true,'mpfriend'); } } @@ -1086,6 +1103,7 @@ function micropro($contact, $redirect = false, $class = '', $mode = false) { '$click' => (($contact['click']) ? $contact['click'] : ''), '$class' => $class . (($contact['archived']) ? ' archived' : ''), '$oneway' => (($contact['oneway']) ? true : false), + '$perminfo' => $contact['perminfo'], '$url' => $url, '$photo' => $contact['xchan_photo_s'], '$name' => $contact['xchan_name'], -- cgit v1.2.3 From b62eb665c5ad12ec7bde6bace71a0ddbb6aac28d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 22 Nov 2019 14:11:26 +0000 Subject: sse: store the item mid plus reactions mids in data-mids and change functions accordingly --- include/conversation.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index e2dd02ffc..95eb1daad 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1172,6 +1172,9 @@ function builtin_activity_puller($item, &$conv_responses) { if(! $item['thr_parent']) $item['thr_parent'] = $item['parent_mid']; + + $conv_responses[$mode]['mids'][$item['thr_parent']][] = 'b64.' . base64url_encode($item['mid']); + if(! ((isset($conv_responses[$mode][$item['thr_parent'] . '-l'])) && (is_array($conv_responses[$mode][$item['thr_parent'] . '-l'])))) $conv_responses[$mode][$item['thr_parent'] . '-l'] = array(); -- cgit v1.2.3 From e6b1b2056542735034d24dbe057e1cb1bf9e93e7 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 22 Nov 2019 19:28:37 +0100 Subject: Add space after comma in connection accepted interactions list --- include/text.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index d19f4b782..eba41521d 100644 --- a/include/text.php +++ b/include/text.php @@ -1024,17 +1024,17 @@ function contact_block() { } if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','send_stream'))) { $rr['perminfo']['connpermcount']++; - $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ',' : $rr['perminfo']['connperms'] ; + $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ', ' : $rr['perminfo']['connperms'] ; $rr['perminfo']['connperms'] .= t('Stream items'); } if(intval(get_abconfig(App::$profile['uid'],$rr['xchan_hash'],'their_perms','post_wall'))) { $rr['perminfo']['connpermcount']++; - $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ',' : $rr['perminfo']['connperms'] ; + $rr['perminfo']['connperms'] = ($rr['perminfo']['connperms']) ? $rr['perminfo']['connperms'] . ', ' : $rr['perminfo']['connperms'] ; $rr['perminfo']['connperms'] .= t('Wall posts'); } if ($rr['perminfo']['connpermcount'] == 0) { - $rr['perminfo']['connperms'] .= t('nothing'); + $rr['perminfo']['connperms'] .= t('Nothing'); } $micropro[] = micropro($rr,true,'mpfriend'); -- cgit v1.2.3 From c1aa96ebf70fd5b6426d96bf7d7e771dfc4ca9ab Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 29 Nov 2019 19:46:13 +0000 Subject: sse: template fixes, fix missing forum notifications and minor impovements --- include/conversation.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 95eb1daad..e8b8051bb 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -736,6 +736,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa 'delete' => t('Delete'), 'preview_lbl' => $preview_lbl, 'id' => (($preview) ? 'P0' : $item['item_id']), + 'mids' => json_encode(['b64.' . base64url_encode($item['mid'])]), 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_url), 'profile_url' => $profile_link, 'thread_action_menu' => thread_action_menu($item,$mode), -- cgit v1.2.3 From 21b398252aaf28d9ff8045fbe3e9fcb162a6f447 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Wed, 4 Dec 2019 03:44:24 +0100 Subject: Add content pinning support --- include/js_strings.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/js_strings.php b/include/js_strings.php index f01fa87ae..6f559f4c4 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -33,7 +33,10 @@ function js_strings() { '$name_empty' => t('A channel name is required.'), '$name_ok1' => t('This is a '), '$name_ok2' => t(' channel name'), - '$to_reply' => t('Back to reply'), + '$to_reply' => t('Back to reply'), + '$pinned' => t('Pinned'), + '$pin_item' => t('Pin to the top'), + '$unpin_item' => t('Unpin from the top'), // translatable prefix and suffix strings for jquery.timeago - // using the defaults set below if left untranslated, empty strings if -- cgit v1.2.3 From aed682305173a67b2af1a56b8595445bec690e2b Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sat, 7 Dec 2019 20:14:17 +0100 Subject: Add .webp image format support --- include/attach.php | 19 +++++++++++++------ include/photo/photo_driver.php | 2 ++ include/text.php | 1 + 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 80efe0838..952270949 100644 --- a/include/attach.php +++ b/include/attach.php @@ -56,6 +56,7 @@ function z_mime_content_type($filename) { 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', + 'webp' => 'image/webp', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', @@ -616,7 +617,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $is_photo = 0; $gis = @getimagesize($src); logger('getimagesize: ' . print_r($gis,true), LOGGER_DATA); - if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) { + if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG || $gis[2] === IMAGETYPE_WEBP)) { $is_photo = 1; if($gis[2] === IMAGETYPE_GIF) $def_extension = '.gif'; @@ -624,6 +625,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $def_extension = '.jpg'; if($gis[2] === IMAGETYPE_PNG) $def_extension = '.png'; + if($gis[2] === IMAGETYPE_WEBP) + $def_extension = '.webp'; } // If we know it's a photo, over-ride the type in case the source system could not determine what it was @@ -908,7 +911,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { ); } - if($is_photo) { + if($is_photo && $r) { $args = array( 'source' => $source, 'visible' => $visible, 'resource_id' => $hash, 'album' => $pathname, 'os_syspath' => $os_basepath . $os_relpath, 'os_path' => $os_path, 'display_path' => $display_path, 'filename' => $filename, 'getimagesize' => $gis, 'directory' => $direct, 'options' => $options ); if($arr['contact_allow']) @@ -942,9 +945,15 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $args['deliver'] = $dosync; $p = photo_upload($channel,$observer,$args); - if($p['success']) { - $ret['body'] = $p['body']; + if($p['success']) + $ret['body'] = $p['body']; + else { + // Attach as ordinary file if image processing is failed + $x = q("UPDATE attach SET is_photo = 0 WHERE hash = '%s'", + dbesc($hash) + ); } + } if(($options !== 'update') && ($remove_when_processed)) @@ -2654,5 +2663,3 @@ function save_chunk($channel,$start,$end,$len) { $result['length'] = intval(filesize($new_path)); return $result; } - - diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index c11580bdc..284206161 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -135,6 +135,8 @@ function guess_image_type($filename, $headers = '') { $type = 'image/gif'; elseif(strpos(strtolower($filename),'png') !== false) $type = 'image/png'; + elseif(strpos(strtolower($filename),'webp') !== false) + $type = 'image/webp'; } } diff --git a/include/text.php b/include/text.php index eba41521d..87ed9f658 100644 --- a/include/text.php +++ b/include/text.php @@ -2992,6 +2992,7 @@ function getIconFromType($type) { 'image/jpeg' => 'fa-picture-o', 'image/png' => 'fa-picture-o', 'image/gif' => 'fa-picture-o', + 'image/webp' => 'fa-picture-o', 'image/svg+xml' => 'fa-picture-o', //Archive 'application/zip' => 'fa-file-archive-o', -- cgit v1.2.3 From 5c4301369235b7f03a4654e81ded6b9da3b98891 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Jan 2020 08:20:01 +0000 Subject: deal with situations where we do not have an xchan_addr but only an xchan_url --- include/conversation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index e8b8051bb..a80adb933 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1010,11 +1010,11 @@ function thread_author_menu($item, $mode = '') { $contact = App::$contacts[$item['author_xchan']]; } else { - if($local_channel && $item['author']['xchan_addr'] && (! in_array($item['author']['xchan_network'],[ 'rss', 'anon','unknown' ]))) { - $follow_url = z_root() . '/follow/?f=&url=' . urlencode($item['author']['xchan_addr']) . '&interactive=0'; + $url = (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']); + if($local_channel && $url && (! in_array($item['author']['xchan_network'],[ 'rss', 'anon','unknown' ]))) { + $follow_url = z_root() . '/follow/?f=&url=' . urlencode($url) . '&interactive=0'; } } - if($item['uid'] > 0 && author_is_pmable($item['author'],$contact)) { $pm_url = z_root() . '/mail/new/?f=&hash=' . urlencode($item['author_xchan']); } -- cgit v1.2.3 From a1ccacb825edac6ae36e5db4f62ebfe7aeaebe9f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 12 Jan 2020 18:24:59 +0100 Subject: Fix wrong URL detection with Markdown support enabled --- include/markdown.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/markdown.php b/include/markdown.php index 69cc264df..0bfe595b8 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -76,7 +76,7 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = html2bbcode($s); - $s = bb_code_protect($s); + // $s = bb_code_protect($s); // Convert everything that looks like a link to a link if($use_zrl) { @@ -84,13 +84,13 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = preg_replace_callback("/\[img\](.*?)\[\/img\]/ism", 'use_zrl_cb_img', $s); $s = preg_replace_callback("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", 'use_zrl_cb_img_x', $s); } - $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", 'use_zrl_cb_link',$s); + $s = preg_replace_callback("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", 'use_zrl_cb_link',$s); } else { - $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]',$s); + $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)([\,\.\:\;]\s|$)/ismu", '$1[url=$2$3]$2$3[/url]$4',$s); } - $s = bb_code_unprotect($s); + // $s = bb_code_unprotect($s); // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); @@ -110,9 +110,9 @@ function use_zrl_cb_link($match) { $is_zid = is_matrix_url(trim($match[0])); if($is_zid) - $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]'; + $res = $match[1] . '[zrl=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/zrl]' . $match[4]; else - $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]'; + $res = $match[1] . '[url=' . $match[2] . $match[3] . ']' . $match[2] . $match[3] . '[/url]' . $match[4]; return $res; } -- cgit v1.2.3 From d3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Jan 2020 22:41:28 -0800 Subject: rework activitystreams events - send invite/event activities instead of create/event. Also a first pass at creating a Zap export file from Hubzilla. Much more work is needed before this is functional. --- include/channel.php | 17 ++++++++++++++--- include/event.php | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 32bd596fc..e7d119b1e 100644 --- a/include/channel.php +++ b/include/channel.php @@ -796,7 +796,7 @@ function get_default_export_sections() { * @return array * See function for details */ -function identity_basic_export($channel_id, $sections = null) { +function identity_basic_export($channel_id, $sections = null, $zap_compat = false) { /* * basic channel export @@ -812,12 +812,16 @@ function identity_basic_export($channel_id, $sections = null) { // with a non-standard platform and version. $ret['compatibility'] = [ - 'project' => PLATFORM_NAME, + 'project' => (($zap_compat) ? 'zap' : PLATFORM_NAME), 'version' => STD_VERSION, 'database' => DB_UPDATE_VERSION, 'server_role' => System::get_server_role() ]; + if ($zap_compat) { + $ret['compatibility']['codebase'] = 'zap'; + } + /* * Process channel information regardless of it is one of the sections desired * because we need the channel relocation information in all export files/streams. @@ -834,6 +838,13 @@ function identity_basic_export($channel_id, $sections = null) { unset($ret['channel']['channel_password']); unset($ret['channel']['channel_salt']); } + if ($zap_compat) { + $channel['channel_guid_sig'] = 'sha256.' . $channel['channel_guid_sig']; + $channel['channel_hash'] = $channel['channel_portable_id']; + unset($channel['channel_portable_id']); + } + + } if(in_array('channel',$sections) || in_array('profile',$sections)) { @@ -853,7 +864,7 @@ function identity_basic_export($channel_id, $sections = null) { $ret['photo'] = [ 'type' => $r[0]['mimetype'], 'data' => (($r[0]['os_storage']) - ? base64url_encode(file_get_contents($r[0]['content'])) : base64url_encode($r[0]['content'])) + ? base64url_encode(file_get_contents($r[0]['content'])) : base64url_encode(dbunescbin($r[0]['content']))) ]; } } diff --git a/include/event.php b/include/event.php index 9d76aabd6..30dca2df2 100644 --- a/include/event.php +++ b/include/event.php @@ -1194,7 +1194,7 @@ function event_store_item($arr, $event) { if(! $arr['mid']) { $arr['uuid'] = $event['event_hash']; - $arr['mid'] = z_root() . '/event/' . $event['event_hash']; + $arr['mid'] = z_root() . '/activity/' . $event['event_hash']; } $item_arr['aid'] = $z[0]['channel_account_id']; -- cgit v1.2.3 From 2a287e6def5ab54037222c963ab0875faf62fc1a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Jan 2020 13:29:45 -0800 Subject: event compatibility work --- include/event.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 30dca2df2..59057e7d5 100644 --- a/include/event.php +++ b/include/event.php @@ -250,7 +250,7 @@ function format_ical_sourcetext($s) { } -function format_event_bbcode($ev) { +function format_event_bbcode($ev, $utc = false) { $o = ''; @@ -258,6 +258,14 @@ function format_event_bbcode($ev) { $o .= '[event]' . $ev['event_vdata'] . '[/event]'; } + if ($utc && $ev['event-timezone'] !== 'UTC') { + $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart'],ATOM_TIME); + if ($ev['dtend'] && ! $ev['nofinish']) { + $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend'],ATOM_TIME); + } + $ev['timezone'] = 'UTC'; + } + if($ev['summary']) $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]'; -- cgit v1.2.3 From 17a4aa983ef1d5b68195d91f78ac04bc48085b1b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 17 Jan 2020 21:31:37 +0000 Subject: $owner in get_feed_for() is the atom rendered channel, for atom_entry we need the owners channel_id though. --- include/feedutils.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 6d14eb5c4..9ff09cc66 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -155,7 +155,7 @@ function get_feed_for($channel, $observer_hash, $params) { if($item['item_private']) continue; - $atom .= atom_entry($item, $type, null, $owner, true, '', $params['compat']); + $atom .= atom_entry($item, $type, null, $channel, true, '', $params['compat']); } } @@ -1921,7 +1921,7 @@ function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0, $ $summary = ''; if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) - $body = fix_private_photos($body,$owner['uid'],$item,$cid); + $body = fix_private_photos($body,$owner['channel_id'],$item,$cid); if($compat) { $compat_photos = compat_photos_list($body); -- cgit v1.2.3 From 7404a8ec1a0980fa3448ca6b05e410ea36c6a5f2 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 14:19:31 +0000 Subject: implement bdi tags via bbcode where possible --- include/bbcode.php | 8 +++++++- include/conversation.php | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index c7dea53c5..301ffbd24 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -382,7 +382,7 @@ function bb_ShareAttributes($match) { // Bob Smith wrote the following post 2 hours ago $fmt = sprintf( t('%1$s wrote the following %2$s %3$s'), - '' . $author . '', + '' . $author . '', '' . $type . '', $reldate ); @@ -1111,6 +1111,12 @@ function bbcode($Text, $options = []) { if (strpos($Text,'[/footer]') !== false) { $Text = preg_replace("(\[footer\](.*?)\[\/footer\])ism", "
$1
", $Text); } + + // Check for bdi + if (strpos($Text,'[/bdi]') !== false) { + $Text = preg_replace("(\[bdi\](.*?)\[\/bdi\])ism", "$1", $Text); + } + // Check for list text $Text = preg_replace("/
\[\*\]/ism",'[*]',$Text); diff --git a/include/conversation.php b/include/conversation.php index a80adb933..1aa34ae85 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -172,9 +172,9 @@ function localize_item(&$item){ $shortbodyverb = t('doesn\'t like %1$s\'s %2$s'); } - $item['shortlocalize'] = sprintf($shortbodyverb, $objauthor, $plink); + $item['shortlocalize'] = sprintf($shortbodyverb, '[bdi]' . $objauthor . '[/bdi]', $plink); - $item['body'] = $item['localize'] = sprintf($bodyverb, $author, $objauthor, $plink); + $item['body'] = $item['localize'] = sprintf($bodyverb, '[bdi]' . $author . '[/bdi]', '[bdi]' . $objauthor . '[/bdi]', $plink); if($Bphoto != "") $item['body'] .= "\n\n\n" . '[zrl=' . chanlink_url($author_link) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]'; -- cgit v1.2.3 From 9eeccc087dbba93d5d67c242666fe257cc35f3ee Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 14:23:23 +0000 Subject: move mail frontend to addons and remove mail app from system apps --- include/message.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/message.php b/include/message.php index 7d05b9ab7..37fe6749d 100644 --- a/include/message.php +++ b/include/message.php @@ -299,10 +299,6 @@ function create_conversation($channel,$recipient,$subject) { } - - - - function private_messages_list($uid, $mailbox = '', $start = 0, $numitems = 0) { $where = ''; -- cgit v1.2.3 From 570d84c031d9cdf0e16aa79bc4a7a111345cc3f3 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 16:04:40 +0000 Subject: fix shortlocalize --- 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 1aa34ae85..3c86bef3c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -172,7 +172,7 @@ function localize_item(&$item){ $shortbodyverb = t('doesn\'t like %1$s\'s %2$s'); } - $item['shortlocalize'] = sprintf($shortbodyverb, '[bdi]' . $objauthor . '[/bdi]', $plink); + $item['shortlocalize'] = sprintf($shortbodyverb, '[bdi]' . $author_name . '[/bdi]', $post_type); $item['body'] = $item['localize'] = sprintf($bodyverb, '[bdi]' . $author . '[/bdi]', '[bdi]' . $objauthor . '[/bdi]', $plink); if($Bphoto != "") -- cgit v1.2.3 From cbaf4b7536c0b056bc8079aa39b24f2e2c312dd6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 20:00:37 +0000 Subject: introduce db_str_to_date() --- include/dba/dba_driver.php | 4 ++++ include/dba/dba_pdo.php | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'include') diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index cfb208e2d..b96601fec 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -307,6 +307,10 @@ function db_use_index($str) { return \DBA::$dba->use_index($str); } +function db_str_to_date($str) { + return \DBA::$dba->str_to_date($str); +} + /** * @brief Execute a SQL query with printf style args. * diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index 0279342ec..0ae69fe27 100755 --- a/include/dba/dba_pdo.php +++ b/include/dba/dba_pdo.php @@ -139,6 +139,15 @@ class dba_pdo extends dba_driver { } } + function str_to_date($str) { + if($this->driver_dbtype === 'pgsql') { + return "TO_TIMESTAMP($str, 'YYYY-MM-DD HH:MI:SS')"; + } + else { + return "STR_TO_DATE($str, '%Y-%m-%d %H:%i:%s')"; + } + } + function quote_interval($txt) { if($this->driver_dbtype === 'pgsql') { return "'$txt'"; -- cgit v1.2.3 From 43aea3ce38bf6fd9c5b778dc71a977eca711c26d Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Jan 2020 20:05:05 +0000 Subject: we need 24h format --- include/dba/dba_pdo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index 0ae69fe27..49f741601 100755 --- a/include/dba/dba_pdo.php +++ b/include/dba/dba_pdo.php @@ -141,7 +141,7 @@ class dba_pdo extends dba_driver { function str_to_date($str) { if($this->driver_dbtype === 'pgsql') { - return "TO_TIMESTAMP($str, 'YYYY-MM-DD HH:MI:SS')"; + return "TO_TIMESTAMP($str, 'YYYY-MM-DD HH24:MI:SS')"; } else { return "STR_TO_DATE($str, '%Y-%m-%d %H:%i:%s')"; -- cgit v1.2.3 From b81b18814ef2b4600224a08c6f97e4f1f227982d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 19 Jan 2020 21:55:15 +0100 Subject: Don't validate domain with PTR record; remove uneccessary CNAME check; add IPv6 check --- 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 f6992291d..c2edb4f8a 100644 --- a/include/network.php +++ b/include/network.php @@ -505,7 +505,7 @@ function z_dns_check($h,$check_mx = 0) { // Otherwise we will assume dns_get_record() works as documented - $opts = DNS_A + DNS_CNAME + DNS_PTR; + $opts = DNS_A + DNS_AAAA; if($check_mx) $opts += DNS_MX; -- cgit v1.2.3 From 7973567a7c9ef531f1e3877066dab71599895e0d Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Jan 2020 09:30:24 +0000 Subject: more shortlocalize and bdi tags --- include/conversation.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 3c86bef3c..07d43e660 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -205,10 +205,12 @@ function localize_item(&$item){ $Bname = $obj['title']; - $A = '[zrl=' . chanlink_url($Alink) . ']' . $Aname . '[/zrl]'; - $B = '[zrl=' . chanlink_url($Blink) . ']' . $Bname . '[/zrl]'; + $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]'; + $B = '[zrl=' . chanlink_url($Blink) . '][bdi]' . $Bname . '[/bdi][/zrl]'; if ($Bphoto!="") $Bphoto = '[zrl=' . chanlink_url($Blink) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]'; + $item['shortlocalize'] = sprintf( t('%1$s is now connected with %2$s'), '[bdi]' . $Aname . '[/bdi]', '[bdi]' . $Bname . '[/bdi]'); + $item['body'] = $item['localize'] = sprintf( t('%1$s is now connected with %2$s'), $A, $B); $item['body'] .= "\n\n\n" . $Bphoto; } @@ -237,8 +239,8 @@ function localize_item(&$item){ } $Bname = $obj['title']; - $A = '[zrl=' . chanlink_url($Alink) . ']' . $Aname . '[/zrl]'; - $B = '[zrl=' . chanlink_url($Blink) . ']' . $Bname . '[/zrl]'; + $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]'; + $B = '[zrl=' . chanlink_url($Blink) . '][bdi]' . $Bname . '[/bdi][/zrl]'; if ($Bphoto!="") $Bphoto = '[zrl=' . chanlink_url($Blink) . '][zmg=80x80]' . $Bphoto . '[/zmg][/zrl]'; // we can't have a translation string with three positions but no distinguishable text @@ -252,6 +254,8 @@ function localize_item(&$item){ // then do the sprintf on the translation string + $item['shortlocalize'] = sprintf($txt, '[bdi]' . $Aname . '[/bdi]', '[bdi]' . $Bname . '[/bdi]'); + $item['body'] = $item['localize'] = sprintf($txt, $A, $B); $item['body'] .= "\n\n\n" . $Bphoto; } @@ -263,7 +267,7 @@ function localize_item(&$item){ $Aname = $item['author']['xchan_name']; $Alink = $item['author']['xchan_url']; - $A = '[zrl=' . chanlink_url($Alink) . ']' . $Aname . '[/zrl]'; + $A = '[zrl=' . chanlink_url($Alink) . '][bdi]' . $Aname . '[/bdi][/zrl]'; $txt = t('%1$s is %2$s','mood'); -- cgit v1.2.3 From 8789edb65db0945d2996e39c15a995c19f7214bc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Jan 2020 14:24:46 +0000 Subject: make sure we import the zot6 xchan if we do not have it yet --- include/items.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 917808ad5..9f90b2f3b 100755 --- a/include/items.php +++ b/include/items.php @@ -930,8 +930,19 @@ function import_author_xchan($x) { } // if we were told that it's a zot connection, don't probe/import anything else - if(array_key_exists('network',$x) && $x['network'] === 'zot') + if(array_key_exists('network',$x) && $x['network'] === 'zot') { + if($x['url']) { + // check if we already have the zot6 xchan of this xchan_url. if not import it. + $r = q("SELECT xchan_hash FROM xchan WHERE xchan_url = '%s' AND xchan_network = 'zot6'", + dbesc($x['url']) + ); + + if(! $r) + discover_by_webbie($x['url'], 'zot6'); + } + return $y; + } // perform zot6 discovery -- cgit v1.2.3 From ead56c59e2551f39d00e880a2cdb4b2d02b38705 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Jan 2020 19:38:52 -0800 Subject: bugfix: event_addtocal not preserving original privacy expectation --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 59057e7d5..64e63074c 100644 --- a/include/event.php +++ b/include/event.php @@ -614,7 +614,7 @@ function event_addtocal($item_id, $uid) { $ev['event_hash'] = $item['resource_id']; } - if($ev->private) + if($ev['private']) $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; else { $acl = new Zotlabs\Access\AccessList($channel); -- cgit v1.2.3 From f123809d29d6cc335251cd4fd8984c1b5ef67e2a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 25 Jan 2020 16:24:14 -0800 Subject: more work on zap export --- include/channel.php | 11 ++++++++++- include/text.php | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index e7d119b1e..66ab56715 100644 --- a/include/channel.php +++ b/include/channel.php @@ -922,8 +922,17 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals $r = q("select * from pconfig where uid = %d", intval($channel_id) ); - if($r) + + if($r) { + if ($zap_compat) { + for($x = 0; $x < count($r); $x ++) { + if (preg_match('|^a:[0-9]+:{.*}$|s', $r[$x]['v'])) { + $r[$x]['v'] = serialise(unserialize($r[$x]['v'])); + } + } + } $ret['config'] = $r; + } // All other term types will be included in items, if requested. diff --git a/include/text.php b/include/text.php index 87ed9f658..1f0af08e3 100644 --- a/include/text.php +++ b/include/text.php @@ -3694,3 +3694,18 @@ function svg2bb($s) { } return EMPTY_STR; } + + + +function serialise($x) { + return ((is_array($x)) ? 'json:' . json_encode($x) : $x); +} + +function unserialise($x) { + if (is_array($x)) { + return $x; + } + $y = ((substr($x,0,5) === 'json:') ? json_decode(substr($x,5),true) : ''); + return ((is_array($y)) ? $y : $x); +} + -- cgit v1.2.3 From 1712eceaf95e5e57d8f5866cb1f6100a0acd28b6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 26 Jan 2020 15:08:55 +0000 Subject: port Lib/Connect and Module/Follow from zap. Connect with new connections via zot6 --- include/permissions.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/permissions.php b/include/permissions.php index 501b2cc77..ca8ff6e93 100644 --- a/include/permissions.php +++ b/include/permissions.php @@ -554,4 +554,24 @@ function site_default_perms() { return $ret; } +function their_perms_contains($channel_id,$xchan_hash,$perm) { + $x = get_abconfig($channel_id,$xchan_hash,'system','their_perms'); + if($x) { + $y = explode(',',$x); + if(in_array($perm,$y)) { + return true; + } + } + return false; +} +function my_perms_contains($channel_id,$xchan_hash,$perm) { + $x = get_abconfig($channel_id,$xchan_hash,'system','my_perms'); + if($x) { + $y = explode(',',$x); + if(in_array($perm,$y)) { + return true; + } + } + return false; +} -- cgit v1.2.3 From 9545a81166cf52c930dfafda40d93bf93d66260d Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 26 Jan 2020 19:41:52 +0000 Subject: update create_identity() to use Lib/Connect via connect_and_sync() ported from zap --- include/channel.php | 55 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index e7d119b1e..61603fb42 100644 --- a/include/channel.php +++ b/include/channel.php @@ -11,6 +11,8 @@ use Zotlabs\Daemon\Master; use Zotlabs\Lib\System; use Zotlabs\Render\Comanche; use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Connect; +use Zotlabs\Lib\Libsync; require_once('include/zot.php'); require_once('include/crypto.php'); @@ -346,7 +348,7 @@ function create_identity($arr) { ] ); if(! $r) - logger('Unable to store hub location'); + logger('Unable to store hub location (zot)'); $r = hubloc_store_lowlevel( [ @@ -367,7 +369,7 @@ function create_identity($arr) { ] ); if(! $r) - logger('Unable to store hub location'); + logger('Unable to store hub location (zot6)'); $newuid = $ret['channel']['channel_id']; @@ -393,6 +395,8 @@ function create_identity($arr) { 'xchan_system' => $system ] ); + if(! $r) + logger('Unable to store xchan (zot)'); $r = xchan_store_lowlevel( [ @@ -415,6 +419,8 @@ function create_identity($arr) { 'xchan_system' => $system ] ); + if(! $r) + logger('Unable to store xchan (zot6)'); @@ -521,13 +527,22 @@ function create_identity($arr) { $accts = get_config('system','auto_follow'); if(($accts) && (! $total_identities)) { - require_once('include/follow.php'); if(! is_array($accts)) $accts = array($accts); foreach($accts as $acct) { - if(trim($acct)) - new_contact($newuid,trim($acct),$ret['channel'],false); + $acct = trim($acct); + if($acct) { + $f = connect_and_sync($ret['channel'], $acct); + if($f['success']) { + $can_view_stream = their_perms_contains($ret['channel']['channel_id'],$f['abook']['abook_xchan'],'view_stream'); + + // If we can view their stream, pull in some posts + if(($can_view_stream) || ($f['abook']['xchan_network'] === 'rss')) { + Master::Summon([ 'Onepoll',$f['abook']['abook_id'] ]); + } + } + } } } @@ -539,6 +554,7 @@ function create_identity($arr) { call_hooks('create_identity', $newuid); Master::Summon(array('Directory', $ret['channel']['channel_id'])); + } $ret['success'] = true; @@ -546,6 +562,35 @@ function create_identity($arr) { } +function connect_and_sync($channel,$address, $sub_channel = false) { + + if((! $channel) || (! $address)) { + return false; + } + + $f = Connect::connect($channel,$address, $sub_channel); + if($f['success']) { + $clone = []; + foreach($f['abook'] as $k => $v) { + if(strpos($k,'abook_') === 0) { + $clone[$k] = $v; + } + } + unset($clone['abook_id']); + unset($clone['abook_account']); + unset($clone['abook_channel']); + + $abconfig = load_abconfig($channel['channel_id'],$clone['abook_xchan']); + if($abconfig) { + $clone['abconfig'] = $abconfig; + } + + Libsync::build_sync_packet($channel['channel_id'], [ 'abook' => [ $clone ] ], true); + return $f; + } + return false; +} + function change_channel_keys($channel) { $ret = array('success' => false); -- cgit v1.2.3 From 3df5d854b8935b11c67893bbbd24cdf8829eda00 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Jan 2020 14:29:06 -0800 Subject: z6 transition work - prevent z6 sync packets from being unpacked into an incompatible schema --- include/zid.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/zid.php b/include/zid.php index 3b3dd8554..325af5580 100644 --- a/include/zid.php +++ b/include/zid.php @@ -1,6 +1,7 @@ Date: Thu, 30 Jan 2020 17:24:08 +0000 Subject: provide img and zmg tags with image description --- include/bbcode.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 301ffbd24..f3ecbd9e9 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1237,9 +1237,18 @@ function bbcode($Text, $options = []) { if (strpos($Text,'[/img]') !== false) { $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } + // [img=pathtoimage]image description[/img] + if (strpos($Text,'[/img]') !== false) { + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + } + // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } + // [zmg=pathtoimage]image description[/zmg] + if (strpos($Text,'[/zmg]') !== false) { + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + } // [img float={left, right}]pathtoimage[/img] if (strpos($Text,'[/img]') !== false) { -- cgit v1.2.3 From 2c42daf6090ba8d0e3a50b8350ea5a3750891b68 Mon Sep 17 00:00:00 2001 From: Zot Date: Thu, 30 Jan 2020 20:06:15 +0100 Subject: z6 compat work --- include/channel.php | 11 ++++++++++- include/text.php | 15 +++++++++++++++ include/zid.php | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index e7d119b1e..66ab56715 100644 --- a/include/channel.php +++ b/include/channel.php @@ -922,8 +922,17 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals $r = q("select * from pconfig where uid = %d", intval($channel_id) ); - if($r) + + if($r) { + if ($zap_compat) { + for($x = 0; $x < count($r); $x ++) { + if (preg_match('|^a:[0-9]+:{.*}$|s', $r[$x]['v'])) { + $r[$x]['v'] = serialise(unserialize($r[$x]['v'])); + } + } + } $ret['config'] = $r; + } // All other term types will be included in items, if requested. diff --git a/include/text.php b/include/text.php index 87ed9f658..1f0af08e3 100644 --- a/include/text.php +++ b/include/text.php @@ -3694,3 +3694,18 @@ function svg2bb($s) { } return EMPTY_STR; } + + + +function serialise($x) { + return ((is_array($x)) ? 'json:' . json_encode($x) : $x); +} + +function unserialise($x) { + if (is_array($x)) { + return $x; + } + $y = ((substr($x,0,5) === 'json:') ? json_decode(substr($x,5),true) : ''); + return ((is_array($y)) ? $y : $x); +} + diff --git a/include/zid.php b/include/zid.php index 3b3dd8554..325af5580 100644 --- a/include/zid.php +++ b/include/zid.php @@ -1,6 +1,7 @@ Date: Thu, 30 Jan 2020 15:56:33 -0800 Subject: basic poll support and patch to not call System::get_platform_name() within t() unless needed. Polls probably need refining and have not yet been fully tested after porting --- include/conversation.php | 4 ++- include/language.php | 7 +++-- include/text.php | 77 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 07d43e660..45b2b4d80 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -408,7 +408,7 @@ function count_descendants($item) { * @return boolean */ function visible_activity($item) { - $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE ]; + $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE, 'Answer' ]; if(intval($item['item_notshown'])) return false; @@ -419,6 +419,8 @@ function visible_activity($item) { } } + + if(is_edit_activity($item)) return false; diff --git a/include/language.php b/include/language.php index e9d62e434..622b9614d 100644 --- a/include/language.php +++ b/include/language.php @@ -217,9 +217,10 @@ function t($s, $ctx = '') { */ function translate_projectname($s) { - - return str_replace(array('$projectname','$Projectname'),array(Zotlabs\Lib\System::get_platform_name(),ucfirst(Zotlabs\Lib\System::get_platform_name())),$s); - + if(strpos($s,'rojectname') !== false) { + return str_replace(array('$projectname','$Projectname'),array(Zotlabs\Lib\System::get_platform_name(),ucfirst(Zotlabs\Lib\System::get_platform_name())),$s); + } + return $s; } diff --git a/include/text.php b/include/text.php index 1f0af08e3..caecae33e 100644 --- a/include/text.php +++ b/include/text.php @@ -1731,6 +1731,11 @@ function prepare_body(&$item,$attach = false,$opts = false) { } } + $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ 'Create','Update' ])) ? format_poll($item, $s, $opts) : false); + if ($poll) { + $s = $poll; + } + $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false); $prep_arr = [ @@ -1814,6 +1819,78 @@ function prepare_binary($item) { } +function format_poll($item,$s,$opts) { + + if (! is_array($item['obj'])) { + $act = json_decode($item['obj'],true); + } + else { + $act = $item['obj']; + } + + if (! is_array($act)) { + return EMPTY_STR; + } + + $commentable = can_comment_on_post(((local_channel()) ? get_observer_hash() : EMPTY_STR),$item); + + //logger('format_poll: ' . print_r($item,true)); + $activated = ((local_channel() && local_channel() == $item['uid']) ? true : false); + $output = $s . EOL. EOL; + + if ($act['type'] === 'Question') { + if ($activated and $commentable) { + $output .= '
'; + } + if (array_key_exists('anyOf',$act) && is_array($act['anyOf'])) { + foreach ($act['anyOf'] as $poll) { + if (array_key_exists('name',$poll) && $poll['name']) { + $text = html2plain(purify_html($poll['name']),256); + if (array_path_exists('replies/totalItems',$poll)) { + $total = $poll['replies']['totalItems']; + } + else { + $total = 0; + } + if ($activated && $commentable) { + $output .= ' ' . $text . '' . ' (' . $total . ')' . EOL; + } + else { + $output .= '[ ] ' . $text . ' (' . $total . ')' . EOL; + } + } + } + } + if (array_key_exists('oneOf',$act) && is_array($act['oneOf'])) { + foreach ($act['oneOf'] as $poll) { + if (array_key_exists('name',$poll) && $poll['name']) { + $text = html2plain(purify_html($poll['name']),256); + if (array_path_exists('replies/totalItems',$poll)) { + $total = $poll['replies']['totalItems']; + } + else { + $total = 0; + } + if ($activated && $commentable) { + $output .= ' ' . $text . '' . ' (' . $total . ')' . EOL; + } + else { + $output .= '( ) ' . $text . ' (' . $total . ')' . EOL; + } + } + } + } + if ($activated and $commentable) { + $output .= EOL . ''. '
'; + } + + } + return $output; +} + + + + /** * @brief Given a text string, convert from content_type to HTML. * -- cgit v1.2.3 From fc9e6d289acf30f89da0051a90cbf16f0bc006fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 31 Jan 2020 12:51:23 -0800 Subject: missing piece of poll code --- include/items.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 9f90b2f3b..c5743e91c 100755 --- a/include/items.php +++ b/include/items.php @@ -9,6 +9,7 @@ use Zotlabs\Lib\MarkdownSoap; use Zotlabs\Lib\MessageFilter; use Zotlabs\Lib\ThreadListener; use Zotlabs\Lib\IConfig; +use Zotlabs\Lib\Activity; use Zotlabs\Access\PermissionLimits; use Zotlabs\Access\AccessList; use Zotlabs\Daemon\Master; @@ -1947,6 +1948,11 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if(intval($r[0]['item_uplink']) && (! $r[0]['item_private'])) $arr['item_private'] = 0; + + if(in_array($arr['verb'], ['Note','Answer']) && $arr['obj_type'] === 'Question' && intval($r[0]['item_wall'])) { + Activity::update_poll($r[0],$arr['mid'],$arr['title']); + } + } else { logger('item_store: item parent was not found - ignoring item'); -- cgit v1.2.3 From ca75619518590fece646a582ee91b218725df85d Mon Sep 17 00:00:00 2001 From: Voryzen Date: Fri, 7 Feb 2020 11:24:01 +0100 Subject: Add 'hook call' to be used for new addon 'NavBanner_options' --- include/nav.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 672cc2689..bd4d000f7 100644 --- a/include/nav.php +++ b/include/nav.php @@ -59,6 +59,8 @@ function nav($template = 'default') { if($banner === false) $banner = get_config('system','sitename'); + + call_hooks('get_banner',$banner); App::$page['header'] .= replace_macros(get_markup_template('hdr.tpl'), array( //we could additionally use this to display important system notifications e.g. for updates -- cgit v1.2.3 From bbcb237f5b996e94af37611152105b2e965ea493 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 9 Feb 2020 16:32:18 -0800 Subject: poll updates --- include/conversation.php | 6 +++++- include/text.php | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 45b2b4d80..327d89e53 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -408,11 +408,15 @@ function count_descendants($item) { * @return boolean */ function visible_activity($item) { - $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE, 'Answer' ]; + $hidden_activities = [ ACTIVITY_LIKE, ACTIVITY_DISLIKE, ACTIVITY_AGREE, ACTIVITY_DISAGREE, ACTIVITY_ABSTAIN, ACTIVITY_ATTEND, ACTIVITY_ATTENDNO, ACTIVITY_ATTENDMAYBE, ACTIVITY_POLLRESPONSE ]; if(intval($item['item_notshown'])) return false; + if ($item['obj_type'] === 'Answer') { + return false; + } + foreach($hidden_activities as $act) { if((activity_match($item['verb'], $act)) && ($item['mid'] != $item['parent_mid'])) { return false; diff --git a/include/text.php b/include/text.php index caecae33e..992b455c8 100644 --- a/include/text.php +++ b/include/text.php @@ -1880,6 +1880,17 @@ function format_poll($item,$s,$opts) { } } } + if ($item['comments_closed'] > NULL_DATE) { + $t = datetime_convert('UTC',date_default_timezone_get(), $item['comments_closed'], 'Y-m-d h:i'); + $closed = ((datetime_convert() > $item['comments_closed']) ? true : false); + if ($closed) { + $message = t('Poll has ended.'); + } + else { + $message = sprintf(t('Poll ends: %s'),$t); + } + $output .= EOL . '
' . $message . '
'; + } if ($activated and $commentable) { $output .= EOL . ''. ''; } @@ -3721,7 +3732,7 @@ function array_path_exists($str,$arr) { if($search) { foreach($search as $s) { - if(array_key_exists($s,$ptr)) { + if($ptr && array_key_exists($s,$ptr)) { $ptr = $ptr[$s]; } else { -- cgit v1.2.3 From a39d436f9f46138db623ee3c9ddef2c501ea8bd2 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 10 Feb 2020 20:37:35 +0000 Subject: poll fixes --- 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 992b455c8..3dd0755a3 100644 --- a/include/text.php +++ b/include/text.php @@ -1731,7 +1731,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { } } - $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ 'Create','Update' ])) ? format_poll($item, $s, $opts) : false); + $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ ACTIVITY_POST, ACTIVITY_UPDATE ])) ? format_poll($item, $s, $opts) : false); if ($poll) { $s = $poll; } -- cgit v1.2.3 From bf7c96807a50433b7241ddf6df9e01d4ef11f43d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 10 Feb 2020 18:17:41 -0800 Subject: fix poll responses --- 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 c5743e91c..bf1ddee82 100755 --- a/include/items.php +++ b/include/items.php @@ -1949,7 +1949,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if(intval($r[0]['item_uplink']) && (! $r[0]['item_private'])) $arr['item_private'] = 0; - if(in_array($arr['verb'], ['Note','Answer']) && $arr['obj_type'] === 'Question' && intval($r[0]['item_wall'])) { + if(in_array($arr['obj_type'], ['Note','Answer']) && $r[0]['obj_type'] === 'Question' && intval($r[0]['item_wall'])) { Activity::update_poll($r[0],$arr['mid'],$arr['title']); } -- cgit v1.2.3 From 9f029336cab322e04d29af842ba0a666189c8683 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 11 Feb 2020 09:20:32 +0000 Subject: fix notifications for polls --- include/conversation.php | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 327d89e53..0098a694d 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -625,11 +625,17 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa $items = $cb['items']; - $conv_responses = array( - 'like' => array('title' => t('Likes','title')),'dislike' => array('title' => t('Dislikes','title')), - 'agree' => array('title' => t('Agree','title')),'disagree' => array('title' => t('Disagree','title')), 'abstain' => array('title' => t('Abstain','title')), - 'attendyes' => array('title' => t('Attending','title')), 'attendno' => array('title' => t('Not attending','title')), 'attendmaybe' => array('title' => t('Might attend','title')) - ); + $conv_responses = [ + 'like' => ['title' => t('Likes','title')], + 'dislike' => ['title' => t('Dislikes','title')], + 'agree' => ['title' => t('Agree','title')], + 'disagree' => ['title' => t('Disagree','title')], + 'abstain' => ['title' => t('Abstain','title')], + 'attendyes' => ['title' => t('Attending','title')], + 'attendno' => ['title' => t('Not attending','title')], + 'attendmaybe' => ['title' => t('Might attend','title')], + 'answer' => [] + ]; // array with html for each thread (parent+comments) @@ -1136,7 +1142,7 @@ function builtin_activity_puller($item, &$conv_responses) { // if this item is a post or comment there's nothing for us to do here, just return. - if(activity_match($item['verb'],ACTIVITY_POST)) + if(activity_match($item['verb'],ACTIVITY_POST) && $item['obj_type'] !== 'Answer') return; foreach($conv_responses as $mode => $v) { @@ -1168,6 +1174,9 @@ function builtin_activity_puller($item, &$conv_responses) { case 'attendmaybe': $verb = ACTIVITY_ATTENDMAYBE; break; + case 'answer': + $verb = ACTIVITY_POST; + break; default: return; break; @@ -1183,9 +1192,11 @@ function builtin_activity_puller($item, &$conv_responses) { if(! $item['thr_parent']) $item['thr_parent'] = $item['parent_mid']; - $conv_responses[$mode]['mids'][$item['thr_parent']][] = 'b64.' . base64url_encode($item['mid']); + if($item['obj_type'] === 'Answer') + continue; + if(! ((isset($conv_responses[$mode][$item['thr_parent'] . '-l'])) && (is_array($conv_responses[$mode][$item['thr_parent'] . '-l'])))) $conv_responses[$mode][$item['thr_parent'] . '-l'] = array(); -- cgit v1.2.3 From b7bac45427a400275597faa9b51c4d277fe1f5c7 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Thu, 20 Feb 2020 20:03:50 +0100 Subject: Revert "Use argv() instead URI parsing" This reverts commit bcfb69eeeef6a0506a0ec0574a03b673df84a55a --- include/cdav.php | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/import.php | 67 +++++++++++++++++++ include/zot.php | 3 + 3 files changed, 256 insertions(+) create mode 100644 include/cdav.php (limited to 'include') diff --git a/include/cdav.php b/include/cdav.php new file mode 100644 index 000000000..d72caa442 --- /dev/null +++ b/include/cdav.php @@ -0,0 +1,186 @@ +ORG = $f['org']; + else + if($edit) + unset($vcard->ORG); + + + if($f['title']) + $vcard->TITLE = $f['title']; + else + if($edit) + unset($vcard->TITLE); + + if($edit) + unset($vcard->TEL); + if($f['tel']) { + $i = 0; + foreach($f['tel'] as $item) { + if($item) { + $vcard->add('TEL', $item, ['type' => $f['tel_type'][$i]]); + } + $i++; + } + } + + if($edit) + unset($vcard->EMAIL); + if($f['email']) { + $i = 0; + foreach($f['email'] as $item) { + if($item) { + $vcard->add('EMAIL', $item, ['type' => $f['email_type'][$i]]); + } + $i++; + } + } + + if($edit) + unset($vcard->IMPP); + if($f['impp']) { + $i = 0; + foreach($f['impp'] as $item) { + if($item) { + $vcard->add('IMPP', $item, ['type' => $f['impp_type'][$i]]); + } + $i++; + } + } + + if($edit) + unset($vcard->URL); + if($f['url']) { + $i = 0; + foreach($f['url'] as $item) { + if($item) { + $vcard->add('URL', $item, ['type' => $f['url_type'][$i]]); + } + $i++; + } + } + + if($edit) + unset($vcard->ADR); + if($f['adr']) { + $i = 0; + foreach($f['adr'] as $item) { + if($item) { + $vcard->add('ADR', $item, ['type' => $f['adr_type'][$i]]); + } + $i++; + } + } + + if($f['note']) { + $vcard->NOTE = $f['note']; + } + else + if($edit) + unset($vcard->NOTE); +} + + +/** + * @brief Import CardDAV or CalDAV card + * + * @param int $id card id + * @param str $ext card extension + * @param str $table name + * @param str $column name + * @param obj $objects + * @param str $profile + * @param obj $backend + * @param array $ids + * @param bool $notice + * + */ + +function import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backend, &$ids, $notice = false) { + + $i = 0; + $newid = (count($ids) ? false : true); + + while ($object = $objects->getNext()) { + + if($_REQUEST['a_upload']) + $object = $object->convert(\Sabre\VObject\Document::VCARD40); + + $ret = $object->validate($profile & \Sabre\VObject\Node::REPAIR); + + //level 3 Means that the document is invalid, + //level 2 means a warning. A warning means it's valid but it could cause interopability issues, + //level 1 means that there was a problem earlier, but the problem was automatically repaired. + + if($ret[0]['level'] < 3) { + + if($newid) { + do { + $duplicate = false; + $objectUri = random_string(40) . '.' . $ext; + + $r = q("SELECT uri FROM $table WHERE $column = %d AND uri = '%s' LIMIT 1", + dbesc($id), + dbesc($objectUri) + ); + if (count($r)) + $duplicate = true; + } while ($duplicate == true); + $ids[$i] = $objectUri; + } + else + $objectUri = $ids[$i]; + + $i++; + + if($ext == 'ics') + $backend->createCalendarObject($id, $objectUri, $object->serialize()); + + if($ext == 'vcf') + $backend->createCard($id, $objectUri, $object->serialize()); + } + else { + if($notice && $ext == 'ics') { + notice( + '' . t('INVALID EVENT DISMISSED!') . '' . EOL . + '' . t('Summary: ') . '' . (($object->VEVENT->SUMMARY) ? $object->VEVENT->SUMMARY : t('Unknown')) . EOL . + '' . t('Date: ') . '' . (($object->VEVENT->DTSTART) ? $object->VEVENT->DTSTART : t('Unknown')) . EOL . + '' . t('Reason: ') . '' . $ret[0]['message'] . EOL + ); + } + + if($notice && $exp == 'vcf') { + notice( + '' . t('INVALID CARD DISMISSED!') . '' . EOL . + '' . t('Name: ') . '' . (($object->FN) ? $object->FN : t('Unknown')) . EOL . + '' . t('Reason: ') . '' . $ret[0]['message'] . EOL + ); + } + } + } +} + + +function get_cdav_id($principaluri, $uri, $table) { + + $r = q("SELECT id FROM $table WHERE principaluri = '%s' AND uri = '%s' LIMIT 1", + dbesc($principaluri), + dbesc($uri) + ); + if(! $r) + return false; + + return $r[0]['id']; +} diff --git a/include/import.php b/include/import.php index 6a3895b9f..0519052d8 100644 --- a/include/import.php +++ b/include/import.php @@ -1503,6 +1503,73 @@ function sync_files($channel, $files) { } } +/** + * @brief Synchronize addressbooks. + * + * @param array $channel + * @param array $data + */ +function sync_addressbook($channel, $data) { + + if(! \Zotlabs\Lib\Apps::system_app_installed($channel['channel_id'], 'CardDAV')) + return; + + logger("debug: " . print_r($data,true), LOGGER_DEBUG); + + require_once('include/cdav.php'); + + $principalUri = 'principals/' . $channel['channel_address']; + + if($data['action'] !== 'create') { + $id = get_cdav_id($principalUri, $data['uri'], 'addressbooks'); + if(! $id) + return; + } + + $pdo = \DBA::$dba->db; + + $carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo); + $addressbooks = $carddavBackend->getAddressBooksForUser($principalUri); + + switch($data['action']) { + + case 'create': + $carddavBackend->createAddressBook($principalUri, $data['uri'], $data['properties']); + break; + + case 'drop': + $carddavBackend->deleteAddressBook($id); + break; + + case 'edit': + $patch = new \Sabre\DAV\PropPatch($data['mutations']); + $carddavBackend->updateAddressBook($id, $patch); + $patch->commit(); + break; + + case 'delete_card': + $carddavBackend->deleteCard($id, $data['carduri']); + break; + + case 'update_card': + $vcard = \Sabre\VObject\Reader::read($data['card']); + $object = $vcard->convert(\Sabre\VObject\Document::VCARD40); + $cardData = $vcard->serialize(); + $carddavBackend->updateCard($id, $data['carduri'], $cardData); + break; + + case 'import': + $objects = new \Sabre\VObject\Splitter\VCard($data['card']); + $profile = \Sabre\VObject\Node::PROFILE_CARDDAV; + import_cdav_card($id, 'vcf', 'cards', 'addressbookid', $objects, $profile, $carddavBackend, $data['ids']); + break; + + default: + break; + } +} + + /** * @brief Rename a key in an array. * diff --git a/include/zot.php b/include/zot.php index d08146287..c02dab162 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3611,6 +3611,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('app',$arr) && $arr['app']) sync_apps($channel,$arr['app']); + if(array_key_exists('addressbook',$arr) && $arr['addressbook']) + sync_addressbook($channel,$arr['addressbook']); + if(array_key_exists('chatroom',$arr) && $arr['chatroom']) sync_chatrooms($channel,$arr['chatroom']); -- cgit v1.2.3 From 9d97cc2a1d28cd201912870a5342e7eaf9285491 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 21 Feb 2020 10:44:26 +0000 Subject: implement optional events and polls filter --- include/features.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/features.php b/include/features.php index 87df0c50d..c6cfcf822 100644 --- a/include/features.php +++ b/include/features.php @@ -298,6 +298,22 @@ function get_features($filtered = true, $level = (-1)) { t('Network'), + [ + 'events_tab', + t('Events Filter'), + t('Ability to display only events'), + false, + get_config('feature_lock','events_tab') + ], + + [ + 'polls_tab', + t('Polls Filter'), + t('Ability to display only polls'), + false, + get_config('feature_lock','polls_tab') + ], + [ 'savedsearch', t('Saved Searches'), -- cgit v1.2.3 From ed28ef185e1e64b1666533d21df5de71741e5571 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 23 Feb 2020 08:45:39 +0000 Subject: polls can also appear in shares --- 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 3dd0755a3..1475ff334 100644 --- a/include/text.php +++ b/include/text.php @@ -1731,7 +1731,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { } } - $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ ACTIVITY_POST, ACTIVITY_UPDATE ])) ? format_poll($item, $s, $opts) : false); + $poll = (($item['obj_type'] === 'Question' && in_array($item['verb'],[ ACTIVITY_POST, ACTIVITY_UPDATE, ACTIVITY_SHARE ])) ? format_poll($item, $s, $opts) : false); if ($poll) { $s = $poll; } -- cgit v1.2.3 From 85cf25a2a8bfbbfe10de485d4affd54626fbbfa4 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 23 Feb 2020 15:28:16 -0800 Subject: add iconfig to zot6 objects --- include/channel.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 66ab56715..991d4675b 100644 --- a/include/channel.php +++ b/include/channel.php @@ -878,11 +878,38 @@ function identity_basic_export($channel_id, $sections = null, $zap_compat = fals $ret['abook'] = $r; for($x = 0; $x < count($ret['abook']); $x ++) { + $xchans[] = $ret['abook'][$x]['abook_xchan']; + $my_perms = []; + $their_perms = []; + $newconfig = []; $abconfig = load_abconfig($channel_id,$ret['abook'][$x]['abook_xchan']); - if($abconfig) - $ret['abook'][$x]['abconfig'] = $abconfig; + if($abconfig) { + foreach ($abconfig as $abc) { + + if ($abc['cat'] === 'my_perms' && intval($abc['v'])) { + $my_perms[] = $abc['k']; + continue; + } + if ($abc['cat'] === 'their_perms' && intval($abc['v'])) { + $their_perms[] = $abc['k']; + continue; + } + if ($zap_compat && preg_match('|^a:[0-9]+:{.*}$|s', $abc['v'])) { + $abc['v'] = serialise(unserialize($abc['v'])); + } + $newconfig[] = $abc; + } + + $ret['abook'][$x]['abconfig'] = $newconfig; + if ($zap_compat) { + $ret['abook'][$x]['abconfig'][] = [ 'chan' => $channel_id, 'xchan' => $ret['abook'][$x]['abook_chan'], 'cat' => 'system', 'k' => 'my_perms', 'v' => implode(',',$my_perms) ]; + $ret['abook'][$x]['abconfig'][] = [ 'chan' => $channel_id, 'xchan' => $ret['abook'][$x]['abook_chan'], 'cat' => 'system', 'k' => 'their_perms', 'v' => implode(',',$their_perms) ]; + } + } + translate_abook_perms_outbound($ret['abook'][$x]); + } // pick up the zot6 xchan and hublocs also -- cgit v1.2.3 From 989fbe70cd566da4c5757527aa77022036af6274 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 24 Feb 2020 10:02:09 +0100 Subject: Implement DAV calendars sync with clones --- include/cdav.php | 4 +-- include/import.php | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/zot.php | 3 +++ 3 files changed, 76 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/cdav.php b/include/cdav.php index d72caa442..cdf7775db 100644 --- a/include/cdav.php +++ b/include/cdav.php @@ -175,12 +175,12 @@ function import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backe function get_cdav_id($principaluri, $uri, $table) { - $r = q("SELECT id FROM $table WHERE principaluri = '%s' AND uri = '%s' LIMIT 1", + $r = q("SELECT * FROM $table WHERE principaluri = '%s' AND uri = '%s' LIMIT 1", dbesc($principaluri), dbesc($uri) ); if(! $r) return false; - return $r[0]['id']; + return $r[0]; } diff --git a/include/import.php b/include/import.php index 0519052d8..bfe71963f 100644 --- a/include/import.php +++ b/include/import.php @@ -1503,6 +1503,7 @@ function sync_files($channel, $files) { } } + /** * @brief Synchronize addressbooks. * @@ -1570,6 +1571,76 @@ function sync_addressbook($channel, $data) { } +/** + * @brief Synchronize calendars. + * + * @param array $channel + * @param array $data + */ +function sync_calendar($channel, $data) { + + if(! \Zotlabs\Lib\Apps::system_app_installed($channel['channel_id'], 'Calendar')) + return; + + logger("debug: " . print_r($data,true), LOGGER_DEBUG); + + require_once('include/cdav.php'); + + $principalUri = 'principals/' . $channel['channel_address']; + + if($data['action'] !== 'create') { + $x = get_cdav_id($principalUri, $data['uri'], 'calendarinstances'); + if(! $x) + return; + $id = [ $x['id'], $x['calendarid'] ]; + } + + $pdo = \DBA::$dba->db; + + $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); + $calendars = $caldavBackend->getCalendarsForUser($principalUri); + + switch($data['action']) { + + case 'create': + $id = $caldavBackend->createCalendar($principalUri, $data['uri'], $data['properties']); + set_pconfig($channel['channel_id'], 'cdav_calendar', $id[0], 1); + break; + + case 'drop': + $caldavBackend->deleteCalendar($id); + break; + + case 'edit': + $patch = new \Sabre\DAV\PropPatch($data['mutations']); + $caldavBackend->updateCalendar($id, $patch); + $patch->commit(); + break; + + case 'delete_card': + $caldavBackend->deleteCalendarObject($id, $data['carduri']); + break; + + case 'update_card': + $caldavBackend->updateCalendarObject($id, $data['carduri'], $data['card']); + break; + + case 'switch': + set_pconfig($channel['channel_id'], 'cdav_calendar', $id[0], $data['switch']); + break; + + case 'import': + $objects = new \Sabre\VObject\Splitter\ICalendar($data['card']); + $profile = \Sabre\VObject\Node::PROFILE_CALDAV; + import_cdav_card($id, 'ics', 'calendarobjects', 'calendarid', $objects, $profile, $caldavBackend, $data['ids']); + break; + + default: + break; + } +} + + /** * @brief Rename a key in an array. * diff --git a/include/zot.php b/include/zot.php index c02dab162..5d5ac8424 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3614,6 +3614,9 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { if(array_key_exists('addressbook',$arr) && $arr['addressbook']) sync_addressbook($channel,$arr['addressbook']); + if(array_key_exists('calendar',$arr) && $arr['calendar']) + sync_calendar($channel,$arr['calendar']); + if(array_key_exists('chatroom',$arr) && $arr['chatroom']) sync_chatrooms($channel,$arr['chatroom']); -- cgit v1.2.3 From c28ba4be37bdce7bd0c0f5fd729b6ff951f741fd Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 24 Feb 2020 11:39:26 +0100 Subject: Update cdav import parameters comment --- include/cdav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/cdav.php b/include/cdav.php index cdf7775db..ef248a9fe 100644 --- a/include/cdav.php +++ b/include/cdav.php @@ -3,7 +3,7 @@ /** * @brief Process CardDAV card * - * @param array $f fields array + * @param array $f fields * @param obj $vcard SabreDAV object * @param bool $edit update card * @@ -96,7 +96,7 @@ function process_cdav_card($f, &$vcard, $edit = false) { /** * @brief Import CardDAV or CalDAV card * - * @param int $id card id + * @param mixed $id card id * @param str $ext card extension * @param str $table name * @param str $column name -- cgit v1.2.3 From e7f25b84664c158343621c391b8653042d5be53c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 26 Feb 2020 09:51:40 +0000 Subject: implement poll UI in jot --- include/conversation.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 0098a694d..ba0f61196 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1293,7 +1293,7 @@ function hz_status_editor($a, $x, $popup = false) { $feature_voting = feature_enabled($x['profile_uid'], 'consensus_tools'); if(x($x, 'hide_voting')) $feature_voting = false; - + $feature_nocomment = feature_enabled($x['profile_uid'], 'disable_comments'); if(x($x, 'disable_comments')) $feature_nocomment = false; @@ -1441,6 +1441,8 @@ function hz_status_editor($a, $x, $popup = false) { '$embedPhotosModalOK' => t('OK'), '$setloc' => $setloc, '$voting' => t('Toggle voting'), + '$poll' => t('Toggle poll'), + '$multiple_answers' => ['poll_multiple_answers', t("Allow multiple answers")], '$feature_voting' => $feature_voting, '$consensus' => ((array_key_exists('item',$x)) ? $x['item']['item_consensus'] : 0), '$nocommenttitle' => t('Disable comments'), -- cgit v1.2.3 From a574290235b840e56c2f0b3a3c37b9050f02e45b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 Feb 2020 13:22:30 +0000 Subject: poll UI strings --- 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 ba0f61196..62d4b405f 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1442,7 +1442,10 @@ function hz_status_editor($a, $x, $popup = false) { '$setloc' => $setloc, '$voting' => t('Toggle voting'), '$poll' => t('Toggle poll'), - '$multiple_answers' => ['poll_multiple_answers', t("Allow multiple answers")], + '$poll_option_label' => t('Option'), + '$poll_add_option_label' => t('Add option'), + '$poll_expire_unit_label' => [t('Minutes'), t('Hours'), t('Days')], + '$multiple_answers' => ['poll_multiple_answers', t("Allow multiple answers"), '', '', [t('No'), t('Yes')]], '$feature_voting' => $feature_voting, '$consensus' => ((array_key_exists('item',$x)) ? $x['item']['item_consensus'] : 0), '$nocommenttitle' => t('Disable comments'), -- cgit v1.2.3 From a776f69a59718b3e9034ef12f543b0aaef317855 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 28 Feb 2020 14:31:49 -0800 Subject: alt attribute for images --- include/bbcode.php | 93 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 35 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index f3ecbd9e9..bb7b9e2dd 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -655,6 +655,63 @@ function bb_observer($Text) { return $Text; } +function bb_imgoptions($match) { + + // $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); + // alt text cannot contain ']' + + // [img|zmg=wwwxhhh float=left|right alt=alt text]url[/img|zmg] + + $local_match = null; + $width = 0; + $float = false; + $alt = false; + + $style = EMPTY_STR; + + if ($match[2] === '=') { + // pull out (optional) size declarations first + if (preg_match("/([0-9]*)x([0-9]*)/ism",$match[3],$local_match)) { + $width = intval($local_match[1]); + } + $match[3] = substr($match[3],strpos($match[3],' ')); + } + // then (optional) float specifiers + if ($n = strpos($match[3],'float=left') !== false) { + $float = 'left'; + $match[3] = substr($match[3],$n + 10); + } + if ($n = strpos($match[3],'float=right') !== false) { + $float = 'right'; + $match[3] = substr($match[3],$n + 11); + } + // finally alt text which extends to the close of the tag + if ($n = strpos($match[3],'alt=') !== false) { + $alt = substr($match[3],$n + 4); + } + + // now assemble the resulting img tag from these components + + $output = ''; + + return $output; + +} + function bb_code_protect($s) { return 'b64.^9e%.' . base64_encode($s) . '.b64.$9e%'; } @@ -1250,41 +1307,7 @@ function bbcode($Text, $options = []) { $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } - // [img float={left, right}]pathtoimage[/img] - if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img float=left\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img float=right\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg float=left\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg float=right\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); - } - - // [img=widthxheight]pathtoimage[/img] - if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*)\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); - } - - // [img=widthxheight float={left, right}]pathtoimage[/img] - if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*) float=left\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*) float=right\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*) float=left\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); - } - if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\=([0-9]*)x([0-9]*) float=right\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); - } + $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); // style (sanitized) if (strpos($Text,'[/style]') !== false) { -- cgit v1.2.3 From 06f2979e04db2c5eb7e10bc4967d750209a4cc73 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 29 Feb 2020 10:25:22 +0000 Subject: prevent duplicate votes --- 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 bf1ddee82..9768fdf23 100755 --- a/include/items.php +++ b/include/items.php @@ -1950,7 +1950,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { $arr['item_private'] = 0; if(in_array($arr['obj_type'], ['Note','Answer']) && $r[0]['obj_type'] === 'Question' && intval($r[0]['item_wall'])) { - Activity::update_poll($r[0],$arr['mid'],$arr['title']); + Activity::update_poll($r[0],$arr); } } -- cgit v1.2.3 From 16fd618380d2f88524b3545f751690b39be084f5 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 29 Feb 2020 13:08:16 -0800 Subject: rework img alt text - preserve legacy bbcode --- include/bbcode.php | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index bb7b9e2dd..b2e3f1d3b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -668,15 +668,60 @@ function bb_imgoptions($match) { $alt = false; $style = EMPTY_STR; + + $attributes = $match[3]; + + $x = preg_match("/alt='(.*?)'/ism", $attributes, $matches); + if ($x) { + $alt = $matches[1]; + } + + $x = preg_match("/alt=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $alt = $matches[1]; + } + + $x = preg_match("/width='(.*?)'/ism", $attributes, $matches); + if ($x) { + $width = $matches[1]; + } + + $x = preg_match("/width=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $width = $matches[1]; + } + + $x = preg_match("/height='(.*?)'/ism", $attributes, $matches); + if ($x) { + $height = $matches[1]; + } + + $x = preg_match("/height=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $height = $matches[1]; + } + + $x = preg_match("/style='(.*?)'/ism", $attributes, $matches); + if ($x) { + $style = $matches[1]; + } + + $x = preg_match("/style=\"\;(.*?)\"\;/ism", $attributes, $matches); + if ($x) { + $style = $matches[1]; + } + + // legacy img options if ($match[2] === '=') { - // pull out (optional) size declarations first + // pull out (optional) legacy size declarations first if (preg_match("/([0-9]*)x([0-9]*)/ism",$match[3],$local_match)) { $width = intval($local_match[1]); } $match[3] = substr($match[3],strpos($match[3],' ')); } - // then (optional) float specifiers + + // then (optional) legacy float specifiers if ($n = strpos($match[3],'float=left') !== false) { $float = 'left'; $match[3] = substr($match[3],$n + 10); @@ -685,8 +730,9 @@ function bb_imgoptions($match) { $float = 'right'; $match[3] = substr($match[3],$n + 11); } + // finally alt text which extends to the close of the tag - if ($n = strpos($match[3],'alt=') !== false) { + if ((! $alt) && ($n = strpos($match[3],'alt=') !== false)) { $alt = substr($match[3],$n + 4); } -- cgit v1.2.3 From c2b691fd0153f0b468f9014b4ca1f0f2b339c617 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Fri, 6 Mar 2020 10:33:25 +0100 Subject: Translate 'vote' button text --- 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 1475ff334..3c1d4c996 100644 --- a/include/text.php +++ b/include/text.php @@ -1892,7 +1892,7 @@ function format_poll($item,$s,$opts) { $output .= EOL . '
' . $message . '
'; } if ($activated and $commentable) { - $output .= EOL . ''. ''; + $output .= EOL . ''. ''; } } -- cgit v1.2.3 From ce4fc304393001771e906af1f2e2702a1820eaa2 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 6 Mar 2020 10:11:10 +0000 Subject: use 24h time format --- 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 3c1d4c996..5d1cf6eff 100644 --- a/include/text.php +++ b/include/text.php @@ -1881,7 +1881,7 @@ function format_poll($item,$s,$opts) { } } if ($item['comments_closed'] > NULL_DATE) { - $t = datetime_convert('UTC',date_default_timezone_get(), $item['comments_closed'], 'Y-m-d h:i'); + $t = datetime_convert('UTC',date_default_timezone_get(), $item['comments_closed'], 'Y-m-d H:i'); $closed = ((datetime_convert() > $item['comments_closed']) ? true : false); if ($closed) { $message = t('Poll has ended.'); -- cgit v1.2.3 From b23751128bafdc0e2d546517cab48f8095eed315 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 11 Mar 2020 10:43:19 +0000 Subject: port create_identity() to zot6 --- include/channel.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 4aad64f3d..e48420fa0 100644 --- a/include/channel.php +++ b/include/channel.php @@ -230,12 +230,16 @@ function create_identity($arr) { return $ret; } - $guid = zot_new_uid($nick); + $guid = Libzot::new_uid($nick); $key = new_keypair(4096); - $sig = base64url_encode(rsa_sign($guid,$key['prvkey'])); - $hash = make_xchan_hash($guid,$sig); - $zhash = Libzot::make_xchan_hash($guid,$key['pubkey']); + // legacy zot + $zsig = base64url_encode(rsa_sign($guid,$key['prvkey'])); + $zhash = make_xchan_hash($guid,$sig); + + // zot6 + $sig = Libzot::sign($guid,$key['prvkey']); + $hash = Libzot::make_xchan_hash($guid,$key['pubkey']); // Force a few things on the short term until we can provide a theme or app with choice @@ -334,8 +338,8 @@ function create_identity($arr) { $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $guid, - 'hubloc_guid_sig' => $sig, - 'hubloc_hash' => $hash, + 'hubloc_guid_sig' => $zsig, + 'hubloc_hash' => $zhash, 'hubloc_addr' => channel_reddress($ret['channel']), 'hubloc_primary' => intval($primary), 'hubloc_url' => z_root(), @@ -353,13 +357,13 @@ function create_identity($arr) { $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $guid, - 'hubloc_guid_sig' => 'sha256.' . $sig, - 'hubloc_hash' => $zhash, + 'hubloc_guid_sig' => $sig, + 'hubloc_hash' => $hash, 'hubloc_id_url' => channel_url($ret['channel']), 'hubloc_addr' => channel_reddress($ret['channel']), 'hubloc_primary' => intval($primary), 'hubloc_url' => z_root(), - 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey'])), + 'hubloc_url_sig' => Libzot::sign(z_root(),$ret['channel']['channel_prvkey']), 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')), 'hubloc_host' => App::get_hostname(), 'hubloc_callback' => z_root() . '/zot', @@ -376,9 +380,9 @@ function create_identity($arr) { $r = xchan_store_lowlevel( [ - 'xchan_hash' => $hash, + 'xchan_hash' => $zhash, 'xchan_guid' => $guid, - 'xchan_guid_sig' => $sig, + 'xchan_guid_sig' => $zsig, 'xchan_pubkey' => $key['pubkey'], 'xchan_photo_mimetype' => (($photo_type) ? $photo_type : 'image/png'), 'xchan_photo_l' => z_root() . "/photo/profile/l/{$newuid}", @@ -400,9 +404,9 @@ function create_identity($arr) { $r = xchan_store_lowlevel( [ - 'xchan_hash' => $zhash, + 'xchan_hash' => $hash, 'xchan_guid' => $guid, - 'xchan_guid_sig' => 'sha256.' . $sig, + '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}", -- cgit v1.2.3 From c358aa2806717d1af6e47697f87e54b7c9967c9e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 12 Mar 2020 18:27:16 +0000 Subject: first batch of zot6 transition patches. basic communication with transitioned channels *should* work now --- include/zot.php | 70 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 5d5ac8424..ca33b6c48 100644 --- a/include/zot.php +++ b/include/zot.php @@ -578,7 +578,7 @@ function zot_refresh($them, $channel = null, $force = false) { [ 'type' => NOTIFY_INTRO, 'from_xchan' => $x['hash'], - 'to_xchan' => $channel['channel_hash'], + 'to_xchan' => $channel['channel_portable_id'], 'link' => z_root() . '/connedit/' . $new_connection[0]['abook_id'] ] ); @@ -921,7 +921,7 @@ function import_xchan($arr, $ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { // see if this is a channel clone that's hosted locally - which we treat different from other xchans/connections - $local = q("select channel_account_id, channel_id from channel where channel_hash = '%s' limit 1", + $local = q("select channel_account_id, channel_id from channel where channel_portable_id = '%s' limit 1", dbesc($xchan_hash) ); @@ -1299,7 +1299,7 @@ function zot_fetch($arr) { * * @returns array * Suitable for logging remotely, enumerating the processing results of each message/recipient combination - * * [0] => \e string $channel_hash + * * [0] => \e string $channel_portable_id * * [1] => \e string $delivery_status * * [2] => \e string $address */ @@ -1385,7 +1385,7 @@ function zot_import($arr, $sender_url) { if($recip_arr) { stringify_array_elms($recip_arr); $recips = implode(',',$recip_arr); - $r = q("select channel_hash as hash from channel where channel_hash in ( " . $recips . " ) + $r = q("select channel_portable_id as hash from channel where channel_portable_id in ( " . $recips . " ) and channel_removed = 0 "); } @@ -1596,11 +1596,11 @@ function public_recips($msg) { $r = array(); - $c = q("select channel_id, channel_hash from channel where channel_removed = 0"); + $c = q("select channel_id, channel_portable_id from channel where channel_removed = 0"); if($c) { foreach($c as $cc) { if(perm_is_allowed($cc['channel_id'],$msg['notify']['sender']['hash'],$perm)) { - $r[] = [ 'hash' => $cc['channel_hash'] ]; + $r[] = [ 'hash' => $cc['channel_portable_id'] ]; } } } @@ -1610,7 +1610,7 @@ function public_recips($msg) { if($include_sys && array_key_exists('public_scope',$msg['message']) && $msg['message']['public_scope'] === 'public') { $sys = get_sys_channel(); if($sys) - $r[] = [ 'hash' => $sys['channel_hash'] ]; + $r[] = [ 'hash' => $sys['channel_portable_id'] ]; } // look for any public mentions on this site @@ -1624,7 +1624,7 @@ function public_recips($msg) { if(($tag['type'] === 'mention' || $tag['type'] === 'forum') && (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' + $z = q("select channel_portable_id as hash from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc($address) ); @@ -1727,7 +1727,7 @@ function allowed_public_recips($msg) { $condensed_recips[] = $rr['hash']; $results = array(); - $r = q("select channel_hash as hash, channel_id from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' and channel_removed = 0 ", + $r = q("select channel_portable_id as hash, channel_id from channel left join abook on abook_channel = channel_id where abook_xchan = '%s' and channel_removed = 0 ", dbesc($hash) ); if($r) { @@ -1776,7 +1776,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $DR = new Zotlabs\Lib\DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']); - $channel = channelx_by_hash($d['hash']); + $channel = channelx_by_portid($d['hash']); if(! $channel) { $DR->update('recipient not found'); @@ -2076,7 +2076,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $stored = (($item_result && $item_result['item']) ? $item_result['item'] : false); if((is_array($stored)) && ($stored['id'] != $stored['parent']) - && ($stored['author_xchan'] === $channel['channel_hash'])) { + && ($stored['author_xchan'] === $channel['channel_portable_id'])) { retain_item($stored['item']['parent']); } @@ -2344,7 +2344,7 @@ function process_mail_delivery($sender, $arr, $deliveries) { $DR = new Zotlabs\Lib\DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']); - $r = q("select * from channel where channel_hash = '%s' limit 1", + $r = q("select * from channel where channel_portable_id = '%s' limit 1", dbesc($d['hash']) ); @@ -2555,7 +2555,7 @@ function check_location_move($sender_hash, $locations) { $loc = $locations[0]; - $r = q("select * from channel where channel_hash = '%s' limit 1", + $r = q("select * from channel where channel_portable_id = '%s' limit 1", dbesc($sender_hash) ); @@ -2563,7 +2563,7 @@ function check_location_move($sender_hash, $locations) { return; if($loc['url'] !== z_root()) { - $x = q("update channel set channel_moved = '%s' where channel_hash = '%s' limit 1", + $x = q("update channel set channel_moved = '%s' where channel_portable_id = '%s' limit 1", dbesc($loc['url']), dbesc($sender_hash) ); @@ -2826,13 +2826,13 @@ function sync_locations($sender, $arr, $absolute = false) { * * @see zot_get_hublocs() * @param array $channel an associative array which must contain - * * \e string \b channel_hash the hash of the channel + * * \e string \b channel_portable_id the hash of the channel * @return array an array with associative arrays */ function zot_encode_locations($channel) { $ret = array(); - $x = zot_get_hublocs($channel['channel_hash']); + $x = zot_get_hublocs($channel['channel_portable_id']); if($x && count($x)) { foreach($x as $hub) { @@ -3301,7 +3301,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { return; $h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0", - dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_hash']) + dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_portable_id']) ); if(! $h) @@ -3325,7 +3325,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { return; $r = q("select xchan_guid, xchan_guid_sig from xchan where xchan_hash = '%s' limit 1", - dbesc($channel['channel_hash']) + dbesc($channel['channel_portable_id']) ); if(! $r) return; @@ -3446,7 +3446,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $keychange = ((array_key_exists('keychange',$arr)) ? true : false); foreach ($deliveries as $d) { - $r = q("select * from channel where channel_hash = '%s' limit 1", + $r = q("select * from channel where channel_portable_id = '%s' limit 1", dbesc(($keychange) ? $arr['keychange']['old_hash'] : $d['hash']) ); @@ -3460,8 +3460,8 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $max_friends = service_class_fetch($channel['channel_id'],'total_channels'); $max_feeds = account_service_class_fetch($channel['channel_account_id'],'total_feeds'); - if($channel['channel_hash'] != $sender['hash']) { - logger('Possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_hash']); + if($channel['channel_portable_id'] != $sender['hash']) { + logger('Possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_portable_id']); $result[] = array($d['hash'],'channel mismatch',$channel['channel_name'],''); continue; } @@ -3478,7 +3478,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $r = q("update channel set channel_prvkey = '%s', channel_pubkey = '%s', channel_guid_sig = '%s', - channel_hash = '%s' where channel_id = %d", + channel_portable_id = '%s' where channel_id = %d", dbesc($arr['channel']['channel_prvkey']), dbesc($arr['channel']['channel_pubkey']), dbesc($sig), @@ -4192,7 +4192,7 @@ function zot_reply_message_request($data) { $arr = $data['recipients'][0]; $recip_hash = make_xchan_hash($arr['guid'],$arr['guid_sig']); - $c = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_hash = '%s' limit 1", + $c = q("select * from channel left join xchan on channel_portable_id = xchan_hash where channel_portable_id = '%s' limit 1", dbesc($recip_hash) ); if (! $c) { @@ -4338,13 +4338,13 @@ function zotinfo($arr) { $r = null; if(strlen($zhash)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash - where channel_hash = '%s' limit 1", + $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash + where channel_portable_id = '%s' limit 1", dbesc($zhash) ); } elseif(strlen($zguid) && strlen($zguid_sig)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($zguid), dbesc($zguid_sig) @@ -4352,7 +4352,7 @@ function zotinfo($arr) { } elseif(strlen($zaddr)) { if(strpos($zaddr,'[system]') === false) { /* normal address lookup */ - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1", dbesc($zaddr), dbesc($zaddr) @@ -4372,10 +4372,10 @@ function zotinfo($arr) { * */ - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash where channel_system = 1 order by channel_id limit 1"); if(! $r) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash where channel_removed = 0 order by channel_id limit 1"); } } @@ -4699,14 +4699,14 @@ function check_zotinfo($channel, $locations, &$ret) { // for the sys channel as normal channels will be trickier. q("delete from hubloc where hubloc_hash = '%s'", - dbesc($channel['channel_hash']) + dbesc($channel['channel_portable_id']) ); $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $channel['channel_guid'], 'hubloc_guid_sig' => $channel['channel_guid_sig'], - 'hubloc_hash' => $channel['channel_hash'], + 'hubloc_hash' => $channel['channel_portable_id'], 'hubloc_addr' => channel_reddress($channel), 'hubloc_network' => 'zot', 'hubloc_primary' => 1, @@ -4761,7 +4761,7 @@ function delivery_report_is_storable($dr) { // Is the sender one of our channels? - $c = q("select channel_id from channel where channel_hash = '%s' limit 1", + $c = q("select channel_id from channel where channel_portable_id = '%s' limit 1", dbesc($dr['sender']) ); if(! $c) @@ -5107,7 +5107,7 @@ function zot_reply_auth_check($data,$encrypted_packet) { $arr = $data['recipients'][0]; $recip_hash = make_xchan_hash($arr['guid'], $arr['guid_sig']); - $c = q("select channel_id, channel_account_id, channel_prvkey from channel where channel_hash = '%s' limit 1", + $c = q("select channel_id, channel_account_id, channel_prvkey from channel where channel_portable_id = '%s' limit 1", dbesc($recip_hash) ); if (! $c) { @@ -5174,7 +5174,7 @@ function zot_reply_purge($sender, $recipients) { // basically this means "unfriend" foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel - left join xchan on channel_hash = xchan_hash + left join xchan on channel_portable_id = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($recip['guid']), dbesc($recip['guid_sig']) @@ -5227,7 +5227,7 @@ function zot_reply_refresh($sender, $recipients) { foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel - left join xchan on channel_hash = xchan_hash + left join xchan on channel_portable_id = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($recip['guid']), dbesc($recip['guid_sig']) -- cgit v1.2.3 From 3b4503c971cda9e78d8cb310ab7c2e62987efffd Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 12 Mar 2020 19:09:34 +0000 Subject: use xchan_guid_sig instead of channel_guid_sig since it slightly differs depending on *default* protocol --- include/zot.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index ca33b6c48..7d7df9ece 100644 --- a/include/zot.php +++ b/include/zot.php @@ -407,8 +407,8 @@ function zot_refresh($them, $channel = null, $force = false) { $postvars['token'] = $token; if($channel) { - $postvars['target'] = $channel['channel_guid']; - $postvars['target_sig'] = $channel['channel_guid_sig']; + $postvars['target'] = $channel['xchan_guid']; + $postvars['target_sig'] = $channel['xchan_guid_sig']; $postvars['key'] = $channel['channel_pubkey']; } @@ -426,7 +426,6 @@ function zot_refresh($them, $channel = null, $force = false) { logger('zot_refresh: ' . $url, LOGGER_DATA, LOG_INFO); - $result = z_post_url($url . $rhs,$postvars); if ($result['success']) { @@ -5228,11 +5227,10 @@ function zot_reply_refresh($sender, $recipients) { foreach ($recipients as $recip) { $r = q("select channel.*,xchan.* from channel left join xchan on channel_portable_id = xchan_hash - where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", + where xchan_guid = '%s' and xchan_guid_sig = '%s' limit 1", dbesc($recip['guid']), dbesc($recip['guid_sig']) ); - $x = zot_refresh(array( 'xchan_guid' => $sender['guid'], 'xchan_guid_sig' => $sender['guid_sig'], -- cgit v1.2.3 From b2de12442d3064ee3899583661efef28c4efd38f Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 13 Mar 2020 19:32:59 +0000 Subject: wrong variable --- include/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index e48420fa0..25eb93cac 100644 --- a/include/channel.php +++ b/include/channel.php @@ -235,7 +235,7 @@ function create_identity($arr) { // legacy zot $zsig = base64url_encode(rsa_sign($guid,$key['prvkey'])); - $zhash = make_xchan_hash($guid,$sig); + $zhash = make_xchan_hash($guid,$zsig); // zot6 $sig = Libzot::sign($guid,$key['prvkey']); -- cgit v1.2.3 From 4eaddd12796cd49e9ee5d5527e2eaa519279d57e Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 24 Mar 2020 08:32:37 +0000 Subject: do not sync with incompatible hubs --- include/zot.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 7d7df9ece..bb5537d2e 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3299,7 +3299,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { if(intval($channel['channel_removed'])) return; - $h = q("select hubloc.*, site.site_crypto from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0", + $h = q("select hubloc.*, site.site_crypto, site.site_version, site.site_project from hubloc left join site on site_url = hubloc_url where hubloc_hash = '%s' and hubloc_deleted = 0", dbesc(($keychange) ? $packet['keychange']['old_hash'] : $channel['channel_portable_id']) ); @@ -3312,6 +3312,14 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { if($x['hubloc_host'] == App::get_hostname()) continue; + if(stripos($x['site_project'], 'hubzilla') !== false && version_compare($x['site_version'], '4.7.3', '<=')) { + + logger('Dismiss sync due to incompatible version.'); + // logger(print_r($x,true)); + continue; + + } + $y = q("select site_dead from site where site_url = '%s' limit 1", dbesc($x['hubloc_url']) ); @@ -3326,6 +3334,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) { $r = q("select xchan_guid, xchan_guid_sig from xchan where xchan_hash = '%s' limit 1", dbesc($channel['channel_portable_id']) ); + if(! $r) return; -- cgit v1.2.3 From a3acec96745f90443de84d8503334b3a204436fb Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 24 Mar 2020 18:26:20 -0700 Subject: issue 1454 - some photo item ActivityStreams links not returning json-ld; requires related fixes in addons/pubcrawl --- include/photos.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/photos.php b/include/photos.php index ee662f707..631660d7a 100644 --- a/include/photos.php +++ b/include/photos.php @@ -388,7 +388,7 @@ function photo_upload($channel, $observer, $args) { 'title' => $title, 'created' => $p['created'], 'edited' => $p['edited'], - 'id' => z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash, + 'id' => z_root() . '/item/' . $photo_hash, 'link' => $link, 'body' => $summary ); @@ -438,13 +438,13 @@ function photo_upload($channel, $observer, $args) { } } else { - $uuid = item_message_id(); - $mid = z_root() . '/item/' . $uuid; + // $uuid = item_message_id(); + $mid = z_root() . '/item/' . $photo_hash; $arr = [ 'aid' => $account_id, 'uid' => $channel_id, - 'uuid' => $uuid, + 'uuid' => $photo_hash, 'mid' => $mid, 'parent_mid' => $mid, 'item_hidden' => $item_hidden, -- cgit v1.2.3 From 0c1c386a0af1e8dabaf7acf345dffa5cf5ad89eb Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 25 Mar 2020 11:29:00 +0000 Subject: do not use channel_portable_id in process_channel_sync_delivery(). we should only accept sync packages from channels which are already transitioned to zot6. --- include/zot.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index bb5537d2e..5cf357d40 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3454,7 +3454,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $keychange = ((array_key_exists('keychange',$arr)) ? true : false); foreach ($deliveries as $d) { - $r = q("select * from channel where channel_portable_id = '%s' limit 1", + $r = q("select * from channel where channel_hash = '%s' limit 1", dbesc(($keychange) ? $arr['keychange']['old_hash'] : $d['hash']) ); @@ -3468,8 +3468,8 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $max_friends = service_class_fetch($channel['channel_id'],'total_channels'); $max_feeds = account_service_class_fetch($channel['channel_account_id'],'total_feeds'); - if($channel['channel_portable_id'] != $sender['hash']) { - logger('Possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_portable_id']); + if($channel['channel_hash'] != $sender['hash']) { + logger('Possible forgery. Sender ' . $sender['hash'] . ' is not ' . $channel['channel_hash']); $result[] = array($d['hash'],'channel mismatch',$channel['channel_name'],''); continue; } @@ -3486,7 +3486,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { $r = q("update channel set channel_prvkey = '%s', channel_pubkey = '%s', channel_guid_sig = '%s', - channel_portable_id = '%s' where channel_id = %d", + channel_hash = '%s' where channel_id = %d", dbesc($arr['channel']['channel_prvkey']), dbesc($arr['channel']['channel_pubkey']), dbesc($sig), -- cgit v1.2.3 From 0271f2a1ae5175fc5f1a7ec4f860a5d6372d7aeb Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Mar 2020 08:14:20 +0000 Subject: fix z6_discover() to do the right thing after transition --- include/hubloc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index 4a1f77733..059a4dadc 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -317,7 +317,7 @@ function z6_discover() { if ($c) { foreach ($c as $entry) { $q1 = q("select * from hubloc left join site on hubloc_url = site_url where hubloc_deleted = 0 and site_dead = 0 and hubloc_hash = '%s' and hubloc_url != '%s'", - dbesc($entry['channel_hash']), + dbesc($entry['channel_portable_id']), dbesc(z_root()) ); if (! $q1) { @@ -327,7 +327,7 @@ function z6_discover() { // does this particular server have a zot6 clone registered on our site for this channel? foreach ($q1 as $q) { $q2 = q("select * from hubloc left join site on hubloc_url = site_url where hubloc_deleted = 0 and site_dead = 0 and hubloc_hash = '%s' and hubloc_url = '%s'", - dbesc($entry['channel_portable_id']), + dbesc($entry['channel_hash']), dbesc($q['hubloc_url']) ); if ($q2) { -- cgit v1.2.3 From b739f91caa1522522a4ce093d7c63f0f4c777085 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 29 Mar 2020 15:18:49 +0000 Subject: use Libsync::build_sync_packet() in mod item, default Lib/Queue driver to zot6 and some whitespace cleanup in queue_deliver() --- include/queue_fn.php | 80 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'include') diff --git a/include/queue_fn.php b/include/queue_fn.php index 865228041..b72730d2f 100644 --- a/include/queue_fn.php +++ b/include/queue_fn.php @@ -228,49 +228,49 @@ function queue_deliver($outq, $immediate = false) { // normal zot delivery - logger('deliver: dest: ' . $outq['outq_posturl'], LOGGER_DEBUG); + logger('deliver: dest: ' . $outq['outq_posturl'] . ' driver: ' . $outq['outq_driver'], LOGGER_DEBUG); if($outq['outq_driver'] === 'zot6') { - if($outq['outq_posturl'] === z_root() . '/zot') { - // local delivery - $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']); - $result = $zot->run(true); - logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); - logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']); - Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); - } - else { - logger('remote'); - $channel = null; - - if($outq['outq_channel']) { - $channel = channelx_by_n($outq['outq_channel']); - } - - $host_crypto = null; - if($channel && $base) { - $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", - dbesc($base) - ); - if($h) { - $host_crypto = $h[0]; - } - } - - $msg = $outq['outq_notify']; - - $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); - - if($result['success']) { - logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']); - Libzot::process_response($outq['outq_posturl'],$result, $outq); - } - else { - logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']); - logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA); - update_queue_item($outq['outq_hash'],10); - } + if($outq['outq_posturl'] === z_root() . '/zot') { + // local delivery + $zot = new Receiver(new Zot6Handler(),$outq['outq_notify']); + $result = $zot->run(true); + logger('returned_json: ' . json_encode($result,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES), LOGGER_DATA); + logger('deliver: local zot6 delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],[ 'success' => true, 'body' => json_encode($result) ], $outq); + } + else { + logger('remote'); + $channel = null; + + if($outq['outq_channel']) { + $channel = channelx_by_n($outq['outq_channel']); + } + + $host_crypto = null; + if($channel && $base) { + $h = q("select hubloc_sitekey, site_crypto from hubloc left join site on hubloc_url = site_url where site_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", + dbesc($base) + ); + if($h) { + $host_crypto = $h[0]; + } + } + + $msg = $outq['outq_notify']; + + $result = Libzot::zot($outq['outq_posturl'],$msg,$channel,$host_crypto); + + if($result['success']) { + logger('deliver: remote zot6 delivery succeeded to ' . $outq['outq_posturl']); + Libzot::process_response($outq['outq_posturl'],$result, $outq); + } + else { + logger('deliver: remote zot6 delivery failed to ' . $outq['outq_posturl']); + logger('deliver: remote zot6 delivery fail data: ' . print_r($result,true), LOGGER_DATA); + update_queue_item($outq['outq_hash'],10); + } } return; -- cgit v1.2.3 From ffe429be65e8d6198579d3dd987053387799ca78 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Apr 2020 07:44:07 +0000 Subject: transition connections to zot6 if their site has been updated --- include/connections.php | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) (limited to 'include') diff --git a/include/connections.php b/include/connections.php index 51df18b70..c7ec163c8 100644 --- a/include/connections.php +++ b/include/connections.php @@ -772,3 +772,67 @@ function vcard_query(&$r) { } } } + +function z6trans_connections() { + + $r = q("SELECT DISTINCT abook.abook_xchan, hubloc.hubloc_addr, hubloc.hubloc_url, hubloc.hubloc_guid, site.site_project, site.site_version FROM abook + LEFT JOIN hubloc ON abook_xchan = hubloc_hash + LEFT JOIN site ON hubloc_url = site_url + WHERE abook.abook_self = 0 AND hubloc.hubloc_network = 'zot' + AND hubloc.hubloc_deleted = 0 AND site.site_dead = 0" + ); + + foreach($r as $rr) { + if(stripos($rr['site_project'], 'hubzilla') !== false && version_compare($rr['site_version'], '4.7.4', '>=')) { + + $zot_xchan = $rr['abook_xchan']; + $guid = $rr['hubloc_guid']; + $hub_url = $rr['hubloc_url']; + $addr = $rr['hubloc_addr']; + + $x = q("SELECT hubloc_hash FROM hubloc + WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6' AND hubloc_deleted = 0", + dbesc($guid), + dbesc($hub_url) + ); + + if(!$x) { + logger("z6trans_connections: zot6 hubloc for $addr not found"); + discover_by_webbie($addr,'zot6'); + continue; + } + + $zot6_xchan = $x[0]['hubloc_hash']; + + logger("z6trans_connections: transition $zot_xchan to $zot6_xchan"); + + q("START TRANSACTION"); + + $q1 = q("UPDATE abook set abook_xchan = '%s' WHERE abook_xchan = '%s'", + dbesc($zot6_xchan), + dbesc($zot_xchan) + ); + + $q2 = q("UPDATE abconfig set xchan = '%s' WHERE xchan = '%s'", + dbesc($zot6_xchan), + dbesc($zot_xchan) + ); + + $q3 = q("UPDATE pgrp_member set xchan = '%s' WHERE xchan = '%s'", + dbesc($zot6_xchan), + dbesc($zot_xchan) + ); + + if($q1 && $q2 && $q3) { + q("COMMIT"); + logger("z6trans_connections: completed"); + continue; + } + + logger("z6trans_connections: failed - performing rollback"); + q("ROLLBACK"); + + } + } + +} -- cgit v1.2.3 From 38be2386dd63a4a18c07e445b9859a5836ed5b46 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 1 Apr 2020 09:26:27 +0000 Subject: cheat with guid_sig to reflect transition to zot6 and re-enable transition 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 5cf357d40..8b9cb0767 100644 --- a/include/zot.php +++ b/include/zot.php @@ -4355,7 +4355,7 @@ function zotinfo($arr) { $r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash where channel_guid = '%s' and channel_guid_sig = '%s' limit 1", dbesc($zguid), - dbesc($zguid_sig) + dbesc('sha256.' . $zguid_sig) ); } elseif(strlen($zaddr)) { -- cgit v1.2.3 From ac52bebb88306273a481b7114fe190917da49b91 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Apr 2020 12:33:57 +0000 Subject: ATOM_TIME format is not compatible with the DB --- include/event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 64e63074c..b92d2c8a9 100644 --- a/include/event.php +++ b/include/event.php @@ -259,9 +259,9 @@ function format_event_bbcode($ev, $utc = false) { } if ($utc && $ev['event-timezone'] !== 'UTC') { - $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart'],ATOM_TIME); + $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']); if ($ev['dtend'] && ! $ev['nofinish']) { - $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend'],ATOM_TIME); + $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend']); } $ev['timezone'] = 'UTC'; } -- cgit v1.2.3 From 6cfaa5cba32eb1e7f2b4a0ba6bb281ebd610a54b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 18:34:15 +0000 Subject: set timezone iconfig a little earlier in the process so that it will be included in the object --- include/event.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index b92d2c8a9..0cc7170d1 100644 --- a/include/event.php +++ b/include/event.php @@ -1251,6 +1251,8 @@ function event_store_item($arr, $event) { else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); + set_iconfig($item_arr, 'event', 'timezone', $arr['timezone'], true); + $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) ); @@ -1286,7 +1288,7 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); - set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); + //set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); -- cgit v1.2.3 From cec2e92fe381a5e4bb67426290303639dd260358 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 19:50:50 +0000 Subject: more timezone changes --- include/event.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 0cc7170d1..f455a0dbf 100644 --- a/include/event.php +++ b/include/event.php @@ -40,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -50,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -98,11 +98,11 @@ function format_event_obj($jobject) { '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Start:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), '$dtend_label' => t('End:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), '$allday' => $allday, '$oneday' => $oneday )); @@ -1097,6 +1097,8 @@ function event_store_item($arr, $event) { ); if($r) { + set_iconfig($r[0], 'event', 'timezone', $arr['timezone'], true); + $object = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], @@ -1167,7 +1169,7 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; - set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); + //set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); /** * @hooks event_updated -- cgit v1.2.3 From ec9418b2626f343614b3307902551ea68307002c Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 22:01:02 +0200 Subject: Revert "set timezone iconfig a little earlier in the process so that it will be included in the object" This reverts commit 6cfaa5cba32eb1e7f2b4a0ba6bb281ebd610a54b --- include/event.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index f455a0dbf..fbc46100f 100644 --- a/include/event.php +++ b/include/event.php @@ -1253,8 +1253,6 @@ function event_store_item($arr, $event) { else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); - set_iconfig($item_arr, 'event', 'timezone', $arr['timezone'], true); - $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) ); @@ -1290,7 +1288,7 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); - //set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); + set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); -- cgit v1.2.3 From cade25a112d3884034090135db421dab805a93d6 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 22:01:44 +0200 Subject: Revert "more timezone changes" This reverts commit cec2e92fe381a5e4bb67426290303639dd260358 --- include/event.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index fbc46100f..b92d2c8a9 100644 --- a/include/event.php +++ b/include/event.php @@ -40,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -50,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -98,11 +98,11 @@ function format_event_obj($jobject) { '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Start:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), '$dtend_label' => t('End:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), '$allday' => $allday, '$oneday' => $oneday )); @@ -1097,8 +1097,6 @@ function event_store_item($arr, $event) { ); if($r) { - set_iconfig($r[0], 'event', 'timezone', $arr['timezone'], true); - $object = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], @@ -1169,7 +1167,7 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; - //set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); + set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); /** * @hooks event_updated -- cgit v1.2.3 From 44b935f8756ea751371065f1edc4f6fab339ab3d Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 4 Apr 2020 15:41:58 +0000 Subject: another attempt to get events right --- include/event.php | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index b92d2c8a9..d39da227c 100644 --- a/include/event.php +++ b/include/event.php @@ -40,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -50,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -97,12 +97,12 @@ function format_event_obj($jobject) { $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Start:'), - '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), '$finish' => (($object['nofinish']) ? false : true), '$dtend_label' => t('End:'), - '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), '$allday' => $allday, '$oneday' => $oneday )); @@ -257,7 +257,7 @@ function format_event_bbcode($ev, $utc = false) { if($ev['event_vdata']) { $o .= '[event]' . $ev['event_vdata'] . '[/event]'; } - +/* if ($utc && $ev['event-timezone'] !== 'UTC') { $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']); if ($ev['dtend'] && ! $ev['nofinish']) { @@ -265,7 +265,7 @@ function format_event_bbcode($ev, $utc = false) { } $ev['timezone'] = 'UTC'; } - +*/ if($ev['summary']) $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]'; @@ -284,8 +284,8 @@ function format_event_bbcode($ev, $utc = false) { if($ev['event_hash']) $o .= '[event-id]' . $ev['event_hash'] . '[/event-id]'; - if($ev['timezone']) - $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]'; +// if($ev['timezone']) +// $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]'; if($ev['adjust']) $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]'; @@ -1091,12 +1091,17 @@ function event_store_item($arr, $event) { $item_arr['comment_policy'] = 'none'; } - $r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1", + $r = q("SELECT * FROM item WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1", dbesc($event['event_hash']), intval($arr['uid']) ); if($r) { + + set_iconfig($r[0]['id'], 'event', 'timezone', $arr['timezone'], true); + xchan_query($r); + $r = fetch_post_tags($r,true); + $object = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], @@ -1111,13 +1116,13 @@ function event_store_item($arr, $event) { 'content' => format_event_bbcode($arr), 'attachment' => Activity::encode_attachment($r[0]), 'author' => array( - 'name' => $r[0]['xchan_name'], - 'address' => $r[0]['xchan_addr'], - 'guid' => $r[0]['xchan_guid'], - 'guid_sig' => $r[0]['xchan_guid_sig'], + 'name' => $r[0]['author']['xchan_name'], + 'address' => $r[0]['author']['xchan_addr'], + 'guid' => $r[0]['author']['xchan_guid'], + 'guid_sig' => $r[0]['author']['xchan_guid_sig'], 'link' => array( - array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']), - array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m']) + array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['author']['xchan_url']), + array('rel' => 'photo', 'type' => $r[0]['author']['xchan_photo_mimetype'], 'href' => $r[0]['author']['xchan_photo_m']) ), ), )); @@ -1167,7 +1172,6 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; - set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); /** * @hooks event_updated @@ -1251,6 +1255,8 @@ function event_store_item($arr, $event) { else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); + set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); + $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) ); @@ -1286,7 +1292,6 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); - set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); -- cgit v1.2.3 From 805f8bf98377d17593dfe884eac5c69079b83eed Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 07:59:41 +0000 Subject: show event timezone if it differs from the channel default timezone --- include/event.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index d39da227c..c8f9d2561 100644 --- a/include/event.php +++ b/include/event.php @@ -76,7 +76,17 @@ function format_event_obj($jobject) { //ensure compatibility with older items - this check can be removed at a later point if(array_key_exists('description', $object)) { - $tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); + $event_tz = ''; + if(is_array($object['asld']) && isset($object['asld']['attachment'])) { + foreach($object['asld']['attachment'] as $attachment) { + if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { + $event_tz = $attachment['value']; + break; + } + } + + } + $allday = (($object['adjust']) ? false : true); $dtstart = new DateTime($object['dtstart']); @@ -104,7 +114,8 @@ function format_event_obj($jobject) { '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), '$allday' => $allday, - '$oneday' => $oneday + '$oneday' => $oneday, + '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)] )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( -- cgit v1.2.3 From 84183d9f7ef669779841cfccd65aae8000012e6d Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 09:11:12 +0000 Subject: show event timezone only if adjust ist set and the offset of the event timezone is different from the channel default timezone offset --- include/event.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index c8f9d2561..69ca64e0f 100644 --- a/include/event.php +++ b/include/event.php @@ -77,14 +77,22 @@ function format_event_obj($jobject) { if(array_key_exists('description', $object)) { $event_tz = ''; - if(is_array($object['asld']) && isset($object['asld']['attachment'])) { + if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { foreach($object['asld']['attachment'] as $attachment) { if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { - $event_tz = $attachment['value']; + // check if the offset of the timezones is different and only set event_tz if offset is not the same + $local_tz = new DateTimeZone(date_default_timezone_get()); + $local_dt = new DateTime('now', $local_tz); + + $ev_tz = new DateTimeZone($attachment['value']); + $ev_dt = new DateTime('now', $ev_tz); + + if($local_dt->getOffset() !== $ev_dt->getOffset()) + $event_tz = $attachment['value']; + break; } } - } $allday = (($object['adjust']) ? false : true); -- cgit v1.2.3 From cb2996a40cf86d727bfda2df86bdcc8d643b46da Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 15:00:08 +0000 Subject: another import fix and do not allow importing channels < version 4.7.4 for zot6 compatibility reasons --- include/import.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/import.php b/include/import.php index bfe71963f..910cb8be7 100644 --- a/include/import.php +++ b/include/import.php @@ -1,6 +1,7 @@ Date: Wed, 8 Apr 2020 18:41:54 +0000 Subject: remove voting from UI in favour of polls --- include/conversation.php | 8 -------- include/features.php | 8 -------- 2 files changed, 16 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 62d4b405f..49dd411fb 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1287,13 +1287,6 @@ function hz_status_editor($a, $x, $popup = false) { $plaintext = true; -// if(feature_enabled(local_channel(),'richtext')) -// $plaintext = false; - - $feature_voting = feature_enabled($x['profile_uid'], 'consensus_tools'); - if(x($x, 'hide_voting')) - $feature_voting = false; - $feature_nocomment = feature_enabled($x['profile_uid'], 'disable_comments'); if(x($x, 'disable_comments')) $feature_nocomment = false; @@ -1446,7 +1439,6 @@ function hz_status_editor($a, $x, $popup = false) { '$poll_add_option_label' => t('Add option'), '$poll_expire_unit_label' => [t('Minutes'), t('Hours'), t('Days')], '$multiple_answers' => ['poll_multiple_answers', t("Allow multiple answers"), '', '', [t('No'), t('Yes')]], - '$feature_voting' => $feature_voting, '$consensus' => ((array_key_exists('item',$x)) ? $x['item']['item_consensus'] : 0), '$nocommenttitle' => t('Disable comments'), '$nocommenttitlesub' => t('Toggle comments'), diff --git a/include/features.php b/include/features.php index c6cfcf822..0dd245e7f 100644 --- a/include/features.php +++ b/include/features.php @@ -229,14 +229,6 @@ function get_features($filtered = true, $level = (-1)) { false, get_config('feature_lock','content_encrypt'), ], - - [ - 'consensus_tools', - t('Enable Voting Tools'), - t('Provide a class of post which others can vote on'), - false, - get_config('feature_lock','consensus_tools'), - ], [ 'disable_comments', -- cgit v1.2.3 From 328685d2fbe505fd5b1bf9892a0cce993210ac52 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Apr 2020 09:38:36 +0000 Subject: move from build_sync_packet() to Libsync::build_sync_packet() --- include/attach.php | 6 ++++-- include/channel.php | 4 ++-- include/event.php | 3 ++- include/group.php | 9 +++++---- include/items.php | 9 +++++---- include/menu.php | 4 +++- 6 files changed, 21 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 952270949..d986f4af1 100644 --- a/include/attach.php +++ b/include/attach.php @@ -11,6 +11,8 @@ * @todo Also an 'append' option to the storage function might be a useful addition. */ +use Zotlabs\Lib\Libsync; + require_once('include/permissions.php'); require_once('include/security.php'); require_once('include/group.php'); @@ -1018,7 +1020,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $sync = attach_export_data($channel,$hash); if($sync) - build_sync_packet($channel['channel_id'],array('file' => array($sync))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($sync))); } if($notify) { @@ -1403,7 +1405,7 @@ function attach_change_permissions($channel_id, $resource, $allow_cid, $allow_gi $data = attach_export_data($channel,$resource); if($data) - build_sync_packet($channel['channel_id'],array('file' => array($data))); + Libsync::build_sync_packet($channel['channel_id'],array('file' => array($data))); } } diff --git a/include/channel.php b/include/channel.php index 25eb93cac..be58f154a 100644 --- a/include/channel.php +++ b/include/channel.php @@ -673,7 +673,7 @@ function change_channel_keys($channel) { } } - build_sync_packet($channel['channel_id'], [ 'keychange' => $stored ]); + Libsync::build_sync_packet($channel['channel_id'], [ 'keychange' => $stored ]); $a = q("select * from abook where abook_xchan = '%s' and abook_self = 1", dbesc($stored['old_hash']) @@ -2241,7 +2241,7 @@ function profiles_build_sync($channel_id,$send = true) { ); if($r) { if($send) { - build_sync_packet($channel_id,array('profile' => $r)); + Libsync::build_sync_packet($channel_id,array('profile' => $r)); } else { return $r; diff --git a/include/event.php b/include/event.php index 69ca64e0f..c9cbb7c94 100644 --- a/include/event.php +++ b/include/event.php @@ -8,6 +8,7 @@ use Sabre\VObject; use Zotlabs\Lib\Activity; +use Zotlabs\Lib\Libsync; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; @@ -663,7 +664,7 @@ function event_addtocal($item_id, $uid) { intval($channel['channel_id']) ); if($z) { - build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); + Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); } return true; } diff --git a/include/group.php b/include/group.php index 6011af08f..efda389d6 100644 --- a/include/group.php +++ b/include/group.php @@ -1,5 +1,6 @@ [$sync_data]]); + Libsync::build_sync_packet($item['uid'], ['event' => [$sync_data]]); } } @@ -3882,7 +3883,7 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) { $channel = channelx_by_n($item['uid']); $sync_data = attach_export_data($channel, $item['resource_id'], true); if($sync_data) - build_sync_packet($item['uid'], ['file' => [$sync_data]]); + Libsync::build_sync_packet($item['uid'], ['file' => [$sync_data]]); } // immediately remove any undesired profile likes. @@ -4726,7 +4727,7 @@ function sync_an_item($channel_id,$item_id) { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($channel_id, array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($channel_id, array('item' => array(encode_item($sync_item[0],true)))); } } @@ -4928,7 +4929,7 @@ function item_create_edit_activity($post) { if($r) { xchan_query($r); $sync_item = fetch_post_tags($r); - build_sync_packet($new_item['uid'],array('item' => array(encode_item($sync_item[0],true)))); + Libsync::build_sync_packet($new_item['uid'],array('item' => array(encode_item($sync_item[0],true)))); } } diff --git a/include/menu.php b/include/menu.php index 1a2059451..88863f57b 100644 --- a/include/menu.php +++ b/include/menu.php @@ -1,5 +1,7 @@ array(menu_element($c,$m)))); + Libsync::build_sync_packet($uid,array('menu' => array(menu_element($c,$m)))); } } } -- cgit v1.2.3 From 6a0ac591d161df1b3a1d6182915ed01cfee95b0a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 10 Apr 2020 14:27:20 -0700 Subject: event issue when using strict sql mode --- include/event.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index c9cbb7c94..6161175f6 100644 --- a/include/event.php +++ b/include/event.php @@ -422,6 +422,10 @@ function event_store_event($arr) { $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); $arr['event_priority'] = (($arr['event_priority']) ? $arr['event_priority'] : 0); + if (! $arr['dtend']) { + $arr['dtend'] = NULL_DATE; + $arr['nofinish'] = 1; + } if(array_key_exists('event_status_date',$arr)) $arr['event_status_date'] = datetime_convert('UTC','UTC', $arr['event_status_date']); @@ -507,9 +511,9 @@ function event_store_event($arr) { deny_gid = '%s' WHERE id = %d AND uid = %d", - dbesc($arr['edited']), - dbesc($arr['dtstart']), - dbesc($arr['dtend']), + dbesc(datetime_convert('UTC','UTC',$arr['edited'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtstart'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtend'])), dbesc($arr['summary']), dbesc($arr['description']), dbesc($arr['location']), @@ -517,7 +521,7 @@ function event_store_event($arr) { intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['event_status']), - dbesc($arr['event_status_date']), + dbesc(datetime_convert('UTC','UTC',$arr['event_status_date'])), intval($arr['event_percent']), dbesc($arr['event_repeat']), intval($arr['event_sequence']), @@ -553,10 +557,10 @@ function event_store_event($arr) { intval($arr['account']), dbesc($arr['event_xchan']), dbesc($hash), - dbesc($arr['created']), - dbesc($arr['edited']), - dbesc($arr['dtstart']), - dbesc($arr['dtend']), + dbesc(datetime_convert('UTC','UTC',$arr['created'])), + dbesc(datetime_convert('UTC','UTC',$arr['edited'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtstart'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtend'])), dbesc($arr['summary']), dbesc($arr['description']), dbesc($arr['location']), @@ -564,7 +568,7 @@ function event_store_event($arr) { intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['event_status']), - dbesc($arr['event_status_date']), + dbesc(datetime_convert('UTC','UTC',$arr['event_status_date'])), intval($arr['event_percent']), dbesc($arr['event_repeat']), intval($arr['event_sequence']), -- cgit v1.2.3 From 52e698cae6794ce92c249fd365f6035f88382688 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Apr 2020 07:05:01 +0000 Subject: function is_edit_activity() is obsolete --- include/conversation.php | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 49dd411fb..a78ee1704 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -423,35 +423,9 @@ function visible_activity($item) { } } - - - if(is_edit_activity($item)) - return false; - return true; } -/** - * @brief Check if a given activity is an edit activity - * - * - * @param array $item - * @return boolean - */ - -function is_edit_activity($item) { - - $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)]; - - // In order to share edits with networks which have no concept of editing, we'll create - // separate activities to indicate the edit. Our network will not require them, since our - // edits are automatically applied and the activity indicated. - - if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) - return true; - - return false; -} /** * @brief "Render" a conversation or list of items for HTML display. -- cgit v1.2.3 From 27ae9c9d343fec96f117d5c4940d2221bc7cfd55 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Apr 2020 07:35:17 +0000 Subject: just comment out is_edit_activity() call and add comments on why it is commented out --- include/conversation.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index a78ee1704..b0e81b7e2 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -423,9 +423,43 @@ function visible_activity($item) { } } + // We only need edit activities for other federated protocols + // which do not support edits natively. While this does federate + // edits, it presents a number of issues locally - such as #757 and #758. + // The SQL check for an edit activity would not perform that well so to fix these issues + // requires an additional item flag (perhaps 'item_edit_activity') that we can add to the + // query for searches and notifications. + + // For now we'll just forget about trying to make edits work on network protocols that + // don't support them. + + // if(is_edit_activity($item)) + // return false; + return true; } +/** + * @brief Check if a given activity is an edit activity + * + * + * @param array $item + * @return boolean + */ + +function is_edit_activity($item) { + + $post_types = [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_COMMENT, basename(ACTIVITY_OBJ_NOTE), basename(ACTIVITY_OBJ_COMMENT)]; + + // In order to share edits with networks which have no concept of editing, we'll create + // separate activities to indicate the edit. Our network will not require them, since our + // edits are automatically applied and the activity indicated. + + if(($item['verb'] === ACTIVITY_UPDATE) && (in_array($item['obj_type'],$post_types))) + return true; + + return false; +} /** * @brief "Render" a conversation or list of items for HTML display. -- cgit v1.2.3 From 69878ed628735cf1ecca3b6a2480a648c1e89127 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Apr 2020 07:54:22 +0000 Subject: handle some basic friendica attachment bbcodes --- include/bbcode.php | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index b2e3f1d3b..e846e38db 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -319,6 +319,139 @@ function translate_design_element($type) { return $ret; } +function bb_format_attachdata($body) { + + $data = getAttachmentData($body); + + if($data) { + $txt = ''; + if($data['url'] && $data['title']) { + $txt .= "\n\n" . '[url=' . $data['url'] . ']' . $data['title'] . '[/url]'; + } + else { + if($data['url']) { + $txt .= "\n\n" . $data['url']; + } + if($data['title']) { + $txt .= "\n\n" . $data['title']; + } + } + if($data['preview']) { + $txt .= "\n\n" . '[img]' . $data['preview'] . '[/img]'; + } + if($data['image']) { + $txt .= "\n\n" . '[img]' . $data['image'] . '[/img]'; + } + + + $txt .= "\n\n" . $data['text']; + return preg_replace('/\[attachment(.*?)\](.*?)\[\/attachment\]/ism',$txt,$body); + } + + return $body; +} + +function getAttachmentData($body) { + + $data = []; + + if (! preg_match("/\[attachment(.*?)\](.*?)\[\/attachment\]/ism", $body, $match)) { + return null; + } + + $attributes = $match[1]; + + $data["text"] = trim($match[2]); + + $type = ""; + preg_match("/type='(.*?)'/ism", $attributes, $matches); + + if (x($matches, 1)) { + $type = strtolower($matches[1]); + } + + preg_match('/type=\"\;(.*?)\"\;/ism', $attributes, $matches); + if (x($matches, 1)) { + $type = strtolower($matches[1]); + } + + if ($type == "") { + return []; + } + + if (!in_array($type, ["link", "audio", "photo", "video"])) { + return []; + } + + if ($type != "") { + $data["type"] = $type; + } + $url = ""; + preg_match("/url='(.*?)'/ism", $attributes, $matches); + if (x($matches, 1)) { + $url = $matches[1]; + } + + preg_match('/url=\"\;(.*?)\"\;/ism', $attributes, $matches); + if (x($matches, 1)) { + $url = $matches[1]; + } + + if ($url != "") { + $data["url"] = html_entity_decode($url, ENT_QUOTES, 'UTF-8'); + } + + $title = ""; + preg_match("/title='(.*?)'/ism", $attributes, $matches); + if (x($matches, 1)) { + $title = $matches[1]; + } + + preg_match('/title=\"\;(.*?)\"\;/ism', $attributes, $matches); + if (x($matches, 1)) { + $title = $matches[1]; + } + if ($title != "") { + $title = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); + $title = str_replace(["[", "]"], ["[", "]"], $title); + $data["title"] = $title; + } + + $image = ""; + preg_match("/image='(.*?)'/ism", $attributes, $matches); + if (x($matches, 1)) { + $image = $matches[1]; + } + + preg_match('/image=\"\;(.*?)\"\;/ism', $attributes, $matches); + if (x($matches, 1)) { + $image = $matches[1]; + } + + if ($image != "") { + $data["image"] = html_entity_decode($image, ENT_QUOTES, 'UTF-8'); + } + + $preview = ""; + preg_match("/preview='(.*?)'/ism", $attributes, $matches); + if (x($matches, 1)) { + $preview = $matches[1]; + } + + preg_match('/preview=\"\;(.*?)\"\;/ism', $attributes, $matches); + if (x($matches, 1)) { + $preview = $matches[1]; + } + if ($preview != "") { + $data["preview"] = html_entity_decode($preview, ENT_QUOTES, 'UTF-8'); + } + + $data["description"] = trim($match[3]); + + $data["after"] = trim($match[4]); + + return $data; +} function bb_ShareAttributes($match) { @@ -935,6 +1068,8 @@ function bbcode($Text, $options = []) { $Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text); } + $Text = bb_format_attachdata($Text); + // If we find any event code, turn it into an event. // After we're finished processing the bbcode we'll // replace all of the event code with a reformatted version. -- cgit v1.2.3 From 244936b0fd3ac60defa9fa6042e6ee3be869721c Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Apr 2020 09:34:00 +0000 Subject: some work on improving federation of item_private and make sure we deal with an array in array_path_exists() --- 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 5d1cf6eff..6f56a0754 100644 --- a/include/text.php +++ b/include/text.php @@ -3732,7 +3732,7 @@ function array_path_exists($str,$arr) { if($search) { foreach($search as $s) { - if($ptr && array_key_exists($s,$ptr)) { + if(is_array($ptr) && array_key_exists($s,$ptr)) { $ptr = $ptr[$s]; } else { -- cgit v1.2.3 From 03506bd6cf70719819f35a4979a759a7afee7eab Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Apr 2020 11:58:08 +0000 Subject: use $mid as plink to prevent to long plinks --- include/event.php | 2 +- include/photos.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 6161175f6..82f6ca81e 100644 --- a/include/event.php +++ b/include/event.php @@ -1275,7 +1275,7 @@ function event_store_item($arr, $event) { // otherwise we'll fallback to /display/$message_id if($wall) - $item_arr['plink'] = z_root() . '/channel/' . $z[0]['channel_address'] . '/?f=&mid=' . gen_link_id($item_arr['mid']); + $item_arr['plink'] = $item_arr['mid']; else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); diff --git a/include/photos.php b/include/photos.php index 631660d7a..11dd07586 100644 --- a/include/photos.php +++ b/include/photos.php @@ -469,7 +469,7 @@ function photo_upload($channel, $observer, $args) { 'body' => $summary ]; - $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']); + $arr['plink'] = $mid; if($lat && $lon) $arr['coord'] = $lat . ' ' . $lon; @@ -850,7 +850,7 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $arr['deny_cid'] = $photo['deny_cid']; $arr['deny_gid'] = $photo['deny_gid']; - $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']); + $arr['plink'] = $mid; $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['imgscale'] . '[/zmg]' -- cgit v1.2.3 From 579adb48978172ae26f8cb1c724b8b17a6a37b34 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Apr 2020 09:42:40 +0000 Subject: fix onepoll --- 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 8b9cb0767..fb0804aa7 100644 --- a/include/zot.php +++ b/include/zot.php @@ -408,7 +408,7 @@ function zot_refresh($them, $channel = null, $force = false) { if($channel) { $postvars['target'] = $channel['xchan_guid']; - $postvars['target_sig'] = $channel['xchan_guid_sig']; + $postvars['target_sig'] = str_replace('sha256.', '', $channel['xchan_guid_sig']); $postvars['key'] = $channel['channel_pubkey']; } -- cgit v1.2.3 From b1b9dbe55f4cc0740b113514085da52f290853ee Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 22 Apr 2020 07:44:51 +0000 Subject: more prefer zot6 over zot --- include/channel.php | 2 +- include/zid.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index be58f154a..742d9e3a7 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1930,7 +1930,7 @@ function zid_init() { Master::Summon(array('Gprobe',bin2hex($tmp_str))); } if($r) { - $r = zot_record_preferred($r); + $r = Libzot::zot_record_preferred($r); } if($r && remote_channel() && remote_channel() === $r['hubloc_hash']) return; diff --git a/include/zid.php b/include/zid.php index 325af5580..10e09e212 100644 --- a/include/zid.php +++ b/include/zid.php @@ -1,5 +1,6 @@ Date: Thu, 23 Apr 2020 18:19:25 +0000 Subject: some work on deprecating ACTIVITY_OBJ_FILE --- include/attach.php | 92 +++++++++++++++++++++++++++++++++++++++++++++++------- include/items.php | 8 ++--- 2 files changed, 84 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index d986f4af1..7b5972525 100644 --- a/include/attach.php +++ b/include/attach.php @@ -12,6 +12,8 @@ */ use Zotlabs\Lib\Libsync; +use Zotlabs\Access\PermissionLimits; +use Zotlabs\Daemon\Master; require_once('include/permissions.php'); require_once('include/security.php'); @@ -1024,9 +1026,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } if($notify) { - $cloudPath = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $r['0']['display_path']; - $object = get_file_activity_object($channel['channel_id'], $r['0']['hash'], $cloudPath); - file_activity($channel['channel_id'], $object, $r['0']['allow_cid'], $r['0']['allow_gid'], $r['0']['deny_cid'], $r['0']['deny_gid'], 'post', $notify); + file_activity($channel, $observer, $r[0]); } return $ret; @@ -1517,7 +1517,7 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { */ call_hooks('attach_delete', $arr); - file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', true); + //file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', true); return; } @@ -1754,6 +1754,7 @@ function pipe_streams($in, $out, $bufsize = 16384) { * @param string $verb * @param boolean $notify */ +/* function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $verb, $notify) { require_once('include/items.php'); @@ -1802,7 +1803,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, $uuid = item_message_id(); $mid = z_root() . '/item/' . $uuid; - $objtype = ACTIVITY_OBJ_FILE; + $objtype = 'ACTIVITY_OBJ_FILE'; $arr = array(); $arr['aid'] = get_account_id(); @@ -1901,6 +1902,62 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, return; } +*/ + + +function file_activity($channel, $observer, $file) { + + $filetype_parts = explode('/', $file['filetype']); + + switch($filetype_parts[0]) { + case 'image': + $type = 'Image'; + break; + case 'audio': + $type = 'Audio'; + break; + case 'video': + $type = 'Video'; + break; + default: + $type = 'Document'; + } + + $resource_id = $file['hash']; + $uuid = new_uuid(); + + $mid = z_root() . '/item/' . $uuid; + + $arr = []; // Initialize the array of parameters for the post + $arr['aid'] = $channel['channel_account_id']; + $arr['uuid'] = $uuid; + $arr['uid'] = $channel['channel_id']; + $arr['mid'] = $mid; + $arr['parent_mid'] = $mid; + $arr['resource_type'] = 'attach'; + $arr['resource_id'] = $resource_id; + $arr['owner_xchan'] = $channel['channel_hash']; + $arr['author_xchan'] = $observer['xchan_hash']; + $arr['plink'] = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path']; + $arr['llink'] = $arr['plink']; + $arr['title'] = $file['filename']; + $arr['allow_cid'] = $file['allow_cid']; + $arr['allow_gid'] = $file['allow_gid']; + $arr['deny_cid'] = $file['deny_cid']; + $arr['deny_gid'] = $file['deny_gid']; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; + $arr['item_private'] = (($file['allow_cid'] || $file['allow_gid'] || $file['deny_cid'] || $file['deny_gid']) ? 1 : 0); + $arr['verb'] = ACTIVITY_CREATE; + $arr['obj_type'] = $type; + $arr['title'] = $file['filename']; + $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $arr['plink'] . ']' . t('file') . '[/zrl]'); + $arr['body'] = $body_str; + + post_activity_item($arr); + +} + /** * @brief Create file activity object. @@ -1917,17 +1974,28 @@ function get_file_activity_object($channel_id, $hash, $url) { dbesc($hash) ); - $url = rawurlencode($url); - - $links = array(); - $links[] = array( + $links = []; + $links[] = [ 'rel' => 'alternate', - 'type' => 'text/html', + 'type' => $x[0]['filetype'], 'href' => $url - ); + ]; + + $filetype_parts = explode('/', $x[0]['filetype']); + + switch($filetype_parts[0]) { + case 'audio': + $type = 'Audio'; + break; + case 'video': + $type = 'Video'; + break; + default: + $type = 'Document'; + } $object = array( - 'type' => ACTIVITY_OBJ_FILE, + 'type' => $type, 'title' => $x[0]['filename'], 'id' => $url, 'link' => $links, diff --git a/include/items.php b/include/items.php index 6fe5e1f0b..dbb4a7623 100755 --- a/include/items.php +++ b/include/items.php @@ -239,19 +239,19 @@ function comments_are_now_closed($item) { function item_normal() { return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 - and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' "; + and item.item_blocked = 0 "; } function item_normal_search() { return " and item.item_hidden = 0 and item.item_type in (0,3,6,7) and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 - and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' "; + and item.item_blocked = 0 "; } function item_normal_update() { return " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 - and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' "; + and item.item_blocked = 0 "; } @@ -267,7 +267,7 @@ function is_item_normal($item) { if(intval($item['item_hidden']) || intval($item['item_type']) || intval($item['item_deleted']) || intval($item['item_unpublished']) || intval($item['item_delayed']) || intval($item['item_pending_remove']) - || intval($item['item_blocked']) || ($item['obj_type'] == ACTIVITY_OBJ_FILE)) + || intval($item['item_blocked'])) return false; return true; -- cgit v1.2.3 From 77c87bcccf6fffca9975fd5a6c08cfddc1ca66e8 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Apr 2020 18:21:38 +0000 Subject: default item_wall to 0 --- 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 dbb4a7623..87ae5c6a5 100755 --- a/include/items.php +++ b/include/items.php @@ -423,7 +423,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) { if(! array_key_exists('item_origin',$arr)) $arr['item_origin'] = 1; if(! array_key_exists('item_wall',$arr) && (! $is_comment)) - $arr['item_wall'] = 1; + $arr['item_wall'] = 0; if(! array_key_exists('item_thread_top',$arr) && (! $is_comment)) $arr['item_thread_top'] = 1; -- cgit v1.2.3 From 7e89d816d7cddbd378e7eaed8e38f9776f3ae167 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Apr 2020 19:14:43 +0000 Subject: more work on deprecating ACTIVITY_OBJ_FILE --- include/attach.php | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 7b5972525..7149be735 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1026,7 +1026,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { } if($notify) { - file_activity($channel, $observer, $r[0]); + attach_store_item($channel, $observer, $r[0]); } return $ret; @@ -1452,9 +1452,6 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { return; } - $url = get_cloud_url($channel_id, $channel_address, $resource); - $object = get_file_activity_object($channel_id, $resource, $url); - // If resource is a directory delete everything in the directory recursive if(intval($r[0]['is_dir'])) { $x = q("SELECT hash, os_storage, is_dir, flags FROM attach WHERE folder = '%s' AND uid = %d", @@ -1498,6 +1495,9 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { if($r[0]['is_photo']) { attach_drop_photo($channel_id,$resource); } + else { + attach_drop_item($channel_id,$resource); + } // update the parent folder's lastmodified timestamp @@ -1517,8 +1517,6 @@ function attach_delete($channel_id, $resource, $is_photo = 0) { */ call_hooks('attach_delete', $arr); - //file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', true); - return; } @@ -1553,6 +1551,21 @@ function attach_drop_photo($channel_id,$resource) { } +function attach_drop_item($channel_id,$resource) { + + $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'attach' and uid = %d and item_deleted = 0", + dbesc($resource), + intval($channel_id) + ); + + if($x) { + $stage = (($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1); + $interactive = (($x[0]['item_hidden']) ? false : true); + drop_item($x[0]['id'], $interactive, $stage); + } + +} + /** * @brief Returns path to file in cloud/. @@ -1905,7 +1918,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, */ -function file_activity($channel, $observer, $file) { +function attach_store_item($channel, $observer, $file) { $filetype_parts = explode('/', $file['filetype']); @@ -1945,6 +1958,7 @@ function file_activity($channel, $observer, $file) { $arr['allow_gid'] = $file['allow_gid']; $arr['deny_cid'] = $file['deny_cid']; $arr['deny_gid'] = $file['deny_gid']; + $arr['item_wall'] = 1; $arr['item_origin'] = 1; $arr['item_thread_top'] = 1; $arr['item_private'] = (($file['allow_cid'] || $file['allow_gid'] || $file['deny_cid'] || $file['deny_gid']) ? 1 : 0); -- cgit v1.2.3 From e2b10f52e02c4cee77af089a544ec55e62048aba Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 24 Apr 2020 14:25:49 +0000 Subject: more work on deprecating ACTIVITY_OBJ_FILE and adapt mod sharedwithme --- include/attach.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 7149be735..fbf131fb3 100644 --- a/include/attach.php +++ b/include/attach.php @@ -12,6 +12,7 @@ */ use Zotlabs\Lib\Libsync; +use Zotlabs\Lib\Activity; use Zotlabs\Access\PermissionLimits; use Zotlabs\Daemon\Master; @@ -1940,6 +1941,7 @@ function attach_store_item($channel, $observer, $file) { $uuid = new_uuid(); $mid = z_root() . '/item/' . $uuid; + $path = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path']; $arr = []; // Initialize the array of parameters for the post $arr['aid'] = $channel['channel_account_id']; @@ -1951,8 +1953,6 @@ function attach_store_item($channel, $observer, $file) { $arr['resource_id'] = $resource_id; $arr['owner_xchan'] = $channel['channel_hash']; $arr['author_xchan'] = $observer['xchan_hash']; - $arr['plink'] = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path']; - $arr['llink'] = $arr['plink']; $arr['title'] = $file['filename']; $arr['allow_cid'] = $file['allow_cid']; $arr['allow_gid'] = $file['allow_gid']; @@ -1965,9 +1965,22 @@ function attach_store_item($channel, $observer, $file) { $arr['verb'] = ACTIVITY_CREATE; $arr['obj_type'] = $type; $arr['title'] = $file['filename']; - $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $arr['plink'] . ']' . t('file') . '[/zrl]'); + $body_str = sprintf(t('%s shared a %s with you'), '[zrl=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/zrl]', '[zrl=' . $path . ']' . t('file') . '[/zrl]'); $arr['body'] = $body_str; + $meta = [ + 'name' => $file['filename'], + 'type' => $file['filetype'], + 'size' => $file['filesize'], + 'revision' => $file['revision'], + 'size' => $file['filesize'], + 'created' => $file['created'], + 'edited' => $file['edited'], + 'path' => $path + ]; + + set_iconfig($arr, 'attach', 'meta' , $meta, true); + post_activity_item($arr); } -- cgit v1.2.3 From c229f058b4331e3b631d9ca725385ef78bf59778 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 25 Apr 2020 09:15:20 +0000 Subject: fix mod filestorage and fetch the info from attach if only the hash is provided in attach_store_item() --- include/attach.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index fbf131fb3..4c2459046 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1921,6 +1921,20 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid, function attach_store_item($channel, $observer, $file) { + + if(is_string($file)) { + $r = q("SELECT * FROM attach WHERE uid = %d AND hash = '%s' LIMIT 1", + intval($channel['channel_id']), + dbesc($file) + ); + + if(! $r) + return; + + $file = $r[0]; + + } + $filetype_parts = explode('/', $file['filetype']); switch($filetype_parts[0]) { -- cgit v1.2.3 From 079c13e6330bc3b4bc3928c55b89023be0af5ad7 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 29 Apr 2020 08:21:33 +0000 Subject: more work on attach_store_item() --- include/attach.php | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 4c2459046..d648293ee 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1935,6 +1935,59 @@ function attach_store_item($channel, $observer, $file) { } + $path = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path']; + + $r = q("SELECT * FROM item WHERE resource_id = '%s' AND resource_type = 'attach' and uid = %d LIMIT 1", + dbesc($file['hash']), + intval($channel['channel_id']) + ); + + if($r) { + + // At the moment only file permission edits are possible. + // If permissions did not change do nothing. Otherwise delete the item and create a new one with new permissions. + + if($r[0]['allow_cid'] === $file['allow_cid'] && $r[0]['allow_gid'] === $file['allow_gid'] && $r[0]['deny_cid'] === $file['deny_cid'] && $r[0]['deny_gid'] === $file['deny_gid']) { + + /* once possible, other edits (eg rename) can be done here. + + q("UPDATE item SET title = '%s' WHERE id = %d AND uid = %d", + dbesc($file['filename']) + ); + + $meta = [ + 'name' => $file['filename'], + 'type' => $file['filetype'], + 'size' => $file['filesize'], + 'revision' => $file['revision'], + 'size' => $file['filesize'], + 'created' => $file['created'], + 'edited' => $file['edited'], + 'path' => $path + ]; + + set_iconfig($r[0], 'attach', 'meta' , $meta, true); + + $post = item_store($arr); + + $item_id = $post['item_id']; + + if($item_id) { + Master::Summon(['Notifier', 'activity', $item_id]); + } + + */ + + return; + + } + + $stage = (($r[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1); + $interactive = (($r[0]['item_hidden']) ? false : true); + drop_item($r[0]['id'], $interactive, $stage); + + } + $filetype_parts = explode('/', $file['filetype']); switch($filetype_parts[0]) { @@ -1955,7 +2008,6 @@ function attach_store_item($channel, $observer, $file) { $uuid = new_uuid(); $mid = z_root() . '/item/' . $uuid; - $path = z_root() . '/cloud/' . $channel['channel_address'] . '/' . $file['display_path']; $arr = []; // Initialize the array of parameters for the post $arr['aid'] = $channel['channel_account_id']; @@ -1994,8 +2046,14 @@ function attach_store_item($channel, $observer, $file) { ]; set_iconfig($arr, 'attach', 'meta' , $meta, true); + + $post = item_store($arr); - post_activity_item($arr); + $item_id = $post['item_id']; + + if($item_id) { + Master::Summon(['Notifier', 'activity', $item_id]); + } } -- cgit v1.2.3 From c9794439bcdf7bf738055fdecddc754609b8b9ab Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 29 Apr 2020 08:24:00 +0000 Subject: adjust code comments and whitespace --- include/attach.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index d648293ee..80f71b9ea 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1945,7 +1945,8 @@ function attach_store_item($channel, $observer, $file) { if($r) { // At the moment only file permission edits are possible. - // If permissions did not change do nothing. Otherwise delete the item and create a new one with new permissions. + // Since we do not support permission editing on posts yet, + // we will delete the item and create a new one with the new permissions for now. if($r[0]['allow_cid'] === $file['allow_cid'] && $r[0]['allow_gid'] === $file['allow_gid'] && $r[0]['deny_cid'] === $file['deny_cid'] && $r[0]['deny_gid'] === $file['deny_gid']) { @@ -1967,7 +1968,7 @@ function attach_store_item($channel, $observer, $file) { ]; set_iconfig($r[0], 'attach', 'meta' , $meta, true); - + $post = item_store($arr); $item_id = $post['item_id']; @@ -2046,7 +2047,7 @@ function attach_store_item($channel, $observer, $file) { ]; set_iconfig($arr, 'attach', 'meta' , $meta, true); - + $post = item_store($arr); $item_id = $post['item_id']; -- cgit v1.2.3 From 01334d761aa8219c50625efd4ba4b1e74744c101 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 1 May 2020 10:24:00 +0000 Subject: set CURLOPT_ENCODING to empty string so that compressed content will be uncompressed --- include/network.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index c2edb4f8a..29c5bbcb9 100644 --- a/include/network.php +++ b/include/network.php @@ -61,7 +61,8 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) { @curl_setopt($ch, CURLOPT_CAINFO, get_capath()); @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); @curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); - @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; zot)"); + @curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; zot)'); + @curl_setopt($ch, CURLOPT_ENCODING, ''); $ciphers = @get_config('system','curl_ssl_ciphers'); if($ciphers) -- cgit v1.2.3 From ad040a0b111539d6cdc4922539d550e21500be04 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 May 2020 07:44:19 +0000 Subject: set CURLOPT_ENCODING in z_post_url() --- include/network.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/network.php b/include/network.php index 29c5bbcb9..80d19797b 100644 --- a/include/network.php +++ b/include/network.php @@ -258,6 +258,7 @@ function z_post_url($url, $params, $redirects = 0, $opts = array()) { @curl_setopt($ch, CURLOPT_POST,1); @curl_setopt($ch, CURLOPT_POSTFIELDS,$params); @curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; zot)"); + @curl_setopt($ch, CURLOPT_ENCODING, ''); $ciphers = @get_config('system','curl_ssl_ciphers'); if($ciphers) -- cgit v1.2.3 From 46242aeaae084191244008529703c964fa5b2d53 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 May 2020 09:24:22 +0000 Subject: display complete perminfo only to owner --- include/text.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 6f56a0754..0202061ab 100644 --- a/include/text.php +++ b/include/text.php @@ -1010,7 +1010,7 @@ function contact_block() { if(count($r)) { $contacts = t('Connections'); - $micropro = Array(); + $micropro = []; foreach($r as $rr) { // There is no setting to discover if you are bi-directionally connected @@ -1037,6 +1037,9 @@ function contact_block() { $rr['perminfo']['connperms'] .= t('Nothing'); } + if($is_owner && $rr['perminfo']['connpermcount'] !== 0) + unset($rr['perminfo']); + $micropro[] = micropro($rr,true,'mpfriend'); } } @@ -1047,7 +1050,7 @@ function contact_block() { '$contacts' => $contacts, '$nickname' => App::$profile['channel_address'], '$viewconnections' => (($total > $shown) ? sprintf(t('View all %s connections'),$total) : ''), - '$micropro' => $micropro, + '$micropro' => $micropro )); $arr = ['contacts' => $r, 'output' => $o]; -- cgit v1.2.3 From a40b882d723166313bacb04b67110fb31d960778 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 4 May 2020 09:26:06 +0000 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 0202061ab..b13458e99 100644 --- a/include/text.php +++ b/include/text.php @@ -1037,7 +1037,7 @@ function contact_block() { $rr['perminfo']['connperms'] .= t('Nothing'); } - if($is_owner && $rr['perminfo']['connpermcount'] !== 0) + if(!$is_owner && $rr['perminfo']['connpermcount'] !== 0) unset($rr['perminfo']); $micropro[] = micropro($rr,true,'mpfriend'); -- cgit v1.2.3 From 06d1cf83d2b1acfef5529fe388d2502bea381881 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 5 May 2020 14:51:00 +0000 Subject: deal with polls and votes in enotify --- include/text.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index b13458e99..a2e5ce37a 100644 --- a/include/text.php +++ b/include/text.php @@ -2240,6 +2240,9 @@ function item_post_type($item) { if(strlen($item['verb']) && (! activity_match($item['verb'],ACTIVITY_POST))) $post_type = t('activity'); + if($item['obj_type'] === 'Question') + $post_type = t('poll'); + return $post_type; } -- cgit v1.2.3 From c8b45c3449dd36c533cde2600920186fc941c8c8 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 7 May 2020 06:57:33 +0000 Subject: channelx caching --- include/channel.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 742d9e3a7..b71849a5f 100644 --- a/include/channel.php +++ b/include/channel.php @@ -4,6 +4,8 @@ * @brief Channel related functions. */ + +use App; use Zotlabs\Access\PermissionRoles; use Zotlabs\Access\PermissionLimits; use Zotlabs\Access\Permissions; @@ -2486,6 +2488,12 @@ function channelx_by_nick($nick) { $nick = punify($nick); + // return a cached copy if there is a cached copy and it's a match + + if (App::$channel && is_array(App::$channel) && array_key_exists('channel_address',App::$channel) && App::$channel['channel_address'] === $nick) { + return App::$channel; + } + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and channel_removed = 0 LIMIT 1", dbesc($nick) ); @@ -2500,6 +2508,11 @@ function channelx_by_nick($nick) { * @return array|boolean false if channel ID not found, otherwise the channel array */ function channelx_by_hash($hash) { + + if (App::$channel && is_array(App::$channel) && array_key_exists('channel_hash',App::$channel) && App::$channel['channel_hash'] === $hash) { + return App::$channel; + } + $r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and channel_removed = 0 LIMIT 1", dbesc($hash) ); @@ -2515,6 +2528,11 @@ function channelx_by_hash($hash) { * @return array|boolean false if channel ID not found, otherwise the channel array */ function channelx_by_portid($hash) { + + if (App::$channel && is_array(App::$channel) && array_key_exists('channel_portable_id',App::$channel) && intval(App::$channel['channel_portable_id']) === intval($hash)) { + return App::$channel; + } + $r = q("SELECT * FROM channel left join xchan on channel_portable_id = xchan_hash WHERE channel_portable_id = '%s' and channel_removed = 0 LIMIT 1", dbesc($hash) ); @@ -2529,6 +2547,11 @@ function channelx_by_portid($hash) { * @return array|boolean false if channel ID not found, otherwise the channel array */ function channelx_by_n($id) { + + if (App::$channel && is_array(App::$channel) && array_key_exists('channel_id',App::$channel) && intval(App::$channel['channel_id']) === intval($id)) { + return App::$channel; + } + $r = q("SELECT * FROM channel LEFT JOIN xchan ON channel_hash = xchan_hash WHERE channel_id = %d AND channel_removed = 0 LIMIT 1", dbesc($id) ); -- cgit v1.2.3 From 4ee809bed6ea023ad9e2888eedd65e083d4c1e3e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 7 May 2020 08:31:31 +0000 Subject: fix tests --- include/channel.php | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index b71849a5f..210b6ae91 100644 --- a/include/channel.php +++ b/include/channel.php @@ -5,7 +5,6 @@ */ -use App; use Zotlabs\Access\PermissionRoles; use Zotlabs\Access\PermissionLimits; use Zotlabs\Access\Permissions; -- cgit v1.2.3 From c656478230e0e5a4f3716e8ba227d9359961b00f Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 10 May 2020 16:13:01 -0700 Subject: issue with quoted hashtags/mentions --- include/text.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index a2e5ce37a..6873cc1c3 100644 --- a/include/text.php +++ b/include/text.php @@ -864,6 +864,11 @@ function get_tags($s) { $ret[] = $mtch; } } + if(preg_match_all('/([@#\!]\".*?\")/',$s,$match)) { + foreach($match[1] as $mtch) { + $ret[] = $mtch; + } + } // match bracket mentions @@ -2798,6 +2803,10 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $basetag = substr($tag,7); $basetag = substr($basetag,0,-6); } + elseif((substr($tag,0,2) === '#"') && (substr($tag,-1,1) === '"')) { + $basetag = substr($tag,2); + $basetag = substr($basetag,0,-1); + } else $basetag = substr($tag,1); @@ -2880,6 +2889,10 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $newname = substr($name,6); $newname = substr($newname,0,-6); } + elseif((substr($name,0,1) === '"') && (substr($name,-1,1) === '"')) { + $newname = substr($name,1); + $newname = substr($newname,0,-1); + } // select someone from this user's contacts by name -- cgit v1.2.3 From 2d3740b91246b37349b3ffa373f2706cd8b14b29 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 11 May 2020 20:22:25 +0000 Subject: Legacy Hubzilla compatibility: when we relay a comment from hubzilla < 4.0, we send it to ourself again but this time with a valid uri as mid. To catch this as duplicate, we need to check for the basename aswell. --- 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 87ae5c6a5..a566ddfd9 100755 --- a/include/items.php +++ b/include/items.php @@ -1973,8 +1973,9 @@ function item_store($arr, $allow_exec = false, $deliver = true) { ); } else { - $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d and revision = %d LIMIT 1", + $r = q("SELECT id FROM item WHERE (mid = '%s' OR mid = '%s') AND uid = %d and revision = %d LIMIT 1", dbesc($arr['mid']), + dbesc(basename(rawurldecode($arr['mid']))), // de-duplicate relayed comments from hubzilla < 4.0 intval($arr['uid']), intval($arr['revision']) ); -- cgit v1.2.3 From 97d5ffe056a70f9ed3e67d98b3c73b1cb41ebb1c Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 16 May 2020 08:44:24 +0000 Subject: wrong path --- include/dir_fns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 08a9fb653..34a6f13cd 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -349,7 +349,7 @@ function update_directory_entry($ud) { $hsig = $record['signature']; if($hsig && $hsig['signer'] === $url && $hsig['header_valid'] === true && $hsig['content_valid'] === true) { - $x = \Zotlabs\Zot\Libzot::import_xchan($record['data'], 0, $ud); + $x = \Zotlabs\Lib\Libzot::import_xchan($record['data'], 0, $ud); if($x['success']) { $success = true; } -- cgit v1.2.3 From d0c7c99d5e1eb27281431231640c7e8c019b90e1 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 18 May 2020 11:06:46 +0000 Subject: use strip_tags() on rss titles --- include/feedutils.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 9ff09cc66..0a9af7ee1 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -452,6 +452,7 @@ function get_atom_elements($feed, $item) { else { $res['title'] = bbcode($res['title'], [ 'tryoembed' => false ]); $res['title'] = html2plain($res['title'], 0, true); + $res['title'] = strip_tags($res['title']); $res['title'] = html_entity_decode($res['title'], ENT_QUOTES, 'UTF-8'); $res['title'] = preg_replace("/https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+/", "", $res['title']); while (strpos($res['title'], "\n") !== false) -- cgit v1.2.3 From 3201a4bec5f3524c2eba813e46d69b4c5943840f Mon Sep 17 00:00:00 2001 From: Zot Date: Thu, 11 Jun 2020 12:13:43 +0200 Subject: allow apps to be both pinned and starred independently --- include/nav.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index bd4d000f7..b2a061661 100644 --- a/include/nav.php +++ b/include/nav.php @@ -296,14 +296,10 @@ function nav($template = 'default') { $app['active'] = true; if($is_owner) { - if(strpos($app['categories'],'nav_pinned_app') === false) { - $nav_apps[] = Apps::app_render($app,'nav'); - } + $nav_apps[] = Apps::app_render($app,'nav'); } elseif(! $is_owner && strpos($app['requires'], 'local_channel') === false) { - if(strpos($app['categories'],'nav_pinned_app') === false) { - $nav_apps[] = Apps::app_render($app,'nav'); - } + $nav_apps[] = Apps::app_render($app,'nav'); } } } -- cgit v1.2.3 From 92ee27349cb62e0a78f25686c3fe64cd8dd4130c Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 14 Jun 2020 13:35:17 +0000 Subject: check for zot6 first --- include/network.php | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index 80d19797b..aada36fba 100644 --- a/include/network.php +++ b/include/network.php @@ -1102,29 +1102,6 @@ function discover_by_webbie($webbie, $protocol = '') { $x = webfinger_rfc7033($webbie, true); if($x && array_key_exists('links',$x) && $x['links']) { - foreach($x['links'] as $link) { - if(array_key_exists('rel',$link)) { - - // If we discover zot - don't search further; grab the info and get out of - // here. - - if($link['rel'] === PROTOCOL_ZOT && ((! $protocol) || (strtolower($protocol) === 'zot'))) { - logger('zot found for ' . $webbie, LOGGER_DEBUG); - if(array_key_exists('zot',$x) && $x['zot']['success']) { - $i = import_xchan($x['zot']); - return true; - } - else { - $z = z_fetch_url($link['href']); - if($z['success']) { - $j = json_decode($z['body'],true); - $i = import_xchan($j); - return true; - } - } - } - } - } foreach($x['links'] as $link) { if(array_key_exists('rel',$link)) { @@ -1150,6 +1127,31 @@ function discover_by_webbie($webbie, $protocol = '') { } } } + + foreach($x['links'] as $link) { + if(array_key_exists('rel',$link)) { + + // If we discover zot - don't search further; grab the info and get out of + // here. + + if($link['rel'] === PROTOCOL_ZOT && ((! $protocol) || (strtolower($protocol) === 'zot'))) { + logger('zot found for ' . $webbie, LOGGER_DEBUG); + if(array_key_exists('zot',$x) && $x['zot']['success']) { + $i = import_xchan($x['zot']); + return true; + } + else { + $z = z_fetch_url($link['href']); + if($z['success']) { + $j = json_decode($z['body'],true); + $i = import_xchan($j); + return true; + } + } + } + } + } + } logger('webfinger: ' . print_r($x,true), LOGGER_DATA, LOG_INFO); -- cgit v1.2.3 From 36e969fd79a252e9aef7a87b8fa2d5f7c75ecd6d Mon Sep 17 00:00:00 2001 From: Zot Date: Wed, 17 Jun 2020 09:12:15 +0200 Subject: zap group compatibility - rewrites DMs and wall-to-wall posts to group pages as new posts authored by the group with an embedded reshare. This currently has known delivery issues due to zot/zot6 xchan confusion which are already slated for resolution in hz5. Specifically "sender is not owner/author" and missing abconfig permissions on the zot6 identity for a channel we're connected with over traditional zot. --- include/items.php | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index a566ddfd9..f2db7288f 100755 --- a/include/items.php +++ b/include/items.php @@ -12,6 +12,7 @@ use Zotlabs\Lib\IConfig; use Zotlabs\Lib\Activity; use Zotlabs\Lib\Libsync; use Zotlabs\Access\PermissionLimits; +use Zotlabs\Access\PermissionRoles; use Zotlabs\Access\AccessList; use Zotlabs\Daemon\Master; @@ -290,7 +291,7 @@ function is_item_normal($item) { */ function can_comment_on_post($observer_xchan, $item) { -// logger('Comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG); + // logger('Comment_policy: ' . $item['comment_policy'], LOGGER_DEBUG); $x = [ 'observer_hash' => $observer_xchan, @@ -351,7 +352,8 @@ function can_comment_on_post($observer_xchan, $item) { return true; } break; - default: + + default: break; } if(strstr($item['comment_policy'],'network:') && strstr($item['comment_policy'],'red')) { @@ -2628,6 +2630,12 @@ function get_item_contact($item,$contacts) { */ function tag_deliver($uid, $item_id) { + $role = get_pconfig($uid,'system','permissions_role'); + $rolesettings = PermissionRoles::role_perms($role); + $channel_type = isset($rolesettings['channel_type']) ? $rolesettings['channel_type'] : 'normal'; + + $is_group = (($channel_type === 'group') ? true : false); + $mention = false; /* @@ -2647,6 +2655,7 @@ function tag_deliver($uid, $item_id) { if(! $i) return; + xchan_query($i,true); $i = fetch_post_tags($i); $item = $i[0]; @@ -2662,6 +2671,28 @@ function tag_deliver($uid, $item_id) { return; } + if ($is_group && intval($item['item_private']) === 2 && intval($item['item_thread_top'])) { + // group delivery via DM + logger('group DM delivery for ' . $u[0]['channel_address']); + start_delivery_chain($u[0], $item, $item_id, 0, false); + return; + } + + + if ($is_group && intval($item['item_thread_top']) && intval($item['item_wall']) && $item['author_xchan'] !== $item['owner_xchan']) { + if (strpos($item['body'],'[/share]')) { + logger('W2W post already shared'); + return; + } + // group delivery via W2W + logger('rewriting W2W post for ' . $u[0]['channel_address']); + start_delivery_chain($u[0], $item, $item_id, 0, false); + q("update item set item_wall = 0 where id = %d", + intval($item_id) + ); + return; + } + /* * Seems like a good place to plug in a poke notification. */ @@ -2965,6 +2996,13 @@ function item_community_tag($channel,$item) { */ function tgroup_check($uid, $item) { + + $role = get_pconfig($uid,'system','permissions_role'); + $rolesettings = PermissionRoles::role_perms($role); + $channel_type = isset($rolesettings['channel_type']) ? $rolesettings['channel_type'] : 'normal'; + + $is_group = (($channel_type === 'group') ? true : false); + $mention = false; // check that the message originated elsewhere and is a top-level post @@ -2981,6 +3019,15 @@ function tgroup_check($uid, $item) { return false; } + // post to group via DM + + if ($is_group) { + if (intval($item['item_private']) === 2 && $item['mid'] === $item['parent_mid']) { + return true; + } + } + + // see if we already have this item. Maybe it is being updated. $r = q("select id from item where mid = '%s' and uid = %d limit 1", @@ -3136,6 +3183,75 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) } } + // @todo handle edit and parent correctly + + if(! $parent) { + + if ($edit) { + return; + } + + $arr = []; + + $arr['aid'] = $channel['channel_account_id']; + $arr['uid'] = $channel['channel_id']; + + $arr['item_private'] = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] + || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0); + + $arr['item_origin'] = 1; + $arr['item_wall'] = 1; + + $arr['uuid'] = item_message_id(); + $arr['mid'] = z_root() . '/activity/' . $arr['uuid']; + $arr['parent_mid'] = $arr['mid']; + $arr['item_thread_top'] = 1; + + if (strpos($item['body'], "[/share]") !== false) { + $pos = strpos($item['body'], "[share"); + $bb = substr($item['body'], $pos); + } else { + $bb = "[share author='" . urlencode($item['author']['xchan_name']). + "' profile='" . $item['author']['xchan_url'] . + "' portable_id='" . $item['author']['xchan_hash'] . + "' avatar='" . $item['author']['xchan_photo_s'] . + "' link='" . $item['plink'] . + "' auth='" . ((in_array($item['author']['network'], ['zot','zot6'])) ? 'true' : 'false') . + "' posted='" . $item['created'] . + "' message_id='" . $item['mid'] . + "']"; + if($item['title']) + $bb .= '[b]'.$item['title'].'[/b]'."\r\n"; + $bb .= $item['body']; + $bb .= "[/share]"; + } + + $mention = '@[zrl=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/zrl]'; + $arr['body'] = $bb; + + $arr['author_xchan'] = $channel['channel_hash']; + $arr['owner_xchan'] = $channel['channel_hash']; + // $arr['obj'] = $item['obj']; + $arr['obj_type'] = $item['obj_type']; + $arr['verb'] = ACTIVITY_POST; + + $arr['allow_cid'] = $channel['channel_allow_cid']; + $arr['allow_gid'] = $channel['channel_allow_gid']; + $arr['deny_cid'] = $channel['channel_deny_cid']; + $arr['deny_gid'] = $channel['channel_deny_gid']; + $arr['comment_policy'] = map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments')); + + $post = item_store($arr); + + $post_id = $post['item_id']; + + if($post_id) { + Master::Summon([ 'Notifier','tgroup',$post_id ]); + } + return; + } + + // 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 fa752b0ac1bf4c0b19fcb0f7ff7dcfa3b3b90078 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Jul 2020 19:06:24 -0700 Subject: zot6 group updates to support edit and delete of top-level group posts. This is supported remotely by editing or removing the post that started it all. A W2W post can only be deleted at this time. --- include/items.php | 74 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index f2db7288f..7df5e35fe 100755 --- a/include/items.php +++ b/include/items.php @@ -2660,21 +2660,23 @@ function tag_deliver($uid, $item_id) { $item = $i[0]; - if(($item['source_xchan']) && intval($item['item_uplink']) + if(intval($item['item_uplink']) && $item['source_xchan'] && intval($item['item_thread_top']) && ($item['edited'] != $item['created'])) { // this is an update (edit) to a post which was already processed by us and has a second delivery chain // Just start the second delivery chain to deliver the updated post // after resetting ownership and permission bits logger('updating edited tag_deliver post for ' . $u[0]['channel_address']); - start_delivery_chain($u[0], $item, $item_id, 0, true); + start_delivery_chain($u[0], $item, $item_id, 0, false, true); return; } if ($is_group && intval($item['item_private']) === 2 && intval($item['item_thread_top'])) { // group delivery via DM - logger('group DM delivery for ' . $u[0]['channel_address']); - start_delivery_chain($u[0], $item, $item_id, 0, false); + if(perm_is_allowed($uid,$item['owner_xchan'],'post_wall') || perm_is_allowed($uid,$item['owner_xchan'],'tag_deliver')) { + logger('group DM delivery for ' . $u[0]['channel_address']); + start_delivery_chain($u[0], $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted'])); + } return; } @@ -2686,7 +2688,7 @@ function tag_deliver($uid, $item_id) { } // group delivery via W2W logger('rewriting W2W post for ' . $u[0]['channel_address']); - start_delivery_chain($u[0], $item, $item_id, 0, false); + start_delivery_chain($u[0], $item, $item_id, 0, true, (($item['edited'] != $item['created']) || $item['item_deleted'])); q("update item set item_wall = 0 where id = %d", intval($item_id) ); @@ -3136,7 +3138,7 @@ function tgroup_check($uid, $item) { * @param boolean $edit (optional) default false * @return void */ -function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) { +function start_delivery_chain($channel, $item, $item_id, $parent, $group = false, $edit = false) { $sourced = check_item_source($channel['channel_id'],$item); @@ -3183,28 +3185,56 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) } } - // @todo handle edit and parent correctly - - if(! $parent) { - - if ($edit) { - return; - } + if ($group && (! $parent)) { $arr = []; + + if ($edit) { + // process edit or delete action + $r = q("select * from item where source_xchan = '%s' and body like '%s' and uid = %d limit 1", + dbesc($item['owner_xchan']), + dbesc("%message_id='" . $item['mid'] . "'%"), + intval($channel['channel_id']) + ); + if ($r) { + if (intval($item['item_deleted'])) { + drop_item($r[0]['id'],false,DROPITEM_PHASE1); + Master::Summon([ 'Notifier','drop',$r[0]['id'] ]); + return; + } + $arr['id'] = intval($r[0]['id']); + $arr['parent'] = intval($r[0]['parent']); + $arr['uuid'] = $r[0]['uuid']; + $arr['mid'] = $r[0]['mid']; + $arr['parent_mid'] = $r[0]['parent_mid']; + $arr['edited'] = datetime_convert(); + } + else { + logger('unable to locate original group post ' . $item['mid']); + return; + } + } + else { + $arr['uuid'] = item_message_id(); + $arr['mid'] = z_root() . '/activity/' . $arr['uuid']; + $arr['parent_mid'] = $arr['mid']; + } + $arr['aid'] = $channel['channel_account_id']; $arr['uid'] = $channel['channel_id']; + // WARNING: the presence of both source_xchan and non-zero item_uplink here will cause a delivery loop + + $arr['item_uplink'] = 0; + $arr['source_xchan'] = $item['owner_xchan']; + $arr['item_private'] = (($channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 1 : 0); $arr['item_origin'] = 1; $arr['item_wall'] = 1; - $arr['uuid'] = item_message_id(); - $arr['mid'] = z_root() . '/activity/' . $arr['uuid']; - $arr['parent_mid'] = $arr['mid']; $arr['item_thread_top'] = 1; if (strpos($item['body'], "[/share]") !== false) { @@ -3226,12 +3256,11 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) $bb .= "[/share]"; } - $mention = '@[zrl=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/zrl]'; $arr['body'] = $bb; $arr['author_xchan'] = $channel['channel_hash']; $arr['owner_xchan'] = $channel['channel_hash']; - // $arr['obj'] = $item['obj']; + $arr['obj_type'] = $item['obj_type']; $arr['verb'] = ACTIVITY_POST; @@ -3241,7 +3270,12 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) $arr['deny_gid'] = $channel['channel_deny_gid']; $arr['comment_policy'] = map_scope(PermissionLimits::Get($channel['channel_id'],'post_comments')); - $post = item_store($arr); + if ($arr['id']) { + $post = item_store_update($arr); + } + else { + $post = item_store($arr); + } $post_id = $post['item_id']; @@ -3341,7 +3375,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) function check_item_source($uid, $item) { logger('source: uid: ' . $uid, LOGGER_DEBUG); - $xchan = (($item['source_xchan']) ? $item['source_xchan'] : $item['owner_xchan']); + $xchan = (($item['source_xchan'] && intval($item['item_uplink'])) ? $item['source_xchan'] : $item['owner_xchan']); $r = q("select * from source where src_channel_id = %d and ( src_xchan = '%s' or src_xchan = '*' ) limit 1", intval($uid), -- cgit v1.2.3 From 774cc852d4bc46a533c5ec2fb533463871721fe0 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Jul 2020 09:18:11 +0000 Subject: fix php warning --- 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 6873cc1c3..92e5807b4 100644 --- a/include/text.php +++ b/include/text.php @@ -3751,7 +3751,7 @@ function array_path_exists($str,$arr) { if($search) { foreach($search as $s) { - if(is_array($ptr) && array_key_exists($s,$ptr)) { + if ($ptr && is_array($ptr) && array_key_exists($s,$ptr)) { $ptr = $ptr[$s]; } else { -- cgit v1.2.3 From 01abb82c37e3fe5b0505154a8bf5f3bc4c712f53 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 14 Jul 2020 09:36:10 +0000 Subject: prefer zot6 sys channel --- include/channel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 210b6ae91..05f1bd34b 100644 --- a/include/channel.php +++ b/include/channel.php @@ -129,10 +129,10 @@ function create_sys_channel() { * @return array|boolean */ function get_sys_channel() { - $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_system = 1 limit 1"); + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_system = 1"); if ($r) - return $r[0]; + return Libzot::zot_record_preferred($r, 'xchan_network'); return false; } -- cgit v1.2.3 From 634a515ec15baff240a2e41603d576c1c5dc88c7 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 14 Jul 2020 12:43:34 +0000 Subject: reduce result sets and work around a regression in justifiedGallery --- include/help.php | 2 +- include/items.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/help.php b/include/help.php index e82fa96da..affe64495 100644 --- a/include/help.php +++ b/include/help.php @@ -223,7 +223,7 @@ function find_doc_file($s) { */ function search_doc_files($s) { - \App::set_pager_itemspage(60); + \App::set_pager_itemspage(30); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start'])); $regexop = db_getfunc('REGEXP'); diff --git a/include/items.php b/include/items.php index 7df5e35fe..dc76af31b 100755 --- a/include/items.php +++ b/include/items.php @@ -4536,8 +4536,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C // only setup pagination on initial page view $pager_sql = ''; } else { - $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 20); - App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20)); + $itemspage = (($channel) ? get_pconfig($uid,'system','itemspage') : 10); + App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10)); $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start'])); } -- cgit v1.2.3 From 4db38ec64a44de425d6966cb2b50d487d70b5366 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 21 Jul 2020 23:59:26 +0200 Subject: Add minimum form displaying time before login --- include/security.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index 38cb72263..c9df00f1e 100644 --- a/include/security.php +++ b/include/security.php @@ -594,9 +594,11 @@ function check_form_security_token($typename = '', $formname = 'form_security_to $hash = $_REQUEST[$formname]; $max_livetime = 10800; // 3 hours + $min_livetime = 3; // 3 sec $x = explode('.', $hash); - if (time() > (IntVal($x[0]) + $max_livetime)) return false; + if (time() > (IntVal($x[0]) + $max_livetime) || time() < (IntVal($x[0]) + $min_livetime)) + return false; $sec_hash = hash('whirlpool', App::$observer['xchan_guid'] . ((local_channel()) ? App::$channel['channel_prvkey'] : '') . session_id() . $x[0] . $typename); -- cgit v1.2.3 From 13ff9a897da05fbd4d82f9bfa758e6f821b833b3 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Jul 2020 16:20:36 -0700 Subject: foreach warning --- 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 aada36fba..d9d534cd7 100644 --- a/include/network.php +++ b/include/network.php @@ -1101,7 +1101,7 @@ function discover_by_webbie($webbie, $protocol = '') { $network = null; $x = webfinger_rfc7033($webbie, true); - if($x && array_key_exists('links',$x) && $x['links']) { + if($x && array_key_exists('links',$x) && is_array($x['links'])) { foreach($x['links'] as $link) { if(array_key_exists('rel',$link)) { -- cgit v1.2.3 From 7ae86d29d2474c5e85965c06a4c6a6b7e416b333 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 22 Jul 2020 16:23:38 -0700 Subject: add api_verify to api_zot --- include/api_zot.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/api_zot.php b/include/api_zot.php index 287720484..8f621d998 100644 --- a/include/api_zot.php +++ b/include/api_zot.php @@ -1,7 +1,9 @@ Date: Fri, 24 Jul 2020 20:44:55 +0000 Subject: construct hubloc_id_url for imported legacy zot hublocs --- include/zot.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index fb0804aa7..e10ef6fd7 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2763,6 +2763,8 @@ function sync_locations($sender, $arr, $absolute = false) { } logger('New hub: ' . $location['url']); + $addr_arr = explode('@', $location['address']); + $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $sender['guid'], @@ -2777,7 +2779,8 @@ function sync_locations($sender, $arr, $absolute = false) { 'hubloc_callback' => $location['callback'], 'hubloc_sitekey' => $location['sitekey'], 'hubloc_updated' => datetime_convert(), - 'hubloc_connected' => datetime_convert() + 'hubloc_connected' => datetime_convert(), + 'hubloc_id_url' => $location['url'] . '/channel/' . $addr_arr[0] ] ); -- cgit v1.2.3 From 845f7e9382797e6abb89ea1a59d67cb4bea1634f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 30 Jul 2020 09:59:25 +0000 Subject: add new lock icon as svg --- 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 e846e38db..cfc5a76bf 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -257,7 +257,7 @@ function bb_parse_crypt($match) { $x = random_string(); - $Text = '
' . t('Encrypted content') . '

'; + $Text = '
' . t('Encrypted content') . '

'; return $Text; } @@ -1498,7 +1498,7 @@ function bbcode($Text, $options = []) { // crypt if (strpos($Text,'[/crypt]') !== false) { $x = random_string(); - $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); + $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); $Text = preg_replace_callback("/\[crypt (.*?)\](.*?)\[\/crypt\]/ism", 'bb_parse_crypt', $Text); } -- cgit v1.2.3 From be15a395d868c68855cb2a38fbcfcbdaaeaaeb0e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 30 Jul 2020 12:32:00 +0000 Subject: use cursor-pointer for the lock --- 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 cfc5a76bf..b195701dc 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -257,7 +257,7 @@ function bb_parse_crypt($match) { $x = random_string(); - $Text = '
' . t('Encrypted content') . '

'; + $Text = '
' . t('Encrypted content') . '

'; return $Text; } @@ -1498,7 +1498,7 @@ function bbcode($Text, $options = []) { // crypt if (strpos($Text,'[/crypt]') !== false) { $x = random_string(); - $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); + $Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
' . t('Encrypted content') . '
', $Text); $Text = preg_replace_callback("/\[crypt (.*?)\](.*?)\[\/crypt\]/ism", 'bb_parse_crypt', $Text); } -- cgit v1.2.3 From 2d2cab0aba7026c4b68c9a21ac33b415620e613d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 31 Jul 2020 08:41:18 +0000 Subject: event display zot/zot6 compatibility --- include/event.php | 102 +++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 82f6ca81e..679440726 100644 --- a/include/event.php +++ b/include/event.php @@ -74,67 +74,67 @@ function format_event_obj($jobject) { $object = json_decode($jobject,true); - //ensure compatibility with older items - this check can be removed at a later point - if(array_key_exists('description', $object)) { - - $event_tz = ''; - if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { - foreach($object['asld']['attachment'] as $attachment) { - if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { - // check if the offset of the timezones is different and only set event_tz if offset is not the same - $local_tz = new DateTimeZone(date_default_timezone_get()); - $local_dt = new DateTime('now', $local_tz); - - $ev_tz = new DateTimeZone($attachment['value']); - $ev_dt = new DateTime('now', $ev_tz); - - if($local_dt->getOffset() !== $ev_dt->getOffset()) - $event_tz = $attachment['value']; - - break; - } + $event_tz = ''; + if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { + foreach($object['asld']['attachment'] as $attachment) { + if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { + // check if the offset of the timezones is different and only set event_tz if offset is not the same + $local_tz = new DateTimeZone(date_default_timezone_get()); + $local_dt = new DateTime('now', $local_tz); + + $ev_tz = new DateTimeZone($attachment['value']); + $ev_dt = new DateTime('now', $ev_tz); + if($local_dt->getOffset() !== $ev_dt->getOffset()) + $event_tz = $attachment['value']; + break; } } - $allday = (($object['adjust']) ? false : true); - - $dtstart = new DateTime($object['dtstart']); - $dtend = new DateTime($object['dtend']); - $dtdiff = $dtstart->diff($dtend); + } - if($allday && ($dtdiff->days < 2)) - $oneday = true; + $allday = (($object['adjust']) ? false : true); - if($allday && !$oneday) { - // Subtract one day from the end date so we can use the "first day - last day" format for display. - $dtend->modify('-1 day'); - $object['dtend'] = datetime_convert('UTC', 'UTC', $dtend->format('Y-m-d H:i:s')); - } + $dtstart = new DateTime($object['dtstart']); + $dtend = new DateTime($object['dtend']); + $dtdiff = $dtstart->diff($dtend); - $bd_format = (($allday) ? t('l F d, Y') : t('l F d, Y \@ g:i A')); // Friday January 18, 2011 @ 8:01 AM or Friday January 18, 2011 for allday events - - $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( - '$title' => zidify_links(smilies(bbcode($object['title']))), - '$dtstart_label' => t('Start:'), - '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), - '$finish' => (($object['nofinish']) ? false : true), - '$dtend_label' => t('End:'), - '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), - '$allday' => $allday, - '$oneday' => $oneday, - '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)] - )); + if($allday && ($dtdiff->days < 2)) + $oneday = true; - $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( - '$description' => zidify_links(smilies(bbcode($object['description']))), - '$location_label' => t('Location:'), - '$location' => zidify_links(smilies(bbcode($object['location']))) - )); + if($allday && !$oneday) { + // Subtract one day from the end date so we can use the "first day - last day" format for display. + $dtend->modify('-1 day'); + $object['dtend'] = datetime_convert('UTC', 'UTC', $dtend->format('Y-m-d H:i:s')); + } + $bd_format = (($allday) ? t('l F d, Y') : t('l F d, Y \@ g:i A')); // Friday January 18, 2011 @ 8:01 AM or Friday January 18, 2011 for allday events + + $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( + '$title' => zidify_links(smilies(bbcode($object['title']))), + '$dtstart_label' => t('Start:'), + '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$finish' => (($object['nofinish']) ? false : true), + '$dtend_label' => t('End:'), + '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$allday' => $allday, + '$oneday' => $oneday, + '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)] + )); + + $event_src = []; + + if(array_path_exists('asld/source', $object) && $object['asld']['source']['mediaType'] === 'text/bbcode') { + $event_src = bbtoevent($object['asld']['source']['content']); } + $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( + '$description' => zidify_links(smilies(bbcode($event_src ? $event_src['description'] : $object['description']))), + '$location_label' => t('Location:'), + '$location' => zidify_links(smilies(bbcode($event_src ? $event_src['location'] : $object['location']))), + )); + return $event; } -- cgit v1.2.3 From 5ecbbfc7dfe1d1f3d36a02ac36b659538d6c5937 Mon Sep 17 00:00:00 2001 From: Zot Date: Wed, 5 Aug 2020 19:13:44 +0200 Subject: update profile|cover photo activities converted to z6 --- include/items.php | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index dc76af31b..0cfa2a340 100755 --- a/include/items.php +++ b/include/items.php @@ -4830,14 +4830,6 @@ function send_profile_photo_activity($channel,$photo,$profile) { $arr['item_thread_top'] = 1; $arr['item_origin'] = 1; $arr['item_wall'] = 1; - $arr['obj_type'] = ACTIVITY_OBJ_PHOTO; - $arr['verb'] = ACTIVITY_UPDATE; - - $arr['obj'] = json_encode(array( - 'type' => $arr['obj_type'], - 'id' => z_root() . '/photo/profile/l/' . $channel['channel_id'], - 'link' => array('rel' => 'photo', 'type' => $photo['type'], 'href' => z_root() . '/photo/profile/l/' . $channel['channel_id']) - )); if(stripos($profile['gender'],t('female')) !== false) $t = t('%1$s updated her %2$s'); -- cgit v1.2.3 From c4c47f777724937746c99c064e65f52723443e59 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 20 Aug 2020 22:47:33 +0200 Subject: first cut on implementing additional encryption with the SJCL library. aes only and no backward compatibility. --- include/bbcode.php | 4 +++- include/conversation.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index b195701dc..ea04eb470 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -257,7 +257,9 @@ function bb_parse_crypt($match) { $x = random_string(); - $Text = '
' . t('Encrypted content') . '

'; + $f = ((in_array($algorithm, ['AES-256', 'rot13', 'triple-rot13'])) ? 'hz_decrypt' : 'red_decrypt'); + + $Text = '
' . t('Encrypted content') . '

'; return $Text; } diff --git a/include/conversation.php b/include/conversation.php index b0e81b7e2..05d1cdc26 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1396,7 +1396,7 @@ function hz_status_editor($a, $x, $popup = false) { $cipher = get_pconfig($x['profile_uid'], 'system', 'default_cipher'); if(! $cipher) - $cipher = 'aes256'; + $cipher = 'AES-256'; if(array_key_exists('catsenabled',$x)) $catsenabled = $x['catsenabled']; -- cgit v1.2.3 From 49df57df45f82e2e0f1b10f2508f61b78d6d3ac0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 21 Aug 2020 10:55:55 +0200 Subject: use the default setting and also add the mode to the cipher. aes-128 is to be preferred over aes-256 according to bruce schneier https://www.schneier.com/blog/archives/2009/07/another_new_aes.html#c386957 --- include/bbcode.php | 2 +- include/conversation.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index ea04eb470..535e4ac33 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -257,7 +257,7 @@ function bb_parse_crypt($match) { $x = random_string(); - $f = ((in_array($algorithm, ['AES-256', 'rot13', 'triple-rot13'])) ? 'hz_decrypt' : 'red_decrypt'); + $f = ((in_array($algorithm, ['AES-128-CCM', 'rot13', 'triple-rot13'])) ? 'hz_decrypt' : 'red_decrypt'); $Text = '
' . t('Encrypted content') . '

'; diff --git a/include/conversation.php b/include/conversation.php index 05d1cdc26..876e907e5 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1396,7 +1396,7 @@ function hz_status_editor($a, $x, $popup = false) { $cipher = get_pconfig($x['profile_uid'], 'system', 'default_cipher'); if(! $cipher) - $cipher = 'AES-256'; + $cipher = 'AES-128-CCM'; if(array_key_exists('catsenabled',$x)) $catsenabled = $x['catsenabled']; -- cgit v1.2.3 From 4e0fc81e5dfaad3c3ed47a02df4589f5b25a88be Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 22 Aug 2020 22:14:29 +0200 Subject: move cryptojs to addon --- include/bbcode.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 535e4ac33..e5b2a068a 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -233,7 +233,7 @@ function bb_replace_images($body, $images) { */ function bb_parse_crypt($match) { - $matches = array(); + $matches = []; $attributes = $match[1]; $algorithm = ""; @@ -257,9 +257,17 @@ function bb_parse_crypt($match) { $x = random_string(); - $f = ((in_array($algorithm, ['AES-128-CCM', 'rot13', 'triple-rot13'])) ? 'hz_decrypt' : 'red_decrypt'); + $f = 'hz_decrypt'; + + //legacy cryptojs support + if(plugin_is_installed('cryptojs')) { + $f = ((in_array($algorithm, ['AES-128-CCM', 'rot13', 'triple-rot13'])) ? 'hz_decrypt' : 'red_decrypt'); + } + + $onclick = 'onclick="' . $f . '(\'' . $algorithm . '\',\'' . $hint . '\',\'' . $match[2] . '\',\'#' . $x . '\');"'; + $label = t('Encrypted content'); - $Text = '
' . t('Encrypted content') . '

'; + $Text = '
' . $label . '

'; return $Text; } -- cgit v1.2.3 From 170b2e4465951edff5019545045714aa660cad51 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 22 Aug 2020 22:44:00 +0200 Subject: only show poke link if poke app is installed --- include/conversation.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 876e907e5..b43a6f47e 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1,5 +1,7 @@ Date: Mon, 24 Aug 2020 09:45:26 +0200 Subject: prefer zot6 and also check for hubloc_deleted --- include/auth.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index b952754fd..8eeb077b5 100644 --- a/include/auth.php +++ b/include/auth.php @@ -9,6 +9,8 @@ * Also provides a function for OpenID identiy matching. */ +use Zotlabs\Lib\Libzot; + require_once('include/api_auth.php'); require_once('include/security.php'); @@ -224,12 +226,13 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && $r = array(atoken_xchan($y[0])); } else { - $r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where xchan_hash = '%s' limit 1", + $r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where xchan_hash = '%s' and hubloc_deleted = 0", dbesc($_SESSION['visitor_id']) ); } if($r) { - App::set_observer($r[0]); + $r = Libzot::zot_record_preferred($r); + App::set_observer($r); } else { unset($_SESSION['visitor_id']); -- cgit v1.2.3 From e9a264cb43e4c782160db645329d59db9835e388 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 24 Aug 2020 11:18:47 +0200 Subject: more prefer zot6 --- include/security.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index c9df00f1e..eb18f3b21 100644 --- a/include/security.php +++ b/include/security.php @@ -5,6 +5,8 @@ * @brief Some security related functions. */ +use Zotlabs\Lib\Libzot; + /** * @param int $user_record The account_id * @param array $channel @@ -277,14 +279,16 @@ function change_channel($change_channel) { } $ret = $r[0]; } - $x = q("select * from xchan where xchan_hash = '%s' limit 1", + $x = q("select * from xchan where xchan_hash = '%s'", dbesc($hash) ); if($x) { - $_SESSION['my_url'] = $x[0]['xchan_url']; + $x = Libzot::zot_record_preferred($x, 'xchan_network'); + + $_SESSION['my_url'] = $x['xchan_url']; $_SESSION['my_address'] = channel_reddress($r[0]); - App::set_observer($x[0]); + App::set_observer($x); App::set_perms(get_all_perms(local_channel(), $hash)); } if(! is_dir('store/' . $r[0]['channel_address'])) -- cgit v1.2.3 From aafdeb9000454e723a0b6a3940306f500245c4d0 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 24 Aug 2020 11:26:52 +0200 Subject: Revert "more prefer zot6" This reverts commit e9a264cb43e4c782160db645329d59db9835e388 --- include/security.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index eb18f3b21..c9df00f1e 100644 --- a/include/security.php +++ b/include/security.php @@ -5,8 +5,6 @@ * @brief Some security related functions. */ -use Zotlabs\Lib\Libzot; - /** * @param int $user_record The account_id * @param array $channel @@ -279,16 +277,14 @@ function change_channel($change_channel) { } $ret = $r[0]; } - $x = q("select * from xchan where xchan_hash = '%s'", + $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($hash) ); if($x) { - $x = Libzot::zot_record_preferred($x, 'xchan_network'); - - $_SESSION['my_url'] = $x['xchan_url']; + $_SESSION['my_url'] = $x[0]['xchan_url']; $_SESSION['my_address'] = channel_reddress($r[0]); - App::set_observer($x); + App::set_observer($x[0]); App::set_perms(get_all_perms(local_channel(), $hash)); } if(! is_dir('store/' . $r[0]['channel_address'])) -- cgit v1.2.3 From d53b3b242daca5d64886c5caa1c6aa93473239de Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 4 Sep 2020 18:56:21 +0000 Subject: fix get_plink() for zot6 --- 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 92e5807b4..e798bf8f8 100644 --- a/include/text.php +++ b/include/text.php @@ -2046,7 +2046,7 @@ function get_plink($item,$conversation_mode = true) { $zidify = true; - if(array_key_exists('author',$item) && $item['author']['xchan_network'] !== 'zot') + if(array_key_exists('author',$item) && in_array($item['author']['xchan_network'], ['zot6', 'zot']) === false) $zidify = false; if(x($item,$key)) { -- cgit v1.2.3 From ff09b2131e6ba7045d5afd65adfd49e427617afc Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Sep 2020 12:11:09 +0000 Subject: disable community tags until we agree on how to implemnt this in zot6/activitypub --- include/features.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/features.php b/include/features.php index 0dd245e7f..bb3c126ab 100644 --- a/include/features.php +++ b/include/features.php @@ -144,7 +144,7 @@ function get_features($filtered = true, $level = (-1)) { 'conversation' => [ t('Conversation'), - +/* disable until we agree on how to implemnt this in zot6/activitypub [ 'commtag', t('Community Tagging'), @@ -152,7 +152,7 @@ function get_features($filtered = true, $level = (-1)) { false, get_config('feature_lock','commtag'), ], - +*/ [ 'emojis', t('Emoji Reactions'), -- cgit v1.2.3 From 7fa70108c4c5a0315811fb8cebb53f87ae7ac101 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 11 Sep 2020 12:19:24 +0000 Subject: whitespace --- include/features.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/features.php b/include/features.php index bb3c126ab..e1457604b 100644 --- a/include/features.php +++ b/include/features.php @@ -144,7 +144,7 @@ function get_features($filtered = true, $level = (-1)) { 'conversation' => [ t('Conversation'), -/* disable until we agree on how to implemnt this in zot6/activitypub + /* disable until we agree on how to implemnt this in zot6/activitypub [ 'commtag', t('Community Tagging'), @@ -152,7 +152,7 @@ function get_features($filtered = true, $level = (-1)) { false, get_config('feature_lock','commtag'), ], -*/ + */ [ 'emojis', t('Emoji Reactions'), -- cgit v1.2.3 From 25b9776bf662c14f0296f776616266a214650136 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 13 Sep 2020 11:56:02 +0200 Subject: Support remote host cache directives on profile photo fetching --- include/photo/photo_driver.php | 126 +++++++++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php index 284206161..52f761b65 100644 --- a/include/photo/photo_driver.php +++ b/include/photo/photo_driver.php @@ -190,25 +190,27 @@ function delete_thing_photo($url, $ob_hash) { * * \e string \b 5 => modification date */ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { + $modified = ''; $o = null; - $flags = (($thing) ? PHOTO_THING : PHOTO_XCHAN); $album = (($thing) ? 'Things' : 'Contact Photos'); logger('Updating channel photo from ' . $photo . ' for ' . $xchan, LOGGER_DEBUG); - if($thing) { + if($thing) $hash = photo_new_resource(); - } else { - $r = q("select resource_id, edited, mimetype from photo where xchan = '%s' and photo_usage = %d and imgscale = 4 limit 1", dbesc($xchan), intval(PHOTO_XCHAN)); + else { + $r = q("SELECT resource_id, edited, mimetype, expires, description FROM photo WHERE xchan = '%s' AND photo_usage = %d AND imgscale = 4 LIMIT 1", dbesc($xchan), intval(PHOTO_XCHAN)); if($r) { $hash = $r[0]['resource_id']; $modified = $r[0]['edited']; $type = $r[0]['mimetype']; - } else { - $hash = photo_new_resource(); + $exp = strtotime($r[0]['expires']); + $etag = $r[0]['description']; } + else + $hash = photo_new_resource(); } $photo_failure = false; @@ -216,37 +218,74 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { if($photo) { - if($force || $modified == '') { + if($force || empty($modified)) $result = z_fetch_url($photo, true); - } else { - $h = [ - 'headers' => [ - 'If-Modified-Since: ' . gmdate('D, d M Y H:i:s', strtotime($modified . 'Z')) . ' GMT' - ] - ]; - $result = z_fetch_url($photo, true, 0, $h); + elseif($exp - 60 < time()) { + $h = []; + $h[] = "If-Modified-Since: " . gmdate("D, d M Y H:i:s", $exp) . " GMT"; + if(! empty($etag)) + $h[] = "If-None-Match: " . $etag; + $result = z_fetch_url($photo, true, 0, [ 'headers' => $h ]); } - if($result['success']) { - $img_str = $result['body']; - $type = guess_image_type($photo, $result['header']); - $modified = gmdate('Y-m-d H:i:s', (preg_match('/last-modified: (.+) \S+/i', $result['header'], $o) ? strtotime($o[1] . 'Z') : time())); - if(is_null($type)) + if(isset($result)) { + $hdrs = []; + $h = explode("\n", $result['header']); + foreach ($h as $l) { + list($t,$v) = array_map("trim", explode(":", trim($l), 2)); + $hdrs[strtolower($t)] = $v; + } + + if(array_key_exists('expires', $hdrs)) + $expires = strtotime($hdrs['expires']); + if($expires - 60 < time()) + $expires = time() + 60; + else { + $cc = ''; + if(array_key_exists('cache-control', $hdrs)) + $cc = $hdrs['cache-control']; + if(strpos($cc, 'no-cache')) + $expires = time() + 60; + else { + $ttl = (preg_match('/max-age=(\d+)/i', $cc, $o) ? intval($o[1]) : 86400); + $expires = time() + $ttl; + } + } + + $modified = gmdate('Y-m-d H:i:s', (array_key_exists('last-modified', $hdrs) ? strtotime($hdrs['last-modified']) : time())); + + if($result['success']) { + $img_str = $result['body']; + $type = guess_image_type($photo, $result['header']); + if(is_null($type)) + $photo_failure = true; + } + else $photo_failure = true; - } elseif($result['return_code'] == 304) { + } + + if(! isset($result) || $result['return_code'] == 304) { $photo = z_root() . '/photo/' . $hash . '-4'; $thumb = z_root() . '/photo/' . $hash . '-5'; $micro = z_root() . '/photo/' . $hash . '-6'; - } else { + if(isset($result)) + q("UPDATE photo SET expires = '%s' WHERE xchan = '%s' and photo_usage = %d and imgscale IN (4, 5, 6)", + dbescdate(gmdate('Y-m-d H:i:s', (isset($expires) ? $expires : time() + 86400))), + dbesc($xchan), + intval(PHOTO_XCHAN) + ); + $photo_notmodified = true; $photo_failure = true; } - } else { - $photo_failure = true; } + else + $photo_failure = true; + + if(! $photo_failure) { - if(!$photo_failure && $result['return_code'] != 304) { $img = photo_factory($img_str, $type); if($img->is_valid()) { + $width = $img->getWidth(); $height = $img->getHeight(); @@ -255,25 +294,28 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { // crop out the sides $margin = $width - $height; $img->cropImage(300, ($margin / 2), 0, $height, $height); - } elseif(($height / $width) > 1.2) { + } + elseif(($height / $width) > 1.2) { // crop out the bottom $margin = $height - $width; $img->cropImage(300, 0, 0, $width, $width); - } else { - $img->scaleImageSquare(300); } - } else { - $photo_failure = true; + else + $img->scaleImageSquare(300); } + else + $photo_failure = true; $p = [ - 'xchan' => $xchan, - 'resource_id' => $hash, - 'filename' => basename($photo), - 'album' => $album, - 'photo_usage' => $flags, - 'imgscale' => 4, - 'edited' => $modified, + 'xchan' => $xchan, + 'resource_id' => $hash, + 'filename' => basename($photo), + 'album' => $album, + 'photo_usage' => $flags, + 'imgscale' => 4, + 'edited' => $modified, + 'description' => (array_key_exists('etag', $hdrs) ? $hdrs['etag'] : ''), + 'expires' => gmdate('Y-m-d H:i:s', (isset($expires) ? $expires : time() + 86400)) ]; $r = $img->save($p); @@ -295,12 +337,14 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { $photo = z_root() . '/photo/' . $hash . '-4'; $thumb = z_root() . '/photo/' . $hash . '-5'; $micro = z_root() . '/photo/' . $hash . '-6'; - } else { + } + else { logger('Invalid image from ' . $photo); $photo_failure = true; } } - if($photo_failure) { + + if($photo_failure && ! isset($photo_notmodified)) { $default = get_default_profile_photo(); $photo = z_root() . '/' . $default; $thumb = z_root() . '/' . get_default_profile_photo(80); @@ -309,12 +353,12 @@ function import_xchan_photo($photo, $xchan, $thing = false, $force = false) { $modified = gmdate('Y-m-d H:i:s', filemtime($default)); } - logger('HTTP code: ' . $result['return_code'] . '; modified: ' . $modified - . '; failure: ' . ($photo_failure ? 'yes' : 'no') . '; URL: ' . $photo, LOGGER_DEBUG); + logger('xchan: ' . $xchan . '; HTTP code: ' . (isset($result) && array_key_exists('return_code', $result) ? $result['return_code'] : 'none') . '; modified: ' . $modified . '; URL: ' . $photo, LOGGER_DEBUG); - return([$photo, $thumb, $micro, $type, $photo_failure, $modified]); + return([ $photo, $thumb, $micro, $type, $photo_failure, $modified ]); } + /** * @brief Import channel photo from a URL. * -- cgit v1.2.3 From 1a41c44c2f54d7ee4f1ee2597c6e3ff3de3450f7 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 21 Sep 2020 09:14:39 +0000 Subject: 5.0RC testing: provide hubloc_id_url for new created zot hublocs --- include/channel.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 05f1bd34b..45000cdff 100644 --- a/include/channel.php +++ b/include/channel.php @@ -341,6 +341,7 @@ function create_identity($arr) { 'hubloc_guid' => $guid, 'hubloc_guid_sig' => $zsig, 'hubloc_hash' => $zhash, + 'hubloc_id_url' => channel_url($ret['channel']), 'hubloc_addr' => channel_reddress($ret['channel']), 'hubloc_primary' => intval($primary), 'hubloc_url' => z_root(), @@ -360,7 +361,7 @@ function create_identity($arr) { 'hubloc_guid' => $guid, 'hubloc_guid_sig' => $sig, 'hubloc_hash' => $hash, - 'hubloc_id_url' => channel_url($ret['channel']), + 'hubloc_id_url' => channel_url($ret['channel']), 'hubloc_addr' => channel_reddress($ret['channel']), 'hubloc_primary' => intval($primary), 'hubloc_url' => z_root(), -- cgit v1.2.3 From be627c3f3aa7b4ab4834aff30fba79ee67b4fa50 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 22 Sep 2020 08:23:28 +0000 Subject: changelog and use dbq() where apropriate in z6trans_connections() --- include/connections.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/connections.php b/include/connections.php index c7ec163c8..96077cd69 100644 --- a/include/connections.php +++ b/include/connections.php @@ -775,7 +775,7 @@ function vcard_query(&$r) { function z6trans_connections() { - $r = q("SELECT DISTINCT abook.abook_xchan, hubloc.hubloc_addr, hubloc.hubloc_url, hubloc.hubloc_guid, site.site_project, site.site_version FROM abook + $r = dbq("SELECT DISTINCT abook.abook_xchan, hubloc.hubloc_addr, hubloc.hubloc_url, hubloc.hubloc_guid, site.site_project, site.site_version FROM abook LEFT JOIN hubloc ON abook_xchan = hubloc_hash LEFT JOIN site ON hubloc_url = site_url WHERE abook.abook_self = 0 AND hubloc.hubloc_network = 'zot' @@ -806,7 +806,7 @@ function z6trans_connections() { logger("z6trans_connections: transition $zot_xchan to $zot6_xchan"); - q("START TRANSACTION"); + dbq("START TRANSACTION"); $q1 = q("UPDATE abook set abook_xchan = '%s' WHERE abook_xchan = '%s'", dbesc($zot6_xchan), @@ -824,13 +824,13 @@ function z6trans_connections() { ); if($q1 && $q2 && $q3) { - q("COMMIT"); + dbq("COMMIT"); logger("z6trans_connections: completed"); continue; } logger("z6trans_connections: failed - performing rollback"); - q("ROLLBACK"); + dbq("ROLLBACK"); } } -- cgit v1.2.3 From 60fd27eca426aa5001f25f52fc89634ef9c00b9d Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Sep 2020 09:18:02 +0000 Subject: 5.0RC testing: on channel removal mark both zot6 and zot xchans and hublocs deleted --- include/channel.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 45000cdff..9424c8550 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2812,12 +2812,15 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { logger('deleting hublocs',LOGGER_DEBUG); - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", - dbesc($channel['channel_hash']) + $r = q("UPDATE hubloc SET hubloc_deleted = 1 WHERE hubloc_hash = '%s' OR hubloc_hash = '%s'", + dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']) + ); - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", - dbesc($channel['channel_hash']) + $r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s' OR xchan_hash = '%s'", + dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']) ); Master::Summon(array('Notifier','purge_all',$channel_id)); @@ -2901,8 +2904,9 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { logger('deleting hublocs',LOGGER_DEBUG); - $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", + $r = q("UPDATE hubloc SET hubloc_deleted = 1 WHERE (hubloc_hash = '%s' OR hubloc_hash = '%s') AND hubloc_url = '%s' ", dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']), dbesc(z_root()) ); @@ -2917,8 +2921,9 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { $hublocs = count($r); if(! $hublocs) { - $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ", - dbesc($channel['channel_hash']) + $r = q("UPDATE xchan SET xchan_deleted = 1 WHERE xchan_hash = '%s' OR xchan_hash = '%s'", + dbesc($channel['channel_hash']), + dbesc($channel['channel_portable_id']) ); } -- cgit v1.2.3 From 5edec37d571b79dc4fcc30aac1c48b2fc1ae66c9 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 23 Sep 2020 12:14:16 +0000 Subject: 5.0RC testing: comment out global remove --- include/channel.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 9424c8550..a51404652 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2715,6 +2715,9 @@ function account_remove($account_id, $local = true, $unset_session = true) { logger('account_remove: ' . $account_id); + // Global removal (all clones) not currently supported + $local = true; + if(! intval($account_id)) { logger('No account.'); return false; @@ -2775,6 +2778,11 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { if(! $channel_id) return; + // global removal (all clones) not currently supported + // hence this operation _may_ leave orphan data on remote servers + + $local = true; + logger('Removing channel: ' . $channel_id); logger('local only: ' . intval($local)); @@ -2793,6 +2801,7 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { */ call_hooks('channel_remove', $r[0]); +/* if(! $local) { if(intval($r[0]['channel_removed'])) { @@ -2825,7 +2834,7 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { Master::Summon(array('Notifier','purge_all',$channel_id)); } - +*/ $r = q("select iid from iconfig left join item on item.id = iconfig.iid where item.uid = %d", @@ -2929,7 +2938,6 @@ function channel_remove($channel_id, $local = true, $unset_session = false) { //remove from file system - $f = 'store/' . $channel['channel_address']; if(is_dir($f)) { @rrmdir($f); -- cgit v1.2.3 From 3f784a974a1ccc15f69865f8015b0c36fd7bc1d7 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 26 Sep 2020 15:05:16 +0200 Subject: deprecate \Zotlabs\Zot\Finger where apropriate --- include/dir_fns.php | 21 ++++++++++----------- include/socgraph.php | 2 +- include/zid.php | 42 ++++++++++++++++++------------------------ 3 files changed, 29 insertions(+), 36 deletions(-) (limited to 'include') diff --git a/include/dir_fns.php b/include/dir_fns.php index 34a6f13cd..f477b35dd 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -3,6 +3,10 @@ * @file include/dir_fns.php */ +use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Webfinger; +use Zotlabs\Lib\Zotfinger; + require_once('include/permissions.php'); /** @@ -67,15 +71,10 @@ function check_upstream_directory() { $isadir = true; if ($directory) { - $h = parse_url($directory); - if ($h) { - $j = Zotlabs\Zot\Finger::run('[system]@' . $h['host']); - if ($j['success']) { - if (array_key_exists('site', $j) && array_key_exists('directory_mode', $j['site'])) { - if ($j['site']['directory_mode'] === 'normal') { - $isadir = false; - } - } + $j = Zotfinger::exec($directory); + if (array_path_exists('data/directory_mode',$j)) { + if ($j['data']['directory_mode'] === 'normal') { + $isadir = false; } } } @@ -341,9 +340,9 @@ function update_directory_entry($ud) { // Hubzilla channels running traditional zot which have not upgraded can or will be dropped from the directory or // "not found" at the end of the transition period as the directory will only serve zot6 entries at that time. - $uri = \Zotlabs\Lib\Webfinger::zot_url($ud['ud_addr']); + $uri = Webfinger::zot_url($ud['ud_addr']); if($uri) { - $record = \Zotlabs\Lib\Zotfinger::exec($uri); + $record = Zotfinger::exec($uri); // Check the HTTP signature diff --git a/include/socgraph.php b/include/socgraph.php index 3d26f5cfd..3da4dce63 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -158,7 +158,7 @@ function poco_load($xchan = '', $url = null) { if($address) { if($network === 'zot6') { $j = Zotfinger::exec($profile_url); - if(is_array($j) && array_path_exists('signature/signer',$j) && $j['signature']['signer'] === $profile_url && intval($j['signature']['header_valid'])) { + if(array_path_exists('signature/signer',$j) && $j['signature']['signer'] === $profile_url && intval($j['signature']['header_valid'])) { Libzot::import_xchan($j['data']); } $x = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", diff --git a/include/zid.php b/include/zid.php index 10e09e212..538adcc41 100644 --- a/include/zid.php +++ b/include/zid.php @@ -2,7 +2,6 @@ use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Verify; -use Zotlabs\Zot\Finger; function is_matrix_url($url) { @@ -280,44 +279,39 @@ function owt_init($token) { Verify::purge('owt', '3 MINUTE'); - $key = Verify::get_meta('owt', 0, $token); + $ob_hash = Verify::get_meta('owt', 0, $token); - if($key === false) { - return; - } - - $parts = explode(',',$key,2); - if(count($parts) < 2) { + if($ob_hash === false) { return; } $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash - where hubloc_network = '%s' and hubloc_addr = '%s' order by hubloc_id desc", - dbesc($parts[0]), - dbesc($parts[1]) + where hubloc_addr = '%s' or hubloc_id_url = '%s' or hubloc_hash = '%s' order by hubloc_id desc", + dbesc($ob_hash), + dbesc($ob_hash), + dbesc($ob_hash) ); if(! $r) { - // finger them if they can't be found. - // @todo check that this is still needed. Discovery should have been performed in the Owa module. - - $j = \Zotlabs\Zot\Finger::run($parts[1], null); - if ($j['success']) { - import_xchan($j); + $wf = discover_by_webbie($ob_hash); + if($wf) { $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash - where hubloc_network = '%s' and hubloc_addr = '%s' order by hubloc_id desc", - dbesc($parts[0]), - dbesc($parts[1]) + where hubloc_addr = '%s' or hubloc_id_url = '%s' or hubloc_hash = '%s' order by hubloc_id desc", + dbesc($ob_hash), + dbesc($ob_hash), + dbesc($ob_hash) ); } } if(! $r) { - logger('owt: unable to finger ' . $key); + logger('owt: unable to finger ' . $ob_hash); return; } - - $hubloc = $r[0]; + + $r = Libzot::zot_record_preferred($r); + + $hubloc = $r; $_SESSION['authenticated'] = 1; @@ -343,7 +337,7 @@ function owt_init($token) { if (! $delegate_success) { // normal visitor (remote_channel) login session credentials $_SESSION['visitor_id'] = $hubloc['xchan_hash']; - $_SESSION['my_url'] = $hubloc['xchan_url']; + $_SESSION['my_url'] = $hubloc['xchan_url']; $_SESSION['my_address'] = $hubloc['hubloc_addr']; $_SESSION['remote_hub'] = $hubloc['hubloc_url']; $_SESSION['DNT'] = 1; -- cgit v1.2.3 From e529635952c9a10f56d3bc90a666eccd9c5b9842 Mon Sep 17 00:00:00 2001 From: nobody Date: Wed, 30 Sep 2020 17:05:36 -0700 Subject: delete fixes --- include/network.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/network.php b/include/network.php index d9d534cd7..750d56ac3 100644 --- a/include/network.php +++ b/include/network.php @@ -2061,3 +2061,23 @@ function get_request_string($url) { return '/' . ((count($a) > 3) ? $a[3] : EMPTY_STR); } + + +/* + * + * Takes the output of parse_url and builds a URL from it + * + */ + +function unparse_url($parsed_url) { + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $user = isset($parsed_url['user']) ? $parsed_url['user'] : ''; + $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : ''; + $pass = ($user || $pass) ? "$pass@" : ''; + $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; + $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : ''; + return "$scheme$user$pass$host$port$path$query$fragment"; +} -- cgit v1.2.3 From ad51be7dd9446b1338f2e140a479a497f56820f3 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 8 Oct 2020 18:18:44 +0000 Subject: reduce result set for query in zid_init() and use Libzot::zot_record_preferred() in mod rmagic --- include/channel.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index a51404652..ccec4f9ee 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1925,7 +1925,7 @@ function zid_init() { call_hooks('zid_init', $arr); if(! local_channel()) { - $r = q("select * from hubloc where hubloc_addr = '%s' order by hubloc_connected desc", + $r = q("select hubloc_url, hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s' order by hubloc_connected desc", dbesc($tmp_str) ); if(! $r) { @@ -1934,6 +1934,7 @@ function zid_init() { if($r) { $r = Libzot::zot_record_preferred($r); } + if($r && remote_channel() && remote_channel() === $r['hubloc_hash']) return; -- cgit v1.2.3 From 3acd5dcc07f74640734b8b5a837354859dd5a213 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 9 Oct 2020 07:38:11 +0000 Subject: remove source entries for removed contacts --- include/connections.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/connections.php b/include/connections.php index 96077cd69..658fb6ee6 100644 --- a/include/connections.php +++ b/include/connections.php @@ -446,8 +446,13 @@ function contact_remove($channel_id, $abook_id) { ); $r = q("delete from abconfig where chan = %d and xchan = '%s'", - intval($channel_id), - dbesc($abook['abook_xchan']) + intval($channel_id), + dbesc($abook['abook_xchan']) + ); + + $r = q("delete from source where src_channel_id = %d and src_xchan = '%s'", + intval($channel_id), + dbesc($abook['abook_xchan']) ); return true; -- cgit v1.2.3 From 1215618589636fd433d69fa5d81f2aca264beef5 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 9 Oct 2020 12:16:55 +0000 Subject: add zot6 to the authenticatable options and fix array key in reshare header --- 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 0cfa2a340..960aa3580 100755 --- a/include/items.php +++ b/include/items.php @@ -3175,6 +3175,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false // This MAY cause you to run afoul of copyright law. $rewrite_author = intval(get_abconfig($channel['channel_id'],$item['owner_xchan'],'system','rself')); + if($rewrite_author) { $item['author_xchan'] = $channel['channel_hash']; @@ -3246,7 +3247,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $group = false "' portable_id='" . $item['author']['xchan_hash'] . "' avatar='" . $item['author']['xchan_photo_s'] . "' link='" . $item['plink'] . - "' auth='" . ((in_array($item['author']['network'], ['zot','zot6'])) ? 'true' : 'false') . + "' auth='" . ((in_array($item['author']['xchan_network'], ['zot6','zot'])) ? 'true' : 'false') . "' posted='" . $item['created'] . "' message_id='" . $item['mid'] . "']"; -- cgit v1.2.3 From 595f3d99b4bd2618630f9a49423b29bfbfcbca41 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 10 Oct 2020 08:00:25 +0000 Subject: quickfix localize_item() - requires more work --- include/conversation.php | 15 +++++++++++++-- include/text.php | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index b43a6f47e..c8c36f241 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -104,20 +104,30 @@ function localize_item(&$item){ if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); + elseif($obj['actor'] && $obj['actor']['url']) + $author_link = $obj['actor']['url'][0]['href']; else $author_link = ''; $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); + if(!$author_name) + $author_name = (($obj['actor'] && $obj['actor']['name']) ? $obj['actor']['name'] : ''); + $item_url = get_rel_link($obj['link'],'alternate'); + if(!$item_url) + $item_url = $obj['id']; + $Bphoto = ''; switch($obj['type']) { case ACTIVITY_OBJ_PHOTO: + case 'Photo': $post_type = t('photo'); break; case ACTIVITY_OBJ_EVENT: + case 'Event': $post_type = t('event'); break; case ACTIVITY_OBJ_PERSON: @@ -142,9 +152,10 @@ function localize_item(&$item){ break; case ACTIVITY_OBJ_NOTE: + case 'Note': default: - $post_type = t('status'); - if($obj['id'] != $obj['parent']) + $post_type = t('post'); + if(($obj['parent'] && $obj['id'] != $obj['parent']) || $obj['inReplyTo']) $post_type = t('comment'); break; } diff --git a/include/text.php b/include/text.php index e798bf8f8..8bad8337f 100644 --- a/include/text.php +++ b/include/text.php @@ -2236,7 +2236,7 @@ function item_post_type($item) { $post_type = t('event'); break; default: - $post_type = t('status'); + $post_type = t('post'); if($item['mid'] != $item['parent_mid']) $post_type = t('comment'); break; -- cgit v1.2.3 From ed845d93bc7ac5f46ccb1ea95d53bc5e5f2756bd Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 10 Oct 2020 19:06:35 +0000 Subject: 5.0RC testing: fix issue with event responses --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 679440726..765086167 100644 --- a/include/event.php +++ b/include/event.php @@ -1247,7 +1247,7 @@ function event_store_item($arr, $event) { $item_arr['deny_cid'] = $arr['deny_cid']; $item_arr['deny_gid'] = $arr['deny_gid']; $item_arr['item_private'] = $private; - $item_arr['verb'] = ACTIVITY_POST; + $item_arr['verb'] = 'Invite'; $item_arr['item_wall'] = $item_wall; $item_arr['item_origin'] = $item_origin; $item_arr['item_thread_top'] = $item_thread_top; -- cgit v1.2.3 From 8d3c201830020d63a5204df04fdcb2ae04bf2b0f Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 20:22:07 +0000 Subject: if we receive an item with a zot xchan as author or owner rewrite them to the zot6 xchan if we have their zot6 xchan in abook --- include/zot.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index e10ef6fd7..ce5fd0174 100644 --- a/include/zot.php +++ b/include/zot.php @@ -9,6 +9,7 @@ */ use Zotlabs\Lib\DReport; +use Zotlabs\Lib\Libzot; require_once('include/crypto.php'); require_once('include/items.php'); @@ -1952,6 +1953,31 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ intval($channel['channel_id']), dbesc($arr['owner_xchan']) ); + + if(! $ab) { + + $best_owner_xchan = find_best_zot_identity($arr['owner_xchan']); + + $ab = q("select * from abook where abook_channel = %d and abook_xchan = '%s'", + intval($channel['channel_id']), + dbesc($best_owner_xchan) + ); + + if($ab) + $arr['owner_xchan'] = $best_owner_xchan; + } + + $best_author_xchan = find_best_zot_identity($arr['author_xchan']); + + $ab_author = q("select * from abook where abook_channel = %d and abook_xchan = '%s'", + intval($channel['channel_id']), + dbesc($best_author_xchan) + ); + + if($ab_author) + $arr['author_xchan'] = $best_author_xchan; + + $abook = (($ab) ? $ab[0] : null); if(intval($arr['item_deleted'])) { @@ -2044,6 +2070,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $result[] = $DR->get(); } else { + + hz_syslog(print_r($arr,true)); + + $item_result = item_store($arr); if($item_result['success']) { $item_id = $item_result['item_id']; @@ -5341,3 +5371,33 @@ function zot_record_preferred($arr, $check = 'hubloc_network') { return $arr[0]; } + +function find_best_zot_identity($xchan) { + + if (filter_var($xchan, FILTER_VALIDATE_URL)) { + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s'", + dbesc($xchan) + ); + if ($r) { + $r = Libzot::zot_record_preferred($r); + return $r['hubloc_hash']; + } + } + + $r = q("select hubloc_addr from hubloc where hubloc_hash = '%s'", + dbesc($xchan) + ); + + if ($r) { + + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s'", + dbesc($r[0]['hubloc_addr']) + ); + if ($r) { + $r = Libzot::zot_record_preferred($r); + return $r['hubloc_hash']; + } + } + + return $xchan; +} -- cgit v1.2.3 From 375986437ab94d3e25bb829409971adc89d4bdf9 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 20:58:30 +0000 Subject: fix php warnings --- include/conversation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index c8c36f241..0be50ce26 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -104,15 +104,15 @@ function localize_item(&$item){ if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); - elseif($obj['actor'] && $obj['actor']['url']) - $author_link = $obj['actor']['url'][0]['href']; + elseif(is_array($obj['actor']) && $obj['actor']['url']) + $author_link = ((is_array($obj['actor']['url']) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); else $author_link = ''; $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); if(!$author_name) - $author_name = (($obj['actor'] && $obj['actor']['name']) ? $obj['actor']['name'] : ''); + $author_name = ((is_array($obj['actor']) && $obj['actor']['name']) ? $obj['actor']['name'] : ''); $item_url = get_rel_link($obj['link'],'alternate'); -- cgit v1.2.3 From 31e030af69bd5e542dff45b299718f6c12b08467 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 21:01:36 +0000 Subject: missing parenthesis --- 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 0be50ce26..48a72aa21 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -105,7 +105,7 @@ function localize_item(&$item){ if($obj['author'] && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); elseif(is_array($obj['actor']) && $obj['actor']['url']) - $author_link = ((is_array($obj['actor']['url']) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); + $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); else $author_link = ''; -- cgit v1.2.3 From 8cd67a5d4a7072034df581e8ce212f1d24055348 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 12 Oct 2020 21:37:44 +0000 Subject: fix more php warnings and remove temporary logging --- include/conversation.php | 5 +++-- include/zot.php | 4 ---- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 48a72aa21..e77404cff 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -102,7 +102,7 @@ function localize_item(&$item){ logger('localize_item: failed to decode object: ' . print_r($item['obj'],true)); } - if($obj['author'] && $obj['author']['link']) + if(is_array($obj['author']) && $obj['author']['link']) $author_link = get_rel_link($obj['author']['link'],'alternate'); elseif(is_array($obj['actor']) && $obj['actor']['url']) $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); @@ -114,7 +114,8 @@ function localize_item(&$item){ if(!$author_name) $author_name = ((is_array($obj['actor']) && $obj['actor']['name']) ? $obj['actor']['name'] : ''); - $item_url = get_rel_link($obj['link'],'alternate'); + if(is_array($obj['link'])) + $item_url = get_rel_link($obj['link'],'alternate'); if(!$item_url) $item_url = $obj['id']; diff --git a/include/zot.php b/include/zot.php index ce5fd0174..38d6288cf 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2070,10 +2070,6 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $result[] = $DR->get(); } else { - - hz_syslog(print_r($arr,true)); - - $item_result = item_store($arr); if($item_result['success']) { $item_id = $item_result['item_id']; -- cgit v1.2.3 From 08e7c7b249e123edaa81348e54180e89080de012 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Oct 2020 08:16:14 +0000 Subject: use a more neutral default cover image provided by bggenerator.com --- include/channel.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index ccec4f9ee..ae186d02f 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2384,7 +2384,7 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { $cover = $r[0]; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { - $default_cover = get_config('system','default_cover_photo','pexels-94622'); + $default_cover = get_config('system','default_cover_photo','bggenerator'); $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ]; } @@ -2458,7 +2458,7 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { - $default_cover = get_config('system','default_cover_photo','pexels-94622'); + $default_cover = get_config('system','default_cover_photo','bggenerator'); $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ]; } -- cgit v1.2.3 From 45a5a0418983127edd5e726adf8b10cb45950cbd Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 13 Oct 2020 09:03:13 +0000 Subject: do not overwrite $x variable --- include/network.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index 750d56ac3..4457f59bc 100644 --- a/include/network.php +++ b/include/network.php @@ -1120,9 +1120,9 @@ function discover_by_webbie($webbie, $protocol = '') { continue; } - $x = Libzot::import_xchan($record['data']); - if($x['success']) { - return $x['hash']; + $y = Libzot::import_xchan($record['data']); + if($y['success']) { + return $y['hash']; } } } -- cgit v1.2.3 From e2e160b8e8d01eb0d2c537318f1d738aef9df9c8 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 14 Oct 2020 07:33:30 +0000 Subject: In find_best_identity() only look for zot and zot6 network types. Otherwise we could end up rewriting activitypub contacts to their diaspora equivalent which would be counterproductive here. Dismiss deleted hublocs. Same applies for find_best_zot_identity(). Also add logging. --- include/zot.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 38d6288cf..1a0ebdacb 100644 --- a/include/zot.php +++ b/include/zot.php @@ -10,6 +10,7 @@ use Zotlabs\Lib\DReport; use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\Activity; require_once('include/crypto.php'); require_once('include/items.php'); @@ -5370,27 +5371,18 @@ function zot_record_preferred($arr, $check = 'hubloc_network') { function find_best_zot_identity($xchan) { - if (filter_var($xchan, FILTER_VALIDATE_URL)) { - $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_id_url = '%s'", - dbesc($xchan) - ); - if ($r) { - $r = Libzot::zot_record_preferred($r); - return $r['hubloc_hash']; - } - } - - $r = q("select hubloc_addr from hubloc where hubloc_hash = '%s'", + $r = q("select hubloc_addr from hubloc where hubloc_hash = '%s' and hubloc_network in ('zot6', 'zot') and hubloc_deleted = 0", dbesc($xchan) ); if ($r) { - $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s'", + $r = q("select hubloc_hash, hubloc_network from hubloc where hubloc_addr = '%s' and hubloc_network in ('zot6', 'zot') and hubloc_deleted = 0", dbesc($r[0]['hubloc_addr']) ); if ($r) { $r = Libzot::zot_record_preferred($r); + logger('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); return $r['hubloc_hash']; } } -- cgit v1.2.3 From ea77043aaf0419f065ab47cb38e98203918f3465 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 14 Oct 2020 08:53:12 +0000 Subject: more logging --- include/zot.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 1a0ebdacb..4fa8bf14c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1964,8 +1964,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ dbesc($best_owner_xchan) ); - if($ab) + if($ab) { + logger('rewrite owner: ' . $arr['owner_xchan'] . ' > ' . $best_owner_xchan); $arr['owner_xchan'] = $best_owner_xchan; + } } $best_author_xchan = find_best_zot_identity($arr['author_xchan']); @@ -1975,9 +1977,10 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ dbesc($best_author_xchan) ); - if($ab_author) + if($ab_author) { + logger('rewrite author: ' . $arr['author_xchan'] . ' > ' . $best_author_xchan); $arr['author_xchan'] = $best_author_xchan; - + } $abook = (($ab) ? $ab[0] : null); @@ -5382,7 +5385,7 @@ function find_best_zot_identity($xchan) { ); if ($r) { $r = Libzot::zot_record_preferred($r); - logger('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); + hz_syslog('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); return $r['hubloc_hash']; } } -- cgit v1.2.3 From f5315ed6a2bf0ac3fa4e6e5dac8671ec7abafd76 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 14 Oct 2020 14:25:22 +0000 Subject: use logger for logging --- 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 4fa8bf14c..8a2177de7 100644 --- a/include/zot.php +++ b/include/zot.php @@ -5385,7 +5385,7 @@ function find_best_zot_identity($xchan) { ); if ($r) { $r = Libzot::zot_record_preferred($r); - hz_syslog('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); + logger('find_best_zot_identity: ' . $xchan . ' > ' . $r['hubloc_hash']); return $r['hubloc_hash']; } } -- cgit v1.2.3 From 3b252d98b89b884be995f6f90e31d7e6612cf522 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2020 10:51:58 +0000 Subject: add forums to acl selector where appropriate --- include/acl_selectors.php | 47 ++++++++++++++++++++++++++++++++++------------- include/xchan.php | 2 +- 2 files changed, 35 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 35e385058..30219a476 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -79,24 +79,44 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $custom = false; } - $r = q("SELECT id, profile_guid, profile_name from profile where is_default = 0 and uid = %d order by profile_name", + $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval(local_channel()) ); + if($r) { - foreach($r as $rv) { - $selected = (($single_group && 'vp.' . $rv['profile_guid'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); - $groups .= '' . "\r\n"; + $groups .= ''; + foreach($r as $rr) { + $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); + $groups .= '' . "\r\n"; } + $groups .= ''; } - $r = q("SELECT id, hash, gname FROM pgrp WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", + $r = q("SELECT id, profile_guid, profile_name from profile where is_default = 0 and uid = %d order by profile_name", intval(local_channel()) ); if($r) { - foreach($r as $rr) { - $selected = (($single_group && $rr['hash'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); - $groups .= '' . "\r\n"; + $groups .= ''; + foreach($r as $rv) { + $selected = (($single_group && 'vp.' . $rv['profile_guid'] === $allow_gid[0]) ? ' selected = "selected" ' : ''); + $groups .= '' . "\r\n"; + } + $groups .= ''; + } + + // $dialog_description is only set in places where we set permissions for a post. + // Abuse this fact to decide if forums should be displayed or not. + if($dialog_description) { + $forums = get_forum_channels(local_channel(),1); + + if($forums) { + $groups .= ''; + foreach($forums as $f) { + $selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : ''); + $groups .= '' . "\r\n"; + } + $groups .= ''; } } @@ -104,17 +124,18 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $o = replace_macros($tpl, array( '$showall' => $showall_caption, '$onlyme' => t('Only me'), - '$groups' => $groups, + '$groups' => $groups, '$public_selected' => (($has_acl) ? false : true), '$justme_selected' => $just_me, '$custom_selected' => $custom, '$showallOrigin' => $showall_origin, '$showallIcon' => $showall_icon, - '$select_label' => t('Who can see this?'), + '$select_label' => t('Share with'), '$custom' => t('Custom selection'), - '$showlimitedDesc' => t('Select "Show" to allow viewing. "Don\'t show" lets you override and limit the scope of "Show".'), - '$show' => t('Show'), - '$hide' => t("Don't show"), + '$custom_label' => t('Advanced'), + '$showlimitedDesc' => t('Select "Allow" to allow viewing. "Don\'t allow" lets you override and limit the scope of "Allow".'), + '$show' => t('Allow'), + '$hide' => t("Don't allow"), '$search' => t('Search'), '$allowcid' => json_encode($allow_cid), '$allowgid' => json_encode($allow_gid), diff --git a/include/xchan.php b/include/xchan.php index d69d707aa..8032dae2f 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -264,4 +264,4 @@ function xchan_change_key($oldx,$newx,$data) { foreach($acls as $k => $v) { xchan_keychange_acl($k,$v,$oldx,$newx); } -} \ No newline at end of file +} -- cgit v1.2.3 From 61f554e0d7820b19f7ecb7b6d216f3012dc23acf Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2020 10:54:59 +0000 Subject: remove new lines and tabs from xchan_name --- include/text.php | 9 +++++++++ include/xchan.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 8bad8337f..af1473713 100644 --- a/include/text.php +++ b/include/text.php @@ -3816,3 +3816,12 @@ function unserialise($x) { return ((is_array($y)) ? $y : $x); } +/** + * @brief Remove new lines and tabs from strings. + * + * @return string + */ +function sanitize_text_field($str) { + return preg_replace('/\s+/S', ' ', $str); +} + diff --git a/include/xchan.php b/include/xchan.php index 8032dae2f..5de828e7f 100644 --- a/include/xchan.php +++ b/include/xchan.php @@ -25,7 +25,7 @@ function xchan_store_lowlevel($arr) { 'xchan_connurl' => ((array_key_exists('xchan_connurl',$arr)) ? $arr['xchan_connurl'] : ''), 'xchan_follow' => ((array_key_exists('xchan_follow',$arr)) ? $arr['xchan_follow'] : ''), 'xchan_connpage' => ((array_key_exists('xchan_connpage',$arr)) ? $arr['xchan_connpage'] : ''), - 'xchan_name' => ((array_key_exists('xchan_name',$arr)) ? $arr['xchan_name'] : ''), + 'xchan_name' => ((array_key_exists('xchan_name',$arr)) ? sanitize_text_field($arr['xchan_name']) : ''), 'xchan_network' => ((array_key_exists('xchan_network',$arr)) ? $arr['xchan_network'] : ''), 'xchan_instance_url' => ((array_key_exists('xchan_instance_url',$arr)) ? $arr['xchan_instance_url'] : ''), 'xchan_flags' => ((array_key_exists('xchan_flags',$arr)) ? intval($arr['xchan_flags']) : 0), -- cgit v1.2.3 From b6ca9b6020e2eae0b5389148ce45bc2f7a81f999 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 10:32:07 +0000 Subject: make acl selector work correctly if we provide a cid in mod network --- include/text.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index af1473713..0a54ddd2f 100644 --- a/include/text.php +++ b/include/text.php @@ -3661,11 +3661,15 @@ function get_forum_channels($uid) { if(! $uid) return; - $xf = false; + if(App::$data['forum_channels']) + return App::$data['forum_channels']; + + $xf = ''; $x1 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'send_stream' and v = '0'", intval($uid) ); + if($x1) { $xc = ids_to_querystr($x1,'xchan',true); @@ -3702,6 +3706,8 @@ function get_forum_channels($uid) { } } + App::$data['forum_channels'] = $r; + return $r; } -- cgit v1.2.3 From f0acb9f01e0e2e130121dff435dea4a29f460d8e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 11:43:21 +0000 Subject: get_forum_channels(): fix an issue where we would not look for private forums in case we did not have any channels where tag_deliver is set --- include/text.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 0a54ddd2f..ec397910d 100644 --- a/include/text.php +++ b/include/text.php @@ -3677,22 +3677,21 @@ function get_forum_channels($uid) { intval($uid) ); - if($x2) { - $xf = ids_to_querystr($x2,'xchan',true); + $xf = ids_to_querystr($x2,'xchan',true); + $sql_extra = (($xf) ? ' and not xchan in (' . $xf . ')' : ''); - // private forums - $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") and not xchan in (" . $xf . ") ", - intval(local_channel()) - ); - if($x3) { - $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); - } + // private forums + $x3 = q("select xchan from abconfig where chan = %d and cat = 'their_perms' and k = 'post_wall' and v = '1' and xchan in (" . $xc . ") $sql_extra ", + intval(local_channel()) + ); + if($x3) { + $xf = ids_to_querystr(array_merge($x2,$x3),'xchan',true); } } - $sql_extra = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); + $sql_extra_1 = (($xf) ? " and ( xchan_hash in (" . $xf . ") or xchan_pubforum = 1 ) " : " and xchan_pubforum = 1 "); - $r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_addr, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra order by xchan_name", + $r = q("select abook_id, xchan_hash, xchan_name, xchan_url, xchan_addr, xchan_photo_s from abook left join xchan on abook_xchan = xchan_hash where xchan_deleted = 0 and abook_channel = %d and abook_pending = 0 and abook_ignored = 0 and abook_blocked = 0 and abook_archived = 0 $sql_extra_1 order by xchan_name", intval($uid) ); -- cgit v1.2.3 From 5dc2f43d1d38d190cadbd8eb53227570277e69b1 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Oct 2020 11:54:14 +0000 Subject: mark private forums in acl selector --- include/acl_selectors.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 30219a476..a3476439a 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -109,12 +109,12 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti // Abuse this fact to decide if forums should be displayed or not. if($dialog_description) { $forums = get_forum_channels(local_channel(),1); - if($forums) { $groups .= ''; foreach($forums as $f) { + $private = (($f['private_forum']) ? ' (' . t('Private Forum') . ')' : ''); $selected = (($single_group && $f['hash'] === $allow_cid[0]) ? ' selected = "selected" ' : ''); - $groups .= '' . "\r\n"; + $groups .= '' . "\r\n"; } $groups .= ''; } -- cgit v1.2.3 From 5e0f5460f2ee92aecc53fd900e55d54fa5326fc5 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 19 Oct 2020 07:25:30 +0000 Subject: provide info about dead sites in delivery report and set site_dead when marking a hubloc down. --- include/hubloc.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/hubloc.php b/include/hubloc.php index 059a4dadc..6b896c627 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -247,6 +247,7 @@ function hubloc_change_primary($hubloc) { * * We use the post url to distinguish between http and https hublocs. * The https might be alive, and the http dead. + * Also set site_dead for the corresponding entry in the site table. * * @param string $posturl Hubloc callback url which to disable */ @@ -255,6 +256,13 @@ function hubloc_mark_as_down($posturl) { intval(HUBLOC_OFFLINE), dbesc($posturl) ); + + // extract the baseurl and set site.site_dead to match + $m = parse_url($posturl); + $h = $m['scheme'] . '://' . $m['host']; + $r = q("update site set site_dead = 1 where site_url = '%s'", + dbesc($h) + ); } -- cgit v1.2.3 From 75a73be60c97597f93a67a4ecd412daed06cd744 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Oct 2020 18:54:21 +0000 Subject: lazy/eager loading and minor css fixes --- include/bbcode.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index e5b2a068a..d79429719 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -218,7 +218,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } // logger('replace_images: ' . $newbody); @@ -513,7 +513,7 @@ function bb_ShareAttributes($match) { $headline = '
'; if ($avatar != "") - $headline .= '' . $author . ''; + $headline .= '' . $author . ''; if(strpos($link,'/cards/')) $type = t('card'); @@ -881,7 +881,7 @@ function bb_imgoptions($match) { // now assemble the resulting img tag from these components - $output = '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } // [img=pathtoimage]image description[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); } // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [zmg=pathtoimage]image description[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); -- cgit v1.2.3 From 78f655f877d2d2b7afd6d606edabc5b0df638738 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Oct 2020 19:11:03 +0000 Subject: more lazy, less eager --- include/bbcode.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index d79429719..c5d58e80d 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -218,7 +218,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } // logger('replace_images: ' . $newbody); @@ -881,7 +881,7 @@ function bb_imgoptions($match) { // now assemble the resulting img tag from these components - $output = '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } // [img=pathtoimage]image description[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); } // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [zmg=pathtoimage]image description[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); -- cgit v1.2.3 From 2772c335635aa5248a4509e0976432707b3e716e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Oct 2020 19:22:52 +0000 Subject: load eager in items - lazy breaks collapsing of long items with images --- include/bbcode.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index c5d58e80d..d79429719 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -218,7 +218,7 @@ function bb_replace_images($body, $images) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element - $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); + $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '' . t('Image/photo') . '', $newbody); $cnt++; } // logger('replace_images: ' . $newbody); @@ -881,7 +881,7 @@ function bb_imgoptions($match) { // now assemble the resulting img tag from these components - $output = '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '' . t('Image/photo') . '', $Text); } // [img=pathtoimage]image description[/img] if (strpos($Text,'[/img]') !== false) { - $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); + $Text = preg_replace("/\[img=http(.*?)\](.*?)\[\/img\]/ism", '$2', $Text); } // [zmg]pathtoimage[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); + $Text = preg_replace("/\[zmg\](.*?)\[\/zmg\]/ism", '' . t('Image/photo') . '', $Text); } // [zmg=pathtoimage]image description[/zmg] if (strpos($Text,'[/zmg]') !== false) { - $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); + $Text = preg_replace("/\[zmg=http(.*?)\](.*?)\[\/zmg\]/ism", '$2', $Text); } $Text = preg_replace_callback("/\[([zi])mg([ \=])(.*?)\](.*?)\[\/[zi]mg\]/ism",'bb_imgoptions',$Text); -- cgit v1.2.3 From 59fd3861a76bad8ac07592046401b3c27a5f3cb2 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 23 Oct 2020 09:28:49 +0000 Subject: wrong extension --- include/channel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index ae186d02f..bca09f1f3 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2379,13 +2379,13 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { intval($cover_size), intval(PHOTO_COVER) ); - +hz_syslog(); if($r) { $cover = $r[0]; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { $default_cover = get_config('system','default_cover_photo','bggenerator'); - $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ]; + $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.png' ]; } $o .= replace_macros(get_markup_template('zcard.tpl'), array( @@ -2452,14 +2452,14 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { intval($cover_size), intval(PHOTO_COVER) ); - +hz_syslog(print_r($r,true)); if($r) { $cover = $r[0]; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; } else { $default_cover = get_config('system','default_cover_photo','bggenerator'); - $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.jpg' ]; + $cover = [ 'href' => z_root() . '/images/default_cover_photos/' . $default_cover . '/' . $cover_width . '.png' ]; } $o .= replace_macros(get_markup_template('zcard_embed.tpl'),array( -- cgit v1.2.3 From 29e89d1152d4aa16de1e90141ad5711e63b768c5 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 23 Oct 2020 11:46:43 +0000 Subject: =?UTF-8?q?=C3=83remove=20logging=C3=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index bca09f1f3..7167d3716 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2452,7 +2452,7 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { intval($cover_size), intval(PHOTO_COVER) ); -hz_syslog(print_r($r,true)); + if($r) { $cover = $r[0]; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; -- cgit v1.2.3 From c136741db65b65c33b3579c7d2a952d3b509e10e Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 23 Oct 2020 12:18:04 +0000 Subject: more remove logging --- include/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 7167d3716..e2be4d8a8 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2379,7 +2379,7 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { intval($cover_size), intval(PHOTO_COVER) ); -hz_syslog(); + if($r) { $cover = $r[0]; $cover['href'] = z_root() . '/photo/' . $r[0]['resource_id'] . '-' . $r[0]['imgscale']; -- cgit v1.2.3 From d3d5ddfb434555373b892e127ad9faa6425af3bf Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 24 Oct 2020 21:26:46 +0000 Subject: enable btlogging to syslog (cherry picked from commit 5580fc1954a63f861644e2de3773fbb3adfa8f2c) --- include/text.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index ec397910d..237202283 100644 --- a/include/text.php +++ b/include/text.php @@ -723,7 +723,7 @@ function logid() { * @param int $level A log level * @param int $priority - compatible with syslog */ -function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { +function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO, $syslog = false) { if(! defined('BTLOGGER_DEBUG_FILE')) define('BTLOGGER_DEBUG_FILE','btlogger.out'); @@ -742,7 +742,9 @@ function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { for($x = 1; $x < count($stack); $x ++) { $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()'; logger($s,$level, $priority); - + if($syslog) { + hz_syslog(print_r($s,true)); + } if(file_exists(BTLOGGER_DEBUG_FILE) && is_writable(BTLOGGER_DEBUG_FILE)) { @file_put_contents(BTLOGGER_DEBUG_FILE, $s . PHP_EOL, FILE_APPEND); } -- cgit v1.2.3 From 7112bcd134fcbc1c6cef6618c801e6f879d5e920 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 25 Oct 2020 07:27:07 +0000 Subject: bt_syslog() instead of syslog flag for btlogger --- include/text.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 237202283..a300ccf58 100644 --- a/include/text.php +++ b/include/text.php @@ -659,6 +659,26 @@ function hz_syslog($msg, $priority = LOG_INFO) { closelog(); } +/** + * @brief like hz_syslog() but with a function backtrace to pinpoint certain classes + * of problems which show up deep in the calling stack. + * + * @param string $msg Message to log + * @param int $priority - compatible with syslog + */ +function bt_syslog($msg, $priority = LOG_INFO) { + $stack = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); + if($stack) { + for($x = 1; $x < count($stack); $x ++) { + $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()'; + openlog("bt-log", LOG_PID | LOG_PERROR, LOG_LOCAL0); + syslog($priority, $msg); + closelog(); + } + } +} + + /** * @brief Logging function for Hubzilla. @@ -723,7 +743,7 @@ function logid() { * @param int $level A log level * @param int $priority - compatible with syslog */ -function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO, $syslog = false) { +function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO) { if(! defined('BTLOGGER_DEBUG_FILE')) define('BTLOGGER_DEBUG_FILE','btlogger.out'); @@ -742,9 +762,6 @@ function btlogger($msg, $level = LOGGER_NORMAL, $priority = LOG_INFO, $syslog = for($x = 1; $x < count($stack); $x ++) { $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()'; logger($s,$level, $priority); - if($syslog) { - hz_syslog(print_r($s,true)); - } if(file_exists(BTLOGGER_DEBUG_FILE) && is_writable(BTLOGGER_DEBUG_FILE)) { @file_put_contents(BTLOGGER_DEBUG_FILE, $s . PHP_EOL, FILE_APPEND); } -- cgit v1.2.3 From 7008cf326903ea6f1887011fca1e5fa8ca626d28 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Sun, 25 Oct 2020 11:28:40 +0100 Subject: Add results caching on public tag and profile categories fetching --- include/contact_widgets.php | 49 +++++++++++++++--------- include/taxonomy.php | 93 +++++++++++++++++++++++++-------------------- 2 files changed, 82 insertions(+), 60 deletions(-) (limited to 'include') diff --git a/include/contact_widgets.php b/include/contact_widgets.php index 6ad276b00..626a825b2 100644 --- a/include/contact_widgets.php +++ b/include/contact_widgets.php @@ -1,6 +1,6 @@ $rr['term'], 'selected' => (($selected == $rr['term']) ? 'selected' : '')); @@ -104,6 +116,7 @@ function categories_widget($baseurl,$selected = '') { return ''; } + function cardcategories_widget($baseurl,$selected = '') { if(! feature_enabled(App::$profile['profile_uid'],'categories')) diff --git a/include/taxonomy.php b/include/taxonomy.php index b0304de5b..e06568d19 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -5,6 +5,9 @@ // and save to file categories in square brackets. // To do this we need to escape these characters if they appear in our tag. +use Zotlabs\Lib\Cache; + + function file_tag_encode($s) { return str_replace(array('<','>','[',']'),array('%3c','%3e','%5b','%5d'),$s); } @@ -327,50 +330,56 @@ function pubtagblock($net,$site,$limit,$recent = 0,$safemode = 1, $type = TERM_H return $o; } -function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) { - - - $item_normal = item_normal(); - $count = intval($limit); - - if($site) { - $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 "; - } - else { - $sys = get_sys_channel(); - $uids = " and item.uid = " . intval($sys['channel_id']) . " "; - $sql_extra = " and item_private = 0 "; - } - - if($recent) - $sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' "; +function pub_tagadelic($net,$site,$limit,$recent,$safemode,$type) { - if($safemode) { - $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); - if($unsafetags) { - $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") "; - } - } - - - // Fetch tags - $r = q("select term, count(term) as total from term left join item on term.oid = item.id - where term.ttype = %d - and otype = %d and item_type = %d - $sql_extra $uids $item_normal - group by term order by total desc %s", - intval($type), - intval(TERM_OBJ_POST), - intval(ITEM_TYPE_POST), - ((intval($count)) ? "limit $count" : '') - ); - - if(! $r) - return array(); - - return Zotlabs\Text\Tagadelic::calc($r); - + $item_normal = item_normal(); + $count = intval($limit); + + if($site) + $uids = " and item.uid in ( " . stream_perms_api_uids(PERMS_PUBLIC) . " ) and item_private = 0 and item_wall = 1 "; + else { + $sys = get_sys_channel(); + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; + $sql_extra = " and item_private = 0 "; + } + + if($recent) + $sql_extra .= " and item.created > '" . datetime_convert('UTC','UTC', 'now - ' . intval($recent) . ' days ') . "' "; + + + if($safemode) { + $unsafetags = get_config('system','unsafepubtags', [ 'boobs', 'bot', 'rss', 'girl','girls', 'nsfw', 'sexy', 'nude' ]); + if($unsafetags) { + $sql_extra .= " and not term.term in ( " . stringify_array($unsafetags,true) . ") "; + } + } + + + $key = __FUNCTION__ . "-" . md5($site . $recent . $safemode . $limit . $type); + $content = Cache::get($key, '1 MINUTE'); + + if(! $content) { + // Fetch tags + $r = q("SELECT term, count(term) AS total FROM term LEFT JOIN item ON term.oid = item.id + where term.ttype = %d + and otype = %d and item_type = %d + $sql_extra $uids $item_normal + group by term order by total desc %s", + intval($type), + intval(TERM_OBJ_POST), + intval(ITEM_TYPE_POST), + ((intval($count)) ? "limit $count" : '') + ); + } else + $r = unserialize($content); + + if(! $r) + return array(); + else + Cache::set($key, serialize($r)); + + return Zotlabs\Text\Tagadelic::calc($r); } -- cgit v1.2.3 From 0ad7c8f69eb8b0d6087ef9982af90add02770b1c Mon Sep 17 00:00:00 2001 From: root Date: Fri, 30 Oct 2020 20:01:12 +0000 Subject: HTML parsing lib change to standard PHP in scrape_feed() and scrape_vcard() (cherry picked from commit 16d450fc6980bb70f13e574d1b20406dd313110e) --- include/network.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index 4457f59bc..9d4c00ee8 100644 --- a/include/network.php +++ b/include/network.php @@ -1333,14 +1333,15 @@ function fetch_xrd_links($url) { */ function scrape_feed($url) { - require_once('library/HTML5/Parser.php'); $ret = array(); $level = 0; $x = z_fetch_url($url,false,$level,array('novalidate' => true)); - if(! $x['success']) + if(! $x['success']) { + logger('ERROR fetching URL'); return $ret; + } $headers = $x['header']; $code = $x['return_code']; @@ -1374,17 +1375,16 @@ function scrape_feed($url) { } } + $dom = new DOMDocument(); try { - $dom = HTML5_Parser::parse($s); + $dom->loadHTML( $s); } catch (DOMException $e) { - logger('Parse error: ' . $e); - } - - if(! $dom) { - logger('Failed to parse.'); + logger('Feed parse error: ' . $e); + // logger('Feed parse ERROR: ' . libxml_get_last_error()->message); return $ret; } + $head = $dom->getElementsByTagName('base'); if($head) { foreach($head as $head0) { @@ -1846,15 +1846,15 @@ function probe_api_path($host) { function scrape_vcard($url) { - require_once('library/HTML5/Parser.php'); - $ret = array(); logger('url=' . $url); $x = z_fetch_url($url); - if(! $x['success']) + if(! $x['success']) { + logger('ERROR fetching URL'); return $ret; + } $s = $x['body']; @@ -1871,14 +1871,14 @@ function scrape_vcard($url) { } } + $dom = new DOMDocument(); try { - $dom = HTML5_Parser::parse($s); + $dom->loadHTML( $s); } catch (DOMException $e) { - logger('Parse error: ' . $e); - } - - if(! $dom) + logger('hCard parse error: ' . $e); + // logger('hCard fetch ERROR: ' . libxml_get_last_error()->message); return $ret; + } // Pull out hCard profile elements -- cgit v1.2.3 From d59b81f11df990c7710378f9d9b0341fc89276e9 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 31 Oct 2020 19:57:14 +0000 Subject: if restarting a previously interrupted upload just return where we ended - fix issue #1485 --- include/attach.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 80f71b9ea..c9649a4ce 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2807,6 +2807,12 @@ function save_chunk($channel,$start,$end,$len) { $new_path = $new_base . '/' . $_FILES['files']['name']; + if(file_exists($new_path) && intval($start) === 0) { + $result['partial'] = true; + $result['length'] = intval(filesize($new_path)); + return $result; + } + if(! file_exists($new_path)) { rename($tmp_path,$new_path); } -- cgit v1.2.3 From 953c2947782cdd34a40eafc45f90125696a2fc91 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 5 Nov 2020 08:32:21 +0000 Subject: wrong variable name --- 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 a300ccf58..58cde7838 100644 --- a/include/text.php +++ b/include/text.php @@ -672,7 +672,7 @@ function bt_syslog($msg, $priority = LOG_INFO) { for($x = 1; $x < count($stack); $x ++) { $s = 'stack: ' . basename($stack[$x]['file']) . ':' . $stack[$x]['line'] . ':' . $stack[$x]['function'] . '()'; openlog("bt-log", LOG_PID | LOG_PERROR, LOG_LOCAL0); - syslog($priority, $msg); + syslog($priority, $s); closelog(); } } -- cgit v1.2.3