get_channel(); $token = random_string(); $token_sig = rsa_sign($token,$channel['channel_prvkey']); $channel['token'] = $token; $channel['token_sig'] = $token_sig; $recip = array(array('guid' => $x[0]['hubloc_guid'],'guid_sig' => $x[0]['hubloc_guid_sig'])); $hash = random_string(); $r = q("insert into verify ( type, channel, token, meta, created) values ('%s','%d','%s','%s','%s')", dbesc('auth'), intval($channel['channel_id']), dbesc($token), dbesc($hubloc['hubloc_hash']), dbesc(datetime_convert()) ); $packet = zot_build_packet($channel,'auth',$recip,$x[0]['hubloc_sitekey'],$hash); $result = zot_zot($x[0]['hubloc_callback'],$packet); if($result['success']) { $j = json_decode($result['body'],true); if($j['iv']) { $y = aes_unencapsulate($j,$channel['prvkey']); $j = json_decode($y,true); } if($j['token'] && $j['ticket'] && $j['token'] === $token) { $r = q("delete from verify where token = '%s' and type = '%s' and channel = %d limit 1", dbesc($token), dbesc('auth'), intval($channel['channel_id']) ); goaway($x[0]['callback'] . '?f=&ticket=' . $ticket . '&dest=' . $dest); } } goaway($dest); } goaway(z_root()); }