Location: PHPKode > projects > PHPture > phpture/image.preview.php
<?php

require_once('conf.php');

$id = null;
$path = null;
$filename = null;

if(isset($_GET['id'])) {

	$id = intval($_GET['id']);
}

if(isset($id) && $id > 0) {

	$db = new PDO('sqlite:'.DATABASE_PATH);
	
	foreach($db->query('SELECT V.ZFILENAME, V.ZFULLSIZEPREVIEWPATH, F.ZLIBRARYRELATIVEPATH FROM ZRKVERSION AS V, ZRKFOLDER AS F WHERE V.ZPROJECTUUID=F.ZUUID AND V.ZVERSIONID='.$id) as $row) {
			
		$path = LIBRARY_PATH.'/'.$row['ZLIBRARYRELATIVEPATH'].'/'.$row['ZFULLSIZEPREVIEWPATH'];
		$filename = $row['ZFILENAME'];
	}
}

if(isset($path) && is_readable($path)) {

	header('Content-Type: image/jpeg');	
	
	if(!empty($filename)) {
		header('Content-Disposition: inline; filename="'.$filename.'"');
	}
	
	header('Last-Modified: '.date('r', filemtime($path)));
			
	readfile($path);
}

?>
Return current item: PHPture