aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2020-12-12 21:39:38 +0000
committerMario <mario@mariovavti.com>2020-12-12 22:41:38 +0100
commit634ace552d40f9f287a6419dd6fe5b19d3f390ca (patch)
tree6f28c1a243f186af7c7a6b90ea5afc1b65c515ac /Zotlabs
parent751a1ba969b4a48b40d42022ed342db7e4e00c03 (diff)
downloadvolse-hubzilla-634ace552d40f9f287a6419dd6fe5b19d3f390ca.tar.gz
volse-hubzilla-634ace552d40f9f287a6419dd6fe5b19d3f390ca.tar.bz2
volse-hubzilla-634ace552d40f9f287a6419dd6fe5b19d3f390ca.zip
try to prevent hubloc confusion in some places
(cherry picked from commit 61cfeb5bdb749319357912d958cd13304b895bce)
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Onedirsync.php19
-rw-r--r--Zotlabs/Lib/Libsync.php36
-rw-r--r--Zotlabs/Module/Cdav.php29
-rw-r--r--Zotlabs/Module/Dav.php5
4 files changed, 50 insertions, 39 deletions
diff --git a/Zotlabs/Daemon/Onedirsync.php b/Zotlabs/Daemon/Onedirsync.php
index cc16c0b58..2ad76761d 100644
--- a/Zotlabs/Daemon/Onedirsync.php
+++ b/Zotlabs/Daemon/Onedirsync.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Daemon;
+use Zotlabs\Lib\Libzot;
+
require_once('include/zot.php');
require_once('include/dir_fns.php');
@@ -11,7 +13,7 @@ class Onedirsync {
static public function run($argc,$argv) {
logger('onedirsync: start ' . intval($argv[1]));
-
+
if(($argc > 1) && (intval($argv[1])))
$update_id = intval($argv[1]);
@@ -19,7 +21,7 @@ class Onedirsync {
logger('onedirsync: no update');
return;
}
-
+
$r = q("select * from updates where ud_id = %d limit 1",
intval($update_id)
);
@@ -50,10 +52,13 @@ class Onedirsync {
// ignore doing an update if this ud_addr refers to a known dead hubloc
- $h = q("select * from hubloc where hubloc_addr = '%s' limit 1",
+ $h = q("select * from hubloc where hubloc_addr = '%s'",
dbesc($r[0]['ud_addr'])
);
- if(($h) && ($h[0]['hubloc_status'] & HUBLOC_OFFLINE)) {
+
+ $h = Libzot::zot_record_preferred($h);
+
+ if(($h) && ($h['hubloc_status'] & HUBLOC_OFFLINE)) {
$y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 ",
intval(UPDATE_FLAGS_UPDATED),
dbesc($r[0]['ud_addr']),
@@ -63,13 +68,13 @@ class Onedirsync {
return;
}
- // we might have to pull this out some day, but for now update_directory_entry()
+ // we might have to pull this out some day, but for now update_directory_entry()
// runs zot_finger() and is kind of zot specific
- if($h && $h[0]['hubloc_network'] !== 'zot')
+ if($h && ! in_array($h['hubloc_network'], ['zot6', 'zot']))
return;
- update_directory_entry($r[0]);
+ update_directory_entry($r[0]);
return;
}
diff --git a/Zotlabs/Lib/Libsync.php b/Zotlabs/Lib/Libsync.php
index cff320e11..72a9afc48 100644
--- a/Zotlabs/Lib/Libsync.php
+++ b/Zotlabs/Lib/Libsync.php
@@ -42,7 +42,7 @@ class Libsync {
$channel = $r[0];
- // don't provide these in the export
+ // don't provide these in the export
unset($channel['channel_active']);
unset($channel['channel_password']);
@@ -245,7 +245,7 @@ class Libsync {
if(array_key_exists('app',$arr) && $arr['app'])
sync_apps($channel,$arr['app']);
-
+
if(array_key_exists('addressbook',$arr) && $arr['addressbook'])
sync_addressbook($channel,$arr['addressbook']);
@@ -260,7 +260,7 @@ class Libsync {
if(array_key_exists('mail',$arr) && $arr['mail'])
sync_mail($channel,$arr['mail']);
-
+
if(array_key_exists('event',$arr) && $arr['event'])
sync_events($channel,$arr['event']);
@@ -269,7 +269,7 @@ class Libsync {
if(array_key_exists('item',$arr) && $arr['item'])
sync_items($channel,$arr['item'],((array_key_exists('relocate',$arr)) ? $arr['relocate'] : null));
-
+
// deprecated, maintaining for a few months for upward compatibility
// this should sync webpages, but the logic is a bit subtle
@@ -278,7 +278,7 @@ class Libsync {
if(array_key_exists('menu',$arr) && $arr['menu'])
sync_menus($channel,$arr['menu']);
-
+
if(array_key_exists('file',$arr) && $arr['file'])
sync_files($channel,$arr['file']);
@@ -293,7 +293,7 @@ class Libsync {
if(array_key_exists('channel_pageflags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) {
// Several pageflags are site-specific and cannot be sync'd.
- // Only allow those bits which are shareable from the remote and then
+ // Only allow those bits which are shareable from the remote and then
// logically OR with the local flags
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] & (PAGE_HIDDEN|PAGE_AUTOCONNECT|PAGE_APPLICATION|PAGE_PREMIUM|PAGE_ADULT);
@@ -562,7 +562,7 @@ class Libsync {
// our group list is already synchronised
if($x) {
foreach($x as $y) {
-
+
// for each group, loop on members list we just received
if(isset($y['hash']) && isset($members[$y['hash']])) {
foreach($members[$y['hash']] as $member) {
@@ -574,9 +574,9 @@ class Libsync {
);
if($z)
$found = true;
-
+
// if somebody is in the group that wasn't before - add them
-
+
if(! $found) {
q("INSERT INTO pgrp_member (uid, gid, xchan)
VALUES( %d, %d, '%s' ) ",
@@ -587,7 +587,7 @@ class Libsync {
}
}
}
-
+
// now retrieve a list of members we have on this site
$m = q("select xchan from pgrp_member where gid = %d and uid = %d",
intval($y['id']),
@@ -615,7 +615,7 @@ class Libsync {
$disallowed = array('id','aid','uid','guid');
foreach($arr['profile'] as $profile) {
-
+
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
@@ -628,7 +628,7 @@ class Libsync {
'profile_guid' => $profile['profile_guid'],
]
);
-
+
$x = q("select * from profile where profile_guid = '%s' and uid = %d limit 1",
dbesc($profile['profile_guid']),
intval($channel['channel_id'])
@@ -775,14 +775,14 @@ class Libsync {
);
if($r) {
logger('Hub exists: ' . $location['url'], LOGGER_DEBUG);
-
+
// update connection timestamp if this is the site we're talking to
// This only happens when called from import_xchan
$current_site = false;
$t = datetime_convert('UTC','UTC','now - 15 minutes');
-
+
if(array_key_exists('site',$arr) && $location['url'] == $arr['site']['url']) {
q("update hubloc set hubloc_connected = '%s', hubloc_updated = '%s' where hubloc_id = %d and hubloc_connected < '%s'",
dbesc(datetime_convert()),
@@ -903,12 +903,14 @@ class Libsync {
$changed = true;
if($location['primary']) {
- $r = q("select * from hubloc where hubloc_addr = '%s' and hubloc_sitekey = '%s' limit 1",
+ $r = q("select * from hubloc where hubloc_addr = '%s' and hubloc_sitekey = '%s'",
dbesc($location['address']),
dbesc($location['sitekey'])
);
- if($r)
- hubloc_change_primary($r[0]);
+ if($r) {
+ $r = Libzot::zot_record_preferred($r);
+ hubloc_change_primary($r);
+ }
}
}
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index d7d57664c..0f4f4585e 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -5,6 +5,8 @@ use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
use Zotlabs\Web\HTTPSig;
+use Zotlabs\Lib\Libzot;
+
require_once('include/event.php');
@@ -47,11 +49,12 @@ class Cdav extends Controller {
if($sigblock) {
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
- $r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
+ $r = q("select * from hubloc where hubloc_addr = '%s'",
dbesc($keyId)
);
if($r) {
- $c = channelx_by_hash($r[0]['hubloc_hash']);
+ $r = Libzot::zot_record_preferred($r);
+ $c = channelx_by_hash($r['hubloc_hash']);
if($c) {
$a = q("select * from account where account_id = %d limit 1",
intval($c['channel_account_id'])
@@ -157,10 +160,10 @@ class Cdav extends Controller {
}
}
-
+
// Track CDAV updates from remote clients
- $httpmethod = $_SERVER['REQUEST_METHOD'];
+ $httpmethod = $_SERVER['REQUEST_METHOD'];
if($httpmethod === 'PUT' || $httpmethod === 'DELETE') {
@@ -190,9 +193,9 @@ class Cdav extends Controller {
if($x = get_cdav_id($principalUri, explode("/", $httpuri)[4], $cdavtable)) {
$cdavdata = $this->get_cdav_data($x['id'], $cdavtable);
-
+
$etag = (isset($_SERVER['HTTP_IF_MATCH']) ? $_SERVER['HTTP_IF_MATCH'] : false);
-
+
// delete
if($httpmethod === 'DELETE' && $cdavdata['etag'] == $etag)
build_sync_packet($channel['channel_id'], [
@@ -762,7 +765,7 @@ class Cdav extends Controller {
$cardData = $vcard->serialize();
$carddavBackend->updateCard($id, $uri, $cardData);
-
+
build_sync_packet($channel['channel_id'], [
'addressbook' => [
'action' => 'update_card',
@@ -804,7 +807,7 @@ class Cdav extends Controller {
$src = $_FILES['userfile']['tmp_name'];
if($src) {
-
+
$carddata = @file_get_contents($src);
if($_REQUEST['c_upload']) {
@@ -840,13 +843,13 @@ class Cdav extends Controller {
$objects = new \Sabre\VObject\Splitter\VCard($carddata);
$profile = \Sabre\VObject\Node::PROFILE_CARDDAV;
$backend = new \Sabre\CardDAV\Backend\PDO($pdo);
-
+
$cdavdata = $this->get_cdav_data($id, 'addressbooks');
}
-
+
$ids = [];
import_cdav_card($id, $ext, $table, $column, $objects, $profile, $backend, $ids, true);
-
+
build_sync_packet($channel['channel_id'], [
$sync => [
'action' => 'import',
@@ -1013,7 +1016,7 @@ class Cdav extends Controller {
$catsenabled = feature_enabled(local_channel(), 'categories');
require_once('include/acl_selectors.php');
-
+
$accesslist = new \Zotlabs\Access\AccessList($channel);
$perm_defaults = $accesslist->get();
@@ -1427,7 +1430,7 @@ class Cdav extends Controller {
return;
$uri = 'principals/' . $channel['channel_address'];
-
+
$r = q("select * from principals where uri = '%s' limit 1",
dbesc($uri)
diff --git a/Zotlabs/Module/Dav.php b/Zotlabs/Module/Dav.php
index adab25e45..11950dda0 100644
--- a/Zotlabs/Module/Dav.php
+++ b/Zotlabs/Module/Dav.php
@@ -51,11 +51,12 @@ class Dav extends \Zotlabs\Web\Controller {
if($sigblock) {
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
- $r = q("select * from hubloc where hubloc_addr = '%s' limit 1",
+ $r = q("select * from hubloc where hubloc_addr = '%s'",
dbesc($keyId)
);
if($r) {
- $c = channelx_by_hash($r[0]['hubloc_hash']);
+ $r = Libzot::zot_record_preferred($r);
+ $c = channelx_by_hash($r['hubloc_hash']);
if($c) {
$a = q("select * from account where account_id = %d limit 1",
intval($c['channel_account_id'])