From 2fcc8a388b27747bb534f0beba18114720f9b899 Mon Sep 17 00:00:00 2001 From: deva Date: Sun, 12 Oct 2008 08:55:05 +0000 Subject: Now files, forums and image cache create their storage dirs themselves, instead of createentities (when they do not already exists that is...) --- forum/utils/imagecache.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'forum/utils/imagecache.php') diff --git a/forum/utils/imagecache.php b/forum/utils/imagecache.php index aae5e66..ac3ebc3 100644 --- a/forum/utils/imagecache.php +++ b/forum/utils/imagecache.php @@ -40,6 +40,16 @@ function getCachedImage($filename) global $IMAGECACHE; $fullfilename = $IMAGECACHE . "/" . urlencode($filename); + // Test the storage dir + if(!file_exists($IMAGECACHE)) { + if(!mkdir($IMAGECACHE)) errorImage("Could not create directory: " . $IMAGECACHE); + } + if(!is_dir($IMAGECACHE)) errorImage($IMAGECACHE . " exists but is not a directory"); + if(!is_readable($IMAGECACHE) || !is_writeable($IMAGECACHE) || !is_executable($IMAGECACHE)) { + errorImage($IMAGECACHE . " exists but does not have the correct permissions. (r/w/x)"); + } + // end of dir test + if(!file_exists($fullfilename)) { $url = parse_url($filename); @@ -49,7 +59,7 @@ function getCachedImage($filename) error_reporting(E_ERROR | E_PARSE); - switch(tolower($filetype)) { + switch(strtolower($filetype)) { case ".jpeg": case ".jpg": $image = imagecreatefromjpeg(urldecode($filename)); -- cgit v1.2.3