summaryrefslogtreecommitdiff
path: root/lib/file.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/file.php')
-rw-r--r--lib/file.php8
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");