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