Last active
August 29, 2015 14:06
-
-
Save karpstrucking/8e86502c27eaa2182021 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
private function outputImage($filepath){ | |
$info = UniteFunctionsRev::getPathInfo($filepath); | |
$ext = $info["extension"]; | |
$filetime = filemtime($filepath); | |
$ext = strtolower($ext); | |
if($ext == "jpg") | |
$ext = "jpeg"; | |
$allowed = array( "bmp", "gif", "jpeg", "png", "tga", "thm", "tif", "tiff" ); | |
if ( ! in_array( $ext, $allowed ) ) | |
exit(); | |
$numExpires = 31536000; //one year | |
$strExpires = @date('D, d M Y H:i:s',time()+$numExpires); | |
$strModified = @date('D, d M Y H:i:s',$filetime); | |
$contents = file_get_contents($filepath); | |
$filesize = strlen($contents); | |
header("Last-Modified: $strModified GMT"); | |
header("Expires: $strExpires GMT"); | |
header("Cache-Control: public"); | |
header("Content-Type: image/$ext"); | |
header("Content-Length: $filesize"); | |
echo $contents; | |
exit(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment