]> git.mxchange.org Git - friendica.git/blob - mod/hostxrd.php
Merge pull request #6977 from annando/fix-reshare
[friendica.git] / mod / hostxrd.php
1 <?php
2 /**
3  * @file mod/hostxrd.php
4  */
5 use Friendica\App;
6 use Friendica\Core\Config;
7 use Friendica\Core\Renderer;
8 use Friendica\Core\System;
9 use Friendica\Protocol\Salmon;
10 use Friendica\Util\Crypto;
11
12 function hostxrd_init(App $a)
13 {
14         header('Access-Control-Allow-Origin: *');
15         header("Content-type: text/xml");
16         $pubkey = Config::get('system', 'site_pubkey');
17
18         if (! $pubkey) {
19                 $res = Crypto::newKeypair(1024);
20
21                 Config::set('system','site_prvkey', $res['prvkey']);
22                 Config::set('system','site_pubkey', $res['pubkey']);
23         }
24
25         $tpl = Renderer::getMarkupTemplate('xrd_host.tpl');
26         echo Renderer::replaceMacros($tpl, [
27                 '$zhost' => $a->getHostName(),
28                 '$zroot' => System::baseUrl(),
29                 '$domain' => System::baseUrl(),
30                 '$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))]
31         );
32
33         exit();
34 }