diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 10 | ||||
-rw-r--r-- | include/fixd.php | 33 | ||||
-rw-r--r-- | include/hubloc.php | 2 | ||||
-rw-r--r-- | include/identity.php | 4 | ||||
-rw-r--r-- | include/network.php | 5 | ||||
-rw-r--r-- | include/notifier.php | 2 | ||||
-rw-r--r-- | include/onedirsync.php | 2 | ||||
-rw-r--r-- | include/text.php | 6 | ||||
-rw-r--r-- | include/zot.php | 62 |
9 files changed, 41 insertions, 85 deletions
diff --git a/include/Contact.php b/include/Contact.php index 4a016e32f..c872dc913 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -22,9 +22,8 @@ function rconnect_url($channel_id,$xchan) { if(($r) && ($r[0]['xchan_follow'])) return $r[0]['xchan_follow']; - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d )>0 limit 1", - dbesc($xchan), - intval(HUBLOC_FLAGS_PRIMARY) + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1", + dbesc($xchan) ); if($r) @@ -389,8 +388,7 @@ function mark_orphan_hubsxchans() { // } - $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0", - ); + $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0"); if($r) { foreach($r as $rr) { @@ -398,7 +396,7 @@ function mark_orphan_hubsxchans() { // see if any other hublocs are still alive for this channel $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0", - dbesc($rr['hubloc_hash']), + dbesc($rr['hubloc_hash']) ); if($x) { diff --git a/include/fixd.php b/include/fixd.php deleted file mode 100644 index bce5eb348..000000000 --- a/include/fixd.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - - require_once('include/cli_startup.php'); - - cli_startup(); - - $rand = db_getfunc('RAND'); - $r = q("select xchan_addr, hubloc_url from xchan left join hubloc on hubloc_hash = xchan_hash where xchan_network like '%%diaspora%%' order by $rand"); - - if(! $r) - killme(); - - require_once('include/network.php'); - $total = 0; - foreach ($r as $rr) { - if($rr['hubloc_url']) { - continue; - } - $total ++; - } - - print $total . "\n"; - - foreach ($r as $rr) { - if($rr['hubloc_url']) { - continue; - } - - $webbie = $rr['xchan_addr']; - print $webbie . ' '; - - discover_by_webbie($webbie); - } diff --git a/include/hubloc.php b/include/hubloc.php index 92736e090..cde166e8d 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -120,7 +120,7 @@ function hubloc_change_primary($hubloc) { logger('no hubloc'); return false; } - if(! ($hubloc['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) { + if(! (intval($hubloc['hubloc_primary']))) { logger('not primary: ' . $hubloc['hubloc_url']); return false; } diff --git a/include/identity.php b/include/identity.php index d98f39cb7..f5a729573 100644 --- a/include/identity.php +++ b/include/identity.php @@ -291,14 +291,14 @@ function create_identity($arr) { // Create a verified hub location pointing to this site. - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, + $r = 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($guid), dbesc($sig), dbesc($hash), dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()), - intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0), + intval($primary), dbesc(z_root()), dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))), dbesc(get_app()->get_hostname()), diff --git a/include/network.php b/include/network.php index 170b77d7d..8082d0217 100644 --- a/include/network.php +++ b/include/network.php @@ -1113,7 +1113,7 @@ function discover_by_webbie($webbie) { if(! $r) { - $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_flags ) values ('%s','%s','%s','%s','%s','%s','%s','%s', %d)", + $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_primary ) values ('%s','%s','%s','%s','%s','%s','%s','%s', 1)", dbesc($guid), dbesc($addr), dbesc($addr), @@ -1121,8 +1121,7 @@ function discover_by_webbie($webbie) { dbesc(trim($diaspora_base,'/')), dbesc($hostname), dbesc($notify), - dbescdate(datetime_convert()), - intval(HUBLOC_FLAGS_PRIMARY) + dbescdate(datetime_convert()) ); } $photos = import_profile_photo($vcard['photo'],$addr); diff --git a/include/notifier.php b/include/notifier.php index 0bdc71261..29646fb38 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -493,7 +493,7 @@ function notifier_run($argv, $argc){ // aren't the owner or author. - $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc + $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1"); } else { diff --git a/include/onedirsync.php b/include/onedirsync.php index c94a1410f..e611492af 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -55,7 +55,7 @@ function onedirsync_run($argv, $argc){ $h = q("select * from hubloc where hubloc_addr = '%s' limit 1", dbesc($r[0]['ud_addr']) ); - if(($h) && (intval($h[0]['hubloc_error']))) + if(($h) && (intval($h[0]['hubloc_error']))) { $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), diff --git a/include/text.php b/include/text.php index b6e4abf24..fcd7b422c 100644 --- a/include/text.php +++ b/include/text.php @@ -1890,13 +1890,13 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) { if(count($arr)) { if($abook) { $chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d - where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0", + where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1", intval($item['uid']) ); } else { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash - where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0"); + where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1"); } $xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')"); if(! $chans) @@ -1924,7 +1924,7 @@ function xchan_mail_query(&$item) { if(count($arr)) { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash - where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0"); + where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1"); } if($chans) { $item['from'] = find_xchan_in_array($item['from_xchan'],$chans); diff --git a/include/zot.php b/include/zot.php index ac5127f1c..debd2c8a8 100644 --- a/include/zot.php +++ b/include/zot.php @@ -201,9 +201,8 @@ function zot_finger($webbie,$channel,$autofallback = true) { $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash - where xchan_addr = '%s' and (hubloc_flags & %d) > 0 limit 1", - dbesc($xchan_addr), - intval(HUBLOC_FLAGS_PRIMARY) + where xchan_addr = '%s' and hubloc_primary = 1 limit 1", + dbesc($xchan_addr) ); if($r) { @@ -300,9 +299,8 @@ function zot_refresh($them,$channel = null, $force = false) { if($them['hubloc_url']) $url = $them['hubloc_url']; else { - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) > 0 limit 1", - dbesc($them['xchan_hash']), - intval(HUBLOC_FLAGS_PRIMARY) + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1", + dbesc($them['xchan_hash']) ); if($r) $url = $r[0]['hubloc_url']; @@ -1887,9 +1885,8 @@ function sync_locations($sender,$arr,$absolute = false) { q("update hubloc set hubloc_error = 0 where hubloc_id = %d", intval($r[0]['hubloc_id']) ); - if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { - q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_ORPHANCHECK), + if(intval($r[0]['hubloc_orphancheck'])) { + q("update hubloc set hubloc_orphancheck = 0 where hubloc_id = %d", intval($r[0]['hubloc_id']) ); } @@ -1911,15 +1908,15 @@ function sync_locations($sender,$arr,$absolute = false) { } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) { - $m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", - intval(HUBLOC_FLAGS_PRIMARY), + if((intval($r[0]['hubloc_primary']) && (! $location['primary'])) + || ((! intval($r[0]['hubloc_primary'])) && ($location['primary']))) { + $m = q("update hubloc set hubloc_primary = %d, hubloc_updated = '%s' where hubloc_id = %d", + intval($location['primary']), dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); // make sure hubloc_change_primary() has current data - $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; + $r[0]['hubloc_primary'] = intval($location['primary']); hubloc_change_primary($r[0]); $what .= 'primary_hub '; $changed = true; @@ -1949,22 +1946,20 @@ function sync_locations($sender,$arr,$absolute = false) { // New hub claiming to be primary. Make it so by removing any existing primaries. if(intval($location['primary'])) { - $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_hash = '%s' and (hubloc_flags & %d )>0", - intval(HUBLOC_FLAGS_PRIMARY), + $r = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_hash = '%s' and hubloc_primary = 1", dbesc(datetime_convert()), - dbesc($sender['hash']), - intval(HUBLOC_FLAGS_PRIMARY) + dbesc($sender['hash']) ); } logger('sync_locations: new hub: ' . $location['url']); - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected) + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_primary, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected) values ( '%s','%s','%s','%s', '%s', %d ,'%s','%s','%s','%s','%s','%s','%s')", dbesc($sender['guid']), dbesc($sender['guid_sig']), dbesc($sender['hash']), dbesc($location['address']), dbesc('zot'), - intval((intval($location['primary'])) ? HUBLOC_FLAGS_PRIMARY : 0), + intval($location['primary']), dbesc($location['url']), dbesc($location['url_sig']), dbesc($location['host']), @@ -2017,18 +2012,16 @@ function zot_encode_locations($channel) { $x = zot_get_hublocs($channel['channel_hash']); if($x && count($x)) { foreach($x as $hub) { - if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) { - $ret[] = array( - 'host' => $hub['hubloc_host'], - 'address' => $hub['hubloc_addr'], - 'primary' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false), - 'url' => $hub['hubloc_url'], - 'url_sig' => $hub['hubloc_url_sig'], - 'callback' => $hub['hubloc_callback'], - 'sitekey' => $hub['hubloc_sitekey'], - 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) - ); - } + $ret[] = array( + 'host' => $hub['hubloc_host'], + 'address' => $hub['hubloc_addr'], + 'primary' => (intval($hub['hubloc_primary']) ? true : false), + 'url' => $hub['hubloc_url'], + 'url_sig' => $hub['hubloc_url_sig'], + 'callback' => $hub['hubloc_callback'], + 'sitekey' => $hub['hubloc_sitekey'], + 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) + ); } } return $ret; @@ -2843,10 +2836,9 @@ function get_rpost_path($observer) { function import_author_zot($x) { $hash = make_xchan_hash($x['guid'],$x['guid_sig']); - $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and (hubloc_flags & %d)>0 limit 1", + $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_primary = 1 limit 1", dbesc($x['guid']), - dbesc($x['guid_sig']), - intval(HUBLOC_FLAGS_PRIMARY) + dbesc($x['guid_sig']) ); if($r) { |