]> git.mxchange.org Git - friendica.git/commitdiff
Move mod/probe to src/Module/Probe
authorPhilipp Holzer <admin+github@philipp.info>
Sat, 18 May 2019 19:05:13 +0000 (21:05 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Sun, 19 May 2019 02:24:18 +0000 (04:24 +0200)
16 files changed:
mod/probe.php [deleted file]
src/App/Router.php
src/Module/Babel.php [deleted file]
src/Module/Diagnostic/Babel.php [new file with mode: 0644]
src/Module/Diagnostic/Feed.php [new file with mode: 0644]
src/Module/Diagnostic/ItemBody.php [new file with mode: 0644]
src/Module/Diagnostic/ItemSource.php [new file with mode: 0644]
src/Module/Diagnostic/Localtime.php [new file with mode: 0644]
src/Module/Diagnostic/Probe.php [new file with mode: 0644]
src/Module/Diagnostic/WebFinger.php [new file with mode: 0644]
src/Module/Feedtest.php [deleted file]
src/Module/ItemBody.php [deleted file]
src/Module/Itemsource.php [deleted file]
src/Module/Localtime.php [deleted file]
src/Module/WebFinger.php [deleted file]
view/templates/probe.tpl [new file with mode: 0644]

diff --git a/mod/probe.php b/mod/probe.php
deleted file mode 100644 (file)
index 7fc3a92..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-/**
- * @file mod/probe.php
- */
-use Friendica\App;
-use Friendica\Core\L10n;
-use Friendica\Core\System;
-use Friendica\Network\Probe;
-
-function probe_content(App $a)
-{
-       if (!local_user()) {
-               $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;
-       }
-
-       $o = '<div class="generic-page-wrapper">';
-       $o .= '<h3>Probe Diagnostic</h3>';
-
-       $o .= '<form action="probe" method="get">';
-       $o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . defaults($_GET, 'addr', '') . '" />';
-       $o .= '<input type="submit" name="submit" value="Submit" /></form>';
-
-       $o .= '<br /><br />';
-
-       if (!empty($_GET['addr'])) {
-               $addr = trim($_GET['addr']);
-               $res = Probe::uri($addr, "", 0, false);
-               $o .= '<pre>';
-               $o .= str_replace("\n", '<br />', print_r($res, true));
-               $o .= '</pre>';
-       }
-       $o .= '</div>';
-
-       return $o;
-}
index 373bb1c32e81a3059b15868aca61db72cb352e65..ddb3dbdfe40e9af99b6f3321b96610c6e6e03a55 100644 (file)
@@ -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/Babel.php
deleted file mode 100644 (file)
index 93bb310..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Content\Text;
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Model\Item;
-
-/**
- * Translates input text into different formats (HTML, BBCode, Markdown)
- */
-class Babel extends BaseModule
-{
-       public static function content()
-       {
-               function visible_whitespace($s)
-               {
-                       $s = str_replace(' ', '&nbsp;', $s);
-
-                       return str_replace(["\r\n", "\n", "\r"], '<br />', $s);
-               }
-
-               $results = [];
-               if (!empty($_REQUEST['text'])) {
-                       switch (defaults($_REQUEST, 'type', 'bbcode')) {
-                               case 'bbcode':
-                                       $bbcode = trim($_REQUEST['text']);
-                                       $results[] = [
-                                               'title'   => L10n::t('Source input'),
-                                               'content' => visible_whitespace($bbcode)
-                                       ];
-
-                                       $plain = Text\BBCode::toPlaintext($bbcode, false);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::toPlaintext'),
-                                               'content' => visible_whitespace($plain)
-                                       ];
-
-                                       $html = Text\BBCode::convert($bbcode);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::convert (raw HTML)'),
-                                               'content' => visible_whitespace(htmlspecialchars($html))
-                                       ];
-
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::convert'),
-                                               'content' => $html
-                                       ];
-
-                                       $bbcode2 = Text\HTML::toBBCode($html);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::convert => HTML::toBBCode'),
-                                               'content' => visible_whitespace($bbcode2)
-                                       ];
-
-                                       $markdown = Text\BBCode::toMarkdown($bbcode);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::toMarkdown'),
-                                               'content' => visible_whitespace($markdown)
-                                       ];
-
-                                       $html2 = Text\Markdown::convert($markdown);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::toMarkdown => Markdown::convert'),
-                                               'content' => $html2
-                                       ];
-
-                                       $bbcode3 = Text\Markdown::toBBCode($markdown);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
-                                               'content' => visible_whitespace($bbcode3)
-                                       ];
-
-                                       $bbcode4 = Text\HTML::toBBCode($html2);
-                                       $results[] = [
-                                               'title'   => L10n::t('BBCode::toMarkdown =>  Markdown::convert => HTML::toBBCode'),
-                                               'content' => visible_whitespace($bbcode4)
-                                       ];
-
-                                       $item = [
-                                               'body' => $bbcode,
-                                               'tag'  => '',
-                                       ];
-
-                                       Item::setHashtags($item);
-                                       $results[] = [
-                                               'title'   => L10n::t('Item Body'),
-                                               'content' => visible_whitespace($item['body'])
-                                       ];
-                                       $results[] = [
-                                               'title'   => L10n::t('Item Tags'),
-                                               'content' => $item['tag']
-                                       ];
-                                       break;
-                               case 'markdown':
-                                       $markdown = trim($_REQUEST['text']);
-                                       $results[] = [
-                                               'title'   => L10n::t('Source input (Diaspora format)'),
-                                               'content' => '<pre>' . $markdown . '</pre>'
-                                       ];
-
-                                       $html = Text\Markdown::convert($markdown);
-                                       $results[] = [
-                                               'title'   => L10n::t('Markdown::convert (raw HTML)'),
-                                               'content' => visible_whitespace(htmlspecialchars($html))
-                                       ];
-
-                                       $results[] = [
-                                               'title'   => L10n::t('Markdown::convert'),
-                                               'content' => $html
-                                       ];
-
-                                       $bbcode = Text\Markdown::toBBCode($markdown);
-                                       $results[] = [
-                                               'title'   => L10n::t('Markdown::toBBCode'),
-                                               'content' => '<pre>' . $bbcode . '</pre>'
-                                       ];
-                                       break;
-                               case 'html' :
-                                       $html = trim($_REQUEST['text']);
-                                       $results[] = [
-                                               'title'   => L10n::t('Raw HTML input'),
-                                               'content' => htmlspecialchars($html)
-                                       ];
-
-                                       $results[] = [
-                                               'title'   => L10n::t('HTML Input'),
-                                               'content' => $html
-                                       ];
-
-                                       $bbcode = Text\HTML::toBBCode($html);
-                                       $results[] = [
-                                               'title'   => L10n::t('HTML::toBBCode'),
-                                               'content' => visible_whitespace($bbcode)
-                                       ];
-
-                                       $html2 = Text\BBCode::convert($bbcode);
-                                       $results[] = [
-                                               'title'   => L10n::t('HTML::toBBCode => BBCode::convert'),
-                                               'content' => $html2
-                                       ];
-
-                                       $results[] = [
-                                               'title'   => L10n::t('HTML::toBBCode => BBCode::convert (raw HTML)'),
-                                               'content' => htmlspecialchars($html2)
-                                       ];
-
-                                       $markdown = Text\HTML::toMarkdown($html);
-                                       $results[] = [
-                                               'title'   => L10n::t('HTML::toMarkdown'),
-                                               'content' => visible_whitespace($markdown)
-                                       ];
-
-                                       $text = Text\HTML::toPlaintext($html);
-                                       $results[] = [
-                                               'title'   => L10n::t('HTML::toPlaintext'),
-                                               'content' => '<pre>' . $text . '</pre>'
-                                       ];
-                       }
-               }
-
-               $tpl = Renderer::getMarkupTemplate('babel.tpl');
-               $o = Renderer::replaceMacros($tpl, [
-                       '$text'          => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
-                       '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
-                       '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
-                       '$type_html'     => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
-                       '$results'       => $results
-               ]);
-
-               return $o;
-       }
-}
diff --git a/src/Module/Diagnostic/Babel.php b/src/Module/Diagnostic/Babel.php
new file mode 100644 (file)
index 0000000..797584a
--- /dev/null
@@ -0,0 +1,175 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\BaseModule;
+use Friendica\Content\Text;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Model\Item;
+
+/**
+ * Translates input text into different formats (HTML, BBCode, Markdown)
+ */
+class Babel extends BaseModule
+{
+       public static function content()
+       {
+               function visible_whitespace($s)
+               {
+                       $s = str_replace(' ', '&nbsp;', $s);
+
+                       return str_replace(["\r\n", "\n", "\r"], '<br />', $s);
+               }
+
+               $results = [];
+               if (!empty($_REQUEST['text'])) {
+                       switch (defaults($_REQUEST, 'type', 'bbcode')) {
+                               case 'bbcode':
+                                       $bbcode = trim($_REQUEST['text']);
+                                       $results[] = [
+                                               'title'   => L10n::t('Source input'),
+                                               'content' => visible_whitespace($bbcode)
+                                       ];
+
+                                       $plain = Text\BBCode::toPlaintext($bbcode, false);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::toPlaintext'),
+                                               'content' => visible_whitespace($plain)
+                                       ];
+
+                                       $html = Text\BBCode::convert($bbcode);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::convert (raw HTML)'),
+                                               'content' => visible_whitespace(htmlspecialchars($html))
+                                       ];
+
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::convert'),
+                                               'content' => $html
+                                       ];
+
+                                       $bbcode2 = Text\HTML::toBBCode($html);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::convert => HTML::toBBCode'),
+                                               'content' => visible_whitespace($bbcode2)
+                                       ];
+
+                                       $markdown = Text\BBCode::toMarkdown($bbcode);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::toMarkdown'),
+                                               'content' => visible_whitespace($markdown)
+                                       ];
+
+                                       $html2 = Text\Markdown::convert($markdown);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::toMarkdown => Markdown::convert'),
+                                               'content' => $html2
+                                       ];
+
+                                       $bbcode3 = Text\Markdown::toBBCode($markdown);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::toMarkdown => Markdown::toBBCode'),
+                                               'content' => visible_whitespace($bbcode3)
+                                       ];
+
+                                       $bbcode4 = Text\HTML::toBBCode($html2);
+                                       $results[] = [
+                                               'title'   => L10n::t('BBCode::toMarkdown =>  Markdown::convert => HTML::toBBCode'),
+                                               'content' => visible_whitespace($bbcode4)
+                                       ];
+
+                                       $item = [
+                                               'body' => $bbcode,
+                                               'tag'  => '',
+                                       ];
+
+                                       Item::setHashtags($item);
+                                       $results[] = [
+                                               'title'   => L10n::t('Item Body'),
+                                               'content' => visible_whitespace($item['body'])
+                                       ];
+                                       $results[] = [
+                                               'title'   => L10n::t('Item Tags'),
+                                               'content' => $item['tag']
+                                       ];
+                                       break;
+                               case 'markdown':
+                                       $markdown = trim($_REQUEST['text']);
+                                       $results[] = [
+                                               'title'   => L10n::t('Source input (Diaspora format)'),
+                                               'content' => '<pre>' . $markdown . '</pre>'
+                                       ];
+
+                                       $html = Text\Markdown::convert($markdown);
+                                       $results[] = [
+                                               'title'   => L10n::t('Markdown::convert (raw HTML)'),
+                                               'content' => visible_whitespace(htmlspecialchars($html))
+                                       ];
+
+                                       $results[] = [
+                                               'title'   => L10n::t('Markdown::convert'),
+                                               'content' => $html
+                                       ];
+
+                                       $bbcode = Text\Markdown::toBBCode($markdown);
+                                       $results[] = [
+                                               'title'   => L10n::t('Markdown::toBBCode'),
+                                               'content' => '<pre>' . $bbcode . '</pre>'
+                                       ];
+                                       break;
+                               case 'html' :
+                                       $html = trim($_REQUEST['text']);
+                                       $results[] = [
+                                               'title'   => L10n::t('Raw HTML input'),
+                                               'content' => htmlspecialchars($html)
+                                       ];
+
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML Input'),
+                                               'content' => $html
+                                       ];
+
+                                       $bbcode = Text\HTML::toBBCode($html);
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toBBCode'),
+                                               'content' => visible_whitespace($bbcode)
+                                       ];
+
+                                       $html2 = Text\BBCode::convert($bbcode);
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toBBCode => BBCode::convert'),
+                                               'content' => $html2
+                                       ];
+
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toBBCode => BBCode::convert (raw HTML)'),
+                                               'content' => htmlspecialchars($html2)
+                                       ];
+
+                                       $markdown = Text\HTML::toMarkdown($html);
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toMarkdown'),
+                                               'content' => visible_whitespace($markdown)
+                                       ];
+
+                                       $text = Text\HTML::toPlaintext($html);
+                                       $results[] = [
+                                               'title'   => L10n::t('HTML::toPlaintext'),
+                                               'content' => '<pre>' . $text . '</pre>'
+                                       ];
+                       }
+               }
+
+               $tpl = Renderer::getMarkupTemplate('babel.tpl');
+               $o = Renderer::replaceMacros($tpl, [
+                       '$text'          => ['text', L10n::t('Source text'), defaults($_REQUEST, 'text', ''), ''],
+                       '$type_bbcode'   => ['type', L10n::t('BBCode'), 'bbcode', '', defaults($_REQUEST, 'type', 'bbcode') == 'bbcode'],
+                       '$type_markdown' => ['type', L10n::t('Markdown'), 'markdown', '', defaults($_REQUEST, 'type', 'bbcode') == 'markdown'],
+                       '$type_html'     => ['type', L10n::t('HTML'), 'html', '', defaults($_REQUEST, 'type', 'bbcode') == 'html'],
+                       '$results'       => $results
+               ]);
+
+               return $o;
+       }
+}
diff --git a/src/Module/Diagnostic/Feed.php b/src/Module/Diagnostic/Feed.php
new file mode 100644 (file)
index 0000000..c54431f
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Model;
+use Friendica\Protocol;
+use Friendica\Util\Network;
+
+/**
+ * Tests a given feed of a contact
+ */
+class Feed extends BaseModule
+{
+       public static function init()
+       {
+               if (!local_user()) {
+                       info(L10n::t('You must be logged in to use this module'));
+                       self::getApp()->internalRedirect();
+               }
+       }
+
+       public static function content()
+       {
+               $result = [];
+               if (!empty($_REQUEST['url'])) {
+                       $url = $_REQUEST['url'];
+
+                       $importer = Model\User::getById(local_user());
+
+                       $contact_id = Model\Contact::getIdForURL($url, local_user(), true);
+                       $contact = Model\Contact::getById($contact_id);
+
+                       $xml = Network::fetchUrl($contact['poll']);
+
+                       $dummy = null;
+                       $import_result = Protocol\Feed::import($xml, $importer, $contact, $dummy, true);
+
+                       $result = [
+                               'input' => $xml,
+                               'output' => var_export($import_result, true),
+                       ];
+               }
+
+               $tpl = Renderer::getMarkupTemplate('feedtest.tpl');
+               return Renderer::replaceMacros($tpl, [
+                       '$url'    => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
+                       '$result' => $result
+               ]);
+       }
+}
diff --git a/src/Module/Diagnostic/ItemBody.php b/src/Module/Diagnostic/ItemBody.php
new file mode 100644 (file)
index 0000000..e4e45b7
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Model\Item;
+use Friendica\Network\HTTPException;
+
+/**
+ * Print the body of an Item
+ */
+class ItemBody extends BaseModule
+{
+       public static function content()
+       {
+               if (!local_user()) {
+                       throw new HTTPException\UnauthorizedException(L10n::t('Access denied.'));
+               }
+
+               $app = self::getApp();
+
+               // @TODO: Replace with parameter from router
+               $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
+
+               if (!$itemId) {
+                       throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
+               }
+
+               $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
+
+               if (!empty($item)) {
+                       if ($app->isAjax()) {
+                               echo str_replace("\n", '<br />', $item['body']);
+                               exit();
+                       } else {
+                               return str_replace("\n", '<br />', $item['body']);
+                       }
+               } else {
+                       throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
+               }
+       }
+}
diff --git a/src/Module/Diagnostic/ItemSource.php b/src/Module/Diagnostic/ItemSource.php
new file mode 100644 (file)
index 0000000..bd580cf
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Model;
+
+/**
+ * @author Hypolite Petovan <mrpetovan@gmail.com>
+ */
+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/src/Module/Diagnostic/Localtime.php b/src/Module/Diagnostic/Localtime.php
new file mode 100644 (file)
index 0000000..a3870ca
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\BaseModule;
+use Friendica\Core\Installer;
+use Friendica\Core\L10n;
+use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Temporal;
+
+class Localtime extends BaseModule
+{
+       public static function post()
+       {
+               $time = defaults($_REQUEST, 'time', 'now');
+
+               $bd_format = L10n::t('l F d, Y \@ g:i A');
+
+               if (!empty($_POST['timezone'])) {
+                       self::getApp()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
+               }
+       }
+
+       public static function content()
+       {
+               $app = self::getApp();
+
+               $time = defaults($_REQUEST, 'time', 'now');
+
+               $output  = '<h3>' . L10n::t('Time Conversion') . '</h3>';
+               $output .= '<p>' . L10n::t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
+               $output .= '<p>' . L10n::t('UTC time: %s', $time) . '</p>';
+
+               if (!empty($_REQUEST['timezone'])) {
+                       $output .= '<p>' . L10n::t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
+               }
+
+               if (!empty($app->data['mod-localtime'])) {
+                       $output .= '<p>' . L10n::t('Converted localtime: %s', $app->data['mod-localtime']) . '</p>';
+               }
+
+               $output .= '<form action ="' . $app->getBaseURL() . '/localtime?f=&time=' . $time . '" method="post" >';
+               $output .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
+               $output .= Temporal::getTimezoneSelect(defaults($_REQUEST, 'timezone', Installer::DEFAULT_TZ));
+               $output .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
+
+               return $output;
+       }
+}
diff --git a/src/Module/Diagnostic/Probe.php b/src/Module/Diagnostic/Probe.php
new file mode 100644 (file)
index 0000000..516c494
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Network\HTTPException;
+use Friendica\Network\Probe as NetworkProbe;
+
+/**
+ * Fetch information (protocol endpoints and user information) about a given uri
+ */
+class Probe extends BaseModule
+{
+       public static function content()
+       {
+               if (!local_user()) {
+                       $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;
+               }
+
+               $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/Diagnostic/WebFinger.php b/src/Module/Diagnostic/WebFinger.php
new file mode 100644 (file)
index 0000000..5d6e05a
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Friendica\Module\Diagnostic;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Network\Probe;
+
+/**
+ * Web based module to perform webfinger probing
+ */
+class WebFinger extends BaseModule
+{
+       public static function content()
+       {
+               if (!local_user()) {
+                       $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 = '';
+
+               if (!empty($addr)) {
+                       $res = Probe::lrdd($addr);
+                       $res = print_r($res, true);
+               }
+
+               $tpl = Renderer::getMarkupTemplate('webfinger.tpl');
+               return Renderer::replaceMacros($tpl, [
+                       '$addr' => $addr,
+                       '$res'  => $res,
+               ]);
+       }
+}
diff --git a/src/Module/Feedtest.php b/src/Module/Feedtest.php
deleted file mode 100644 (file)
index 75cca52..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Model;
-use Friendica\Protocol;
-use Friendica\Util\Network;
-
-/**
- * Tests a given feed of a contact
- */
-class Feedtest extends BaseModule
-{
-       public static function init()
-       {
-               if (!local_user()) {
-                       info(L10n::t('You must be logged in to use this module'));
-                       self::getApp()->internalRedirect();
-               }
-       }
-
-       public static function content()
-       {
-               $result = [];
-               if (!empty($_REQUEST['url'])) {
-                       $url = $_REQUEST['url'];
-
-                       $importer = Model\User::getById(local_user());
-
-                       $contact_id = Model\Contact::getIdForURL($url, local_user(), true);
-                       $contact = Model\Contact::getById($contact_id);
-
-                       $xml = Network::fetchUrl($contact['poll']);
-
-                       $dummy = null;
-                       $import_result = Protocol\Feed::import($xml, $importer, $contact, $dummy, true);
-
-                       $result = [
-                               'input' => $xml,
-                               'output' => var_export($import_result, true),
-                       ];
-               }
-
-               $tpl = Renderer::getMarkupTemplate('feedtest.tpl');
-               return Renderer::replaceMacros($tpl, [
-                       '$url'    => ['url', L10n::t('Source URL'), defaults($_REQUEST, 'url', ''), ''],
-                       '$result' => $result
-               ]);
-       }
-}
diff --git a/src/Module/ItemBody.php b/src/Module/ItemBody.php
deleted file mode 100644 (file)
index ee50b52..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\L10n;
-use Friendica\Model\Item;
-use Friendica\Network\HTTPException;
-
-/**
- * Print the body of an Item
- */
-class ItemBody extends BaseModule
-{
-       public static function content()
-       {
-               if (!local_user()) {
-                       throw new HTTPException\UnauthorizedException(L10n::t('Access denied.'));
-               }
-
-               $app = self::getApp();
-
-               // @TODO: Replace with parameter from router
-               $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
-
-               if (!$itemId) {
-                       throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
-               }
-
-               $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
-
-               if (!empty($item)) {
-                       if ($app->isAjax()) {
-                               echo str_replace("\n", '<br />', $item['body']);
-                               exit();
-                       } else {
-                               return str_replace("\n", '<br />', $item['body']);
-                       }
-               } else {
-                       throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
-               }
-       }
-}
diff --git a/src/Module/Itemsource.php b/src/Module/Itemsource.php
deleted file mode 100644 (file)
index d781db3..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Model;
-
-/**
- * @author Hypolite Petovan <mrpetovan@gmail.com>
- */
-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/src/Module/Localtime.php b/src/Module/Localtime.php
deleted file mode 100644 (file)
index d0b5408..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\Installer;
-use Friendica\Core\L10n;
-use Friendica\Util\DateTimeFormat;
-use Friendica\Util\Temporal;
-
-class Localtime extends BaseModule
-{
-       public static function post()
-       {
-               $time = defaults($_REQUEST, 'time', 'now');
-
-               $bd_format = L10n::t('l F d, Y \@ g:i A');
-
-               if (!empty($_POST['timezone'])) {
-                       self::getApp()->data['mod-localtime'] = DateTimeFormat::convert($time, $_POST['timezone'], 'UTC', $bd_format);
-               }
-       }
-
-       public static function content()
-       {
-               $app = self::getApp();
-
-               $time = defaults($_REQUEST, 'time', 'now');
-
-               $output  = '<h3>' . L10n::t('Time Conversion') . '</h3>';
-               $output .= '<p>' . L10n::t('Friendica provides this service for sharing events with other networks and friends in unknown timezones.') . '</p>';
-               $output .= '<p>' . L10n::t('UTC time: %s', $time) . '</p>';
-
-               if (!empty($_REQUEST['timezone'])) {
-                       $output .= '<p>' . L10n::t('Current timezone: %s', $_REQUEST['timezone']) . '</p>';
-               }
-
-               if (!empty($app->data['mod-localtime'])) {
-                       $output .= '<p>' . L10n::t('Converted localtime: %s', $app->data['mod-localtime']) . '</p>';
-               }
-
-               $output .= '<form action ="' . $app->getBaseURL() . '/localtime?f=&time=' . $time . '" method="post" >';
-               $output .= '<p>' . L10n::t('Please select your timezone:') . '</p>';
-               $output .= Temporal::getTimezoneSelect(defaults($_REQUEST, 'timezone', Installer::DEFAULT_TZ));
-               $output .= '<input type="submit" name="submit" value="' . L10n::t('Submit') . '" /></form>';
-
-               return $output;
-       }
-}
diff --git a/src/Module/WebFinger.php b/src/Module/WebFinger.php
deleted file mode 100644 (file)
index 0c1a692..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Network\Probe;
-
-/**
- * Web based module to perform webfinger probing
- */
-class WebFinger extends BaseModule
-{
-       public static function content()
-       {
-               if (!local_user()) {
-                       $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 = '';
-
-               if (!empty($addr)) {
-                       $res = Probe::lrdd($addr);
-                       $res = print_r($res, true);
-               }
-
-               $tpl = Renderer::getMarkupTemplate('webfinger.tpl');
-               return Renderer::replaceMacros($tpl, [
-                       '$addr' => $addr,
-                       '$res'  => $res,
-               ]);
-       }
-}
diff --git a/view/templates/probe.tpl b/view/templates/probe.tpl
new file mode 100644 (file)
index 0000000..5f31cc5
--- /dev/null
@@ -0,0 +1,24 @@
+<div id="probe" class="generic-page-wrapper">
+       <h2>Probe Diagnostic</h2>
+       <form action="probe" method="get" class="panel panel-default">
+               <div class="panel-body">
+                       <div class="form-group">
+                               {{include file="field_input.tpl" field=$addr}}
+                       </div>
+                       <p><button type="submit" class="btn btn-primary">Submit</button></p>
+               </div>
+       </form>
+
+       {{if $res}}
+               <div class="probe-result">
+                       <div class="panel panel-default">
+                               <div class="panel-heading">
+                                       <h3 class="panel-title">Output</h3>
+                               </div>
+                               <div class="panel-body">
+                                       <pre>{{$res}}</pre>
+                               </div>
+                       </div>
+               </div>
+       {{/if}}
+</div>