Link to home
Start Free TrialLog in
Avatar of Pancake_Effect
Pancake_EffectFlag for United States of America

asked on

Tweaking a php code for photo gallery

I have written this code (from a tutorial) to display a photo gallery from a directory using lightbox. It works amazing so far. The only complaint I have is it has an in between page that I don't like. Right now it navigates to a page where you select an album that you would like to view. User generated image
Above shows that it first displays a list of photo galleries. After you click it navigates to the gallery selected and displays the photos. The galleries are sorted by folder on my site.

User generated image
So what I want is to skip the showing of the directory like in the first photo and go directly to the gallery. I plan on just having one two folders named photogallery and thumbs in my data folder. Can anyone change to part in my code to skip directly to the gallery.

Thanks, let me know if you need any additional information.
Here is my code

<?php


$page = $_server['php_self'];


//settings
$column = 9;

//directories

$base = "data";
$thumbs = "thumbs";

//get album
$get_album = $_GET['album'];

if (!$get_album)
{
	echo "<b>select an album: </b><p />";	
	$handle = opendir($base);
	while (($file = readdir($handle))!==FALSE)
	{
	if (is_dir($base."/".$file) && $file !="." && $file !=".." && $file !=$thumbs)
		
		{
		echo "<a href='$page?album=$file'>$file</a><br />";	
		}
	}
	closedir($handle);
} 

		else
			{
			if (!is_dir($base."/".$get_album) || strstr($get_album,".")!=NULL || strstr($get_album,"/")!=NULL || strstr($get_album,"\\")!=NULL)
				
				
				{
					
				echo "album doesn't exist, please contact kora@kphoto-design.com";
				
				} 
				
				else 
					{
					$x = 0;
						
					echo "<b>$get_album</b><p />";
					$handle = opendir($base."/".$get_album);
					while (($file = readdir($handle)) !==FALSE)
						{
						if ($file != "." && $file !="..")
								{
								echo "<a href='$base/$get_album/$file' rel='example_group' title='Image: $file'>
								<img src='$base/$thumbs/$file' height='100' width='100'>";
								$x++;
								
								if ($x==$column)
								{
								echo "<br />";
								$x = 0;
								}
								}
						}
						
			closedir($handle);
			
			echo "<p /><a href='index.php'>Back to your albums.</a>";
					
					}

			
			}



	
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Erdinç Güngör Çorbacı
Erdinç Güngör Çorbacı
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pancake_Effect

ASKER

Thanks!