]> git.mxchange.org Git - friendica.git/blob - mod/post.php
631bf0eba63f5d058e813fdd5306730dd021f111
[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 if(! function_exists('post_post')) {
14 function post_post(&$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(! count($r))
28                         http_status_exit(500);
29
30                 $importer = $r[0];
31         }
32
33         $xml = file_get_contents('php://input');
34
35         logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
36
37         if(! $xml)
38                 http_status_exit(500);
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         $ret = 0;
48         $ret = zot_incoming($bulk_delivery, $importer,$msg);
49         http_status_exit(($ret) ? $ret : 200);
50         // NOTREACHED
51 }
52 }