Hab jetzt mal doch das eine von oben gefunden und angepasst, ich hoffe mal ich hab’s nicht verschlimmbessert, so dolle ist es mit meinen PHP Kenntnissen nicht. Leider Existiert der Autor des ursprünglichen Scriptes nicht mehr, zumindest nicht mehr seine Seiten, aber das Script läuft immerhin unter der GPL ;). http://www.e-hahn.de/grafik/fotoalbum/gallery.php PHP-Code: <?php
/*
THEPICS lite - a picture gallery generator
Copyright (C) 2001-2003
Website: http://d0x.codesociety.com/
Email: [email protected]
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
*/
/************ THEPICS lite CONFIGURATION ************/
// Name of your gallery
$subject = "Gallery";
// Short description of your gallery.
$description = "Thumbnailübersicht";
// How many images to output per row
$imagesPerRow = 4;
// How many images to output per page
$imagesPerPage = 32;
// Gallery sort order [ alpha | date ]
$sort = "alpha";
// Height of each thumbnail
$thumbHeight = 96;
// Width of each thumbnail. NOTE: Width takes precedence
$thumbWidth = 128;
// Debugging
$showdebug = "1"; //Set to "1" to show the page generation time
//error_reporting(E_ALL); //Uncomment this to show all warnings and errors.
//phpinfo(); //Uncomment this to display PHP info.
/************ END THEPICS lite CONFIGURATION ************/
$mtime = explode(" ", microtime()); //debug timer
$starttime = $mtime[1] + $mtime[0];
//Styles
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
<html>
<head>
<title>www.e-hahn.de</title>
<meta http-equiv='Content-Language' content='de'>
<meta name='Autor' content='Enrico Hahn'>
<meta name='Copyright' content='Copyright 2005 by Enrico Hahn.'>
<meta name='Generator' content='Microsoft Visual Studio .NET 7.1'>
<meta name='Language' content='Deutsch,German,de,at,ch'>
<meta name='vs_targetSchema' content='http://schemas.microsoft.com/intellisense/ie5'>
<meta name='Keywords' content='Enrico Hahn, Scotty, e-hahn, e-hahn Soft, DOTNET, VisualBasic, Neuruppin, Ostprignitz-Ruppin, Softwareentwicklung, VB .NET GUI-Design, Webdesign, Updater, Easy Desktop Note, StarTrek Infos'>
<style type='text/css'>
<!--
a:active { text-decoration: none; color: #000080}
a:link { font : Standert; text-decoration: none; color: #000080}
a:visited { text-decoration: none; color: #000080}
a:hover { text-decoration: underline; color: #000080}
-->
</style>
<script type='text/javascript' src='gallery_popup.js'></script>
</head>
<body style='FONT-FAMILY: Arial, Verdana; TEXT-DECORATION: none' bgColor='#F7F5F2'>
<div align='center'><FIELDSET style='width: 680px'><LEGEND><STRONG>$subject</STRONG></LEGEND>";
//Code
if (isset($_GET['pic'])) {
$picsdir = preg_replace("/gallery.php/", "", $_SERVER['SCRIPT_FILENAME']);
$dir = opendir($picsdir);
while ($dirdata = readdir($dir)) {
if (eregi("\.jpg", $dirdata)) {
$main[] = $dirdata;
$picdates[] = filemtime($dirdata);
}
}
closedir($dir);
if($sort == "date") {
arsort($picdates, SORT_NUMERIC);
}
else {
natcasesort($main); //Sort pictures alphabetically
}
$pickey = ($sort == "date") ? array_keys($picdates) : array_keys($main);
$curPic = array_search($_GET['pic'], $main);
$nextkey = $pickey[0];
while ($nextkey != $curPic) {
$nextkey = next($pickey);
}
$nextkey = next($pickey);
$page_next = ($pickey[$curPic] != count($main)-1) ? " <A href='gallery.php?pic={$main[$nextkey]}' title='nächstes Foto'><IMG src='http://www.e-hahn.de/grafik/showfoto_next.gif' border='0'></A>" : "";
prev($pickey);
$prevkey = prev($pickey);
$page_prev = ($curPic != $pickey[0]) ? "<A href='gallery.php?pic={$main[$prevkey]}' title='vorheriges Foto'><IMG src='http://www.e-hahn.de/grafik/showfoto_prev.gif' border='0'></A> " : "";
// Make sure the file exists
if (file_exists($_GET['pic'])) {
$desc = stripslashes(preg_replace("/.jpg/", "", $_GET['pic']));
echo "<TABLE id='Table_Fotoalbum_ShowFoto_Nav' width='640' align='center' border='0'>
<TR>
<TD align='center'><FONT size='2'>[ <A href='gallery.php'>$description</A> ] - [ <A href='http://www.e-hahn.de/sonstiges/fotoalbum.php' title='Fotoalbum - Übersicht'>e-hahn.de - Fotoalbum</A> ]</FONT></TD>
<TD align='right' width='200'><FONT size='2'>{$page_prev}{$page_next}</FONT></TD>
</TR>
</TABLE>
<IMG src=\"{$_GET['pic']}\" border=\"1\" alt=\"$desc\" />";
}
} else {
$rootdir = preg_replace("/gallery.php/", "", $_SERVER['SCRIPT_FILENAME']);
$picsdir = $rootdir;
$thumbsdir = $rootdir . 'thumbs/';
$thumbpicssitedir = 'thumbs/';
$numberofmainpics = 0;
$dir = opendir($picsdir);
while ($dirdata = readdir($dir)) {
if (eregi("\.jpg", $dirdata)) {
$main[] = $dirdata;
$picdates[] = filemtime($dirdata);
$numberofmainpics++;
}
}
closedir($dir);
$actionlistfile = $main; //temp variables
$numberofactionpics = $numberofmainpics;
// Get mainthumblistfile
$numberofmainpics = 0;
if (file_exists($thumbsdir)) {
$dir = opendir($thumbsdir);
while ($dirdata = readdir($dir)) {
if (eregi("\.jpg", $dirdata)) {
$mainthumbs[] = $dirdata;
}
}
closedir($dir);
} else {
if (!@mkdir($thumbsdir, 0777)) {
echo "Error: Did you CHMOD the installation directory to 777 ?<BR />";
}
}
$counter = 0;
$createdhowmanymain = 0;
$createdhowmanyaction = 0;
foreach($main as $mainpic) {
if (!@in_array($mainpic, $mainthumbs)) {
$createmainthumbs[$counter] = $mainpic;
$createdhowmanymain++;
$counter++;
}
}
// Find out if we need to create thumbnails or not
if ($createdhowmanymain > 0) {
foreach($createmainthumbs as $createmain) {
makethumb($picsdir . $createmain, $thumbsdir . $createmain, $thumbWidth, $thumbHeight);
}
}
if ($description != "") {
$showDescription = "<FONT size='2'><STRONG>$description</STRONG> ( <FONT color='#800000'>$numberofactionpics</FONT> Fotos )</FONT><BR /><BR />";
}
// The follow lines control the Gallery Header.
echo "$showDescription <FONT size='2'>[ <A href='http://www.e-hahn.de/sonstiges/fotoalbum.php' title='Fotoalbum - Übersicht'>e-hahn.de - Fotoalbum</A> ]</FONT>";
// Set inital row and column counts to 1
$actionrow = 1;
$actioncol = 0;
if($sort == "date") {
arsort($picdates, SORT_NUMERIC);
}
else {
natcasesort($actionlistfile); //Sort pictures alphabetically
}
$pickey = ($sort == "date") ? array_keys($picdates) : array_keys($actionlistfile);
echo '<TABLE>';
$multiPage = "";
$totalpages = ceil($numberofactionpics / $imagesPerPage);
$_GET['page'] = isset($_GET['page']) ? $_GET['page'] : 0;
if ($totalpages > 1) {
if (($numberofactionpics - $_GET['page']) <= $imagesPerPage) { // no next page
$page_next = "<IMG src='http://www.e-hahn.de/grafik/showfoto_next.gif' border='0'>";
} else {
$nextpage = $_GET['page'] + $imagesPerPage;
$page_next = "<A href='gallery.php?page={$nextpage}' title='nächste Seite'><IMG src='http://www.e-hahn.de/grafik/showfoto_next.gif' border='0'></A>";
}
$thepages = "";
for($temp = 0; $temp < $totalpages; $temp++) {
$gotopage = $temp * $imagesPerPage;
$temp_pagenum = $temp + 1;
$thepages .= ($_GET['page'] == $gotopage) ? "<STRONG>{$temp_pagenum}</STRONG> " : "<a href='gallery.php?page={$gotopage}'>{$temp_pagenum}</a> ";
}
if ($_GET['page'] == 0) { // no prev page
$page_previous = "<IMG src='http://www.e-hahn.de/grafik/showfoto_prev.gif' border='0'>";
} else {
$previouspage = $_GET['page'] - $imagesPerPage;
$page_previous = "<A href='gallery.php?page={$previouspage}' title='vorheriges Seite'><IMG src='http://www.e-hahn.de/grafik/showfoto_prev.gif' border='0'></A>";
}
$multiPage = "<FONT size='8'>{$page_previous} {$thepages} {$page_next}</FONT>";
}
if (($_GET['page'] + $imagesPerPage) > $numberofactionpics) {
$imagesPerPage = $numberofactionpics % $_GET['page'];
$imagesPerPage = $imagesPerPage ? $imagesPerPage : $numberofactionpics;
}
// Output the actual images
for($x = $_GET['page']; $x < ($_GET['page'] + $imagesPerPage) ; $x++) {
if ($actioncol == 0) {
echo '<TR>';
}
$sizetemp = preg_replace("/ /", "%20", $actionlistfile[$pickey[$x]]);
$picname = addslashes($sizetemp);
$desc = preg_replace("/.jpg/i", "", $actionlistfile[$pickey[$x]]);
$sizer = $picsdir . $sizetemp;
$openPic = "<a href=\"gallery.php?pic=$picname\"";
echo '<TD align="center" style="width: 150px">
<A ', $openPic , '><img src="thumbs/', $sizetemp , '"border="1" alt="', $desc, '" /></A></TD>';
$actioncol++;
if ($actioncol == $imagesPerRow) {
$actioncol = 0;
echo '</TR>';
}
}
echo "<TR><TD colspan='{$imagesPerRow}' align='center'>$multiPage</TD></TR></TABLE>";
$mtime = explode(" ", microtime());
$totaltime = round((($mtime[1] + $mtime[0]) - $starttime), 5);
$debug = "";
if ($showdebug == 1) {
$debug = "Diese Thumbnailgallery wurde in {$totaltime} Sekunden erzeugt.";
}
}
// Version info
$debug = isset($debug) ? $debug : "";
echo '<FONT size="2">', $debug, '</FONT>
</FIELDSET>
</div>
</body>
</html>';
function makethumb($image, $filename, $newwidth, $newheight)
{
$imagequality = 70;
$size = getimagesize($image);
$ratio = $newwidth / $newheight;
if ($im = @imagecreatefromjpeg($image)) {
if ($newheight && ($size[0] < $size[1])) {
$newwidth = ($newheight / $size[1]) * $size[0];
} else {
$newheight = ($newwidth / $size[0]) * $size[1];
}
$im2 = imagecreatetruecolor($newwidth, $newheight);
// Version Dependant setting
// imageantialias($im2, TRUE); //for PHP 4.3.2 and up only
imagecopyresized($im2, $im, 0, 0, 0, 0, $newwidth, $newheight, $size[0], $size[1]);
if (@imagejpeg($im2, $filename, $imagequality)) {
return true;
} else {
echo "Error: Did you CHMOD the installation directory to 777 ?<BR />";
}
}
echo "Error: Thumbnail creation failed for <STRONG>{$filename}</STRONG>. Is the original picture corrupted?<BR />";
return false;
}
?> |