From 9dc949b62c6b5e3c8872211f71b11714d9d22b22 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 20 Jan 2023 11:05:15 +0000 Subject: native dark theme initial checkin --- include/nav.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 2cdf7d42b..d4e9b8f92 100644 --- a/include/nav.php +++ b/include/nav.php @@ -201,6 +201,8 @@ function nav($template = 'default') { $nav['admin'] = ['admin/', t('Admin'), "", t('Site Setup and Configuration'), 'admin_nav_btn']; } + $theme_switch_icon = ((App::$page['color_mode'] === 'dark') ? 'sun' : 'moon'); + $x = ['nav' => $nav, 'usermenu' => $userinfo]; call_hooks('nav', $x); @@ -317,6 +319,7 @@ function nav($template = 'default') { App::$page['nav'] .= replace_macros($tpl, [ '$baseurl' => z_root(), + '$theme_switch_icon' => $theme_switch_icon, '$fulldocs' => t('Help'), '$sitelocation' => $sitelocation, '$nav' => $x['nav'], -- cgit v1.2.3 From cf1838f76eea5a33f1af78447c7dcf3f52dacc56 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Jan 2023 10:10:06 +0000 Subject: minor cleanup and prevent duplicate recipients in some places --- include/items.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 900ffe2fa..b795df90d 100644 --- a/include/items.php +++ b/include/items.php @@ -149,14 +149,16 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { // in the middle of a public thread. Unless we can guarantee beyond all doubt that // this is public, don't allow it to go to thread listeners. - if(! intval($item['item_private'])) { + if(!intval($item['item_private'])) { $sys = get_sys_channel(); $recipients[] = $sys['xchan_hash']; $r = ThreadListener::fetch_by_target($item['parent_mid']); if($r) { foreach($r as $rv) { - $recipients[] = $rv['portable_id']; + if (!in_array($rv['portable_id'], $recipients)) { + $recipients[] = $rv['portable_id']; + } } } } @@ -172,9 +174,9 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { $r = q("select author_xchan from item where parent = %d", intval($item['parent']) ); - if($r) { + if ($r) { foreach($r as $rv) { - if(! in_array($rv['author_xchan'],$recipients)) { + if (!in_array($rv['author_xchan'], $recipients)) { $recipients[] = $rv['author_xchan']; } } @@ -185,7 +187,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { // This is a somewhat expensive operation but important. // Don't send this item to anybody who isn't allowed to see it - $recipients = check_list_permissions($item['uid'],$recipients,'view_stream'); + $recipients = check_list_permissions($item['uid'], $recipients, 'view_stream'); // remove any upstream recipients from our list. // If it is ourself we'll add it back in a second. @@ -193,7 +195,7 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { // sending to anybody who is on our list of those who sent it to us. if($item['route']) { - $route = explode(',',$item['route']); + $route = explode(',', $item['route']); if(count($route)) { $route = array_unique($route); $recipients = array_diff($recipients,$route); @@ -202,9 +204,13 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { // add ourself just in case we have nomadic clones that need to get a copy. - $recipients[] = $item['author_xchan']; - if($item['owner_xchan'] != $item['author_xchan']) + if (!in_array($item['author_xchan'], $recipients)) { + $recipients[] = $item['author_xchan']; + } + + if($item['owner_xchan'] !== $item['author_xchan'] && !in_array($item['owner_xchan'], $recipients)) { $recipients[] = $item['owner_xchan']; + } return $recipients; } -- cgit v1.2.3 From 79b40179b40b0f1539e58a8c2c7d7f914e6b212b Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Jan 2023 18:28:40 +0000 Subject: redbasic: implement setting for always light navbar icons and some minor fixes --- include/nav.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index d4e9b8f92..31a447a84 100644 --- a/include/nav.php +++ b/include/nav.php @@ -319,6 +319,8 @@ function nav($template = 'default') { App::$page['nav'] .= replace_macros($tpl, [ '$baseurl' => z_root(), + '$color_mode' => App::$page['color_mode'] ?? '', + '$navbar_color_mode' => App::$page['navbar_color_mode'] ?? '', '$theme_switch_icon' => $theme_switch_icon, '$fulldocs' => t('Help'), '$sitelocation' => $sitelocation, -- cgit v1.2.3 From a3913c5ca47479e0ae616d7720b75e6415fd072f Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 28 Jan 2023 16:57:32 +0000 Subject: fix ics import --- include/cdav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/cdav.php b/include/cdav.php index fcce0ec4a..73977e624 100644 --- a/include/cdav.php +++ b/include/cdav.php @@ -132,7 +132,7 @@ function import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backe $objectUri = random_string(40) . '.' . $ext; $r = q("SELECT uri FROM $table WHERE $column = %d AND uri = '%s' LIMIT 1", - dbesc($id), + dbesc(is_array($id) ? $id[0] : $id), dbesc($objectUri) ); if (count($r)) -- cgit v1.2.3 From 1ca988b177834467671137c94f17a5948b465f6f Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Feb 2023 09:41:48 +0000 Subject: revisit author_id and fix issue with pinned content --- include/conversation.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index caad5bb0e..2f0b6f6fd 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -802,6 +802,7 @@ function conversation($items, $mode, $update, $page_mode = 'traditional', $prepa 'mid' => gen_link_id($item['mid']), 'mids' => json_encode([gen_link_id($item['mid'])]), 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, $profile_link), + 'author_id' => (($item['author']['xchan_addr']) ? $item['author']['xchan_addr'] : $item['author']['xchan_url']), 'profile_url' => $profile_link, 'thread_action_menu' => thread_action_menu($item,$mode), 'thread_author_menu' => thread_author_menu($item,$mode), -- cgit v1.2.3 From 09a60774d746de57d6f9e479a1f6cf70c691f031 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 15 Feb 2023 13:33:23 +0000 Subject: we can sign messages which are not from the primary location --- include/channel.php | 2 +- include/hubloc.php | 8 ++++++++ include/text.php | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 296615524..c36e50f19 100644 --- a/include/channel.php +++ b/include/channel.php @@ -3086,6 +3086,6 @@ function channel_url($channel) { } function get_channel_hashes() { - $r = q("SELECT channel_hash FROM channel WHERE channel_removed = 0"); + $r = dbq("SELECT channel_hash FROM channel WHERE channel_removed = 0"); return flatten_array_recursive($r); } diff --git a/include/hubloc.php b/include/hubloc.php index 0236e4ae7..4d2980a6b 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -392,3 +392,11 @@ function z6_discover() { } } + +function get_hubloc_id_urls_by_x($xchan) { + $r = q("SELECT hubloc_id_url FROM hubloc WHERE hubloc_deleted = 0 AND hubloc_hash = '%s' order by hubloc_primary desc", + dbesc($xchan) + ); + return flatten_array_recursive($r); +} + diff --git a/include/text.php b/include/text.php index 35ce465d6..a09d1bd7b 100644 --- a/include/text.php +++ b/include/text.php @@ -2621,13 +2621,13 @@ function xchan_query(&$items, $abook = true, $effective_uid = 0) { if(count($arr)) { if($abook) { $chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d - where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1", + where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc", intval($item['uid']) ); } else { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash - where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_primary = 1"); + where xchan_hash in (" . protect_sprintf(implode(',', $arr)) . ") and hubloc_deleted = 0 order by hubloc_primary desc"); } $xchans = q("select * from xchan where xchan_hash in (" . protect_sprintf(implode(',',$arr)) . ") and xchan_network in ('rss','unknown', 'anon', 'token')"); if(! $chans) -- cgit v1.2.3 From efcda1d37d609677b4fdc6a12c63feea250a3f5e Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 23 Feb 2023 09:51:37 +0000 Subject: port some functions from streams --- include/text.php | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index a09d1bd7b..d7ffa5550 100644 --- a/include/text.php +++ b/include/text.php @@ -3505,6 +3505,14 @@ function flatten_array_recursive($arr) { return($ret); } +// Turn $element into an array if it isn't already. +function force_array($element) { + if (empty($element)) { + return []; + } + return (is_array($element)) ? $element : [$element]; +} + /** * @brief Highlight Text. * -- cgit v1.2.3 From 9ab9ac0e2eab443265ceeba2f6dfbaa41c853a65 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 27 Feb 2023 08:22:35 +0000 Subject: possible fix for issue #1731 --- include/language.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/language.php b/include/language.php index 23aff0a02..e7363cffb 100644 --- a/include/language.php +++ b/include/language.php @@ -24,15 +24,15 @@ use CommerceGuys\Intl\Language\LanguageRepository; * @return array with ordered list of preferred languages from browser */ function get_browser_language() { - $langs = array(); - $lang_parse = array(); + $langs = []; + $lang_parse = []; if (x($_SERVER, 'HTTP_ACCEPT_LANGUAGE')) { // break up string into pieces (languages and q factors) preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); - if (count($lang_parse[1])) { + if (is_array($lang_parse[1])) { // create a list like "en" => 0.8 $langs = array_combine($lang_parse[1], $lang_parse[4]); -- cgit v1.2.3 From da034045cc1bba74287b7c3e83f4a94ff5359150 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Mar 2023 21:15:19 +0000 Subject: some work on bringing bang tags back for forums --- include/items.php | 13 ++----------- include/text.php | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index b795df90d..d8f817fc2 100644 --- a/include/items.php +++ b/include/items.php @@ -2686,12 +2686,7 @@ function tag_deliver($uid, $item_id) { * Now we've got those out of the way. Let's see if this is a post that's tagged for re-delivery */ - $terms = []; - if (array_key_exists('term', $item)) { - $terms = array_merge(get_terms_oftype($item['term'],TERM_MENTION),get_terms_oftype($item['term'],TERM_FORUM)); - logger('Post mentions: ' . print_r($terms,true), LOGGER_DATA); - } - + $terms = isset($item['term']) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_FORUM]) : []; $max_forums = get_config('system','max_tagged_forums',2); $matched_forums = 0; @@ -2732,7 +2727,7 @@ function tag_deliver($uid, $item_id) { // standard forum tagging sequence !forumname -/* + $forumpattern = '/\!\!?\[[uz]rl\=([^\]]*?)\]((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/'; $forumpattern2 = '/\[[uz]rl\=([^\]]*?)\]\!((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/'; @@ -2766,8 +2761,6 @@ function tag_deliver($uid, $item_id) { } } -*/ - if(! ($tagged || $plustagged)) { logger('Mention was in a reshare or exceeded max_tagged_forums - ignoring'); continue; @@ -2993,7 +2986,6 @@ function tgroup_check($uid, $item) { $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']); -/* $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; $forumpattern2 = '/\[zrl\=([^\]]*?)\]\!((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; @@ -3033,7 +3025,6 @@ function tgroup_check($uid, $item) { logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring'); continue; } -*/ return true; } diff --git a/include/text.php b/include/text.php index d7ffa5550..415a51790 100644 --- a/include/text.php +++ b/include/text.php @@ -1652,7 +1652,7 @@ function format_hashtags(&$item) { function format_mentions(&$item) { $s = ''; - $terms = isset($item['term']) ? get_terms_oftype($item['term'], TERM_MENTION) : []; + $terms = isset($item['term']) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_FORUM]) : []; if($terms) { foreach($terms as $t) { if(! isset($t['term'])) @@ -2876,7 +2876,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $termtype = ((strpos($tag,'#') === 0) ? TERM_HASHTAG : TERM_UNKNOWN); $termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype); -// $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype); + $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype); $termtype = ((strpos($tag,'#^[') === 0) ? TERM_BOOKMARK : $termtype); // Is it a hashtag of some kind? @@ -2943,7 +2943,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) // BEGIN mentions - if ($termtype === TERM_MENTION) { + if (in_array($termtype, [TERM_MENTION, TERM_FORUM])) { // The @! tag will alter permissions @@ -3051,8 +3051,15 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $profile = str_replace(',','%2c',$profile); $url = $profile; - $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + if($termtype === TERM_FORUM) { + $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; + $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + } + + if ($termtype === TERM_MENTION) { + $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; + $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + } // append tag to str_tags if(! stristr($str_tags,$newtag)) { @@ -3110,12 +3117,12 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) //create profile link $profile = str_replace(',','%2c',$profile); $url = $profile; -/* + if($termtype === TERM_FORUM) { $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } -*/ + if ($termtype === TERM_MENTION) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); -- cgit v1.2.3 From ec3ba87f3a6cb9cda5f094bb1e62ed6b746f087f Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Mar 2023 08:49:18 +0000 Subject: Revert "some work on bringing bang tags back for forums" This reverts commit da034045cc1bba74287b7c3e83f4a94ff5359150. --- include/items.php | 13 +++++++++++-- include/text.php | 21 +++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index d8f817fc2..b795df90d 100644 --- a/include/items.php +++ b/include/items.php @@ -2686,7 +2686,12 @@ function tag_deliver($uid, $item_id) { * Now we've got those out of the way. Let's see if this is a post that's tagged for re-delivery */ - $terms = isset($item['term']) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_FORUM]) : []; + $terms = []; + if (array_key_exists('term', $item)) { + $terms = array_merge(get_terms_oftype($item['term'],TERM_MENTION),get_terms_oftype($item['term'],TERM_FORUM)); + logger('Post mentions: ' . print_r($terms,true), LOGGER_DATA); + } + $max_forums = get_config('system','max_tagged_forums',2); $matched_forums = 0; @@ -2727,7 +2732,7 @@ function tag_deliver($uid, $item_id) { // standard forum tagging sequence !forumname - +/* $forumpattern = '/\!\!?\[[uz]rl\=([^\]]*?)\]((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/'; $forumpattern2 = '/\[[uz]rl\=([^\]]*?)\]\!((?:.(?!\[[uz]rl\=))*?)\[\/[uz]rl\]/'; @@ -2761,6 +2766,8 @@ function tag_deliver($uid, $item_id) { } } +*/ + if(! ($tagged || $plustagged)) { logger('Mention was in a reshare or exceeded max_tagged_forums - ignoring'); continue; @@ -2986,6 +2993,7 @@ function tgroup_check($uid, $item) { $body = preg_replace('/\[share(.*?)\[\/share\]/','',$item['body']); +/* $forumpattern = '/\!\!?\[zrl\=([^\]]*?)\]((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; $forumpattern2 = '/\[zrl\=([^\]]*?)\]\!((?:.(?!\[zrl\=))*?)\[\/zrl\]/'; @@ -3025,6 +3033,7 @@ function tgroup_check($uid, $item) { logger('tgroup_check: mention was in a reshare or exceeded max_tagged_forums - ignoring'); continue; } +*/ return true; } diff --git a/include/text.php b/include/text.php index 415a51790..d7ffa5550 100644 --- a/include/text.php +++ b/include/text.php @@ -1652,7 +1652,7 @@ function format_hashtags(&$item) { function format_mentions(&$item) { $s = ''; - $terms = isset($item['term']) ? get_terms_oftype($item['term'], [TERM_MENTION, TERM_FORUM]) : []; + $terms = isset($item['term']) ? get_terms_oftype($item['term'], TERM_MENTION) : []; if($terms) { foreach($terms as $t) { if(! isset($t['term'])) @@ -2876,7 +2876,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $termtype = ((strpos($tag,'#') === 0) ? TERM_HASHTAG : TERM_UNKNOWN); $termtype = ((strpos($tag,'@') === 0) ? TERM_MENTION : $termtype); - $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype); +// $termtype = ((strpos($tag,'!') === 0) ? TERM_FORUM : $termtype); $termtype = ((strpos($tag,'#^[') === 0) ? TERM_BOOKMARK : $termtype); // Is it a hashtag of some kind? @@ -2943,7 +2943,7 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) // BEGIN mentions - if (in_array($termtype, [TERM_MENTION, TERM_FORUM])) { + if ($termtype === TERM_MENTION) { // The @! tag will alter permissions @@ -3051,15 +3051,8 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $profile = str_replace(',','%2c',$profile); $url = $profile; - if($termtype === TERM_FORUM) { - $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body); - } - - if ($termtype === TERM_MENTION) { - $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); - } + $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; + $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); // append tag to str_tags if(! stristr($str_tags,$newtag)) { @@ -3117,12 +3110,12 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) //create profile link $profile = str_replace(',','%2c',$profile); $url = $profile; - +/* if($termtype === TERM_FORUM) { $newtag = '!' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; $body = str_replace('!' . (($exclusive) ? '!' : '') . $name, $newtag, $body); } - +*/ if ($termtype === TERM_MENTION) { $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); -- cgit v1.2.3 From dc6075aa3f91ad8e96f440f0569cfe5bd862b201 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Mar 2023 19:33:39 +0000 Subject: do not use zrl tag for non zot profiles and remove redundant foreach which was a leftover from zot to zot6 transition days --- include/text.php | 64 +++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index d7ffa5550..5dc894d11 100644 --- a/include/text.php +++ b/include/text.php @@ -3033,46 +3033,44 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) if($r) { - $xchan[0] = Libzot::zot_record_preferred($r, 'xchan_network'); - - foreach($xchan as $xc) { - $profile = $xc['xchan_url']; - $newname = $xc['xchan_name']; - // add the channel's xchan_hash to $access_tag if exclusive - if($exclusive) { - $access_tag = 'cid:' . $xc['xchan_hash']; - } + $xc = Libzot::zot_record_preferred($r, 'xchan_network'); - // if there is a url for this channel + $profile = $xc['xchan_url']; + $newname = $xc['xchan_name']; + // add the channel's xchan_hash to $access_tag if exclusive + if($exclusive) { + $access_tag = 'cid:' . $xc['xchan_hash']; + } - if(isset($profile)) { - $replaced = true; - //create profile link - $profile = str_replace(',','%2c',$profile); - $url = $profile; + // if there is a url for this channel - $newtag = '@' . (($exclusive) ? '!' : '') . '[zrl=' . $profile . ']' . $newname . '[/zrl]'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + if(isset($profile)) { + $replaced = true; + //create profile link + $profile = str_replace(',','%2c',$profile); + $url = $profile; + $bb_tag = (($xc['xchan_network'] === 'zot6') ? 'zrl' : 'url'); - // append tag to str_tags - if(! stristr($str_tags,$newtag)) { - if(strlen($str_tags)) - $str_tags .= ','; - $str_tags .= $newtag; - } - } + $newtag = '@' . (($exclusive) ? '!' : '') . '[' . $bb_tag . '=' . $profile . ']' . $newname . '[/' . $bb_tag . ']'; + $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + // append tag to str_tags + if(! stristr($str_tags,$newtag)) { + if(strlen($str_tags)) + $str_tags .= ','; + $str_tags .= $newtag; + } + } - $fn_results[] = [ - 'replaced' => $replaced, - 'termtype' => $termtype, - 'term' => $newname, - 'url' => $url, - 'access_tag' => $access_tag, - 'contact' => (($r) ? $xc : []), - ]; - } + $fn_results[] = [ + 'replaced' => $replaced, + 'termtype' => $termtype, + 'term' => $newname, + 'url' => $url, + 'access_tag' => $access_tag, + 'contact' => (($r) ? $xc : []), + ]; } else { -- cgit v1.2.3 From 234bb6425021b72f0db71667191b2c36dc593791 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Mar 2023 10:04:29 +0000 Subject: port totp mfa from streams with some adjustions --- include/auth.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index 125aedffd..de515489a 100644 --- a/include/auth.php +++ b/include/auth.php @@ -10,6 +10,7 @@ */ use Zotlabs\Lib\Libzot; +use Zotlabs\Lib\AConfig; require_once('include/api_auth.php'); require_once('include/security.php'); @@ -263,8 +264,16 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && App::$session->extend_cookie(); $login_refresh = true; } + + $multiFactor = AConfig::Get(App::$account['account_id'], 'system', 'mfa_enabled'); + if ($multiFactor && empty($_SESSION['2FA_VERIFIED']) && App::$module !== 'totp_check') { + $o = new Zotlabs\Module\Totp_check; + echo $o->get(true); + killme(); + } + $ch = (($_SESSION['uid']) ? channelx_by_n($_SESSION['uid']) : null); - authenticate_success($r[0], null, $ch, false, false, $login_refresh); + authenticate_success($r[0], $ch, false, false, $login_refresh); } else { $_SESSION['account_id'] = 0; -- cgit v1.2.3 From 2ffef2be8f6967c012be52efb6c21dd28878ee4c Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Mar 2023 10:18:32 +0000 Subject: minor cleanup --- include/auth.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index de515489a..0ea7b3dba 100644 --- a/include/auth.php +++ b/include/auth.php @@ -268,7 +268,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && $multiFactor = AConfig::Get(App::$account['account_id'], 'system', 'mfa_enabled'); if ($multiFactor && empty($_SESSION['2FA_VERIFIED']) && App::$module !== 'totp_check') { $o = new Zotlabs\Module\Totp_check; - echo $o->get(true); + echo $o->get(); killme(); } -- cgit v1.2.3 From 3de81877c6aaacfad993375bcf88b512958180ab Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 8 Mar 2023 13:15:33 +0000 Subject: more mfa cleanup --- include/auth.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/auth.php b/include/auth.php index 0ea7b3dba..5956b89e2 100644 --- a/include/auth.php +++ b/include/auth.php @@ -11,6 +11,7 @@ use Zotlabs\Lib\Libzot; use Zotlabs\Lib\AConfig; +use Zotlabs\Module\Totp_check; require_once('include/api_auth.php'); require_once('include/security.php'); @@ -267,7 +268,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) && $multiFactor = AConfig::Get(App::$account['account_id'], 'system', 'mfa_enabled'); if ($multiFactor && empty($_SESSION['2FA_VERIFIED']) && App::$module !== 'totp_check') { - $o = new Zotlabs\Module\Totp_check; + $o = new Totp_check; echo $o->get(); killme(); } -- cgit v1.2.3 From 38a1b791749a9cd8142e820231f84c4aee67998e Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Mar 2023 20:59:36 +0000 Subject: fix max_oembed_size check if content length header is an array (e.g. after a redirect with code 301) - fix issue #1727 --- include/oembed.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/oembed.php b/include/oembed.php index bcf5d525c..fbe6a573b 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -147,6 +147,7 @@ function oembed_fetch_url($embedurl){ $txt = Cache::get('[' . App::$videowidth . '] ' . $furl); } + if(strpos(strtolower($embedurl),'.pdf') !== false && get_config('system','inline_pdf')) { $action = 'allow'; $j = [ @@ -158,7 +159,6 @@ function oembed_fetch_url($embedurl){ // set $txt to something so that we don't attempt to fetch what could be a lengthy pdf. $txt = EMPTY_STR; } - if(is_null($txt)) { $txt = EMPTY_STR; @@ -177,12 +177,17 @@ function oembed_fetch_url($embedurl){ $headers = get_headers($furl, true); - if (isset($headers['Content-Length']) && $headers['Content-Length'] > $max_oembed_size) { - $action = 'block'; + if (isset($headers['Content-Length'])) { + $content_length = ((is_array($headers['Content-Length'])) ? array_key_last($headers['Content-Length']) : $headers['Content-Length']); + + if ($content_length > $max_oembed_size) { + $action = 'block'; + } } } if ($action !== 'block') { + // try oembed autodiscovery $redirects = 0; $result = z_fetch_url($furl, false, $redirects, -- cgit v1.2.3 From 63a861157993e78e85df10b8dc8292be5d24f5d1 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 12 Mar 2023 22:03:47 +0000 Subject: fix issue #1728 --- include/event.php | 4 ++-- include/text.php | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index b27504296..6273279c2 100644 --- a/include/event.php +++ b/include/event.php @@ -1389,8 +1389,8 @@ function event_store_item($arr, $event) { // 'summary' => bbcode($arr['summary']), // RFC3339 Section 4.3 'startTime' => (($arr['adjust']) ? datetime_convert('UTC', 'UTC', $arr['dtstart'], ATOM_TIME) : datetime_convert('UTC', 'UTC', $arr['dtstart'], 'Y-m-d\\TH:i:s-00:00')), - 'content' => bbcode($arr['description']), - 'location' => [ 'type' => 'Place', 'name' => bbcode($arr['location']) ], + 'content' => $arr['description'], + 'location' => [ 'type' => 'Place', 'name' => $arr['location'] ], 'source' => [ 'content' => format_event_bbcode($arr), 'mediaType' => 'text/bbcode' ], 'url' => [ [ 'mediaType' => 'text/calendar', 'href' => z_root() . '/events/ical/' . $event['event_hash'] ] ], 'actor' => Activity::encode_person($z, false), diff --git a/include/text.php b/include/text.php index 5dc894d11..705147e93 100644 --- a/include/text.php +++ b/include/text.php @@ -1795,7 +1795,6 @@ function prepare_body(&$item,$attach = false,$opts = false) { } $event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : []); - $prep_arr = [ 'item' => $item, 'html' => $event ? $event['content'] : $s, -- cgit v1.2.3 From 20735083b30b1572acd02594de1c9f758ac4958a Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 18 Mar 2023 14:52:25 +0000 Subject: update bb_parse_b64_crypt() --- include/bbcode.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/bbcode.php b/include/bbcode.php index 6ec24fa0b..735f267c3 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -295,9 +295,11 @@ function bb_parse_b64_crypt($match) { if(empty($match[2])) return; - $r .= '----- ENCRYPTED CONTENT -----' . PHP_EOL; - $r .= $match[2] . PHP_EOL; + $r .= ''; + $r .= '----- ENCRYPTED CONTENT -----' . '
'; + $r .= $match[2] . '
'; $r .= '----- END ENCRYPTED CONTENT -----'; + $r .= '
'; return $r; -- cgit v1.2.3