PHPNewbie-KY
Sat 2 June 2007, 03:37 am GMT +0300
I have several php photo albums on my site. They all work fine, and follow the same code, the only difference is the name and directory. I have a new album I am trying to incorporate. And it won't work. All I changed is the directory and some other file names. The only difference is that the new pictures have some panoramic pictures.
any help would be appreciated!
Thanks
Code:
<?php
$photo = $_GET['P'];
$dirlist = "images/ablum1/"; // leave it alone if it's the same directory
// Change it if you want to view a different
// directory. default value: "./"
if (is_dir($dirlist)==true ) // check if directory exists
{
chdir( $dirlist );
$handle=opendir( "."); // open the directory
$x=0;
$files=array();
while (($file = readdir($handle))!==false) // while there's files to read....
{
$pieces = explode (".", $file);
if ($pieces[0] && $pieces[1]) // filename.ext
{
// if (($pieces[1]=="jpg")) // add only .jpg files
// {
$files[$x]=$file; // add it to the array.
$x++;
// }
}
}
}
closedir($handle); //done finding files
sort($files); // sort them alphabetically
if ($photo == '')
{
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
$picture = 0 ;
$row = 1 ;
for ($i=0; $i<sizeof($files); $i++) // output each element from the array
{
$picture = $picture + 1 ;
echo "<td width=\"100\"><a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a></td>";
if($picture == 4 )
{?>
</tr>
<tr>
<?php
$row = 1 ;
$picture = 0 ;
}
}
?>
</tr>
</table></div>
<?php
}
else
{
$i = $photo ;
?> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><a href="/photos.php">Back to Photos Page</a></div></td>
</tr>
<tr>
<td><div align="center"><img src="<?php echo"resize2.php?$files[$i]";?>" alt=""></div></td>
</tr>
<tr>
<td><div align="center"><a href="images/gallery/<?php echo"$files[$i]";?>" target="_blank">Show fullscreen</a></div></td>
</tr>
</table>
<table width="50%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 25%; margin-right: 25%; ">
<tr>
<td>
<?php
$i = $i - 1;
if($i >= 0)
{
echo "<a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a>";
}
?>
</td>
<td>
<?php
$i = $i + 2;
if($i < sizeof($files))
{
echo "<a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" align=\"right\" alt=\"\"></a>";
}
?></td>
</tr>
<tr>
<td>
<?php
if($i >= 2 )
{
echo"Previous Image";
}
?></td>
<td><div align="right">
<?php
if($i < sizeof($files))
{
echo"Next Image";
}
?>
</div></td>
</tr>
</table>
<?php
}
?>
$photo = $_GET['P'];
$dirlist = "images/ablum1/"; // leave it alone if it's the same directory
// Change it if you want to view a different
// directory. default value: "./"
if (is_dir($dirlist)==true ) // check if directory exists
{
chdir( $dirlist );
$handle=opendir( "."); // open the directory
$x=0;
$files=array();
while (($file = readdir($handle))!==false) // while there's files to read....
{
$pieces = explode (".", $file);
if ($pieces[0] && $pieces[1]) // filename.ext
{
// if (($pieces[1]=="jpg")) // add only .jpg files
// {
$files[$x]=$file; // add it to the array.
$x++;
// }
}
}
}
closedir($handle); //done finding files
sort($files); // sort them alphabetically
if ($photo == '')
{
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
$picture = 0 ;
$row = 1 ;
for ($i=0; $i<sizeof($files); $i++) // output each element from the array
{
$picture = $picture + 1 ;
echo "<td width=\"100\"><a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a></td>";
if($picture == 4 )
{?>
</tr>
<tr>
<?php
$row = 1 ;
$picture = 0 ;
}
}
?>
</tr>
</table></div>
<?php
}
else
{
$i = $photo ;
?> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><a href="/photos.php">Back to Photos Page</a></div></td>
</tr>
<tr>
<td><div align="center"><img src="<?php echo"resize2.php?$files[$i]";?>" alt=""></div></td>
</tr>
<tr>
<td><div align="center"><a href="images/gallery/<?php echo"$files[$i]";?>" target="_blank">Show fullscreen</a></div></td>
</tr>
</table>
<table width="50%" border="0" cellspacing="0" cellpadding="0" style="margin-left: 25%; margin-right: 25%; ">
<tr>
<td>
<?php
$i = $i - 1;
if($i >= 0)
{
echo "<a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" alt=\"\"></a>";
}
?>
</td>
<td>
<?php
$i = $i + 2;
if($i < sizeof($files))
{
echo "<a href=\"album1.php?P=$i\"><img src=\"resize.php?$files[$i]\" border=\"0\" align=\"right\" alt=\"\"></a>";
}
?></td>
</tr>
<tr>
<td>
<?php
if($i >= 2 )
{
echo"Previous Image";
}
?></td>
<td><div align="right">
<?php
if($i < sizeof($files))
{
echo"Next Image";
}
?>
</div></td>
</tr>
</table>
<?php
}
?>
any help would be appreciated!
Thanks