From 0e891e13072e25abc41772e8a9e73d5d6706c02f Mon Sep 17 00:00:00 2001 From: Vincent LAURENT Date: Sat, 2 Apr 2022 01:07:41 +0200 Subject: [PATCH] Using php function to move and copy instead of shell --- app.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app.php b/app.php index fdd0522..2fe32fb 100644 --- a/app.php +++ b/app.php @@ -205,10 +205,11 @@ $f3->route('GET /signature/@hash/pdf', if (!$layers) { Web::instance()->send($originalFile, null, 0, TRUE, $filename); } + copy($originalFile, $finalFile); $bufferFile = str_replace('.pdf', '_tmp.pdf', $originalFile); - shell_exec(sprintf("cp %s %s", $originalFile, $finalFile)); - foreach($layers as $layer) { - shell_exec(sprintf("pdftk %1\$s multistamp %2\$s output %3\$s && mv %3\$s %1\$s", $finalFile, $layer, $bufferFile)); + foreach($layers as $layerFile) { + shell_exec(sprintf("pdftk %s multistamp %s output %s", $finalFile, $layerFile, $bufferFile)); + rename($bufferFile, $finalFile); } Web::instance()->send($finalFile, null, 0, TRUE, $filename); }