<?php

namespace app\foreignone;

use engine\http\errors\NotFound;
use engine\http\errors\Redirect;
use engine\http\PlainTextResponse;
use engine\http\Response;

class ServicesHandler
    extends BaseHandler
{
    public function GET_robots_txt(): Response {
        $txt = <<<TXT
User-agent: *
Disallow: /admin/
TXT;
        return new PlainTextResponse($txt);
    }

    public function GET_latest(): Response {
        global $config;
        list($lang) = $this->input('lang');
        if (!isset($config['book_versions'][$lang]))
            throw new NotFound();
        throw new Redirect("https://files.4in1.ws/4in1-{$lang}.pdf?{$config['book_versions'][$lang]}");
    }
}