summaryrefslogtreecommitdiff
path: root/src/web/lib/hooks.php
blob: 266f2cbcb52b1f5fd34ecfe9463a6106cbe46a36 (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
37
<?php /* Copyright (c) 2024 Freya Murphy */

function XSSBOOK_begin_session(): void {

	$session_dir = '/var/run/crimson/xssbook';
	if (!is_dir($session_dir))
		mkdir($session_dir, 0770, FALSE);

	session_save_path($session_dir);
	session_start();
	setcookie(
		session_name(),
		session_id(),
		array(
			'expires' => time() + 60*60*24*7,
			'path' => '/',
			'domain' => NULL,
			'secure' => FALSE,
			'httponly' => FALSE,
			'samesite' => 'Lax'
		)
	);
}

function CRIMSON_init_hook(): void {
	//date_default_timezone_set('America/New_York');
	XSSBOOK_begin_session();
}

function CRIMSON_pre_route_hook(Router $router): void {
}

function CRIMSON_error_hook(?array $req, int $code): never {
	$error_controller = ROUTER->load_controller('error');
	$error_controller->code($code);
	CRIMSON_DIE();
}