->
Bilder-Galerie
"Die Fotos sind selbst geknipst. Falls sie jemand verwenden möchte, mich unbedingt vorher informieren!"
<?php
// Verzeichnis auslesen und sortieren
function GetPics($list_dir) {
$verz = opendir($list_dir);
while ($file = readdir($verz)) {
if (!is_dir($file) && $file != "." && $file != "..") {
$fotos_arr[] = $list_dir.'/'.$file;
}
}
closedir($verz);
sort($fotos_arr);
return $fotos_arr;
}
/*
Es duerfen sich natuerlich auch nur Fotos in dem Verzeichnis "fotos" befinden :-)
Einfaches Skript mit Blaetterfunktion
*/
$pfad = '../fotos';
$fotos = GetPics($pfad);
if (isset($_GET['foto'])) {
$pos = array_search($_GET['foto'], $fotos);
echo '<a href="'.$_SERVER['PHP_SELF'].'?foto='.$fotos[$pos-1].'">';
echo '<<';
echo '</a>';
echo ' | '.($pos+1).'. von '.count($fotos).' Bilder | ';
echo '<a href="'.$_SERVER['PHP_SELF'].'?foto='.$fotos[$pos+1].'">';
echo '>>';
echo '</a>';
echo '<br>';
echo '<a href="'.$_SERVER['PHP_SELF'].'">';
echo '<img src="'.$_GET['foto'].'" width="600" border="0" alt="'.$foto.'">';
echo '</a>';
} else {
foreach ($fotos as $foto) {
echo '<a href="'.$_SERVER['PHP_SELF'].'?foto='.$foto.'">';
echo '<img src="'.$foto.'" width="300" border="0" alt="'.$foto.'">' ."\n";
echo '</a>';
}
}
?>
<?php
/*
... noch eine schlanke Variante mit glob() um ein Bildverzeichnis darzustellen.
Es muss PHP >= 4.3.0 am Start sein.
*/
$img_arr = glob("./mypics/*.{gif,png,jpg}", GLOB_BRACE);
foreach ($img_arr as $img) {
echo '<img src="'.$img.'" alt=""><br />';
}
?>