]> git.mxchange.org Git - friendica.git/blob - src/Module/Hostxrd.php
optimize check
[friendica.git] / src / Module / Hostxrd.php
1 <?php
2
3 namespace Friendica\Module;
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 host-meta text
12  */
13 class Hostxrd extends BaseModule
14 {
15         public static function rawContent()
16         {
17                 parent::rawContent();
18
19                 self::printHostMeta();
20         }
21
22         /**
23          * Prints the host-meta output of this node
24          *
25          * @throws \Friendica\Network\HTTPException\InternalServerErrorException
26          */
27         public static function printHostMeta()
28         {
29                 $app = self::getApp();
30                 $config = $app->getConfig();
31
32                 header("Content-type: text/xml");
33
34                 if (!$config->get('system', 'site_pubkey', false)) {
35                         $res = Crypto::newKeypair(1024);
36
37                         $config->set('system','site_prvkey', $res['prvkey']);
38                         $config->set('system','site_pubkey', $res['pubkey']);
39                 }
40
41                 $tpl = Renderer::getMarkupTemplate('xrd_host.tpl');
42                 echo Renderer::replaceMacros($tpl, [
43                                 '$zhost' => $app->getHostName(),
44                                 '$zroot' => $app->getBaseURL(),
45                                 '$domain' => $app->getBaseURL(),
46                                 '$bigkey' => Salmon::salmonKey($config->get('system', 'site_pubkey'))]
47                 );
48
49                 exit();
50         }
51 }