diff --git a/src/Module/Api/Friendica/Notification/Seen.php b/src/Module/Api/Friendica/Notification/Seen.php index 30637d78c..7b37b7615 100644 --- a/src/Module/Api/Friendica/Notification/Seen.php +++ b/src/Module/Api/Friendica/Notification/Seen.php @@ -65,7 +65,7 @@ class Seen extends BaseApi if ($Notify->otype === Notification\ObjectType::ITEM) { $item = Post::selectFirstForUser($uid, [], ['id' => $Notify->iid, 'uid' => $uid]); if (DBA::isResult($item)) { - $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); // we found the item, return it to the user $ret = [DI::twitterStatus()->createFromUriId($item['uri-id'], $item['uid'], $include_entities)->toArray()]; diff --git a/src/Module/Api/GNUSocial/Statusnet/Conversation.php b/src/Module/Api/GNUSocial/Statusnet/Conversation.php index 76bc9b816..cd70cb502 100644 --- a/src/Module/Api/GNUSocial/Statusnet/Conversation.php +++ b/src/Module/Api/GNUSocial/Statusnet/Conversation.php @@ -41,15 +41,15 @@ class Conversation extends BaseApi // params $id = $this->parameters['id'] ?? 0; - $since_id = $_REQUEST['since_id'] ?? 0; - $max_id = $_REQUEST['max_id'] ?? 0; - $count = $_REQUEST['count'] ?? 20; - $page = $_REQUEST['page'] ?? 1; + $since_id = $request['since_id'] ?? 0; + $max_id = $request['max_id'] ?? 0; + $count = $request['count'] ?? 20; + $page = $request['page'] ?? 1; $start = max(0, ($page - 1) * $count); if ($id == 0) { - $id = $_REQUEST['id'] ?? 0; + $id = $request['id'] ?? 0; } Logger::info(BaseApi::LOG_PREFIX . '{subaction}', ['module' => 'api', 'action' => 'conversation', 'subaction' => 'show', 'id' => $id]); @@ -82,7 +82,7 @@ class Conversation extends BaseApi throw new BadRequestException("There is no status with id $id."); } - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Account/UpdateProfile.php b/src/Module/Api/Twitter/Account/UpdateProfile.php index 079d58f4b..70cac42a2 100644 --- a/src/Module/Api/Twitter/Account/UpdateProfile.php +++ b/src/Module/Api/Twitter/Account/UpdateProfile.php @@ -56,7 +56,7 @@ class UpdateProfile extends BaseApi Profile::publishUpdate($uid); - $skip_status = $request['skip_status'] ?? false; + $skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); diff --git a/src/Module/Api/Twitter/Account/VerifyCredentials.php b/src/Module/Api/Twitter/Account/VerifyCredentials.php index 592cff4c0..181c20dfb 100644 --- a/src/Module/Api/Twitter/Account/VerifyCredentials.php +++ b/src/Module/Api/Twitter/Account/VerifyCredentials.php @@ -37,7 +37,7 @@ class VerifyCredentials extends BaseApi BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); $uid = BaseApi::getCurrentUserID(); - $skip_status = $_REQUEST['skip_status'] ?? false; + $skip_status = filter_var($request['skip_status'] ?? false, FILTER_VALIDATE_BOOLEAN); $user_info = DI::twitterUser()->createFromUserId($uid, $skip_status)->toArray(); diff --git a/src/Module/Api/Twitter/Lists/Statuses.php b/src/Module/Api/Twitter/Lists/Statuses.php index 68afa411e..301966a6a 100644 --- a/src/Module/Api/Twitter/Lists/Statuses.php +++ b/src/Module/Api/Twitter/Lists/Statuses.php @@ -95,7 +95,7 @@ class Statuses extends BaseApi $params = ['order' => ['id' => true], 'limit' => [$start, $count]]; $statuses = Post::selectForUser($uid, [], $condition, $params); - $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $items = []; while ($status = $this->dba->fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Search/Tweets.php b/src/Module/Api/Twitter/Search/Tweets.php index 759c797a6..c8ebd21db 100644 --- a/src/Module/Api/Twitter/Search/Tweets.php +++ b/src/Module/Api/Twitter/Search/Tweets.php @@ -115,7 +115,7 @@ class Tweets extends BaseApi $statuses = $statuses ?: Post::selectForUser($uid, [], $condition, $params); - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Statuses/Destroy.php b/src/Module/Api/Twitter/Statuses/Destroy.php index 784b8ef66..aabf6f98d 100644 --- a/src/Module/Api/Twitter/Statuses/Destroy.php +++ b/src/Module/Api/Twitter/Statuses/Destroy.php @@ -50,7 +50,7 @@ class Destroy extends BaseApi $this->logger->notice('API: api_statuses_destroy: ' . $id); - $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = DI::twitterStatus()->createFromItemId($id, $uid, $include_entities)->toArray(); diff --git a/src/Module/Api/Twitter/Statuses/HomeTimeline.php b/src/Module/Api/Twitter/Statuses/HomeTimeline.php index a9ed6a832..8a54aeda6 100644 --- a/src/Module/Api/Twitter/Statuses/HomeTimeline.php +++ b/src/Module/Api/Twitter/Statuses/HomeTimeline.php @@ -71,7 +71,7 @@ class HomeTimeline extends BaseApi $params = ['order' => ['id' => true], 'limit' => [$start, $count]]; $statuses = Post::selectForUser($uid, [], $condition, $params); - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; $idarray = []; diff --git a/src/Module/Api/Twitter/Statuses/Mentions.php b/src/Module/Api/Twitter/Statuses/Mentions.php index 31cde911e..cb66a49f1 100644 --- a/src/Module/Api/Twitter/Statuses/Mentions.php +++ b/src/Module/Api/Twitter/Statuses/Mentions.php @@ -72,7 +72,7 @@ class Mentions extends BaseApi $params = ['order' => ['id' => true], 'limit' => [$start, $count]]; $statuses = Post::selectForUser($uid, [], $condition, $params); - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php b/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php index 5fa104e88..d7612d193 100644 --- a/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php +++ b/src/Module/Api/Twitter/Statuses/NetworkPublicTimeline.php @@ -58,7 +58,7 @@ class NetworkPublicTimeline extends BaseApi $params = ['order' => ['id' => true], 'limit' => [$start, $count]]; $statuses = Post::selectForUser($uid, Item::DISPLAY_FIELDLIST, $condition, $params); - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Statuses/PublicTimeline.php b/src/Module/Api/Twitter/Statuses/PublicTimeline.php index 0015d3e08..5508d3b09 100644 --- a/src/Module/Api/Twitter/Statuses/PublicTimeline.php +++ b/src/Module/Api/Twitter/Statuses/PublicTimeline.php @@ -78,7 +78,7 @@ class PublicTimeline extends BaseApi $statuses = Post::selectForUser($uid, [], $condition, $params); } - $include_entities = strtolower(($_REQUEST['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Statuses/Show.php b/src/Module/Api/Twitter/Statuses/Show.php index d03769751..f69899709 100644 --- a/src/Module/Api/Twitter/Statuses/Show.php +++ b/src/Module/Api/Twitter/Statuses/Show.php @@ -79,7 +79,7 @@ class Show extends BaseApi throw new BadRequestException(sprintf("There is no status or conversation with the id %d.", $id)); } - $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) { diff --git a/src/Module/Api/Twitter/Statuses/UserTimeline.php b/src/Module/Api/Twitter/Statuses/UserTimeline.php index 2c884a6b6..2255287c7 100644 --- a/src/Module/Api/Twitter/Statuses/UserTimeline.php +++ b/src/Module/Api/Twitter/Statuses/UserTimeline.php @@ -74,7 +74,7 @@ class UserTimeline extends BaseApi $params = ['order' => ['id' => true], 'limit' => [$start, $count]]; $statuses = Post::selectForUser($uid, [], $condition, $params); - $include_entities = strtolower(($request['include_entities'] ?? 'false') == 'true'); + $include_entities = filter_var($request['include_entities'] ?? false, FILTER_VALIDATE_BOOLEAN); $ret = []; while ($status = DBA::fetch($statuses)) {