3 require_once('include/crypto.php');
5 function xrd_init(&$a) {
7 $uri = urldecode(notags(trim($_GET['uri'])));
9 if(substr($uri,0,4) === 'http')
10 $name = basename($uri);
12 $local = str_replace('acct:', '', $uri);
13 if(substr($local,0,2) == '//')
14 $local = substr($local,2);
16 $name = substr($local,0,strpos($local,'@'));
19 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
25 $salmon_key = salmon_key($r[0]['spubkey']);
27 header('Access-Control-Allow-Origin: *');
28 header("Content-type: text/xml");
30 if(get_config('system','diaspora_enabled')) {
31 $tpl = file_get_contents('view/xrd_diaspora.tpl');
32 $dspr = replace_macros($tpl,array(
33 '$baseurl' => $a->get_baseurl(),
34 '$dspr_guid' => $r[0]['guid'],
35 '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
41 $tpl = file_get_contents('view/xrd_person.tpl');
43 $o = replace_macros($tpl, array(
44 '$nick' => $r[0]['nickname'],
46 '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
47 '$hcard_url' => $a->get_baseurl() . '/hcard/' . $r[0]['nickname'],
48 '$atom' => $a->get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
49 '$zot_post' => $a->get_baseurl() . '/post/' . $r[0]['nickname'],
50 '$poco_url' => $a->get_baseurl() . '/poco/' . $r[0]['nickname'],
51 '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
53 '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'],
54 '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
55 '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
56 '$bigkey' => salmon_key($r[0]['pubkey'])
60 $arr = array('user' => $r[0], 'xml' => $o);
61 call_hooks('personal_xrd', $arr);