1
1
Fork 0

Completely removed argc/argv

This commit is contained in:
Michael 2021-07-25 15:23:37 +00:00
parent 540ddb9265
commit df558d4056
18 changed files with 70 additions and 114 deletions

View file

@ -58,10 +58,6 @@ class App
{ {
public $user; public $user;
public $data = []; public $data = [];
/** @deprecated 2019.09 - use App\Arguments->getArgv() or Arguments->get() */
public $argv;
/** @deprecated 2019.09 - use App\Arguments->getArgc() */
public $argc;
public $theme_info = []; public $theme_info = [];
// Allow themes to control internal parameters // Allow themes to control internal parameters
// by changing App values in theme.php // by changing App values in theme.php
@ -254,9 +250,6 @@ class App
$this->process = $process; $this->process = $process;
$this->pConfig = $pConfig; $this->pConfig = $pConfig;
$this->argv = $args->getArgv();
$this->argc = $args->getArgc();
$this->load(); $this->load();
} }

View file

@ -37,12 +37,11 @@ class Attach extends BaseModule
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = DI::app(); $a = DI::app();
if ($a->argc != 2) { if (empty($parameters['item'])) {
throw new \Friendica\Network\HTTPException\BadRequestException(); throw new \Friendica\Network\HTTPException\BadRequestException();
} }
// @TODO: Replace with parameter from router $item_id = intval($parameters['item']);
$item_id = intval($a->argv[1]);
// Check for existence // Check for existence
$item = MAttach::exists(['id' => $item_id]); $item = MAttach::exists(['id' => $item_id]);

View file

@ -42,21 +42,21 @@ class BaseSettings extends BaseModule
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Account'), 'label' => DI::l10n()->t('Account'),
'url' => 'settings', 'url' => 'settings',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'settings') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() == 1) && (DI::args()->getArgv() === 'settings') ? 'active' : ''),
'accesskey' => 'o', 'accesskey' => 'o',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Two-factor authentication'), 'label' => DI::l10n()->t('Two-factor authentication'),
'url' => 'settings/2fa', 'url' => 'settings/2fa',
'selected' => (($a->argc > 1) && ($a->argv[1] === '2fa') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === '2fa') ? 'active' : ''),
'accesskey' => 'o', 'accesskey' => 'o',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Profile'), 'label' => DI::l10n()->t('Profile'),
'url' => 'settings/profile', 'url' => 'settings/profile',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'profile') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'profile') ? 'active' : ''),
'accesskey' => 'p', 'accesskey' => 'p',
]; ];
@ -64,7 +64,7 @@ class BaseSettings extends BaseModule
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Additional features'), 'label' => DI::l10n()->t('Additional features'),
'url' => 'settings/features', 'url' => 'settings/features',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'features') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'features') ? 'active' : ''),
'accesskey' => 't', 'accesskey' => 't',
]; ];
} }
@ -72,49 +72,49 @@ class BaseSettings extends BaseModule
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Display'), 'label' => DI::l10n()->t('Display'),
'url' => 'settings/display', 'url' => 'settings/display',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'display') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'display') ? 'active' : ''),
'accesskey' => 'i', 'accesskey' => 'i',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Social Networks'), 'label' => DI::l10n()->t('Social Networks'),
'url' => 'settings/connectors', 'url' => 'settings/connectors',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'connectors') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'connectors') ? 'active' : ''),
'accesskey' => 'w', 'accesskey' => 'w',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Addons'), 'label' => DI::l10n()->t('Addons'),
'url' => 'settings/addon', 'url' => 'settings/addon',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'addon') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'addon') ? 'active' : ''),
'accesskey' => 'l', 'accesskey' => 'l',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Manage Accounts'), 'label' => DI::l10n()->t('Manage Accounts'),
'url' => 'settings/delegation', 'url' => 'settings/delegation',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'delegation') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'delegation') ? 'active' : ''),
'accesskey' => 'd', 'accesskey' => 'd',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Connected apps'), 'label' => DI::l10n()->t('Connected apps'),
'url' => 'settings/oauth', 'url' => 'settings/oauth',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'oauth') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'oauth') ? 'active' : ''),
'accesskey' => 'b', 'accesskey' => 'b',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Export personal data'), 'label' => DI::l10n()->t('Export personal data'),
'url' => 'settings/userexport', 'url' => 'settings/userexport',
'selected' => (($a->argc > 1) && ($a->argv[1] === 'userexport') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === 'userexport') ? 'active' : ''),
'accesskey' => 'e', 'accesskey' => 'e',
]; ];
$tabs[] = [ $tabs[] = [
'label' => DI::l10n()->t('Remove account'), 'label' => DI::l10n()->t('Remove account'),
'url' => 'removeme', 'url' => 'removeme',
'selected' => (($a->argc == 1) && ($a->argv[0] === 'removeme') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() == 1) && (DI::args()->getArgv() === 'removeme') ? 'active' : ''),
'accesskey' => 'r', 'accesskey' => 'r',
]; ];

View file

@ -106,13 +106,13 @@ class Contact extends BaseModule
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argv[1] === 'batch') { if (DI::args()->getArgv()[1] === 'batch') {
self::batchActions(); self::batchActions();
return; return;
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$contact_id = intval($a->argv[1]); $contact_id = intval(DI::args()->getArgv()[1]);
if (!$contact_id) { if (!$contact_id) {
return; return;
} }
@ -271,10 +271,10 @@ class Contact extends BaseModule
$contact = null; $contact = null;
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc == 2 && intval($a->argv[1]) if (DI::args()->getArgc() == 2 && intval(DI::args()->getArgv()[1])
|| $a->argc == 3 && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations']) || DI::args()->getArgc() == 3 && intval(DI::args()->getArgv()[1]) && in_array(DI::args()->getArgv()[2], ['posts', 'conversations'])
) { ) {
$contact_id = intval($a->argv[1]); $contact_id = intval(DI::args()->getArgv()[1]);
// Ensure to use the user contact when the public contact was provided // Ensure to use the user contact when the public contact was provided
$data = Model\Contact::getPublicAndUserContactID($contact_id, local_user()); $data = Model\Contact::getPublicAndUserContactID($contact_id, local_user());
@ -293,7 +293,7 @@ class Contact extends BaseModule
if (DBA::isResult($contact)) { if (DBA::isResult($contact)) {
if ($contact['self']) { if ($contact['self']) {
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc == 3) && intval($a->argv[1]) && in_array($a->argv[2], ['posts', 'conversations'])) { if ((DI::args()->getArgc() == 3) && intval(DI::args()->getArgv()[1]) && in_array(DI::args()->getArgv()[2], ['posts', 'conversations'])) {
DI::baseUrl()->redirect('profile/' . $contact['nick']); DI::baseUrl()->redirect('profile/' . $contact['nick']);
} else { } else {
DI::baseUrl()->redirect('profile/' . $contact['nick'] . '/profile'); DI::baseUrl()->redirect('profile/' . $contact['nick'] . '/profile');
@ -343,14 +343,14 @@ class Contact extends BaseModule
return Login::form(); return Login::form();
} }
if ($a->argc == 3) { if (DI::args()->getArgc() == 3) {
$contact_id = intval($a->argv[1]); $contact_id = intval(DI::args()->getArgv()[1]);
if (!$contact_id) { if (!$contact_id) {
throw new BadRequestException(); throw new BadRequestException();
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$cmd = $a->argv[2]; $cmd = DI::args()->getArgv()[2];
$orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]); $orig_record = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => [0, local_user()], 'self' => false, 'deleted' => false]);
if (!DBA::isResult($orig_record)) { if (!DBA::isResult($orig_record)) {
@ -637,7 +637,7 @@ class Contact extends BaseModule
$sql_values = [local_user()]; $sql_values = [local_user()];
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
$type = $a->argv[1] ?? ''; $type = DI::args()->getArgv()[1] ?? '';
switch ($type) { switch ($type) {
case 'blocked': case 'blocked':

View file

@ -23,7 +23,6 @@ namespace Friendica\Module\Debug;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\DI; use Friendica\DI;
use Friendica\Model\Item;
use Friendica\Model\Post; use Friendica\Model\Post;
use Friendica\Network\HTTPException; use Friendica\Network\HTTPException;
@ -38,16 +37,13 @@ class ItemBody extends BaseModule
throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.')); throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.'));
} }
$app = DI::app(); if (empty($parameters['item'])) {
// @TODO: Replace with parameter from router
$itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
if (!$itemId) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.'));
} }
$item = Post::selectFirst(['body'], ['uid' => local_user(), 'uri-id' => $itemId]); $itemId = intval($parameters['item']);
$item = Post::selectFirst(['body'], ['uid' => [0, local_user()], 'uri-id' => $itemId]);
if (!empty($item)) { if (!empty($item)) {
if (DI::mode()->isAjax()) { if (DI::mode()->isAjax()) {

View file

@ -40,15 +40,11 @@ class Fetch extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = DI::app(); if (empty($parameters['guid'])) {
// @TODO: Replace with parameter from router
if (($app->argc != 3) || (!in_array($app->argv[1], ["post", "status_message", "reshare"]))) {
throw new HTTPException\NotFoundException(); throw new HTTPException\NotFoundException();
} }
// @TODO: Replace with parameter from router $guid = $parameters['guid'];
$guid = $app->argv[2];
// Fetch the item // Fetch the item
$fields = [ $fields = [
@ -68,7 +64,7 @@ class Fetch extends BaseModule
$host = $parts["scheme"] . "://" . $parts["host"]; $host = $parts["scheme"] . "://" . $parts["host"];
if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl()->get())) { if (Strings::normaliseLink($host) != Strings::normaliseLink(DI::baseUrl()->get())) {
$location = $host . "/fetch/" . $app->argv[1] . "/" . urlencode($guid); $location = $host . "/fetch/" . DI::args()->getArgv()[1] . "/" . urlencode($guid);
System::externalRedirect($location, 301); System::externalRedirect($location, 301);
} }
} }

View file

@ -76,12 +76,6 @@ class Directory extends BaseModule
if ($profiles['total'] === 0) { if ($profiles['total'] === 0) {
notice(DI::l10n()->t('No entries (some entries may be hidden).')); notice(DI::l10n()->t('No entries (some entries may be hidden).'));
} else { } else {
if (in_array('small', $app->argv)) {
$photo = 'thumb';
} else {
$photo = 'photo';
}
foreach ($profiles['entries'] as $entry) { foreach ($profiles['entries'] as $entry) {
$contact = Model\Contact::getByURLForUser($entry['url'], local_user()); $contact = Model\Contact::getByURLForUser($entry['url'], local_user());
if (!empty($contact)) { if (!empty($contact)) {

View file

@ -48,15 +48,10 @@ class Feed extends BaseModule
$last_update = $_GET['last_update'] ?? ''; $last_update = $_GET['last_update'] ?? '';
$nocache = !empty($_GET['nocache']) && local_user(); $nocache = !empty($_GET['nocache']) && local_user();
// @TODO: Replace with parameter from router
if ($a->argc < 2) {
throw new \Friendica\Network\HTTPException\BadRequestException();
}
$type = null; $type = null;
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc > 2) { if (DI::args()->getArgc() > 2) {
$type = $a->argv[2]; $type = DI::args()->getArgv()[2];
} }
switch ($type) { switch ($type) {
@ -72,10 +67,8 @@ class Feed extends BaseModule
$type = 'posts'; $type = 'posts';
} }
// @TODO: Replace with parameter from router
$nickname = $a->argv[1];
header("Content-type: application/atom+xml; charset=utf-8"); header("Content-type: application/atom+xml; charset=utf-8");
echo ProtocolFeed::atom($nickname, $last_update, 10, $type, $nocache, true); echo ProtocolFeed::atom($parameters['nickname'], $last_update, 10, $type, $nocache, true);
exit(); exit();
} }
} }

View file

@ -39,10 +39,9 @@ class RemoveTag extends BaseModule
throw new HTTPException\ForbiddenException(); throw new HTTPException\ForbiddenException();
} }
$app = DI::app();
$logger = DI::logger(); $logger = DI::logger();
$item_id = (($app->argc > 1) ? intval($app->argv[1]) : 0); $item_id = $parameters['id'] ?? 0;
$term = XML::unescape(trim($_GET['term'] ?? '')); $term = XML::unescape(trim($_GET['term'] ?? ''));
$cat = XML::unescape(trim($_GET['cat'] ?? '')); $cat = XML::unescape(trim($_GET['cat'] ?? ''));

View file

@ -44,12 +44,11 @@ class SaveTag extends BaseModule
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$a = DI::app();
$logger = DI::logger(); $logger = DI::logger();
$term = XML::unescape(trim($_GET['term'] ?? '')); $term = XML::unescape(trim($_GET['term'] ?? ''));
// @TODO: Replace with parameter from router
$item_id = (($a->argc > 1) ? intval($a->argv[1]) : 0); $item_id = $parameters['id'] ?? 0;
$logger->info('filer', ['tag' => $term, 'item' => $item_id]); $logger->info('filer', ['tag' => $term, 'item' => $item_id]);

View file

@ -120,10 +120,8 @@ class Friendica extends BaseModule
} }
} }
$app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($app->argc <= 1 || ($app->argv[1] !== 'json')) { if (DI::args()->getArgc() <= 1 || (DI::args()->getArgv()[1] !== 'json')) {
return; return;
} }

View file

@ -47,7 +47,7 @@ class Group extends BaseModule
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc == 2) && ($a->argv[1] === 'new')) { if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit'); BaseModule::checkFormSecurityTokenRedirectOnError('/group/new', 'group_edit');
$name = Strings::escapeTags(trim($_POST['groupname'])); $name = Strings::escapeTags(trim($_POST['groupname']));
@ -64,10 +64,10 @@ class Group extends BaseModule
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc == 2) && intval($a->argv[1])) { if ((DI::args()->getArgc() == 2) && intval(DI::args()->getArgv()[1])) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit'); BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_edit');
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user()]); $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user()]);
if (!DBA::isResult($group)) { if (!DBA::isResult($group)) {
notice(DI::l10n()->t('Group not found.')); notice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact'); DI::baseUrl()->redirect('contact');
@ -93,8 +93,8 @@ class Group extends BaseModule
// POST /group/123/add/123 // POST /group/123/add/123
// POST /group/123/remove/123 // POST /group/123/remove/123
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc == 4) { if (DI::args()->getArgc() == 4) {
list($group_id, $command, $contact_id) = array_slice($a->argv, 1); list($group_id, $command, $contact_id) = array_slice(DI::args()->getArgv(), 1);
if (!Model\Group::exists($group_id, local_user())) { if (!Model\Group::exists($group_id, local_user())) {
throw new \Exception(DI::l10n()->t('Unknown group.'), 404); throw new \Exception(DI::l10n()->t('Unknown group.'), 404);
@ -149,11 +149,11 @@ class Group extends BaseModule
$a = DI::app(); $a = DI::app();
DI::page()['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', (($a->argc > 1) ? $a->argv[1] : 'everyone')); DI::page()['aside'] = Model\Group::sidebarWidget('contact', 'group', 'extended', ((DI::args()->getArgc() > 1) ? DI::args()->getArgv()[1] : 'everyone'));
// With no group number provided we jump to the unassigned contacts as a starting point // With no group number provided we jump to the unassigned contacts as a starting point
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc == 1) { if (DI::args()->getArgc() == 1) {
DI::baseUrl()->redirect('group/none'); DI::baseUrl()->redirect('group/none');
} }
@ -172,7 +172,7 @@ class Group extends BaseModule
]; ];
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc == 2) && ($a->argv[1] === 'new')) { if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'new')) {
return Renderer::replaceMacros($tpl, $context + [ return Renderer::replaceMacros($tpl, $context + [
'$title' => DI::l10n()->t('Create a group of contacts/friends.'), '$title' => DI::l10n()->t('Create a group of contacts/friends.'),
'$gname' => ['groupname', DI::l10n()->t('Group Name: '), '', ''], '$gname' => ['groupname', DI::l10n()->t('Group Name: '), '', ''],
@ -184,8 +184,8 @@ class Group extends BaseModule
$nogroup = false; $nogroup = false;
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc == 2) && ($a->argv[1] === 'none') || if ((DI::args()->getArgc() == 2) && (DI::args()->getArgv()[1] === 'none') ||
($a->argc == 1) && ($a->argv[0] === 'nogroup')) { (DI::args()->getArgc() == 1) && (DI::args()->getArgv()[0] === 'nogroup')) {
$id = -1; $id = -1;
$nogroup = true; $nogroup = true;
$group = [ $group = [
@ -205,17 +205,17 @@ class Group extends BaseModule
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc == 3) && ($a->argv[1] === 'drop')) { if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop')) {
BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't'); BaseModule::checkFormSecurityTokenRedirectOnError('/group', 'group_drop', 't');
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (intval($a->argv[2])) { if (intval(DI::args()->getArgv()[2])) {
if (!Model\Group::exists($a->argv[2], local_user())) { if (!Model\Group::exists(DI::args()->getArgv()[2], local_user())) {
notice(DI::l10n()->t('Group not found.')); notice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact'); DI::baseUrl()->redirect('contact');
} }
if (!Model\Group::remove($a->argv[2])) { if (!Model\Group::remove(DI::args()->getArgv()[2])) {
notice(DI::l10n()->t('Unable to remove group.')); notice(DI::l10n()->t('Unable to remove group.'));
} }
} }
@ -223,17 +223,17 @@ class Group extends BaseModule
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc > 2) && intval($a->argv[1]) && intval($a->argv[2])) { if ((DI::args()->getArgc() > 2) && intval(DI::args()->getArgv()[1]) && intval(DI::args()->getArgv()[2])) {
BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't'); BaseModule::checkFormSecurityTokenForbiddenOnError('group_member_change', 't');
if (DBA::exists('contact', ['id' => $a->argv[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) { if (DBA::exists('contact', ['id' => DI::args()->getArgv()[2], 'uid' => local_user(), 'self' => false, 'pending' => false, 'blocked' => false])) {
$change = intval($a->argv[2]); $change = intval(DI::args()->getArgv()[2]);
} }
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if (($a->argc > 1) && intval($a->argv[1])) { if ((DI::args()->getArgc() > 1) && intval(DI::args()->getArgv()[1])) {
$group = DBA::selectFirst('group', ['id', 'name'], ['id' => $a->argv[1], 'uid' => local_user(), 'deleted' => false]); $group = DBA::selectFirst('group', ['id', 'name'], ['id' => DI::args()->getArgv()[1], 'uid' => local_user(), 'deleted' => false]);
if (!DBA::isResult($group)) { if (!DBA::isResult($group)) {
notice(DI::l10n()->t('Group not found.')); notice(DI::l10n()->t('Group not found.'));
DI::baseUrl()->redirect('contact'); DI::baseUrl()->redirect('contact');

View file

@ -45,11 +45,11 @@ class Help extends BaseModule
$lang = $config->get('system', 'language'); $lang = $config->get('system', 'language');
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc > 1) { if (DI::args()->getArgc() > 1) {
$path = ''; $path = '';
// looping through the argv keys bigger than 0 to build // looping through the argv keys bigger than 0 to build
// a path relative to /help // a path relative to /help
for ($x = 1; $x < $a->argc; $x ++) { for ($x = 1; $x < DI::args()->getArgc(); $x ++) {
if (strlen($path)) { if (strlen($path)) {
$path .= '/'; $path .= '/';
} }

View file

@ -39,26 +39,24 @@ class Oembed extends BaseModule
{ {
public static function content(array $parameters = []) public static function content(array $parameters = [])
{ {
$a = DI::app();
// Unused form: /oembed/b2h?url=... // Unused form: /oembed/b2h?url=...
if ($a->argv[1] == 'b2h') { if (DI::args()->getArgv()[1] == 'b2h') {
$url = ["", trim(hex2bin($_REQUEST['url']))]; $url = ["", trim(hex2bin($_REQUEST['url']))];
echo Content\OEmbed::replaceCallback($url); echo Content\OEmbed::replaceCallback($url);
exit(); exit();
} }
// Unused form: /oembed/h2b?text=... // Unused form: /oembed/h2b?text=...
if ($a->argv[1] == 'h2b') { if (DI::args()->getArgv()[1] == 'h2b') {
$text = trim(hex2bin($_REQUEST['text'])); $text = trim(hex2bin($_REQUEST['text']));
echo Content\OEmbed::HTML2BBCode($text); echo Content\OEmbed::HTML2BBCode($text);
exit(); exit();
} }
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($a->argc == 2) { if (DI::args()->getArgc() == 2) {
echo '<html><body>'; echo '<html><body>';
$url = Strings::base64UrlDecode($a->argv[1]); $url = Strings::base64UrlDecode(DI::args()->getArgv()[1]);
$j = Content\OEmbed::fetchURL($url); $j = Content\OEmbed::fetchURL($url);
// workaround for media.ccc.de (and any other endpoint that return size 0) // workaround for media.ccc.de (and any other endpoint that return size 0)

View file

@ -27,7 +27,6 @@ use Friendica\Model\User;
use Friendica\Network\HTTPException\BadRequestException; use Friendica\Network\HTTPException\BadRequestException;
use Friendica\Util\Crypto; use Friendica\Util\Crypto;
use Friendica\Util\Strings; use Friendica\Util\Strings;
use phpseclib\File\ASN1;
/** /**
* prints the public RSA key of a user * prints the public RSA key of a user
@ -36,15 +35,11 @@ class PublicRSAKey extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = DI::app(); if (empty($parameters['nick'])) {
// @TODO: Replace with parameter from router
if ($app->argc !== 2) {
throw new BadRequestException(); throw new BadRequestException();
} }
// @TODO: Replace with parameter from router $nick = $parameters['nick'];
$nick = $app->argv[1];
$user = User::getByNickname($nick, ['spubkey']); $user = User::getByNickname($nick, ['spubkey']);
if (empty($user) || empty($user['spubkey'])) { if (empty($user) || empty($user['spubkey'])) {

View file

@ -23,6 +23,7 @@ namespace Friendica\Module;
use Friendica\BaseModule; use Friendica\BaseModule;
use Friendica\Content; use Friendica\Content;
use Friendica\Core\Logger;
use Friendica\Core\Renderer; use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\DI; use Friendica\DI;
@ -34,9 +35,7 @@ class Smilies extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = DI::app(); if (!empty(DI::args()->getArgv()[1]) && (DI::args()->getArgv()[1] === "json")) {
if (!empty($app->argv[1]) && ($app->argv[1] === "json")) {
$smilies = Content\Smilies::getList(); $smilies = Content\Smilies::getList();
$results = []; $results = [];
for ($i = 0; $i < count($smilies['texts']); $i++) { for ($i = 0; $i < count($smilies['texts']); $i++) {

View file

@ -40,10 +40,8 @@ class Xrd extends BaseModule
{ {
public static function rawContent(array $parameters = []) public static function rawContent(array $parameters = [])
{ {
$app = DI::app();
// @TODO: Replace with parameter from router // @TODO: Replace with parameter from router
if ($app->argv[0] == 'xrd') { if (DI::args()->getArgv()[0] == 'xrd') {
if (empty($_GET['uri'])) { if (empty($_GET['uri'])) {
return; return;
} }

View file

@ -343,7 +343,7 @@ class Authentication
} }
} }
$this->redirectForTwoFactorAuthentication($user_record['uid'], $a); $this->redirectForTwoFactorAuthentication($user_record['uid']);
if ($interactive) { if ($interactive) {
if ($user_record['login_date'] <= DBA::NULL_DATETIME) { if ($user_record['login_date'] <= DBA::NULL_DATETIME) {
@ -369,12 +369,11 @@ class Authentication
* All return calls in this method skip two-factor authentication * All return calls in this method skip two-factor authentication
* *
* @param int $uid The User Identified * @param int $uid The User Identified
* @param App $a The Friendica Application context
* *
* @throws HTTPException\ForbiddenException In case the two factor authentication is forbidden (e.g. for AJAX calls) * @throws HTTPException\ForbiddenException In case the two factor authentication is forbidden (e.g. for AJAX calls)
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
private function redirectForTwoFactorAuthentication(int $uid, App $a) private function redirectForTwoFactorAuthentication(int $uid)
{ {
// Check user setting, if 2FA disabled return // Check user setting, if 2FA disabled return
if (!$this->pConfig->get($uid, '2fa', 'verified')) { if (!$this->pConfig->get($uid, '2fa', 'verified')) {
@ -382,7 +381,7 @@ class Authentication
} }
// Check current path, if public or 2fa module return // Check current path, if public or 2fa module return
if ($a->argc > 0 && in_array($a->argv[0], ['2fa', 'view', 'help', 'api', 'proxy', 'logout'])) { if (DI::args()->getArgc() > 0 && in_array(DI::args()->getArgv()[0], ['2fa', 'view', 'help', 'api', 'proxy', 'logout'])) {
return; return;
} }