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