From be8354b535f41c92789ff8ffc05ff57dbe1f6bfe Mon Sep 17 00:00:00 2001 From: Alban Date: Fri, 22 Nov 2019 23:41:40 +0100 Subject: [PATCH] [fix] montage: smaller, secu --- page_generator.sh | 6 +++--- public/index.php | 3 ++- public/montage.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/page_generator.sh b/page_generator.sh index f956071..422ecc0 100755 --- a/page_generator.sh +++ b/page_generator.sh @@ -9,8 +9,8 @@ panic(){ echo $@; exit 2; } [[ ! -f $IMG ]] && panic "$IMG does not exist" -SMALL_SIDE=4000 -LARGE_SIDE=5800 +SMALL_SIDE=3000 +LARGE_SIDE=4350 # /tmp/out.pdf PDF 567x822 567x822+0+0 16-bit sRGB 980KB 0.010u 0:00.009 read name type GEOMETRY canvas depth format size other <<< $( identify $IMG ) @@ -29,6 +29,6 @@ DATE=$( date +%s ) OUTPUT_DIR=$( dirname ~+ )/a4 FILENAME=$( basename $IMG ) PDF_NAME=${OUTPUT_DIR}/${DATE}_${FILENAME}.pdf -OUT=$( montage -tile ${COUNT_HORIZONTAL}x${COUNT_VERTICAL} -density 200x200 -units pixelspercentimeter -border 0 -page ${TOTAL_WIDTH}x${TOTAL_HEIGHT} -compress zip -quality 100 "$IMG" -geometry ${REQ_WIDTH}x${REQ_HEIGHT} -duplicate ${DUP},0 ${PDF_NAME} ) +OUT=$( montage -tile ${COUNT_HORIZONTAL}x${COUNT_VERTICAL} -density 150x150 -units pixelspercentimeter -border 0 -page ${TOTAL_WIDTH}x${TOTAL_HEIGHT} -compress zip -quality 100 "$IMG" -geometry ${REQ_WIDTH}x${REQ_HEIGHT} -duplicate ${DUP},0 ${PDF_NAME} ) [ 0 -eq $? ] && echo $PDF_NAME || panic "An error occured... $OUT" diff --git a/public/index.php b/public/index.php index 5c4a86c..d46e282 100644 --- a/public/index.php +++ b/public/index.php @@ -311,7 +311,8 @@ $( "#montage" ).on("submit",function(e){ div.html( "Download "+data["horizontal"]+"x"+data["vertical"]+"")        }, error: function( data, msg, xhr){ - console.log( msg) + console.log( data) + div.html( "Oops... An error occured.") },     url: "montage.php",     data: data      diff --git a/public/montage.php b/public/montage.php index 23dc28f..0ce5a23 100644 --- a/public/montage.php +++ b/public/montage.php @@ -21,7 +21,7 @@ if (strpos($img, 'data:image/png;base64') === 0) { panic("Not a valid image"); } $output = $return_code = NULL; -exec( __DIR__."/../page_generator.sh ".escapeshellargs($file)." ".escapeshellargs($horizontal)." ".escapeshellargs($vertical)." ".escapeshellargs($landscape) , $output, $return_code); +exec( __DIR__."/../page_generator.sh ".escapeshellarg($file)." ".escapeshellarg($horizontal)." ".escapeshellarg($vertical)." ".escapeshellarg($landscape) , $output, $return_code); if( 0 === $return_code ){ $pdf = basename(implode("", $output)); echo( "https://2020.hackersfest.org/ImageGenerator/a4/".urlencode($pdf) );