Skip to content

Commit

Permalink
Merge pull request #30 from sebiboga/feature-5
Browse files Browse the repository at this point in the history
Feature 5
  • Loading branch information
sebiboga committed Oct 21, 2023
2 parents c8996d3 + 3dacf0a commit e4611ca
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion engine/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@
$rawDomain = isset($_POST['domain']) ? $_POST['domain'] : "https:\/\/peviitor.ro";
$rawDomain = isset($_GET['domain']) ? $_GET['domain'] : $rawDomain;

function discord_webhook($msg) {
$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
$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
Expand Down Expand Up @@ -86,10 +111,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;
}

Expand Down

0 comments on commit e4611ca

Please sign in to comment.