mirror of
https://github.com/24eme/signaturepdf
synced 2026-03-14 13:55:44 +01:00
Merge branch 'master' of github.com:24eme/signaturepdf
This commit is contained in:
commit
17fa19987b
2 changed files with 31 additions and 8 deletions
27
app.php
27
app.php
|
|
@ -102,7 +102,7 @@ if($f3->get('PDF_DEMO_LINK') === null || $f3->get('PDF_DEMO_LINK') === true) {
|
|||
}
|
||||
}
|
||||
|
||||
$f3->route('GET /',
|
||||
$f3->route('GET|HEAD /',
|
||||
function($f3) {
|
||||
$f3->set('activeTab', 'index');
|
||||
echo View::instance()->render('index.html.php');
|
||||
|
|
@ -501,13 +501,27 @@ $f3->route('GET /api/file/get', function($f3) {
|
|||
}
|
||||
$pdf_path = $localRootFolder . '/' . $f3->get('GET.path');
|
||||
$pdf_filename = basename($pdf_path);
|
||||
if (!preg_match('/.pdf$/', $pdf_path)) {
|
||||
$extension = 'pdf';
|
||||
if (preg_match('/.(pdf|png|jpg|jpeg)$/', $pdf_path, $m)) {
|
||||
$extension = $m[1];
|
||||
}else{
|
||||
$f3->error(403);
|
||||
}
|
||||
if (!file_exists($pdf_path)) {
|
||||
$f3->error(403);
|
||||
}
|
||||
header('Content-type: application/pdf');
|
||||
switch ($extension) {
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
header('Content-type: image/jpg');
|
||||
break;
|
||||
case 'png':
|
||||
header('Content-type: image/png');
|
||||
break;
|
||||
default:
|
||||
header('Content-type: application/pdf');
|
||||
break;
|
||||
}
|
||||
header("Content-Disposition: attachment; filename=$pdf_filename");
|
||||
echo file_get_contents($pdf_path);
|
||||
});
|
||||
|
|
@ -519,13 +533,16 @@ $f3->route('PUT /api/file/save', function($f3) {
|
|||
}
|
||||
$pdf_path = $localRootFolder . '/' . $f3->get('GET.path');
|
||||
$pdf_filename = basename($pdf_path);
|
||||
if (!preg_match('/.pdf$/', $pdf_path)) {
|
||||
if (preg_match('/(.*).(pdf|png|jpg|jpeg)$/', $pdf_path, $m)) {
|
||||
$basefile = $m[1];
|
||||
$extension = $m[2];
|
||||
}else{
|
||||
$f3->error(403);
|
||||
}
|
||||
if (!file_exists($pdf_path)) {
|
||||
$f3->error(403);
|
||||
}
|
||||
file_put_contents($pdf_path, $f3->get('BODY'));
|
||||
file_put_contents($basefile.'.pdf', $f3->get('BODY'));
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue