that should take care of the bitfields in hubloc
This commit is contained in:
parent
6f11f20992
commit
ee3eee425c
@ -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) {
|
||||
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
@ -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()),
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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']),
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -200,8 +200,8 @@ function import_post(&$a) {
|
||||
'url' => $hubloc['hubloc_url'],
|
||||
'url_sig' => $hubloc['hubloc_url_sig']
|
||||
);
|
||||
if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && ($hubloc['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && ($seize))
|
||||
$hubloc['hubloc_flags'] = ($hubloc['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY);
|
||||
if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize))
|
||||
$hubloc['hubloc_primary'] = 0;
|
||||
|
||||
if(! zot_gethub($arr)) {
|
||||
unset($hubloc['hubloc_id']);
|
||||
@ -220,7 +220,7 @@ function import_post(&$a) {
|
||||
|
||||
// create new hubloc for the new channel at this site
|
||||
|
||||
$r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_flags,
|
||||
$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 )
|
||||
values ( '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s' )",
|
||||
dbesc($channel['channel_guid']),
|
||||
@ -228,7 +228,7 @@ function import_post(&$a) {
|
||||
dbesc($channel['channel_hash']),
|
||||
dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
|
||||
dbesc('zot'),
|
||||
intval(($seize) ? HUBLOC_FLAGS_PRIMARY : 0),
|
||||
intval(($seize) ? 1 : 0),
|
||||
dbesc(z_root()),
|
||||
dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))),
|
||||
dbesc(get_app()->get_hostname()),
|
||||
@ -239,9 +239,7 @@ function import_post(&$a) {
|
||||
// reset the original primary hubloc if it is being seized
|
||||
|
||||
if($seize)
|
||||
$r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where (hubloc_flags & %d)>0 and hubloc_hash = '%s' and hubloc_url != '%s' ",
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
$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())
|
||||
);
|
||||
|
13
mod/locs.php
13
mod/locs.php
@ -19,13 +19,10 @@ function locs_post(&$a) {
|
||||
notice( t('Location not found.') . EOL);
|
||||
return;
|
||||
}
|
||||
$r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where (hubloc_flags & %d)>0 and hubloc_hash = '%s' ",
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' ",
|
||||
dbesc($channel['channel_hash'])
|
||||
);
|
||||
$r = q("update hubloc set hubloc_flags = (hubloc_flags & %d) where hubloc_id = %d and hubloc_hash = '%s'",
|
||||
intval(HUBLOC_FLAGS_PRIMARY),
|
||||
$r = q("update hubloc set hubloc_primary = 1 where hubloc_id = %d and hubloc_hash = '%s'",
|
||||
intval($hubloc_id),
|
||||
dbesc($channel['channel_hash'])
|
||||
);
|
||||
@ -37,7 +34,7 @@ function locs_post(&$a) {
|
||||
if($_REQUEST['drop']) {
|
||||
$hubloc_id = intval($_REQUEST['drop']);
|
||||
if($hubloc_id) {
|
||||
$r = q("select hubloc_id, hubloc_flags from hubloc where hubloc_id = %d and hubloc_url != '%s' and hubloc_hash = '%s' limit 1",
|
||||
$r = q("select * from hubloc where hubloc_id = %d and hubloc_url != '%s' and hubloc_hash = '%s' limit 1",
|
||||
intval($hubloc_id),
|
||||
dbesc(z_root()),
|
||||
dbesc($channel['channel_hash'])
|
||||
@ -46,7 +43,7 @@ function locs_post(&$a) {
|
||||
notice( t('Location not found.') . EOL);
|
||||
return;
|
||||
}
|
||||
if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) {
|
||||
if(intval($r[0]['hubloc_primary'])) {
|
||||
notice( t('Primary location cannot be removed.') . EOL);
|
||||
return;
|
||||
}
|
||||
@ -83,7 +80,7 @@ function locs_content(&$a) {
|
||||
|
||||
|
||||
for($x = 0; $x < count($r); $x ++) {
|
||||
$r[$x]['primary'] = (($r[$x]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false);
|
||||
$r[$x]['primary'] = (intval($r[$x]['hubloc_primary']) ? true : false);
|
||||
$r[$x]['deleted'] = (intval($r[$x]['hubloc_deleted']) ? true : false);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user