3 require_once('include/crypto.php');
5 if(! function_exists('xrd_init')) {
6 function xrd_init(&$a) {
8 $uri = urldecode(notags(trim($_GET['uri'])));
10 if(substr($uri,0,4) === 'http') {
12 $name = basename($uri);
15 $local = str_replace('acct:', '', $uri);
16 if(substr($local,0,2) == '//')
17 $local = substr($local,2);
19 $name = substr($local,0,strpos($local,'@'));
22 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
28 $salmon_key = salmon_key($r[0]['spubkey']);
30 header('Access-Control-Allow-Origin: *');
31 header("Content-type: text/xml");
33 if(get_config('system','diaspora_enabled')) {
34 $tpl = get_markup_template('xrd_diaspora.tpl');
35 $dspr = replace_macros($tpl,array(
36 '$baseurl' => $a->get_baseurl(),
37 '$dspr_guid' => $r[0]['guid'],
38 '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
44 $tpl = get_markup_template('xrd_person.tpl');
46 $profile_url = $a->get_baseurl().'/profile/'.$r[0]['nickname'];
49 $alias = $profile_url;
51 $alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
54 $alias .= '/'.$a->get_path();
57 $o = replace_macros($tpl, array(
58 '$nick' => $r[0]['nickname'],
61 '$profile_url' => $profile_url,
62 '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['nickname'],
63 '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
64 '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['nickname'],
65 '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['nickname'],
66 '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
68 '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'],
69 '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
70 '$subscribe' => $a->get_baseurl() . '/follow?url={uri}',
71 '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
72 '$bigkey' => salmon_key($r[0]['pubkey'])
76 $arr = array('user' => $r[0], 'xml' => $o);
77 call_hooks('personal_xrd', $arr);