From b10b8ca3f46fca78ee69d89c49fa671096f72caa Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 27 Mar 2019 15:20:43 +0100 Subject: fix various issues in z6_discover() --- include/hubloc.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/hubloc.php b/include/hubloc.php index 3fed46495..eb91e4f90 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -311,7 +311,9 @@ function z6_discover() { // find unregistered zot6 clone hublocs - $c = q("select channel_hash, channel_portable_id from channel where channel_deleted = 0"); + $c = q("select channel_hash, channel_portable_id from channel where channel_deleted = '%s'", + dbesc(NULL_DATE) + ); 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'", @@ -332,9 +334,9 @@ function z6_discover() { continue; } // zot6 hubloc not found. - if(strpos($entry['site_project'],'hubzilla') !== false && version_compare($entry['site_version'],'4.0') >= 0) { + if(strpos($q['site_project'],'hubzilla') !== false && version_compare($q['site_version'],'4.0') >= 0) { // probe and store results - only for zot6 (over-ride the zot default) - discover_by_webbie($entry['hubloc_addr'],'zot6'); + discover_by_webbie($q['hubloc_addr'],'zot6'); } } } -- cgit v1.2.3 From 31680898e3f36e3fcc44ba797ae99d3234b5fc7b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 28 Mar 2019 15:51:24 +0100 Subject: another fix for z6_discover() and create a zot6 hubloc if applicable --- Zotlabs/Module/Import.php | 34 +++++++++++++++++++++++++++++++++- include/hubloc.php | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index 9d047ed7b..cd7267db3 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -228,13 +228,45 @@ class Import extends \Zotlabs\Web\Controller { ); // reset the original primary hubloc if it is being seized - if($seize) { $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ", dbesc($channel['channel_hash']), dbesc(z_root()) ); } + + // create a new zot6 hubloc if we have got a channel_portable_id + if($channel['channel_portable_id']) { + $r = hubloc_store_lowlevel( + [ + 'hubloc_guid' => $channel['channel_guid'], + 'hubloc_guid_sig' => 'sha256.' . $channel['channel_guid_sig'], + 'hubloc_hash' => $channel['channel_portable_id'], + 'hubloc_addr' => channel_reddress($channel), + 'hubloc_network' => 'zot6', + 'hubloc_primary' => (($seize) ? 1 : 0), + 'hubloc_url' => z_root(), + 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])), + 'hubloc_host' => \App::get_hostname(), + 'hubloc_callback' => z_root() . '/zot', + 'hubloc_sitekey' => get_config('system','pubkey'), + 'hubloc_updated' => datetime_convert(), + 'hubloc_id_url' => channel_url($channel), + 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')); + + ] + ); + + // reset the original primary hubloc if it is being seized + if($seize) { + $r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ", + dbesc($channel['channel_portable_id']), + dbesc(z_root()) + ); + } + + } + } logger('import step 5'); diff --git a/include/hubloc.php b/include/hubloc.php index eb91e4f90..4a1f77733 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -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['portable_id']), + dbesc($entry['channel_portable_id']), dbesc($q['hubloc_url']) ); if ($q2) { -- cgit v1.2.3 From f44cc2b60cd762eed759ce1a3e9bb47f06f80302 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 28 Mar 2019 15:56:28 +0100 Subject: fix typo --- Zotlabs/Module/Import.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php index cd7267db3..a74209c1c 100644 --- a/Zotlabs/Module/Import.php +++ b/Zotlabs/Module/Import.php @@ -234,7 +234,7 @@ class Import extends \Zotlabs\Web\Controller { dbesc(z_root()) ); } - + // create a new zot6 hubloc if we have got a channel_portable_id if($channel['channel_portable_id']) { $r = hubloc_store_lowlevel( @@ -252,7 +252,7 @@ class Import extends \Zotlabs\Web\Controller { 'hubloc_sitekey' => get_config('system','pubkey'), 'hubloc_updated' => datetime_convert(), 'hubloc_id_url' => channel_url($channel), - 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')); + 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')) ] ); -- cgit v1.2.3