-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.php
More file actions
117 lines (103 loc) · 3.76 KB
/
send.php
File metadata and controls
117 lines (103 loc) · 3.76 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
// By: EtskaCoding https://github.com/EtskaCoding
$webhookurl = "YOUR WEBHOOK URL"; //PASTE YOUR WEBHOOK URL HERE!
session_start();
define("RECAPTCHA_V3_SECRET_KEY", 'YOUR SECRET KEY');
$token = $_POST['token'];
$action = $_POST['action'];
// call curl to POST request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('secret' => RECAPTCHA_V3_SECRET_KEY, 'response' => $token)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$arrResponse = json_decode($response, true);
// verify the response
if($arrResponse["success"] == '1' && $arrResponse["action"] == $action && $arrResponse["score"] >= 0.5) {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$playername = $_POST['playername'];
$dcname = $_POST['dcname'];
$description = $_POST['description'];
if (empty($playername)) {
$_SESSION['msg'] = '<div class="alert">
Player name is required!
</div>';
} elseif (empty($dcname)) {
$_SESSION['msg'] = '<div class="alert">
Discord name or email is required!
</div>';
} elseif (empty($description)) {
$_SESSION['msg'] = '<div class="alert">
Description is required!
</div>';
} else {
send($playername, $dcname, $description);
$_SESSION['msg'] = '<div class="success">
Bug report sended succesfully! Staff contacts you soon.
</div>';
}
header("Location: index.php");
exit();
} else {
// spam submission
// show error message
}
}
function send($playername, $dcname, $description) {
global $webhookurl;
$json_data = json_encode([
// Username
"username" => "BugReport",
// Avatar URL.
// Uncoment to replace image set in webhook
"avatar_url" => "https://i.redd.it/b1b640z9b3c21.jpg",
// Embeds Array
"embeds" => [
[
// Embed Title
"title" => "BugReport",
// Embed Type
"type" => "rich",
// Embed left border color in HEX
"color" => hexdec("3366ff"),
// Footer
"footer" => [
"text" => "By EtskaCoding",
"icon_url" => "https://etska.ml/etska.png"
],
// Additional Fields array
"fields" => [
[
"name" => "Player Name",
"value" => $playername,
"inline" => false
],
[
"name" => "Discord or email",
"value" => $dcname,
"inline" => false
],
[
"name" => "Description",
"value" => $description,
"inline" => false
]
// Etc..
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$ch = curl_init($webhookurl);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
// If you need to debug, or find out why you can't send message uncomment line below, and execute script.
// echo $response;
curl_close($ch);
}