-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshout.php
More file actions
87 lines (86 loc) · 2.62 KB
/
shout.php
File metadata and controls
87 lines (86 loc) · 2.62 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
<?php
if (count(get_included_files()) == 1) {
http_response_code(403);
exit("Direct access not permitted.");
}
//Authenticaton Info
$auth = require_once 'auth.php';
$key = $auth['key'];
$constant = $auth['constant'];
$webhookurl = $auth['discord'];
$url = $auth['url'];
//Content
$whseal = echousername($user->data()->id);
$whclient = $data['client_nm'];
$whcaseid = $extractArray;
// IRC Message
$data = [
"type" => "PPWK",
"parameters" => [
"CMDR" => $whclient,
"Seal" => $whseal,
"Number" => $whcaseid
]
];
$postdata = json_encode($data);
$hmacdata = preg_replace("/\s+/", "", $postdata);
$auth = hash_hmac('sha256', $hmacdata, $key);
$keyCheck = hash_hmac('sha256', $constant, $key);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'hmac: ' . $auth,
'keyCheck: ' . $keyCheck
));
$result = curl_exec($ch);
curl_close($ch);
//Discord Webhook
$timestamp = date("c", strtotime("now"));
$json_data = json_encode([
"content" => "Paperwork Completed",
"username" => "HalpyBOT",
"avatar_url" => "https://hullseals.space/images/emblem_mid.png",
"tts" => false,
"embeds" => [
[
"title" => "Paperwork Complete",
"type" => "rich",
"timestamp" => $timestamp,
"color" => hexdec("F5921F"),
"footer" => [
"text" => "Hull Seals Case Notification System",
"icon_url" => "https://hullseals.space/images/emblem_mid.png"
],
"fields" => [
[
"name" => "Paperwork for case",
"value" => $whclient,
"inline" => true
],
[
"name" => "Completed by ",
"value" => $whseal,
"inline" => true
],
[
"name" => "Case ID",
"value" => $whcaseid,
"inline" => true
]
]
]
]
], 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);
curl_close($ch);