Keine Ahnung. Das Skript ist eh komisch.
Du hast ja gesagt, dass der Fehler nicht kommt, wenn mehrere Seiten da sind. Als Schnell-Lösung habe ich jetzt eingefügt, dass wenn [anzahlBilderProSeite] kleiner ist als [anzahlBilderÜberhaupt], dass dann [anzahlBilderProSeite] halbiert wird, damit es weitere Seiten gibt und der Fehler nicht mehr kommt. Und, dass wen ?page nicht gesetzt ist, dass es automatisch 1 wird.
Klappt das so?
<?php
/*
THEPICS lite - a picture gallery generator
Copyright (C) 2001-2003
Website: http://d0x.codesociety.com/
Email: d0x@codesociety.com
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 ************/
$pathToImagesDir = "images/";
// Name of your gallery
$subject = "Gallery";
// Short description of your gallery.
$description = "Übersicht";
// How many images to output per row
$imagesPerRow = 4;
// How many images to output per page
$imagesPerPage = 5;
// Gallery sort order [ alpha | date ]
$sort = "alpha";
// Height of each thumbnail
$thumbHeight = 50;
// Width of each thumbnail. NOTE: Width takes precedence
$thumbWidth = 50;
if (!$_GET['page'])
$_GET['page'] = 1;
// Debugging
$showdebug = "0"; //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.01 Transitional//EN'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<title>Depo-Fit-Entspannung</title>
<link rel='stylesheet' type='text/css' media='screen, projection' href='../stylesheet.css'>
<link rel='shortcut icon' href='../favicon.ico>
<style type='text/css'>
</head>
<div id='galerie'><body>
<div align='center'><FIELDSET style='width: 680px'><LEGEND><STRONG>$subject</STRONG></LEGEND>";
//Code
if (isset($_GET['pic'])) {
$picsdir = $pathToImagesDir;
$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='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='grafik/showfoto_prev.gif' border='0'></A> " : "";
// Make sure the file exists
if (file_exists($picsdir.$_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='3'>[ <A href='gallery.php'>$description</A> ]</FONT></TD>
<TD align='right' width='200'><FONT size='2'>{$page_prev}{$page_next}</FONT></TD>
</TR>
</TABLE>
<IMG src=\"{$picsdir}{$_GET['pic']}\" border=\"1\" alt=\"$desc\" width=\"600\" />";
}
} else {
$rootdir = $pathToImagesDir;
$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='3'><STRONG>$description</STRONG> ( <FONT color='#800000'>$numberofactionpics</FONT> Fotos )</FONT><BR /><BR />";
}
// The follow lines control the Gallery Header.
echo "$showDescription
<FONT size='16'></FONT>";
if ($numofactionpics < $imagesPerPage)
$imagesPerPage = (round($imagesPerPage/2));
// 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='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='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 = "<grafik/showfoto_prev.gif' border='0'>";
} else {
$previouspage = $_GET['page'] - $imagesPerPage;
$page_previous = "<A href='gallery.php?page={$previouspage}' title='vorherige Seite'><IMG src='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="'.$picsdir.'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></div>
</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;
}
?>
Alles anzeigen