%PDF- %PDF-
| Direktori : /home/cargonizer/domains/cargonizer.com.tr/private_html/ |
| Current File : /home/cargonizer/domains/cargonizer.com.tr/private_html/picture.php |
<?php
@session_start();
@ob_start();
include 'includes/functions.php';
include 'includes/db.php';
$id = intval("0". $_GET["id"]);
$rs = getTable('files',"WHERE id='{$id}'");
$w = intval("0". $_GET['w']);
$h = intval("0". $_GET['h']);
function getRequestHeaders() {
if (function_exists("apache_request_headers")) {
if($headers = apache_request_headers()) {
return $headers;
}
}
$headers = array();
// Grab the IF_MODIFIED_SINCE header
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
$headers['If-Modified-Since'] = $_SERVER['HTTP_IF_MODIFIED_SINCE'];
}
return $headers;
}
function displayGraphicFile ($graphicFileName, $fileType='jpeg') {
$fileModTime = filemtime($graphicFileName);
// Getting headers sent by the client.
$headers = getRequestHeaders();
// Checking if the client is validating his cache and if it is current.
if (isset($headers['If-Modified-Since']) && (strtotime($headers['If-Modified-Since']) == $fileModTime)) {
// Client's cache IS current, so we just respond '304 Not Modified'.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fileModTime).' GMT', true, 304);
} else {
// Image not cached or cache outdated, we respond '200 OK' and output the image.
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $fileModTime).' GMT', true, 200);
$imginfo = getimagesize($graphicFileName);
header("Content-type: {$imginfo['mime']}");
header('Content-transfer-encoding: binary');
header('Content-length: '.filesize($graphicFileName));
readfile($graphicFileName);
}
}
if(file_exists("files/cache/{$w}_{$h}_{$rs['file']}")) {
displayGraphicFile("files/cache/{$w}_{$h}_{$rs['file']}");
}
else {
$dosya = "files/". $rs['file'];
include_once "includes/thumbnail.php";
if(!file_exists($dosya) || $dosya == "files/"){
$dosya = "files/nopicture.png";
}
$thumb = new Thumbnail($dosya, $w, $h);
$thumb->show();
$asd = @ob_get_contents();
@ob_end_flush();
file_put_contents("files/cache/{$w}_{$h}_{$rs['file']}",$asd);
}
?>