3 function redir_init(App $a) {
5 $url = ((x($_GET,'url')) ? $_GET['url'] : '');
6 $quiet = ((x($_GET,'quiet')) ? '&quiet=1' : '');
7 $con_url = ((x($_GET,'conurl')) ? $_GET['conurl'] : '');
11 if( $con_url || (local_user() && $a->argc > 1 && intval($a->argv[1])) ) {
14 $con_url = str_replace('https', 'http', $con_url);
16 $r = q("SELECT * FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d LIMIT 1",
21 if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
29 $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
34 if((! dbm::is_result($r)) || ($r[0]['network'] !== NETWORK_DFRN))
38 $dfrn_id = $orig_id = (($r[0]['issued-id']) ? $r[0]['issued-id'] : $r[0]['dfrn-id']);
40 if($r[0]['duplex'] && $r[0]['issued-id']) {
41 $orig_id = $r[0]['issued-id'];
42 $dfrn_id = '1:' . $orig_id;
44 if($r[0]['duplex'] && $r[0]['dfrn-id']) {
45 $orig_id = $r[0]['dfrn-id'];
46 $dfrn_id = '0:' . $orig_id;
49 $sec = random_string();
51 q("INSERT INTO `profile_check` ( `uid`, `cid`, `dfrn_id`, `sec`, `expire`)
52 VALUES( %d, %s, '%s', '%s', %d )",
60 logger('mod_redir: ' . $r[0]['name'] . ' ' . $sec, LOGGER_DEBUG);
61 $dest = (($url) ? '&destination_url=' . $url : '');
62 goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id
63 . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&type=profile&sec=' . $sec . $dest . $quiet );
67 $handle = $a->user['nickname'] . '@' . substr(App::get_baseurl(),strpos(App::get_baseurl(),'://')+3);
70 $handle = $_SESSION['handle'];
74 $url = str_replace('{zid}','&zid=' . $handle,$url);