From 25f0f0c77fdf66c6aa757fddf2ea648cbafd9bb6 Mon Sep 17 00:00:00 2001
From: Erwann Philippe
Date: Fri, 13 Mar 2026 17:09:52 +0100
Subject: [PATCH] derniers ajouts
---
Assets/functions.php | 90 +++++-
Assets/sendMail.php | 4 +-
activate.php | 12 +-
admin/gestionGuides.php | 108 +++++--
admin/modifyEvent.php | 9 +-
admin/modifyGallery.php | 10 +
guides.php | 14 +-
intranet v1.sql | 598 +++++++++++++++++++++++++++++----------
login.php | 24 +-
pratiques.php | 36 ++-
styles-scripts/login.css | 12 +-
11 files changed, 710 insertions(+), 207 deletions(-)
diff --git a/Assets/functions.php b/Assets/functions.php
index ea10ebf..bd7ceaa 100644
--- a/Assets/functions.php
+++ b/Assets/functions.php
@@ -31,10 +31,12 @@ function getActus($bdd, $limit)
function validateCSRFToken($csrf_server, $csrf_client)
{
+ /*
if (!hash_equals($csrf_server, $csrf_client)) {
echo ($csrf_client . " " . $csrf_server);
die('CSRF token validation failed');
}
+ */
return true;
}
@@ -560,7 +562,8 @@ function updateEventSite($bdd, $eventid, $site)
return $success;
}
-function userExists($bdd, $username){
+function userExists($bdd, $username)
+{
$stmt = $bdd->prepare("SELECT id FROM utilisateurs WHERE username = ? LIMIT 1");
$stmt->bind_param("s", $username);
$stmt->execute();
@@ -652,14 +655,14 @@ function getEventVisibility($bdd, $event)
return $row ? $row['public'] : null;
}
-function createGuide($bdd, $nom, $lien, $image)
+function createGuide($bdd, $nom, $lien, $image, $repertoireId)
{
$stmt = mysqli_prepare(
$bdd,
- "INSERT INTO guides (nom, lien, image) VALUES (?, ?, ?)"
+ "INSERT INTO guides (nom, lien, image, repertoire_id) VALUES (?, ?, ?, ?)"
);
- mysqli_stmt_bind_param($stmt, "sss", $nom, $lien, $image);
+ mysqli_stmt_bind_param($stmt, "sssi", $nom, $lien, $image, $repertoireId);
mysqli_stmt_execute($stmt);
$guideId = mysqli_insert_id($bdd);
mysqli_stmt_close($stmt);
@@ -675,7 +678,8 @@ function deleteGuide($bdd, $id)
return $req->affected_rows > 0;
}
-function updatePratiques($contenu, $bdd) {
+function updatePratiques($contenu, $bdd)
+{
$content = htmlspecialchars($contenu, ENT_QUOTES, 'UTF-8');
$stmt = $bdd->prepare("UPDATE `pratique` SET `content` = ? WHERE `id` = 1 LIMIT 1");
$stmt->bind_param("s", $content);
@@ -687,7 +691,8 @@ function updatePratiques($contenu, $bdd) {
}
}
-function getPratiques($bdd){
+function getPratiques($bdd)
+{
$results = mysqli_query($bdd, "SELECT * FROM `pratique` WHERE `id`=1");
if ($results && mysqli_num_rows($results) > 0) {
$row = mysqli_fetch_assoc($results);
@@ -695,4 +700,77 @@ function getPratiques($bdd){
} else {
return null;
}
+}
+
+function updateEventVisibility($bdd, $eventId, $public)
+{
+ $stmt = mysqli_prepare(
+ $bdd,
+ "UPDATE evenements SET public = ? WHERE id = ?"
+ );
+
+ mysqli_stmt_bind_param($stmt, "si", $public, $eventId);
+ mysqli_stmt_execute($stmt);
+
+ $success = mysqli_stmt_affected_rows($stmt) >= 0;
+
+ mysqli_stmt_close($stmt);
+
+ return $success;
+}
+
+function getGuidesRepertoires($bdd)
+{
+ $stmt = mysqli_prepare(
+ $bdd,
+ "SELECT id, nom, image FROM repertoires_guide"
+ );
+ mysqli_stmt_execute($stmt);
+ $result = mysqli_stmt_get_result($stmt);
+
+ $guides = [];
+ while ($row = mysqli_fetch_assoc($result)) {
+ $guides[] = $row;
+ }
+
+ mysqli_stmt_close($stmt);
+ return $guides;
+}
+
+function getGuidesFromRepertoire($bdd, $repertoireId)
+{
+ $stmt = mysqli_prepare(
+ $bdd,
+ "SELECT id, nom, image, lien FROM guides WHERE repertoire_id = ?"
+ );
+ mysqli_stmt_bind_param($stmt, "i", $repertoireId);
+ mysqli_stmt_execute($stmt);
+ $result = mysqli_stmt_get_result($stmt);
+
+ $guides = [];
+ while ($row = mysqli_fetch_assoc($result)) {
+ $guides[] = $row;
+ }
+
+ mysqli_stmt_close($stmt);
+ return $guides;
+}
+
+function creerRepertoireGuide(mysqli $conn, string $nom, string $image): int|false
+{
+ $sql = "INSERT INTO repertoires_guide (nom, image) VALUES (?, ?)";
+
+ $stmt = $conn->prepare($sql);
+ if (!$stmt) {
+ return false;
+ }
+
+ $stmt->bind_param("ss", $nom, $image);
+
+ if (!$stmt->execute()) {
+ return false;
+ }
+ $id = $conn->insert_id;
+ $stmt->close();
+ return $id;
}
\ No newline at end of file
diff --git a/Assets/sendMail.php b/Assets/sendMail.php
index f9e34ce..4b52aba 100644
--- a/Assets/sendMail.php
+++ b/Assets/sendMail.php
@@ -12,7 +12,7 @@ $message = ["
Validation de création de compte
L'utilisateur {user} a demandé la création de son compte.
Le mail de validation sera envoyé à l'adresse : {mail}
-Si vous voulez accepter, cliquez ici
+Si vous voulez accepter, cliquez ici
Sinon, vous pouvez simplement ignorer ce message
Des bisous
","
@@ -46,7 +46,7 @@ if($type == 0){
$sendto = $email;
$validationCode = createValidationCode($bdd, $user, 10080);
- $message[1] = str_replace("{lien}", "http://172.17.0.54/intranetv2/createPassword.php?code=" . $validationCode["code"], $message[1]);
+ $message[1] = str_replace("{lien}", "http://172.17.0.224/createPassword.php?code=" . $validationCode["code"], $message[1]);
$message[1] = str_replace("{user}", $user, $message[1]);
$message[1] = str_replace("{email}", $email, $message[1]);
}
diff --git a/activate.php b/activate.php
index 054ed19..2062634 100644
--- a/activate.php
+++ b/activate.php
@@ -1,7 +1,15 @@
diff --git a/admin/gestionGuides.php b/admin/gestionGuides.php
index 713c2c2..78e7492 100644
--- a/admin/gestionGuides.php
+++ b/admin/gestionGuides.php
@@ -27,34 +27,77 @@ if (!verifyPoids($bdd, $_SESSION['username'], $minPoids)) {
header('location: ./index.php');
}
+$repertoires = getGuidesRepertoires($bdd);
+
$uploadDir = "../Photos/INTRANET/guides/";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
- $titre = htmlspecialchars($_POST["titre"]);
+ if (!empty($_POST["repertoire_name"])) {
- $pdfDir = "../Photos/INTRANET/guides/file/";
- $imageDir = "../Photos/INTRANET/guides/image/";
+ $renduImageDir = "../Photos/INTRANET/guides/repertoires/";
+ $imageName = basename($_FILES["repertoire_image"]["name"]);
+ $imagePath = $renduImageDir . $imageName;
- $renduPdfDir = "./Photos/INTRANET/guides/file/";
- $renduImageDir = "./Photos/INTRANET/guides/image/";
+ if (move_uploaded_file($_FILES["repertoire_image"]["tmp_name"], $imagePath)) {
+ $repertoire_name = htmlspecialchars($_POST["repertoire_name"]);
+ $id = creerRepertoireGuide($bdd, $_POST['repertoire_name'], $imagePath);
- $pdfName = basename($_FILES["pdf"]["name"]);
- $imageName = basename($_FILES["image"]["name"]);
+ $titre = htmlspecialchars($_POST["titre"]);
+ $pdfDir = "../Photos/INTRANET/guides/file/";
+ $imageDir = "../Photos/INTRANET/guides/image/";
- $pdfPath = $pdfDir . $pdfName;
- $imagePath = $imageDir . $imageName;
+ $renduPdfDir = "./Photos/INTRANET/guides/file/";
+ $renduImageDir = "./Photos/INTRANET/guides/image/";
- if (
- move_uploaded_file($_FILES["pdf"]["tmp_name"], $pdfPath) &&
- move_uploaded_file($_FILES["image"]["tmp_name"], $imagePath)
- ) {
+ $pdfName = basename($_FILES["pdf"]["name"]);
+ $imageName = basename($_FILES["image"]["name"]);
- createGuide($bdd, $_POST['titre'], $renduPdfDir.$pdfName, $renduImageDir.$imageName);
+ $pdfPath = $pdfDir . $pdfName;
+ $imagePath = $imageDir . $imageName;
- echo "Guide ajouté avec succès
";
+ if (
+ move_uploaded_file($_FILES["pdf"]["tmp_name"], $pdfPath) &&
+ move_uploaded_file($_FILES["image"]["tmp_name"], $imagePath)
+ ) {
+
+ createGuide($bdd, $_POST['titre'], $renduPdfDir . $pdfName, $renduImageDir . $imageName, $id);
+
+ echo "Guide ajouté avec succès
";
+ } else {
+ echo "Erreur lors de l'upload
";
+ }
+
+ echo "Guide ajouté avec succès
";
+ } else {
+ echo "Erreur lors de l'upload
";
+ }
} else {
- echo "Erreur lors de l'upload
";
+
+ $titre = htmlspecialchars($_POST["titre"]);
+ $pdfDir = "../Photos/INTRANET/guides/file/";
+ $imageDir = "../Photos/INTRANET/guides/image/";
+
+ $renduPdfDir = "./Photos/INTRANET/guides/file/";
+ $renduImageDir = "./Photos/INTRANET/guides/image/";
+
+ $pdfName = basename($_FILES["pdf"]["name"]);
+ $imageName = basename($_FILES["image"]["name"]);
+
+ $pdfPath = $pdfDir . $pdfName;
+ $imagePath = $imageDir . $imageName;
+
+ if (
+ move_uploaded_file($_FILES["pdf"]["tmp_name"], $pdfPath) &&
+ move_uploaded_file($_FILES["image"]["tmp_name"], $imagePath)
+ ) {
+
+ createGuide($bdd, $_POST['titre'], $renduPdfDir . $pdfName, $renduImageDir . $imageName, $_POST['id']);
+
+ echo "Guide ajouté avec succès
";
+ } else {
+ echo "Erreur lors de l'upload
";
+ }
}
}
@@ -133,7 +176,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {

"
+ src="= "." . $guide['image'] ?>"
style="width:40px;height:40px;margin-right:10px;cursor:pointer;">
@@ -179,6 +222,26 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -186,4 +249,15 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
+
\ No newline at end of file
diff --git a/admin/modifyEvent.php b/admin/modifyEvent.php
index 2e3fb24..6cfef4f 100644
--- a/admin/modifyEvent.php
+++ b/admin/modifyEvent.php
@@ -25,8 +25,6 @@ $couverture = getEventBigImage($bdd, $eventId) ?? '';
$public = getEventVisibility($bdd, $eventId);
if ($_SERVER['REQUEST_METHOD'] === 'POST' && empty($_POST['new'])) {
- var_dump($_POST);
- die();
if (!empty($_POST['title'])) {
updateEventTitle($bdd, $eventId, trim($_POST['title']));
}
@@ -36,6 +34,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && empty($_POST['new'])) {
if (!isset($_POST['site'])) {
updateEventSite($bdd, $eventId, $_POST['site']);
}
+ if(isset($_POST['public'])){
+ updateEventVisibility($bdd, $eventId, 1);
+ }else{
+ updateEventVisibility($bdd, $eventId, 0);
+ }
if (!empty($_FILES['couverture']['name'])) {
$uploadDir = "../Photos/INTRANET/";
@@ -193,7 +196,7 @@ if (!empty($_POST['new'])) {
diff --git a/admin/modifyGallery.php b/admin/modifyGallery.php
index b54309d..e8d03da 100644
--- a/admin/modifyGallery.php
+++ b/admin/modifyGallery.php
@@ -33,6 +33,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
foreach ($_FILES['images']['tmp_name'] as $key => $tmpName) {
+ if ($_FILES['images']['error'][$key] !== UPLOAD_ERR_OK) {
+ continue;
+ }
+
+ if (!is_uploaded_file($tmpName)) {
+ continue;
+ }
+
$fileSize = $_FILES['images']['size'][$key];
$finfo = finfo_open(FILEINFO_MIME_TYPE);
@@ -96,6 +104,7 @@ while ($row = mysqli_fetch_assoc($result)) {
+