Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

77 řádky
1.5 KiB

  1. <?php
  2. /**
  3. * Diaspora endpoint
  4. */
  5. require_once('include/salmon.php');
  6. require_once('include/crypto.php');
  7. require_once('include/diaspora.php');
  8. function receive_post(App $a) {
  9. $enabled = intval(get_config('system','diaspora_enabled'));
  10. if(! $enabled) {
  11. logger('mod-diaspora: disabled');
  12. http_status_exit(500);
  13. }
  14. $public = false;
  15. if(($a->argc == 2) && ($a->argv[1] === 'public')) {
  16. $public = true;
  17. }
  18. else {
  19. if($a->argc != 3 || $a->argv[1] !== 'users')
  20. http_status_exit(500);
  21. $guid = $a->argv[2];
  22. $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
  23. dbesc($guid)
  24. );
  25. if (! dbm::is_result($r)) {
  26. http_status_exit(500);
  27. }
  28. $importer = $r[0];
  29. }
  30. // It is an application/x-www-form-urlencoded
  31. logger('mod-diaspora: receiving post', LOGGER_DEBUG);
  32. $xml = urldecode($_POST['xml']);
  33. logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
  34. if(! $xml)
  35. http_status_exit(500);
  36. logger('mod-diaspora: message is okay', LOGGER_DEBUG);
  37. $msg = Diaspora::decode($importer,$xml);
  38. logger('mod-diaspora: decoded', LOGGER_DEBUG);
  39. logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
  40. if(! is_array($msg))
  41. http_status_exit(500);
  42. logger('mod-diaspora: dispatching', LOGGER_DEBUG);
  43. $ret = 0;
  44. if($public) {
  45. Diaspora::dispatch_public($msg);
  46. } else {
  47. $ret = Diaspora::dispatch($importer,$msg);
  48. }
  49. http_status_exit(($ret) ? $ret : 200);
  50. // NOTREACHED
  51. }