diff options
| -rw-r--r-- | lib/file.php | 7 | ||||
| -rw-r--r-- | public/index.php | 6 | ||||
| -rw-r--r-- | public/upload.php | 5 |
3 files changed, 18 insertions, 0 deletions
diff --git a/lib/file.php b/lib/file.php index d8f740e..fe7dae1 100644 --- a/lib/file.php +++ b/lib/file.php @@ -34,4 +34,11 @@ function delete_file(string $file_id, string $file_extension): bool } return true; +} + +function strip_exif(string $file_path) +{ + $file_path = escapeshellarg($file_path); + $output = shell_exec("exiftool -q -EXIF= $file_path $file_path"); + return empty($output); }
\ No newline at end of file diff --git a/public/index.php b/public/index.php index 7c23b88..6f58fe8 100644 --- a/public/index.php +++ b/public/index.php @@ -299,6 +299,12 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); <th>Preserve original filename:</th> <td><input type="checkbox" name="preserve_original_name" value="1"></td> </tr> + <?php if (FILE_STRIP_EXIF): ?> + <tr> + <th>Strip EXIF data:</th> + <td><input type="checkbox" name="strip_exif_data" value="1" checked></td> + </tr> + <?php endif; ?> </table> <button type="submit">Upload</button> </form> diff --git a/public/upload.php b/public/upload.php index a0810ef..11c0f15 100644 --- a/public/upload.php +++ b/public/upload.php @@ -108,6 +108,11 @@ try { throw new RuntimeException('Invalid file format.'); } + // striping exif data + if (FILE_STRIP_EXIF && $is_media && !strip_exif($file['tmp_name'])) { + throw new RuntimeException('Failed to strip EXIF tags.'); + } + $file_data = [ 'size' => $file['size'], 'mime' => $file_mime, |
