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