djlein
Grünschnabel
Hallo ich sollte eine PHP Galerie in einer Seite integrieren.
Da ich aber nicht so Erfahrungen habe, habe ich dabei einige Probleme.
Kann mir jemand helfen?
Bekomme immer die Meldungen:
Include:
gallery.php
calculate.php
Da ich aber nicht so Erfahrungen habe, habe ich dabei einige Probleme.
Kann mir jemand helfen?
Bekomme immer die Meldungen:
Warning: opendir(images) [function.opendir]: failed to open dir: No such file or directory in /srv/www/websites/sonnaewinkel/krippe/fotogalerie/galerie1/gallery.php on line 135
Warning: readdir(): supplied argument is not a valid Directory resource in /srv/www/websites/sonnaewinkel/krippe/fotogalerie/galerie1/gallery.php on line 136
Warning: closedir(): supplied argument is not a valid Directory resource in /srv/www/websites/sonnaewinkel/krippe/fotogalerie/galerie1/gallery.php on line 144
Warning: opendir(images) [function.opendir]: failed to open dir: No such file or directory in /srv/www/websites/sonnaewinkel/krippe/fotogalerie/galerie1/gallery.php on line 147
Warning: readdir(): supplied argument is not a valid Directory resource in /srv/www/websites/sonnaewinkel/krippe/fotogalerie/galerie1/gallery.php on line 149
Warning: closedir(): supplied argument is not a valid Directory resource in /srv/www/websites/sonnaewinkel/krippe/fotogalerie/galerie1/gallery.php on line 161
Include:
PHP:
<?
include 'krippe/fotogalerie/galerie1/gallery.php';
?>
gallery.php
PHP:
<html>
<head>
<title>Gallery</title>
<meta http-equiv="generator" content="PHP Designer 2005" />
<style>
td {
border:1px solid #999999;
}
.bigtext {
font : 24px Verdana, Arial, Helvetica, sans-serif;
color: #000000;
}
.text {
font : 12px Verdana, Arial, Helvetica, sans-serif;
color: #000000;
}
a{
font : 12px Verdana, Arial, Helvetica, sans-serif;
color: #666666;
text-decoration: none;
}
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<?php
/*
**********************************************************
* *
* Gallery by Christian Fedder 18.03.2005 *
* *
**********************************************************
*/
//<<<<<<<<<<<<<<<<<<<<<<<< KONFIGURATION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
$subdir = "images"; //Bilderverzeichnis
$heading = "Meine Gallery"; //Überschrift
$imagewidth = 120; //Thumbnailbreite (Min 50; Max 200)
$bigimagewidth = 500; //Originalbild-Breite (Min 250; Max 600)
$colums = 4; //Spalten (Min 2; Max 10)
$shadow = false; //Schatten? Ja = true; Nein = False
//<<<<<<<<<<<<<<<<<<<<<< KONFIGURATION ENDE >>>>>>>>>>>>>>>>>>>>>>>>>>
function shadowtable($imagehtml)
{
$output .= "<table style='border-style: none;' cellspacing='0' cellpadding='0' height='100%'>
<tr><td rowspan='2' colspan='2' style='border-style: none;'>
$imagehtml</td><td valign='top' style='border-style: none;' background='shadow/r.gif'>
<img border='0' src='shadow/or.gif' width='8' height='10'></td></tr><tr>
<td style='border-style: none;' background='shadow/r.gif'> </td></tr>
<tr><td style='border-style: none;' background='shadow/u.gif' align='left'>
<img border='0' src='shadow/ul.gif' width='10' height='10'></td>
<td style='border-style: none;' background='shadow/u.gif'></td>
<td style='border-style: none;' valign='top'><img border='0' src='shadow/ur.gif' width='8' height='10'></td>
</tr></table>";
return $output;
}
function showpicture($image, $widthget, $subdir, $shadow)
{
if ($shadow == true)
{
$output = "<td align='center' valign='middle'>";
$imagehtml = "<a href='$PHP_SELF?image=$image&view=big'>
<img border='0' src='calculate.php?image=$subdir/$image&width=$widthget' alt='$image'></a>";
$output .= shadowtable($imagehtml);
$output .= "<span class='text'>" .$image. "</span></td>";
}
else
{
$output = "<td align='center' valign='middle'>";
$output .= "<table style='border-style: none;' cellspacing='0' cellpadding='0' height='100%'>
<tr><td style='border-style: none;'>";
$output .= "<a href='$PHP_SELF?image=$image&view=big'>
<img border='0' src='calculate.php?image=$subdir/$image&width=$widthget' alt='$image'></a></td></tr></table>
<span class='text'>" .$image. "</span></td>";
}
return $output;
}
function showbigpicture($subdir, $imagewidth, $image, $shadow, $von)
{
$i = 0;
$dir = opendir($subdir);
while ($file = readdir($dir))
{
$imagechecker = @getimagesize($subdir. "/" .$file);
if ($imagechecker[2] == 1 OR $imagechecker[2] == 2)
{
$images[$i] = $file;
if ($file == $image)
{
$imagehtml = "<img border='0' src='calculate.php?image=$subdir/$file&width=$imagewidth' alt='$file'>";
$aktuell = count($images);
if ($shadow == true)
{
echo shadowtable($imagehtml);
echo "<table width='100%' border='0'>
<tr><td class='text' align='left' width='50%'>Bild " .$aktuell. " von " .$von. "</td>
<td class='text' align='right' width='50%'>Bildname: $file</td>
</tr></table>";
}
else
{
echo $imagehtml. "<br>";
echo "<span class='text'>Bild " .$aktuell. " von " .$von. "</span>";
}
$count = $i;
}
$i++;
}
}
echo "<table border='0' width='100%' align='center'><tr><td align='center' width='33%'>";
if ($count > 0)
{
$output .= "<a href='" .$PHP_SELF. "?image=" .$images[0]. "&view=big'> << Erstes</a>";
$output .= "<a href='" .$PHP_SELF. "?image=" .$images[$count-1]. "&view=big'> < Zurück </a>";
}
else {$output .= " ";}
$output .= "</td><td align='center'>";
$output .= "<a href='gallery.php'>Back</a>";
$output .= "</td><td align='center' width='33%'>";
if ($count < count($images)-1)
{
$output .= "<a href='" .$PHP_SELF. "?image=" .$images[$count+1]. "&view=big'> Vorwärts > </a>";
$output .= "<a href='" .$PHP_SELF. "?image=" .$images[$von-1]. "&view=big'> Letztes >> </a>";
}
else {$output .= " ";}
$output .= "</td></tr></table>";
return $output;
}
//<<<<<<<<<<<<< HAUPTPROGRAMM >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
echo "<center><span class='bigtext'>$heading</span></center><br>";
$count = 1;
$zaehler = 0;
$dir = opendir($subdir);
while ($file = readdir($dir))
{
$imagechecker = @getimagesize($subdir. "/" .$file);
if ($imagechecker[2] == 1 OR $imagechecker[2] == 2)
{
$zaehler ++;
}
}
closedir($dir);
if (!$view)
{
$dir = opendir($subdir);
echo "<table align='center' cellpadding='5' cellspacing='0' style=\"border:1px solid black; empty-cells:show\">";
while ($file = readdir($dir))
{
$imagechecker = @getimagesize($subdir. "/" .$file);
if ($imagechecker[2] == 1 OR $imagechecker[2] == 2)
{
$zaehler ++;
if ($count == 1){echo "<tr>";}
echo showpicture($file, $imagewidth, $subdir, $shadow);
if ($count < $colums) {$count++;}
else {$count = 1; echo "</tr>";}
}
}
closedir($dir);
echo "</table>";
}
else
{
echo "<br>";
echo "<table align='center' cellpadding='5' cellspacing='0' style=\"border:1px solid black; empty-cells:show\">";
echo "<tr><td>";
echo showbigpicture($subdir, $bigimagewidth, $image, $shadow, $zaehler);
echo "</td></tr></table>";
}
if ($shadow == true){$shaus = "Ja";} else {$shaus = "Nein";}
echo "<br><br><center><span class='text'>Thumbnailgröße: $imagewidth Pixel<br>
Normale Bildgröße: $bigimagewidth Pixel<br>
Spalten: $colums<br>
Schatten: $shaus</span></center>";
?>
</body>
</html>
calculate.php
PHP:
<?php
if (!$width)
{
$width = 50;
}
$sourceimage = $image;
$info = getimagesize($sourceimage);
$widthold = $info[0];
$heightold = $info[1];
if ($heightold>$widthold)
{
$height = $width;
$width = ceil($widthold*$height/$heightold);
}else{
$height = ceil($heightold*$width/$widthold);
}
switch($info[2])
{
case 1: //Gif
$imageold = imagecreatefromgif($sourceimage);
break;
case 2: //Jpeg
$imageold = imagecreatefromjpeg($sourceimage);
break;
}
$imagenew = imagecreatetruecolor($width, $height);
imagecopyresampled($imagenew, $imageold, 0, 0, 0, 0, $width, $height, $widthold, $heightold);
header("Content-type: image/jpeg");
imagegif($imagenew);
imagedestroy($imageold);
imagedestroy($imagenew);
?>