From 7e0416ac97ad90bd34c7e9a60a8370d23f3891b9 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 19:05:03 +0000 Subject: Remove unusable variable $sql_query --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index ee360dac5..87697f5a7 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -180,7 +180,7 @@ class Photo extends \Zotlabs\Web\Controller { $channel = channelx_by_n($r[0]['uid']); // Now we'll see if we can access the photo - $e = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d $sql_extra LIMIT 1", + $e = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) ); -- cgit v1.2.3 From e4512842561cf1a6b6e482085c27a77aac20b59a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 19:35:45 +0000 Subject: Check if port in the site URL provided --- Zotlabs/Lib/Activity.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5fefb2979..f8f312c7c 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -104,7 +104,10 @@ class Activity { if ($x['success']) { $m = parse_url($url); if ($m) { - $site_url = unparse_url(['scheme' => $m['scheme'], 'host' => $m['host'], 'port' => $m['port'] ]); + $y = [ 'scheme' => $m['scheme'], 'host' => $m['host'] ]; + if (array_key_exists('port', $m)) + $y['port'] = $m['port']; + $site_url = unparse_url($y); q("UPDATE site SET site_update = '%s', site_dead = 0 WHERE site_url = '%s' AND site_update < %s - INTERVAL %s", dbesc(datetime_convert()), dbesc($site_url), -- cgit v1.2.3 From c2adf1dcd16c6bb71798141212e80310adf5a03d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 19:40:40 +0000 Subject: Check if 'attach' and 'iconfig' array are defined --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index f8f312c7c..8df76b5bf 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -641,7 +641,7 @@ class Activity { $ret = []; - if ($item['attach']) { + if (array_key_exists('attach', $item)) { $atts = ((is_array($item['attach'])) ? $item['attach'] : json_decode($item['attach'], true)); if ($atts) { foreach ($atts as $att) { @@ -654,7 +654,7 @@ class Activity { } } } - if ($item['iconfig']) { + if (array_key_exists('iconfig', $item) && is_array($item['iconfig'])) { foreach ($item['iconfig'] as $att) { if ($att['sharing']) { $value = ((is_string($att['v']) && preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']); -- cgit v1.2.3 From f62b294a72a3f0a9b482cadabc01669483992fc9 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 19:46:27 +0000 Subject: Check if terms are defined as array for item --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 8df76b5bf..dcfd3896e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -610,7 +610,7 @@ class Activity { $ret = []; - if ($item['term']) { + if (array_key_exists('term', $item) && is_array($item['term'])) { foreach ($item['term'] as $t) { switch ($t['ttype']) { case TERM_HASHTAG: -- cgit v1.2.3 From 4bcd093befaf5a1b4ee483e5d324bac1c6e57f2d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 19:50:55 +0000 Subject: Check for attachments in item --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index dcfd3896e..1963090cf 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -698,7 +698,7 @@ class Activity { $ret = []; - if ($item['attachment']) { + if (array_key_exists('attachment', $item) && is_array($item['attachment'])) { foreach ($item['attachment'] as $att) { $entry = []; if ($att['href']) -- cgit v1.2.3 From 956aec14482bf069d7f73797c7ce364eda428e72 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:00:59 +0000 Subject: Check if item have a mention --- Zotlabs/Lib/Activity.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1963090cf..5730da934 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -980,19 +980,17 @@ class Activity { // Returns an array of URLS for any mention tags found in the item array $i. static function map_mentions($i) { - if (!$i['term']) { - return []; - } - $list = []; - foreach ($i['term'] as $t) { - if (!$t['url']) { - continue; - } - if ($t['ttype'] == TERM_MENTION) { - $url = self::lookup_term_url($t['url']); - $list[] = (($url) ? $url : $t['url']); + if (array_key_exists('term', $i) && is_array($i['term'])) { + foreach ($i['term'] as $t) { + if (!$t['url']) { + continue; + } + if ($t['ttype'] == TERM_MENTION) { + $url = self::lookup_term_url($t['url']); + $list[] = (($url) ? $url : $t['url']); + } } } -- cgit v1.2.3 From 360ae9080e85f565bd0925c3eb80ce5f757acd5f Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:06:36 +0000 Subject: Fix actor store warnings on non defined properties --- Zotlabs/Lib/Activity.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 5730da934..d535ad241 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1602,13 +1602,13 @@ class Activity { if ($inbox) { $collections['inbox'] = $inbox; - if ($person_obj['outbox']) + if (array_key_exists('outbox', $person_obj)) $collections['outbox'] = $person_obj['outbox']; - if ($person_obj['followers']) + if (array_key_exists('followers', $person_obj)) $collections['followers'] = $person_obj['followers']; - if ($person_obj['following']) + if (array_key_exists('following', $person_obj)) $collections['following'] = $person_obj['following']; - if ($person_obj['endpoints'] && $person_obj['endpoints']['sharedInbox']) + if (array_key_exists('endpoints', $person_obj) && array_key_exists('sharedInbox', $person_obj['endpoints'])) $collections['sharedInbox'] = $person_obj['endpoints']['sharedInbox']; } -- cgit v1.2.3 From 4afddabe15b03115e744e83e39da863035bc6d5a Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:09:49 +0000 Subject: Fix missed tag warning on decode taxonomy --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d535ad241..de8f881d0 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -573,7 +573,7 @@ class Activity { $ret = []; - if ($item['tag'] && is_array($item['tag'])) { + if (array_key_exists('tag', $item) && is_array($item['tag'])) { $ptr = $item['tag']; if (!array_key_exists(0, $ptr)) { $ptr = [$ptr]; -- cgit v1.2.3 From 88b63534653d3d3da3de6cc1c6db26efddbdd7fb Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:13:08 +0000 Subject: More checks on attachments decode --- Zotlabs/Lib/Activity.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index de8f881d0..1afd2780d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -701,13 +701,13 @@ class Activity { if (array_key_exists('attachment', $item) && is_array($item['attachment'])) { foreach ($item['attachment'] as $att) { $entry = []; - if ($att['href']) + if (array_key_exists('href', $att)) $entry['href'] = $att['href']; - elseif ($att['url']) + elseif (array_key_exists('url', $att)) $entry['href'] = $att['url']; - if ($att['mediaType']) + if (array_key_exists('mediaType', $att)) $entry['type'] = $att['mediaType']; - elseif ($att['type'] === 'Image') + elseif (array_key_exists('type', $att) && $att['type'] === 'Image') $entry['type'] = 'image/jpeg'; if ($entry) $ret[] = $entry; -- cgit v1.2.3 From c8fe56e57d22373f34ebc62849ffcd74dc08fd09 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:30:14 +0000 Subject: Check if oStatus conversation exists --- Zotlabs/Lib/Activity.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1afd2780d..27fd4906e 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2717,7 +2717,7 @@ class Activity { } } - if ($act->obj['conversation']) { + if (array_key_exists('conversation', $act->obj)) { set_iconfig($item, 'ostatus', 'conversation', $act->obj['conversation'], 1); } -- cgit v1.2.3 From 5d82bf946e10ce2bc29935977b17987a3bb84b07 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:35:03 +0000 Subject: Check if properties were provided on taxonomy decode --- Zotlabs/Lib/Activity.php | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 27fd4906e..d28f5631d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -582,23 +582,25 @@ class Activity { if (!array_key_exists('type', $t)) $t['type'] = 'Hashtag'; - switch ($t['type']) { - case 'Hashtag': - $ret[] = ['ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '#') ? substr($t['name'], 1) : $t['name'])]; - break; + if (array_key_exists('href', $t) && array_key_exists('name', $t)) { + switch ($t['type']) { + case 'Hashtag': + $ret[] = ['ttype' => TERM_HASHTAG, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '#') ? substr($t['name'], 1) : $t['name'])]; + break; - case 'Mention': - $mention_type = substr($t['name'], 0, 1); - if ($mention_type === '!') { - $ret[] = ['ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'], 1))]; - } - else { - $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '@') ? substr($t['name'], 1) : $t['name'])]; - } - break; + case 'Mention': + $mention_type = substr($t['name'], 0, 1); + if ($mention_type === '!') { + $ret[] = ['ttype' => TERM_FORUM, 'url' => $t['href'], 'term' => escape_tags(substr($t['name'], 1))]; + } + else { + $ret[] = ['ttype' => TERM_MENTION, 'url' => $t['href'], 'term' => escape_tags((substr($t['name'], 0, 1) === '@') ? substr($t['name'], 1) : $t['name'])]; + } + break; - default: - break; + default: + break; + } } } } -- cgit v1.2.3 From 6b500ee3e111b5b10860edaefc914dc79ff06f61 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:52:39 +0000 Subject: Check if BBcode field exist --- Zotlabs/Lib/Activity.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d28f5631d..d8e3b7947 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -3372,22 +3372,25 @@ class Activity { require_once('include/event.php'); $ret = false; - if (is_array($content[$field])) { - foreach ($content[$field] as $k => $v) { - $ret .= html2bbcode($v); - // save this for auto-translate or dynamic filtering - // $ret .= '[language=' . $k . ']' . html2bbcode($v) . '[/language]'; - } - } - else { - if ($field === 'bbcode' && array_key_exists('bbcode', $content)) { - $ret = $content[$field]; + if (array_key_exists($field, $content)) { + if (is_array($content[$field])) { + foreach ($content[$field] as $k => $v) { + $ret .= html2bbcode($v); + // save this for auto-translate or dynamic filtering + // $ret .= '[language=' . $k . ']' . html2bbcode($v) . '[/language]'; + } } else { - $ret = html2bbcode($content[$field]); + if ($field === 'bbcode' && array_key_exists('bbcode', $content)) { + $ret = $content[$field]; + } + else { + $ret = html2bbcode($content[$field]); + } } } - if ($field === 'content' && $content['event'] && (!strpos($ret, '[event'))) { + + if ($field === 'content' && array_key_exists('event', $content) && (!strpos($ret, '[event'))) { $ret .= format_event_bbcode($content['event']); } -- cgit v1.2.3 From efe65e1ba87aed8b92af1e8cc80183f21427505d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 20:57:02 +0000 Subject: Fix undefined edited and created checks --- Zotlabs/Lib/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index d8e3b7947..e5801fba0 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2189,10 +2189,10 @@ class Activity { } } - if (!$s['created']) + if (! array_key_exists('created', $s)) $s['created'] = datetime_convert(); - if (!$s['edited']) + if (! array_key_exists('edited', $s)) $s['edited'] = $s['created']; $s['title'] = (($response_activity) ? EMPTY_STR : self::bb_content($content, 'name')); -- cgit v1.2.3 From 66495e6838ed9c89968c8f33322e974fc58128db Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 21:06:26 +0000 Subject: Check propeties existance on note decode --- Zotlabs/Lib/Activity.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index e5801fba0..4a2de3092 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2114,22 +2114,22 @@ class Activity { $s['uuid'] = $act->obj['diaspora:guid']; $s['parent_mid'] = $act->parent_id; - if ($act->data['published']) { + if (array_key_exists('published', $act->data)) { $s['created'] = datetime_convert('UTC', 'UTC', $act->data['published']); } - elseif ($act->obj['published']) { + elseif (array_key_exists('published', $act->obj)) { $s['created'] = datetime_convert('UTC', 'UTC', $act->obj['published']); } - if ($act->data['updated']) { + if (array_key_exists('updated', $act->data)) { $s['edited'] = datetime_convert('UTC', 'UTC', $act->data['updated']); } - elseif ($act->obj['updated']) { + elseif (array_key_exists('updated', $act->obj)) { $s['edited'] = datetime_convert('UTC', 'UTC', $act->obj['updated']); } - if ($act->data['expires']) { + if (array_key_exists('expires', $act->data)) { $s['expires'] = datetime_convert('UTC', 'UTC', $act->data['expires']); } - elseif ($act->obj['expires']) { + elseif (array_key_exists('expires', $act->obj)) { $s['expires'] = datetime_convert('UTC', 'UTC', $act->obj['expires']); } -- cgit v1.2.3 From 65e9ff357bc533bd1e61c66b3067d64d638d25cb Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 8 Mar 2021 21:16:24 +0000 Subject: More checks on note decode --- Zotlabs/Lib/Activity.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 4a2de3092..c800f331d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2293,17 +2293,20 @@ class Activity { $s['iconfig'] = $a; } - if ($act->obj['type'] === 'Note' && $s['attach']) { - $s['body'] .= self::bb_attach($s['attach'], $s['body']); - } - - if ($act->obj['type'] === 'Question' && in_array($act->type, ['Create', 'Update'])) { - if ($act->obj['endTime']) { - $s['comments_closed'] = datetime_convert('UTC', 'UTC', $act->obj['endTime']); + if (array_key_exists('type', $act->obj)) { + + if ($act->obj['type'] === 'Note' && $s['attach']) { + $s['body'] .= self::bb_attach($s['attach'], $s['body']); + } + + if ($act->obj['type'] === 'Question' && in_array($act->type, ['Create', 'Update'])) { + if (array_key_exists('endTime', $act->obj)) { + $s['comments_closed'] = datetime_convert('UTC', 'UTC', $act->obj['endTime']); + } } } - if ($act->obj['closed']) { + if (array_key_exists('closed', $act->obj)) { $s['comments_closed'] = datetime_convert('UTC', 'UTC', $act->obj['closed']); } -- cgit v1.2.3 From 92ada6eb98300ad7d730ffb7ad05aa9aa11aa350 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 9 Mar 2021 09:07:47 +0000 Subject: Change set_linkified_perms() arguments order --- Zotlabs/Module/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index bc35ac452..f3e8e4e57 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -832,7 +832,7 @@ class Item extends Controller { if($results) { // Set permissions based on tag replacements - set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private); + set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $private, $parent_item); foreach($results as $result) { $success = $result['success']; -- cgit v1.2.3 From 723d757091d55a09633d09119a7214ff64d6eff0 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Tue, 9 Mar 2021 09:08:33 +0000 Subject: Change set_linkified_perms() arguments order --- Zotlabs/Module/Channel_calendar.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index ac1545644..26c6aaf40 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -116,7 +116,7 @@ class Channel_calendar extends Controller { if ($results) { // Set permissions based on tag replacements - set_linkified_perms($results, $str_contact_allow, $str_group_allow, $uid, false, $private); + set_linkified_perms($results, $str_contact_allow, $str_group_allow, $uid, $private); foreach ($results as $result) { $success = $result['success']; -- cgit v1.2.3