-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
48 lines (39 loc) · 1.36 KB
/
send.php
File metadata and controls
48 lines (39 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
// Chemin : send.php
// Ton Webhook Discord (ne PAS exposer ce fichier publiquement ou dans un repo)
$webhook_url = 'https://canary.discord.com/api/webhooks/1378744054761918465/d1nMzVNaewn7XblPTkDuqwr3D2GPp0NnmD5eKch4R7PfNg9mlCejLQ3-sDMXlPK21CuJ';
// Lire les données POST JSON
$input = json_decode(file_get_contents('php://input'), true);
if (!$input) {
http_response_code(400);
echo 'Invalid input';
exit;
}
// Construire le message à envoyer
$message = "**Nouvelle demande de contact :**\n\n"
. "**Nom/Pseudo :** " . htmlspecialchars($input['name']) . "\n"
. "**Email :** " . htmlspecialchars($input['email']) . "\n"
. "**Sujet :** " . htmlspecialchars($input['subject']) . "\n"
. "**Message :**\n" . htmlspecialchars($input['message']);
// Préparer la payload Discord
$payload = json_encode([
'content' => $message
]);
// Envoyer à Discord
$options = [
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\n",
'content' => $payload
]
];
$context = stream_context_create($options);
$response = file_get_contents($webhook_url, false, $context);
// Vérifier la réponse
if ($response === false) {
http_response_code(500);
echo 'Erreur Discord';
exit;
}
http_response_code(200);
echo 'Message envoyé';