]> git.mxchange.org Git - friendica.git/blob - mod/receive.php
Merge pull request #169 from michal-s/master
[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         if($a->argc != 3 || $a->argv[1] !== 'users')
16                 http_status_exit(500);
17
18         $guid = $a->argv[2];
19
20         $r = q("SELECT * FROM `user` WHERE `guid` = '%s' LIMIT 1",
21                 dbesc($guid)
22         );
23         if(! count($r))
24                 http_status_exit(500);
25
26         $importer = $r[0];
27
28         // It is an application/x-www-form-urlencoded
29
30         $xml = urldecode($_POST['xml']);
31
32         logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
33
34         if(! $xml)
35                 http_status_exit(500);
36
37         $msg = diaspora_decode($importer,$xml);
38
39         logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
40
41         if(! is_array($msg))
42                 http_status_exit(500);
43
44         diaspora_dispatch($importer,$msg);
45
46         http_status_exit(200);
47         // NOTREACHED
48 }
49