So I thought .php and then DynamicDrive and downloaded a free photo gallery script. It is dynamic in the sense that it detects the photos within the directory that the "getpics.php" file is located in. With multiple directories and new ones being added, I didn't like this. So I did a little editing and got it so I can enter in my own directories.
When the page loads up it runs football.php (for the football game photo directories)
Code: Select all
<?php
// open this directory
$myDirectory = opendir("./galleries/sportsevents/football");
// get each entry
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
// close directory
closedir($myDirectory);
// count elements in array
$indexCount = count($dirArray);
Print ("$indexCount files<br>\n");
// sort 'em
sort($dirArray);
// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>\n");
print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>\n");
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
print("<TR><TD><a href=gen_gal.php?album=$dirArray[$index]>$dirArray[$index]</a></td>");
print("<td>");
print(dirname($dirArray[$index]));
print("</td>");
print("<td>");
}
}
print("</TABLE>\n");
?>
[b]
From this a user would click on the link in the folder to "gen_gal.php" and it would put the chosen directory name in the url.
gen_gal.php then runs getpics.php on loadup. Get pics sends an array and file path to the .js script and that is what creates the images:
[/b]
<?
Header("content-type: application/x-javascript");
function returnimages() {
$dirname=realpath(".");
$pattern="\.(jpg|jpeg|png|gif|bmp)$";
$files = array();
$curimage=0;
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file)){
$filedate=date ("M d, Y H:i:s", filemtime($file));
echo 'galleryarray[' . $curimage .']=["' . $file . '", "'.$filedate.'"];' . "\n";
$curimage++;
}
}
closedir($handle);
}
return($files);
}
$tempDir="/images/";
/** This sends over the variable imagepath to the .js and the array**/
echo "var imagepath=";
echo $tempDir;
echo ";";
echo "\n";
echo "var galleryarray=new Array();" . "\n";
returnimages();
?>