From d0d78ae4ff0c2aa6dab61bbe730217748d6214e7 Mon Sep 17 00:00:00 2001 From: Boga Sebastian Nicolae Date: Sun, 22 Oct 2023 01:23:43 +0300 Subject: [PATCH 1/2] DISCORD webhook secrets are defined at github level --- engine/index.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/engine/index.php b/engine/index.php index d243d40..c21fb30 100644 --- a/engine/index.php +++ b/engine/index.php @@ -24,6 +24,30 @@ $rawDomain = isset($_POST['domain']) ? $_POST['domain'] : "https:\/\/peviitor.ro"; $rawDomain = isset($_GET['domain']) ? $_GET['domain'] : $rawDomain; +function discord_webhook($msg) { + $date = ' '.date("l d-m-Y H:i:s"); + $msg = $msg.$date; + $method = 'POST'; + + $server_id = '{{SERVER_ID}}'; // Placeholder for the SERVER_ID + $channel_id = '{{CHANNEL_ID}}'; // Placeholder for the CHANNEL_ID + + $url = "https://discord.com/api/webhooks/".$server_id."/".$channel_id; + $data = '{"content": "'.$msg.'"}'; + + $options = array( + 'http' => array( + 'header' => "Content-type: application/json\r\n", + 'method' => 'POST', + 'content' => $data + ) + ); + $context = stream_context_create($options); + $result = file_get_contents($url, false, $context); + if ($result === FALSE) { /* Handle error */ } + + } + function addProtocolToDomain($domain) { if (strpos($domain, 'http://') !== 0 && strpos($domain, 'https://') !== 0) { $domain = 'https://' . $domain; // Add "https://" as the protocol @@ -86,10 +110,14 @@ function checkHumansTxtExistence($domain) { if (!$result_r) { header("HTTP/1.1 404 Not Found"); } - else { echo $result_r;} + else { + discord_webhook($domainWithProtocol); + echo $result_r; + } } else { + discord_webhook($domainWithWww); echo $result; } From 3dacf0aca54004c8ed0a2b3e32fd542fdde50916 Mon Sep 17 00:00:00 2001 From: Boga Sebastian Nicolae Date: Sun, 22 Oct 2023 01:32:35 +0300 Subject: [PATCH 2/2] updated the message to be sent to DISCORD --- engine/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/engine/index.php b/engine/index.php index c21fb30..0a14dc1 100644 --- a/engine/index.php +++ b/engine/index.php @@ -25,8 +25,9 @@ $rawDomain = isset($_GET['domain']) ? $_GET['domain'] : $rawDomain; function discord_webhook($msg) { - $date = ' '.date("l d-m-Y H:i:s"); - $msg = $msg.$date; + $prefix ='Found humans.txt at '; + $date = ' on '.date("l d-m-Y H:i:s"); + $msg =$prefix.$msg.'/humans.txt'.$date; $method = 'POST'; $server_id = '{{SERVER_ID}}'; // Placeholder for the SERVER_ID