diff options
-rw-r--r-- | modules/gallery/models/item.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php index e3d27b6d..2d62c386 100644 --- a/modules/gallery/models/item.php +++ b/modules/gallery/models/item.php @@ -76,9 +76,18 @@ class Item_Model extends ORM_MPTT { parent::delete(); if (is_dir($path)) { + // Take some precautions against accidentally deleting way too much + $delete_resize_path = dirname($resize_path); + $delete_thumb_path = dirname($thumb_path); + if ($delete_resize_path == VARPATH . "resizes" || + $delete_thumb_path == VARPATH . "thumbs" || + $path == VARPATH . "albums") { + throw new Exception( + "@todo DELETING_TOO_MUCH ($delete_resize_path, $delete_thumb_path, $path)"); + } @dir::unlink($path); - @dir::unlink(dirname($resize_path)); - @dir::unlink(dirname($thumb_path)); + @dir::unlink($delete_resize_path); + @dir::unlink($delete_thumb_path); } else { @unlink($path); @unlink($resize_path); |