3 function redir_init(&$a) {
5 $url = ((x($_GET,'url')) ? $_GET['url'] : '');
9 if(local_user() && $a->argc > 1 && intval($a->argv[1])) {
13 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
18 if((! count($r)) || ($r[0]['network'] !== NETWORK_DFRN))
21 $dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
23 if($r[0]['duplex'] && $r[0]['issued-id']) {
24 $orig_id = $r[0]['issued-id'];
25 $dfrn_id = '1:' . $orig_id;
27 if($r[0]['duplex'] && $r[0]['dfrn-id']) {
28 $orig_id = $r[0]['dfrn-id'];
29 $dfrn_id = '0:' . $orig_id;
32 $sec = random_string();
34 q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)
35 VALUES( %d, %s, '%s', '%s', %d )",
43 logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
44 $dest = (($url) ? '&destination_url=' . $url : '');
45 goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
46 . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest );
50 $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
52 $handle = $_SESSION['handle'];
55 $url = str_replace('{zid}','&zid=' . $handle,$url);