servnest/top.inc.php

99 lines
2.8 KiB
PHP
Raw Normal View History

2021-01-22 20:58:46 +00:00
<?php
2021-01-23 16:26:46 +00:00
if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
exit("This file is meant to be included.");
2021-01-22 20:58:46 +00:00
session_start([
'name' => 'niver',
2021-01-23 16:26:46 +00:00
'sid_length' => 64,
'cookie_secure' => true,
'cookie_httponly' => true,
'cookie_samesite' => 'Strict',
2021-02-16 18:20:19 +00:00
'cookie_lifetime' => 604800,
'gc_maxlifetime' => 604800,
2021-02-16 18:20:19 +00:00
'use_strict_mode' => true,
'use_cookies' => true,
'use_only_cookies' => true,
2021-01-22 20:58:46 +00:00
]);
2021-02-16 18:20:19 +00:00
define("USERNAME_REGEX", "^[a-z]{4,32}$");
define("PASSWORD_REGEX", "^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8,1024}|.{10,1024}$");
2021-01-23 16:26:46 +00:00
2021-02-16 18:20:19 +00:00
define("PREFIX", "/malaxe");
define("SERVICE", substr(dirname($_SERVER['PHP_SELF']), strlen(PREFIX) + 1));
define("ROOT_PATH", "/var/www/niver" . PREFIX);
define("PAGE", basename($_SERVER['PHP_SELF'], '.php'));
2021-01-23 16:26:46 +00:00
2021-02-16 18:20:19 +00:00
if (SERVICE != "auth" AND !isset($_SESSION['username'])) {
header('Location: ' . PREFIX . '/auth/login?redir=' . SERVICE . "/" . PAGE);
2021-01-22 20:58:46 +00:00
exit;
}
2021-02-16 18:20:19 +00:00
define("DB_PATH", ROOT_PATH . "/db/auth.db");
$dbPath = DB_PATH;
2021-01-22 20:58:46 +00:00
2021-01-25 12:39:31 +00:00
$theme = array(
'htColor' => "#FF0000",
'nicColor' => "#DA03E5",
2021-01-25 12:39:31 +00:00
'authColor' => "#00FF00",
'nsColor' => "#00FFFF",
'lightColor' => '#FFFFFF',
'darkColor' => '#2a2a2a',
2021-01-25 12:39:31 +00:00
);
2021-01-22 20:58:46 +00:00
2021-02-16 18:20:19 +00:00
switch (SERVICE) {
case "ht":
require "ht/ht.fn.inc.php";
2021-01-25 12:39:31 +00:00
$theme = array('mainColor' => $theme['htColor']) + $theme;
2021-01-22 20:58:46 +00:00
break;
2021-02-16 18:20:19 +00:00
case "nic":
2021-01-25 12:39:31 +00:00
$theme = array('mainColor' => $theme['nicColor']) + $theme;
2021-01-22 20:58:46 +00:00
break;
2021-02-16 18:20:19 +00:00
case "auth":
2021-01-25 12:39:31 +00:00
$theme = array('mainColor' => $theme['authColor']) + $theme;
2021-01-22 20:58:46 +00:00
break;
2021-02-16 18:20:19 +00:00
case "":
2021-01-25 12:39:31 +00:00
$theme = array('mainColor' => $theme['authColor']) + $theme;
2021-01-22 20:58:46 +00:00
break;
2021-02-16 18:20:19 +00:00
case "ns":
2021-01-25 12:39:31 +00:00
$theme = array('mainColor' => $theme['nsColor']) + $theme;
2021-01-22 20:58:46 +00:00
break;
}
require "pages.inc.php";
require "fn.inc.php";
2021-01-22 20:58:46 +00:00
require_once 'lessphp/lib/Less/Autoloader.php';
Less_Autoloader::register();
2021-02-16 18:20:19 +00:00
$relativeLessFiles = array_diff(scandir(ROOT_PATH . "/less"), array('..', '.'));
2021-01-23 16:26:46 +00:00
$relativeLessFiles = array_flip($relativeLessFiles);
foreach ($relativeLessFiles as $relativeLessFile => $nothing) {
2021-02-16 18:20:19 +00:00
$absoluteLessFiles[ROOT_PATH . "/less/" . $relativeLessFile] = "";
2021-01-23 16:26:46 +00:00
}
2021-02-16 18:20:19 +00:00
$options = array('cache_dir' => ROOT_PATH . '/css/'); //, 'compress' => true
2021-01-23 16:26:46 +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">
2021-01-22 20:58:46 +00:00
<head>
2021-01-25 12:39:31 +00:00
<title><?php if ($page['title'] != "Accueil") echo $page['title'] . " · "; ?><?php if (isset($page['service'])) { echo $page['service'] . " · "; } ?>Atope</title>
2021-02-16 18:20:19 +00:00
<link type="text/css" rel="stylesheet" href="<?= PREFIX ?>/css/<?= $cssFileName ?>">
2021-01-22 20:58:46 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
2021-01-25 12:39:31 +00:00
2021-01-22 20:58:46 +00:00
<body>
<header>
<?php if (!isset($page['service'])) {
$page['service'] = "Atope";
} ?>
<nav>
2021-02-16 18:20:19 +00:00
<a href="<?= PREFIX ?>">Niver</a> > <a href="./"><?= $page['service'] ?></a> > <?= $page['title'] ?>
2021-01-22 20:58:46 +00:00
</nav>
2021-01-22 20:58:46 +00:00
<h1><?= $page['title'] ?></h1>
</header>