2026-03-06 16:23:04 +00:00
|
|
|
<?php
|
|
|
|
|
include("../Assets/functions.php");
|
|
|
|
|
$config = json_decode(file_get_contents("../Assets/config.json"), true);
|
|
|
|
|
$bdd = connectBDD("localhost", $config["BDD_USER"], $config["BDD_PASSWD"], $config["BDD_NAME"]);
|
|
|
|
|
|
|
|
|
|
/* Gestion de la connexion */
|
|
|
|
|
session_start();
|
|
|
|
|
if (!isset($_SESSION['connected']) || $_SESSION['connected'] == false) {
|
|
|
|
|
header('location: ../login.php?redirect_to=./admin/');
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
$permission = $_SESSION["permission"];
|
|
|
|
|
if ($permission == "admin") {
|
|
|
|
|
$evenements = getEvenements($bdd, $_SESSION['site'], true);
|
|
|
|
|
} else {
|
|
|
|
|
$evenements = getEvenements($bdd, $_SESSION['site']);
|
|
|
|
|
}
|
2026-03-06 16:23:04 +00:00
|
|
|
|
|
|
|
|
/* Récupération des infos */
|
|
|
|
|
$permissions = $_SESSION['permission'];
|
|
|
|
|
$site = $_SESSION['site'];
|
|
|
|
|
|
|
|
|
|
/* Gestion de l'accès à la page */
|
|
|
|
|
$minPoids = 99;
|
|
|
|
|
if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
|
|
|
|
die("Vous n'avez pas l'autorisation");
|
|
|
|
|
header('location: ./index.php');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$uploadDir = "../Photos/INTRANET/";
|
|
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
|
|
|
|
|
|
if (!empty($_POST['nom']) && !empty($_POST['url']) && !empty($_POST['image'])) {
|
|
|
|
|
|
|
|
|
|
createShortcut(
|
|
|
|
|
$bdd,
|
|
|
|
|
$_POST['nom'],
|
|
|
|
|
$_POST['image'],
|
|
|
|
|
$_POST['url']
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
header("Location: " . $_SERVER['PHP_SELF']);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="fr">
|
|
|
|
|
|
|
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>Gestion Intranet</title>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
|
<link rel="stylesheet" href="../styles-scripts/index.admin.css">
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
</head>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<script>
|
|
|
|
|
function addShortcut() {
|
|
|
|
|
|
|
|
|
|
const container = document.getElementById("shortcutsContainer");
|
|
|
|
|
|
|
|
|
|
const block = document.createElement("div");
|
|
|
|
|
|
|
|
|
|
block.innerHTML = `
|
2026-03-11 11:01:32 +00:00
|
|
|
<form method="post">
|
2026-03-06 16:23:04 +00:00
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
<div class="row">
|
2026-03-06 16:23:04 +00:00
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
<div class="col-md-4">
|
|
|
|
|
<label>Nom</label>
|
|
|
|
|
<input type="text" name="nom" class="form-control" required>
|
|
|
|
|
</div>
|
2026-03-06 16:23:04 +00:00
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
<div class="col-md-4">
|
|
|
|
|
<label>URL</label>
|
|
|
|
|
<input type="text" name="url" class="form-control" required>
|
|
|
|
|
</div>
|
2026-03-06 16:23:04 +00:00
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
<div class="col-md-4">
|
|
|
|
|
<label>Image</label>
|
|
|
|
|
<input type="text" name="image" class="form-control" required>
|
2026-03-06 16:23:04 +00:00
|
|
|
</div>
|
|
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<button type="submit" class="btn btn-primary mt-2">
|
|
|
|
|
Créer le raccourci
|
|
|
|
|
</button>
|
2026-03-06 16:23:04 +00:00
|
|
|
|
2026-03-11 11:01:32 +00:00
|
|
|
</form>
|
2026-03-06 16:23:04 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
container.appendChild(block);
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<body>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<h1>Gestion de l'intranet</h1>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<!-- navbar -->
|
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
2026-03-11 11:01:32 +00:00
|
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
|
2026-03-06 16:23:04 +00:00
|
|
|
<span class="navbar-toggler-icon"></span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
|
|
|
<ul class="navbar-nav mr-auto">
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<li class="nav-item">
|
2026-03-10 16:38:47 +00:00
|
|
|
<a href="index.php" class="nav-link">Évènements</a>
|
2026-03-06 16:23:04 +00:00
|
|
|
</li>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<li class="nav-item">
|
|
|
|
|
<a href="modifyActuality.php" class="nav-link">Actualités</a>
|
|
|
|
|
</li>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
<li class="nav-item">
|
|
|
|
|
<a href="admin.php" class="nav-link">Administration</a>
|
|
|
|
|
</li>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
|
|
|
|
<div class="container mt-4">
|
|
|
|
|
|
|
|
|
|
<!-- Onglets -->
|
|
|
|
|
<ul class="nav nav-tabs" id="adminTabs" role="tablist">
|
|
|
|
|
|
|
|
|
|
<li class="nav-item" role="presentation">
|
|
|
|
|
<button class="nav-link active"
|
|
|
|
|
id="raccourcis-tab"
|
|
|
|
|
data-bs-toggle="tab"
|
|
|
|
|
data-bs-target="#raccourcis"
|
|
|
|
|
type="button"
|
|
|
|
|
role="tab">
|
|
|
|
|
Raccourcis
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
<li class="nav-item" role="presentation">
|
|
|
|
|
<button class="nav-link"
|
|
|
|
|
id="users-tab"
|
|
|
|
|
data-bs-toggle="tab"
|
|
|
|
|
data-bs-target="#users"
|
|
|
|
|
type="button"
|
|
|
|
|
role="tab">
|
|
|
|
|
Utilisateurs
|
|
|
|
|
</button>
|
|
|
|
|
</li>
|
|
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div class="tab-content mt-4">
|
|
|
|
|
|
|
|
|
|
<!-- Onglet raccourcis -->
|
|
|
|
|
<div class="tab-pane fade show active" id="raccourcis" role="tabpanel">
|
|
|
|
|
|
|
|
|
|
<h3>Création de raccourcis</h3>
|
|
|
|
|
|
|
|
|
|
<div class="mb-4">
|
|
|
|
|
|
|
|
|
|
<?php $shortcuts = getRaccourcis($bdd); ?>
|
|
|
|
|
|
|
|
|
|
<?php foreach ($shortcuts as $shortcut): ?>
|
|
|
|
|
|
|
|
|
|
<div class="card p-3 mb-2 d-flex flex-row align-items-center shortcut"
|
|
|
|
|
data-id="<?= $shortcut['id'] ?>">
|
|
|
|
|
|
|
|
|
|
<img class="editable-image"
|
|
|
|
|
src="<?= (str_starts_with($shortcut['image'], 'http') || str_starts_with($shortcut['image'], 'data')) ? htmlspecialchars($shortcut['image']) : "." . htmlspecialchars($shortcut['image']) ?>"
|
|
|
|
|
style="width:40px;height:40px;margin-right:10px;cursor:pointer;">
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<strong class="editable" data-field="nom">
|
|
|
|
|
<?= htmlspecialchars($shortcut['nom']) ?>
|
|
|
|
|
</strong>
|
|
|
|
|
<br>
|
|
|
|
|
<small class="editable" data-field="url">
|
|
|
|
|
<?= htmlspecialchars($shortcut['url']) ?>
|
|
|
|
|
</small>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
</div>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
|
|
|
|
<button class="btn btn-success mb-3" onclick="addShortcut()">
|
|
|
|
|
Ajouter un raccourci
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<div id="shortcutsContainer"></div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Onglet utilisateurs -->
|
|
|
|
|
<div class="tab-pane fade" id="users" role="tabpanel">
|
|
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
$permissions = getAllPermissions($bdd);
|
|
|
|
|
$roles = [];
|
|
|
|
|
foreach ($permissions as $permission) {
|
|
|
|
|
array_push($roles, $permission["nom"]);
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
<h3>Modification d'un utilisateur</h3>
|
|
|
|
|
|
|
|
|
|
<form action="./gestionUser.php" method="post">
|
|
|
|
|
<label for="username">Nom d'utilisateur à créer</label>
|
|
|
|
|
<input type="text" name="username" id="username" required><br>
|
|
|
|
|
<label for="password">Mot de passe</label>
|
|
|
|
|
<input type="password" name="password" id="password"><br>
|
|
|
|
|
<label for="site">Id du site</label>
|
|
|
|
|
<input type="number" id="site" name="site"><br>
|
|
|
|
|
<label for="permissions">Permission de l'utilisateur</label>
|
|
|
|
|
<select name="permissions" id="permissions">
|
|
|
|
|
<option value="void">Sélectionner</option>
|
|
|
|
|
<?php foreach ($roles as $role) { ?>
|
|
|
|
|
<option value="<?php echo $role; ?>">
|
|
|
|
|
<?php echo $role; ?>
|
|
|
|
|
</option>
|
|
|
|
|
<?php } ?>
|
|
|
|
|
</select><br>
|
|
|
|
|
<button type="submit">Envoyer</button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script src="../styles-scripts/editableCards.js"></script>
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
2026-03-11 11:01:32 +00:00
|
|
|
|
2026-03-06 16:23:04 +00:00
|
|
|
</body>
|
|
|
|
|
|
|
|
|
|
</html>
|