diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/catalogue.php | 2 | ||||
| -rw-r--r-- | public/index.php | 12 | ||||
| -rw-r--r-- | public/upload.php | 8 |
3 files changed, 18 insertions, 4 deletions
diff --git a/public/catalogue.php b/public/catalogue.php index 9836cbf..f2a5cd6 100644 --- a/public/catalogue.php +++ b/public/catalogue.php @@ -77,7 +77,7 @@ 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/')): ?> + <?php if (str_starts_with($file['mime'], 'image/') || str_starts_with($file['mime'], 'video/') || $file['mime'] == 'application/x-shockwave-flash'): ?> <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/')): ?> diff --git a/public/index.php b/public/index.php index 556349f..a9ddec3 100644 --- a/public/index.php +++ b/public/index.php @@ -248,6 +248,12 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); </audio> <?php elseif (str_starts_with($file['mime'], 'text/')): ?> <pre><?= file_get_contents(FILE_UPLOAD_DIRECTORY . "/{$file['id']}.{$file['extension']}") ?></pre> + <?php elseif ($file['mime'] == 'application/x-shockwave-flash' && !empty(RUFFLE_DRIVER_PATH)): ?> + <noscript>JavaScript is required to play Flash</noscript> + <object> + <embed src="<?= $file['full_url'] ?>" width="<?= $file['width'] - 4 ?>" + height="<?= $file['height'] ?>"> + </object> <?php else: ?> <p><i>This file cannot be displayed.</i></p> <?php endif; ?> @@ -452,6 +458,10 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); </main> </body> +<?php if ($file && $file['mime'] == 'application/x-shockwave-flash' && !empty(RUFFLE_DRIVER_PATH)): ?> + <script src="<?= RUFFLE_DRIVER_PATH ?>"></script> +<?php endif; ?> + <?php if ($file): ?> <script> const fileTabButtons = document.getElementById('file-tab-buttons'); @@ -649,7 +659,7 @@ $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/')) { + } else if (!file.mime.startsWith('image/') && !file.mime.startsWith('video/') && file.mime != 'application/x-shockwave-flash') { thumbnailPath = '/static/img/icons/file.png'; } else { thumbnailSize = 'max-width:100%; max-height: 100%;'; 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'] = [ |
