summaryrefslogtreecommitdiff
path: root/src/web/_controller/error.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/_controller/error.php')
-rw-r--r--src/web/_controller/error.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/web/_controller/error.php b/src/web/_controller/error.php
new file mode 100644
index 0000000..55034ba
--- /dev/null
+++ b/src/web/_controller/error.php
@@ -0,0 +1,36 @@
+<?php /* Copyright (c) 2024 Freya Murphy */
+class Error_controller extends XSS_Controller {
+
+ private $error_model;
+
+ function __construct() {
+ parent::__construct();
+ $this->error_model = $this->load_model('error');
+ }
+
+ public function index(): void {
+ $this->code(404);
+ }
+
+ public function code($code): void {
+ parent::index();
+
+ $code = intval($code);
+ if ($code == 404 && rand(0, 100) > 95)
+ $code = 451;
+ if (!is_valid_status_code($code))
+ $code = 404;
+ $msg = status_code_msg($code);
+
+ $data = $this->error_model->get_data();
+ $data['title'] = $code;
+ $data['msg'] = $msg;
+
+ $this->view('header', $data);
+ $this->view('error/main', $data);
+ $this->view('footer', $data);
+ }
+
+}
+
+?>