From ce7d5305e892a54c3e6021410e7c5f2281f985bc Mon Sep 17 00:00:00 2001 From: rylon Date: Sat, 14 Jun 2014 02:55:47 +0200 Subject: [PATCH] updated file HEADER-sending --- files/files.php | 5 ++++- system/HEADER.php | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/files/files.php b/files/files.php index 4475c54..1690800 100644 --- a/files/files.php +++ b/files/files.php @@ -21,7 +21,10 @@ class files { if (!in_array($id, $folder)) { throw new \SYSTEM\LOG\ERROR("No matching ID '" . $id . "' found.");} - \SYSTEM\HEADER::PNG(); + $ext = pathinfo(self::$folders[$cat].$id); + $ext = strtoupper(array_key_exists('extension', $ext) ? $ext['extension'] : ''); + if(\SYSTEM\HEADER::available($ext)){ + call_user_func('\SYSTEM\HEADER::'.$ext);} return file_get_contents(self::$folders[$cat].$id); } diff --git a/system/HEADER.php b/system/HEADER.php index 3dd8ae1..7e13fc7 100644 --- a/system/HEADER.php +++ b/system/HEADER.php @@ -15,10 +15,21 @@ class HEADER { public static function JSON(){ if(self::checkHeader()){ header('Access-Control-Allow-Origin: *');//allow cross domain calls - header('content-type: application/json');} - } + header('content-type: application/json');}} public static function PNG(){ if(self::checkHeader()){ - header('content-type:image/png;');} - } + header('content-type:image/png;');}} + public static function JPG(){ + if(self::checkHeader()){ + header('content-type:image/jpeg;');}} + public static function JPEG(){ + if(self::checkHeader()){ + header('content-type:image/jpeg;');}} + public static function GIF(){ + if(self::checkHeader()){ + header('content-type:image/gif;');}} + + public static function available($datatype){ + $datatype = strtoupper($datatype); + return \method_exists('\SYSTEM\HEADER', $datatype);} } \ No newline at end of file