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

require_once('conf.php');

$id = null;
$path = null;

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

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

} elseif(isset($_GET['path'])) {
	
	$path = LIBRARY_PATH.'/'.ltrim($_GET['path'], '/');
	
	if(get_magic_quotes_gpc()) {
		$path = stripslashes($path);
	}
}

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


	$db = new PDO('sqlite:'.DATABASE_PATH);
	
	foreach($db->query('SELECT V.ZTHUMBNAILPREVIEWPATH, V.ZFULLSIZEPREVIEWPATH, F.ZLIBRARYRELATIVEPATH FROM ZRKVERSION AS V, ZRKFOLDER AS F WHERE V.ZPROJECTUUID=F.ZUUID AND V.Z_PK='.$id) as $row) {
			
		$path = LIBRARY_PATH.'/'.$row['ZLIBRARYRELATIVEPATH'].'/'.$row['ZTHUMBNAILPREVIEWPATH'];
	
		//use full size preview if the thumbnail is not readable for some reason.
		if(!is_readable($path)) {
			$path = LIBRARY_PATH.'/'.$row['ZLIBRARYRELATIVEPATH'].'/'.$row['ZFULLSIZEPREVIEWPATH'];
		}
	}
}

if(isset($path)) {

	if(is_readable($path)) {

		header('Content-Type: image/jpeg');
		header('Last-Modified: '.date('r', filemtime($path)));
			
		readfile($path);
	} else {
	
		header('Content-Type: text/plain; charset=UTF-8');
	
		echo($path.' is not readable');
	}
}

?>
Return current item: PHPture