Make ImageProxy compatible with non-GNU operating systems
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 19 Jan 2017 15:29:27 +0000 (16:29 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 19 Jan 2017 15:29:53 +0000 (16:29 +0100)
wcfsetup/install/files/lib/action/ImageProxyAction.class.php

index 10cce82c49d04a010751a894ae692e46fc584544..19bcd46c43d9e884941f708844dbaf3582d42d3f 100644 (file)
@@ -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();