From 990a3af2a7349e07c10224cf2a023d179ecfd6ca Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 8 Sep 2022 20:02:22 +0000 Subject: php8: random cleanup and warning fixes --- Zotlabs/Lib/Libzot.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 8eb5ce647..09ce3a9de 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -304,8 +304,14 @@ class Libzot { $record = Zotfinger::exec($url, $channel); + if (!$record) { + return false; + } + // Check the HTTP signature $hsig = $record['signature']; + $hsig_valid = false; + if ($hsig && $hsig['signer'] === $url && $hsig['header_valid'] === true && $hsig['content_valid'] === true) { $hsig_valid = true; } -- cgit v1.2.3 From 480862d7143f291658b48e785eda2e61a438a74b Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 11 Sep 2022 14:58:40 +0000 Subject: php8: fix more warnings --- Zotlabs/Lib/Libzot.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 09ce3a9de..340f844d5 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2926,12 +2926,11 @@ class Libzot { // This is a template - %s will be replaced with the follow_url we discover for the return channel. if ($special_channel) { - $ret['connect_url'] = (($e['xchan_connpage']) ? $e['xchan_connpage'] : z_root() . '/connect/' . $e['channel_address']); + $ret['connect_url'] = $e['xchan_connpage'] ?? z_root() . '/connect/' . $e['channel_address']; } // This is a template for our follow url, %s will be replaced with a webbie - if (!$ret['follow_url']) - $ret['follow_url'] = z_root() . '/follow?f=&url=%s'; + $ret['follow_url'] = $ret['follow_url'] ?? z_root() . '/follow?f=&url=%s'; $permissions = get_all_perms($e['channel_id'], $ztarget_hash, false, false); -- cgit v1.2.3 From 1d56b9a1bb155d7a0b4377f9bb1e195230e545e4 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 14 Sep 2022 12:31:19 +0000 Subject: php8: warning fixes --- Zotlabs/Lib/Libzot.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 340f844d5..8bf3c51d5 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -904,11 +904,11 @@ class Libzot { $s = Libsync::sync_locations($arr, $arr); if ($s) { - if ($s['change_message']) + if (isset($s['change_message'])) $what .= $s['change_message']; - if ($s['changed']) + if (isset($s['changed'])) $changed = $s['changed']; - if ($s['message']) + if (isset($s['message'])) $ret['message'] .= $s['message']; } @@ -1769,7 +1769,7 @@ class Libzot { dbesc($arr['author_xchan']) ); - if (intval($arr['item_deleted'])) { + if (isset($arr['item_deleted']) && $arr['item_deleted']) { // remove_community_tag is a no-op if this isn't a community tag activity self::remove_community_tag($sender, $arr, $channel['channel_id']); @@ -2020,11 +2020,11 @@ class Libzot { $arr['owner_xchan'] = $a['signature']['signer']; } - if ($AS->meta['hubloc'] || $arr['author_xchan'] === $arr['owner_xchan']) { + if (isset($AS->meta['hubloc']) || $arr['author_xchan'] === $arr['owner_xchan']) { $arr['item_verified'] = true; } - if ($AS->meta['signed_data']) { + if (isset($AS->meta['signed_data'])) { IConfig::Set($arr, 'activitypub', 'signed_data', $AS->meta['signed_data'], false); $j = json_decode($AS->meta['signed_data'], true); if ($j) { @@ -2518,14 +2518,14 @@ class Libzot { $access_policy = ACCESS_PRIVATE; } - $directory_url = htmlspecialchars((string)$arr['directory_url'], ENT_COMPAT, 'UTF-8', false); - $url = htmlspecialchars((string)strtolower($arr['url']), ENT_COMPAT, 'UTF-8', false); - $sellpage = htmlspecialchars((string)$arr['sellpage'], ENT_COMPAT, 'UTF-8', false); - $site_location = htmlspecialchars((string)$arr['location'], ENT_COMPAT, 'UTF-8', false); - $site_realm = htmlspecialchars((string)$arr['realm'], ENT_COMPAT, 'UTF-8', false); - $site_project = htmlspecialchars((string)$arr['project'], ENT_COMPAT, 'UTF-8', false); - $site_crypto = ((array_key_exists('encryption', $arr) && is_array($arr['encryption'])) ? htmlspecialchars((string)implode(',', $arr['encryption']), ENT_COMPAT, 'UTF-8', false) : ''); - $site_version = ((array_key_exists('version', $arr)) ? htmlspecialchars((string)$arr['version'], ENT_COMPAT, 'UTF-8', false) : ''); + $directory_url = ((isset($arr['directory_url'])) ? htmlspecialchars($arr['directory_url'], ENT_COMPAT, 'UTF-8', false) : ''); + $url = ((isset($arr['url'])) ? htmlspecialchars(strtolower($arr['url']), ENT_COMPAT, 'UTF-8', false) : ''); + $sellpage = ((isset($arr['sellpage'])) ? htmlspecialchars($arr['sellpage'], ENT_COMPAT, 'UTF-8', false) : ''); + $site_location = ((isset($arr['location'])) ? htmlspecialchars($arr['location'], ENT_COMPAT, 'UTF-8', false) : ''); + $site_realm = ((isset($arr['realm'])) ? htmlspecialchars($arr['realm'], ENT_COMPAT, 'UTF-8', false) : ''); + $site_project = ((isset($arr['project'])) ? htmlspecialchars($arr['project'], ENT_COMPAT, 'UTF-8', false) : ''); + $site_crypto = ((isset($arr['encryption']) && is_array($arr['encryption'])) ? htmlspecialchars(implode(',', $arr['encryption']), ENT_COMPAT, 'UTF-8', false) : ''); + $site_version = ((isset($arr['version'])) ? htmlspecialchars($arr['version'], ENT_COMPAT, 'UTF-8', false) : ''); // You can have one and only one primary directory per realm. // Downgrade any others claiming to be primary. As they have @@ -3198,7 +3198,7 @@ class Libzot { } foreach ($arr as $v) { - if ($v[$check] === 'zot6') { + if (isset($v[$check]) && $v[$check] === 'zot6') { return $v; } } -- cgit v1.2.3 From 118a5edebc745fe2760f781c8bb9e9006bf6215f Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Sep 2022 09:19:55 +0000 Subject: fix warnings and regressions --- Zotlabs/Lib/Libzot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 8bf3c51d5..2486f7d67 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -251,7 +251,7 @@ class Libzot { $url = null; - if ($them['hubloc_id_url']) { + if (isset($them['hubloc_id_url']) && $them['hubloc_id_url']) { $url = $them['hubloc_id_url']; } else { @@ -1744,7 +1744,7 @@ class Libzot { if (in_array('undefined', $existing_route) || $last_hop == 'undefined' || $sender == 'undefined') $last_hop = ''; - $current_route = (($arr['route']) ? $arr['route'] . ',' : '') . $sender; + $current_route = ((isset($arr['route']) && $arr['route']) ? $arr['route'] . ',' : '') . $sender; if ($last_hop && $last_hop != $sender) { logger('comment route mismatch: parent route = ' . $r[0]['route'] . ' expected = ' . $current_route, LOGGER_DEBUG); -- cgit v1.2.3 From 937d6cb1efef3250f68f2b943e3964473495acae Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 22 Sep 2022 06:31:35 +0000 Subject: php8: fix warnings --- Zotlabs/Lib/Libzot.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 2486f7d67..84fccd18f 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2735,6 +2735,8 @@ class Libzot { $token = ((x($arr, 'token')) ? $arr['token'] : ''); $feed = ((x($arr, 'feed')) ? intval($arr['feed']) : 0); + $ztarget_hash = EMPTY_STR; + if ($ztarget) { $t = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1", dbesc($ztarget) @@ -2742,7 +2744,6 @@ class Libzot { if ($t) { $ztarget_hash = $t[0]['hubloc_hash']; - } else { @@ -2750,7 +2751,6 @@ class Libzot { // permissions we would know about them and we only want to know who they are to // enumerate their specific permissions - $ztarget_hash = EMPTY_STR; } } -- cgit v1.2.3 From ad35363c2e2ea30707cbea4796a03b88abde380e Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 28 Sep 2022 10:27:35 +0000 Subject: hub reinstall issues --- Zotlabs/Lib/Libzot.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 84fccd18f..607eadb07 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1233,7 +1233,7 @@ class Libzot { return; } - $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'", + $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' order by hubloc_id desc", dbesc($AS->actor['id']) ); @@ -1241,7 +1241,7 @@ class Libzot { // Author is unknown to this site. Perform channel discovery and try again. $z = discover_by_webbie($AS->actor['id']); if ($z) { - $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s'", + $r = q("select hubloc_hash, hubloc_network, hubloc_url from hubloc where hubloc_id_url = '%s' order by hubloc_id desc", dbesc($AS->actor['id']) ); } @@ -2738,7 +2738,7 @@ class Libzot { $ztarget_hash = EMPTY_STR; if ($ztarget) { - $t = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1", + $t = q("select * from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", dbesc($ztarget) ); if ($t) { -- cgit v1.2.3 From 05bd2a1f9e1f2fc6f0c501201dd73467443799ce Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 28 Sep 2022 10:35:09 +0000 Subject: one more hub reinstall fix --- Zotlabs/Lib/Libzot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 607eadb07..3d14248de 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1261,7 +1261,7 @@ class Libzot { if(filter_var($env['sender'], FILTER_VALIDATE_URL)) { // in individual delivery, change owner if needed - $s = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' limit 1", + $s = q("select hubloc_hash, hubloc_url from hubloc where hubloc_id_url = '%s' and hubloc_network = 'zot6' order by hubloc_id desc limit 1", dbesc($env['sender']) ); -- cgit v1.2.3 From 4549bc89eca7418dd86424d1791f7a86a5966ce9 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 5 Oct 2022 08:41:31 +0000 Subject: when updating hubloc_connected also update hubloc_updated --- Zotlabs/Lib/Libzot.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Lib/Libzot.php') diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 3d14248de..6f7d74606 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -3106,7 +3106,8 @@ class Libzot { $t = datetime_convert('UTC', 'UTC', 'now - 15 minutes'); - $r = q("update hubloc set hubloc_connected = '%s' where hubloc_id = %d and hubloc_site_id = '%s' and hubloc_connected < '%s' ", + q("update hubloc set hubloc_connected = '%s', hubloc_updated = '%s' where hubloc_id = %d and hubloc_site_id = '%s' and hubloc_connected < '%s' ", + dbesc(datetime_convert()), dbesc(datetime_convert()), intval($hub['hubloc_id']), dbesc($site_id), -- cgit v1.2.3