]> git.mxchange.org Git - friendica.git/blob - mod/xrd.php
Merge branch 'dispy' of github.com:fabrixxm/friendika into dispy
[friendica.git] / mod / xrd.php
1 <?php
2
3 require_once('salmon.php');
4
5 function xrd_content(&$a) {
6
7         $uri = urldecode(notags(trim($_GET['uri'])));
8
9         if(substr($uri,0,4) === 'http')
10                 $name = basename($uri);
11         else {
12                 $local = str_replace('acct:', '', $uri);
13                 if(substr($local,0,2) == '//')
14                         $local = substr($local,2);
15
16                 $name = substr($local,0,strpos($local,'@'));
17         }
18
19         $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
20                 dbesc($name)
21         );
22         if(! count($r))
23                 killme();
24
25         $salmon_key = salmon_key($r[0]['spubkey']);
26
27         header('Access-Control-Allow-Origin: *');
28         header("Content-type: text/xml");
29
30         $tpl = file_get_contents('view/xrd_person.tpl');
31
32         $o = replace_macros($tpl, array(
33                 '$accturi'     => $uri,
34                 '$profile_url' => $a->get_baseurl() . '/profile/'       . $r[0]['nickname'],
35                 '$atom'        => $a->get_baseurl() . '/dfrn_poll/'     . $r[0]['nickname'],
36                 '$photo'       => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']      . '.jpg',
37                 '$salmon'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'],
38                 '$salmen'      => $a->get_baseurl() . '/salmon/'        . $r[0]['nickname'] . '/mention',
39                 '$modexp'      => 'data:application/magic-public-key,'  . $salmon_key
40         ));
41
42
43         $arr = array('user' => $r[0], 'xml' => $o);
44         call_hooks('personal_xrd', $arr);
45
46         echo $o;
47         killme();
48
49 }