MSIN-3487 — Add function to generate binary PNG QR for event results with optional logo. Update existing QR generation functions for improved URL handling. Enhance UI to display and download event result QR codes. Increment version code.
This commit is contained in:
@ -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
|
||||
);
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
42
superadm/eve_resultats_qr.php
Normal file
42
superadm/eve_resultats_qr.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* MSIN-3487 — PNG QR résultats événement (logo MS1).
|
||||
*
|
||||
* Affichage : eve_resultats_qr.php?eve_id=760
|
||||
* Téléchargement : eve_resultats_qr.php?eve_id=760&dl=1
|
||||
*/
|
||||
session_start();
|
||||
require_once __DIR__ . '/php/inc_functions.php';
|
||||
require_once dirname(__FILE__) . '/../php/inc_fx_eve_extra.php';
|
||||
|
||||
if (empty($_SESSION['usa_id']) || empty($_SESSION['usa_info'])) {
|
||||
http_response_code(403);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'Accès refusé.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$intEveId = isset($_GET['eve_id']) ? intval($_GET['eve_id']) : 0;
|
||||
$blnDownload = !empty($_GET['dl']);
|
||||
|
||||
$binPng = fxKcEveResultatsQrPngBinary($intEveId, null, 10, true);
|
||||
if ($binPng === false) {
|
||||
http_response_code(400);
|
||||
header('Content-Type: text/plain; charset=utf-8');
|
||||
echo 'QR impossible à générer.';
|
||||
exit;
|
||||
}
|
||||
|
||||
$strFilename = 'qr_resultats_eve_' . $intEveId . '.png';
|
||||
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Length: ' . strlen($binPng));
|
||||
header('Cache-Control: private, max-age=60');
|
||||
if ($blnDownload) {
|
||||
header('Content-Disposition: attachment; filename="' . $strFilename . '"');
|
||||
} else {
|
||||
header('Content-Disposition: inline; filename="' . $strFilename . '"');
|
||||
}
|
||||
|
||||
echo $binPng;
|
||||
exit;
|
||||
@ -1164,6 +1164,24 @@ if ($strAction == 'mod') {
|
||||
<code><?php echo htmlspecialchars($strEveQrPreview, ENT_QUOTES, 'UTF-8'); ?></code>
|
||||
— si vide → <code>https://ms1.ca</code>
|
||||
</small>
|
||||
<?php if ($intEveIdForm > 0) {
|
||||
$strEveQrImg = 'eve_resultats_qr.php?eve_id=' . intval($intEveIdForm);
|
||||
$strEveQrDl = $strEveQrImg . '&dl=1';
|
||||
?>
|
||||
<div class="mt-3">
|
||||
<div class="mb-2">
|
||||
<img src="<?php echo htmlspecialchars($strEveQrImg, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
alt="QR résultats événement <?php echo intval($intEveIdForm); ?>"
|
||||
width="220" height="220"
|
||||
class="border bg-white p-1"
|
||||
loading="lazy">
|
||||
</div>
|
||||
<a class="btn btn-outline-secondary btn-sm rounded-0"
|
||||
href="<?php echo htmlspecialchars($strEveQrDl, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<i class="fa fa-download" aria-hidden="true"></i> Télécharger le QR (PNG)
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
|
||||
Reference in New Issue
Block a user