156 lines
No EOL
5 KiB
PHP
156 lines
No EOL
5 KiB
PHP
<?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/');
|
|
}
|
|
|
|
$events = getEvenements($bdd, $_SESSION['site']);
|
|
|
|
/* 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>
|
|
<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">
|
|
</head>
|
|
<script>
|
|
function addShortcut() {
|
|
|
|
const container = document.getElementById("shortcutsContainer");
|
|
|
|
const block = document.createElement("div");
|
|
|
|
block.className = "";
|
|
|
|
block.innerHTML = `
|
|
<form method="post">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-4">
|
|
<label>Nom</label>
|
|
<input type="text" name="nom" class="form-control" required>
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<label>URL</label>
|
|
<input type="text" name="url" class="form-control" required>
|
|
</div>
|
|
|
|
<div class="col-md-4">
|
|
<label>Image</label>
|
|
<input type="text" name="image" class="form-control" required>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary mt-2">
|
|
Créer le raccourci
|
|
</button>
|
|
|
|
</form>
|
|
`;
|
|
|
|
container.appendChild(block);
|
|
}
|
|
</script>
|
|
|
|
<body>
|
|
<h1>Gestion de l'intranet</h1>
|
|
<!-- navbar -->
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
<ul class="navbar-nav mr-auto">
|
|
<li class="nav-item">
|
|
<a href="index.php" class="nav-link">Évènements</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="modifyActuality.php" class="nav-link">Actualités</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="admin.php" class="nav-link">Administration</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
<!-- Partie création de raccourcis -->
|
|
<div class="">
|
|
|
|
<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; ?>
|
|
</div>
|
|
<button class="btn btn-success mb-3" onclick="addShortcut()">
|
|
Ajouter un raccourci
|
|
</button>
|
|
<div id="shortcutsContainer"></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>
|
|
</body>
|
|
|
|
</html>
|