diff --git a/www/admin.php b/www/admin.php index a8d01e4..5446a96 100644 --- a/www/admin.php +++ b/www/admin.php @@ -351,8 +351,10 @@ if ($action === 'identity_edit') { if ($safeName === '') { $safeName = 'file'; } - $storedName = bin2hex(random_bytes(12)) . '_' . $safeName; - $destination = $uploadDir . $storedName; + do { + $storedName = bin2hex(random_bytes(12)) . '_' . $safeName; + $destination = $uploadDir . $storedName; + } while (is_file($destination)); if (!move_uploaded_file($tmpName, $destination)) { $fileUploadErrors[] = sprintf('Speichern von %s fehlgeschlagen.', $originalName); @@ -482,6 +484,18 @@ if ($action === 'identity_edit') { if ($identityFiles === false) { $identityFiles = []; } + $duplicateFilenameCounts = []; + foreach ($identityFiles as $file) { + $filename = $file['filename'] ?? ''; + if ($filename === '') { + continue; + } + $duplicateFilenameCounts[$filename] = ($duplicateFilenameCounts[$filename] ?? 0) + 1; + } + $duplicateFileNames = array_keys(array_filter( + $duplicateFilenameCounts, + static fn (int $count): bool => $count > 1 + )); ?> @@ -586,10 +600,18 @@ if ($action === 'identity_edit') {

+ +

+ Dateien mit identischem Dateinamen bleiben getrennt und können einzeln gelöscht. +

+