}
// check whether we already downloaded the image
- $files = glob($dir.'/'.$fileName.'.{png,gif,jpg}', GLOB_BRACE | GLOB_NOSORT);
- if ($files === false) throw new IllegalLinkException();
+ $fileLocation = null;
+ foreach (['png','jpg','gif'] as $extension) {
+ if (is_file($dir.'/'.$fileName.'.'.$extension)) {
+ $fileLocation = $dir.'/'.$fileName.'.'.$extension;
+ break;
+ }
+ }
- if (empty($files)) {
+ if ($fileLocation === null) {
try {
// download image
try {
// update mtime for correct expiration calculation
@touch($fileLocation);
}
- else {
- $fileLocation = $files[0];
- }
-
+
$path = FileUtil::getRelativePath(WCF_DIR, dirname($fileLocation)).basename($fileLocation);
$this->executed();