'.$sContent.'
';
sendIfChanged($sHtml);
}
function fastimagecopyresampled (&$dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h, $quality = 5) {
// Plug-and-Play fastimagecopyresampled function replaces much slower imagecopyresampled.
// Just include this function and change all "imagecopyresampled" references to "fastimagecopyresampled".
// Typically from 30 to 60 times faster when reducing high resolution images down to thumbnail size using the default quality setting.
// Author: Tim Eckel - Date: 09/07/07 - Version: 1.1 - Project: FreeRingers.net - Freely distributable - These comments must remain.
//
// Optional "quality" parameter (defaults is 3). Fractional values are allowed, for example 1.5. Must be greater than zero.
// Between 0 and 1 = Fast, but mosaic results, closer to 0 increases the mosaic effect.
// 1 = Up to 350 times faster. Poor results, looks very similar to imagecopyresized.
// 2 = Up to 95 times faster. Images appear a little sharp, some prefer this over a quality of 3.
// 3 = Up to 60 times faster. Will give high quality smooth results very close to imagecopyresampled, just faster.
// 4 = Up to 25 times faster. Almost identical to imagecopyresampled for most images.
// 5 = No speedup. Just uses imagecopyresampled, no advantage over imagecopyresampled.
if (empty($src_image) || empty($dst_image) || $quality <= 0) { return false; }
if ($quality < 5 && (($dst_w * $quality) < $src_w || ($dst_h * $quality) < $src_h)) {
$temp = imagecreatetruecolor ($dst_w * $quality + 1, $dst_h * $quality + 1);
imagecopyresized ($temp, $src_image, 0, 0, $src_x, $src_y, $dst_w * $quality + 1, $dst_h * $quality + 1, $src_w, $src_h);
imagecopyresampled ($dst_image, $temp, $dst_x, $dst_y, 0, 0, $dst_w, $dst_h, $dst_w * $quality, $dst_h * $quality);
imagedestroy ($temp);
} else imagecopyresampled ($dst_image, $src_image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
return true;
}
// Create a thumbnail JPEG and send it to the browser
function getThumbImage ($filepath, $size = THUMBNAIL_SIZE) {
$path = dirname($filepath);
$file = basename($filepath);
$thumbspath=$path.'/.thumbs/'.$size;
$thumbfilename = $thumbspath.'/'.$file;
if (!is_file($thumbfilename)) { // no thumbnail file so far, so create one
if(stristr($file, ".jpg")||stristr($file, ".jpeg") )
$src = imagecreatefromjpeg($filepath);
else die('not supportet');
list($width,$height)=getimagesize($filepath); // get image dimensions
if ($width > $height) {
$newwidth = $size; // landscape
$newheight=round(($height/$width) * $size);
} else {
$newheight = $size; // portrait
$newwidth=round(($width/$height) * $size);
}
$tmp=imagecreatetruecolor($newwidth,$newheight);
fastimagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // generate a new resized image
if (!is_dir($thumbspath))
if(!@mkdir($thumbspath,0755,true)) // 755 is not very secure, but 700 can couse trouble, please try 700 your own
die('sorry, unable to create thumbnail directory, please check permissions');
imageinterlace($tmp, true); // turn interlace on, better for slow connections e.g. on mobile devices
if (!imagejpeg($tmp,$thumbfilename)) { // create and save jpg
header("Content-Type: image/gif",false);
die(BATSU);//die('could not save thumbnail');
}
imagedestroy($src);
imagedestroy($tmp);
}
$expires = 60*60*24*14; // seconds, minutes, hours, days
header("Pragma: public");
header("Cache-Control: maxage=".$expires); // let the browser cache the images
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
header("Content-Type: image/jpeg",false);
header("Content-Length: ".@filesize("$thumbfilename"));
if (!@readfile($thumbfilename)) { // send file content to the browser
header("Content-Type: text/plain",true); // or if not possible
die('could not read file:'.$thumbfilename); // give simple error message
};
exit(); // stop script execution after sending image data
}
function getDetails ($filepath,&$sHeadline, &$sTitle=null) {
$path = dirname($filepath);
$sTitle=$file = basename($filepath);
list($aDirs,$aImages)=getDirectory($path);
$pref=$next=false;
foreach ($aImages as $i => $sFile) {
if ($sFile == $file) { // find previous and next image
if ($i>0) $pref = $aImages[$i-1];
$next = $aImages[$i+1];
break;
}
}
if (DOWNLOAD)
$download = ' '.TXT_DOWNLOAD.'';
else
$download = '';
$sHtml='
';
if ($path != '.')
$sHeadline=' > '.$path.'';
if ($pref)
$sHtml.='
<';
if (BIG_PICTURE)
$sHtml.='';
else
$sHtml.='';
if ($next)
$sHtml.='
>';
$sHtml.='
'.$file.$download.'
';
if (PRELOAD_IMAGES) { // preload prev/next image
if ($next)
$sHtml.='';
if ($pref)
$sHtml.='';
}
// for swipe effect
$sHtml.='
';
return $sHtml;
}
// get all directory entries into a sorted array
function getDir ($directory) {
$aDir=array();
if (empty($directory))
$directory = './';
$handle = openDir($directory);
while (false !== ($sFile=readDir($handle)))
if ($sFile[0] != "." ) // ignore ".", "..", and ".thumbs"
$aDir[]=$sFile;
closeDir($handle);
sort($aDir);
return $aDir;
}
function getDirectory ($directory) {
$aDirs=$aImages=array();
if (empty($directory))
$directory = '.';
$directory.='/';
$handle = openDir($directory);
while (false !== ($sFile=readDir($handle)))
if ($sFile[0] != "." ) { // ignore ".", "..", and ".thumbs"
if (is_dir($directory.$sFile)) {
$aDirs[]=$sFile;
} elseif (stristr($sFile, ".jpg") || stristr($sFile, ".jpeg")) {
$aImages[]=$sFile;
}
}
closeDir($handle);
sort($aDirs);
sort($aImages);
return array($aDirs,$aImages);
}
function url_encode ($filepath) {
return str_replace("%2F", "/", rawurlencode($filepath));
}
function getThumbUrl ($filepath, $size = THUMBNAIL_SIZE) {
$path = dirname($filepath);
$file = basename($filepath);
$thumbspath=$path.'/.thumbs/'.$size;
$thumbfilename = $thumbspath.'/'.$file;
if (!is_file($thumbfilename)) { // no thumbnail so far
if ($size == MEDIUM_SIZE)
return SELF."?m=".urlencode($filepath);
return SELF."?t=".urlencode($filepath);
}
return url_encode($thumbfilename);
}
function getAlbumUrl ($sPath) {
return SELF.'?a='.urlencode($sPath);
}
function getDetailsUrl ($filepath) {
return SELF.'?d='.urlencode($filepath).'#img';
}
// get a image from the middle of an album as the album thumbnail
function getAlbumThumbnail ($directory) {
list($aDirs,$aImages)=getDirectory($directory);
if ($i=count($aImages)) {
if (PREV_IMAGE == 1)
$iMiddle = 1;
ELSE
$iMiddle = round($i/2);
IF (IMG_COUNTER)
$img_counter = $i." Bilder";
ELSE
$img_counter = "";
return " ".$img_counter;
}
return false;
}
function getAlbum($directory, &$sHeadline, &$sTitle=null) {
$sAlbums=$sThumbs='';
$path = dirname($filepath);
list($aDirs,$aImages)=getDirectory($directory);
if ($directory) {
$sTitle=$directory;
$sHeadline=' > '.$directory;
$directory.='/';
}
foreach ($aDirs as $sFile)
$sAlbums.="