]> git.mxchange.org Git - friendica.git/blob - mod/hostxrd.php
Some Bugfixes, and variable checks
[friendica.git] / mod / hostxrd.php
1 <?php
2
3 require_once('include/crypto.php');
4
5 function hostxrd_init(&$a) {
6         header('Access-Control-Allow-Origin: *');
7         header("Content-type: text/xml");
8         $pubkey = get_config('system','site_pubkey');
9
10         if(! $pubkey) {
11
12                 // should only have to ever do this once.
13
14                 $res=openssl_pkey_new(array(
15                         'digest_alg' => 'sha1',
16                         'private_key_bits' => 4096,
17                         'encrypt_key' => false ));
18
19
20                 $prvkey = '';
21
22                 openssl_pkey_export($res, $prvkey);
23
24                 // Get public key
25
26                 $pkey = openssl_pkey_get_details($res);
27                 $pubkey = $pkey["key"];
28
29                 set_config('system','site_prvkey', $prvkey);
30                 set_config('system','site_pubkey', $pubkey);
31         }
32
33         $tpl = file_get_contents('view/xrd_host.tpl');
34         echo str_replace(array(
35                 '$zhost','$zroot','$domain','$zot_post','$bigkey'),array($a->get_hostname(),z_root(),z_path(),z_root() . '/post', salmon_key(get_config('system','site_pubkey'))),$tpl);
36         session_write_close();
37         exit();
38
39 }