From c4af4e3297f09aa0c6f8ed8e21d6f54729ebfc4d Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Aug 2023 08:17:47 +0000 Subject: fix unable to create folders with name 0 --- include/attach.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index ead5a8e06..3060295b9 100644 --- a/include/attach.php +++ b/include/attach.php @@ -1180,7 +1180,7 @@ function attach_mkdir($channel, $observer_hash, $arr = null) { return $ret; } - if(! $arr['filename']) { + if(isset($arr['filename']) && !strlen($arr['filename'])) { $ret['message'] = t('Empty pathname'); return $ret; } -- cgit v1.2.3 From be19b7503105955b58c85dbec65c02626c9e5000 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 15 Aug 2023 12:05:50 +0000 Subject: make sure that we allow "0" as pathname --- include/attach.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/attach.php b/include/attach.php index 3060295b9..9baebe2a0 100644 --- a/include/attach.php +++ b/include/attach.php @@ -691,7 +691,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $type = $gis['mime']; } - $pathname = ''; + $pathname = null; if($source === 'photos') { if($newalbum) { @@ -708,7 +708,7 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) { $pathname = find_path_by_hash($channel['channel_id'], $arr['folder']); } - if(! $pathname) { + if($pathname === null) { $pathname = filepath_macro($upload_path); } -- cgit v1.2.3 From ce4150cd06a5eb3995592b7c3898d980a58d3dd6 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 19 Aug 2023 08:55:17 +0000 Subject: fix notification text for likes in cases where obj.actor is not set --- include/conversation.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index c02b0c4c8..5e63c4199 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -108,6 +108,8 @@ function localize_item(&$item){ $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); elseif (isset($obj['actor']) && is_string($obj['actor'])) $author_link = $obj['actor']; + elseif (isset($obj['attributedTo']) && is_string($obj['attributedTo']) && $obj['attributedTo']) + $author_link = $obj['attributedTo']; else $author_link = ''; @@ -123,6 +125,13 @@ function localize_item(&$item){ } } + if(!$author_name && isset($obj['attributedTo']) && is_string($obj['attributedTo'])) { + $cached_actor = Activity::get_cached_actor($obj['attributedTo']); + if (is_array($cached_actor)) { + $author_name = $cached_actor['name'] ?? $cached_actor['preferredUsername']; + } + } + $item_url = ''; if(isset($obj['link']) && is_array($obj['link'])) $item_url = get_rel_link($obj['link'],'alternate'); -- cgit v1.2.3 From 1426b7a6dc56250bc528c21028975ac9d68a2d95 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 27 Aug 2023 20:29:30 +0000 Subject: order by hubloc_id like everywhere else for this reason and do not include deleted hublocs --- 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 2e8aefaaa..50cd77d6c 100644 --- a/include/channel.php +++ b/include/channel.php @@ -1937,7 +1937,7 @@ function zid_init() { call_hooks('zid_init', $arr); if(! local_channel()) { - $r = q("select hubloc_url, hubloc_hash, hubloc_network 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' and hubloc_deleted = 0 order by hubloc_id desc", dbesc($tmp_str) ); if(! $r) { -- cgit v1.2.3 From 0e8ecbc9fc108b4903eb013ca0a4a1f4beb5fbe1 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 10 Sep 2023 08:00:18 +0000 Subject: theme fixes to make a barebones theme work slightly better --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 31a447a84..18fa65edc 100644 --- a/include/nav.php +++ b/include/nav.php @@ -85,7 +85,7 @@ function nav($template = 'default') { if ($observer) { $userinfo = [ - 'icon' => $observer['xchan_photo_m'] . '?rev=' . strtotime($observer['xchan_photo_date']), + 'icon' => $observer['xchan_photo_s'] . '?rev=' . strtotime($observer['xchan_photo_date']), 'addr' => $observer['xchan_addr'], 'name' => $observer['xchan_name'], ]; -- cgit v1.2.3 From 0cb5d0d63e3150331999c51c5807603d74b7d4dc Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 14 Sep 2023 12:30:14 +0000 Subject: also look for widgets in view/theme/themename/widget --- include/plugin.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index ae73a847c..648e1953c 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -1074,6 +1074,7 @@ function theme_include($file, $root = '') { $paths = array( "{$root}view/theme/$thname/$ext/$file", + "{$root}view/theme/$thname/widget/$file", "{$root}view/theme/$parent/$ext/$file", "{$root}view/site/$ext/$file", "{$root}view/$ext/$file", -- cgit v1.2.3 From 198070700c3f087b97e431ea64ae6845db8f4062 Mon Sep 17 00:00:00 2001 From: "System user; apache" Date: Fri, 15 Sep 2023 15:28:13 +0200 Subject: only select the required fields to prevent memory exhaustion on big result sets (cherry picked from commit 3a01aa40d8f788c89f50f9893214f6591dac7bae) --- include/items.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index d88a676a1..57e5dbb96 100644 --- a/include/items.php +++ b/include/items.php @@ -3920,16 +3920,19 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) { $notify_id = intval($item['id']); - $items = q("select * from item where parent = %d and uid = %d", + $items = q("select id, resource_id, uid, resource_type, mid from item where parent = %d and uid = %d", intval($item['id']), intval($item['uid']) ); + if($items) { - foreach($items as $i) + foreach($items as $i) { delete_item_lowlevel($i, $stage); + } } - else + else { delete_item_lowlevel($item, $stage); + } if(! $interactive) return 1; -- cgit v1.2.3 From 3708c1ac8c60c500e3aa15450380fe657f1dd24a Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 16 Sep 2023 10:51:28 +0000 Subject: fix regression in jsonld_document_loader() --- include/network.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/network.php b/include/network.php index ec3474a41..c95ae90a1 100644 --- a/include/network.php +++ b/include/network.php @@ -2093,9 +2093,7 @@ function jsonld_document_loader($url) { if (file_exists($filename) && filemtime($filename) > time() - (12 * 60 * 60)) { logger('loading ' . $filename . ' from recent cache'); - - $doc->document = file_get_contents($filename); - return $doc; + return file_get_contents($filename); } $r = jsonld_default_document_loader($url); @@ -2112,8 +2110,7 @@ function jsonld_document_loader($url) { if (file_exists($filename)) { logger('loading ' . $filename . ' from longterm cache'); - $doc->document = file_get_contents($filename); - return $doc; + return file_get_contents($filename); } else { logger($filename . ' does not exist and cannot be loaded'); -- cgit v1.2.3 From d88c67eba37569a95691bc967046eed318e39b46 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 20 Sep 2023 10:45:33 +0000 Subject: deprecate the ancient $a variable --- include/plugin.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index 648e1953c..1a253d38f 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -500,8 +500,6 @@ function call_hooks($name, &$data = null) { $func = $hook[1]; if($hook[3]) $func($data); - else - $func($a, $data); } else { -- cgit v1.2.3 From 601ee0b40b4de7a27cb72341c058124d6f19a1f5 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 08:31:53 +0000 Subject: only show theme switch icon if switching is supported by the theme --- include/nav.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 18fa65edc..737beaca2 100644 --- a/include/nav.php +++ b/include/nav.php @@ -201,7 +201,10 @@ 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'); + $theme_switch_icon = ''; + if (isset(App::$page['color_mode'])) { + $theme_switch_icon = ((App::$page['color_mode'] === 'dark') ? 'sun' : 'moon'); + } $x = ['nav' => $nav, 'usermenu' => $userinfo]; -- cgit v1.2.3 From 150174c3bb5578e0dfc20ac97a061d170fc90f5a Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 08:33:17 +0000 Subject: jsonld: return object instead of json string --- 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 c95ae90a1..13339eccd 100644 --- a/include/network.php +++ b/include/network.php @@ -2084,7 +2084,7 @@ function jsonld_document_loader($url) { } } - $cachepath = 'store/[data]/ldcache'; + $cachepath = 'store/[data]/[jsonld]'; if(!is_dir($cachepath)) { os_mkdir($cachepath, STORAGE_DEFAULT_PERMISSIONS, true); } @@ -2093,7 +2093,7 @@ function jsonld_document_loader($url) { if (file_exists($filename) && filemtime($filename) > time() - (12 * 60 * 60)) { logger('loading ' . $filename . ' from recent cache'); - return file_get_contents($filename); + return json_decode(file_get_contents($filename)); } $r = jsonld_default_document_loader($url); @@ -2110,7 +2110,7 @@ function jsonld_document_loader($url) { if (file_exists($filename)) { logger('loading ' . $filename . ' from longterm cache'); - return file_get_contents($filename); + return json_decode(file_get_contents($filename)); } else { logger($filename . ' does not exist and cannot be loaded'); -- cgit v1.2.3 From a5e32dc3de997c3a3d9046161ce1ec149abb65c1 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 21 Sep 2023 08:34:02 +0000 Subject: more deprecate $a --- include/conversation.php | 6 +++--- include/text.php | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 5e63c4199..f8d5f7ec0 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1306,11 +1306,11 @@ function format_like($cnt, $arr, $type, $id) { /** * Wrapper to allow addons to replace the status editor if desired. */ -function status_editor($a, $x, $popup = false, $module='') { +function status_editor($x, $popup = false, $module='') { $hook_info = ['editor_html' => '', 'x' => $x, 'popup' => $popup, 'module' => $module]; call_hooks('status_editor',$hook_info); if ($hook_info['editor_html'] == '') { - return hz_status_editor($a, $x, $popup); + return hz_status_editor($x, $popup); } else { return $hook_info['editor_html']; } @@ -1322,7 +1322,7 @@ function status_editor($a, $x, $popup = false, $module='') { * They are referring to the content editor or components thereof. */ -function hz_status_editor($a, $x, $popup = false) { +function hz_status_editor($x, $popup = false) { $o = ''; diff --git a/include/text.php b/include/text.php index 6ab8fc1ce..4088e85e1 100644 --- a/include/text.php +++ b/include/text.php @@ -528,9 +528,8 @@ function unxmlify($s) { * will limit the results to the correct items for the current page. * The actual page handling is then accomplished at the application layer. * - * @param App &$a */ -function paginate(&$a) { +function paginate() { $o = ''; $stripped = preg_replace('/(&page=[0-9]*)/','',App::$query_string); -- cgit v1.2.3 From d1421d720c3f8ae9a7c409423fcbea4ff8132676 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 4 Oct 2023 20:11:05 +0200 Subject: parse the event object in first place and use the body bbcode as backup --- include/event.php | 124 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 82 insertions(+), 42 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 894a1e4f7..745469064 100644 --- a/include/event.php +++ b/include/event.php @@ -9,6 +9,7 @@ use Sabre\VObject; use Zotlabs\Lib\Activity; use Zotlabs\Lib\Libsync; +use Zotlabs\Access\AccessList; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; @@ -718,56 +719,95 @@ function event_addtocal($item_id, $uid) { $item = $r[0]; - $ev = bbtoevent($r[0]['body']); + $ev = parse_event_object($item['obj']); - if(x($ev,'summary') && x($ev,'dtstart')) { - $ev['event_xchan'] = $item['author_xchan']; - $ev['uid'] = $channel['channel_id']; - $ev['account'] = $channel['channel_account_id']; - $ev['edited'] = $item['edited']; - $ev['mid'] = $item['mid']; - $ev['private'] = $item['item_private']; + // if we could not parse the object, parse try to parse the body bbcode + if (!$ev) { + $ev = bbtoevent($item['body']); + } - // is this an edit? + if (!$ev) { + return false; + } - if($item['resource_type'] === 'event' && (! $ev['event_hash'])) { - $ev['event_hash'] = $item['resource_id']; - } + $ev['event_xchan'] = $item['author_xchan']; + $ev['uid'] = $channel['channel_id']; + $ev['account'] = $channel['channel_account_id']; + $ev['edited'] = $item['edited']; + $ev['mid'] = $item['mid']; + $ev['private'] = $item['item_private']; - if($ev['private']) - $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; - else { - $acl = new Zotlabs\Access\AccessList($channel); - $x = $acl->get(); - $ev['allow_cid'] = $x['allow_cid']; - $ev['allow_gid'] = $x['allow_gid']; - $ev['deny_cid'] = $x['deny_cid']; - $ev['deny_gid'] = $x['deny_gid']; - } + if($item['resource_type'] === 'event' && (! $ev['event_hash'])) { + $ev['event_hash'] = $item['resource_id']; + } - $event = event_store_event($ev); - if($event) { - $r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d", - dbesc($event['event_hash']), - intval($item['id']), - intval($channel['channel_id']) - ); + if($ev['private']) { + $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; + $ev['allow_gid'] = ''; + $ev['deny_cid'] = ''; + $ev['deny_gid'] = ''; + } + else { + $acl = new AccessList($channel); + $x = $acl->get(); + $ev['allow_cid'] = $x['allow_cid']; + $ev['allow_gid'] = $x['allow_gid']; + $ev['deny_cid'] = $x['deny_cid']; + $ev['deny_gid'] = $x['deny_gid']; + } - $item['resource_id'] = $event['event_hash']; - $item['resource_type'] = 'event'; + $event = event_store_event($ev); + if($event) { + $r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d", + dbesc($event['event_hash']), + intval($item['id']), + intval($channel['channel_id']) + ); - $i = array($item); - xchan_query($i); - $sync_item = fetch_post_tags($i); - $z = q("select * from event where event_hash = '%s' and uid = %d limit 1", - dbesc($event['event_hash']), - intval($channel['channel_id']) - ); - if($z) { - Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); - } - return true; + $item['resource_id'] = $event['event_hash']; + $item['resource_type'] = 'event'; + + $i = [$item]; + + xchan_query($i); + $sync_item = fetch_post_tags($i); + + $z = q("select * from event where event_hash = '%s' and uid = %d limit 1", + dbesc($event['event_hash']), + intval($channel['channel_id']) + ); + + if($z) { + libsync::build_sync_packet($channel['channel_id'], ['event_item' => [encode_item($sync_item[0], true)], 'event' => $z]); } + + return true; + } + +} + +function parse_event_object($event_object_json) { + + $object = json_decode($event_object_json, true); + + $tz = $object['timezone'] ?? 'UTC'; + + $ev['summary'] = $object['summary'] ?? $object['name'] ?? ''; + $ev['description'] = html2bbcode($content['content']) ?? ''; + $ev['dtstart'] = $object['startTime'] ? datetime_convert('UTC', 'UTC', $object['startTime']) : ''; + $ev['dtend'] = $object['endTime'] ? datetime_convert('UTC', 'UTC', $object['endTime']) : $ev['dtstart']; + $ev['location'] = $object['location']['name'] ?? ''; + $ev['event_hash'] = $object['uuid'] ?? $object['diaspora:guid'] ?? uuid_from_url($object['id']); + $ev['timezone'] = $tz; + $ev['adjust'] = (strpos($object['startTime'], 'Z') !== false || !empty($object['dfrn:adjust']) || $tz !== 'UTC'); + + $ev['nofinish'] = 0; + if($ev['dtend'] === $ev['dtstart']) { + $ev['nofinish'] = 1; + } + + if ($ev['summary'] && $ev['dtstart']) { + return $ev; } return false; -- cgit v1.2.3 From 2f2e353ecef52639a78cac3bc407ccfe64197ac9 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 7 Oct 2023 16:00:34 +0000 Subject: use new lang detect library which supports much more languages --- include/help.php | 9 +++++---- include/language.php | 45 +++++++++++++++++---------------------------- 2 files changed, 22 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/help.php b/include/help.php index 8a913578a..9e4be57f9 100644 --- a/include/help.php +++ b/include/help.php @@ -1,6 +1,7 @@ setNameMode(2); - if($lang_detect->languageExists(argv(1))) { + $language_repository = new LanguageRepository; + $languages = $language_repository->getList(); + + if(array_key_exists(argv(1), $languages)) { $lang = argv(1); $from_url = true; } else { diff --git a/include/language.php b/include/language.php index d84f02a36..1b2e7332e 100644 --- a/include/language.php +++ b/include/language.php @@ -9,6 +9,7 @@ */ use CommerceGuys\Intl\Language\LanguageRepository; +use LanguageDetection\Language; /** * @brief Get the browser's submitted preferred languages. @@ -299,14 +300,10 @@ function string_plural_select_default($n) { /** * @brief Takes a string and tries to identify the language. * - * It uses the pear library Text_LanguageDetect and it can identify 52 human languages. - * It returns the identified languges and a confidence score for each. - * * Strings need to have a min length config['system']['language_detect_min_length'] * and you can influence the confidence that must be met before a result will get * returned through config['system']['language_detect_min_confidence']. * - * @see http://pear.php.net/package/Text_LanguageDetect * @param string $s A string to examine * @return string Language code in 2-letter ISO 639-1 (en, de, fr) format */ @@ -316,43 +313,35 @@ function detect_language($s) { return EMPTY_STR; } - $min_length = get_config('system', 'language_detect_min_length'); - if ($min_length === false) - $min_length = LANGUAGE_DETECT_MIN_LENGTH; - - $min_confidence = get_config('system', 'language_detect_min_confidence'); - if ($min_confidence === false) - $min_confidence = LANGUAGE_DETECT_MIN_CONFIDENCE; + $min_length = get_config('system', 'language_detect_min_length', LANGUAGE_DETECT_MIN_LENGTH); + $min_confidence = get_config('system', 'language_detect_min_confidence', LANGUAGE_DETECT_MIN_CONFIDENCE); // embedded apps have long base64 strings which will trip up the detector. $naked_body = preg_replace('/\[app\](.*?)\[\/app\]/', '', $s); + // strip off bbcode $naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body); + + // strip any links + $naked_body = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i', '', $naked_body); + if (mb_strlen($naked_body) < intval($min_length)) { logger('string length less than ' . intval($min_length), LOGGER_DATA); - return ''; + return EMPTY_STR; } - $l = new Text_LanguageDetect; - try { - // return 2-letter ISO 639-1 (en) language code - $l->setNameMode(2); - $lng = $l->detectConfidence($naked_body); - logger('detect language: ' . print_r($lng, true) . $naked_body, LOGGER_DATA); - } catch (Text_LanguageDetect_Exception $e) { - logger('detect language exception: ' . $e->getMessage(), LOGGER_DATA); - } + $lang = new Language; + $lang_arr = $lang->detect($naked_body)->limit(0, 1)->close(); - if ((! $lng) || (! (x($lng,'language')))) { - return ''; + $confidence = reset($lang_arr); + if ($confidence >= intval($min_confidence)) { + logger('detect language: ' . print_r($lang_arr, true) . $naked_body, LOGGER_DATA); + return key($lang_arr); } - if ($lng['confidence'] < (float) $min_confidence) { - logger('detect language: confidence less than ' . (float) $min_confidence, LOGGER_DATA); - return ''; - } + logger('detect language: confidence less than ' . $min_confidence, LOGGER_DATA); - return($lng['language']); + return EMPTY_STR; } /** -- cgit v1.2.3 From ca92dd02994b60c351efe7801bef0eeba2b9a9e9 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 7 Nov 2023 08:30:27 +0000 Subject: bbcode: do not overrule default list style --- 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 735f267c3..e0a0fe9a1 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1446,14 +1446,14 @@ function bbcode($Text, $options = []) { ((strpos($Text, "[/ul]") !== false) && (strpos($Text, "[ul]") !== false)) || ((strpos($Text, "[/dl]") !== false) && (strpos($Text, "[dl") !== false)) || ((strpos($Text, "[/li]") !== false) && (strpos($Text, "[li]") !== false))) && (++$endlessloop < 20)) { - $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '
    $1
', $Text); + $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '
    $1
', $Text); $Text = preg_replace("/\[list=\](.*?)\[\/list\]/ism", '
    $1
', $Text); $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '
    $1
', $Text); $Text = preg_replace("/\[list=((?-i)i)\](.*?)\[\/list\]/ism",'
    $2
', $Text); $Text = preg_replace("/\[list=((?-i)I)\](.*?)\[\/list\]/ism", '
    $2
', $Text); $Text = preg_replace("/\[list=((?-i)a)\](.*?)\[\/list\]/ism", '
    $2
', $Text); $Text = preg_replace("/\[list=((?-i)A)\](.*?)\[\/list\]/ism", '
    $2
', $Text); - $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '
    $1
', $Text); + $Text = preg_replace("/\[ul\](.*?)\[\/ul\]/ism", '
    $1
', $Text); $Text = preg_replace("/\[ol\](.*?)\[\/ol\]/ism", '
    $1
', $Text); $Text = preg_replace("/\[\/li\]
\[li\]/ism",'[/li][li]',$Text); $Text = preg_replace("/\[li\](.*?)\[\/li\]/ism", '
  • $1
  • ', $Text); -- cgit v1.2.3 From 85d8c1a97eec7fe40c6ea4b9ee895897d54a38c6 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Nov 2023 19:32:29 +0000 Subject: some low level work on native repeats --- 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 57e5dbb96..6cef3d2cd 100644 --- a/include/items.php +++ b/include/items.php @@ -353,12 +353,13 @@ function can_comment_on_post($observer_xchan, $item) { case 'specific': case 'contacts': case '': - if(local_channel() && get_abconfig(local_channel(),$item['owner_xchan'],'their_perms','post_comments')) { + if(local_channel() && get_abconfig(local_channel(), (($item['verb'] === ACTIVITY_SHARE) ? $item['author_xchan'] : $item['owner_xchan']), 'their_perms', 'post_comments')) { return true; } if(intval($item['item_wall']) && perm_is_allowed($item['uid'],$observer_xchan,'post_comments')) { return true; } + break; default: -- cgit v1.2.3 From 1063a67ae26be8fcd251eb8498a70f2163ebb094 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Nov 2023 21:37:28 +0000 Subject: a possible fix for issue #1816 --- include/text.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 4088e85e1..27dd94bc5 100644 --- a/include/text.php +++ b/include/text.php @@ -894,6 +894,7 @@ function get_tags($s) { // ignore anything in [style= ] $s = preg_replace('/\[style=(.*?)\]/sm','',$s); + // ignore anything in [color= ], because it may contain color codes which are mistaken for tags $s = preg_replace('/\[color=(.*?)\]/sm','',$s); @@ -3061,7 +3062,10 @@ function handle_tag(&$body, &$str_tags, $profile_uid, $tag, $in_network = true) $bb_tag = (($xc['xchan_network'] === 'zot6') ? 'zrl' : 'url'); $newtag = '@' . (($exclusive) ? '!' : '') . '[' . $bb_tag . '=' . $profile . ']' . $newname . '[/' . $bb_tag . ']'; - $body = str_replace('@' . (($exclusive) ? '!' : '') . $name, $newtag, $body); + + // Replace tag but make sure to not replace something in the middle of a word + $body = preg_replace('/(? Date: Mon, 20 Nov 2023 19:22:06 +0000 Subject: do not provide channel info for templates --- include/channel.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index 50cd77d6c..dc164eba1 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2397,8 +2397,12 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { // $scale = (float) $maxwidth / $width; // $translate = intval(($scale / 1.0) * 100); - $channel['channel_addr'] = channel_reddress($channel); - $zcard = array('chan' => $channel); + $zcard = [ + 'chan' => [ + 'xchan_name' => $channel['xchan_name'], + 'channel_addr' => channel_reddress($channel) + ] + ]; $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel['channel_id']), -- cgit v1.2.3 From febebc8d3da6a77d8c71dc31c364b7b1a6cf0c84 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Nov 2023 20:21:03 +0000 Subject: more do not provide channel info for templates and code cleanup --- include/channel.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/channel.php b/include/channel.php index dc164eba1..640274348 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2397,11 +2397,10 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { // $scale = (float) $maxwidth / $width; // $translate = intval(($scale / 1.0) * 100); - $zcard = [ - 'chan' => [ - 'xchan_name' => $channel['xchan_name'], - 'channel_addr' => channel_reddress($channel) - ] + $zcard['chan'] = [ + 'xchan_name' => $channel['xchan_name'], + 'xchan_url' => $channel['xchan_url'], + 'xchan_addr' => $channel['xchan_addr'] ]; $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", @@ -2474,8 +2473,11 @@ function get_zcard_embed($channel, $observer_hash = '', $args = array()) { $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); } - $channel['channel_addr'] = channel_reddress($channel); - $zcard = array('chan' => $channel); + $zcard['chan'] = [ + 'xchan_name' => $channel['xchan_name'], + 'xchan_url' => $channel['xchan_url'], + 'xchan_addr' => $channel['xchan_addr'] + ]; $r = q("select height, width, resource_id, imgscale, mimetype from photo where uid = %d and imgscale = %d and photo_usage = %d", intval($channel['channel_id']), -- cgit v1.2.3 From cfdbf02e6b4901850287d096b97fb38dbf5779d9 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Nov 2023 21:52:40 +0000 Subject: the additional parameter has been deprecated there is no need to check the version anymore --- include/plugin.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index 1a253d38f..eb761dc37 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -482,9 +482,13 @@ function call_hooks($name, &$data = null) { } $data = $checkhook['data']; } + $origfn = $hook[1]; - if($hook[0]) + + if($hook[0]) { @include_once($hook[0]); + } + if(preg_match('|^a:[0-9]+:{.*}$|s', $hook[1])) { $hook[1] = unserialize($hook[1]); } @@ -496,13 +500,12 @@ function call_hooks($name, &$data = null) { $hook[1] = explode('::',$hook[1]); } + if(is_callable($hook[1])) { $func = $hook[1]; - if($hook[3]) - $func($data); + $func($data); } else { - // Don't do any DB write calls if we're currently logging a possibly failed DB call. if(! DBA::$logging) { // The hook should be removed so we don't process it. -- cgit v1.2.3 From 33cb429e151766ec6cee7d050def380c487d88e0 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Nov 2023 21:56:31 +0000 Subject: remove unused variable --- include/plugin.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/plugin.php b/include/plugin.php index eb761dc37..f1d501001 100644 --- a/include/plugin.php +++ b/include/plugin.php @@ -459,8 +459,6 @@ function insert_hook($hook, $fn, $version = 0, $priority = 0) { * @param[in,out] string|array &$data to transmit to the callback handler */ function call_hooks($name, &$data = null) { - $a = 0; - if (isset(App::$hooks[$name])) { foreach(App::$hooks[$name] as $hook) { -- cgit v1.2.3 From 1f18fed3a26fb1b88efb83ab1b0ce2b19ea433f4 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Nov 2023 08:01:03 +0000 Subject: add additional observer and channel info to nav if applicable --- include/nav.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 737beaca2..9c67ade1f 100644 --- a/include/nav.php +++ b/include/nav.php @@ -21,7 +21,7 @@ function nav($template = 'default') { $is_owner = (((local_channel()) && ((App::$profile_uid == local_channel()) || (App::$profile_uid == 0))) ? true : false); $observer = App::get_observer(); $chans = []; - + $channel = []; if (local_channel()) { $channel = App::get_channel(); @@ -84,11 +84,23 @@ function nav($template = 'default') { $userinfo = []; if ($observer) { - $userinfo = [ - 'icon' => $observer['xchan_photo_s'] . '?rev=' . strtotime($observer['xchan_photo_date']), - 'addr' => $observer['xchan_addr'], - 'name' => $observer['xchan_name'], - ]; + $userinfo['icon'] = $observer['xchan_photo_s'] . '?rev=' . strtotime($observer['xchan_photo_date']); + $userinfo['icon_m'] = $observer['xchan_photo_m'] . '?rev=' . strtotime($observer['xchan_photo_date']); + $userinfo['icon_l'] = $observer['xchan_photo_l'] . '?rev=' . strtotime($observer['xchan_photo_date']); + $userinfo['icon_mime_type'] = $observer['xchan_photo_mimetype']; + $userinfo['addr'] = $observer['xchan_addr']; + $userinfo['url'] = $observer['xchan_url']; + $userinfo['forum'] = $observer['xchan_pubforum']; + $userinfo['name'] = $observer['xchan_name']; + } + + if ($channel) { + $userinfo['follow'] = sprintf($channel['xchan_follow'], urlencode(channel_reddress($channel))); + $userinfo['id'] = $channel['channel_id']; + $userinfo['nick'] = $channel['channel_address']; + $userinfo['location'] = $channel['channel_location']; + $userinfo['theme'] = $channel['channel_theme']; + $userinfo['timezone'] = $channel['channel_timezone']; } elseif (empty($_SESSION['authenticated'])) { -- cgit v1.2.3 From 1cfa81450cf0ce5691cdbade0a7ab4dfd76ea483 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 21 Nov 2023 08:07:40 +0000 Subject: remove follow (does not make any sense to add follow link of the logged in channel), add startpage --- include/nav.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 9c67ade1f..e4df7e4e5 100644 --- a/include/nav.php +++ b/include/nav.php @@ -95,12 +95,12 @@ function nav($template = 'default') { } if ($channel) { - $userinfo['follow'] = sprintf($channel['xchan_follow'], urlencode(channel_reddress($channel))); $userinfo['id'] = $channel['channel_id']; $userinfo['nick'] = $channel['channel_address']; $userinfo['location'] = $channel['channel_location']; $userinfo['theme'] = $channel['channel_theme']; $userinfo['timezone'] = $channel['channel_timezone']; + $userinfo['startpage'] = $channel['channel_startpage']; } elseif (empty($_SESSION['authenticated'])) { -- cgit v1.2.3 From 1e4e59bb5750a1b7f4a8458e0d8b6b2a34e5edeb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 8 Dec 2023 18:02:54 +0100 Subject: if it is not an array do not attempt count() --- include/taxonomy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/taxonomy.php b/include/taxonomy.php index 3f6db50d1..cfec8414a 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -122,7 +122,7 @@ function store_item_tag($uid,$iid,$otype,$type,$term,$url = '') { function get_terms_oftype($arr, $type) { $ret = []; - if(!is_array($arr) && count($arr)) + if(!is_array($arr)) return $ret; if(! is_array($type)) -- cgit v1.2.3