diff options
author | friendica <info@friendica.com> | 2013-11-17 14:28:13 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-11-17 14:28:13 -0800 |
commit | 28b0eb9c330261ea6a8cd36248c194b6b153f5e6 (patch) | |
tree | a5805cf30712714c05c1a87aa73ad8004aa1edb6 /mod | |
parent | bec85f1494026a94eb521b802a74b67762b01a6c (diff) | |
download | volse-hubzilla-28b0eb9c330261ea6a8cd36248c194b6b153f5e6.tar.gz volse-hubzilla-28b0eb9c330261ea6a8cd36248c194b6b153f5e6.tar.bz2 volse-hubzilla-28b0eb9c330261ea6a8cd36248c194b6b153f5e6.zip |
more work on redmtx.com magic-auth situation
Diffstat (limited to 'mod')
-rw-r--r-- | mod/magic.php | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/mod/magic.php b/mod/magic.php index 4794f86a8..21f703192 100644 --- a/mod/magic.php +++ b/mod/magic.php @@ -28,16 +28,34 @@ function magic_init(&$a) { ); } else { + // See if we know anybody at the dest site that will unlock the door for us + // This is the equivalent of buzzing every apartment in an apartment block + // to get inside the front gate. The thing about magic auth is that we're + // authenticating to the other site. Permissions provided by various + // channels will still affect what we can do once authenticated. + $b = explode('/',$dest); if(count($b) >= 2) { $u = $b[0] . '//' . $b[2]; - $x = q("select xchan.xchan_url, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash - where hubloc_url = '%s' order by hubloc_id desc limit 5", - dbesc($u) - ); + if(local_user()) { + // first look for a connection or anybody who knows us + $x = q("select xchan.xchan_url, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash + left join abook on abook_xchan = hubloc_hash + where abook_channel = %d and hubloc_url = '%s' order by hubloc_id desc limit 5", + intval(local_user()), + dbesc($u) + ); + } + if(! $x) { + // no luck - ok anybody will do + $x = q("select xchan.xchan_url, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash + where hubloc_url = '%s' order by hubloc_id desc limit 5", + dbesc($u) + ); + } if($x) { // They must have a valid hubloc_addr |