mirror of
https://github.com/friendica/friendica
synced 2024-11-09 17:02:54 +00:00
some zot-id infrastructure
This commit is contained in:
parent
e43a3a412c
commit
61246cbd1c
3 changed files with 48 additions and 32 deletions
2
boot.php
2
boot.php
|
@ -9,7 +9,7 @@ require_once('include/nav.php');
|
|||
require_once('include/cache.php');
|
||||
|
||||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||
define ( 'FRIENDICA_VERSION', '2.3.1238' );
|
||||
define ( 'FRIENDICA_VERSION', '2.3.1239' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.22' );
|
||||
define ( 'DB_UPDATE_VERSION', 1118 );
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ function dfrn_poll_init(&$a) {
|
|||
$_SESSION['authenticated'] = 1;
|
||||
$_SESSION['visitor_id'] = $r[0]['id'];
|
||||
$_SESSION['visitor_home'] = $r[0]['url'];
|
||||
$_SESSION['visitor_handle'] = $r[0]['addr'];
|
||||
$_SESSION['visitor_visiting'] = $r[0]['uid'];
|
||||
info( sprintf(t('%s welcomes %s'), $r[0]['username'] , $r[0]['name']) . EOL);
|
||||
// Visitors get 1 day session.
|
||||
|
|
|
@ -2,44 +2,59 @@
|
|||
|
||||
function redir_init(&$a) {
|
||||
|
||||
if((! local_user()) || (! ($a->argc == 2)) || (! intval($a->argv[1])))
|
||||
goaway(z_root());
|
||||
$cid = $a->argv[1];
|
||||
$url = ((x($_GET,'url')) ? $_GET['url'] : '');
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($cid),
|
||||
intval(local_user())
|
||||
);
|
||||
// traditional DFRN
|
||||
|
||||
if((! count($r)) || ($r[0]['network'] !== 'dfrn'))
|
||||
goaway(z_root());
|
||||
if(local_user() && $a->argc == 2 && intval($a->argv[1])) {
|
||||
|
||||
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
|
||||
$cid = $a->argv[1];
|
||||
|
||||
if($r[0]['duplex'] && $r[0]['issued-id']) {
|
||||
$orig_id = $r[0]['issued-id'];
|
||||
$dfrn_id = '1:' . $orig_id;
|
||||
}
|
||||
if($r[0]['duplex'] && $r[0]['dfrn-id']) {
|
||||
$orig_id = $r[0]['dfrn-id'];
|
||||
$dfrn_id = '0:' . $orig_id;
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($cid),
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
|
||||
goaway(z_root());
|
||||
|
||||
$dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
|
||||
|
||||
if($r[0]['duplex'] && $r[0]['issued-id']) {
|
||||
$orig_id = $r[0]['issued-id'];
|
||||
$dfrn_id = '1:' . $orig_id;
|
||||
}
|
||||
if($r[0]['duplex'] && $r[0]['dfrn-id']) {
|
||||
$orig_id = $r[0]['dfrn-id'];
|
||||
$dfrn_id = '0:' . $orig_id;
|
||||
}
|
||||
|
||||
$sec = random_string();
|
||||
|
||||
q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)
|
||||
VALUES( %d, %s, '%s', '%s', %d )",
|
||||
intval(local_user()),
|
||||
intval($cid),
|
||||
dbesc($dfrn_id),
|
||||
dbesc($sec),
|
||||
intval(time() + 45)
|
||||
);
|
||||
|
||||
logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
|
||||
$dest = (($url) ? '&destination_url=' . $url : '');
|
||||
goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
|
||||
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest );
|
||||
}
|
||||
|
||||
$sec = random_string();
|
||||
if(local_user())
|
||||
$handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
|
||||
if(remote_user())
|
||||
$handle = $_SESSION['handle'];
|
||||
|
||||
q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)
|
||||
VALUES( %d, %s, '%s', '%s', %d )",
|
||||
intval(local_user()),
|
||||
intval($cid),
|
||||
dbesc($dfrn_id),
|
||||
dbesc($sec),
|
||||
intval(time() + 45)
|
||||
);
|
||||
if($url) {
|
||||
$url = str_replace('{zid}','&zid=' . $handle,$url);
|
||||
goaway($url);
|
||||
}
|
||||
|
||||
logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
|
||||
$dest = (($url) ? '&destination_url=' . $url : '');
|
||||
goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
|
||||
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest );
|
||||
|
||||
goaway(z_root());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue