organic: Add exernal BioQS api
This commit is contained in:
36
www/organic/external/bioqs/attachments.php
vendored
Normal file
36
www/organic/external/bioqs/attachments.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET' && $_SERVER['REQUEST_METHOD'] !== 'HEAD') {
|
||||
header('Status: 405');
|
||||
header('Content-Length: 0');
|
||||
header('Allow: GET, HEAD');
|
||||
exit;
|
||||
}
|
||||
|
||||
$info = $_SERVER['PATH_INFO'];
|
||||
if ($info === '') {
|
||||
header('Status: 404');
|
||||
header('Content-Length: 0');
|
||||
exit;
|
||||
}
|
||||
$certId = substr($info, 1);
|
||||
|
||||
$file = tmpfile();
|
||||
if (!$file) {
|
||||
header('Status: 500');
|
||||
header('Content-Length: 0');
|
||||
exit;
|
||||
}
|
||||
$filename = stream_get_meta_data($file)['uri'];
|
||||
if (($pdfName = exec("python3 .attachment.py " . escapeshellarg($certId) . " 2>&1 > $filename ")) === false) {
|
||||
header('Status: 500');
|
||||
header('Content-Length: 0');
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: application/pdf');
|
||||
header('Content-Length: ' . filesize($filename));
|
||||
header('Content-Disposition: inline; filename="' . $pdfName . '"');
|
||||
readfile($filename);
|
Reference in New Issue
Block a user