that should take care of the bitfields in hubloc
This commit is contained in:
@@ -22,9 +22,8 @@ function rconnect_url($channel_id,$xchan) {
|
|||||||
if(($r) && ($r[0]['xchan_follow']))
|
if(($r) && ($r[0]['xchan_follow']))
|
||||||
return $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",
|
$r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1",
|
||||||
dbesc($xchan),
|
dbesc($xchan)
|
||||||
intval(HUBLOC_FLAGS_PRIMARY)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r)
|
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) {
|
if($r) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
@@ -398,7 +396,7 @@ function mark_orphan_hubsxchans() {
|
|||||||
// see if any other hublocs are still alive for this channel
|
// see if any other hublocs are still alive for this channel
|
||||||
|
|
||||||
$x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0",
|
$x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0",
|
||||||
dbesc($rr['hubloc_hash']),
|
dbesc($rr['hubloc_hash'])
|
||||||
);
|
);
|
||||||
if($x) {
|
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');
|
logger('no hubloc');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(! ($hubloc['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) {
|
if(! (intval($hubloc['hubloc_primary']))) {
|
||||||
logger('not primary: ' . $hubloc['hubloc_url']);
|
logger('not primary: ' . $hubloc['hubloc_url']);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,14 +291,14 @@ function create_identity($arr) {
|
|||||||
|
|
||||||
// Create a verified hub location pointing to this site.
|
// 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 )
|
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' )",
|
values ( '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s' )",
|
||||||
dbesc($guid),
|
dbesc($guid),
|
||||||
dbesc($sig),
|
dbesc($sig),
|
||||||
dbesc($hash),
|
dbesc($hash),
|
||||||
dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
|
dbesc($ret['channel']['channel_address'] . '@' . get_app()->get_hostname()),
|
||||||
intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0),
|
intval($primary),
|
||||||
dbesc(z_root()),
|
dbesc(z_root()),
|
||||||
dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))),
|
dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))),
|
||||||
dbesc(get_app()->get_hostname()),
|
dbesc(get_app()->get_hostname()),
|
||||||
|
|||||||
@@ -1113,7 +1113,7 @@ function discover_by_webbie($webbie) {
|
|||||||
|
|
||||||
if(! $r) {
|
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($guid),
|
||||||
dbesc($addr),
|
dbesc($addr),
|
||||||
dbesc($addr),
|
dbesc($addr),
|
||||||
@@ -1121,8 +1121,7 @@ function discover_by_webbie($webbie) {
|
|||||||
dbesc(trim($diaspora_base,'/')),
|
dbesc(trim($diaspora_base,'/')),
|
||||||
dbesc($hostname),
|
dbesc($hostname),
|
||||||
dbesc($notify),
|
dbesc($notify),
|
||||||
dbescdate(datetime_convert()),
|
dbescdate(datetime_convert())
|
||||||
intval(HUBLOC_FLAGS_PRIMARY)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$photos = import_profile_photo($vcard['photo'],$addr);
|
$photos = import_profile_photo($vcard['photo'],$addr);
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ function notifier_run($argv, $argc){
|
|||||||
// aren't the owner or author.
|
// 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");
|
where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ function onedirsync_run($argv, $argc){
|
|||||||
$h = q("select * from hubloc where hubloc_addr = '%s' limit 1",
|
$h = q("select * from hubloc where hubloc_addr = '%s' limit 1",
|
||||||
dbesc($r[0]['ud_addr'])
|
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' ",
|
$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),
|
intval(UPDATE_FLAGS_UPDATED),
|
||||||
dbesc($r[0]['ud_addr']),
|
dbesc($r[0]['ud_addr']),
|
||||||
|
|||||||
@@ -1890,13 +1890,13 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) {
|
|||||||
if(count($arr)) {
|
if(count($arr)) {
|
||||||
if($abook) {
|
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
|
$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'])
|
intval($item['uid'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
|
$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')");
|
$xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')");
|
||||||
if(! $chans)
|
if(! $chans)
|
||||||
@@ -1924,7 +1924,7 @@ function xchan_mail_query(&$item) {
|
|||||||
|
|
||||||
if(count($arr)) {
|
if(count($arr)) {
|
||||||
$chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash
|
$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) {
|
if($chans) {
|
||||||
$item['from'] = find_xchan_in_array($item['from_xchan'],$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
|
$r = q("select xchan.*, hubloc.* from xchan
|
||||||
left join hubloc on xchan_hash = hubloc_hash
|
left join hubloc on xchan_hash = hubloc_hash
|
||||||
where xchan_addr = '%s' and (hubloc_flags & %d) > 0 limit 1",
|
where xchan_addr = '%s' and hubloc_primary = 1 limit 1",
|
||||||
dbesc($xchan_addr),
|
dbesc($xchan_addr)
|
||||||
intval(HUBLOC_FLAGS_PRIMARY)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
@@ -300,9 +299,8 @@ function zot_refresh($them,$channel = null, $force = false) {
|
|||||||
if($them['hubloc_url'])
|
if($them['hubloc_url'])
|
||||||
$url = $them['hubloc_url'];
|
$url = $them['hubloc_url'];
|
||||||
else {
|
else {
|
||||||
$r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) > 0 limit 1",
|
$r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1",
|
||||||
dbesc($them['xchan_hash']),
|
dbesc($them['xchan_hash'])
|
||||||
intval(HUBLOC_FLAGS_PRIMARY)
|
|
||||||
);
|
);
|
||||||
if($r)
|
if($r)
|
||||||
$url = $r[0]['hubloc_url'];
|
$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",
|
q("update hubloc set hubloc_error = 0 where hubloc_id = %d",
|
||||||
intval($r[0]['hubloc_id'])
|
intval($r[0]['hubloc_id'])
|
||||||
);
|
);
|
||||||
if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) {
|
if(intval($r[0]['hubloc_orphancheck'])) {
|
||||||
q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d",
|
q("update hubloc set hubloc_orphancheck = 0 where hubloc_id = %d",
|
||||||
intval(HUBLOC_FLAGS_ORPHANCHECK),
|
|
||||||
intval($r[0]['hubloc_id'])
|
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']))
|
if((intval($r[0]['hubloc_primary']) && (! $location['primary']))
|
||||||
|| ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) {
|
|| ((! intval($r[0]['hubloc_primary'])) && ($location['primary']))) {
|
||||||
$m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d",
|
$m = q("update hubloc set hubloc_primary = %d, hubloc_updated = '%s' where hubloc_id = %d",
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
intval($location['primary']),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($r[0]['hubloc_id'])
|
intval($r[0]['hubloc_id'])
|
||||||
);
|
);
|
||||||
// make sure hubloc_change_primary() has current data
|
// 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]);
|
hubloc_change_primary($r[0]);
|
||||||
$what .= 'primary_hub ';
|
$what .= 'primary_hub ';
|
||||||
$changed = true;
|
$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.
|
// New hub claiming to be primary. Make it so by removing any existing primaries.
|
||||||
|
|
||||||
if(intval($location['primary'])) {
|
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",
|
$r = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_hash = '%s' and hubloc_primary = 1",
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc($sender['hash']),
|
dbesc($sender['hash'])
|
||||||
intval(HUBLOC_FLAGS_PRIMARY)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
logger('sync_locations: new hub: ' . $location['url']);
|
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')",
|
values ( '%s','%s','%s','%s', '%s', %d ,'%s','%s','%s','%s','%s','%s','%s')",
|
||||||
dbesc($sender['guid']),
|
dbesc($sender['guid']),
|
||||||
dbesc($sender['guid_sig']),
|
dbesc($sender['guid_sig']),
|
||||||
dbesc($sender['hash']),
|
dbesc($sender['hash']),
|
||||||
dbesc($location['address']),
|
dbesc($location['address']),
|
||||||
dbesc('zot'),
|
dbesc('zot'),
|
||||||
intval((intval($location['primary'])) ? HUBLOC_FLAGS_PRIMARY : 0),
|
intval($location['primary']),
|
||||||
dbesc($location['url']),
|
dbesc($location['url']),
|
||||||
dbesc($location['url_sig']),
|
dbesc($location['url_sig']),
|
||||||
dbesc($location['host']),
|
dbesc($location['host']),
|
||||||
@@ -2017,18 +2012,16 @@ function zot_encode_locations($channel) {
|
|||||||
$x = zot_get_hublocs($channel['channel_hash']);
|
$x = zot_get_hublocs($channel['channel_hash']);
|
||||||
if($x && count($x)) {
|
if($x && count($x)) {
|
||||||
foreach($x as $hub) {
|
foreach($x as $hub) {
|
||||||
if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) {
|
$ret[] = array(
|
||||||
$ret[] = array(
|
'host' => $hub['hubloc_host'],
|
||||||
'host' => $hub['hubloc_host'],
|
'address' => $hub['hubloc_addr'],
|
||||||
'address' => $hub['hubloc_addr'],
|
'primary' => (intval($hub['hubloc_primary']) ? true : false),
|
||||||
'primary' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false),
|
'url' => $hub['hubloc_url'],
|
||||||
'url' => $hub['hubloc_url'],
|
'url_sig' => $hub['hubloc_url_sig'],
|
||||||
'url_sig' => $hub['hubloc_url_sig'],
|
'callback' => $hub['hubloc_callback'],
|
||||||
'callback' => $hub['hubloc_callback'],
|
'sitekey' => $hub['hubloc_sitekey'],
|
||||||
'sitekey' => $hub['hubloc_sitekey'],
|
'deleted' => (intval($hub['hubloc_deleted']) ? true : false)
|
||||||
'deleted' => (intval($hub['hubloc_deleted']) ? true : false)
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
@@ -2843,10 +2836,9 @@ function get_rpost_path($observer) {
|
|||||||
|
|
||||||
function import_author_zot($x) {
|
function import_author_zot($x) {
|
||||||
$hash = make_xchan_hash($x['guid'],$x['guid_sig']);
|
$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']),
|
||||||
dbesc($x['guid_sig']),
|
dbesc($x['guid_sig'])
|
||||||
intval(HUBLOC_FLAGS_PRIMARY)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
|
|||||||
@@ -200,8 +200,8 @@ function import_post(&$a) {
|
|||||||
'url' => $hubloc['hubloc_url'],
|
'url' => $hubloc['hubloc_url'],
|
||||||
'url_sig' => $hubloc['hubloc_url_sig']
|
'url_sig' => $hubloc['hubloc_url_sig']
|
||||||
);
|
);
|
||||||
if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && ($hubloc['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && ($seize))
|
if(($hubloc['hubloc_hash'] === $channel['channel_hash']) && intval($hubloc['hubloc_primary']) && ($seize))
|
||||||
$hubloc['hubloc_flags'] = ($hubloc['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY);
|
$hubloc['hubloc_primary'] = 0;
|
||||||
|
|
||||||
if(! zot_gethub($arr)) {
|
if(! zot_gethub($arr)) {
|
||||||
unset($hubloc['hubloc_id']);
|
unset($hubloc['hubloc_id']);
|
||||||
@@ -220,7 +220,7 @@ function import_post(&$a) {
|
|||||||
|
|
||||||
// create new hubloc for the new channel at this site
|
// 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 )
|
hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey )
|
||||||
values ( '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s' )",
|
values ( '%s', '%s', '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s' )",
|
||||||
dbesc($channel['channel_guid']),
|
dbesc($channel['channel_guid']),
|
||||||
@@ -228,7 +228,7 @@ function import_post(&$a) {
|
|||||||
dbesc($channel['channel_hash']),
|
dbesc($channel['channel_hash']),
|
||||||
dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
|
dbesc($channel['channel_address'] . '@' . get_app()->get_hostname()),
|
||||||
dbesc('zot'),
|
dbesc('zot'),
|
||||||
intval(($seize) ? HUBLOC_FLAGS_PRIMARY : 0),
|
intval(($seize) ? 1 : 0),
|
||||||
dbesc(z_root()),
|
dbesc(z_root()),
|
||||||
dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))),
|
dbesc(base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey']))),
|
||||||
dbesc(get_app()->get_hostname()),
|
dbesc(get_app()->get_hostname()),
|
||||||
@@ -239,9 +239,7 @@ function import_post(&$a) {
|
|||||||
// reset the original primary hubloc if it is being seized
|
// reset the original primary hubloc if it is being seized
|
||||||
|
|
||||||
if($seize)
|
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' ",
|
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
|
||||||
dbesc($channel['channel_hash']),
|
dbesc($channel['channel_hash']),
|
||||||
dbesc(z_root())
|
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);
|
notice( t('Location not found.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where (hubloc_flags & %d)>0 and hubloc_hash = '%s' ",
|
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' ",
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
|
||||||
dbesc($channel['channel_hash'])
|
dbesc($channel['channel_hash'])
|
||||||
);
|
);
|
||||||
$r = q("update hubloc set hubloc_flags = (hubloc_flags & %d) where hubloc_id = %d and hubloc_hash = '%s'",
|
$r = q("update hubloc set hubloc_primary = 1 where hubloc_id = %d and hubloc_hash = '%s'",
|
||||||
intval(HUBLOC_FLAGS_PRIMARY),
|
|
||||||
intval($hubloc_id),
|
intval($hubloc_id),
|
||||||
dbesc($channel['channel_hash'])
|
dbesc($channel['channel_hash'])
|
||||||
);
|
);
|
||||||
@@ -37,7 +34,7 @@ function locs_post(&$a) {
|
|||||||
if($_REQUEST['drop']) {
|
if($_REQUEST['drop']) {
|
||||||
$hubloc_id = intval($_REQUEST['drop']);
|
$hubloc_id = intval($_REQUEST['drop']);
|
||||||
if($hubloc_id) {
|
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),
|
intval($hubloc_id),
|
||||||
dbesc(z_root()),
|
dbesc(z_root()),
|
||||||
dbesc($channel['channel_hash'])
|
dbesc($channel['channel_hash'])
|
||||||
@@ -46,7 +43,7 @@ function locs_post(&$a) {
|
|||||||
notice( t('Location not found.') . EOL);
|
notice( t('Location not found.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) {
|
if(intval($r[0]['hubloc_primary'])) {
|
||||||
notice( t('Primary location cannot be removed.') . EOL);
|
notice( t('Primary location cannot be removed.') . EOL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -83,7 +80,7 @@ function locs_content(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
for($x = 0; $x < count($r); $x ++) {
|
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);
|
$r[$x]['deleted'] = (intval($r[$x]['hubloc_deleted']) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user