2011-09-26 09:25:43 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2017-12-02 14:32:45 +00:00
|
|
|
* @file mod/post.php
|
|
|
|
* @brief Zot endpoint
|
2011-09-26 09:25:43 +00:00
|
|
|
*/
|
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2017-11-08 03:57:46 +00:00
|
|
|
use Friendica\Database\DBM;
|
2017-12-02 14:32:45 +00:00
|
|
|
use dba;
|
2011-09-26 09:25:43 +00:00
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
require_once 'include/crypto.php';
|
2011-09-26 09:25:43 +00:00
|
|
|
// not yet ready for prime time
|
|
|
|
//require_once('include/zot.php');
|
2017-01-09 12:14:25 +00:00
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
/**
|
|
|
|
* @param object $a App
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function post_post(App $a)
|
|
|
|
{
|
2011-09-26 09:25:43 +00:00
|
|
|
$bulk_delivery = false;
|
|
|
|
|
2016-12-20 09:58:55 +00:00
|
|
|
if ($a->argc == 1) {
|
2011-09-26 09:25:43 +00:00
|
|
|
$bulk_delivery = true;
|
2017-12-02 14:32:45 +00:00
|
|
|
} else {
|
2011-09-26 09:25:43 +00:00
|
|
|
$nickname = $a->argv[2];
|
2017-12-02 14:32:45 +00:00
|
|
|
$r = dba::select('user', array(), array('nickname' => $nickname, 'account_expired' => 0, 'account_removed' => 0), array('limit' => 1));
|
2017-11-08 03:57:46 +00:00
|
|
|
if (! DBM::is_result($r)) {
|
2011-09-26 09:25:43 +00:00
|
|
|
http_status_exit(500);
|
2016-12-20 09:10:33 +00:00
|
|
|
}
|
2011-09-26 09:25:43 +00:00
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
$importer = $r;
|
2011-09-26 09:25:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$xml = file_get_contents('php://input');
|
|
|
|
|
|
|
|
logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
|
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
if (! $xml) {
|
2011-09-26 09:25:43 +00:00
|
|
|
http_status_exit(500);
|
2017-12-02 14:32:45 +00:00
|
|
|
}
|
2011-09-26 09:25:43 +00:00
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
$msg = zot_decode($importer, $xml);
|
2011-09-26 09:25:43 +00:00
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
logger('mod-post: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
|
2011-09-26 09:25:43 +00:00
|
|
|
|
2017-12-02 14:32:45 +00:00
|
|
|
if (! is_array($msg)) {
|
2011-09-26 09:25:43 +00:00
|
|
|
http_status_exit(500);
|
2017-12-02 14:32:45 +00:00
|
|
|
}
|
2011-09-26 09:25:43 +00:00
|
|
|
|
|
|
|
$ret = 0;
|
2017-12-02 14:32:45 +00:00
|
|
|
$ret = zot_incoming($bulk_delivery, $importer, $msg);
|
2011-09-26 09:25:43 +00:00
|
|
|
http_status_exit(($ret) ? $ret : 200);
|
|
|
|
// NOTREACHED
|
|
|
|
}
|