diff --git a/mod/_well_known.php b/mod/_well_known.php index 8e82dabef..d861b2780 100644 --- a/mod/_well_known.php +++ b/mod/_well_known.php @@ -3,6 +3,7 @@ use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; +use Friendica\Module\Hostxrd; use Friendica\Module\Nodeinfo; require_once 'mod/hostxrd.php'; @@ -13,7 +14,7 @@ function _well_known_init(App $a) if ($a->argc > 1) { switch ($a->argv[1]) { case "host-meta": - hostxrd_init($a); + Hostxrd::printHostMeta(); break; case "x-social-relay": wk_social_relay(); diff --git a/mod/hostxrd.php b/mod/hostxrd.php deleted file mode 100644 index 93a9d833c..000000000 --- a/mod/hostxrd.php +++ /dev/null @@ -1,34 +0,0 @@ - $a->getHostName(), - '$zroot' => System::baseUrl(), - '$domain' => System::baseUrl(), - '$bigkey' => Salmon::salmonKey(Config::get('system', 'site_pubkey'))] - ); - - exit(); -} diff --git a/src/Module/Hostxrd.php b/src/Module/Hostxrd.php new file mode 100644 index 000000000..75997c86b --- /dev/null +++ b/src/Module/Hostxrd.php @@ -0,0 +1,52 @@ +getConfig(); + + header("Content-type: text/xml"); + $pubkey = $config->get('system', 'site_pubkey'); + + if (!$pubkey) { + $res = Crypto::newKeypair(1024); + + $config->set('system','site_prvkey', $res['prvkey']); + $config->set('system','site_pubkey', $res['pubkey']); + } + + $tpl = Renderer::getMarkupTemplate('xrd_host.tpl'); + echo Renderer::replaceMacros($tpl, [ + '$zhost' => $app->getHostName(), + '$zroot' => $app->getBaseURL(), + '$domain' => $app->getBaseURL(), + '$bigkey' => Salmon::salmonKey($config->get('system', 'site_pubkey'))] + ); + + exit(); + } +}