Move mod/probe to src/Module/Probe
[friendica.git/.git] / src / Module / Diagnostic / Probe.php
1 <?php
2
3 namespace Friendica\Module\Diagnostic;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 use Friendica\Core\Renderer;
8 use Friendica\Network\HTTPException;
9 use Friendica\Network\Probe as NetworkProbe;
10
11 /**
12  * Fetch information (protocol endpoints and user information) about a given uri
13  */
14 class Probe extends BaseModule
15 {
16         public static function content()
17         {
18                 if (!local_user()) {
19                         $e           = new HTTPException\ForbiddenException(L10n::t("Only logged in users are permitted to perform a probing."));
20                         $e->httpdesc = L10n::t("Public access denied.");
21                         throw $e;
22                 }
23
24                 $addr = defaults($_GET, 'addr', '');
25                 $res  = '';
26
27                 if (!empty($addr)) {
28                         $res = NetworkProbe::uri($addr, '', 0, false);
29                         $res = print_r($res, true);
30                 }
31
32                 $tpl = Renderer::getMarkupTemplate('probe.tpl');
33                 return Renderer::replaceMacros($tpl, [
34                         '$addr' => ['addr',
35                                     L10n::t('Lookup address'),
36                                     $addr,
37                                     '',
38                                     'required'
39                         ],
40                         '$res'  => $res,
41                 ]);
42         }
43 }