summaryrefslogtreecommitdiff
path: root/src/web/_controller/error.php
blob: 55034ba640a758a029132ed0c2b2d8fa67085438 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
	}

}

?>