G1BILLET/index.php

31 lines
1.1 KiB
PHP
Raw Normal View History

2021-01-24 19:21:49 +01:00
<?php
$mytime = new Datetime("now");
2021-01-25 10:02:44 +01:00
$timestamp = $mytime->format('U').rand();
2021-01-24 19:21:49 +01:00
2022-12-06 22:39:40 +01:00
/// BROKEN PREFER DAEMON MODE
2021-01-24 19:21:49 +01:00
// CREATE 6 G1BILLETS in /tmp/g1billet/$timestamp
$page = shell_exec(dirname(__FILE__)."/G1BILLETS.sh '".$_REQUEST['montant']."' '".$timestamp."' '".$_REQUEST['style']."'");
2021-01-24 19:21:49 +01:00
2022-12-06 01:00:20 +01:00
if ( $_REQUEST['style'] == 'ticket' || $_REQUEST['style'] == 'xbian' || $_REQUEST['style'] == 'astro' ) {
$file_type = "jpg";
2021-02-03 15:10:49 +01:00
} else {
2022-12-06 01:00:20 +01:00
$file_type = "pdf";
2021-02-03 15:10:49 +01:00
}
2022-12-06 14:51:16 +01:00
$attachment_location = dirname(__FILE__)."/tmp/g1billet/".$timestamp.".".$file_type;
2021-02-03 15:10:49 +01:00
2021-01-24 19:21:49 +01:00
if (file_exists($attachment_location)) {
2022-12-06 01:00:20 +01:00
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
2021-01-24 19:21:49 +01:00
header("Cache-Control: public"); // needed for internet explorer
2021-02-03 15:10:49 +01:00
header("Content-Type: application/".$file_type);
2021-01-24 19:21:49 +01:00
header("Content-Transfer-Encoding: Binary");
header("Content-Length:".filesize($attachment_location));
2021-02-03 15:10:49 +01:00
header("Content-Disposition: attachment; filename=".$timestamp.".".$file_type);
2022-12-06 01:00:20 +01:00
readfile($attachment_location);
2022-12-06 14:51:16 +01:00
unlink(dirname(__FILE__)."/tmp/g1billet/".$timestamp.".".$file_type);
2022-12-06 01:00:20 +01:00
die();
2021-01-24 19:21:49 +01:00
} else {
2022-12-06 14:55:35 +01:00
die("Error: File not found.".$attachment_location);
2021-01-24 19:21:49 +01:00
}
?>