2026-03-04 13:26:06 +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"]);
|
|
|
|
|
|
|
|
|
|
session_start();
|
|
|
|
|
|
|
|
|
|
if (!isset($_SESSION['connected']) || $_SESSION['connected'] == false) {
|
|
|
|
|
header('location: login.php?redirect_to=./admin/');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$minPoids = 45;
|
|
|
|
|
if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
|
|
|
|
|
header('location: ../index.php');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$eventId = $_GET['id'] ?? null;
|
|
|
|
|
|
|
|
|
|
if (!$eventId) {
|
|
|
|
|
die("ID évènement manquant.");
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 16:34:46 +00:00
|
|
|
$uploadDir = "../Photos/INTRANET/gallerie/";
|
2026-03-04 13:26:06 +00:00
|
|
|
|
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
|
|
|
|
|
|
if (!empty($_FILES['images']['name'][0])) {
|
|
|
|
|
|
|
|
|
|
$allowedTypes = ['image/jpeg', 'image/png', 'image/gif'];
|
|
|
|
|
|
|
|
|
|
foreach ($_FILES['images']['tmp_name'] as $key => $tmpName) {
|
|
|
|
|
|
2026-03-13 16:09:52 +00:00
|
|
|
if ($_FILES['images']['error'][$key] !== UPLOAD_ERR_OK) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!is_uploaded_file($tmpName)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-04 13:26:06 +00:00
|
|
|
$fileSize = $_FILES['images']['size'][$key];
|
|
|
|
|
|
|
|
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
|
|
|
|
$mime = finfo_file($finfo, $tmpName);
|
|
|
|
|
finfo_close($finfo);
|
|
|
|
|
|
|
|
|
|
if (in_array($mime, $allowedTypes) && $fileSize <= 5 * 1024 * 1024) {
|
|
|
|
|
|
|
|
|
|
$extension = pathinfo($_FILES['images']['name'][$key], PATHINFO_EXTENSION);
|
|
|
|
|
|
|
|
|
|
$newFileName = "gallery_" . $eventId . "_" . time() . "_" . $key . "." . $extension;
|
|
|
|
|
|
|
|
|
|
if (move_uploaded_file($tmpName, $uploadDir . $newFileName)) {
|
|
|
|
|
|
|
|
|
|
mysqli_query(
|
|
|
|
|
$bdd,
|
|
|
|
|
"INSERT INTO gallerie (event_id, chemin, texte)
|
|
|
|
|
VALUES ('$eventId','$newFileName','')"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header("Location: ?id=" . $eventId);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['delete'])) {
|
|
|
|
|
|
|
|
|
|
$file = basename($_GET['delete']);
|
|
|
|
|
|
|
|
|
|
mysqli_query(
|
|
|
|
|
$bdd,
|
|
|
|
|
"DELETE FROM gallerie
|
|
|
|
|
WHERE event_id='$eventId'
|
|
|
|
|
AND chemin='$file'"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (file_exists($uploadDir . $file)) {
|
|
|
|
|
unlink($uploadDir . $file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
header("Location: ?id=" . $eventId);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$result = mysqli_query(
|
|
|
|
|
$bdd,
|
|
|
|
|
"SELECT chemin FROM gallerie WHERE event_id='$eventId'"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$images = [];
|
|
|
|
|
|
|
|
|
|
while ($row = mysqli_fetch_assoc($result)) {
|
|
|
|
|
$images[] = $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
|
|
<html lang="fr">
|
2026-03-13 16:09:52 +00:00
|
|
|
|
2026-03-04 13:26:06 +00:00
|
|
|
<head>
|
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
|
<title>Galerie évènement</title>
|
|
|
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
|
<style>
|
|
|
|
|
.gallery-img {
|
|
|
|
|
height: 180px;
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
<body class="container py-4">
|
|
|
|
|
<h1>Gestion de l'intranet</h1>
|
|
|
|
|
|
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-4">
|
|
|
|
|
<div class="collapse navbar-collapse">
|
|
|
|
|
<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="#" class="nav-link">Actualités</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="nav-item">
|
2026-03-06 16:23:04 +00:00
|
|
|
<a href="admin.php" class="nav-link">Administration</a>
|
2026-03-04 13:26:06 +00:00
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
<ul class="nav nav-tabs mb-4">
|
|
|
|
|
<li class="nav-item">
|
|
|
|
|
<a class="nav-link"
|
|
|
|
|
href="modifyEvent.php?id=<?= $eventId ?>">
|
|
|
|
|
Général
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
<li class="nav-item">
|
|
|
|
|
<a class="nav-link active">
|
|
|
|
|
Galerie
|
|
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
<div class="card p-4 mb-4">
|
|
|
|
|
<form method="post" enctype="multipart/form-data">
|
|
|
|
|
<label class="form-label">Ajouter des images</label>
|
|
|
|
|
<input type="file"
|
|
|
|
|
name="images[]"
|
|
|
|
|
class="form-control mb-3"
|
|
|
|
|
multiple
|
|
|
|
|
accept="image/*">
|
|
|
|
|
|
|
|
|
|
<button class="btn btn-primary">
|
|
|
|
|
Uploader
|
|
|
|
|
</button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
|
<?php foreach ($images as $img): ?>
|
|
|
|
|
<div class="col-md-3 mb-4">
|
|
|
|
|
<div class="card">
|
2026-03-04 16:34:46 +00:00
|
|
|
<img src="../Photos/INTRANET/gallerie/<?= htmlspecialchars($img['chemin']) ?>"
|
2026-03-04 13:26:06 +00:00
|
|
|
class="card-img-top gallery-img">
|
|
|
|
|
|
|
|
|
|
<div class="card-body text-center">
|
|
|
|
|
<a href="?id=<?= $eventId ?>&delete=<?= urlencode($img['chemin']) ?>"
|
|
|
|
|
class="btn btn-danger btn-sm"
|
|
|
|
|
onclick="return confirm('Supprimer cette image ?')">
|
|
|
|
|
|
|
|
|
|
Supprimer
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<?php endforeach; ?>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
|
|
|
|
</body>
|
2026-03-13 16:09:52 +00:00
|
|
|
|
2026-03-04 13:26:06 +00:00
|
|
|
</html>
|