diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Contact.php | 28 | ||||
-rw-r--r-- | include/hubloc.php | 3 | ||||
-rw-r--r-- | include/notifier.php | 7 | ||||
-rw-r--r-- | include/onedirsync.php | 2 | ||||
-rw-r--r-- | include/zot.php | 32 |
5 files changed, 26 insertions, 46 deletions
diff --git a/include/Contact.php b/include/Contact.php index 4c80f5d6a..4a016e32f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -272,8 +272,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { ); - $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s'", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", dbesc($channel['channel_hash']) ); @@ -312,8 +311,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { intval($channel_id) ); - $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s' and hubloc_url = '%s' ", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", dbesc($channel['channel_hash']), dbesc(z_root()) ); @@ -322,9 +320,8 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { $hublocs = 0; - $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d)>0", - dbesc($channel['channel_hash']), - intval(HUBLOC_FLAGS_DELETED) + $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", + dbesc($channel['channel_hash']) ); if($r) $hublocs = count($r); @@ -374,10 +371,8 @@ function mark_orphan_hubsxchans() { if($dirmode == DIRECTORY_MODE_NORMAL) return; - $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d)>0 + $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", - intval(HUBLOC_OFFLINE), - intval(HUBLOC_OFFLINE), db_utcnow(), db_quoteinterval('36 day') ); @@ -394,9 +389,7 @@ function mark_orphan_hubsxchans() { // } - $r = q("select hubloc_id, hubloc_hash from hubloc where (hubloc_status & %d)>0 and not (hubloc_flags & %d)>0", - intval(HUBLOC_OFFLINE), - intval(HUBLOC_FLAGS_ORPHANCHECK) + $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0", ); if($r) { @@ -404,9 +397,8 @@ 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 not (hubloc_status & %d)>0", + $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0", dbesc($rr['hubloc_hash']), - intval(HUBLOC_OFFLINE) ); if($x) { @@ -431,8 +423,7 @@ function mark_orphan_hubsxchans() { // mark that we've checked this entry so we don't need to do it again - $y = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_ORPHANCHECK), + $y = q("update hubloc set hubloc_orphancheck = 1 where hubloc_id = %d", dbesc($rr['hubloc_id']) ); } @@ -501,8 +492,7 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) { // directory servers need to keep the record around for sync purposes - mark it deleted - $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s'", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", dbesc($xchan) ); diff --git a/include/hubloc.php b/include/hubloc.php index b5a3d47c5..92736e090 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -96,8 +96,7 @@ function remove_obsolete_hublocs() { ? intval(get_config('system','delivery_interval')) : 2 ); foreach($r as $rr) { - q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_DELETED), + q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d", intval($rr['hubloc_id']) ); diff --git a/include/notifier.php b/include/notifier.php index 06ef7bc94..0bdc71261 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -497,11 +497,8 @@ function notifier_run($argv, $argc){ where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1"); } else { - $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc - where hubloc_hash in (" . implode(',',$recipients) . ") and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0", - intval(HUBLOC_FLAGS_DELETED), - intval(HUBLOC_OFFLINE) - ); + $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") + and hubloc_error = 0 and hubloc_deleted = 0"); } if(! $r) { diff --git a/include/onedirsync.php b/include/onedirsync.php index a1450e183..c94a1410f 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) && ($h[0]['hubloc_status'] & HUBLOC_OFFLINE)) { + 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/zot.php b/include/zot.php index 384769d61..ac5127f1c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -79,9 +79,8 @@ function zot_get_hublocs($hash) { /** Only search for active hublocs - e.g. those that haven't been marked deleted */ - $ret = q("select * from hubloc where hubloc_hash = '%s' and not ( hubloc_flags & %d )>0 order by hubloc_url ", - dbesc($hash), - intval(HUBLOC_FLAGS_DELETED) + $ret = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted != 0 order by hubloc_url ", + dbesc($hash) ); return $ret; } @@ -1884,9 +1883,8 @@ function sync_locations($sender,$arr,$absolute = false) { // Should we do this? It's basically saying that the channel knows better than // the directory server if the site is alive. - if($r[0]['hubloc_status'] & HUBLOC_OFFLINE) { - q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d", - intval(HUBLOC_OFFLINE), + if($r[0]['hubloc_error']) { + q("update hubloc set hubloc_error = 0 where hubloc_id = %d", intval($r[0]['hubloc_id']) ); if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { @@ -1934,10 +1932,10 @@ function sync_locations($sender,$arr,$absolute = false) { $changed = true; } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) { - $n = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", - intval(HUBLOC_FLAGS_DELETED), + if((intval($r[0]['hubloc_deleted']) && (! $location['deleted'])) + || ((! (intval($r[0]['hubloc_deleted']))) && ($location['deleted']))) { + $n = q("update hubloc set hubloc_deleted = %d, hubloc_updated = '%s' where hubloc_id = %d", + intval($location['deleted']), dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); @@ -1994,8 +1992,7 @@ function sync_locations($sender,$arr,$absolute = false) { foreach($xisting as $x) { if(! array_key_exists('updated',$x)) { logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_url']); - $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d", dbesc(datetime_convert()), intval($x['hubloc_id']) ); @@ -2029,7 +2026,7 @@ function zot_encode_locations($channel) { 'url_sig' => $hub['hubloc_url_sig'], 'callback' => $hub['hubloc_callback'], 'sitekey' => $hub['hubloc_sitekey'], - 'deleted' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_DELETED) ? true : false) + 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) ); } } @@ -2917,12 +2914,9 @@ function zot_process_message_request($data) { if($messages) { $env_recips = null; - $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host - from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d)>0 - and not (hubloc_status & %d)>0 group by hubloc_sitekey", - dbesc($sender_hash), - intval(HUBLOC_FLAGS_DELETED), - intval(HUBLOC_OFFLINE) + $r = q("select * from hubloc where hubloc_hash = '%s' and not hubloc_error and not hubloc_deleted + group by hubloc_sitekey", + dbesc($sender_hash) ); if(! $r) { logger('no hubs'); |