Redirect to static image in ImageProxyAction
authorTim Düsterhus <duesterhus@woltlab.com>
Tue, 16 Aug 2016 18:18:31 +0000 (20:18 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Tue, 16 Aug 2016 18:22:29 +0000 (20:22 +0200)
This reduces load in case some use tries to be funny and directly
request ImageProxyAction over and over and over again.

wcfsetup/install/files/lib/action/ImageProxyAction.class.php

index e7c43e541d7d4a67942b0ae48f0c040e1b4ee94e..7cb064bb15e5c73346a3ffe326bc9946daf54703 100644 (file)
@@ -47,7 +47,8 @@ class ImageProxyAction extends AbstractAction {
                        
                        // prepare path
                        $fileExtension = pathinfo($url, PATHINFO_EXTENSION);
-                       $fileLocation = WCF_DIR.'images/proxy/'.substr($fileName, 0, 2).'/'.$fileName.($fileExtension ? '.'.$fileExtension : '');
+                       $path = 'images/proxy/'.substr($fileName, 0, 2).'/'.$fileName.($fileExtension ? '.'.$fileExtension : '');
+                       $fileLocation = WCF_DIR.$path;
                        $dir = dirname($fileLocation);
                        if (!@file_exists($dir)) {
                                FileUtil::makePath($dir);
@@ -76,13 +77,9 @@ class ImageProxyAction extends AbstractAction {
                                // update mtime for correct expiration calculation
                                @touch($fileLocation);
                        }
-                       else {
-                               $imageData = getimagesize($fileLocation);
-                       }
                        $this->executed();
                        
-                       @header('Content-Type: '.$imageData['mime']);
-                       @readfile($fileLocation);
+                       HeaderUtil::redirect(WCF::getPath().$path, true, false);
                        exit;
                }
                catch (SystemException $e) {