Move mod/probe to src/Module/Probe

This commit is contained in:
Philipp Holzer 2019-05-18 21:05:13 +02:00
parent 7a13582c67
commit 48bba87abe
No known key found for this signature in database
GPG Key ID: D8365C3D36B77D90
10 changed files with 81 additions and 52 deletions

View File

@ -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;
}

View 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);
}

View File

@ -1,6 +1,6 @@
<?php
namespace Friendica\Module;
namespace Friendica\Module\Diagnostic;
use Friendica\BaseModule;
use Friendica\Content\Text;

View File

@ -1,6 +1,6 @@
<?php
namespace Friendica\Module;
namespace Friendica\Module\Diagnostic;
use Friendica\BaseModule;
use Friendica\Core\L10n;
@ -12,7 +12,7 @@ use Friendica\Util\Network;
/**
* Tests a given feed of a contact
*/
class Feedtest extends BaseModule
class Feed extends BaseModule
{
public static function init()
{

View File

@ -1,6 +1,6 @@
<?php
namespace Friendica\Module;
namespace Friendica\Module\Diagnostic;
use Friendica\BaseModule;
use Friendica\Core\L10n;

View File

@ -1,6 +1,6 @@
<?php
namespace Friendica\Module;
namespace Friendica\Module\Diagnostic;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
@ -9,7 +9,7 @@ use Friendica\Model;
/**
* @author Hypolite Petovan <mrpetovan@gmail.com>
*/
class Itemsource extends \Friendica\BaseModule
class ItemSource extends \Friendica\BaseModule
{
public static function content()
{

View File

@ -1,6 +1,6 @@
<?php
namespace Friendica\Module;
namespace Friendica\Module\Diagnostic;
use Friendica\BaseModule;
use Friendica\Core\Installer;

View File

@ -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,
]);
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Friendica\Module;
namespace Friendica\Module\Diagnostic;
use Friendica\BaseModule;
use Friendica\Core\L10n;
@ -20,8 +20,6 @@ class WebFinger extends BaseModule
throw $e;
}
$app = self::getApp();
$addr = defaults($_GET, 'addr', '');
$res = '';

24
view/templates/probe.tpl Normal file
View File

@ -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>