2021-01-22 20:58:46 +00:00
|
|
|
<?php
|
|
|
|
|
2022-05-19 14:59:32 +00:00
|
|
|
require "init.php";
|
2021-05-22 12:07:25 +00:00
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
// Session initialisation (with cookies)
|
2021-08-05 00:16:58 +00:00
|
|
|
if (
|
2022-05-22 12:59:45 +00:00
|
|
|
isset($_COOKIE['niver-session-key']) // Resume session
|
2022-04-18 14:05:00 +00:00
|
|
|
OR
|
|
|
|
(SERVICE === "auth" // Create new session
|
2022-05-21 17:41:46 +00:00
|
|
|
AND (PAGE === "login" OR PAGE === "register")
|
2022-04-18 14:05:00 +00:00
|
|
|
AND isset($_POST['username']))
|
|
|
|
) {
|
|
|
|
session_start([
|
2022-05-22 12:59:45 +00:00
|
|
|
'name' => 'niver-session-key',
|
2022-04-18 14:05:00 +00:00
|
|
|
'sid_length' => 64,
|
|
|
|
'sid_bits_per_character' => 6,
|
|
|
|
'cookie_secure' => true,
|
|
|
|
'cookie_httponly' => true,
|
|
|
|
'cookie_samesite' => 'Strict',
|
2022-05-19 22:15:13 +00:00
|
|
|
'cookie_path' => CONF['common']['prefix'] . '/',
|
2022-04-18 14:05:00 +00:00
|
|
|
'cookie_lifetime' => 432000, // = 60*60*24*5 = 5 days
|
|
|
|
'gc_maxlifetime' => 10800,
|
|
|
|
'use_strict_mode' => true,
|
|
|
|
'use_cookies' => true,
|
|
|
|
'use_only_cookies' => true,
|
|
|
|
]);
|
2021-08-05 00:16:58 +00:00
|
|
|
}
|
2021-05-14 19:10:56 +00:00
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
// Less > CSS compilation
|
2021-01-22 20:58:46 +00:00
|
|
|
|
2022-04-22 23:57:43 +00:00
|
|
|
// Color scheme
|
|
|
|
define("THEME", array(
|
|
|
|
// Displayed on light theme
|
|
|
|
'darkRegColor' => "#D100D1",
|
|
|
|
'darkNsColor' => "#006DFF",
|
|
|
|
'darkHtColor' => "#008768",
|
|
|
|
'darkAuthColor' => "#EE0000",
|
|
|
|
|
|
|
|
// Displayed on dark theme
|
|
|
|
'lightRegColor' => "#FF50FF",
|
|
|
|
'lightNsColor' => "#00FFFF",
|
|
|
|
'lightHtColor' => "#FFFF00",
|
|
|
|
'lightAuthColor' => "#00FF00",
|
|
|
|
|
|
|
|
'lightColor' => '#FFFFFF',
|
|
|
|
'darkColor' => '#000000',
|
|
|
|
));
|
|
|
|
|
2022-05-19 22:15:13 +00:00
|
|
|
require_once CONF['common']['root_path'] . "/lessphp/lib/Less/Autoloader.php";
|
2021-01-22 20:58:46 +00:00
|
|
|
Less_Autoloader::register();
|
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
// List files in less/
|
2022-05-19 22:15:13 +00:00
|
|
|
$relativeLessFiles = array_diff(scandir(CONF['common']['root_path'] . "/less"), array('..', '.'));
|
2021-07-15 13:36:34 +00:00
|
|
|
// Replace keys by values, and values by keys
|
2021-01-23 16:26:46 +00:00
|
|
|
$relativeLessFiles = array_flip($relativeLessFiles);
|
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
// Change relative paths into absolute paths
|
2021-01-23 16:26:46 +00:00
|
|
|
foreach ($relativeLessFiles as $relativeLessFile => $nothing) {
|
2022-05-19 22:15:13 +00:00
|
|
|
$absoluteLessFiles[CONF['common']['root_path'] . "/less/" . $relativeLessFile] = "";
|
2021-01-23 16:26:46 +00:00
|
|
|
}
|
|
|
|
|
2022-04-18 21:10:15 +00:00
|
|
|
// Generate one minified CSS file into public/css/ from sources in less/
|
2021-05-22 12:07:25 +00:00
|
|
|
$options = array(
|
2022-05-19 22:15:13 +00:00
|
|
|
'cache_dir' => CONF['common']['root_path'] . '/public/css/',
|
2022-04-18 14:05:00 +00:00
|
|
|
'compress' => true
|
2021-05-22 12:07:25 +00:00
|
|
|
);
|
|
|
|
$cssFileName = Less_Cache::Get($absoluteLessFiles, $options, THEME);
|
2021-01-22 20:58:46 +00:00
|
|
|
|
|
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
2021-01-25 12:39:31 +00:00
|
|
|
<html lang="fr">
|
2022-04-18 14:05:00 +00:00
|
|
|
<head>
|
2022-05-22 15:47:00 +00:00
|
|
|
<meta charset="utf-8">
|
2022-04-18 14:05:00 +00:00
|
|
|
<title><?php
|
|
|
|
if (isset($page['title']) AND $page['title'] != "Accueil")
|
2022-04-18 21:10:15 +00:00
|
|
|
echo $page['title'] . " < ";
|
|
|
|
if (isset($page['service']))
|
|
|
|
echo $page['service'] . " < ";
|
|
|
|
?>Niver</title>
|
2022-05-19 22:15:13 +00:00
|
|
|
<link type="text/css" rel="stylesheet" href="<?= CONF['common']['prefix'] ?>/css/<?= $cssFileName ?>">
|
2022-04-18 14:05:00 +00:00
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header>
|
|
|
|
<nav>
|
2022-05-19 22:15:13 +00:00
|
|
|
<a href="..">Niver</a><?php
|
2022-05-22 15:47:00 +00:00
|
|
|
if (isset($page['service']))
|
|
|
|
echo ' > <a href=".">' . $page['service'] . '</a>';
|
|
|
|
if (PAGE != "index")
|
|
|
|
echo ' > <a href="' . PAGE . '">' . $page['title'] . "</a>";
|
|
|
|
?>
|
2021-03-20 22:48:54 +00:00
|
|
|
|
2022-05-22 15:47:00 +00:00
|
|
|
</nav>
|
2022-04-18 14:05:00 +00:00
|
|
|
</header>
|
|
|
|
<main>
|
2022-05-22 15:47:00 +00:00
|
|
|
|
2022-05-22 12:59:45 +00:00
|
|
|
<?php
|
2022-05-22 15:47:00 +00:00
|
|
|
|
|
|
|
if (isset($page['title']))
|
|
|
|
echo "<h1>" . $page['title'] . "</h1>";
|
|
|
|
|
|
|
|
// Protect against cross-site request forgery if a POST request is received
|
|
|
|
if (empty($_POST) === false AND (isset($_SERVER['HTTP_SEC_FETCH_SITE']) !== true OR $_SERVER['HTTP_SEC_FETCH_SITE'] !== "same-origin"))
|
|
|
|
userError("Anti-CSRF verification failed ! (Wrong or unset <code>Sec-Fetch-Site</code> HTTP header)");
|
|
|
|
|
2022-05-22 12:59:45 +00:00
|
|
|
function closeHTML() {
|
|
|
|
?>
|
|
|
|
</main>
|
|
|
|
<footer>
|
|
|
|
<small>
|
|
|
|
<?php if (isset($_SESSION['username'])) {
|
|
|
|
echo "Connecté·e en tant que " . $_SESSION['username'] . "<br><a class='authButton' href='" . CONF['common']['prefix'] . "/auth/logout'>Se déconnecter</a>";
|
|
|
|
} else { ?>
|
|
|
|
Vous n'êtes pas connecté·e à un compte Niver
|
|
|
|
<br><a class="authButton" href="<?= CONF['common']['prefix'] ?>/auth/login?redir=<?php if (SERVICE !== "") echo SERVICE . "/"; ?><?= PAGE ?>">Se connecter</a>
|
|
|
|
<?php } ?>
|
|
|
|
</small>
|
|
|
|
</footer>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
|
|
|
|
<?php } ?>
|