aboutsummaryrefslogtreecommitdiffstats
path: root/mod/post.php
diff options
context:
space:
mode:
Diffstat (limited to 'mod/post.php')
-rw-r--r--mod/post.php42
1 files changed, 14 insertions, 28 deletions
diff --git a/mod/post.php b/mod/post.php
index c68ce9646..4c52de44a 100644
--- a/mod/post.php
+++ b/mod/post.php
@@ -103,9 +103,7 @@ function post_init(&$a) {
// Any channel will do, providing it's currently active. We just need to have an
// identity to attach to the packet we send back. So find one.
- $c = q("select * from channel where not ( channel_pageflags & %d )>0 limit 1",
- intval(PAGE_REMOVED)
- );
+ $c = q("select * from channel where channel_removed = 0 limit 1");
if (! $c) {
// nobody here
@@ -286,20 +284,13 @@ function post_init(&$a) {
$a->set_groups(init_groups_visitor($_SESSION['visitor_id']));
info(sprintf( t('Welcome %s. Remote authentication successful.'),$xx['xchan_name']));
logger('mod_zot: auth success from ' . $xx['xchan_addr']);
- q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ",
- intval(HUBLOC_WORKS),
- intval($xx['hubloc_id'])
- );
- } else {
+ }
+ else {
if ($test) {
$ret['message'] .= 'auth failure. ' . print_r($_REQUEST,true) . print_r($j,true) . EOL;
continue;
}
logger('mod_zot: magic-auth failure - not authenticated: ' . $xx['xchan_addr']);
- q("update hubloc set hubloc_status = (hubloc_status | %d ) where hubloc_id = %d ",
- intval(HUBLOC_RECEIVE_ERROR),
- intval($xx['hubloc_id'])
- );
}
if ($test) {
@@ -308,7 +299,6 @@ function post_init(&$a) {
}
}
-
/**
* @FIXME we really want to save the return_url in the session before we
* visit rmagic. This does however prevent a recursion if you visit
@@ -701,9 +691,8 @@ function post_post(&$a) {
* Any hub with the same URL and a different sitekey cannot be valid.
* Get rid of them (mark them deleted). There's a good chance they were re-installs.
*/
-
- q("update hubloc set hubloc_flags = ( hubloc_flags | %d ) where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
- intval(HUBLOC_FLAGS_DELETED),
+
+ q("update hubloc set hubloc_deleted = 1, hubloc_error = 1 where hubloc_url = '%s' and hubloc_sitekey != '%s' ",
dbesc($hub['hubloc_url']),
dbesc($sender['sitekey'])
);
@@ -711,11 +700,12 @@ function post_post(&$a) {
$sitekey = $sender['sitekey'];
}
- // $sender['sitekey'] is a new addition to the protcol to distinguish
+ // $sender['sitekey'] is a new addition to the protcol to distinguish
// hublocs coming from re-installed sites. Older sites will not provide
// this field and we have to still mark them valid, since we can't tell
// if this hubloc has the same sitekey as the packet we received.
+
// Update our DB to show when we last communicated successfully with this hub
// This will allow us to prune dead hubs from using up resources
@@ -727,30 +717,26 @@ function post_post(&$a) {
// a dead hub came back to life - reset any tombstones we might have
- if ($hub['hubloc_status'] & HUBLOC_OFFLINE) {
- q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d and hubloc_sitekey = '%s' ",
- intval(HUBLOC_OFFLINE),
+ if(intval($hub['hubloc_error'])) {
+ q("update hubloc set hubloc_error = 0 where hubloc_id = %d and hubloc_sitekey = '%s' ",
intval($hub['hubloc_id']),
dbesc($sitekey)
);
- if ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) {
- q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d and hubloc_sitekey = '%s' ",
- intval(HUBLOC_FLAGS_ORPHANCHECK),
+ if(intval($r[0]['hubloc_orphancheck'])) {
+ q("update hubloc set hubloc_orhpancheck = 0 where hubloc_id = %d and hubloc_sitekey = '%s' ",
intval($hub['hubloc_id']),
dbesc($sitekey)
);
}
-
- q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'",
- intval(XCHAN_FLAGS_ORPHAN),
- intval(XCHAN_FLAGS_ORPHAN),
+ q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'",
dbesc($hub['hubloc_hash'])
);
}
-
+
$connecting_url = $hub['hubloc_url'];
}
+
/** @TODO check which hub is primary and take action if mismatched */
if (array_key_exists('recipients', $data))