4 use Friendica\Core\System;
6 require_once('include/crypto.php');
8 function xrd_init(App $a) {
10 $uri = urldecode(notags(trim($_GET['uri'])));
13 $uri = urldecode(notags(trim($_GET['resource'])));
16 if(substr($uri,0,4) === 'http') {
18 $name = basename($uri);
21 $local = str_replace('acct:', '', $uri);
22 if(substr($local,0,2) == '//')
23 $local = substr($local,2);
25 $name = substr($local,0,strpos($local,'@'));
28 $r = dba::select('user', array(), array('nickname' => $name), array('limit' => 1));
29 if (! dbm::is_result($r)) {
33 $salmon_key = salmon_key($r['spubkey']);
35 header('Access-Control-Allow-Origin: *');
36 header("Content-type: text/xml");
38 $tpl = get_markup_template('xrd_diaspora.tpl');
39 $dspr = replace_macros($tpl,array(
40 '$baseurl' => System::baseUrl(),
41 '$dspr_guid' => $r['guid'],
42 '$dspr_key' => base64_encode(pemtorsa($r['pubkey']))
45 $tpl = get_markup_template('xrd_person.tpl');
47 $profile_url = System::baseUrl().'/profile/'.$r['nickname'];
50 $alias = $profile_url;
53 $alias = 'acct:'.$r['nickname'].'@'.$a->get_hostname();
56 $alias .= '/'.$a->get_path();
60 $o = replace_macros($tpl, array(
61 '$nick' => $r['nickname'],
64 '$profile_url' => $profile_url,
65 '$hcard_url' => System::baseUrl() . '/hcard/' . $r['nickname'],
66 '$atom' => System::baseUrl() . '/dfrn_poll/' . $r['nickname'],
67 '$zot_post' => System::baseUrl() . '/post/' . $r['nickname'],
68 '$poco_url' => System::baseUrl() . '/poco/' . $r['nickname'],
69 '$photo' => System::baseUrl() . '/photo/profile/' . $r['uid'] . '.jpg',
71 '$salmon' => System::baseUrl() . '/salmon/' . $r['nickname'],
72 '$salmen' => System::baseUrl() . '/salmon/' . $r['nickname'] . '/mention',
73 '$subscribe' => System::baseUrl() . '/follow?url={uri}',
74 '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
75 '$bigkey' => salmon_key($r['pubkey']),
79 $arr = array('user' => $r, 'xml' => $o);
80 call_hooks('personal_xrd', $arr);