From 48bba87abe7e8d78c48eaec2688509a9dfde7c4f Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Sat, 18 May 2019 21:05:13 +0200 Subject: [PATCH] Move mod/probe to src/Module/Probe --- mod/probe.php | 37 ---------------- src/App/Router.php | 11 ++--- src/Module/{ => Diagnostic}/Babel.php | 2 +- .../{Feedtest.php => Diagnostic/Feed.php} | 4 +- src/Module/{ => Diagnostic}/ItemBody.php | 2 +- .../ItemSource.php} | 4 +- src/Module/{ => Diagnostic}/Localtime.php | 2 +- src/Module/Diagnostic/Probe.php | 43 +++++++++++++++++++ src/Module/{ => Diagnostic}/WebFinger.php | 4 +- view/templates/probe.tpl | 24 +++++++++++ 10 files changed, 81 insertions(+), 52 deletions(-) delete mode 100644 mod/probe.php rename src/Module/{ => Diagnostic}/Babel.php (99%) rename src/Module/{Feedtest.php => Diagnostic/Feed.php} (94%) rename src/Module/{ => Diagnostic}/ItemBody.php (95%) rename src/Module/{Itemsource.php => Diagnostic/ItemSource.php} (93%) rename src/Module/{ => Diagnostic}/Localtime.php (97%) create mode 100644 src/Module/Diagnostic/Probe.php rename src/Module/{ => Diagnostic}/WebFinger.php (93%) create mode 100644 view/templates/probe.tpl 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 373bb1c32e..ddb3dbdfe4 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\Diagnostic\Babel::class); $this->routeCollector->addRoute(['GET'], '/bookmarklet', Module\Bookmarklet::class); $this->routeCollector->addGroup('/contact', function (RouteCollector $collector) { $collector->addRoute(['GET'], '[/]', Module\Contact::class); @@ -153,9 +153,9 @@ 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', 'POST'], '/itemsource[/{guid}]', Module\Diagnostic\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\Diagnostic\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,6 +185,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->addGroup('/profile', function (RouteCollector $collector) { $collector->addRoute(['GET'], '/{nickname}', Module\Profile::class); $collector->addRoute(['GET'], '/{profile:\d+}/view', Module\Profile::class); @@ -213,8 +214,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\Diagnostic\ItemBody::class); + $this->routeCollector->addRoute(['GET'], '/webfinger', Module\Diagnostic\WebFinger::class); $this->routeCollector->addRoute(['GET'], '/xrd', Module\Xrd::class); } diff --git a/src/Module/Babel.php b/src/Module/Diagnostic/Babel.php similarity index 99% rename from src/Module/Babel.php rename to src/Module/Diagnostic/Babel.php index 93bb3107f0..797584a4f7 100644 --- a/src/Module/Babel.php +++ b/src/Module/Diagnostic/Babel.php @@ -1,6 +1,6 @@ */ -class Itemsource extends \Friendica\BaseModule +class ItemSource extends \Friendica\BaseModule { public static function content() { diff --git a/src/Module/Localtime.php b/src/Module/Diagnostic/Localtime.php similarity index 97% rename from src/Module/Localtime.php rename to src/Module/Diagnostic/Localtime.php index d0b540879b..a3870ca95e 100644 --- a/src/Module/Localtime.php +++ b/src/Module/Diagnostic/Localtime.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/Diagnostic/WebFinger.php similarity index 93% rename from src/Module/WebFinger.php rename to src/Module/Diagnostic/WebFinger.php index 0c1a692e1b..5d6e05a27d 100644 --- a/src/Module/WebFinger.php +++ b/src/Module/Diagnostic/WebFinger.php @@ -1,6 +1,6 @@ +

Probe Diagnostic

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

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

Output

+
+
+
{{$res}}
+
+
+
+ {{/if}} + -- 2.39.5