#!/usr/bin/perl -w
#---------------------------------------------------------------------------------------------------------
# more_brewer_photos.pl - this lists the contents of folders of photos as clickable thumbnails images
# written by Eric Pence
# When this script runs it is in the cgi-bin directory, so paths to items must be relative to that location.
# When the html output displays it is in the root directory, so make link paths relative to that location.
#---------------------------------------------------------------------------------------------------------
#
use strict;
use CGI qw(-oldstyle_urls :standard);
use CGI::Carp qw(fatalsToBrowser);
# Define global variables
use vars qw($curr_dir $log_file);
#---------------------------------------------------------------------------------------------------------
# Grab the current directory from $0. The following regular expression
# looks for 'CURR_DIR\xxxxx.xxx' or 'CURR_DIR/xxxxx.xxx'. Place it in
# the BEGIN block so we can use it to include modules
#---------------------------------------------------------------------------------------------------------
BEGIN {
$0 =~ '(.*[\\\/])\w+\.\w+$';
$curr_dir = $1 || "./";
# Set up error log file
$log_file = "error_log.txt";
use CGI::Carp qw(carpout);
open(LOG, ">>${curr_dir}${log_file}")
or die "Unable to append to error log: $!";
carpout(*LOG);
}
use lib ( $curr_dir );
use FileHandle;
my $filename = '';
my $brewer_photos = '';
my @dir_contents = ();
my $work_dir = $curr_dir."../pics/more_brewer";
opendir(DIR,$work_dir) || die("Cannot open directory $work_dir!\n");
@dir_contents = ();
@dir_contents = sort readdir(DIR);
closedir(DIR);
# Display the images as clickable thumbnails
foreach $filename (@dir_contents) {
if (lc($filename) =~ /\.jpg/) {
$brewer_photos = "$brewer_photos
<a href=\"pics/more_brewer/$filename\"><img src=\"pics/more_brewer/$filename\" border=\"0\" hspace=\"10\" vspace=\"10\" width=\"105\" height=\"70\" /></a>";
}
}
print header();
print "<html>
<body background=\"../images/myback.gif\">
<table>
<tr>
<td width=\"10\"></td>
<td height=\"30\" valign=\"middle\">
<font size=\"+1\"><b>More-Brewer Reservation photos...</b></font>
</td>
</tr>
<tr>
<td width=\"10\"></td>
<td valign=\"top\" style=\"{line-height: 1.25}\">
Hingham has several nature preserves around town that I like to walk the dogs in because they can be off-leash. More-Brewer is the one that is
closest to my house so I go there frequently. I didn't realize how much the same these photos would look when I took them. When you are there the
terrain seems more varied, probably because there are so many hills.
</td>
</tr>
</table>
<table width=\"100%\">
<tr>
<td width=\"3%\"></td>
<td width=\"95%\">$brewer_photos</td>
<td width=\"2%\"></td>
</tr>
</table>
<table><tr><td width=\"10\"></td><td>
This page is dynamically created in perl (<a href=\"cgi-bin/print_source.pl?src=more_brewer_photos.pl\" class=\"greenul\"
onClick=\"javascript:windowOpener(this.href,this.target,'width=875,height=700,left=25,top=100,scrollbars=1');return false;\">more_brewer_photos.pl</a>)
</td></tr></table>
</body>
</html>";