summaryrefslogtreecommitdiff
path: root/public/upload.php
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-06-24 22:35:29 +0500
committerilotterytea <iltsu@alright.party>2025-06-24 22:35:29 +0500
commitc734db91064944637e361f90ed90b30d48a7d910 (patch)
tree641e8a7246039d98b13fa43b0d370460168a17e2 /public/upload.php
parent2bdd40b6320d1504bb15f48242068534482c9b54 (diff)
feat: flash (.swf) support
Diffstat (limited to 'public/upload.php')
-rw-r--r--public/upload.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/public/upload.php b/public/upload.php
index 3ec525a..c5a2e7e 100644
--- a/public/upload.php
+++ b/public/upload.php
@@ -207,7 +207,7 @@ try {
if (
FILE_THUMBNAILS && (
(
- str_starts_with($file_data['mime'], 'image/') &&
+ (str_starts_with($file_data['mime'], 'image/') || $file_data['mime'] == 'application/x-shockwave-flash') &&
$thumbnail_error = generate_image_thumbnail(
FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_data['extension']}",
FILE_THUMBNAIL_DIRECTORY . "/{$file_id}.webp",
@@ -237,7 +237,8 @@ try {
'duration' => null,
'line_count' => null,
];
- $metadata_should_be_created = in_array(explode('/', $file_data['mime'])[0], ['image', 'video', 'audio', 'text']);
+ $metadata_should_be_created = in_array(explode('/', $file_data['mime'])[0], ['image', 'video', 'audio', 'text']) || $file_data['mime'] == 'application/x-shockwave-flash';
+ $file_path_escaped = escapeshellarg($file_path);
if (str_starts_with($file_data['mime'], 'image/')) {
[$width, $height] = explode('x', trim(shell_exec('identify -format "%wx%h" ' . escapeshellarg($file_path) . '[0]')));
@@ -253,6 +254,9 @@ try {
$file_data['metadata']['duration'] = intval(round(trim(shell_exec('ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ' . escapeshellarg($file_path))), 2));
} else if (str_starts_with($file_data['mime'], 'text/')) {
$file_data['metadata']['line_count'] = intval(trim(shell_exec('wc -l < ' . escapeshellarg($file_path))));
+ } else if ($file_data['mime'] == 'application/x-shockwave-flash') {
+ $file_data['metadata']['width'] = intval(substr(trim(shell_exec("swfdump -X $file_path_escaped")), 3));
+ $file_data['metadata']['height'] = intval(substr(trim(shell_exec("swfdump -Y $file_path_escaped")), 3));
}
$file_data['urls'] = [