diff --git a/mod/probe.php b/mod/probe.php deleted file mode 100644 index 7fc3a92899..0000000000 --- a/mod/probe.php +++ /dev/null @@ -1,37 +0,0 @@ -httpdesc = L10n::t("Public access denied."); - throw $e; - } - - $o = '
'; - $o .= '

Probe Diagnostic

'; - - $o .= '
'; - $o .= 'Lookup address: '; - $o .= '
'; - - $o .= '

'; - - if (!empty($_GET['addr'])) { - $addr = trim($_GET['addr']); - $res = Probe::uri($addr, "", 0, false); - $o .= '
';
-		$o .= str_replace("\n", '
', print_r($res, true)); - $o .= '
'; - } - $o .= '
'; - - return $o; -} diff --git a/src/App/Router.php b/src/App/Router.php index f4db879e22..796845fbb7 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\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); @@ -120,7 +120,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); @@ -152,9 +152,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\Itemsource::class); $this->routeCollector->addRoute(['GET'], '/like/{item:\d+}', Module\Like::class); - $this->routeCollector->addRoute(['GET', 'POST'], '/localtime', Module\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); @@ -184,6 +183,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\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); @@ -212,8 +212,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\ItemBody::class); - $this->routeCollector->addRoute(['GET'], '/webfinger', Module\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/Babel.php b/src/Module/Debug/Babel.php similarity index 99% rename from src/Module/Babel.php rename to src/Module/Debug/Babel.php index 93bb3107f0..899c8033c4 100644 --- a/src/Module/Babel.php +++ b/src/Module/Debug/Babel.php @@ -1,6 +1,6 @@ httpdesc = L10n::t('Public access denied.'); + throw $e; + } + + $addr = defaults($_GET, 'addr', ''); + $res = ''; + + if (!empty($addr)) { + $res = NetworkProbe::uri($addr, '', 0, false); + $res = print_r($res, true); + } + + $tpl = Renderer::getMarkupTemplate('probe.tpl'); + return Renderer::replaceMacros($tpl, [ + '$addr' => ['addr', + L10n::t('Lookup address'), + $addr, + '', + 'required' + ], + '$res' => $res, + ]); + } +} diff --git a/src/Module/WebFinger.php b/src/Module/Debug/WebFinger.php similarity index 69% rename from src/Module/WebFinger.php rename to src/Module/Debug/WebFinger.php index 0c1a692e1b..2b0b9c53b4 100644 --- a/src/Module/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; } - $app = self::getApp(); - $addr = defaults($_GET, 'addr', ''); - $res = ''; + $res = ''; if (!empty($addr)) { $res = Probe::lrdd($addr); diff --git a/src/Module/Itemsource.php b/src/Module/Itemsource.php deleted file mode 100644 index d781db3ac5..0000000000 --- a/src/Module/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; - } -} diff --git a/view/templates/probe.tpl b/view/templates/probe.tpl new file mode 100644 index 0000000000..5f31cc5488 --- /dev/null +++ b/view/templates/probe.tpl @@ -0,0 +1,24 @@ +
+

Probe Diagnostic

+
+
+
+ {{include file="field_input.tpl" field=$addr}} +
+

+
+
+ + {{if $res}} +
+
+
+

Output

+
+
+
{{$res}}
+
+
+
+ {{/if}} +