]> git.mxchange.org Git - friendica.git/blob - src/Module/WellKnown/HostMeta.php
Introduce new DI container
[friendica.git] / src / Module / WellKnown / HostMeta.php
1 <?php
2
3 namespace Friendica\Module\WellKnown;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\Renderer;
7 use Friendica\DI;
8 use Friendica\Protocol\Salmon;
9 use Friendica\Util\Crypto;
10
11 /**
12  * Prints the metadata for describing this host
13  * @see https://tools.ietf.org/html/rfc6415
14  */
15 class HostMeta extends BaseModule
16 {
17         public static function rawContent(array $parameters = [])
18         {
19                 $app = DI::app();
20                 $config = $app->getConfig();
21
22                 header('Content-type: text/xml');
23
24                 if (!$config->get('system', 'site_pubkey', false)) {
25                         $res = Crypto::newKeypair(1024);
26
27                         $config->set('system', 'site_prvkey', $res['prvkey']);
28                         $config->set('system', 'site_pubkey', $res['pubkey']);
29                 }
30
31                 $tpl = Renderer::getMarkupTemplate('xrd_host.tpl');
32                 echo Renderer::replaceMacros($tpl, [
33                         '$zhost'  => $app->getHostName(),
34                         '$zroot'  => $app->getBaseURL(),
35                         '$domain' => $app->getBaseURL(),
36                         '$bigkey' => Salmon::salmonKey($config->get('system', 'site_pubkey'))
37                 ]);
38
39                 exit();
40         }
41 }