Benutzer-Werkzeuge

Webseiten-Werkzeuge


programmieren:php:programme:fotoalbum

Fotoalbum

File einfach in ein Verzeichnis mit den Bildern.
Die ersten Zeilen des Programms auf die Bedürfnisse anpassen. Fertig - have fun.

nanoalbum.php
<?php
/* 
* NanoAlbum is a simple and small PHP photo album /gallery
* Goals:
* KISS - keep it small and simple
* no database required
* zero configuration / little configuration
* small footprint: basic funtionality in just one single file
* no wasting of display area, use whole screen
* design for modern browsers , html5, css3
* responsive design for mobile devices
* save bandwidth, using Client cache where possible
* provide original photos for download and viewing
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
* installation: https://github.com/oliworx/NanoAlbum/wiki/install
* demo: http://kurmis.com/
* 11.05.2015 - some modifications 2015 by Conny Henn (www.Hennweb.de)
*/
session_start();				// used if counter needed
 
error_reporting(0); 			// 0 do not show errors
@include('config.php');			// you can put your configuration in an extra file
if (!defined('TITLE')) 			define('TITLE','Bilder No1');	// set the title/headline to whatever you like
if (!defined('FOOTER'))			define('FOOTER', '<center>Copyright by Conny Henn - Email: <a href="mailto:Conny@Hennweb.de"> <b>Conny@Hennweb.de</b></a><br><h2>Ich habe einiges neu programmiert.<br>Bitte bei Problemen Bescheid geben. Gruß Conny</h2><hr>Die Bildqualität reicht zum Entwickeln richtiger Bilder nicht aus - bitte mich anmailen<a href="mailto:Conny@Hennweb.de"> <b>Conny@Hennweb.de</b></a></center> ');
if (!defined('THUMBNAIL_SIZE')) define('THUMBNAIL_SIZE',160);	// (160) size of the thumbnails in the album overview (160)
if (!defined('MEDIUM_SIZE'))	define('MEDIUM_SIZE',600);		// (600) size of the image on the preview 
if (!defined('MOBILE_SIZE'))	define('MOBILE_SIZE',600);		// (600) if screen ist smaller, swich to mobile css
if (!defined('PRELOAD_IMAGES'))	define('PRELOAD_IMAGES',true);	// (true) preload next and previous image for faster gallery navigation
if (!defined('CSS_INLINE'))		define('CSS_INLINE', false);	// (true) will use some bandwith but saves one extra http-request
if (!defined('COUNTER'))		define('COUNTER', true);		// (false) will show a Visitor Counter ( a file 'count.txt' will be created )
if (!defined('DOWNLOAD'))		define('DOWNLOAD', true);		// (false) will show a download button
if (!defined('IMG_COUNTER'))	define('IMG_COUNTER', true);	// (true) image counter in subcategories
if (!defined('PREV_IMAGE'))		define('PREV_IMAGE', 1);		// (1) preview image for subcategories (1 = first image / 2 = random image)
if (!defined('BIG_PICTURE'))	define('BIG_PICTURE', false);	// (true) show original picture when click on basis picture
if (!defined('LIKEBUTTON'))		define('LIKEBUTTON', false);	// show Like button, FB, Google+, Twitter
// Language Vars	
define('TXT_COUNTER', " Besucher");					// visitor
define('TXT_IMG_INFO', " klicken für Großansicht");	//  klick to view fullsize
define('TXT_DOWNLOAD', "Download");					// download
 
define('SELF', $_SERVER['SCRIPT_NAME']);
define('BATSU',base64_decode('R0lGODlhEgARALMAAMwzZvzy9eWZstVZgt9/n/XZ4v////LM2c8/b9lljAAAAAAAAAAAAAAAAAAAAAAAACH5BAAHAP8ALAAAAAASABEAAAQ30MhJq7046ynC7VYwDB5FIMUlktOZYqvnbuu8GQECHLd0jiWNKyZESYgX2xEYSrwoAWdvSqVGAAA7'));
$tStart=microtime(true);
 
// incl. counter per Java
//define('TWITTER','<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?\'http\':\'https\';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\'://platform.twitter.com/widgets.js\';fjs.parentNode.insertBefore(js,fjs);}}(document, \'script\', \'twitter-wjs\');</script>');
//define('GOOGLEPLUS','<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone  size="medium" annotation="bubble" recommendations="true" align="left"></g:plusone>');
//define('FACEBOOK','<div class="fb-like" data-href="http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>');
 
// simple - only link - verry fast
//define('TWITTER','<a href="https://twitter.com/intent/tweet?url=http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'&text=YOURPOSTTITLEHERE&via=YOURTWITTERNAMEHERE"><img src="http://hennweb.de/twitter.png" alt="Twitter" title="Twitter" ></a>');
define('GOOGLEPLUS','<a href="https://plus.google.com/share?url=http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'"><img src="http://hennweb.de/google.png" alt="Google+" title="Google+" ></a>');
define('FACEBOOK','<a href="https://facebook.com/sharer.php?u=http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'"><img src="http://hennweb.de/facebook.png" ></a>');
define('TWITTER','<a href="https://twitter.com/share" class="twitter-share-button" data-related="http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].'" data-size="horizontal"  data-lang="de" >Twittern</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> ');
// if nothing changed to what the client has in its cache, just sent the '304 Not Modified' http header
// otherwise send Caching-Information and Etag in http headers and then the content to the client (the browser)
function sendIfChanged($sContent, $iMaxAge=60) {
	header("Pragma: public"); 
	header("Cache-Control: max-age=".$iMaxAge);     // let the browser cache the content
	header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$iMaxAge) . ' GMT'); 
	$sEtag=md5($sContent);
	if ($_SERVER['HTTP_IF_NONE_MATCH'] == $sEtag) {
		// Okay, the browser already has the
		// latest version of our page in his
		// cache. So just tell him that
		// the page was not modified and DON'T
		// send the content -> this saves bandwith and
		// speeds up the loading for the visitor
		header('HTTP/1.1 304 Not Modified');
	} else {  
		header('Etag: '.$sEtag);
		echo $sContent;
	}
}
 
function getCss ($detached=false) {
	$sCss='
body { margin: 0px; padding: 0px ; font: 12px Arial, Helvetica, sans-serif; color: #222; }
header{ background:lightgray;padding-top: 5px;}
img { border: 0px;}
#page {}
#content {}
a {text-decoration: none; color: black;}
a:hover{ color: red;}
h1 { font-size: 2em; }
h2 { font-size: 1.5em; }
h1, h2 {margin: 3px; display: inline;}
ul {margin: 0; padding: 0;}
#social { position: absolute; right: 9px; top: 0px;}
li {list-style:none;display:block;float:left;overflow: hidden;}
ul.albums li {background-color: #ddd; margin: 2px; border: 2px solid #999; border-radius: 7px; font-weight:bold; vertical-align:middle; width:'. (THUMBNAIL_SIZE + 20) .'px; height: '. (THUMBNAIL_SIZE ) .'px ; text-align:center;}
img.thumb {margin: 5px; border: 1px; border-radius: 5px; height:'.round(THUMBNAIL_SIZE*0.75).'px;vertical-align:middle;box-shadow: 3px 2px 5px #aaa;}
ul.albums li img.thumb {max-width:'.THUMBNAIL_SIZE.'px;max-height:130px;}
div.details {text-align:center;white-space : nowrap;}
.preload {max-width: 50px; max-height:50px; display:none;}
div.details img {vertical-align:middle;box-shadow: 3px 2px 5px #aaa;border-radius: 5px;}
div.descr {font-weight:bold; margin:10px;}
a.prevnext {padding:20px 15px; font-size: 60px;color: #999; border: 1px solid #999;border-radius: 5px;box-shadow: 3px 2px 5px #aaa; background-size:118px; background-position:center; background-repeat:no-repeat;}
#footer { text-align:center; font-size: 10px; color: #999; }
#footer a {color: #999;}
a.download {padding:20px 15px 3px; font-size: 17px;color: #999; border: 1px solid #999;border-radius: 5px;box-shadow: 3px 2px 5px #aaa; background-size:118px; background-position:center; background-repeat:no-repeat;}
div.clr {clear:both}
#header {background: #f1f1f1; /* Old browsers */
margin-bottom: 5px;
background: -moz-linear-gradient(top,  #f1f1f1 0%, #a8a8a8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f1f1f1), color-stop(100%,#a8a8a8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* IE10+ */
background: linear-gradient(to bottom,  #f1f1f1 0%,#a8a8a8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#f1f1f1", endColorstr="#a8a8a8",GradientType=0 ); /* IE6-9 */
}
 
@media screen and (max-width: '.MOBILE_SIZE.'px) {
#header { background: gray; }
h1, h2 {font-size:15px}
body {padding: 0px;}
ul.albums li {margin: 1px; border: 1px solid #999; border-radius: 4px; font-weight:normal; width:'. (THUMBNAIL_SIZE - 10) .'px; height: '. (THUMBNAIL_SIZE -20) .'px;}
ul.albums li img.thumb {max-width:'.THUMBNAIL_SIZE.'px;max-height:110px;}
img.thumb { margin: 0 auto; border: none; border-radius: 0; box-shadow:none; height:auto; max-width:'.THUMBNAIL_SIZE.'px; max-height:'.THUMBNAIL_SIZE.'px;}
ul li {margin: 1px 0px 0px 1px; width: '. round(THUMBNAIL_SIZE *0.62) .'px; height: '. round(THUMBNAIL_SIZE *0.62) .'px;}
ul li img.thumb {margin: 0 -5px; }
a.album, #footer {font-size: 9px; }
div.details img {vertical-align:middle;box-shadow: 2px 1px 3px #aaa;  max-width: 250px;}
a.prevnext {padding:20px 15px; font-size: 20px;color: #999; border-radius: 4px; box-shadow: 2px 1px 3px #aaa;text-decoration:none;}
#header {background: #f1f1f1; /* Old browsers */
background: -moz-linear-gradient(top,  #f1f1f1 0%, #a8a8a8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f1f1f1), color-stop(100%,#a8a8a8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* IE10+ */
background: linear-gradient(to bottom,  #f1f1f1 0%,#a8a8a8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#f1f1f1", endColorstr="#a8a8a8",GradientType=0 ); /* IE6-9 */
}}
 
@media screen and (max-width: 330px) {
#header { background: gray; }
h1, h2 {font-size:15px}
div.details img {vertical-align:middle;box-shadow: none; max-width: 240px;}
div.descr {font-size:10px; font-weight:bold; margin:5px;}
#header {background: #f1f1f1; /* Old browsers */
background: -moz-linear-gradient(top,  #f1f1f1 0%, #a8a8a8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f1f1f1), color-stop(100%,#a8a8a8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #f1f1f1 0%,#a8a8a8 100%); /* IE10+ */
background: linear-gradient(to bottom,  #f1f1f1 0%,#a8a8a8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#f1f1f1", endColorstr="#a8a8a8",GradientType=0 ); /* IE6-9 */
}
}
';
 
	if ($detached) {
		header('Content-Type: text/css; charset=UTF-8',true);
		sendIfChanged($sCss, 5000);
		exit();
	}
 
	return $sCss;
}
 
function getPage ($sContent, $sHeadline = '', $sTitle = "") {
	global $tStart;
	header('Content-Type: text/html; charset=UTF-8',true);
	if (CSS_INLINE)
		$sCssTag = '<style type="text/css">'.getCss().'</style>';
	else
		$sCssTag = '<link type="text/css" rel="stylesheet" href="'.SELF.'?css">';
 
	if (COUNTER)
		$counter = counter().TXT_COUNTER;
	else
		$counter = '';
 
	if (LIKEBUTTON)
		$likebutton = '<div id="social" >'.TWITTER.GOOGLEPLUS.FACEBOOK.'</div>';
	else
		$likebutton = "";
 
	$sHtml='<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
<script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
/**
 * jQuery Plugin to obtain touch gestures from iPhone, iPod Touch and iPad, should also work with Android mobile phones (not tested yet!)
 * Common usage: wipe images (left and right to show the previous or next image)
 * 
 * @author Andreas Waltl, netCU Internetagentur (http://www.netcu.de)
 * @version 1.1.1 (9th December 2010) - fix bug (older IE s had problems)
 * @version 1.1 (1st September 2010) - support wipe up and wipe down
 * @version 1.0 (15th July 2010)
 */
(function($) { 
   $.fn.touchwipe = function(settings) {
     var config = {
    		min_move_x: 20,
    		min_move_y: 20,
 			wipeLeft: function() { },
 			wipeRight: function() { },
 			wipeUp: function() { },
 			wipeDown: function() { },
			preventDefaultEvents: true
	 };
 
     if (settings) $.extend(config, settings);
 
     this.each(function() {
    	 var startX;
    	 var startY;
		 var isMoving = false;
 
    	 function cancelTouch() {
    		 this.removeEventListener("touchmove", onTouchMove);
    		 startX = null;
    		 isMoving = false;
    	 }	
 
    	 function onTouchMove(e) {
    		 if(config.preventDefaultEvents) {
    			 e.preventDefault();
    		 }
    		 if(isMoving) {
	    		 var x = e.touches[0].pageX;
	    		 var y = e.touches[0].pageY;
	    		 var dx = startX - x;
	    		 var dy = startY - y;
	    		 if(Math.abs(dx) >= config.min_move_x) {
	    			cancelTouch();
	    			if(dx > 0) {
	    				config.wipeLeft();
	    			}
	    			else {
	    				config.wipeRight();
	    			}
	    		 }
	    		 else if(Math.abs(dy) >= config.min_move_y) {
		    			cancelTouch();
		    			if(dy > 0) {
		    				config.wipeDown();
		    			}
		    			else {
		    				config.wipeUp();
		    			}
		    		 }
    		 }
    	 }
 
    	 function onTouchStart(e)
    	 {
    		 if (e.touches.length == 1) {
    			 startX = e.touches[0].pageX;
    			 startY = e.touches[0].pageY;
    			 isMoving = true;
    			 this.addEventListener("touchmove", onTouchMove, false);
    		 }
    	 }    	 
    	 if ("ontouchstart" in document.documentElement) {
    		 this.addEventListener("touchstart", onTouchStart, false);
    	 }
     });
 
     return this;
   };
 
 })(jQuery);
// -->
</script>
<title>'.($sTitle?$sTitle:TITLE).'</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
'.$sCssTag.'
</head>
<body>
<header>
<h1>'.TITLE.'</h1>
		<div id="header">   
			<h2><a accesskey="1" href="./">Start </a>'.$sHeadline.'</h2>
			'.$likebutton.'
		</div>
</header>
'.$sContent.'
<footer>
	<div id="footer">	
		'.$counter.'
		'.FOOTER.'
	</div>
</footer>
</body>
</html>';
    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 = '<br><a class="download" href="'.url_encode($filepath).'" download="'.$file.'">'.TXT_DOWNLOAD.'</a>';
	else
		$download = '';
 
	$sHtml='<div class="details">';
	if ($path != '.')
		$sHeadline=' &gt;&nbsp;<a href="'.getAlbumUrl($path).'" title="go to album '.$path.'">'.$path.'</a>';
	if ($pref)
		$sHtml.='
	<a style="text-decoration:none;" class="prevnext" href="'.getDetailsUrl($path.'/'.$pref).'"><</a>';
 
	if (BIG_PICTURE)
		$sHtml.='<a id="img" href="'.url_encode($filepath).'" title="'.$file.TXT_IMG_INFO.' "><img alt="'.$file.'" src="'.getThumbUrl($filepath,MEDIUM_SIZE).'"></a>';
	else
		$sHtml.='<a id="img" title="'.$file.' "><img alt="'.$file.'" src="'.getThumbUrl($filepath,MEDIUM_SIZE).'"></a>';
 
	if ($next)
		$sHtml.='
	<a style="text-decoration:none;" class="prevnext" href="'.getDetailsUrl($path.'/'.$next).'">&gt;</a>';
	$sHtml.='
	<div class="descr">
		'.$file.$download.'
	</div>
	</div>';
 
 
	if (PRELOAD_IMAGES) { // preload prev/next image
		if ($next)
		$sHtml.='<img class="preload" alt="next image" src="'.getThumbUrl($path.'/'.$next,MEDIUM_SIZE).'">';
		if ($pref)
		$sHtml.='<img class="preload" alt="previous image" src="'.getThumbUrl($path.'/'.$pref,MEDIUM_SIZE).'">';
	} 
 
	// for swipe effect
	$sHtml.='
	<script>
		$("#img").touchwipe({
		 wipeLeft: function() { window.location.replace("'.getDetailsUrl($path.'/'.$pref).'"); },
		 wipeRight: function() { window.location.replace("'.getDetailsUrl($path.'/'.$next).'"); },
		 min_move_x: 20,
		 min_move_y: 20,
		 preventDefaultEvents: true
		});
	</script>
	';
	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 class=\"thumb\" alt=\"".$aImages[$iMiddle]."\" src=\"".getThumbUrl($directory.'/'.$aImages[$iMiddle])."\"><br>".$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=' &gt; '.$directory;
		$directory.='/';
	}
	foreach ($aDirs as $sFile)
		$sAlbums.="
			<li><a class=\"album\" href=\"".getAlbumUrl($directory.$sFile)."\" >".$sFile.'<br>'.getAlbumThumbnail($directory.$sFile)."</a></li>";
	foreach ($aImages as $sFile)
		$sThumbs.="
			<li><a href=\"".getDetailsUrl($directory.$sFile)."\"><img class=\"thumb\" alt=\"$sFile\" title=\"$sFile\" src=\"".getThumbUrl($directory.$sFile)."\"></a></li>";
	if ($sAlbums)      
		$sAlbums ='
		<ul class="albums">'.$sAlbums.'</ul>
		<div class="clr"></div>';		// make a proper unordered list, stop floating
	if ($sThumbs)
		$sThumbs ='
		<ul>'.$sThumbs.'</ul>
		<div class="clr"></div>'; 		// make a proper unordered list
	return($sAlbums.$sThumbs);
}
 
$sHeadline = $sTitle = '';
if ($_REQUEST['t'])							// get thumbnail with the given path and filename
	getThumbImage($_REQUEST['t']);
elseif ($_REQUEST['m'])						// get mid size image with the given path and filename
	getThumbImage($_REQUEST['m'],MEDIUM_SIZE);
elseif (isset($_GET['css']))				// get css file
	getCss(true);
elseif ($_REQUEST['d'])						// get foto page with midsize thumbnail ( details)
	$sHtml=getDetails($_REQUEST['d'], $sHeadline, $sTitle);
else										// get album of images
	$sHtml=getAlbum($_REQUEST['a'], $sHeadline, $sTitle);
getPage($sHtml, $sHeadline, $sTitle);		// create the entire html-Page
 
function counter() {
if (empty($_SESSION['zaehler'])) {
    $_SESSION['zaehler'] = 1;
 
	$handle = fopen("count.txt", "c+" ); 
	$aufruf=fgets($handle,100); 
	$aufruf=$aufruf+1; 
	rewind($handle); 
	fputs($handle,$aufruf);  
	fclose( $handle );
} else {
	$handle = fopen("count.txt", "c+" ); 
	$aufruf=fgets($handle,100); 
	fclose( $handle );
}
return $aufruf;
}
?>
Cookies helfen bei der Bereitstellung von Inhalten. Diese Website verwendet Cookies. Mit der Nutzung der Website erklären Sie sich damit einverstanden, dass Cookies auf Ihrem Computer gespeichert werden. Außerdem bestätigen Sie, dass Sie unsere Datenschutzerklärung gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website. Weitere Information
programmieren:php:programme (47 views) · Zuletzt geändert: 04/10/2020 16:52 von conny