servnest/common/top.php

107 lines
2.8 KiB
PHP
Raw Normal View History

2021-01-22 21:58:46 +01:00
<?php
2022-05-19 16:59:32 +02:00
require "init.php";
2021-05-22 14:07:25 +02:00
2022-04-23 01:57:43 +02:00
function antiCSRF() {
if (!isset($_SERVER['HTTP_SEC_FETCH_SITE']) OR $_SERVER['HTTP_SEC_FETCH_SITE'] !== "same-origin")
userError("Anti-CSRF verification failed ! (Wrong or unset Sec-Fetch-Site HTTP header)");
2022-04-23 01:57:43 +02:00
}
// Session initialisation (with cookies)
2021-08-05 02:16:58 +02:00
if (
2022-04-18 16:05:00 +02:00
isset($_COOKIE['niver']) // Resume session
OR
(SERVICE === "auth" // Create new session
2022-05-21 19:41:46 +02:00
AND (PAGE === "login" OR PAGE === "register")
2022-04-18 16:05:00 +02:00
AND isset($_POST['username']))
) {
session_start([
'name' => 'niver',
'sid_length' => 64,
'sid_bits_per_character' => 6,
'cookie_secure' => true,
'cookie_httponly' => true,
'cookie_samesite' => 'Strict',
'cookie_path' => CONF['common']['prefix'] . '/',
2022-04-18 16:05:00 +02: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 02:16:58 +02:00
}
2021-05-14 21:10:56 +02:00
// Less > CSS compilation
2021-01-22 21:58:46 +01:00
2022-04-23 01:57:43 +02: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',
));
require_once CONF['common']['root_path'] . "/lessphp/lib/Less/Autoloader.php";
2021-01-22 21:58:46 +01:00
Less_Autoloader::register();
// List files in less/
$relativeLessFiles = array_diff(scandir(CONF['common']['root_path'] . "/less"), array('..', '.'));
// Replace keys by values, and values by keys
2021-01-23 17:26:46 +01:00
$relativeLessFiles = array_flip($relativeLessFiles);
// Change relative paths into absolute paths
2021-01-23 17:26:46 +01:00
foreach ($relativeLessFiles as $relativeLessFile => $nothing) {
$absoluteLessFiles[CONF['common']['root_path'] . "/less/" . $relativeLessFile] = "";
2021-01-23 17:26:46 +01:00
}
2022-04-18 23:10:15 +02:00
// Generate one minified CSS file into public/css/ from sources in less/
2021-05-22 14:07:25 +02:00
$options = array(
'cache_dir' => CONF['common']['root_path'] . '/public/css/',
2022-04-18 16:05:00 +02:00
'compress' => true
2021-05-22 14:07:25 +02:00
);
$cssFileName = Less_Cache::Get($absoluteLessFiles, $options, THEME);
2021-01-22 21:58:46 +01:00
?>
<!DOCTYPE html>
2021-01-25 13:39:31 +01:00
<html lang="fr">
2022-04-18 16:05:00 +02:00
<head>
<meta charset="UTF-8">
<title><?php
if (isset($page['title']) AND $page['title'] != "Accueil")
2022-04-18 23:10:15 +02:00
echo $page['title'] . " < ";
if (isset($page['service']))
echo $page['service'] . " < ";
?>Niver</title>
<link type="text/css" rel="stylesheet" href="<?= CONF['common']['prefix'] ?>/css/<?= $cssFileName ?>">
2022-04-18 16:05:00 +02:00
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
2021-01-25 13:39:31 +01:00
2022-04-18 16:05:00 +02:00
<body>
<header>
2021-03-20 23:48:54 +01:00
2022-04-18 16:05:00 +02:00
<nav>
<a href="..">Niver</a><?php
2022-04-18 23:10:15 +02:00
if (isset($page['service']))
echo ' > <a href=".">' . $page['service'] . '</a>';
2022-04-18 16:05:00 +02:00
if (PAGE != "index")
echo ' > <a href="' . PAGE . '">' . $page['title'] . "</a>";
?>
</nav>
2022-04-18 16:05:00 +02:00
<?php if (isset($page['title'])) { ?>
<h1><?= $page['title'] ?></h1>
<?php } ?>
2021-03-20 23:48:54 +01:00
2022-04-18 16:05:00 +02:00
</header>
<main>