chrisbergr
Erfahrenes Mitglied
PHP:
//---------------------------------------
class gallery {
// ich würde allgemein die ganzen Galleriefunktionen hier als Funktion schreiben...
function random($folder) {
$cat = 'Gallery/' . $folder . ''; //Musst du schauen ob das der richtige Pfad ist...
$cdir = dir("$cat");
while ($entry = $cdir->read()) {
if (!is_dir($entry)) {
if (is_readable("$entry") == 0) {
$pic_file[] = $entry . "\n";
}
}
}
srand((double)microtime()*1000000);
$zahl = rand(0, count($pic_file) - 1);
$random_picture = $cat . '/' . $pic_file[$zahl];
$cdir->close;
return $random_picture;
}
}
$gallery = new gallery;
$gallery->random_pic = $random_picture;
//---------------------------------------
//---------------------------------------
$entry = "blaschwall" // Pfad zum gewünschten Ordner/Album
echo '<img src="'.$gallery->random("$entry").'" width="100" border="0"></a>';
//---------------------------------------
Eine kleine Funktion für ein Zufallsbild... Einfach anpassen.
Gruß