120 lines
4.1 KiB
Perl
Executable File
120 lines
4.1 KiB
Perl
Executable File
#! /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 "<span style='color: red'>Cannot open $album dir.</span>\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 "<span style='font-weight: bold; color: red'>ERROR: Could not open media_data.txt.</span>";
|
|
|
|
my @inside_albums = ( "\n" );
|
|
my $parent_album = 'none';
|
|
while( (my $file_line = <INFILE>) && ($file_line !~ m/<\/albumsection>/) )
|
|
{
|
|
if( $file_line =~ m/<name>(.*)<\/name>/ ) { $album_name = $1; }
|
|
if( $file_line =~ m/<inside>(.*)<\/inside>/ )
|
|
{
|
|
$inside_field = $1;
|
|
if( $inside_field eq $album )
|
|
{
|
|
$file_line = <INFILE>;
|
|
if( $file_line =~ m/<imagefolder>(.*)<\/imagefolder>/ ) { $album_imagefolder = $1; }
|
|
|
|
my @sub_album = ("\t<a href=\"javascript:parent.location='albums.pl?album=$album_imagefolder'\">\n",
|
|
"\t\t<img src=\"../graphics/media/album_icon.gif\" border=\"0\"></a><br>\n",
|
|
"\t\t$album_name\n",
|
|
"\t\t<br> <br>\n\n" );
|
|
|
|
push( @inside_albums, @sub_album );
|
|
}
|
|
}
|
|
if( $file_line =~ m/<imagefolder>(.*)<\/imagefolder>/ )
|
|
{
|
|
if( $1 eq $album ) { $parent_album = $inside_field; }
|
|
}
|
|
}
|
|
|
|
close( INFILE );
|
|
|
|
print<<"HTML";
|
|
|
|
<html>
|
|
<head><title>Photo Album</title>
|
|
<script language="javascript" type="text/javascript">
|
|
<!--
|
|
function Main_Image( image )
|
|
{
|
|
var main_image = "mainImage";
|
|
document[ main_image ].src = "./graphics/media/albums/$album/" + image;
|
|
}
|
|
-->
|
|
</script>
|
|
<style type="text/css">
|
|
body { margin: 0px; }
|
|
img { padding: 5px; }
|
|
body
|
|
{
|
|
scrollbar-face-color: #333333;
|
|
scrollbar-shadow-color: #000000;
|
|
scrollbar-highlight-color: #000000;
|
|
scrollbar-3dlight-color: #000000;
|
|
scrollbar-darkshadow-color: #000000;
|
|
scrollbar-track-color: #000000;
|
|
scrollbar-arrow-color: #000000;
|
|
}
|
|
</style>
|
|
<script language="javascript" type="text/javascript" src="../albums.js">
|
|
</head>
|
|
|
|
<body style="background-color: #000000; color: #CCCCCC; font-family:Arial, Helvetica, sans-serif; font-size: 12px;">
|
|
<div align="center" id="index" style="position:absolute; left: 10px; top: 40px; width: 130px; height: 400px; overflow: auto;border-width: 2px;border-color: #333333; border-style: solid;padding-top: 10px;">
|
|
HTML
|
|
|
|
if( $parent_album ne 'none' ) { print "<a href=\"albums.pl?album=$parent_album\" style=\"font-weight: bold; color: #CCCCCC; font-family: Arial, Helvetica, sans-serif\">Back to previous<br />album</a><br /> <br />\n\n"; } #if this is a nested album, print the link to the parent album
|
|
|
|
foreach $insider ( @inside_albums )
|
|
{
|
|
print $insider;
|
|
}
|
|
|
|
foreach $photo ( @photos )
|
|
{
|
|
$photo =~ s/([ ,\',\",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
|
|
print "<a href='javascript:Main_Image( \"$photo\" )'><img src='./graphics/media/albums/$album/$photo' width='80' border='0' /></a>\n";
|
|
}
|
|
|
|
$first_photo = $photos[ 0 ];
|
|
$first_photo =~ s/([ ,\',\",\\,\/,-])/sprintf( "%%%lx", (unpack( "C", $1 )) )/eg;
|
|
|
|
print<<"HTML";
|
|
</div>
|
|
<div align="center" style="position: absolute; left: 160px; top: 40px; overflow: auto; height: 480px; width: 430px;">
|
|
<img src="./graphics/media/albums/$album/$first_photo" id="mainImage" name="mainImage" style="border-style: solid; border-width: 1px; border-color: #333333;" /><br /><br />
|
|
<a href="javascript:Show_Large_Photo();" style="font-weight: bold; color: #CCCCCC; font-family: Arial, Helvetica, sans-serif">Click here for larger image</a>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
|
|
HTML
|
|
|
|
exit; |