From b32f366b016162897aec2e438ce2f3a46450eeac Mon Sep 17 00:00:00 2001 From: Ilya Prokopenko Date: Mon, 27 Dec 2021 19:35:14 +0300 Subject: [PATCH] robots.txt (#89) Closes #89 I also added humans.txt just for fun --- Web/Presenters/AboutPresenter.php | 34 +++++++++++++++++++++++++++++++ Web/routes.yml | 4 ++++ 2 files changed, 38 insertions(+) diff --git a/Web/Presenters/AboutPresenter.php b/Web/Presenters/AboutPresenter.php index 4c7f916b..e77866c8 100644 --- a/Web/Presenters/AboutPresenter.php +++ b/Web/Presenters/AboutPresenter.php @@ -83,4 +83,38 @@ final class AboutPresenter extends OpenVKPresenter { $this->template->languages = getLanguages(); } + + function renderRobotsTxt(): void + { + $data = "# robots.txt file for openvk\n" + . "#\n" + . "# this includes only those links that are not in any way\n" + . "# covered from unauthorized persons (for example, due to\n" + . "# lack of rights to access the admin panel)\n\n" + . "User-Agent: *\n" + . "Disallow: /rpc\n" + . "Disallow: /language\n" + . "Disallow: /badbrowser.php\n" + . "Disallow: /logout\n" + . "Disallow: /away.php\n" + . "Disallow: /im?\n" + . "Disallow: *query=\n" + . "Disallow: *?lg=\n" + . "Disallow: *hash=\n" + . "Disallow: *?jReturnTo=\n" + . "Disallow: /wall*\n" + . "Disallow: /method/*\n" + . "Disallow: /token*"; + header("Content-Type: text/plain"); + exit($data); + } + + function renderHumansTxt(): void + { + // :D + + header("HTTP/1.1 302 Found"); + header("Location: https://github.com/openvk/openvk#readme"); + exit; + } } diff --git a/Web/routes.yml b/Web/routes.yml index 9ef0389a..f6a27efa 100644 --- a/Web/routes.yml +++ b/Web/routes.yml @@ -265,6 +265,10 @@ routes: handler: "About->sandbox" - url: "/internal/wall{num}" handler: "Wall->wallEmbedded" + - url: "/robots.txt" + handler: "About->robotsTxt" + - url: "/humans.txt" + handler: "About->humansTxt" - url: "/{?shortCode}" handler: "UnknownTextRouteStrategy->delegate" placeholders: