]> git.mxchange.org Git - friendica.git/blob - mod/post.php
Merge pull request #3986 from MrPetovan/task/admin-block-list
[friendica.git] / mod / post.php
1 <?php
2 /**
3  * @file mod/post.php
4  * @brief Zot endpoint
5  */
6
7 use Friendica\App;
8 use Friendica\Database\DBM;
9 use dba;
10
11 require_once 'include/crypto.php';
12 // not yet ready for prime time
13 //require_once('include/zot.php');
14
15 /**
16  * @param object $a App
17  * @return void
18  */
19 function post_post(App $a)
20 {
21         $bulk_delivery = false;
22
23         if ($a->argc == 1) {
24                 $bulk_delivery = true;
25         } else {
26                 $nickname = $a->argv[2];
27                 $r = dba::select('user', array(), array('nickname' => $nickname, 'account_expired' => 0, 'account_removed' => 0), array('limit' => 1));
28                 if (! DBM::is_result($r)) {
29                         http_status_exit(500);
30                 }
31
32                 $importer = $r;
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
43         $msg = zot_decode($importer, $xml);
44
45         logger('mod-post: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
46
47         if (! is_array($msg)) {
48                 http_status_exit(500);
49         }
50
51         $ret = 0;
52         $ret = zot_incoming($bulk_delivery, $importer, $msg);
53         http_status_exit(($ret) ? $ret : 200);
54         // NOTREACHED
55 }