#!c:/perl/bin/perl.exe ################################################## # Photosearch 02/02/99 by Jeff Waldock # Lists pictures ################################################## $cgilocation = "photosearch.pl"; $rootdir="f:/photos/"; $rooturl="/photos/"; $albumdir=$rootdir."albums/"; $albumurl=$rooturl."albums/"; $cgiroot="f:/photos/"; $imageurl="/sysimage"; $cgibin="/photos"; ################################################### # 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,$year,$wday,$yday,$isdst) = localtime(time); if ($min < 10) {$min="0".$min; } $shorttime="$hour:$min"; $century="19"; if ($year < 50) { $century="20"; } $date1="$days[$wday] $mday $month[$mon] $century$year at $shorttime"; $date2="$longdays[$wday] $mday $month[$mon] $century$year at $shorttime"; $thisyear=$century.$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{'search'}; $picsperframe=$INPUT{'n'}; unless(($searchstring)||($picsperframe)) { #first call - set up the list of search words &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 - keyword search


1. Select a keyword from the list given, or enter a value into the box.
2. Choose the number of images to display per page.
3. Press GO!

Choose a keyword: Select the number of images per page
Enter a keyword: 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 "$searchstring\n"; for ($j=1; $j<=$#lines; $j++) { @info=split(/\|/,$lines[$j]); $kw=$info[8]; if ($kw =~ $searchstring) { print OFILE $lines[$j]; } } close(OFILE); #print "hi!\n"; } sub GetPhotoData { $resfile=$rootdir."searchindex.txt"; open (FILE,$resfile); @lines=; close(FILE); $searchstring=$lines[0]; print "

Jeff's Photos

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

\n"; } else { print "Found 1 image containing "$searchstring"

\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[1]; $section =~ tr/A-Z/a-z/; $filename=$info[2]; $type=$info[3]; $xpix=$info[4]; $ypix=$info[5]; $pixels=$xpix." by ".$ypix." pixels "; $fileurl=$rooturl.$section."/".$filename."\.".$type; $thumburl=$rooturl.$section."/thumb/".$filename."\.".$type; $filepath=$rootdir.$section."/".$filename."\.".$type; #($size)=(stat($filepath))[7]; #$filesize="(".int($size/1000)."K)"; print "\"$pixels$filesize\"

"; } } print "

 
"; if ($j < $numpix) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; if ($id) { $section=$info[1]; $section =~ tr/A-Z/a-z/; $filename=$info[2]; $type=$info[3]; $imagedet=$info[6]; $datetaken=$info[7]; $keywords=$info[8]; $description=$info[9]; $fileurl=$rooturl.$section."/".$filename."\.".$type; $thumburl=$rooturl.$section."/thumb/".$filename."\.".$type; print "$description

"; print "$datetaken"; } } print "

\n"; print "

\n"; print "

\n"; print "\n"; print "
\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 { } $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 "
\"Back© Jeff Waldock, 1999
\n"; print "This query: $date2
Data file last updated: $lastdate
\n"; }