fix: Update include paths for Discord webhooks in login, register, and new event pages
This commit is contained in:
77
tools/discordWebhookLogin.php
Normal file
77
tools/discordWebhookLogin.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// Code fork depuis https://stackoverflow.com/a/51748785
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userDataEncoded = $_COOKIE['userData'];
|
||||
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
|
||||
$url = "https://discord.com/api/webhooks/1251174147707506760/9nzTCgf9KQBDm6gjbbJCNgXfwrnSZhdFM3-ysp5_DGeUm0PABxyoYwTBn-HyJ0P6heCY";
|
||||
|
||||
$hookObject = json_encode([
|
||||
"content" => "## ✅ Nouvelle connexion au site des Jeux Olympiques de Paris 2024 ! \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://but.lbalocchi.fr/",
|
||||
],
|
||||
|
||||
// Field array of objects
|
||||
"fields" => [
|
||||
[
|
||||
"name" => "Nom de l'utilisateur",
|
||||
"value" => $nameFetched . " " . $familyNameFetched,
|
||||
"inline" => false
|
||||
],
|
||||
[
|
||||
"name" => "Adresse mail de l'utilisateur",
|
||||
"value" => $email,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Rôle de l'utilisateur",
|
||||
"value" => $roleFetched,
|
||||
"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);
|
||||
?>
|
98
tools/discordWebhookNewEvent.php
Normal file
98
tools/discordWebhookNewEvent.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
// Code fork depuis https://stackoverflow.com/a/51748785
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userDataEncoded = $_COOKIE['userData'];
|
||||
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
|
||||
$url = "https://discord.com/api/webhooks/1251196052133118013/euJIbUIfmdXK0MJsS6WoEDLm2ipPV_efb1gLOeUaP3IZNIM4MRdqu2RuOWbVF_09d2ty";
|
||||
|
||||
$hookObject = json_encode([
|
||||
"content" => "## ✅ Nouvel évènement créé sur le site des Jeux Olympiques de Paris 2024 ! \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://but.lbalocchi.fr/",
|
||||
],
|
||||
|
||||
// Field array of objects
|
||||
"fields" => [
|
||||
// en cas de nouvel évènement créé, notifie via un webhook des informations suivantes concernant l'évènement : Nom de l'évènement, Discipline, Date de l'évènement, Lieu de l'évènement, Description de l'évènement, Rôles pouvant s'inscrire
|
||||
[
|
||||
"name" => "Nom de l'évènement",
|
||||
"value" => $eventName,
|
||||
"inline" => false
|
||||
],
|
||||
[
|
||||
"name" => "Discipline",
|
||||
"value" => $eventDiscipline,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Date de l'évènement",
|
||||
"value" => $eventDate,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Lieu de l'évènement",
|
||||
"value" => $eventLocation,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Description de l'évènement",
|
||||
"value" => $eventDescription,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Rôles pouvant s'inscrire",
|
||||
"value" => $rolesText,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Créateur de l'évènement",
|
||||
"value" => $name . " " . $familyName . " (" . $role . ")\n" . $email,
|
||||
"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);
|
||||
?>
|
77
tools/discordWebhookRegister.php
Normal file
77
tools/discordWebhookRegister.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
// Code fork depuis https://stackoverflow.com/a/51748785
|
||||
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/tools/dbConnect.php';
|
||||
session_start();
|
||||
|
||||
if (isset($_COOKIE['userData'])) {
|
||||
$userDataEncoded = $_COOKIE['userData'];
|
||||
$userData = json_decode($userDataEncoded, true); // 'true' pour obtenir un tableau associatif
|
||||
|
||||
$email = $userData['email'];
|
||||
$name = $userData['name'];
|
||||
$familyName = $userData['familyName'];
|
||||
$role = $userData['role'];
|
||||
}
|
||||
|
||||
$url = "https://discord.com/api/webhooks/1251195948969889893/ul_eB43XfEHoulUbS5YcsiJ2BWdTt4oLxgA_ZD9e7SFbyYYtfYU0HFR5ixE8WmMKjtSY";
|
||||
|
||||
$hookObject = json_encode([
|
||||
"content" => "## ➕ Nouvel utilisateur enregistré sur le site des Jeux Olympiques de Paris 2024 !",
|
||||
"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://but.lbalocchi.fr/",
|
||||
],
|
||||
|
||||
// Field array of objects
|
||||
"fields" => [
|
||||
[
|
||||
"name" => "Nom de l'utilisateur",
|
||||
"value" => $name . " " . $familyName,
|
||||
"inline" => false
|
||||
],
|
||||
[
|
||||
"name" => "Adresse mail de l'utilisateur",
|
||||
"value" => $email,
|
||||
"inline" => true
|
||||
],
|
||||
[
|
||||
"name" => "Rôle de l'utilisateur",
|
||||
"value" => $role,
|
||||
"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);
|
||||
?>
|
Reference in New Issue
Block a user