From 3cd438c4e3450ce00deeae5be3821c20b1377aee Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Tue, 30 Apr 2019 22:22:36 +0200 Subject: [PATCH] Move mod/hostxrd to src/Module/Hostxrd --- mod/_well_known.php | 3 ++- mod/hostxrd.php | 34 --------------------------- src/Module/Hostxrd.php | 52 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 35 deletions(-) delete mode 100644 mod/hostxrd.php create mode 100644 src/Module/Hostxrd.php diff --git a/mod/_well_known.php b/mod/_well_known.php index 8e82dabeff..d861b27801 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 93a9d833c9..0000000000 --- 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 0000000000..75997c86b4 --- /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(); + } +}