#! /usr/bin/perl -w
#
########################################
#
# script to edit DTN site content
# written by benjamin ramey
# bsr@rameydesign.net
# december, 2004
#
########################################
if( $ENV{ 'REQUEST_METHOD' } eq 'GET' )
{
$album = $ENV{ 'QUERY_STRING' }; #get the input string
$album =~ s/.*\=(.*)/$1/; #just take the latter part. this is very specific to my purposes, I know I will only have one variable in the query string and I know what that is (the album to load)
}
print "Content-type: text/html\n\n";
opendir( ALBUM_DIR, "./graphics/media/albums/$album/" ) or print "Cannot open $album dir.\n\n";
my @photos = grep { not m/^\.\.?\z/ } readdir ALBUM_DIR; #won't read the . and .. directories
@photos = grep { /small_.*\.((jpg)|(JPG))\z/ } @photos;
closedir( ALBUM_DIR );
open( INFILE, "./data/media_data.txt" ) or print "ERROR: Could not open media_data.txt.";
my @inside_albums = ( "\n" );
my $parent_album = 'none';
while( (my $file_line = ) && ($file_line !~ m/<\/albumsection>/) )
{
if( $file_line =~ m/(.*)<\/name>/ ) { $album_name = $1; }
if( $file_line =~ m/(.*)<\/inside>/ )
{
$inside_field = $1;
if( $inside_field eq $album )
{
$file_line = ;
if( $file_line =~ m/(.*)<\/imagefolder>/ ) { $album_imagefolder = $1; }
my @sub_album = ("\t\n",
"\t\t
\n",
"\t\t$album_name\n",
"\t\t
\n\n" );
push( @inside_albums, @sub_album );
}
}
if( $file_line =~ m/(.*)<\/imagefolder>/ )
{
if( $1 eq $album ) { $parent_album = $inside_field; }
}
}
close( INFILE );
print<<"HTML";
Photo Album