Oto skad można
wziac skrypt
Należy pozmieniac niektóre parametry, aby wskazywaly na odpowiedni katalog.
CODE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<title>Galeria obrazów</title>
</head>
<body>
<?php
$imgDir = "./images";
//odczytanie parametru
if(isSet($_GET['imgid'])){
$imgId = $_GET['imgid'];
}
else{
$imgId = 0;
}
//odczytanie zawartości katalogu
$dir = scandir($imgDir);
array_shift($dir);
array_shift($dir);
$count = count($dir);
//spradzenie poprawności parametru
if($imgId < 0 || $imgId > $count || !is_Numeric($imgId)){
$imgId = 0;
}
//ustalenie nazwy bieżacego obrazu oraz
//identyfikatorów obrazów dla odnośników
$imgName = $dir["$imgId"];
$first = 0;
$last = $count - 1;
if($imgId < $count - 1){
$next = $imgId + 1;
}
else{
$next = $count - 1;
}
if($imgId > 0){
$prev = $imgId - 1;
}
else{
$prev = 0;
}
?>
<table align="center">
<tr>
<td>
<?php
echo "<img src=\"$imgDir/$imgName\" alt=\"$imgName\">";
?>
</td>
</tr>
<tr>
<td align="center">
<?php
$imgId++;
echo "Obraz $imgName ($imgId z $count)";
?>
</td>
</tr>
<tr>
<td align="center">
<?php echo "<a href=\"galeria.php?imgid=$first\">Pierwszy</a>"; ?>
<?php echo "<a href=\"galeria.php?imgid=$prev\">Poprzedni</a>"; ?>
<?php echo "<a href=\"galeria.php?imgid=$next\">Następny</a>"; ?>
<?php echo "<a href=\"galeria.php?imgid=$last\">Ostatni</a>"; ?>
</td>
</tr>
</table>
</body>
</html>