Browse Source

We now use a central function for fetching the postdata

pull/7450/head
Michael 1 year ago
parent
commit
b4c673a620
7 changed files with 21 additions and 6 deletions
  1. +1
    -1
      include/api.php
  2. +2
    -1
      mod/dfrn_notify.php
  3. +2
    -1
      mod/pubsub.php
  4. +2
    -1
      mod/receive.php
  5. +2
    -1
      mod/salmon.php
  6. +2
    -1
      src/Module/Inbox.php
  7. +10
    -0
      src/Util/Network.php

+ 1
- 1
include/api.php View File

@ -1267,7 +1267,7 @@ function api_media_metadata_create($type)
api_get_user($a);
$postdata = file_get_contents('php://input');
$postdata = Network::postdata();
if (empty($postdata)) {
throw new BadRequestException("No post data");

+ 2
- 1
mod/dfrn_notify.php View File

@ -16,11 +16,12 @@ use Friendica\Model\User;
use Friendica\Protocol\DFRN;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Strings;
use Friendica\Util\Network;
function dfrn_notify_post(App $a) {
Logger::log(__function__, Logger::TRACE);
$postdata = file_get_contents('php://input');
$postdata = Network::postdata();
if (empty($_POST) || !empty($postdata)) {
$data = json_decode($postdata);

+ 2
- 1
mod/pubsub.php View File

@ -7,6 +7,7 @@ use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Protocol\OStatus;
use Friendica\Util\Strings;
use Friendica\Util\Network;
use Friendica\Core\System;
function hub_return($valid, $body)
@ -83,7 +84,7 @@ function pubsub_init(App $a)
function pubsub_post(App $a)
{
$xml = file_get_contents('php://input');
$xml = Network::postdata();
Logger::log('Feed arrived from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $a->cmd . ' with user-agent: ' . $_SERVER['HTTP_USER_AGENT']);
Logger::log('Data: ' . $xml, Logger::DATA);

+ 2
- 1
mod/receive.php View File

@ -10,6 +10,7 @@ use Friendica\Core\Logger;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Protocol\Diaspora;
use Friendica\Util\Network;
/**
* @param App $a App
@ -47,7 +48,7 @@ function receive_post(App $a)
Logger::log('mod-diaspora: receiving post', Logger::DEBUG);
if (empty($_POST['xml'])) {
$postdata = file_get_contents("php://input");
$postdata = Network::postdata();
if ($postdata == '') {
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}

+ 2
- 1
mod/salmon.php View File

@ -13,11 +13,12 @@ use Friendica\Protocol\OStatus;
use Friendica\Protocol\Salmon;
use Friendica\Util\Crypto;
use Friendica\Util\Strings;
use Friendica\Util\Network;
function salmon_post(App $a, $xml = '') {
if (empty($xml)) {
$xml = file_get_contents('php://input');
$xml = Network::postdata();
}
Logger::log('new salmon ' . $xml, Logger::DATA);

+ 2
- 1
src/Module/Inbox.php View File

@ -12,6 +12,7 @@ use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\Protocol\ActivityPub;
use Friendica\Util\HTTPSignature;
use Friendica\Util\Network;
/**
* ActivityPub Inbox
@ -22,7 +23,7 @@ class Inbox extends BaseModule
{
$a = self::getApp();
$postdata = file_get_contents('php://input');
$postdata = Network::postdata();
if (empty($postdata)) {
throw new \Friendica\Network\HTTPException\BadRequestException();

+ 10
- 0
src/Util/Network.php View File

@ -342,6 +342,16 @@ class Network
return $curlResponse;
}
/**
* Return raw post data from a post request
*
* @return string post data
*/
public static function postdata()
{
return file_get_contents('php://input');
}
/**
* @brief Check URL to see if it's real
*

Loading…
Cancel
Save