diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-02-23 22:57:27 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-02-23 22:57:27 -0500 |
| commit | f373ead95fb5beb962c376b5b7b46dfde8ac4e57 (patch) | |
| tree | c99df23521ff2a5e5e2e4627c525a5e99dc2e3ae /src/web/core/controller.php | |
| parent | add 96x96 logo (diff) | |
| download | website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.gz website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.tar.bz2 website-f373ead95fb5beb962c376b5b7b46dfde8ac4e57.zip | |
update website to work with crimson framework
Diffstat (limited to 'src/web/core/controller.php')
| -rw-r--r-- | src/web/core/controller.php | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/src/web/core/controller.php b/src/web/core/controller.php deleted file mode 100644 index ca892e2..0000000 --- a/src/web/core/controller.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php /* Copyright (c) 2024 Freya Murphy */ - -abstract class Controller extends Component { - - /** - * Default index for a app, empty - */ - public function index(): void {} - - /** - * Redirectes to a link - */ - public function redirect(string $link): void - { - header('Location: '. $link, true, 301); - die(); - } - - /** - * Lodas a view - */ - protected function view(string $__name, array $data = array()): void - { - $__path = WEB_ROOT . '/_views/' . $__name . '.php'; - if (is_file($__path)) { - extract($data); - require($__path); - } - } - - /** - * Loads a erorr page with a given - * error code - */ - protected function error(int $code): void - { - $error_controller = $this->load_controller('error'); - $error_controller->code($code); - die(); - } - - /** - * Returns HTTP POST information if POST request. - * Returns 405 Method Not Allowed if not. - * - * If $key is specified, returns only that key. otherwise - * returns HTTP 400 Bad Request; - */ - protected function post_data(?string $key = NULL): array|string - { - // only post requests allowed - if ($_SERVER['REQUEST_METHOD'] != 'POST') - $this->error(405); - - // return entire $_POST array - if (!$key) - return $_POST; - - if (!isset($_POST[$key])) - $this->error(400); - - return $_POST[$key]; - } - -} |