From 5fe7469d4b113139de85a233114c9c9fb9595373 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Thu, 19 Jan 2017 16:29:27 +0100 Subject: [PATCH] Make ImageProxy compatible with non-GNU operating systems --- .../files/lib/action/ImageProxyAction.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/action/ImageProxyAction.class.php b/wcfsetup/install/files/lib/action/ImageProxyAction.class.php index 10cce82c49..19bcd46c43 100644 --- a/wcfsetup/install/files/lib/action/ImageProxyAction.class.php +++ b/wcfsetup/install/files/lib/action/ImageProxyAction.class.php @@ -57,10 +57,15 @@ class ImageProxyAction extends AbstractAction { } // 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 { @@ -116,10 +121,7 @@ class ImageProxyAction extends AbstractAction { // update mtime for correct expiration calculation @touch($fileLocation); } - else { - $fileLocation = $files[0]; - } - + $path = FileUtil::getRelativePath(WCF_DIR, dirname($fileLocation)).basename($fileLocation); $this->executed(); -- 2.20.1