]> git.mxchange.org Git - friendica.git/blob - mod/receive.php
Merge branch 'master' into newui
[friendica.git] / mod / receive.php
1 <?php
2
3 /**
4  * Diaspora endpoint
5  */
6
7
8 require_once('include/salmon.php');
9 require_once('include/crypto.php');
10 require_once('include/diaspora.php');
11
12         
13 function receive_post(&$a) {
14
15         $public = false;
16
17         if(($a->argc == 2) && ($a->argv[1] === 'public')) {
18                 $public = true;
19         }
20         else {
21
22                 if($a->argc != 3 || $a->argv[1] !== 'users')
23                         http_status_exit(500);
24
25                 $guid = $a->argv[2];
26
27                 $r = q("SELECT * FROM `user` WHERE `guid` = '%s' AND `account_expired` = 0 LIMIT 1",
28                         dbesc($guid)
29                 );
30                 if(! count($r))
31                         http_status_exit(500);
32
33                 $importer = $r[0];
34         }
35
36         // It is an application/x-www-form-urlencoded
37
38         $xml = urldecode($_POST['xml']);
39
40         logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
41
42         if(! $xml)
43                 http_status_exit(500);
44
45         $msg = diaspora_decode($importer,$xml);
46
47         logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
48
49         if(! is_array($msg))
50                 http_status_exit(500);
51
52         $ret = 0;
53         if($public)
54                 diaspora_dispatch_public($msg);
55         else
56                 $ret = diaspora_dispatch($importer,$msg);
57
58         http_status_exit(($ret) ? $ret : 200);
59         // NOTREACHED
60 }
61