Hi guys,
i got the following script from a friend and want to use it for a photowebsite that the user can easily update the page by himself by just overwriting files in a certain folder.
So far everything works, although I am not a programmer, just tried to adjust the script by myself.
the problem is now the order of the images.
I labled the uploaded images with the number or letter I named the files after. The appearance should be (for me) 01, 02, 03... 21, 22, 23, ... 45, 46,47 and so on. But the script actually does something totally different. For me following no logical order.
So how come this weird order of the images? How can I make this right?
If someone has any idea .. please .....
here is the uploaded script:
http://dev.perfectday.gb.com/tom/www/photo.php
click on image to go one forward, click on button (not loaded) on the bottom left to go backwards.
the images on the server are named like this:
http://dev.perfectday.gb.com/tom/www/pictures/gallery/screen.jpg
Here the code of the photo php:
Unfortunately some parts of the script in german, as a german friend wrote it... sorry bout that...
<?php
$Pfadcat1 = "./pictures/gallery/";
$Pfadcat2 = "./photos/2/";
$Pfadcat3 = "./photos/3/";
#echo "<hr>index-übergeben<br>"."$index"."<hr>";
#echo "<hr>cat-übergeben<br>"."$cat"."<hr>";
#echo "Per POST übergebene Variablen:<br>\n";
while (list ($key, $val) = each ($_GET))
{
#echo "$key => $val<br>";
if ($key=="cat")
{
$cat=$val;
}
if ($key=="index")
{
$index=$val;
}
}
#echo "<hr>index-übergeben<br>$index<hr>";
#echo "<hr>cat-übergeben<br>$cat<hr>";
if ($cat==1)
{
$Pfad = $Pfadcat1;
}
if ($cat==2)
{
$Pfad = $Pfadcat2;
}
if ($cat==3)
{
$Pfad = $Pfadcat3;
}
if (($cat!=1)&&($cat!=2)&&($cat!=3))
{
$Pfad = $Pfadcat1;
}
#echo $Pfad;
#echo "<hr>index-übergeben<br>$index<hr>";
#echo "<hr>cat-übergeben<br>$cat<hr>";
$counter = 0;
#anzahl datein ermitteln
$i=0;
$verz=opendir ($Pfad);
while ($file=readdir($verz))
{
if (filetype($Pfad.$file)!="dir")
{
$i++;
#echo "<br>.$file";
}
}
closedir($verz);
#linkzähler ermitteln
#echo "<hr>anzn<br>".$i."<hr>";
#sicherheit
if($index<1||$index>$i)
{ $index = 1;}
$prev = $index-1;
$next = $index+1;
if($prev<1)
{ $prev = $i;}
if($next>$i)
{ $next = 1;}
if($Verzeichniszeiger = opendir($Pfad))
{
while($Datei = readdir($Verzeichniszeiger))
{
if($Datei != "." && $Datei != "..")
{
$Bilddaten = getimagesize($Pfad.$Datei);
$counter++;
#echo "<hr>".$counter."<hr>";
if($index==$counter)
{
?>
<table border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td colspan="3">
<div align="center">
<table width="100" cellpadding="4" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<div align="center"><a href="photo.php?index=<?php echo$next; ?>&cat=<?php echo$cat; ?>"><img src="<?php echo$Pfad.$Datei; ?>"></a><br>
<?php
}
}
}
closedir($Verzeichniszeiger);
}
#echo "<hr>".$counter."<hr>";
?> </div> </td>
</tr>
</table>
</div></td>
</tr>
<tr valign="top">
<td height="25"><a href="photo.php?index=<?php echo$prev; ?>&cat=<?php echo$cat; ?>"><img src="images/button1.gif" alt="1" border="0"></a></td>
<td height="25"><div align="center"></div></td>
<td height="25"><div align="right"><a href="photo.php?index=<?php echo$next; ?>&cat=<?php echo$cat; ?>"><img src="images/button2.gif" alt="2" border="0"></a></div></td>
</tr>
</table>
thnks a lot
k.