diff options
author | marijus <mario@localhost.localdomain> | 2013-12-16 12:51:35 +0100 |
---|---|---|
committer | marijus <mario@localhost.localdomain> | 2013-12-16 12:51:35 +0100 |
commit | 5512d6aa1df61e0cdab31a2758d3a865ddfbc280 (patch) | |
tree | 1f2d763c495ad5192456d54036eb3dcc8fafb595 /mod/zfinger.php | |
parent | c3c7a068332ae08aea5eeb8eaf820e34c9cf210b (diff) | |
parent | a7a775a718ef92c9bd623849baab1e386071d70b (diff) | |
download | volse-hubzilla-5512d6aa1df61e0cdab31a2758d3a865ddfbc280.tar.gz volse-hubzilla-5512d6aa1df61e0cdab31a2758d3a865ddfbc280.tar.bz2 volse-hubzilla-5512d6aa1df61e0cdab31a2758d3a865ddfbc280.zip |
Merge branch 'master' of https://github.com/friendica/red
Diffstat (limited to 'mod/zfinger.php')
-rw-r--r-- | mod/zfinger.php | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/mod/zfinger.php b/mod/zfinger.php index 0827f3424..aad8e224d 100644 --- a/mod/zfinger.php +++ b/mod/zfinger.php @@ -52,11 +52,33 @@ function zfinger_init(&$a) { ); } elseif(strlen($zaddr)) { - $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash - where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1", - dbesc($zaddr), - dbesc($zaddr) - ); + if(strpos($zaddr,'[system]') === false) { /* normal address lookup */ + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + where ( channel_address = '%s' or xchan_addr = '%s' ) limit 1", + dbesc($zaddr), + dbesc($zaddr) + ); + } + + else { + + /** + * The special address '[system]' will return a system channel if one has been defined, + * Or the first valid channel we find if there are no system channels. + * + * This is used by magic-auth if we have no prior communications with this site - and + * returns an identity on this site which we can use to create a valid hub record so that + * we can exchange signed messages. The precise identity is irrelevant. It's the hub + * information that we really need at the other end - and this will return it. + * + */ + + $r = q("select channel.*, xchan.* from channel left join xchan on channel_hash = xchan_hash + where (( channel_pageflags & %d ) or not ( channel_pageflags & %d )) order by channel_id limit 1", + intval(PAGE_SYSTEM), + intval(PAGE_REMOVED) + ); + } } else { $ret['message'] = 'Invalid request'; |