+++ /dev/null
-<?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;
-}
$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);
$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);
$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);
$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);
}
+++ /dev/null
-<?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(' ', ' ', $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;
- }
-}
--- /dev/null
+<?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(' ', ' ', $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;
+ }
+}
--- /dev/null
+<?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
+ ]);
+ }
+}
--- /dev/null
+<?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.'));
+ }
+ }
+}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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;
+ }
+}
--- /dev/null
+<?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,
+ ]);
+ }
+}
--- /dev/null
+<?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,
+ ]);
+ }
+}
+++ /dev/null
-<?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
- ]);
- }
-}
+++ /dev/null
-<?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.'));
- }
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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;
- }
-}
+++ /dev/null
-<?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,
- ]);
- }
-}
--- /dev/null
+<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>