From 492d7abe928c63d62ee9794aa5ff23ec374aece9 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sun, 19 May 2019 03:02:58 +0200 Subject: [PATCH] Renamed Diagnostic to Debug and deleted ItemSource (already defined) --- src/App/Router.php | 13 ++--- src/Module/{Diagnostic => Debug}/Babel.php | 2 +- src/Module/{Diagnostic => Debug}/Feed.php | 2 +- src/Module/{Diagnostic => Debug}/ItemBody.php | 2 +- .../{Diagnostic => Debug}/Localtime.php | 2 +- src/Module/{Diagnostic => Debug}/Probe.php | 14 ++--- .../{Diagnostic => Debug}/WebFinger.php | 8 +-- src/Module/Diagnostic/ItemSource.php | 55 ------------------- 8 files changed, 21 insertions(+), 77 deletions(-) rename src/Module/{Diagnostic => Debug}/Babel.php (99%) rename src/Module/{Diagnostic => Debug}/Feed.php (96%) rename src/Module/{Diagnostic => Debug}/ItemBody.php (95%) rename src/Module/{Diagnostic => Debug}/Localtime.php (97%) rename src/Module/{Diagnostic => Debug}/Probe.php (67%) rename src/Module/{Diagnostic => Debug}/WebFinger.php (69%) delete mode 100644 src/Module/Diagnostic/ItemSource.php diff --git a/src/App/Router.php b/src/App/Router.php index ddb3dbdfe4..ecc4eed688 100644 --- a/src/App/Router.php +++ b/src/App/Router.php @@ -92,7 +92,7 @@ class Router $this->routeCollector->addRoute(['GET'], '/allfriends/{id:\d+}', Module\AllFriends::class); $this->routeCollector->addRoute(['GET'], '/apps', Module\Apps::class); $this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class); - $this->routeCollector->addRoute(['GET'], '/babel', Module\Diagnostic\Babel::class); + $this->routeCollector->addRoute(['GET'], '/babel', Module\Debug\Babel::class); $this->routeCollector->addRoute(['GET'], '/bookmarklet', Module\Bookmarklet::class); $this->routeCollector->addGroup('/contact', function (RouteCollector $collector) { $collector->addRoute(['GET'], '[/]', Module\Contact::class); @@ -121,7 +121,7 @@ class Router $collector->addRoute(['GET'], '/{nickname}/replies', Module\Feed::class); $collector->addRoute(['GET'], '/{nickname}/activity', Module\Feed::class); }); - $this->routeCollector->addRoute(['GET'], '/feedtest', Module\Feedtest::class); + $this->routeCollector->addRoute(['GET'], '/feedtest', Module\Debug\Feed::class); $this->routeCollector->addGroup('/fetch', function (RouteCollector $collector) { $collector->addRoute(['GET'], '/{guid}/post', Module\Diaspora\Fetch::class); $collector->addRoute(['GET'], '/{guid}/status_message', Module\Diaspora\Fetch::class); @@ -153,9 +153,8 @@ class Router $collector->addRoute(['GET', 'POST'], '[/]', Module\Install::class); $collector->addRoute(['GET'], '/testrewrite', Module\Install::class); }); - $this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Diagnostic\ItemSource::class); $this->routeCollector->addRoute(['GET'], '/like/{item:\d+}', Module\Like::class); - $this->routeCollector->addRoute(['GET', 'POST'], '/localtime', Module\Diagnostic\Localtime::class); + $this->routeCollector->addRoute(['GET', 'POST'], '/localtime', Module\Debug\Localtime::class); $this->routeCollector->addRoute(['GET', 'POST'], '/login', Module\Login::class); $this->routeCollector->addRoute(['GET', 'POST'], '/logout', Module\Logout::class); $this->routeCollector->addRoute(['GET'], '/magic', Module\Magic::class); @@ -185,7 +184,7 @@ class Router $collector->addRoute(['GET'], '/{type}/{customize}/{name}', Module\Photo::class); }); $this->routeCollector->addRoute(['GET'], '/pretheme', Module\ThemeDetails::class); - $this->routeCollector->addRoute(['GET'], '/probe', Module\Diagnostic\Probe::class); + $this->routeCollector->addRoute(['GET'], '/probe', Module\Debug\Probe::class); $this->routeCollector->addGroup('/profile', function (RouteCollector $collector) { $collector->addRoute(['GET'], '/{nickname}', Module\Profile::class); $collector->addRoute(['GET'], '/{profile:\d+}/view', Module\Profile::class); @@ -214,8 +213,8 @@ class Router $this->routeCollector->addRoute(['GET'], '/toggle_mobile', Module\ToggleMobile::class); $this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class); $this->routeCollector->addRoute(['GET'], '/view/theme/{theme}/style.pcss', Module\Theme::class); - $this->routeCollector->addRoute(['GET'], '/viewsrc/{item:\d+}', Module\Diagnostic\ItemBody::class); - $this->routeCollector->addRoute(['GET'], '/webfinger', Module\Diagnostic\WebFinger::class); + $this->routeCollector->addRoute(['GET'], '/viewsrc/{item:\d+}', Module\Debug\ItemBody::class); + $this->routeCollector->addRoute(['GET'], '/webfinger', Module\Debug\WebFinger::class); $this->routeCollector->addRoute(['GET'], '/xrd', Module\Xrd::class); } diff --git a/src/Module/Diagnostic/Babel.php b/src/Module/Debug/Babel.php similarity index 99% rename from src/Module/Diagnostic/Babel.php rename to src/Module/Debug/Babel.php index 797584a4f7..899c8033c4 100644 --- a/src/Module/Diagnostic/Babel.php +++ b/src/Module/Debug/Babel.php @@ -1,6 +1,6 @@ httpdesc = L10n::t("Public access denied."); + $e = new HTTPException\ForbiddenException(L10n::t('Only logged in users are permitted to perform a probing.')); + $e->httpdesc = L10n::t('Public access denied.'); throw $e; } @@ -32,10 +32,10 @@ class Probe extends BaseModule $tpl = Renderer::getMarkupTemplate('probe.tpl'); return Renderer::replaceMacros($tpl, [ '$addr' => ['addr', - L10n::t('Lookup address'), - $addr, - '', - 'required' + L10n::t('Lookup address'), + $addr, + '', + 'required' ], '$res' => $res, ]); diff --git a/src/Module/Diagnostic/WebFinger.php b/src/Module/Debug/WebFinger.php similarity index 69% rename from src/Module/Diagnostic/WebFinger.php rename to src/Module/Debug/WebFinger.php index 5d6e05a27d..2b0b9c53b4 100644 --- a/src/Module/Diagnostic/WebFinger.php +++ b/src/Module/Debug/WebFinger.php @@ -1,6 +1,6 @@ httpdesc = L10n::t("Public access denied."); + $e = new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Only logged in users are permitted to perform a probing.')); + $e->httpdesc = L10n::t('Public access denied.'); throw $e; } $addr = defaults($_GET, 'addr', ''); - $res = ''; + $res = ''; if (!empty($addr)) { $res = Probe::lrdd($addr); diff --git a/src/Module/Diagnostic/ItemSource.php b/src/Module/Diagnostic/ItemSource.php deleted file mode 100644 index bd580cf892..0000000000 --- a/src/Module/Diagnostic/ItemSource.php +++ /dev/null @@ -1,55 +0,0 @@ - - */ -class ItemSource extends \Friendica\BaseModule -{ - public static function content() - { - if (!is_site_admin()) { - return; - } - - $a = self::getApp(); - - // @TODO: Replace with parameter from router - if (!empty($a->argv[1])) { - $guid = $a->argv[1]; - } - - $guid = defaults($_REQUEST['guid'], $guid); - - $source = ''; - $item_uri = ''; - $item_id = ''; - $terms = []; - if (!empty($guid)) { - $item = Model\Item::selectFirst(['id', 'guid', 'uri'], ['guid' => $guid]); - - $conversation = Model\Conversation::getByItemUri($item['uri']); - - $item_id = $item['id']; - $item_uri = $item['uri']; - $source = $conversation['source']; - $terms = Model\Term::tagArrayFromItemId($item['id'], [Model\Term::HASHTAG, Model\Term::MENTION, Model\Term::IMPLICIT_MENTION]); - } - - $tpl = Renderer::getMarkupTemplate('debug/itemsource.tpl'); - $o = Renderer::replaceMacros($tpl, [ - '$guid' => ['guid', L10n::t('Item Guid'), $guid, ''], - '$source' => $source, - '$item_uri' => $item_uri, - '$item_id' => $item_id, - '$terms' => $terms, - ]); - - return $o; - } -} -- 2.39.5