#!/usr/local/bin/perl use strict; use CGI (':standard'); use IO::File; my %st = (); $st{'IMG'} = param('image') ; $st{'REF'} = $ENV{'HTTP_REFERER'}; my $db = 'dat/miniatures.txt'; my $fh = new IO::File $db, 'r' ; my @flds; my $key; my $isex; while (<$fh>) { chop($_); @flds = split "#", $_; last if $flds[2] =~ /$st{'IMG'}/ ; } ($key,$isex,$st{'IMG'},$st{'ARTIST'},$st{'TITLE'},$st{'YEAR'},$st{'MEDIUM'},$st{'DIMENS'}) = @flds; $st{'ARTISTNM'} = $st{'ARTIST'}; unless ($isex) { $st{'IMG'} =~ m/-(\w*)-/; my $ln = $1; $st{'ARTIST'} = ''.$st{'ARTIST'}.'' unless $ln eq 'greenwalt'; } for (keys %st) { $st{$_} = $st{$_} if ($st{$_} ne '') && $_ ne 'IMG' && $_ ne 'REF' && $_ ne 'ARTISTNM'; } $st{'IMG'} .= '.jpg'; my $str = &stp('dat/tplt-moreinfo.html',\%st); print "Content-type: text/html\n\n"; print $str; exit; sub stp { my($src, $symref, $nullrep, $ph) = @_; my $rep; my $fh; my $s = '' ; $ph = '&' unless (defined $ph) ; my $c = sub { $_[0] =~ s//($symref->{$1}||$nullrep)/ges ; return $_[0]; } ; if (ref($src) eq 'HASH') { if (exists $src->{STR}) { $s = $src->{STR} ; $c->($s) ; } else { return ; } } else { $fh = new IO::File $src, 'r' ; if ($fh) { $fh->input_record_separator(undef) ; $s = <$fh> ; $c->($s) ; undef $fh ; } else { $s = ("Unable to open template: $src"); } return $s; } } 1;