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