aboutsummaryrefslogtreecommitdiffstats
path: root/mod/redir.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-01-29 15:47:25 -0800
committerfriendica <info@friendica.com>2012-01-29 15:47:25 -0800
commit61246cbd1c5abe15bf3a0c4f52d3063966293ec2 (patch)
tree21db913d6f7696b26ae9a3f1e4c87d0559c732ca /mod/redir.php
parente43a3a412c39ae9b98cc534d7f6e579e87601688 (diff)
downloadvolse-hubzilla-61246cbd1c5abe15bf3a0c4f52d3063966293ec2.tar.gz
volse-hubzilla-61246cbd1c5abe15bf3a0c4f52d3063966293ec2.tar.bz2
volse-hubzilla-61246cbd1c5abe15bf3a0c4f52d3063966293ec2.zip
some zot-id infrastructure
Diffstat (limited to 'mod/redir.php')
-rwxr-xr-xmod/redir.php79
1 files changed, 47 insertions, 32 deletions
diff --git a/mod/redir.php b/mod/redir.php
index eb9702b04..9223e5483 100755
--- a/mod/redir.php
+++ b/mod/redir.php
@@ -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;
+ $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 );
}
- if($r[0]['duplex'] && $r[0]['dfrn-id']) {
- $orig_id = $r[0]['dfrn-id'];
- $dfrn_id = '0:' . $orig_id;
+
+ if(local_user())
+ $handle = $a->user['nickname'] . '@' . substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3);
+ if(remote_user())
+ $handle = $_SESSION['handle'];
+
+ if($url) {
+ $url = str_replace('{zid}','&zid=' . $handle,$url);
+ goaway($url);
}
- $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 );
-
+ goaway(z_root());
}