X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fhostxrd.php;h=16f132fe092ff2a871fcc3a0e15fe67cffbe84c6;hb=5743bb0daec2f91f06689c84a69c8d7315311c51;hp=fe61a874c36ad952f034fd57fb183634a3073036;hpb=43d5876e8b35d53a0bef5248c5d63e5bc209dbbf;p=friendica.git diff --git a/mod/hostxrd.php b/mod/hostxrd.php index fe61a874c3..16f132fe09 100644 --- a/mod/hostxrd.php +++ b/mod/hostxrd.php @@ -1,39 +1,33 @@ 'sha1', - 'private_key_bits' => 4096, - 'encrypt_key' => false )); - + $pubkey = Config::get('system', 'site_pubkey'); - $prvkey = ''; + if (! $pubkey) { + $res = Crypto::newKeypair(1024); - openssl_pkey_export($res, $prvkey); - - // Get public key - - $pkey = openssl_pkey_get_details($res); - $pubkey = $pkey["key"]; - - set_config('system','site_prvkey', $prvkey); - set_config('system','site_pubkey', $pubkey); + Config::set('system','site_prvkey', $res['prvkey']); + Config::set('system','site_pubkey', $res['pubkey']); } - $tpl = file_get_contents('view/xrd_host.tpl'); - echo str_replace(array( - '$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); - session_write_close(); - exit(); + $tpl = get_markup_template('xrd_host.tpl'); + echo replace_macros($tpl, [ + '$zhost' => $a->get_hostname(), + '$zroot' => System::baseUrl(), + '$domain' => System::baseUrl(), + '$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))] + ); -} \ No newline at end of file + exit(); +}