diff options
| author | ilotterytea <iltsu@alright.party> | 2025-06-24 22:35:29 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-06-24 22:35:29 +0500 |
| commit | c734db91064944637e361f90ed90b30d48a7d910 (patch) | |
| tree | 641e8a7246039d98b13fa43b0d370460168a17e2 /lib/file.php | |
| parent | 2bdd40b6320d1504bb15f48242068534482c9b54 (diff) | |
feat: flash (.swf) support
Diffstat (limited to 'lib/file.php')
| -rw-r--r-- | lib/file.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/file.php b/lib/file.php index fc3e38a..61c4fb8 100644 --- a/lib/file.php +++ b/lib/file.php @@ -4,16 +4,20 @@ include_once $_SERVER['DOCUMENT_ROOT'] . '/../config.php'; function verify_mimetype(string $file_path, string $mimetype): bool { $path = escapeshellarg($file_path); + $output = []; + $exitCode = 0; if (str_starts_with($mimetype, 'image/')) { $output = shell_exec("identify -quiet -ping $path"); return !empty($output); } else if (str_starts_with($mimetype, 'video/') || str_starts_with($mimetype, 'audio/')) { - $output = []; - $exitCode = 0; $cmd = "ffprobe -v error -i $path 2>&1"; exec($cmd, $output, $exitCode); return $exitCode === 0; + } else if ($mimetype == 'application/x-shockwave-flash') { + $cmd = "swfdump $path 2>&1"; + exec($cmd, $output, $exitCode); + return $exitCode === 0; } throw new RuntimeException("Illegal type for MIME verifications: $mimetype"); |
