1
0
Fork 0
mirror of https://github.com/24eme/signaturepdf synced 2026-03-14 13:55:44 +01:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Hosted Weblate 2025-07-10 02:55:13 +02:00
commit 50da6a1abe
No known key found for this signature in database
GPG key ID: A3FAAA06E6569B4C
5 changed files with 66 additions and 2 deletions

25
app.php
View file

@ -292,12 +292,37 @@ $f3->route('POST /share',
}
\Flash::instance()->setKey('openModal', 'shareinformations');
\Flash::instance()->setKey("adminKey", $pdfSignature->createAdminKey());
$f3->reroute($f3->get('REVERSE_PROXY_URL').'/signature/'.$hash.(($symmetricKey) ? '#'.$symmetricKey : null));
}
);
$f3->route('GET @signature_deletion: /signature/@hash/delete/@key', function ($f3) {
$sharingFolder = $f3->get('PDF_STORAGE_PATH');
$baseHash = $sharingFolder.$f3->get('PARAMS.hash');
if (is_dir($baseHash) === false) {
$f3->error(403);
}
if (is_file($baseHash.'.admin') === false || is_readable($baseHash.'.admin') === false) {
$f3->error(403);
}
if (file_get_contents($baseHash.'.admin') !== $f3->get('PARAMS.key')) {
$f3->error(403);
}
GPGCryptography::hardUnlink($baseHash.'/.lock');
GPGCryptography::hardUnlink($baseHash);
unlink($baseHash.'.admin');
unlink($baseHash.'.expire');
$f3->reroute($f3->get('REVERSE_PROXY_URL').'/signature');
});
$f3->route('GET /signature/@hash/pdf',
function($f3) {
$f3->set('activeTab', 'sign');

View file

@ -90,8 +90,7 @@ class GPGCryptography
return preg_replace('/[^0-9a-zA-Z]*/', '', $key);
}
public static function createSymmetricKey() {
$length = 15;
public static function createSymmetricKey($length = 15) {
$keySpace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$pieces = [];
$max = mb_strlen($keySpace, '8bit') - 1;

View file

@ -30,6 +30,14 @@ class PDFSignature
}
}
public function createAdminKey()
{
$link = $this->gpg->createSymmetricKey(20);
file_put_contents($this->pathHash.'.admin', $link);
return $link;
}
public function verifyEncryption() {
if(!$this->isEncrypted()) {

View file

@ -493,6 +493,10 @@ function addObjectInCanvas(canvas, item) {
};
function updateWatermark() {
if (document.querySelector('input[name=watermark]') === null) {
return
}
const text = new fabric.Text(document.querySelector('input[name=watermark]').value, {angle: -40, fill: "#0009", fontSize: 27 * currentScale})
text.scale = 0.
const overlay = new fabric.Rect({

View file

@ -317,6 +317,34 @@
pdfHash = "<?php echo $hash ?>";
<?php endif; ?>
<?php if(Flash::instance()->hasKey('adminKey')): ?>
localStorage.setItem(pdfHash+'.adminKey', '<?php echo Flash::instance()->getKey('adminKey') ?>')
<?php endif; ?>
const adminKey = localStorage.getItem(pdfHash+'.adminKey')
if (adminKey) {
const icon = document.createElement('i')
icon.classList.add('float-end', 'bi', 'bi-trash3')
icon.style.cursor = 'pointer'
document.getElementById('text_document_name').appendChild(icon)
icon.addEventListener('click', async function () {
if (confirm("Êtes vous sûr de vouloir supprimer ce PDF ainsi que les signatures associées ?")) {
try {
const response = await fetch('/signature/'+pdfHash+'/delete/'+adminKey);
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
localStorage.removeItem(pdfHash+'.adminKey')
window.location.replace('/signature')
} catch (error) {
console.error(error.message);
}
}
})
}
var trad = <?php echo json_encode([
'Text to modify' => _('Text to modify')
]); ?>;