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

40 lines
842 B
PHP
Raw 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
// qr_img.php
// Génération dynamique dun QR code PNG via ?t=TOKEN
// IMPORTANT : aucun espace avant <?php
// Aucun echo avant les headers
require_once __DIR__ . '/../libs/phpqrcode-master/qrlib.php';
// Vérification du token
if (empty($_GET['t'])) {
http_response_code(400);
exit;
}
$strToken = trim($_GET['t']);
// Validation basique (évite injections bizarres)
if (!preg_match('/^[A-Za-z0-9]+$/', $strToken)) {
http_response_code(400);
exit;
}
// URL encodée dans le QR (landing page existante)
$strQrUrl = 'https://' . $_SERVER['HTTP_HOST'] . '/q.php?t=' . urlencode($strToken);
// Headers image
header('Content-Type: image/png');
header('Cache-Control: public, max-age=3600');
// Génération directe vers la sortie navigateur
QRcode::png(
$strQrUrl,
null,
QR_ECLEVEL_Q,
6
);
exit;