diff options
| author | ilotterytea <iltsu@alright.party> | 2025-06-25 00:13:02 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-06-25 00:13:02 +0500 |
| commit | 17cdae613d339d31aacabfd232fdd9f67bea6c3a (patch) | |
| tree | 8824c7c0e55bdec8d1eaf129d97257b3fbbfede9 /public | |
| parent | c734db91064944637e361f90ed90b30d48a7d910 (diff) | |
feat: custom swf parser because swftools is obsolete
Diffstat (limited to 'public')
| -rw-r--r-- | public/catalogue.php | 13 | ||||
| -rw-r--r-- | public/index.php | 4 | ||||
| -rwxr-xr-x | public/static/img/icons/file_flash.png | bin | 0 -> 582 bytes | |||
| -rw-r--r-- | public/upload.php | 7 |
4 files changed, 16 insertions, 8 deletions
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); <div class="brick<?= isset($file['color']) ? " {$file['color']}" : '' ?>"> <a href="/<?= sprintf('%s.%s', $file['id'], $file['extension']) ?>"> <i title="<?= $file['thumb_title'] ?>"> - <?php if (str_starts_with($file['mime'], 'image/') || str_starts_with($file['mime'], 'video/') || $file['mime'] == 'application/x-shockwave-flash'): ?> + <?php if (str_starts_with($file['mime'], 'image/') || str_starts_with($file['mime'], 'video/')): ?> <img src="<?= sprintf('%s/%s.webp', FILE_THUMBNAIL_DIRECTORY_PREFIX, $file['id']) ?>" alt="No thumbnail." loading="lazy"> <?php elseif (str_starts_with($file['mime'], 'audio/')): ?> - <img src="/static/img/icons/file_audio.png" alt="No thumbnail." loading="lazy"> + <img src="/static/img/icons/file_audio.png" alt="No thumbnail." loading="lazy" width="64" + height="64"> <?php elseif (str_starts_with($file['mime'], 'text/')): ?> - <img src="/static/img/icons/file_text.png" alt="No thumbnail." loading="lazy"> + <img src="/static/img/icons/file_text.png" alt="No thumbnail." loading="lazy" width="64" + height="64"> + <?php elseif ($file['mime'] == 'application/x-shockwave-flash'): ?> + <img src="/static/img/icons/file_flash.png" alt="No thumbnail." loading="lazy" width="64" + height="64"> <?php else: ?> - <img src="/static/img/icons/file.png" alt="No thumbnail."> + <img src="/static/img/icons/file.png" alt="No thumbnail." width="64" height="64"> <?php endif; ?> </i> </a> 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 Binary files differnew file mode 100755 index 0000000..5769120 --- /dev/null +++ b/public/static/img/icons/file_flash.png 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'] = [ |
