friendica/mod/post.php

56 lines
1 KiB
PHP
Raw Normal View History

2011-09-26 09:25:43 +00:00
<?php
/**
* @file mod/post.php
* @brief Zot endpoint
2011-09-26 09:25:43 +00:00
*/
use Friendica\App;
2017-11-08 03:57:46 +00:00
use Friendica\Database\DBM;
use dba;
2011-09-26 09:25:43 +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');
/**
* @param object $a App
* @return void
*/
function post_post(App $a)
{
2011-09-26 09:25:43 +00:00
$bulk_delivery = false;
if ($a->argc == 1) {
2011-09-26 09:25:43 +00:00
$bulk_delivery = true;
} else {
2011-09-26 09:25:43 +00:00
$nickname = $a->argv[2];
$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);
}
2011-09-26 09:25:43 +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);
if (! $xml) {
2011-09-26 09:25:43 +00:00
http_status_exit(500);
}
2011-09-26 09:25:43 +00:00
$msg = zot_decode($importer, $xml);
2011-09-26 09:25:43 +00:00
logger('mod-post: decoded msg: ' . print_r($msg, true), LOGGER_DATA);
2011-09-26 09:25:43 +00:00
if (! is_array($msg)) {
2011-09-26 09:25:43 +00:00
http_status_exit(500);
}
2011-09-26 09:25:43 +00:00
$ret = 0;
$ret = zot_incoming($bulk_delivery, $importer, $msg);
2011-09-26 09:25:43 +00:00
http_status_exit(($ret) ? $ret : 200);
// NOTREACHED
}