diff --git a/php/inc_fx_eve_extra.php b/php/inc_fx_eve_extra.php index 2113e17..0e4d8ba 100644 --- a/php/inc_fx_eve_extra.php +++ b/php/inc_fx_eve_extra.php @@ -121,3 +121,29 @@ function fxKcEveResultatsQrUrl($intEveId, $strBaseUrl = null) return rtrim($strBaseUrl, '/') . '/kc.php?t=eve&id=' . $intEveId; } + +/** + * PNG binaire du QR résultats événement (avec logo MS1). + * MSIN-3487 + * + * @param int $intEveId + * @param string|null $strBaseUrl + * @param int $intModuleSize + * @param bool $blnWithLogo + * @return string|false + */ +function fxKcEveResultatsQrPngBinary($intEveId, $strBaseUrl = null, $intModuleSize = 10, $blnWithLogo = true) +{ + require_once __DIR__ . '/inc_fx_kc_qr.php'; + + $intEveId = intval($intEveId); + if ($intEveId <= 0) { + return false; + } + + return fxKcQrGeneratePngBinary( + fxKcEveResultatsQrUrl($intEveId, $strBaseUrl), + $intModuleSize, + $blnWithLogo + ); +} diff --git a/php/inc_fx_kc_qr.php b/php/inc_fx_kc_qr.php index 4c57dd3..9f662f6 100644 --- a/php/inc_fx_kc_qr.php +++ b/php/inc_fx_kc_qr.php @@ -123,11 +123,17 @@ function fxKcQrOverlayLogo($strQrPath, $fltLogoRatio = 0.22) } /** - * Génère un QR key_chain prêt pour l'impression. + * Génère un PNG QR pour une URL quelconque (niveau H, logo optionnel). + * MSIN-3487 — réutilisé key_chain + QR résultats événement. + * + * @param string $strUrl + * @param string $strOutputFile + * @param int $intModuleSize + * @param bool $blnWithLogo + * @return string Chemin du fichier généré */ -function fxKcQrGeneratePng($intParam1, $strBaseUrl, $strOutputFile, $intModuleSize = 18, $blnWithLogo = true) +function fxKcQrGeneratePngFromUrl($strUrl, $strOutputFile, $intModuleSize = 18, $blnWithLogo = true) { - $strUrl = rtrim($strBaseUrl, '/') . '/kc.php?param1=' . intval($intParam1); $strDir = dirname($strOutputFile); if (!is_dir($strDir)) { mkdir($strDir, 0755, true); @@ -137,7 +143,7 @@ function fxKcQrGeneratePng($intParam1, $strBaseUrl, $strOutputFile, $intModuleSi $strUrl, $strOutputFile, QR_ECLEVEL_H, - $intModuleSize, + max(4, (int) $intModuleSize), 2 ); @@ -145,6 +151,45 @@ function fxKcQrGeneratePng($intParam1, $strBaseUrl, $strOutputFile, $intModuleSi fxKcQrOverlayLogo($strOutputFile); } + return $strOutputFile; +} + +/** + * Génère un PNG QR en mémoire (binaire) pour une URL. + * + * @param string $strUrl + * @param int $intModuleSize + * @param bool $blnWithLogo + * @return string|false + */ +function fxKcQrGeneratePngBinary($strUrl, $intModuleSize = 10, $blnWithLogo = true) +{ + $strTmpBase = tempnam(sys_get_temp_dir(), 'kcqr_'); + if ($strTmpBase === false) { + return false; + } + @unlink($strTmpBase); + $strTmpPng = $strTmpBase . '.png'; + + fxKcQrGeneratePngFromUrl($strUrl, $strTmpPng, $intModuleSize, $blnWithLogo); + if (!is_file($strTmpPng)) { + return false; + } + + $binPng = file_get_contents($strTmpPng); + @unlink($strTmpPng); + + return ($binPng === false || $binPng === '') ? false : $binPng; +} + +/** + * Génère un QR key_chain prêt pour l'impression. + */ +function fxKcQrGeneratePng($intParam1, $strBaseUrl, $strOutputFile, $intModuleSize = 18, $blnWithLogo = true) +{ + $strUrl = rtrim($strBaseUrl, '/') . '/kc.php?param1=' . intval($intParam1); + fxKcQrGeneratePngFromUrl($strUrl, $strOutputFile, $intModuleSize, $blnWithLogo); + return [ 'param1' => intval($intParam1), 'url' => $strUrl, diff --git a/superadm/eve_resultats_qr.php b/superadm/eve_resultats_qr.php new file mode 100644 index 0000000..2b0ce95 --- /dev/null +++ b/superadm/eve_resultats_qr.php @@ -0,0 +1,42 @@ + — si vide → https://ms1.ca + 0) { + $strEveQrImg = 'eve_resultats_qr.php?eve_id=' . intval($intEveIdForm); + $strEveQrDl = $strEveQrImg . '&dl=1'; + ?> +
+
+ QR résultats événement <?php echo intval($intEveIdForm); ?> +
+ +  Télécharger le QR (PNG) + +
+