]> git.mxchange.org Git - friendica.git/blob - mod/hostxrd.php
Ops, one more left ...
[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\System;
8 use Friendica\Protocol\Salmon;
9 use Friendica\Util\Crypto;
10
11 function hostxrd_init(App $a)
12 {
13         header('Access-Control-Allow-Origin: *');
14         header("Content-type: text/xml");
15         $pubkey = Config::get('system', 'site_pubkey');
16
17         if (! $pubkey) {
18                 $res = Crypto::newKeypair(1024);
19
20                 Config::set('system','site_prvkey', $res['prvkey']);
21                 Config::set('system','site_pubkey', $res['pubkey']);
22         }
23
24         $tpl = get_markup_template('xrd_host.tpl');
25         echo replace_macros($tpl, [
26                 '$zhost' => $a->get_hostname(),
27                 '$zroot' => System::baseUrl(),
28                 '$domain' => System::baseUrl(),
29                 '$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))]
30         );
31
32         exit();
33 }