$user ?? '', 'password' => $password ?? '', ); } $pupupu = new Pupupu('..', '..', '..'); if (isset($_SERVER['REQUEST_METHOD'])) { $loader = new \Twig\Loader\FilesystemLoader('templates'); $twig = new \Twig\Environment($loader); $twig->addFilter(new \Twig\TwigFilter('trans', 'trans')); $twig->addGlobal('site_title', $_SERVER['HTTP_HOST']); try { $auth = getAuth(); if (!$pupupu->checkPassword($auth['user'], $auth['password'])) { $msg = trans('Login required'); header('WWW-Authenticate: Basic realm="' . $msg . '"'); throw new HttpException($msg, 401); } if (empty($_GET['path']) && $_GET['path'] !== '') { pagesView($pupupu, $twig); } elseif ($_GET['path'] === '/_site') { siteView($pupupu, $twig); } elseif (substr($_GET['path'], 0, 7) === '/_files') { filesView($pupupu, $twig); } elseif (substr($_GET['path'], 0, 7) === '/_users') { usersView($pupupu, $twig); } else { pageView($pupupu, $twig); } } catch (WriteException $e) { errorView($pupupu, $twig, new HttpException('unable to write: ' . $e->getMessage(), 500)); } catch (\Twig\Error\LoaderError $e) { errorView($pupupu, $twig, new HttpException($e->getMessage(), 500)); } catch (HttpException $e) { errorView($pupupu, $twig, $e); } } else { $pupupu->renderAll(true); }