mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:00:21 +00:00
Replaced "requestdata"
This commit is contained in:
parent
ab28fa32aa
commit
c9b14b260f
2 changed files with 10 additions and 59 deletions
|
@ -683,23 +683,6 @@ function group_create($name, $uid, $users = [])
|
|||
return ['success' => true, 'gid' => $gid, 'name' => $name, 'status' => $status, 'wrong users' => $errorusers];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data from $_POST or $_GET
|
||||
*
|
||||
* @param string $k
|
||||
* @return null
|
||||
*/
|
||||
function requestdata($k)
|
||||
{
|
||||
if (!empty($_POST[$k])) {
|
||||
return $_POST[$k];
|
||||
}
|
||||
if (!empty($_GET[$k])) {
|
||||
return $_GET[$k];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* TWITTER API
|
||||
*/
|
||||
|
@ -765,7 +748,7 @@ function api_statuses_mediap($type)
|
|||
|
||||
$_REQUEST['profile_uid'] = $uid;
|
||||
$_REQUEST['api_source'] = true;
|
||||
$txt = requestdata('status') ?? '';
|
||||
$txt = $_REQUEST['status'] ?? '';
|
||||
|
||||
if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
|
||||
$txt = HTML::toBBCodeVideo($txt);
|
||||
|
@ -814,8 +797,8 @@ function api_statuses_update($type)
|
|||
$a = DI::app();
|
||||
|
||||
// convert $_POST array items to the form we use for web posts.
|
||||
if (requestdata('htmlstatus')) {
|
||||
$txt = requestdata('htmlstatus') ?? '';
|
||||
if (!empty($_REQUEST['htmlstatus'])) {
|
||||
$txt = $_REQUEST['htmlstatus'];
|
||||
if ((strpos($txt, '<') !== false) || (strpos($txt, '>') !== false)) {
|
||||
$txt = HTML::toBBCodeVideo($txt);
|
||||
|
||||
|
@ -828,12 +811,12 @@ function api_statuses_update($type)
|
|||
$_REQUEST['body'] = HTML::toBBCode($txt);
|
||||
}
|
||||
} else {
|
||||
$_REQUEST['body'] = requestdata('status');
|
||||
$_REQUEST['body'] = $_REQUEST['status'] ?? null;
|
||||
}
|
||||
|
||||
$_REQUEST['title'] = requestdata('title');
|
||||
$_REQUEST['title'] = $_REQUEST['title'] ?? null;
|
||||
|
||||
$parent = requestdata('in_reply_to_status_id');
|
||||
$parent = $_REQUEST['in_reply_to_status_id'] ?? null;
|
||||
|
||||
// Twidere sends "-1" if it is no reply ...
|
||||
if ($parent == -1) {
|
||||
|
@ -846,8 +829,8 @@ function api_statuses_update($type)
|
|||
$_REQUEST['parent_uri'] = $parent;
|
||||
}
|
||||
|
||||
if (requestdata('lat') && requestdata('long')) {
|
||||
$_REQUEST['coord'] = sprintf("%s %s", requestdata('lat'), requestdata('long'));
|
||||
if (!empty($_REQUEST['lat']) && !empty($_REQUEST['long'])) {
|
||||
$_REQUEST['coord'] = sprintf("%s %s", $_REQUEST['lat'], $_REQUEST['long']);
|
||||
}
|
||||
$_REQUEST['profile_uid'] = $uid;
|
||||
|
||||
|
@ -896,8 +879,8 @@ function api_statuses_update($type)
|
|||
}
|
||||
}
|
||||
|
||||
if (requestdata('media_ids')) {
|
||||
$ids = explode(',', requestdata('media_ids') ?? '');
|
||||
if (!empty($_REQUEST['media_ids'])) {
|
||||
$ids = explode(',', $_REQUEST['media_ids']);
|
||||
} elseif (!empty($_FILES['media'])) {
|
||||
// upload the image if we have one
|
||||
$picture = wall_upload_post($a, false);
|
||||
|
|
|
@ -902,38 +902,6 @@ class ApiTest extends FixtureTest
|
|||
api_account_verify_credentials('json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the requestdata() function.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestdata()
|
||||
{
|
||||
self::assertNull(requestdata('variable_name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the requestdata() function with a POST parameter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestdataWithPost()
|
||||
{
|
||||
$_POST['variable_name'] = 'variable_value';
|
||||
self::assertEquals('variable_value', requestdata('variable_name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the requestdata() function with a GET parameter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRequestdataWithGet()
|
||||
{
|
||||
$_GET['variable_name'] = 'variable_value';
|
||||
self::assertEquals('variable_value', requestdata('variable_name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the api_statuses_mediap() function.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue