Replaced legacy 'nnks.truckwash.dk' endpoint with 'api.truckwash.dk' across the codebase for consistency. Implemented a feature to handle certificate downloads, including file serving and validation. Updated PHP configuration to support additional dependencies like PHPMailer, and introduced necessary route and configuration changes for wash certificate processing.
23 lines
779 B
PHP
23 lines
779 B
PHP
<?php
|
|
// Get the file name from the URL
|
|
$file = $_SERVER['REQUEST_URI'];
|
|
$file = str_replace('/modules/washcertificates/output/certificates/', '', $file);
|
|
|
|
// Download the file from minio, and send it to the client
|
|
$wash_certificate_store = new \classes\wash_certificate_store();
|
|
|
|
// Check if the certificate exists
|
|
if (!$wash_certificate_store->washCertificateExists($file)) {
|
|
header('HTTP/1.1 404 Not Found');
|
|
exit;
|
|
}
|
|
|
|
// Download the certificate from the store to /tmp
|
|
$certificate_path = $wash_certificate_store->download($file);
|
|
|
|
// Send the certificate to the client
|
|
header('Content-Type: application/pdf');
|
|
header('Content-Disposition: inline; filename="' . $file . '"');
|
|
header('Content-Length: ' . filesize($certificate_path));
|
|
readfile($certificate_path);
|
|
exit; |