style=ticket (Fanch le colporteur)

This commit is contained in:
qo-op 2021-02-03 15:10:49 +01:00
parent a4a6d77c81
commit bd8d6c3f3e
3 changed files with 33 additions and 17 deletions

View File

@ -9,7 +9,7 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
################################################################################
# Create and print 6 G1Billets de $MONTANT DU
# ${MY_PATH}/G1BILLETS.sh 5 986397643
# ${MY_PATH}/G1BILLETS.sh 5 986397643 ticket
################################################################################
MONTANT="$1"
UNIQID="$2"
@ -21,7 +21,9 @@ NBbillets=6
[[ $MONTANT == "" ]] && MONTANT="___"
[[ $UNIQID == "" ]] && UNIQID=$(date -u +%s%N | cut -b1-13)$RANDOM
[[ "$STYLE" == "xbian" ]] && NBbillets=1 ## STYLE=xbian => 1 BILLET
[[ "$STYLE" == "1" ]] && NBbillets=1 && STYLE="" ## 1 BILLET
[[ "$STYLE" == "1" ]] && NBbillets=1 && STYLE="" ## 1 BILLET PDF
[[ "$STYLE" == "ticket" ]] && NBbillets=1 && echo "TICKET" ## 1 BILLET JPG
# CHECK IF $STYLE IMAGES EXIST
[[ ! -f ${MY_PATH}/images/fond${STYLE}.jpg ]] && exit 1
@ -46,15 +48,23 @@ do
done
# MONTAGE DES IMAGES DES BILLETS VERS /tmp/g1billet/${UNIQID}.pdf
montage /tmp/g1billet/${UNIQID}/*.jpg -tile 2x3 -geometry 964x459 /tmp/g1billet/${UNIQID}.pdf
# NB!! if "not autorized" then edit /etc/ImageMagick-6/policy.xml and comment
# <!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
if [[ "${STYLE}" != "ticket" ]]
then
# MONTAGE DES IMAGES DES BILLETS VERS /tmp/g1billet/${UNIQID}.pdf
montage /tmp/g1billet/${UNIQID}/*.jpg -tile 2x3 -geometry 964x459 /tmp/g1billet/${UNIQID}.pdf
# NB!! if "not autorized" then edit /etc/ImageMagick-6/policy.xml and comment
# <!-- <policy domain="coder" rights="none" pattern="PDF" /> -->
# CLEANING TEMP FILES
rm -Rf /tmp/g1billet/${UNIQID}
# ALLOWS ANY USER TO DELETE
chmod 777 /tmp/g1billet/${UNIQID}.pdf
else
cp /tmp/g1billet/${UNIQID}/*.jpg /tmp/g1billet/${UNIQID}.jpg
# CLEANING TEMP FILES
rm -Rf /tmp/g1billet/${UNIQID}
# ALLOWS ANY USER TO DELETE
chmod 777 /tmp/g1billet/${UNIQID}.jpg
fi
# CLEANING TEMP FILES
rm -Rf /tmp/g1billet/${UNIQID}
# ALLOWS ANY USER TO DELETE
chmod 777 /tmp/g1billet/${UNIQID}.pdf
exit

View File

@ -32,10 +32,10 @@ BILLETNAME=$(echo $NUMERO | sed 's/ /_/g')
composite -compose Over -gravity SouthWest -geometry +50+50 -dissolve 70% "${MY_PATH}/images/logo${STYLE}.png" "${MY_PATH}/images/fond${STYLE}.jpg" "/tmp/${BILLETNAME}.jpg"
# Prepare BILLET qrcode verification URL
qrencode -s 5 -o "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "$NOTERIB"
qrencode -s 6 -o "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "$NOTERIB"
# Add verification QRCode
composite -compose Over -gravity SouthEast -geometry +45+60 "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "/tmp/${BILLETNAME}.jpg" "/tmp/${BILLETNAME}.jpg"
composite -compose Over -gravity SouthEast -geometry +35+50 "/tmp/g1billet/${UNIQID}/${BILLETNAME}.QR.png" "/tmp/${BILLETNAME}.jpg" "/tmp/${BILLETNAME}.jpg"
# Change June logo color
case "$MONTANT" in

View File

@ -5,16 +5,22 @@ $timestamp = $mytime->format('U').rand();
// CREATE 6 G1BILLETS in /tmp/g1billet/$timestamp
$page = shell_exec(dirname(__FILE__)."/G1BILLETS.sh '".$_REQUEST['montant']."' '".$timestamp."' '".$_REQUEST['style']."'");
$attachment_location = "/tmp/g1billet/".$timestamp.".pdf";
if ( $_REQUEST['style'] == 'ticket' ) {
$file_type = "jpg";
} else {
$file_type = "pdf";
}
$attachment_location = "/tmp/g1billet/".$timestamp.".".$file_type;
if (file_exists($attachment_location)) {
header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
header("Cache-Control: public"); // needed for internet explorer
header("Content-Type: application/pdf");
header("Content-Type: application/".$file_type);
header("Content-Transfer-Encoding: Binary");
header("Content-Length:".filesize($attachment_location));
header("Content-Disposition: attachment; filename=".$timestamp.".pdf");
header("Content-Disposition: attachment; filename=".$timestamp.".".$file_type);
readfile($attachment_location);
unlink("/tmp/g1billet/".$timestamp.".pdf");
unlink("/tmp/g1billet/".$timestamp.".".$file_type);
die();
} else {
die("Error: File not found.");