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