Files
api/modules/washcertificates/certificates/index.php
T
Jepp9350 ea6c65a7b8 Add Wash Certificate generator module.
This commit introduces the Wash Certificate generator, including template files, images, fonts, and outputs necessary for certificate generation. These assets and configurations support creating customized wash certificates effectively.
2025-01-10 15:20:26 +01:00

37 lines
1.1 KiB
PHP

<?php
/**
* This is the processor that handles the certificate download requests
* It is here to avoid direct access to the certificate download API
*/
require_once '../../../config.php';
global $WORDPRESS_STATIC_TOKEN;
// Male sure the config file is loaded and configured
if (!isset($WORDPRESS_STATIC_TOKEN)) {
header('HTTP/1.0 500 Internal Server Error');
return;
}
// Get the certificate ID from the query string
$certificate_id = $_GET['certificate_id'] ?? '';
// Check if the certificate ID is a number
if (!is_numeric($certificate_id) || $certificate_id < 1) {
header('HTTP/1.0 403 Bad Request');
return;
}
// TODO: Add authentication here
// Check if the certificate exists in the /output/certificates folder
if (!file_exists("../output/certificates/wash_certificate_" . $certificate_id . ".pdf")) {
header('HTTP/1.0 403 Bad Request');
return;
}
// Set the headers
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="wash certificate ' . $certificate_id . '.pdf"');
// Output the certificate
readfile("../output/certificates/wash_certificate_" . $certificate_id . ".pdf");
exit;