Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2 KiB

10 years ago
10 years ago
10 years ago
  1. <?php
  2. require_once('include/crypto.php');
  3. function xrd_init(App $a) {
  4. $uri = urldecode(notags(trim($_GET['uri'])));
  5. if(substr($uri,0,4) === 'http') {
  6. $acct = false;
  7. $name = basename($uri);
  8. } else {
  9. $acct = true;
  10. $local = str_replace('acct:', '', $uri);
  11. if(substr($local,0,2) == '//')
  12. $local = substr($local,2);
  13. $name = substr($local,0,strpos($local,'@'));
  14. }
  15. $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
  16. dbesc($name)
  17. );
  18. if (! dbm::is_result($r)) {
  19. killme();
  20. }
  21. $salmon_key = salmon_key($r[0]['spubkey']);
  22. header('Access-Control-Allow-Origin: *');
  23. header("Content-type: text/xml");
  24. $tpl = get_markup_template('xrd_diaspora.tpl');
  25. $dspr = replace_macros($tpl,array(
  26. '$baseurl' => App::get_baseurl(),
  27. '$dspr_guid' => $r[0]['guid'],
  28. '$dspr_key' => base64_encode(pemtorsa($r[0]['pubkey']))
  29. ));
  30. $tpl = get_markup_template('xrd_person.tpl');
  31. $profile_url = App::get_baseurl().'/profile/'.$r[0]['nickname'];
  32. if ($acct) {
  33. $alias = $profile_url;
  34. }
  35. else {
  36. $alias = 'acct:'.$r[0]['nickname'].'@'.$a->get_hostname();
  37. if ($a->get_path()) {
  38. $alias .= '/'.$a->get_path();
  39. }
  40. }
  41. $o = replace_macros($tpl, array(
  42. '$nick' => $r[0]['nickname'],
  43. '$accturi' => $uri,
  44. '$alias' => $alias,
  45. '$profile_url' => $profile_url,
  46. '$hcard_url' => App::get_baseurl() . '/hcard/' . $r[0]['nickname'],
  47. '$atom' => App::get_baseurl() . '/dfrn_poll/' . $r[0]['nickname'],
  48. '$zot_post' => App::get_baseurl() . '/post/' . $r[0]['nickname'],
  49. '$poco_url' => App::get_baseurl() . '/poco/' . $r[0]['nickname'],
  50. '$photo' => App::get_baseurl() . '/photo/profile/' . $r[0]['uid'] . '.jpg',
  51. '$dspr' => $dspr,
  52. '$salmon' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'],
  53. '$salmen' => App::get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention',
  54. '$subscribe' => App::get_baseurl() . '/follow?url={uri}',
  55. '$modexp' => 'data:application/magic-public-key,' . $salmon_key,
  56. '$bigkey' => salmon_key($r[0]['pubkey']),
  57. ));
  58. $arr = array('user' => $r[0], 'xml' => $o);
  59. call_hooks('personal_xrd', $arr);
  60. echo $arr['xml'];
  61. killme();
  62. }