Files
ms1inscription-v5/qbbk.php
2026-05-13 09:43:32 -04:00

80 lines
2.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// MSIN-4290
session_start();
require_once "php/inc_fonctions.php";
// 1. Récupération du token
if (!isset($_GET['t']) || $_GET['t'] == '') {
die('TOKEN MANQUANT');
}
$strToken = $_GET['t'];
$strTokenHash = hash('sha256', $strToken);
// 2. IP
$strIp = $_SERVER['REMOTE_ADDR'] ?? '';
// 3. Recherche du token
$sql = "
SELECT
id,
token_hash,
com_id,
pec_id,
ach_id,
status,
token_enc
FROM qr_tokens
WHERE token_hash = '" . $strTokenHash . "'
LIMIT 1
";
$tabQr = $objDatabase->fxGetRow($sql);
if (!$tabQr) {
die('TOKEN INVALIDE');
}
// 4. Mise à jour IP + used_at
$sqlUpdate = "
UPDATE qr_tokens SET
adress_ip = '" . $strIp . "',
used_at = NOW()
WHERE id = " . intval($tabQr['id'])
;
$objDatabase->fxQuery($sqlUpdate);
$token = fxdecrypt_token($tabQr['token_enc']);
$qrImage =fxgenerer_qr_image($token,$_SERVER['HTTP_HOST'].'/q.php' );
// 5. Affichage TEST
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<title>QR TEST</title>
<style>
body { font-family: Arial, sans-serif; margin: 40px; }
.box { border: 1px solid #ccc; padding: 20px; width: 500px; }
.row { margin-bottom: 8px; }
.label { font-weight: bold; }
</style>
</head>
<body>
<h2>QR TOKEN MODE TEST</h2>
<div class="box">
<div class="row"><span class="label">Status :</span> <?= htmlspecialchars($tabQr['status']) ?></div>
<div class="row"><span class="label">com_id :</span> <?= intval($tabQr['com_id']) ?></div>
<div class="row"><span class="label">pec_id :</span> <?= intval($tabQr['pec_id']) ?></div>
<div class="row"><span class="label">ach_id :</span> <?= intval($tabQr['ach_id']) ?></div>
<div class="row"><span class="label">token_hash :</span><br><?= htmlspecialchars($tabQr['token_hash']) ?></div>
<div class="row"><span class="label">IP :</span> <?= htmlspecialchars($strIp) ?></div>
</div>
<img src="<?= $qrImage ?>" alt="QR Code">
</body>
</html>