diff options
author | friendica <info@friendica.com> | 2015-04-23 19:49:41 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-04-23 19:49:41 -0700 |
commit | 6679734135fb04f4a7beccb81663bf1e9574f062 (patch) | |
tree | 887488543d98b5dd297d917718bdd99844e83ba5 /mod/magic.php | |
parent | 08b757a22cd2804bfec8ecf682b6987b8c06ca49 (diff) | |
parent | c696860cc53bc25558d83de5eda65d9b583da382 (diff) | |
download | volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.gz volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.tar.bz2 volse-hubzilla-6679734135fb04f4a7beccb81663bf1e9574f062.zip |
Merge branch 'master' into tres
Conflicts:
include/Contact.php
include/ItemObject.php
include/api.php
include/attach.php
include/diaspora.php
include/dir_fns.php
include/enotify.php
include/event.php
include/expire.php
include/items.php
include/notifier.php
include/notify.php
include/photos.php
include/taxonomy.php
include/text.php
include/widgets.php
include/zot.php
mod/admin.php
mod/channel.php
mod/dirsearch.php
mod/display.php
mod/editwebpage.php
mod/events.php
mod/home.php
mod/item.php
mod/manage.php
mod/mood.php
mod/network.php
mod/page.php
mod/photos.php
mod/ping.php
mod/post.php
mod/thing.php
mod/viewsrc.php
view/css/mod_events.css
Diffstat (limited to 'mod/magic.php')
-rw-r--r-- | mod/magic.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/mod/magic.php b/mod/magic.php index c31fa71ae..df8ac39a8 100644 --- a/mod/magic.php +++ b/mod/magic.php @@ -10,11 +10,10 @@ function magic_init(&$a) { logger('mod_magic: args: ' . print_r($_REQUEST,true),LOGGER_DATA); $addr = ((x($_REQUEST,'addr')) ? $_REQUEST['addr'] : ''); - $hash = ((x($_REQUEST,'hash')) ? $_REQUEST['hash'] : ''); $dest = ((x($_REQUEST,'dest')) ? $_REQUEST['dest'] : ''); $test = ((x($_REQUEST,'test')) ? intval($_REQUEST['test']) : 0); $rev = ((x($_REQUEST,'rev')) ? intval($_REQUEST['rev']) : 0); - + $delegate = ((x($_REQUEST,'delegate')) ? $_REQUEST['delegate'] : ''); $parsed = parse_url($dest); if(! $parsed) { @@ -100,6 +99,29 @@ function magic_init(&$a) { $ret['message'] .= 'Local site - you are already authenticated.' . EOL; return $ret; } + + $delegation_success = false; + if($delegate) { + $r = q("select * from channel left join hubloc on channel_hash = hubloc_hash where hubloc_addr = '%s' limit 1", + dbesc($delegate) + ); + if($r && intval($r[0]['channel_id'])) { + $allowed = perm_is_allowed($r[0]['channel_id'],get_observer_hash(),'delegate'); + if($allowed) { + $_SESSION['delegate_channel'] = $r[0]['channel_id']; + $_SESSION['delegate'] = get_observer_hash(); + $_SESSION['account_id'] = intval($r[0]['channel_account_id']); + change_channel($r[0]['channel_id']); + $delegation_success = true; + } + } + } + + + + // FIXME: check and honour local delegation + + goaway($dest); } @@ -123,6 +145,9 @@ function magic_init(&$a) { $target_url = $x[0]['hubloc_callback'] . '/?f=&auth=' . urlencode($channel['channel_address'] . '@' . $a->get_hostname()) . '&sec=' . $token . '&dest=' . urlencode($dest) . '&version=' . ZOT_REVISION; + if($delegate) + $target_url .= '&delegate=' . urlencode($delegate); + logger('mod_magic: redirecting to: ' . $target_url, LOGGER_DEBUG); if($test) { |