more ZAT work
This commit is contained in:
parent
e6c8614801
commit
f3eb9af046
@ -59,7 +59,14 @@ class WebServer {
|
|||||||
\App::$query_string = strip_zids(\App::$query_string);
|
\App::$query_string = strip_zids(\App::$query_string);
|
||||||
if(! local_channel()) {
|
if(! local_channel()) {
|
||||||
$_SESSION['my_address'] = $_GET['zid'];
|
$_SESSION['my_address'] = $_GET['zid'];
|
||||||
zid_init($a);
|
zid_init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((x($_GET,'zat')) && (! \App::$install)) {
|
||||||
|
\App::$query_string = strip_zats(\App::$query_string);
|
||||||
|
if(! local_channel()) {
|
||||||
|
zat_init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,13 +1310,12 @@ function get_my_address() {
|
|||||||
* If somebody arrives at our site using a zid, add their xchan to our DB if we don't have it already.
|
* If somebody arrives at our site using a zid, add their xchan to our DB if we don't have it already.
|
||||||
* And if they aren't already authenticated here, attempt reverse magic auth.
|
* And if they aren't already authenticated here, attempt reverse magic auth.
|
||||||
*
|
*
|
||||||
* @param App &$a
|
|
||||||
*
|
*
|
||||||
* @hooks 'zid_init'
|
* @hooks 'zid_init'
|
||||||
* string 'zid' - their zid
|
* string 'zid' - their zid
|
||||||
* string 'url' - the destination url
|
* string 'url' - the destination url
|
||||||
*/
|
*/
|
||||||
function zid_init(&$a) {
|
function zid_init() {
|
||||||
$tmp_str = get_my_address();
|
$tmp_str = get_my_address();
|
||||||
if(validate_email($tmp_str)) {
|
if(validate_email($tmp_str)) {
|
||||||
Zotlabs\Daemon\Master::Summon(array('Gprobe',bin2hex($tmp_str)));
|
Zotlabs\Daemon\Master::Summon(array('Gprobe',bin2hex($tmp_str)));
|
||||||
@ -1342,6 +1341,28 @@ function zid_init(&$a) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief
|
||||||
|
*
|
||||||
|
* If somebody arrives at our site using a zat, authenticate them
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function zat_init() {
|
||||||
|
if(local_channel() || remote_channel())
|
||||||
|
return;
|
||||||
|
|
||||||
|
$r = q("select * from atoken where atoken_token = '%s' limit 1",
|
||||||
|
dbesc($_REQUEST['zat'])
|
||||||
|
);
|
||||||
|
if($r) {
|
||||||
|
atoken_login($r[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Adds a zid parameter to a url.
|
* @brief Adds a zid parameter to a url.
|
||||||
*
|
*
|
||||||
|
@ -102,6 +102,8 @@ function atoken_xchan($atoken) {
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'xchan_hash' => $atoken['atoken_uid'] . '.' . $atoken['atoken_name'],
|
'xchan_hash' => $atoken['atoken_uid'] . '.' . $atoken['atoken_name'],
|
||||||
|
'xchan_name' => $atoken['atoken_name'],
|
||||||
|
'xchan_addr' => t('guest:') . $atoken['atoken_name'] . '@' . \App::get_hostname(),
|
||||||
'xchan_network' => 'unknown',
|
'xchan_network' => 'unknown',
|
||||||
'xchan_hidden' => 1,
|
'xchan_hidden' => 1,
|
||||||
'xchan_photo_mimetype' => 'image/jpeg',
|
'xchan_photo_mimetype' => 'image/jpeg',
|
||||||
|
@ -774,6 +774,10 @@ function strip_zids($s) {
|
|||||||
return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s);
|
return preg_replace('/[\?&]zid=(.*?)(&|$)/ism','$2',$s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function strip_zats($s) {
|
||||||
|
return preg_replace('/[\?&]zat=(.*?)(&|$)/ism','$2',$s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// quick and dirty quoted_printable encoding
|
// quick and dirty quoted_printable encoding
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user