Brauche unbedingt HILFE. Komme alleine einfach nicht mehr weiter. BITTE UM HILFE!!! Bin für jede Hilfe sehr dankbar!!!!
Auf der ersten Seite "forums.html" möchte ich eine Variable festlegen (die Variable beinhaltet
den ausgewählten Ordnernamen) die an die Datei "imagegallery.php" übergeben wird.
Möchte einen Link auf der Seite index.php anklicken. z.B. hochzeit. Dann soll der Ordnername
hochzeit an imagegallery.php gesendet werden und die imagegallery.php soll den unterordner
"bilder" und "thumbs" aus dem Ordner Hochzeit auslesen?
Das Problem ist, dass die Variablen nicht richtig im imagegallery.php erkannt werden!??
Die thumbnails werden richtig angezeigt, aber beim Ancklicken von einem thumb bekomme ich eine
Fehlermeldung. Pfad nicht gefunden... Warum ???
Struktur:
--> Bildergalerie [ Ordner ]
--> index.php[ Datei ]
--> imagegallery.php [ Datei ]
--> hochzeit[ Unterordner von Bildergalerie ]
--> bilder[ Unterordner von hochzeit]hier sind die grossen bilder drin
--> thumbs[ Unterordner von bilder ]hier sind die thumbnails
--> Geburtstag [ Unterordner von Bildergalerie ]
--> bilder[Unterordner von Geburtstag]hier sind die grossen bilder
--> thumbs[ Unterordner von bilder]hier sind die thumbnails
u.s.w
--------------------------------
index.php
--------------------------------
---------------------------------
So werden die Variablen definiert.
$kleinebilder = $_GET[ galerie ]."/".thumbs;
$grossebilder = $_GET[ galerie ];
und übergeben an:
----------------------------------
imagegallery.php
----------------------------------
Auf der ersten Seite "forums.html" möchte ich eine Variable festlegen (die Variable beinhaltet
den ausgewählten Ordnernamen) die an die Datei "imagegallery.php" übergeben wird.
Möchte einen Link auf der Seite index.php anklicken. z.B. hochzeit. Dann soll der Ordnername
hochzeit an imagegallery.php gesendet werden und die imagegallery.php soll den unterordner
"bilder" und "thumbs" aus dem Ordner Hochzeit auslesen?
Das Problem ist, dass die Variablen nicht richtig im imagegallery.php erkannt werden!??
Die thumbnails werden richtig angezeigt, aber beim Ancklicken von einem thumb bekomme ich eine
Fehlermeldung. Pfad nicht gefunden... Warum ???
Struktur:
--> Bildergalerie [ Ordner ]
--> index.php[ Datei ]
--> imagegallery.php [ Datei ]
--> hochzeit[ Unterordner von Bildergalerie ]
--> bilder[ Unterordner von hochzeit]hier sind die grossen bilder drin
--> thumbs[ Unterordner von bilder ]hier sind die thumbnails
--> Geburtstag [ Unterordner von Bildergalerie ]
--> bilder[Unterordner von Geburtstag]hier sind die grossen bilder
--> thumbs[ Unterordner von bilder]hier sind die thumbnails
u.s.w
--------------------------------
index.php
--------------------------------
PHP-Code:
<?php
$verz=opendir ('.');
while ($file = readdir ($verz))
{
if($file != "." && $file != ".." && is_dir($file))
echo " <a href=\"imagegallery.php?galerie=$file\"><img src=\"loeschen.bmp\" alt=\"Löschen\" border=\"0\"></a> ";
}
closedir($verz);
?>
So werden die Variablen definiert.
$kleinebilder = $_GET[ galerie ]."/".thumbs;
$grossebilder = $_GET[ galerie ];
und übergeben an:
----------------------------------
imagegallery.php
----------------------------------
PHP-Code:
<html>
<head>
<title>Simple PHP Image Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<style type="text/css">
<!--
/* Default styles incase you don't have an external css. */
body { background-color: rgb(56,56,56); color: rgb(180,180,180); font: 82% verdana, arial, sans-serif }
table { font-size: inherit }
p, td, div { color: rgb(180,180,180); font-family: verdana, arial, sans-serif }
h2 { font-size: 1.2em; font-weight: bold }
h2, p { text-align: center }
a:link, a:active, a:visited { color: #708090; text-decoration: none; font-size: 12px }
a:hover { text-decoration: underline }
/* the following styles must be included somewhere, since they controll all formatting */
#photo { text-align: center }
#photo table { width: 80%; text-align: center; margin-right: auto; margin-left: auto }
#photo table td { padding: 0px 10px 10px 10px }
#photo .fulltitle { margin-bottom: 0px; padding-bottom: 0px }
#photo .series { margin-top: 0px; padding-top: 0px }
br.hideme { visibility: hidden; volume: silent }
/* hidden from netscape 4: */
div#photo img { border: 1px solid #708090 }
div#photo .caption { text-align: left; width: 500px; margin-right: auto; margin-left: auto }
-->
</style>
</head>
<body>
<h2>Image Gallery</h2>
Insert snappy caption here.</p>
<div id="photo">
<?
//error_reporting (E_ALL);
// 1 for XHTML or 0 for HTML?
$xhtml = 1;
###############################################################
$kleinebilder = $_GET[ galerie ]."/".thumbs;
$grossebilder = $_GET[ galerie ];
// thumbnail directory name
$thumbs_dir = $kleinebilder;
// full size image directory name
$full_dir = $grossebilder;
###############################################################
// captions directory name (captions are option, ignore if you dont' have any)
$captions_dir = 'captions';
// thumbnails title (1 to show, 0 to hide)
$thumb_title = 1;
// full size images title (1 to show, 0 to hide)
$full_title = 1;
// kill beginning numbers for the title (1 to hide, 0 to show)
// hiding would make 0005_baby_pic.jpg have a title of 'Baby pic'
$kill_title_nums = 1;
// how many thumbnails should appear per row? (3 usually looks best)
$cols = 5;
// how many thumbnails per page? (a multiple of $cols, or 0 for all)
$max_thumbs = 0;
// extension name (if your server is not set for "index.$ext to be the index page, put 0)
$ext = 'php';
// captions extension
$cext = 'inc'; // use whatever you're comfortable with
// show random option for single page view (1 to show, 0 to hide)
$showrand = 0;
// closing (X)HTML options
// if you use a function to close your code, put that in, otherwise leave as is
$print_footer = 'print_footer';
// figure out this script's name
$self = $_SERVER['PHP_SELF'];
if (basename($self) == "index.$ext") {
$self = str_replace(basename($self), '', $self);
}
// do you have an existing function to close your page? if not, use this default...
if (!function_exists($print_footer)) {
function print_gallery_footer() {
?>
</body>
</html>
<?
}
$print_footer = 'print_gallery_footer';
}
// our error function, cleanly exits the script on user errors
function imgerror($error) {
global $print_footer;
print "
[b]$error[/b]</p>\n\n";
$print_footer();
exit();
}
// check to see which kind of closing tag we should use
$close_tag = !empty($xhtml) ? ' />' : '>';
// check for directories
if (!is_dir($thumbs_dir)) {
imgerror('Directory "'.$thumbs_dir.'" does not exist.');
}
if (!is_dir($full_dir)) {
imgerror('Directory "'.$full_dir.'" does not exist.');
}
// get contents of $thumbs_dir
$dir = @opendir($thumbs_dir) or imgerror('Can\'t open ' . $thumbs_dir . ' directory');
while (($thumb = readdir($dir)) !== false) {
if (preg_match('/((?i)jpg|jpeg|gif|tif|bmp|png)$/', $thumb))
$thumbs[] = $thumb;
}
natcasesort($thumbs);
$thumbs_size = sizeof($thumbs);
// lowest displayed image in the array
// use http_get_vars incase register_globals is off in php.ini
$i = !empty($_GET['i']) ? $_GET['i'] : 0;
$random = array_rand($thumbs, 2);
$i = $i === 'rand' ? $thumbs[$random[rand(0, 1)]] : $i;
// check to see if all thumbs are meant to be displayed on one page
if ($max_thumbs == 0) {
$max_thumbs = $thumbs_size;
$mt_check = 1;
}
// thumbnail view
if (is_numeric($i)) {
// check to see which thumbnail to start with
$start = empty($mt_check) && $i > 0 ? $max_thumbs * ($i - 1) : 0;
// are they looking for thumbs pages that don't exist?
if ($start >= $thumbs_size) {
print '[url="' . $self . '"]index[/url]' . "\n\n";
imgerror('Sorry, there are no images to display on this page');
}
?>
<table>
<tr>
<?
// loop through $thumbs and display $max_thumbs per page
for ($count = 1; $count <= $max_thumbs; $start++) {
// break if past max_thumbs
if ($start >= $thumbs_size) {
break;
}
// print new row after predefined number of thumbnails
if (($count % $cols == 1) && $count != 1 && $cols > 1) {
print "</tr>\n\n<tr>\n";
} elseif ($cols == 1) {
print "</tr>\n\n<tr>\n";
}
// open cell
print '<td align="center" style="width: ' . (floor(100 / $cols)) . '%">';
// insert thumb
print '<a href="' . $self . '?i=' . rawurlencode($thumbs[$start]) . '">';
print '[img]' . $thumbs_dir . '/' . rawurlencode($thumbs[$start]) . '[/img]';
// image title
if ($thumb_title) {
if ($kill_title_nums) {
$title = ltrim(ltrim(str_replace('_', ' ', $thumbs[$start]), "0..9"));
} else {
$title = ltrim(str_replace('_', ' ', $thumbs[$start]));
}
$title = explode(".", ucfirst($title));
print '<br' . $close_tag . "\n" . $title[0];
}
// close cell
// supress line break for screen readers, but force a line break for lynx
print '<br class="hideme"' . $close_tag . '</td>' . "\n";
$count++;
}
?>
</tr>
</table>
<?
// thumbs page nav
if (!$mt_check) {
print "\n
";
// how many total thumbs pages, including a "remainder" page if needed
$pages = ceil($thumbs_size / $max_thumbs);
for ($count = 1; $count <= $pages; $count++) {
if ($count == 1) {
if ($count == $i || $i == 0) {
print $count;
} else {
print "<a href=\"$self\">$count</a>";
}
} else {
if ($count == $i) {
print " | $count</a>";
} else {
print " | <a href=\"$self?i=$count\">$count</a>";
}
}
}
print '</p>';
}
}
// single image view
else if (file_exists("$full_dir/$i")) {
// find where it is in the array
$key = array_search($i, $thumbs);
if (is_null($key)) {
$key = -1;
}
// navigation
print '
';
// previous
print $key >= 1 ? '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key - 1]) . '">' : '';
print '« previous';
print $key >= 1 ? '</a>' : '';
print ' | ';
// index
print '[url="' . $self . '"]index[/url]';
print ' | ';
// random
if ($showrand != 0) {
print '[url="' . $self . '?i=rand"]random[/url]';
print ' | ';
}
// next
print $key < $thumbs_size - 1 ? '<a href="' . $self . '?i=' . rawurlencode($thumbs[$key + 1]) . '">' : '';
print 'next »';
print $key < $thumbs_size - 1 ? '</a>' : '';
print "</p>\n\n";
// image
print '[img]' . $full_dir . '/' . rawurlencode($i) . '[/img]$title[0]</div>\n\n";
}
// numerically show what image it is in the series; hide this if image isn't in the series
if ($key >= 0) {
// add 1 so that the first image is image 1 in the series, not 0
print '<div class="series">' . ($key + 1) . ' of ' . $thumbs_size . "</div>\n\n";
}
// caption (optional)
if (file_exists("$captions_dir/$i.$cext")) {
print '<div class="caption">' . "\n";
require("$captions_dir/$i.$cext");
print "\n</div>\n";
}
} else { // no image found
?>
[url="<?=$self?>"]index[/url]</p>
<?
imgerror('Sorry, that image does not exist...');
}
?>
</div>
[url="../"]Back to main image gallery[/url]</p>
</body>
</html>
Kommentar