Everything previously under www/src now are under www/ Moved style.CSS under www/ressources, to allow blocking http requests to www/lib completly Moved <head> and <header> generation under lib/PHP/output/sections.php to reduce redundancy within files. Also implemented a system to allow them to generate relatif paht for href to ressources depending on their deepness within www/ hierarchy.
42 lines
1 KiB
PHP
42 lines
1 KiB
PHP
<?php
|
|
|
|
require_once 'config.php';
|
|
|
|
session_name($sessionconfig_name);
|
|
session_set_cookie_params([
|
|
'lifetime' => $sessioncookie_lifetime,
|
|
'path' => $sessioncookie_path,
|
|
'secure' => $sessioncookie_secure,
|
|
'httponly' => $sessioncookie_httponly,
|
|
'samesite' => $sessioncookie_samesite
|
|
]);
|
|
session_start();
|
|
|
|
// If you consider calling this, ask yourself why.
|
|
function regenerate_current_session(bool $force = false): void
|
|
{
|
|
if($force || $_SESSION["REGENERATETIME"] < time())
|
|
{
|
|
$_SESSION["EXPIRES"] = time() + 2*60;
|
|
session_regenerate_id();
|
|
$_SESSION["REGENERATETIME"] = time() + ACCOUNT_REGENERATE_TIMER;
|
|
$_SESSION['EXPIRES'] = time() + ACCOUNT_EXPIRE_TIMER;
|
|
}
|
|
|
|
}
|
|
|
|
// Automaticly called by session/continue.php
|
|
function update_session_validity(): bool
|
|
{
|
|
if(!isset($_SESSION['loggedin'])) { return false; }
|
|
if(isset($_SESSION['EXPIRES']) && $_SESSION["EXPIRES"] < time())
|
|
{
|
|
$_SESSION["loggedin"] = false;
|
|
}
|
|
|
|
if($_SESSION["loggedin"] && $_SESSION["REGENERATETIME"] < time())
|
|
{
|
|
regenerate_current_session(true);
|
|
}
|
|
return $_SESSION["loggedin"];
|
|
}
|