From bab47f19ff4038079792f75cf29347dbb1c0a796 Mon Sep 17 00:00:00 2001 From: Tom B Date: Fri, 1 Aug 2014 18:31:10 +0100 Subject: [PATCH] That later date is right now, apparently --- public/viewer.php | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/public/viewer.php b/public/viewer.php index 713e495..dee57f2 100644 --- a/public/viewer.php +++ b/public/viewer.php @@ -12,19 +12,21 @@ $type = $_GET['type']; $file = $_GET['file']; -if (RAW_IMAGE) { - $filelocation = __DIR__ . "/images/$type/$file.$type"; +$filelocation = __DIR__ . "/images/$type/$file.$type"; + +if ( ! file_exists($filelocation)) { + header("HTTP/1.0 404 Not Found"); + include_once(__DIR__ . '/../app/templates/error.phtml'); + die(); +} - if ( ! file_exists($filelocation)) { - header("HTTP/1.0 404 Not Found"); - include_once(__DIR__ . '/../app/templates/error.phtml'); - die(); - } +$filesize = filesize($filelocation); +if (RAW_IMAGE) { $filecontents = fopen($filelocation, 'rb'); header("Content-type: image/$type"); - header("Content-length: " . filesize($filelocation)); + header("Content-length: " . $filesize); fpassthru($filecontents); exit; @@ -34,15 +36,5 @@ $time = $time[1] + $time[0]; $start = $time; - $filelocation = __DIR__ . "/images/$type/$file.$type"; - - if ( ! file_exists($filelocation)) { - header("HTTP/1.0 404 Not Found"); - include_once(__DIR__ . '/../app/templates/error.phtml'); - die(); - } - - $filesize = filesize($filelocation); - require_once(__DIR__ . '/../app/templates/viewer.phtml'); }