-
Notifications
You must be signed in to change notification settings - Fork 71
/
index.php
35 lines (31 loc) · 922 Bytes
/
index.php
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
<?php
require_once(__DIR__ . '/descartes/load.php');
############
# SESSIONS #
############
session_name(SESSION_NAME);
session_start();
//Create csrf token if it didn't exist
if (!isset($_SESSION['csrf']))
{
$_SESSION['csrf'] = str_shuffle(uniqid().uniqid());
}
//Save previous $_POST for re-populate forms on validation errors
$_SESSION['previous_http_post'] = $_SESSION['http_post'] ?? [];
$_SESSION['http_post'] = $_POST;
//Routing current query
try
{
descartes\Router::route(ROUTES, $_SERVER['REQUEST_URI']);
}
catch (\descartes\exceptions\DescartesException404 $e)
{
$controller = new \controllers\internals\HttpError();
$controller->_404();
}
catch (\Throwable $e)
{
error_log($e);
$controller = new \controllers\internals\HttpError();
$controller->unknown();
}