3 function redir_init(&$a) {
5 if((! local_user()) || (! ($a->argc == 2)) || (! intval($a->argv[1])))
6 goaway($a->get_baseurl());
8 $url = ((x($_GET,'url')) ? $_GET['url'] : '');
10 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
15 if((! count($r)) || ($r[0]['network'] !== 'dfrn'))
16 goaway($a->get_baseurl());
18 $dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
20 if($r[0]['duplex'] && $r[0]['issued-id']) {
21 $orig_id = $r[0]['issued-id'];
22 $dfrn_id = '1:' . $orig_id;
24 if($r[0]['duplex'] && $r[0]['dfrn-id']) {
25 $orig_id = $r[0]['dfrn-id'];
26 $dfrn_id = '0:' . $orig_id;
29 $sec = random_string();
31 q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)
32 VALUES( %d, %s, '%s', '%s', %d )",
40 logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
41 $dest = (($url) ? '&destination_url=' . $url : '');
42 goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
43 . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest );