]> git.mxchange.org Git - friendica.git/commitdiff
We now use a central function for fetching the postdata
authorMichael <heluecht@pirati.ca>
Tue, 30 Jul 2019 22:26:01 +0000 (22:26 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 30 Jul 2019 22:26:01 +0000 (22:26 +0000)
include/api.php
mod/dfrn_notify.php
mod/pubsub.php
mod/receive.php
mod/salmon.php
src/Module/Inbox.php
src/Util/Network.php

index 0e190b84c11837b90154d104689790fe79f5c591..5665a7fbdd6f25faa2a53e6dbd886d2cd25ff3df 100644 (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");
index e75d975a826890d9c2b9ae0958766bce8fa50f3c..3f0ecba005e8e8333ee97dee626ff61c45dac13a 100644 (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);
index e5ede6c80a3792da91512c2d95f8db61d52dd51d..d10d7031d6e203507817288afed647e69a47ecc6 100644 (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);
index db1287ea6f1f804a8b6b784710ce5e01409beb07..182a1df8c51c345a933be30c517aec30904f3563 100644 (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();
                }
index ba1bc8d46513e54caf0c58be55487e5a0387b79c..67e467a73fea89ceb7c9aa1dd03c50997f386129 100644 (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);
index 5367adb7e1c8f9e53f55920b7cecc72ec37ab31f..2cc273b139910c647a141b42bcf484fcdcd58fee 100644 (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();
index 75b928bea2a2d3aeedf0d08a73c04557224f0d2f..cd66abe0b2864b019341bd15139fc3dd68f198d4 100644 (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
         *