3 require_once('include/crypto.php');
5 function hostxrd_init(&$a) {
6 header('Access-Control-Allow-Origin: *');
7 header("Content-type: text/xml");
8 $pubkey = get_config('system','site_pubkey');
12 // should only have to ever do this once.
14 $res=openssl_pkey_new(array(
15 'digest_alg' => 'sha1',
16 'private_key_bits' => 4096,
17 'encrypt_key' => false ));
22 openssl_pkey_export($res, $prvkey);
26 $pkey = openssl_pkey_get_details($res);
27 $pubkey = $pkey["key"];
29 set_config('system','site_prvkey', $prvkey);
30 set_config('system','site_pubkey', $pubkey);
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();