From 17cdae613d339d31aacabfd232fdd9f67bea6c3a Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 25 Jun 2025 00:13:02 +0500 Subject: feat: custom swf parser because swftools is obsolete --- public/catalogue.php | 13 +++++++++---- public/index.php | 4 +++- public/static/img/icons/file_flash.png | Bin 0 -> 582 bytes public/upload.php | 7 ++++--- 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100755 public/static/img/icons/file_flash.png (limited to 'public') diff --git a/public/catalogue.php b/public/catalogue.php index f2a5cd6..764b7d2 100644 --- a/public/catalogue.php +++ b/public/catalogue.php @@ -77,15 +77,20 @@ unset($f);
"> - + No thumbnail. - No thumbnail. + No thumbnail. - No thumbnail. + No thumbnail. + + No thumbnail. - No thumbnail. + No thumbnail. diff --git a/public/index.php b/public/index.php index a9ddec3..4d912c3 100644 --- a/public/index.php +++ b/public/index.php @@ -659,7 +659,9 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); thumbnailPath = '/static/img/icons/file_audio.png'; } else if (file.mime.startsWith('text/')) { thumbnailPath = '/static/img/icons/file_text.png'; - } else if (!file.mime.startsWith('image/') && !file.mime.startsWith('video/') && file.mime != 'application/x-shockwave-flash') { + } else if (file.mime == 'application/x-shockwave-flash') { + thumbnailPath = '/static/img/icons/file_flash.png'; + } else if (!file.mime.startsWith('image/') && !file.mime.startsWith('video/')) { thumbnailPath = '/static/img/icons/file.png'; } else { thumbnailSize = 'max-width:100%; max-height: 100%;'; diff --git a/public/static/img/icons/file_flash.png b/public/static/img/icons/file_flash.png new file mode 100755 index 0000000..5769120 Binary files /dev/null and b/public/static/img/icons/file_flash.png differ diff --git a/public/upload.php b/public/upload.php index c5a2e7e..15a66d2 100644 --- a/public/upload.php +++ b/public/upload.php @@ -207,7 +207,7 @@ try { if ( FILE_THUMBNAILS && ( ( - (str_starts_with($file_data['mime'], 'image/') || $file_data['mime'] == 'application/x-shockwave-flash') && + str_starts_with($file_data['mime'], 'image/') && $thumbnail_error = generate_image_thumbnail( FILE_UPLOAD_DIRECTORY . "/{$file_id}.{$file_data['extension']}", FILE_THUMBNAIL_DIRECTORY . "/{$file_id}.webp", @@ -255,8 +255,9 @@ try { } 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)); + [$width, $height] = parse_swf_file($file_path); + $file_data['metadata']['width'] = $width; + $file_data['metadata']['height'] = $height; } $file_data['urls'] = [ -- cgit v1.2.3