From 222b0a64c1ef0146aa75acd55f71907eeb1c9af0 Mon Sep 17 00:00:00 2001 From: user Date: Wed, 14 Nov 2012 09:56:43 -0400 Subject: [PATCH] Adding code to put content in the header of images at time to response the client. --- workflow/public_html/bootstrap.php | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/workflow/public_html/bootstrap.php b/workflow/public_html/bootstrap.php index a023a91d7..7f04e3f8b 100755 --- a/workflow/public_html/bootstrap.php +++ b/workflow/public_html/bootstrap.php @@ -58,14 +58,27 @@ define( 'PATH_OUTTRUNK', $pathOutTrunk ); define( 'PATH_HTML', PATH_HOME . 'public_html' . PATH_SEP ); //this is the first path, if the file exists... -if (file_exists(PATH_HTML . $_SERVER['REQUEST_URI'])) { - if (!is_file(PATH_HTML . $_SERVER['REQUEST_URI'])) { +$requestFile = PATH_HTML . $_SERVER['REQUEST_URI']; +if (file_exists($requestFile)) { + if (!is_file($requestFile)) { header( "location: /errors/error404.php?url=" . urlencode( $_SERVER['REQUEST_URI'] ) ); - die(); + die; } - //we are missing the header part - //to do: add header mime part - readfile(PATH_HTML . $_SERVER['REQUEST_URI']); + $pos = strripos($requestFile, ".") + 1; + $size = strlen($requestFile); + if($pos < $size) { + //if this file got an extension then assign the content + $ext_file = substr($requestFile, $pos, $size); + if ($ext_file == "gif" || $ext_file == "png" || $ext_file == "jpg") { + $ext_file = 'image/'.$ext_file ; + } elseif ($ext_file=="css") { + //may this line be innecesary, all the css are been generated at run time + $ext_file = 'css/'.$ext_file; + } + header ('Content-Type: ' . $ext_file); + } + header ('Pragma: cache'); + readfile($requestFile); die; }