Pőcze Bence
4fe463fcc5
All checks were successful
soko-web/pipeline/pr-master This commit looks good
57 lines
1.6 KiB
Smarty
57 lines
1.6 KiB
Smarty
<?php
|
|
|
|
require 'main.php';
|
|
|
|
if (!empty($_ENV['DEV'])) {
|
|
error_reporting(E_ALL);
|
|
|
|
ini_set('display_errors', '1');
|
|
} else {
|
|
ini_set('display_errors', '0');
|
|
}
|
|
|
|
Container::$routeCollection = new SokoWeb\Routing\RouteCollection();
|
|
Container::$routeCollection->get('index', '', [{app}\Controller\HomeController::class, 'getIndex']);
|
|
|
|
if (isset($_COOKIE['COOKIES_CONSENT'])) {
|
|
Container::$sessionHandler = new SokoWeb\Session\DatabaseSessionHandler(Container::$dbConnection);
|
|
|
|
session_set_save_handler(Container::$sessionHandler, true);
|
|
session_start([
|
|
'gc_probability' => 0, // old sessions are deleted by MaintainDatabaseCommand
|
|
'cookie_lifetime' => 604800,
|
|
'cookie_path' => '/',
|
|
'cookie_httponly' => true,
|
|
'cookie_samesite' => 'Lax'
|
|
]);
|
|
|
|
if (isset($_COOKIE[session_name()])) {
|
|
// extend session cookie lifetime is cookie already exists
|
|
setcookie(session_name(), session_id(), [
|
|
'expires' => time() + 604800,
|
|
'path' => '/',
|
|
'httponly' => true,
|
|
'samesite' => 'Lax'
|
|
]);
|
|
}
|
|
|
|
// this is needed to handle old type of session IDs
|
|
if (!Container::$sessionHandler->validateId(session_id())) {
|
|
session_regenerate_id(true);
|
|
}
|
|
} else {
|
|
$_SESSION = [];
|
|
}
|
|
|
|
Container::$request = new MapGuesser\Request\Request(
|
|
$_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'],
|
|
$_GET,
|
|
$_POST,
|
|
$_SESSION,
|
|
new MapGuesser\Repository\UserRepository()
|
|
);
|
|
|
|
if (!Container::$request->session()->has('anti_csrf_token')) {
|
|
Container::$request->session()->set('anti_csrf_token', bin2hex(random_bytes(16)));
|
|
}
|