#!c:/perl/bin/perl.exe ################################################## # Section search 04/06/99 by Jeff Waldock # Lists pictures ################################################## $rootdir="h:/landscapeimage/photos/main/"; $rooturl="/photos/main/"; $cgiroot="h:/landscapeimage/photos/"; $imageurl="/images"; $cgibin="/photos"; $cgilocation = "$cgibin/sectionsearch.pl"; ################################################### # Get Date and Time from Server @days=("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); @longdays=("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"); @month=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); # Get Date and Time from Server $date = localtime(); ($sec,$min,$hour,$mday,$mon,$yr,$wday,$yday,$isdst) = localtime(time); if ($min < 10) {$min="0".$min; } $shorttime="$hour:$min"; $year=$yr+1900; $date1="$days[$wday] $mday $month[$mon] $year at $shorttime"; $date2="$longdays[$wday] $mday $month[$mon] $year at $shorttime"; $thisyear=$year; print "Content-Type: text/html\n\n"; $request_method=$ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $form_info=$ENV{'QUERY_STRING'}; } else { $size_of_info=$ENV{'CONTENT_LENGTH'}; read(STDIN, $form_info, $size_of_info); } @key_value_pairs=split(/&/,$form_info); foreach $key_value (@key_value_pairs) { ($key,$value)=split(/=/,$key_value); $value=~ tr/+/ /; $value=~ s/%([\dA-Fa-f][\dA-Fa-f])/pack("C",hex($1))/eg; $INPUT{$key} = $value; #print "",$key," = ",$value,"
\n"; } $searchstring=$INPUT{'section'}; #$searchstring =~ s/ //g; $searchstring =~ s/_/ /g; $sstring=$searchstring; #$searchstring =~ s/ //g; $searchstring =~ tr/A-Z/a-z/; $picsperframe=$INPUT{'n'}; unless(($searchstring)||($picsperframe)) { #first call - set up the list of search words $searchform=1; &ShowSearchForm; } else { unless ($picsperframe) { $picsperframe=4; } if ($searchstring) { #generate the search index &SearchSetup; } $pic1=$INPUT{"first"}; unless ($pic1) { $pic1=1; } &Header; &GetPhotoData; } &Footer; print "\n"; exit; sub ShowSearchForm { print < Jeff Waldock's Photographs

Jeff's Photos - Section Search


1. Select a section from the list given.
2. Choose the number of images to display per page.
3. Press GO!

Choose a Section: End_of_Section1 $infile=$rootdir."/sectionnames.txt"; open (FILE,$infile); @lines=; close(FILE); $nn=$#lines+1; if ($nn>16) { $nn=16; } print " Select the number of images per page
GO

End_of_Section2 } sub SearchSetup { $infile=$rootdir."index.txt"; open (FILE,$infile); @lines=; close(FILE); $lastdate=$lines[0]; $lastdate =~ s/"//g; $outfile=$rootdir."searchindex.txt"; open (OFILE,">$outfile"); print OFILE "$sstring\n"; $ss = $searchstring; $ss =~ tr/A-Z/a-z/; #print "ss=$ss

\n"; #if ($ss eq "yorkshiredales") { $ss="yorkdale"; } #if ($ss eq "lakedistrict") { $ss="lakedist"; } $sectionfile=$rootdir."sectionnames.txt"; #print "search string=$searchstring
\n"; open (FIL,$sectionfile); @sections=; close(FIL); for ($k=0; $k<=$#sections; $k++) { @sec=split(/\|/,$sections[$k]); $sectitle=$sec[0]; #$sectitle =~ s/ //g; #$sectitle =~ tr/A-Z/a-z/; @sec1=split(/\//,$sec[1]); $nsecs=$#sec1; $secdir=$sec1[$nsecs]; #print "$sectitle ... $secdir

\n"; if ($ss eq $secdir) { $ss=$secdir; #print "BINGO! - $secdir\n"; } } for ($j=1; $j<=$#lines; $j++) { @info=split(/\|/,$lines[$j]); $dir=$info[2]; $dir =~ tr/A-Z/a-z/; if ($dir =~ $searchstring) { #print "$dir - $searchstring
\n"; print OFILE $lines[$j]; } } close(OFILE); #print "hi!\n"; } sub GetPhotoData { $resfile=$rootdir."searchindex.txt"; open (FILE,$resfile); @lines=; close(FILE); $searchstring=$lines[0]; $searchstring =~ s/\n//g; print "

Jeff's Photos

"; $numpix=$#lines; if ($numpix>1) { print "Found $numpix images in the "$searchstring" section

\n"; } else { print "Found 1 image in the "$searchstring" section

\n"; } $p=$picsperframe-1; $pic2=$pic1+$p; $w=(100-$p*5)/$picsperframe; print "\n"; #do the labels in row 1 print "\n"; for ($j=0; $j<=$p; $j++) { print "\n"; if ($j<$p) { print "\n"; } } print "\n"; #do the photo thumbnails in row 2 print "\n"; for ($j=0; $j<=$p; $j++) { print "\n"; if ($j<$p) { print "\n"; } } print "\n"; #do the info in row 3 print "\n"; for ($j=0; $j<=$p; $j++) { print "\n"; if ($j<$p) { print "\n"; } } print "\n"; print "
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; print "$id"; } print " 
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; if ($id) { $section=$info[2]; #$section =~ tr/A-Z/a-z/; $filename=$info[3]; #make lc and remove spaces #$filename=~tr/A-Z/a-z/; #$filename=~s/ //g; $filepath=$filename; @ss=split(/\//,$filename); $nss=$#ss; $thumburl=""; for ($f=0;$f<$nss;$f++) { $thumburl=$thumburl.$ss[$f].'/'; } $thumburl=$thumburl.'thumb/'; $thumburl=$thumburl.$ss[$nss]; $thumburl=~s/\\/\//g; #$thumburl=~tr/A-Z/a-z/; #$thumburl=~s/ //g; $fileurl=$filename; $fileurl=~s/$rootdir/$rooturl/; $thumburl=~s/$rootdir/$rooturl/; $xpix=$info[4]; $ypix=$info[5]; $pixels=$xpix." by ".$ypix." pixels "; ($size)=(stat($filepath))[7]; $filesize="(".int($size/1000)."K)"; print "\"$filesize\"

"; } } print "

 
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; if ($id) { $section=$info[2]; $section =~ tr/A-Z/a-z/; $filename=$info[3]; #make lower case & remove spaces $filename=~tr/A-Z/a-z/; $filename=~s/ //g; $filepath=$filename; @ss=split(/\//,$filename); $nss=$#ss; $thumburl=""; $sectionpath=''; for ($f=0;$f<$nss;$f++) { $thumburl=$thumburl.$ss[$f].'/'; $sectionpath=$sectionpath.$ss[$f].'/'; } $thumburl=$thumburl.'thumb/'; $thumburl=$thumburl.$ss[$nss]; $thumburl=~s/\\/\//g; $fileurl=$filename; $fileurl=~s/$rootdir/$rooturl/; $thumburl=~s/$rootdir/$rooturl/; $xpix=$info[4]; $ypix=$info[5]; $pixels=$xpix." by ".$ypix." pixels "; $imagedet=$info[6]; $datetaken=$info[7]; $keywords=$info[8]; $description=$info[9]; print "$datetaken

"; print "$description

"; $sectionpath=~tr/A-Z/a-z/; #print "
Filename=$filename
Fileurl=$fileurl
Filepath=$filepath
Rootdir=$rootdir
Rooturl=$rooturl
section=$section
Sectionpath=$sectionpath\n"; $thisfile=$filename; $thisfile=~tr/\\/\//; $thisfile=~s/$sectionpath//; @files=<$sectionpath*>; $n=@files-1; for ($jj=0;$jj<=$n;$jj++) { if (-d $files[$jj]) { $xfile=$files[$jj]."/".$thisfile; $yfile=$xfile; $yfile=~s/$rootdir/$rooturl/; $s=$xfile; $s=~s/$sectionpath//; $s=~s/$thisfile//; $s=~s/\///g; if (-e $xfile) { unless ($xfile=~"thumb") { $ypath=$yfile; $ypath=~s/$rooturl/$rootdir/; ($size)=(stat($ypath))[7]; $filesize="(".int($size/1000)."K)"; print "$s pixels $filesize
\n"; } } } } } } print "

\n"; print "

\n"; print "

\n"; print "\n"; print "
\n"; #print "$pic1, $pic2, $numpix
\n"; if (($pic1 > 1)&&($pic2 < $numpix)) { $prevpic=$pic1-$picsperframe; $nextpic=$pic1+$picsperframe; $lastpic=$numpix-$picsperframe+1; print "
"; print "\"Back\n"; print "\"Previous\n"; print "\"Next\n"; print "\"Go\n"; print "
"; } elsif (($pic1<2)&&($pic2>=$numpix)) { } elsif ($pic1 < 2) { $nextpic=$pic1+$picsperframe; $lastpic=$numpix-$picsperframe+1; print "
"; print "\n"; print "\n"; print "\"Next\n"; print "\"Go\n"; print "
"; } elsif ($pic2 >= $numpix) { $prevpic=$pic1-$picsperframe; print "
"; print "\"Back\n"; print "\"Previous\n"; print "\n"; print "\n"; print "
"; } else { } print "
\n"; $picbeg=$pic1; $picend=$pic2; if ($pic2>$numpix) { $picend=$numpix; } print "
Showing $picbeg to $picend of $numpix
\n"; print "
\n"; print "
\n"; } sub Header { print "\n"; print "\n"; print "\n"; print "\n"; } sub Footer { $infile=$rootdir."index.txt"; open (FILE,$infile); @lines=; close(FILE); $lastdate=$lines[0]; $lastdate =~ s/"//g; print "\n"; print "\n"; print "\n"; print "\n"; print "
"; print "\"Back"; unless ($searchform) { print "\"Back"; } print "© Jeff Waldock, $thisyear
\n"; print "This query: $date2
Data file last updated: $lastdate
\n"; }