From 5f801216373078817d39b8aea34dd5fa7949dc6a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Fri, 30 Oct 2015 22:43:38 -0700 Subject: add hubloc repair script (needed for deadsuperhero, probably temporary) --- mod/fhublocs.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 mod/fhublocs.php (limited to 'mod/fhublocs.php') diff --git a/mod/fhublocs.php b/mod/fhublocs.php new file mode 100644 index 000000000..d2f15b728 --- /dev/null +++ b/mod/fhublocs.php @@ -0,0 +1,70 @@ +get_hostname(); + + + $primary = (($hub_address === $primary_address) ? 1 : 0); + if(! $y) + $primary = 1; + + $m = q("delete from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' ", + dbesc($rr['channel_hash']), + dbesc(z_root()) + ); + + // Create a verified hub location pointing to this site. + + $h = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_primary, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_network ) + values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )", + dbesc($rr['channel_guid']), + dbesc($rr['channel_guid_sig']), + dbesc($rr['channel_hash']), + dbesc($rr['channel_address'] . '@' . get_app()->get_hostname()), + intval($primary), + dbesc(z_root()), + dbesc(base64url_encode(rsa_sign(z_root(),$rr['channel_prvkey']))), + dbesc(get_app()->get_hostname()), + dbesc(z_root() . '/post'), + dbesc(get_config('system','pubkey')), + dbesc('zot') + ); + + if($h) + $o . 'local hubloc created for ' . $rr['channel_name'] . EOL; + else + $o .= 'DB update failed for ' . $rr['channel_name'] . EOL; + + } + + return $o; + + } +} \ No newline at end of file -- cgit v1.2.3 From 04820ba09ef335f11df6be00b11b09a02989e0cf Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sat, 31 Oct 2015 13:58:26 -0700 Subject: make hubloc repair script a bit more selective --- mod/fhublocs.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'mod/fhublocs.php') diff --git a/mod/fhublocs.php b/mod/fhublocs.php index d2f15b728..dce00e383 100644 --- a/mod/fhublocs.php +++ b/mod/fhublocs.php @@ -13,14 +13,24 @@ function fhublocs_content(&$a) { $o = ''; $r = q("select * from channel where channel_removed = 0"); + $sitekey = get_config('system','pubkey'); if($r) { foreach($r as $rr) { + $found = false; $primary_address = ''; $x = zot_get_hublocs($rr['channel_hash']); if($x) { - $o .= 'Hubloc exists for ' . $rr['channel_name'] . EOL; - continue; + foreach($x as $xx) { + if($xx['hubloc_url'] === z_root() && $xx['hubloc_sitekey'] === $sitekey) { + $found = true; + break; + } + } + if($found) { + $o .= 'Hubloc exists for ' . $rr['channel_name'] . EOL; + continue; + } } $y = q("select xchan_addr from xchan where xchan_hash = '%s' limit 1", dbesc($rr['channel_hash']) @@ -53,7 +63,7 @@ function fhublocs_content(&$a) { dbesc(base64url_encode(rsa_sign(z_root(),$rr['channel_prvkey']))), dbesc(get_app()->get_hostname()), dbesc(z_root() . '/post'), - dbesc(get_config('system','pubkey')), + dbesc($sitekey), dbesc('zot') ); -- cgit v1.2.3