aboutsummaryrefslogtreecommitdiffstats
path: root/mod/post.php
blob: 4a7e33b23bd9e77a42838a3482608909b19fca31 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

/**
 * Zot endpoint
 */


require_once('include/salmon.php');
require_once('include/crypto.php');
// not yet ready for prime time
//require_once('include/zot.php');
	
function post_post(&$a) {

	$bulk_delivery = false;

	if($a->argc == 1) {
		$bulk_delivery = true;
	}
	else {
		$nickname = $a->argv[2];
		$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' 
				AND `account_expired` = 0 LIMIT 1",
			dbesc($nickname)
		);
		if(! count($r))
			http_status_exit(500);

		$importer = $r[0];
	}

	$xml = file_get_contents('php://input');

	logger('mod-post: new zot: ' . $xml, LOGGER_DATA);

	if(! $xml)
		http_status_exit(500);

	$msg = zot_decode($importer,$xml);

	logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);

	if(! is_array($msg))
		http_status_exit(500);

	$ret = 0;
	$ret = zot_incoming($bulk_delivery, $importer,$msg);
	http_status_exit(($ret) ? $ret : 200);
	// NOTREACHED
}