]> git.mxchange.org Git - friendica.git/commitdiff
Adding to router
authorPhilipp Holzer <admin@philipp.info>
Tue, 30 Apr 2019 20:36:28 +0000 (22:36 +0200)
committerPhilipp Holzer <admin@philipp.info>
Wed, 1 May 2019 16:24:51 +0000 (18:24 +0200)
mod/_well_known.php
src/App/Router.php
src/Module/HostMeta.php [new file with mode: 0644]
src/Module/Hostxrd.php [deleted file]

index 3dbac799fd64ec63d10b5011729bb990db31567c..3bd86ecc9c1405580f74c1bf04db140614755f5f 100644 (file)
@@ -3,7 +3,7 @@
 use Friendica\App;
 use Friendica\Core\Config;
 use Friendica\Core\System;
-use Friendica\Module\Hostxrd;
+use Friendica\Module\HostMeta;
 use Friendica\Module\Nodeinfo;
 
 require_once 'mod/xrd.php';
@@ -13,7 +13,7 @@ function _well_known_init(App $a)
        if ($a->argc > 1) {
                switch ($a->argv[1]) {
                        case "host-meta":
-                               Hostxrd::printHostMeta();
+                               HostMeta::printHostMeta();
                                break;
                        case "x-social-relay":
                                wk_social_relay();
index 039d3e2cf9fb1e133d7283a6bf9b805a10b0143e..53fe0689a6452a85cf5ef3eb43f25f1858dd5628 100644 (file)
@@ -42,6 +42,8 @@ class Router
        {
                $this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Itemsource::class);
                $this->routeCollector->addRoute(['GET'],         '/amcd',                Module\AccountManagementControlDocument::class);
+               $this->routeCollector->addRoute(['GET'],         '/host-meta',           Module\HostMeta::class);
+               $this->routeCollector->addRoute(['GET'],         '/hostxrd',             Module\HostMeta::class);
        }
 
        public function __construct(RouteCollector $routeCollector = null)
diff --git a/src/Module/HostMeta.php b/src/Module/HostMeta.php
new file mode 100644 (file)
index 0000000..21953b5
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\Renderer;
+use Friendica\Protocol\Salmon;
+use Friendica\Util\Crypto;
+
+/**
+ * Prints the host-meta text
+ */
+class HostMeta extends BaseModule
+{
+       public static function rawContent()
+       {
+               parent::rawContent();
+
+               self::printHostMeta();
+       }
+
+       /**
+        * Prints the host-meta output of this node
+        *
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        */
+       public static function printHostMeta()
+       {
+               $app = self::getApp();
+               $config = $app->getConfig();
+
+               header("Content-type: text/xml");
+
+               if (!$config->get('system', 'site_pubkey', false)) {
+                       $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();
+       }
+}
diff --git a/src/Module/Hostxrd.php b/src/Module/Hostxrd.php
deleted file mode 100644 (file)
index 4f95ebb..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-
-namespace Friendica\Module;
-
-use Friendica\BaseModule;
-use Friendica\Core\Renderer;
-use Friendica\Protocol\Salmon;
-use Friendica\Util\Crypto;
-
-/**
- * Prints the host-meta text
- */
-class Hostxrd extends BaseModule
-{
-       public static function rawContent()
-       {
-               parent::rawContent();
-
-               self::printHostMeta();
-       }
-
-       /**
-        * Prints the host-meta output of this node
-        *
-        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
-        */
-       public static function printHostMeta()
-       {
-               $app = self::getApp();
-               $config = $app->getConfig();
-
-               header("Content-type: text/xml");
-
-               if (!$config->get('system', 'site_pubkey', false)) {
-                       $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();
-       }
-}