From: Philipp Holzer Date: Tue, 30 Apr 2019 20:22:36 +0000 (+0200) Subject: Move mod/hostxrd to src/Module/Hostxrd X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3cd438c4e3450ce00deeae5be3821c20b1377aee;p=friendica.git Move mod/hostxrd to src/Module/Hostxrd --- 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(); + } +}