3 require_once('include/crypto.php');
5 function xrd_init(App &$a) {
7 $uri = urldecode(notags(trim($_GET['uri'])));
9 if(substr($uri,0,4) === 'http') {
11 $name = basename($uri);
14 $local = str_replace('acct:', '', $uri);
15 if(substr($local,0,2) == '//')
16 $local = substr($local,2);
18 $name = substr($local,0,strpos($local,'@'));
21 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
24 if (! dbm::is_result($r)) {
28 $salmon_key = salmon_key($r[0]['spubkey']);
30 header('Access-Control-Allow-Origin: *');
31 header("Content-type: text/xml");
33 $tpl = get_markup_template('xrd_diaspora.tpl');
34 $dspr = replace_macros($tpl,array(
35 '$baseurl' => App::get_baseurl(),
36 '$dspr_guid' => $r[0]['guid'],
37 '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
40 $tpl = get_markup_template('xrd_person.tpl');
42 $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
45 $alias = $profile_url;
48 $alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
51 $alias .= '/'.$a->get_path();
55 $o = replace_macros($tpl, array(
56 '$nick' => $r[0]['nickname'],
59 '$profile_url' => $profile_url,
60 '$hcard_url' => App::get_baseurl() . '/hcard/' . $r[0]['nickname'],
61 '$atom' => App::get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
62 '$zot_post' => App::get_baseurl() . '/post/' . $r[0]['nickname'],
63 '$poco_url' => App::get_baseurl() . '/poco/' . $r[0]['nickname'],
64 '$photo' => App::get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
66 '$salmon' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'],
67 '$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
68 '$subscribe' => App::get_baseurl() . '/follow?url={uri}',
69 '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
70 '$bigkey' => salmon_key($r[0]['pubkey']),
74 $arr = array('user' => $r[0], 'xml' => $o);
75 call_hooks('personal_xrd', $arr);