diff options
author | Mario Vavti <mario@mariovavti.com> | 2017-09-08 09:22:36 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2017-09-08 09:22:36 +0200 |
commit | 108bb7649bb61bee65d9923c9080c3af8e715bc4 (patch) | |
tree | 4b96649d85d098de8e723df85b409cb0a43832d1 /include/zid.php | |
parent | 7b3aa92b5ad09c0820db2b20bc462c975f0d3aba (diff) | |
parent | 1104e2652f15aaa405208b6dec9e439fb8c39537 (diff) | |
download | volse-hubzilla-108bb7649bb61bee65d9923c9080c3af8e715bc4.tar.gz volse-hubzilla-108bb7649bb61bee65d9923c9080c3af8e715bc4.tar.bz2 volse-hubzilla-108bb7649bb61bee65d9923c9080c3af8e715bc4.zip |
Merge remote-tracking branch 'mike/master' into dev
Diffstat (limited to 'include/zid.php')
-rw-r--r-- | include/zid.php | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/include/zid.php b/include/zid.php index ee43fd7c8..d5d863be6 100644 --- a/include/zid.php +++ b/include/zid.php @@ -81,6 +81,10 @@ function zid($s,$address = '') { } +function strip_query_param($s,$param) { + return preg_replace('/[\?&]' . $param . '=(.*?)(&|$)/ism','$2',$s); +} + function strip_zids($s) { return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s); } @@ -230,3 +234,68 @@ function red_zrlify_img_callback($matches) { return $matches[0]; } +function owt_init($token) { + + \Zotlabs\Zot\Verify::purge('owt','3 MINUTE'); + + $ob_hash = \Zotlabs\Zot\Verify::get_meta('owt',0,$token); + + if($ob_hash === false) { + return; + } + + $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash + where hubloc_addr = '%s' order by hubloc_id desc", + dbesc($ob_hash) + ); + + if(! $r) { + // finger them if they can't be found. + $j = \Zotlabs\Zot\Finger::run($ob_hash, null); + if ($j['success']) { + import_xchan($j); + $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash + where hubloc_addr = '%s' order by hubloc_id desc", + dbesc($ob_hash) + ); + } + } + if(! $r) { + logger('owt: unable to finger ' . $ob_hash); + return; + } + $hubloc = $r[0]; + + $_SESSION['authenticated'] = 1; + + $delegate_success = false; + if($_REQUEST['delegate']) { + $r = q("select * from channel left join xchan on channel_hash = xchan_hash where xchan_addr = '%s' limit 1", + dbesc($_REQUEST['delegate']) + ); + if ($r && intval($r[0]['channel_id'])) { + $allowed = perm_is_allowed($r[0]['channel_id'],$hubloc['xchan_hash'],'delegate'); + if($allowed) { + $_SESSION['delegate_channel'] = $r[0]['channel_id']; + $_SESSION['delegate'] = $hubloc['xchan_hash']; + $_SESSION['account_id'] = intval($r[0]['channel_account_id']); + require_once('include/security.php'); + // this will set the local_channel authentication in the session + change_channel($r[0]['channel_id']); + $delegate_success = true; + } + } + } + + if (! $delegate_success) { + // normal visitor (remote_channel) login session credentials + $_SESSION['visitor_id'] = $hubloc['xchan_hash']; + $_SESSION['my_url'] = $hubloc['xchan_url']; + $_SESSION['my_address'] = $hubloc['hubloc_addr']; + $_SESSION['remote_hub'] = $hubloc['hubloc_url']; + $_SESSION['DNT'] = 1; + } + + logger('owa success!'); + +}
\ No newline at end of file |