<?php
require_once ("config.inc.php");

$file	= isset($_REQUEST['f'])	?	$_REQUEST['f']	:	"";
$type	= isset($_REQUEST['t'])	?	$_REQUEST['t']	:	"p";

if ($type == "p")	$file	= PROFILE_IMAGE_URL.$file;
else $file	= STORY_IMAGE_URL.$file;
if (@file_exists($file)) {
	$date	= date("Y-m-d");
	$image_size = @getimagesize($file);
	if ($image_size[2] == "1") {
		$image_type	= 'image/gif';
	} else if ($image_size[2] == "2") {
		$image_type	= 'image/jpeg';
	} else if ($image_size[2] == "3") {
		$image_type	= 'image/png';
	}
	header("Content-Type: " . $image_type);
	header("Last-Modified: " . gmdate('D, d M Y H:i:s \G\M\T', $date));
	header("Expires: " . gmdate('D, d M Y H:i:s \G\M\T', strtotime('+7 day')));
	header("Cache-Control: max-age=5184000");
	header("Accept-Ranges: bytes");
	header("Pragma: cache");
	header("Cache-Control: store, cache");
	@readfile($file);
}
?>