diff --git a/account/profile/myentries/index.php b/account/profile/myentries/index.php new file mode 100644 index 0000000..e8cb02f --- /dev/null +++ b/account/profile/myentries/index.php @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + Jeux Olympiques - Paris 2024 + + + + Vous n'êtes pas autorisé à accéder à cette page.

"; + echo "

Redirection vers l'accueil dans 5 secondes...

"; + header("refresh:5; url=/"); + include $_SERVER['DOCUMENT_ROOT'] . '/views/footer.php'; + die(); + } ?> +

Mes participations

+ Bienvenue " . $name . " " . $familyName . ".

"; + + ?> + + ✅ Votre participation a bien été prise en compte.

"; + } else if ($_GET['res'] == "entry-failed") { + echo "

❌ La participation a échoué. Veuillez réessayer.

"; + } else if ($_GET['res'] == "entry-cancellation-failed") { + echo "

❌ La participation a échoué. Veuillez réessayer.

"; + } else if ($_GET['res'] == "entry-cancellation-succeeded") { + $eventTitleFetched = $_GET['eventtitle']; + echo "

✅ L'annulation de votre participation à l'évènement \"$eventTitleFetched\" a bien été prise en compte.

"; + } + } + //afficher la liste des évènements auxquels l'utilisateur est inscrit (avec mysqli) (table booking) + $stmt = mysqli_prepare($db, "SELECT * FROM event_entries WHERE mail = ?"); + mysqli_stmt_bind_param($stmt, "s", $email); + mysqli_stmt_execute($stmt); + $result = mysqli_stmt_get_result($stmt); + if (mysqli_num_rows($result) == 0) { + echo "

Vous ne participez à aucun évènement.

"; + } else { + echo "

Voici la liste des évènements auxquels vous êtes inscrit :

"; + echo "
"; + echo "
"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + ; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + // sélectionner les évènements auxquels l'utilisateur est inscrit (avec mysqli et à l'aide de $email) (utiliser cette requete ? SELECT * FROM booking WHERE mail="$email";) + while ($booking = mysqli_fetch_assoc($result)) { + $eventID = $booking['id']; + $stmt = mysqli_prepare($db, "SELECT * FROM event WHERE id = ?"); + mysqli_stmt_bind_param($stmt, "i", $eventID); + mysqli_stmt_execute($stmt); + $eventResult = mysqli_stmt_get_result($stmt); + $event = mysqli_fetch_assoc($eventResult); + + + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + echo "
Nom de l'évènementDateLieuAction
" . $event['title'] . "" . date('d/m/Y', strtotime($event['date'])) . "" . $event['location'] . "Annuler
"; + echo "
"; + echo "
"; + } + + //echo "Annuler"; + + ?> + + + + + \ No newline at end of file diff --git a/events/index.php b/events/index.php index 8e621a9..443880c 100644 --- a/events/index.php +++ b/events/index.php @@ -1,3 +1,16 @@ + @@ -44,25 +57,10 @@ --> Créer un évènement'; - echo ''; - } else if ($role == 'Sportif') { - echo ''; - echo ''; - echo ''; + echo ''; - } else { - echo ''; - } - echo ''; - } else { - echo ''; - - } // faire une requete sql avec mysqli permettant d'afficher tous les évènements @@ -106,21 +104,28 @@ echo ""; echo ""; // En-tête du tableau echo ""; - echo ""; // Ensure class name matches with the CSS - echo ""; // Ensure class name matches with the CSS - echo ""; // Ensure class name matches with the CSS - echo ""; // Ensure class name matches with the CSS - echo ""; // Ensure class name matches with the CSS + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; echo ""; echo ""; - echo ""; // The scrollable body class removed here if not necessary + echo ""; while ($row = mysqli_fetch_array($result)) { echo ""; echo ""; echo ""; echo ""; - echo ""; + echo ""; echo ""; + // mettre un bouton réserver si l'utilisateur est connecté et un bouton participer si l'utilisateur est un sportif + if (isset($_COOKIE['userData'])) { + if ($role == 'Sportif') { + echo ""; + } + } echo ""; } echo ""; diff --git a/events/list/display/index.php b/events/list/display/index.php index f79a010..e51f8fa 100644 --- a/events/list/display/index.php +++ b/events/list/display/index.php @@ -35,143 +35,149 @@ if (isset($_COOKIE['userData'])) { Évènements à $location pour les $role" . "s" . ""; - if ($role == 'Administrateur') { - $query = "SELECT * FROM event WHERE location = '$location'"; - } else { - $query = "SELECT * FROM event WHERE location = '$location' AND role LIKE '%$role%'"; + if (isset($_COOKIE['userData'])) { + if (isset($_GET['location'])) { + $location = $_GET['location']; + echo "

Évènements à $location pour les $role" . "s" . "

"; + if ($role == 'Administrateur') { + $query = "SELECT * FROM event WHERE location = '$location'"; + } else { + $query = "SELECT * FROM event WHERE location = '$location' AND role LIKE '%$role%'"; + } + $result = mysqli_query($db, $query); + echo "
"; + if (mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_assoc($result)) { + $eventID = htmlspecialchars($row['id'], ENT_QUOTES); + $title = htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8'); + $description = htmlspecialchars($row['description'], ENT_QUOTES); + $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); + $date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); + $location = htmlspecialchars($row['location'], ENT_QUOTES); + $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); + $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); + $creator = htmlspecialchars($row['creator'], ENT_QUOTES); + echo "
"; + echo "

$title

"; + echo "

Type d'évènement : $event_type

"; + echo "

Date : $date

"; + echo "

Lieu : $location

"; + echo "

Nombre de participants : $guest_count

"; + echo "

(Roles autorisés) : $authorized_roles

"; + echo "

$description

"; + if ($role != 'Administrateur') { + if ($role != 'Administrateur') { + echo ""; + } + } + if ($role == 'Sportif') { + echo ""; + } + echo "
"; + } + } else { + echo "

Aucun évènement trouvé à cet endroit.

"; + echo "
"; + } } - $result = mysqli_query($db, $query); - echo "
"; - if (mysqli_num_rows($result) > 0) { - while ($row = mysqli_fetch_assoc($result)) { - $eventID = htmlspecialchars($row['id'], ENT_QUOTES); - $title = htmlspecialchars($row['title'], ENT_QUOTES, 'UTF-8'); - $description = htmlspecialchars($row['description'], ENT_QUOTES); - $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); - $date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); - $location = htmlspecialchars($row['location'], ENT_QUOTES); - $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); - $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); - $creator = htmlspecialchars($row['creator'], ENT_QUOTES); - echo "
"; - echo "

$title

"; - echo "

Type d'évènement : $event_type

"; - echo "

Date : $date

"; - echo "

Lieu : $location

"; - echo "

Nombre de participants : $guest_count

"; - echo "

(Roles autorisés) : $authorized_roles

"; - echo "

$description

"; - if ($role != 'Administrateur') { + + + if (isset($_GET['date'])) { + $date = $_GET['date']; + echo "

Évènements le $date pour $role

"; + if ($role == 'Administrateur') { + $query = "SELECT * FROM event WHERE date = '$date'"; + } else { + $query = "SELECT * FROM event WHERE date = '$date' AND role LIKE '%$role%'"; + } + $result = mysqli_query($db, $query); + echo "
"; + if (mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_assoc($result)) { + $eventID = htmlspecialchars($row['id'], ENT_QUOTES); + $title = htmlspecialchars($row['title'], ENT_QUOTES); + $description = htmlspecialchars($row['description'], ENT_QUOTES); + $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); + $date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); + $location = htmlspecialchars($row['location'], ENT_QUOTES); + $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); + $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); + $creator = htmlspecialchars($row['creator'], ENT_QUOTES); + echo "
"; + echo "

$title

"; + echo "

Type d'évènement : $event_type

"; + echo "

Date : $date

"; + echo "

Lieu : $location

"; + echo "

Nombre de participants : $guest_count

"; + echo "

(Roles autorisés) : $authorized_roles

"; + echo "

$description

"; if ($role != 'Administrateur') { echo ""; } + if ($role == 'Sportif') { + echo ""; + } + echo "
"; } - if ($role == 'Sportif') { - echo ""; - } - echo "
"; + } else { + echo "

Aucun évènement trouvé à la date recherchée.

"; } - } else { - echo "

Aucun évènement trouvé à cet endroit.

"; echo "
"; } - } - if (isset($_GET['date'])) { - $date = $_GET['date']; - echo "

Évènements le $date pour $role

"; - if ($role == 'Administrateur') { - $query = "SELECT * FROM event WHERE date = '$date'"; - } else { - $query = "SELECT * FROM event WHERE date = '$date' AND role LIKE '%$role%'"; - } - $result = mysqli_query($db, $query); - echo "
"; - if (mysqli_num_rows($result) > 0) { - while ($row = mysqli_fetch_assoc($result)) { - $eventID = htmlspecialchars($row['id'], ENT_QUOTES); - $title = htmlspecialchars($row['title'], ENT_QUOTES); - $description = htmlspecialchars($row['description'], ENT_QUOTES); - $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); - $date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); - $location = htmlspecialchars($row['location'], ENT_QUOTES); - $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); - $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); - $creator = htmlspecialchars($row['creator'], ENT_QUOTES); - echo "
"; - echo "

$title

"; - echo "

Type d'évènement : $event_type

"; - echo "

Date : $date

"; - echo "

Lieu : $location

"; - echo "

Nombre de participants : $guest_count

"; - echo "

(Roles autorisés) : $authorized_roles

"; - echo "

$description

"; - if ($role != 'Administrateur') { - echo ""; - } - if ($role == 'Sportif') { - echo ""; - } - echo "
"; + if (isset($_GET['title'])) { + $title = $_GET['title']; + echo "

Évènement intitulé \"$title\"

"; + if ($role == 'Administrateur') { + $query = "SELECT * FROM event WHERE title = '$title'"; + } else { + $query = "SELECT * FROM event WHERE title = '$title' AND role LIKE '%$role%'"; } - } else { - echo "

Aucun évènement trouvé à la date recherchée.

"; - } - echo "
"; - } - - - if (isset($_GET['title'])) { - $title = $_GET['title']; - echo "

Évènement intitulé \"$title\"

"; - if ($role == 'Administrateur') { - $query = "SELECT * FROM event WHERE title = '$title'"; - } else { - $query = "SELECT * FROM event WHERE title = '$title' AND role LIKE '%$role%'"; - } - $result = mysqli_query($db, $query); - echo "
"; - if (mysqli_num_rows($result) > 0) { - while ($row = mysqli_fetch_assoc($result)) { - $eventID = htmlspecialchars($row['id'], ENT_QUOTES); - $title = htmlspecialchars($row['title'], ENT_QUOTES); - $description = htmlspecialchars($row['description'], ENT_QUOTES); - $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); - $date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); - $location = htmlspecialchars($row['location'], ENT_QUOTES); - $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); - $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); - $creator = htmlspecialchars($row['creator'], ENT_QUOTES); - echo "
"; - echo "

$title

"; - echo "

Type d'évènement : $event_type

"; - echo "

Date : $date

"; - echo "

Lieu : $location

"; - echo "

Nombre de participants : $guest_count

"; - echo "

(Roles autorisés) : $authorized_roles

"; - echo "

$description

"; - if ($role != 'Administrateur') { - echo ""; + $result = mysqli_query($db, $query); + echo "
"; + if (mysqli_num_rows($result) > 0) { + while ($row = mysqli_fetch_assoc($result)) { + $eventID = htmlspecialchars($row['id'], ENT_QUOTES); + $title = htmlspecialchars($row['title'], ENT_QUOTES); + $description = htmlspecialchars($row['description'], ENT_QUOTES); + $event_type = htmlspecialchars($row['event_type'], ENT_QUOTES); + $date = date('d/m/Y', strtotime(htmlspecialchars($row['date']))); + $location = htmlspecialchars($row['location'], ENT_QUOTES); + $authorized_roles = htmlspecialchars($row['role'], ENT_QUOTES); + $guest_count = htmlspecialchars($row['guest_count'], ENT_QUOTES); + $creator = htmlspecialchars($row['creator'], ENT_QUOTES); + echo "
"; + echo "

$title

"; + echo "

Type d'évènement : $event_type

"; + echo "

Date : $date

"; + echo "

Lieu : $location

"; + echo "

Nombre de participants : $guest_count

"; + echo "

(Roles autorisés) : $authorized_roles

"; + echo "

$description

"; + if ($role != 'Administrateur') { + echo ""; + } + if ($role == 'Sportif') { + echo ""; + } + echo "
"; } - if ($role == 'Sportif') { - echo ""; - } - echo "
"; + } else { + echo "

Aucun évènement n'est prévu à ce nom.

"; } + echo "
"; } else { - echo "

Aucun évènement n'est prévu à ce nom.

"; + } echo "
"; } else { + echo "

Vous n'êtes pas autorisé à accéder à cette page.

"; + echo "

Redirection vers l'accueil dans 5 secondes...

"; + header("refresh:5; url=/"); + die(); } - echo "
"; - ?> diff --git a/events/list/index.php b/events/list/index.php index 6eb1097..1531a62 100644 --- a/events/list/index.php +++ b/events/list/index.php @@ -34,6 +34,17 @@ if (isset($_COOKIE['userData'])) { + + Vous n'êtes pas autorisé à accéder à cette page.

"; + echo "

Redirection vers l'accueil dans 5 secondes...

"; + header("refresh:5; url=/"); + include $_SERVER['DOCUMENT_ROOT'] . '/views/footer.php'; + die(); + } + ?> +
Avatar

Afficher les évènements

diff --git a/events/participate/cancel.php b/events/participate/cancel.php new file mode 100644 index 0000000..cc38089 --- /dev/null +++ b/events/participate/cancel.php @@ -0,0 +1,58 @@ +Vous vous apprêtez à annuler votre participation à l'évènement suivant :

"; + echo "

Nom de l'évènement : $eventTitle

"; + echo "

Date de l'évènement : $eventDate

"; + echo "

Lieu de l'évènement : $eventLocation

"; + echo "

Discipline de l'évènement : $eventType

"; + echo "

Description de l'évènement : $eventDescription

"; + echo "

Adresse mail de l'utilisateur : $userEmail

"; + + $stmt = mysqli_prepare($db, "DELETE FROM booking WHERE id = ? AND mail = ?"); + mysqli_stmt_bind_param($stmt, "is", $eventId, $userEmail); + if (mysqli_stmt_execute($stmt)) { + + + echo "

Votre annulation à l'évènement $eventTitle a bien été prise en compte.

"; + + + include $_SERVER['DOCUMENT_ROOT'] . '/tools/discordWebhookBooking.php'; + header("Location: /account/profile/myevents?res=cancellation-succeeded&eventtitle=$eventTitle"); + } else { + echo "

Erreur lors de la mise à jour du nombre de participants.

"; + } + } else { + echo "

Une erreur est survenue lors de votre annulation à l'évènement. Erreur : " . mysqli_error($db) . "

"; + header("Location: /account/profile/myevents?res=cancellation-failed"); + } +} + +?> \ No newline at end of file diff --git a/events/participate/index.php b/events/participate/index.php deleted file mode 100644 index eb658eb..0000000 --- a/events/participate/index.php +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - Jeux Olympiques - Paris 2024 - - - - - - - - - - diff --git a/events/participate/participate.php b/events/participate/participate.php new file mode 100644 index 0000000..b7e1d9a --- /dev/null +++ b/events/participate/participate.php @@ -0,0 +1,63 @@ +Vous n'êtes pas autorisé à accéder à cette page.

"; + echo "

Redirection vers l'accueil dans 5 secondes...

"; + header("refresh:5; url=/"); + die(); + +} + + +if (isset($_GET['usermail']) && isset($_GET['id'])) { + $userEmail = $_GET['usermail']; + $eventId = $_GET['id']; + + + + $stmt = mysqli_prepare($db, "SELECT * FROM event WHERE id = ?"); + mysqli_stmt_bind_param($stmt, "i", $eventId); + mysqli_stmt_execute($stmt); + $result = mysqli_stmt_get_result($stmt); + $eventDetails = mysqli_fetch_assoc($result); + + if ($eventDetails) { + $eventTitle = $eventDetails["title"]; + $eventDescription = $eventDetails["description"]; + $eventType = $eventDetails["event_type"]; + $eventDate = $eventDetails["date"]; + $eventLocation = $eventDetails["location"]; + + echo "

Vous vous apprêtez à participer à l'évènement suivant :

"; + echo "

Nom de l'évènement : $eventTitle

"; + echo "

Date de l'évènement : $eventDate

"; + echo "

Lieu de l'évènement : $eventLocation

"; + echo "

Discipline de l'évènement : $eventType

"; + echo "

Description de l'évènement : $eventDescription

"; + echo "

Adresse mail de l'utilisateur : $userEmail

"; + + $stmt = mysqli_prepare($db, "INSERT INTO event_entries (id, mail, title, description, event_type, date, location) VALUES (?, ?, ?, ?, ?, ?, ?)"); + mysqli_stmt_bind_param($stmt, "issssss", $eventId, $userEmail, $eventTitle, $eventDescription, $eventType, $eventDate, $eventLocation); + if (mysqli_stmt_execute($stmt)) { + echo "

Votre inscription à l'évènement $eventTitle a bien été prise en compte.

"; + header("Location: /account/profile/myentries?res=entry-succeeded"); + die(); + } else { + echo "

Une erreur est survenue lors de votre inscription à l'évènement. Erreur : " . mysqli_error($db) . "

"; + header("Location: /account/profile/myentries?res=entry-failed"); + die(); + } + } else { + echo "

Évènement introuvable.

"; + } +} +?> \ No newline at end of file diff --git a/styles/main.css b/styles/main.css index eaad6b1..1d9774f 100644 --- a/styles/main.css +++ b/styles/main.css @@ -481,7 +481,6 @@ button.new-event:hover { width: 100%; /* Full width of its container */ border-collapse: collapse; /* Collapse borders */ table-layout: fixed; /* Fixed layout for consistent column sizing */ - font-size: 0.9em; min-width: 400px; } diff --git a/tools/discordWebhookEntry.php b/tools/discordWebhookEntry.php new file mode 100644 index 0000000..709789b --- /dev/null +++ b/tools/discordWebhookEntry.php @@ -0,0 +1,108 @@ + "## ✅ Nouvelle participation à un évènement ! \n@here", + "username" => "Jeux Olympiques - Paris 2024", + "avatar_url" => "https://i.imgur.com/gg5xPa1.png", + "tts" => false, + "embeds" => [ + [ + "title" => "Jeux Olympiques - Paris 2024", + "type" => "rich", + "description" => "", + "url" => "https://but.lbalocchi.fr/", + "timestamp" => date('c', time()), + "color" => hexdec("F4B400"), + "footer" => [ + "text" => "© Juliette & Loris - 2024", + "icon_url" => "https://tickets.paris2024.org/obj/media/FR-Paris2024/specialLogos/favicons/favicon-32x32.png" + ], + "image" => [ + "url" => "https://www.fromagersdefrance.com/wp-content/uploads/2023/03/1200px-Logo_JO_dete_-_Paris_2024.svg__0.png" + ], + "author" => [ + "name" => "Juliette & Loris", + "url" => "https://stackoverflow.com/a/51748785", + ], + + // Field array of objects + "fields" => [ + [ + "name" => "Nom", + "value" => $name, + "inline" => true + ], + [ + "name" => "Prénom", + "value" => $familyName, + "inline" => true + ], + [ + "name" => "Email", + "value" => $email, + "inline" => true + ], + [ + "name" => "Rôle", + "value" => $role, + "inline" => true + ], + [ + "name" => "Évènement", + "value" => $eventTitle, + "inline" => true + ], + [ + "name" => "Date", + "value" => $eventDate, + "inline" => true + ], + [ + "name" => "Lieu", + "value" => $eventLocation, + "inline" => true + ], + [ + "name" => "Type", + "value" => $eventType, + "inline" => true + ], + [ + "name" => "Description", + "value" => $eventDescription, + "inline" => true + ] + + ] + ] + ] + +], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); +$ch = curl_init(); +curl_setopt_array($ch, [ + CURLOPT_URL => $url, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $hookObject, + CURLOPT_HTTPHEADER => [ + "Content-Type: application/json" + ] +]); +$response = curl_exec($ch); +curl_close($ch); +?> \ No newline at end of file diff --git a/views/footer.php b/views/footer.php index 57c17af..bd505eb 100644 --- a/views/footer.php +++ b/views/footer.php @@ -42,6 +42,9 @@ if (isset($_COOKIE['userData'])) { if ($role != 'Administrateur') { echo "
  • Mes réservations
  • "; } + if ($role == 'Sportif') { + echo "
  • Mes participations
  • "; + } } ?> @@ -68,7 +71,9 @@ if (isset($_COOKIE['userData'])) {
    diff --git a/views/header.php b/views/header.php index a7b2cd7..3d27f78 100644 --- a/views/header.php +++ b/views/header.php @@ -85,6 +85,9 @@ if (isset($_COOKIE['userData'])) { if ($role != 'Administrateur') { echo "
  • Mes réservations
  • "; } + if ($role == 'Sportif') { + echo "
  • Mes participations
  • "; + } } ?>
    TitreDescriptionDisciplineDateLieuTitreDescriptionDisciplineDateLieuAction
    " . htmlspecialchars($row['title']) . "" . htmlspecialchars($row['description']) . "" . htmlspecialchars($row['event_type']) . "" . htmlspecialchars($row['date']) . "" . date('d/m/Y', strtotime($row['date'])) . "" . htmlspecialchars($row['location']) . "