updated file HEADER-sending

This commit is contained in:
Ulf Gebhardt 2014-06-14 02:55:47 +02:00
parent 6ad48f80a7
commit ce7d5305e8
2 changed files with 19 additions and 5 deletions

View File

@ -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);
}

View File

@ -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);}
}