#!c:/perl/bin/perl.exe ################################################## # Photos 02/02/99 by Jeff Waldock # Lists pictures ################################################## $rootdir="h:/landscapeimage/photos/main/"; $rooturl="/photos/main/"; $cgibin="/photos"; $imageurl="/images"; $cgilocation = "$cgibin/photos.pl"; $NumPagesPerRow=50; ################################################### # 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"; $year=$year+1900; $date1="$days[$wday] $mday $month[$mon] $year at $shorttime"; $date2="$longdays[$wday] $mday $month[$mon] $year at $shorttime"; #$thisyear=$century+$year; $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"; } $sortorder=$INPUT{'sortorder'}; unless ($sortorder) { $sortorder="LatestFirst"; } $yfile=$INPUT{'yfile'}; $thisid=$INPUT{'id'}; $size=$INPUT{'size'}; if ($yfile) { &ShowPicture; } $picsperframe=$INPUT{'n'}; unless ($picsperframe) { $picsperframe=8; } print < END $pic1=$INPUT{"first"}; unless ($pic1) { $pic1=1; } &GetPhotoData; &Footer; print "\n"; exit; sub Footer { #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; #print "\n"; print "\n"; print "
\"Back© Jeff Waldock, 2000
\n"; #print "This query: $date2
Data file last updated: $lastdate
 
 Page "; #print ""; print <
Back to the Home Page © Jeff Waldock, $thisyear
This query: $date2
 
Page END1 $nframes=int($numpix/$picsperframe)+1; $jpage=1; $kpage=1; for ($jpix=1;$jpix<=$nframes;$jpix++) { $start=($jpix-1)*$picsperframe+1; $end=$start+$picsperframe-1; $thispage=0; $lpage=$jpage; if ($jpage<10) {$lpage="0".$lpage;} #check to see if this is the current page if (($pic1>=$start)&&($pic1<=$end)) { $thispage=1; } if ($end>$numpix) { $end=$numpix; if ($thispage==1) { print "$lpage"; } else { print "$lpage"; } } else { if ($thispage==1) { print "$lpage|"; } else { print "$lpage|"; } } if ($kpage==$NumPagesPerRow) { print "
"; $kpage=1; } else { $kpage++; } $jpage++; } print "
Data file last updated: $lastdate
\n"; } sub SortByFileDate { $zmonth{"January"}="01"; $zmonth{"February"}="02"; $zmonth{"March"}="03"; $zmonth{"April"}="04"; $zmonth{"May"}="05"; $zmonth{"June"}="06"; $zmonth{"July"}="07"; $zmonth{"August"}="08"; $zmonth{"September"}="09"; $zmonth{"October"}="10"; $zmonth{"November"}="11"; $zmonth{"December"}="12"; $zmonth{"Jan"}="01"; $zmonth{"Feb"}="02"; $zmonth{"Mar"}="03"; $zmonth{"Apr"}="04"; $zmonth{"Jun"}="06"; $zmonth{"Jul"}="07"; $zmonth{"Aug"}="08"; $zmonth{"Sep"}="09"; $zmonth{"Oct"}="10"; $zmonth{"Nov"}="11"; $zmonth{"Dec"}="12"; for ($j=1; $j<=$#oldlines; $j++) { @info=split(/\|/,$oldlines[$j]); $lin++; #find the filename (to use as the sort key) @parts=split(/\|/,$oldlines[$j]); #print $parts[0]."
\n"; $filedate=$parts[7]; $filemonth=$filedate; $fileyear=$filedate; $fileyear =~ s/[^0-9 ]//gi; $filemonth =~ s/[0-9]//gi; $fileyear =~ s/ //g; $filemonth =~ s/ //g; $thisdate=$fileyear.$zmonth{$filemonth}; #@fileparts=split(/\\/,$filepath); #$fn=$fileparts[$#fileparts]; #$fn =~ s/[^0-9]//gi; $newlines{$oldlines[$j]}=$thisdate; #print "$thisdate .. $oldlines[$j]
\n"; } if ($sortorder eq "LatestFirst") { @lines=sort { $newlines{$b} <=> $newlines{$a} } keys %newlines; } else { @lines=sort { $newlines{$a} <=> $newlines{$b} } keys %newlines; } #write data to temp.txt $outfile=$rootdir."temp.txt"; #print "outfile=$outfile
\n"; open (NFILE,">$outfile"); print NFILE $lastdate; for ($j=0; $j<$#oldlines; $j++) { print NFILE $lines[$j]; #print $lines[$j]."
\n"; } close(NFILE); } sub GetPhotoData { if (($INPUT{'first'})||($sortorder eq "None")) { $resfile=$rootdir."temp.txt"; open (FILE,$resfile); @lines=; close(FILE); $lastdate=$lines[0]; } else { $resfile=$rootdir."index.txt"; #print "resfile=$resfile
\n"; open (FILE,$resfile); @oldlines=; close(FILE); $lastdate=$oldlines[0]; &SortByFileDate; } #print "HI!
\n"; $lastdate =~ s/"//g; print "

Landscapeimage.com

"; $numpix=$#lines; print "$numpix images

\n"; $p=$picsperframe-1; $pic2=$pic1+$p; if ($pic2>$numpix) {$pic2=$numpix;} $w=(100-$p*5)/$picsperframe; $pnow=$pic2-$pic1+1; $pleft=$p-$pnow; print "\n"; #get the photo information for ($j=0; $j<$pnow; $j++) { @info=split(/\|/,$lines[$pic1+$j-1]); $id[$j]=$info[0]; if ($id[$j]) { $section[$j]=$info[2]; #$section[$j] =~ tr/A-Z/a-z/; $filename[$j]=$info[3]; $filepath[$j]=$filename[$j]; @ss=split(/\//,$filename[$j]); $nss=$#ss; #print "nss=$nss
\n"; $thumburl[$j]=""; $sectionpath[$j]=''; for ($f=0;$f<$nss;$f++) { #print $ss[$f]."\\"; $thumburl[$j]=$thumburl[$j].$ss[$f].'/'; $sectionpath[$j]=$sectionpath[$j].$ss[$f].'/'; } $thumburl[$j]=$thumburl[$j]."thumb\\"; $thumburl[$j]=$thumburl[$j].$ss[$nss]; $thumburl[$j]=~s/\\/\//g; #$thumburl[$j]=~tr/A-Z/a-z/; $fileurl[$j]=$filename[$j]; $fileurl[$j]=~s/$rootdir/$rooturl/; $thumburl[$j]=~s/$rootdir/$rooturl/; $xpix[$j]=$info[4]; $ypix[$j]=$info[5]; $pixels[$j]=$xpix[$j]." by ".$ypix[$j]." pixels "; ($size[$j])=(stat($filepath[$j]))[7]; $filesize[$j]="(".int($size[$j]/1000)."K)"; $imagedet[$j]=$info[6]; $datetaken[$j]=$info[7]; $keywords[$j]=$info[8]; $description[$j]=$info[9]; } } #do the labels in row 1 print "\n"; for ($j=0; $j<=$p; $j++) { $thisfile=$filename[$j]; $thisfile=~tr/\\/\//; $thisfile=~s/$sectionpath[$j]//; $thisfile=~s/.jpg//; if ($j<$pnow) { print "\n"; } else { print "\n"; } } print "\n"; #do the photo thumbnails in row 2 print "\n"; for ($j=0; $j<=$p; $j++) { if ($j<$pnow) { print "\n"; } else { print "\n"; } } print "\n"; #do the info in row 3 print "\n"; for ($j=0; $j<=$p; $j++) { if ($j<$pnow) { print "\n"; } else { print "\n"; } } print "\n"; #links to other sizes in row 4 print "\n"; for ($j=0; $j<=$p; $j++) { if ($j < $pnow) { print "\n"; } else { print "\n"; } } print "\n"; print "
$thisfile 
"; print "\"$pixels[$j]$filesize[$j]\"

"; print "

 
"; print "$datetaken[$j]

"; print "$description[$j]"; print "

 
"; $thisfile=$filename[$j]; #$thisfile=~tr/\\/\//; $thisfile=~s/$sectionpath[$j]//; #$sectionpath[$j]=~tr/\\/\//; $sp=$sectionpath[$j]; @files=<$sp*>; $n=@files-1; for ($jj=0;$jj<=$n;$jj++) { $xfile=$files[$jj]."/".$thisfile; $yfile=$xfile; $yfile=~s/$rootdir/$rooturl/; $s=$xfile; $s=~s/$sectionpath[$j]//; $s=~s/$thisfile//; $s=~s/\///g; if (-e $xfile) { unless ($xfile=~"thumb") { #print "$s pixels
\n"; print "$s pixels
\n"; } } } print "
 
\n"; print "

\n"; print "

\n"; print "\n"; print "
\n"; print "
"; if ($pic1 < 2) { print "\n"; print "\n"; } else { $prevpic=$pic1-$picsperframe; print "\"Back\n"; print "\"Previous\n"; } if ($pic2<$numpix) { $nextpic=$pic1+$picsperframe; $lastpic=$numpix-$picsperframe+1; print "\"Next\n"; print "\"Go\n"; } else { print "\n"; print "\n"; } print "
"; $picbeg=$pic1; $picend=$pic2; if ($pic2>$numpix) { $picend=$numpix; } print "
Showing $picbeg to $picend of $numpix
\n"; print "
\n"; print "
\n"; } sub ShowPicture { print <
END2 $idsel=$thisid; &GetOnePhotoInfo; print "$datetaken  $description

"; print "
\n"; print "

\n"; exit; } sub GetOnePhotoInfo { $resfile=$rootdir."index.txt"; open (FILE,$resfile); @lines=; close(FILE); $lastdate=$lines[0]; $lastdate =~ s/\#//g; $numpix=$#lines; #find the details for this pic for ($j=0; $j<=$numpix; $j++) { @info=split(/\|/,$lines[$pic1+$j]); $id=$info[0]; if ($id == $idsel) { $section=$info[2]; #$section =~ tr/A-Z/a-z/; $filename=$info[3]; $filepath=$filename; @ss=split(/\//,$filename); $nss=$#ss; $fileurl=$filename; $fileurl=~s/\\/\//g; #$fileurl=~tr/A-Z/a-z/; $fileurl=~s/$rootdir/$rooturl/; $imagedet=$info[6]; $datetaken=$info[7]; $keywords=$info[8]; $description=$info[9]; last; } } }