]> git.mxchange.org Git - friendica.git/blob - mod/post.php
bfdc62ab7942706b84485281c98aaef8986a3eb7
[friendica.git] / mod / post.php
1 <?php
2
3 /**
4  * Zot endpoint
5  */
6
7 use Friendica\App;
8
9 require_once('include/salmon.php');
10 require_once('include/crypto.php');
11 // not yet ready for prime time
12 //require_once('include/zot.php');
13
14 function post_post(App $a) {
15
16         $bulk_delivery = false;
17
18         if ($a->argc == 1) {
19                 $bulk_delivery = true;
20         }
21         else {
22                 $nickname = $a->argv[2];
23                 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s'
24                                 AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
25                         dbesc($nickname)
26                 );
27                 if (! dbm::is_result($r)) {
28                         http_status_exit(500);
29                 }
30
31                 $importer = $r[0];
32         }
33
34         $xml = file_get_contents('php://input');
35
36         logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
37
38         if(! $xml)
39                 http_status_exit(500);
40
41         $msg = zot_decode($importer,$xml);
42
43         logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
44
45         if(! is_array($msg))
46                 http_status_exit(500);
47
48         $ret = 0;
49         $ret = zot_incoming($bulk_delivery, $importer,$msg);
50         http_status_exit(($ret) ? $ret : 200);
51         // NOTREACHED
52 }
53