#!/usr/bin/perl -w
##!/usr/bin/perl -wT
#
# LiveFrame - a web based photo album and slideshow application
#
# http://www.liveframe.org
#
# copyright (c)1999, 2000; this is homemade 
# jim@thisishomemade.com
#
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License.
#
# http://www.gnu.org/copyleft/gpl.html
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

BEGIN {
    # add lib directory at start of include path
#    unshift @INC, "/home/kaz/htdocs-kishk.org/lib";
}
use strict;
use CGI ();
use Image::ExifTool qw(:Public);

# CONFIGURTION OPTIONS

my $proto;
#if ("$ENV{'HTTPS'}" == "on") {
#  $proto = "https:";
#} else {
#  $proto = "http:";
#}

# filesystem path to liveframe directory:
#my $lfdir = "/www/liveframe.org/demo/lfdir";
my $lfdir = "/home/kaz/htdocs-kishk.org/picts3";

# URL to liveframe.cgi: 
#my $lfcgiurl = "http://www.liveframe.org/demo/liveframe.cgi";
my $lfcgiurl = "$proto//www.kishk.org/picts3.cgi";

# URL to liveframe directory: 
#my $lfdirurl = "http://www.liveframe.org/demo/lfdir";
my $lfdirurl = "$proto//www.kishk.org/picts3";

# LiveFrame site name: 
my $sitename = "Matthew's Gallery";

# enable start screen: 
my $startscreen = "yes";

# configuration file separator character:
my $sepchar =":";

# use the galleryorder file to do manual gallery ordering:
my $orderon = "yes";

# you shouldn't need to modify anything below this line.
########################################################



# LISTEN TO THE CGI
my $query = new CGI;

my $galleryrequest = $query->path_info() || "unspecified";
my $mode = $query->param('m') || "nonav";
my $show = $query->param('ss') || "no";
my $showspeed = $query->param('showspeed') || "8";
my $showresumespeed = $query->param('showresumespeed') || "8";
my $setsize = $query->param('sz');
my $setpage = $query->param('pg');


# IF GALLERY IS UNSPECIFIED, DISPLAY INDEX 
if ($galleryrequest eq "unspecified") 
  {
    lfindex();
  }


# SET VARIABLES, DO SOME INTITAL THINKING, RUN THE PARSER

my @photos;
my @gallerylist;
my $title;
my $gallerycaption;
my $indextitle;
my $indexcaption;
my $indexpreview;
my $indexed;
my $gallery;
my $page;
my $size;

$galleryrequest = substr($galleryrequest, 1);

($gallery, $page, $size) = split(/\s*\/\s*/, $galleryrequest, 3);


unless (defined $page) 
  {
    $page = $setpage;
  }

unless (defined $page) 
  { 
    if ($startscreen eq "yes")
      {
        $page = "start";
        $mode = "frameset";
      }
      else
      {
        $page = "1";
        $mode = "frameset";
      }
  }
  elsif ($page eq "")
  {
    if ($startscreen eq "yes")
      {
        $page = "start";
        $mode = "frameset";

      }
      else
      {
        $page = "1";
        $mode = "frameset";
      }
  }

if (defined $setsize)
  {
    $size = $setsize;
  }

unless (defined $size)
  {
    $size = "no";
  }


parseconfig();


# DETERMINE PAGE CREATION MODE
if ($mode eq "display")
  {
    picture("display");
  } 
  elsif ($mode eq "nav") 
  {
    picture("nav");
  } 
  elsif ($mode eq "photo") 
  {
    picture("photo");
  } 
  elsif ($mode eq "nonav") 
  {
    if ($page eq "start")
      {
        frameset();
      }
    picture("photo");
  } 
  elsif ($mode eq "preview") 
  {
    preview();
  } 
  elsif ($mode eq "shownav") 
  {
    frameset();
  } 
  else 
  {
    frameset();
  }


# SUB: PARSE THE CONFIG FILE
sub parseconfig 
  {
    my ($parsemode) = @_;
    my @parseindex;
    
    #open(CONFIG, "${lfdir}/galleries/$gallery/config") || error("The gallery specified could not be viewed: $!");
    open(CONFIG, "${lfdir}/galleries/$gallery/config") || next;
    while (<CONFIG>) 
      {
        chomp;
        s/^#.*//;
        s/^\s+//;
        s/\s+$//;
        next unless length;

        unless (defined $parsemode)
          {
            push @photos, [ split(/\s*$sepchar\s*/, $_, 2) ];
          }
          else
          {
            push @parseindex, [ split(/\s*$sepchar\s*/, $_, 2) ];
          } 
      }
  
    $title = $photos[0][0];
    $gallerycaption = $photos[0][1];

    $indextitle = $parseindex[0][0];
    $indexcaption = $parseindex[0][1];
    $indexpreview = $parseindex[1][0];

  }


# SUB: CREATE THE MASTER FRAMESET
sub frameset
  {
  
    my %content = (
      htmllfcgiurl        => $lfcgiurl,
      htmllfdirurl        => $lfdirurl,
      htmltitle           => $title,
      htmlpage            => $page,
      htmlsize            => $size,
      htmlsitename        => $sitename,
      htmlgallery         => $gallery,
      htmlgallerycaption  => $gallerycaption,
      htmlshow            => $show,
      htmlshowspeed       => $showspeed,
    );
  
    header();
    print template("${lfdir}/templates/frameset.tmpl", \%content);
  }


# SUB: CREATE THE PREVIEW PANE
sub preview 
  {
      
    my %content = (
      htmllfcgiurl        => $lfcgiurl,
      htmllfdirurl        => $lfdirurl,
      htmltitle           => $title,
      htmlpage            => $page,
      htmlsize            => $size,
      htmlsitename        => $sitename,
      htmlgallery         => $gallery,
    );
  
    header();
    print template("${lfdir}/templates/previewtop.tmpl", \%content);

    my @list;
    my $x;
    for $x ( 1 .. $#photos ) 
      {
        if (defined $photos[$x][0]) 
          {
            my %content2 = (
              htmllfcgiurl        => $lfcgiurl,
              htmllfdirurl        => $lfdirurl,
              htmltitle           => $title,
              htmlpage            => $page,
              htmlsize            => $size,
              htmlsitename        => $sitename,
              htmlgallery         => $gallery,
              htmlpreviewpage     => $x,
              htmlpreviewname     => $photos[$x][0],
             );
  
            print template("${lfdir}/templates/previewmiddle.tmpl", \%content2);
          }
      }

     print template("${lfdir}/templates/previewbottom.tmpl", \%content);
  }


# SUB: CREATE THE DISPLAY FRAMESET, PHOTO AND NAVIGATION FRAMES
sub picture 
  {
    my $showon = " ";
    my $shownum = "1";
    my $newshowspeed = "8";
    my $showimage = "slideshow";
    my $showbutton = "pause";

    my $sizemenu;
    my $sizeselected;
    my @sizemenuitems;
   
    my $navcount = 1;
    my $navpercent = "50";
    my ($pagemode) = @_;
    
    if ($page eq "start") 
      {
        start();
      } 
      else 
      {
        my $lastnum = $page;
        --$lastnum;
        my $currentnum = $page;
        my $nextnum = $page;
        ++$nextnum;
        
        my $current = $photos[$currentnum][0];
        my $next = $photos[$nextnum][0];
        my $currentphoto = "$current";
        my $caption = $photos[$currentnum][1] || "&nbsp;";
    
    
        if ($startscreen eq "yes")
          {
            if ($lastnum < 1) 
              {
                $lastnum = "start";
              } 
            
            $nextnum = "start" unless $next;
          }
          else
          {
            my $verylastnum = $#photos;

            if ($lastnum < 1) 
              {
                $lastnum = "$verylastnum";
              } 
            
            $nextnum = "1" unless $next;
          }
                      
        if ($show eq "yes") 
          {
            ++$navcount;
            
            if ($showspeed eq "pause")
              {
                $showbutton = "resume";
                $newshowspeed = "$showresumespeed";
                $shownum = "$nextnum";
                $showimage = "slideshowpause";
              }
              else
              {
                $showon = "<META http-equiv=\"refresh\" content=\"$showspeed; URL=${lfcgiurl}/$gallery/$nextnum?m=display&sz=$size&ss=yes&showresumespeed=$showresumespeed%%&showspeed=$showspeed\">";
                $showresumespeed = "$showspeed";
                $newshowspeed = "pause";
                $shownum = "$page";
              }
          }

        if (-d "${lfdir}/galleries/${gallery}/display") 
          {
            $size = "display";
          }
          else
          {
            ++$navcount;
            
              if (-d "${lfdir}/galleries/${gallery}/xsmall")
                { 
                  if ($size eq "no")
                  {
                    $size = "xsmall";
                  }
                    if ($size eq "xsmall")
                      {
                        $sizeselected = " selected";
                      }
                      else
                      {
                        $sizeselected = " ";
                      }
                    push @sizemenuitems, "<option$sizeselected value=\"xsmall\">xs</option>";
                }
                
              if (-d "${lfdir}/galleries/${gallery}/small")
                { 
                  if ($size eq "no")
                  {
                    $size = "small";
                  }
                  if ($size eq "small")
                    {
                      $sizeselected = " selected";
                    }
                    else
                    {
                      $sizeselected = " ";
                    }
                  push @sizemenuitems, "<option$sizeselected value=\"small\">sm</option>";
                }

              if (-d "${lfdir}/galleries/${gallery}/medium")
                { 
                  if ($size eq "no")
                  {
                    $size = "medium";
                  }
                    if ($size eq "medium")
                      {
                        $sizeselected = " selected";
                      }
                      else
                      {
                        $sizeselected = " ";
                      }
                    push @sizemenuitems, "<option$sizeselected value=\"medium\">md</option>";
                }

              if (-d "${lfdir}/galleries/${gallery}/large")
                { 
                  if ($size eq "no")
                  {
                    $size = "large";
                  }
                    if ($size eq "large")
                      {
                        $sizeselected = " selected";
                      }
                      else
                      {
                        $sizeselected = " ";
                      }
                    push @sizemenuitems, "<option$sizeselected value=\"large\">lg</option>";
                }

              if (-d "${lfdir}/galleries/${gallery}/xlarge")
                { 
                  if ($size eq "no")
                  {
                    $size = "xlarge";
                  }
                    if ($size eq "xlarge")
                      {
                        $sizeselected = " selected";
                      }
                      else
                      {
                        $sizeselected = " ";
                      }
                    push @sizemenuitems, "<option$sizeselected value=\"xlarge\">xl</option>";
                }
              if (-d "${lfdir}/galleries/${gallery}/original")
                {
                  if ($size eq "no")
                  {
                    $size = "original";
                  }
                    if ($size eq "original")
                      {
                        $sizeselected = " selected";
                      }
                      else
                      {
                        $sizeselected = " ";
                      }
                    push @sizemenuitems, "<option$sizeselected value=\"original\">org</option>";
                }
          }
                    
      $sizemenu = join "\n", @sizemenuitems;
      
      if ($navcount eq 2)
        {
          $navpercent = "33";
        }
        elsif ($navcount eq 3)
        {
          $navpercent = "25";
        }
    
      if ($currentphoto eq "")
        {
          error("The image specified could not be found.");

        }
    
      
      my %content = (
        htmlsitename        => $sitename,
        htmltitle           => $title,
        htmllfcgiurl        => $lfcgiurl,
        htmllfdirurl        => $lfdirurl,
        htmlgallery         => $gallery,
        htmllastnum         => $lastnum,
        htmlnextnum         => $nextnum,
        htmlpage            => $page,
        htmlcaption         => $caption,
        htmlcurrentphoto    => $currentphoto,
        htmlshow            => $show,
        htmlshowon          => $showon,
        htmlshowspeed       => $showspeed,
        htmlnewshowspeed    => $newshowspeed,
        htmlshowbutton      => $showbutton,
        htmlshowresumespeed => $showresumespeed,
        htmlshownum         => $shownum,
        htmlshowimage       => $showimage,
        htmlsize            => $size,
        htmlsizemenu        => $sizemenu,
        htmlnavpercent      => $navpercent,
      );
            
      header();

      if ($mode eq "display")
        { 
          print template("${lfdir}/templates/display.tmpl", \%content);
        }
        elsif ($mode eq "photo")
        {
          print template("${lfdir}/templates/photo.tmpl", \%content);
	  my $curfile = "${lfdir}/galleries/$gallery/$size/$currentphoto";
          showexif($curfile);
        }     
        elsif ($mode eq "nav")
        {
          print template("${lfdir}/templates/navleft.tmpl", \%content);
          if ($show eq "yes")
            { 
              print template("${lfdir}/templates/navslide.tmpl", \%content);
            }
          unless ($size eq "display")
            {
              print template("${lfdir}/templates/navsize.tmpl", \%content);
            }
          print template("${lfdir}/templates/navright.tmpl", \%content);
        }
      else
        {   
          print template("${lfdir}/templates/photononav.tmpl", \%content);
          my $curfile = "${lfdir}/galleries/$gallery/$size/$currentphoto";
          showexif($curfile);
        }
     }
  }


# SUB: GET A LIST OF GALLERIES
sub getgalleries
  {
    my @hidelist;
    my $hidden;
    my $galleryitem;
    my $gallerydir = "${lfdir}/galleries";
    
    
    if ($orderon eq "yes")
      {
        if (-f "$gallerydir/order.conf")
          {
            open(ORDERFILE, "$gallerydir/order.conf");
            while (<ORDERFILE>) 
              {
                chomp;
                s/#.*//;
                s/^\s+//;
                s/\s+$//;
                next unless length;
              
                push @gallerylist, $_;
              }
          }
          else
          {
            print "<p><b>Error</b><br>order.conf could not be opened: $!<p>(Turn manual gallery ordering off or create an order.conf file!)</p>";
          }                     
      }
      else
      {
        my $hiddenfile = "$gallerydir/hidden.conf";
        
        if (-f "$hiddenfile") 
          {
            open(HIDEFILE, "$hiddenfile");
            while (<HIDEFILE>) 
              {
                chomp;
                s/#.*//;
                s/^\s+//;
                s/\s+$//;
                next unless length;
                
                push @hidelist, $_;
              }

            #unless (defined @hidelist)
            unless (@hidelist)
              {
                $hidden = " ";
              }
              else
              {
                $hidden = join "|", @hidelist;
              }
          }
          else
          {
            $hidden = " ";
          }
          
        opendir(GALLERY, $gallerydir) || 
        error("The gallery directory could not be opened: $!");

        while( defined ($galleryitem = readdir GALLERY) ) 
          {
            next if $galleryitem =~ /^(\.\.??|CVS|hidden.conf|order.conf|$hidden)$/;
            push @gallerylist, "$galleryitem";
          }
      }
  }


# SUB: CREATE START PAGE
sub start 
  {

    my $prevgallerytitle;
    my $prevgallerycaption;
    my $prevgallerypreview;
    my $nextgallerytitle;
    my $nextgallerycaption;
    my $nextgallerypreview;
    my $prevgallery;
    my $nextgallery;
    my $prevgallerynum;
    my $nextgallerynum;
    my $gallerynum;
    my $galleryitem;
    
    getgalleries();

   my $thisgallery = $gallery; 
   my %content;

#    my %content = (
#        htmlsitename          => $sitename,
#        htmltitle             => $title,
#        htmllfcgiurl          => $lfcgiurl,
#        htmllfdirurl          => $lfdirurl,
#        htmlgallery           => $thisgallery,
#        htmlgallerycaption    => $gallerycaption,
#    );

    header();
#    print template("${lfdir}/templates/starttop.tmpl", \%content);


    $gallerynum = 0;
    foreach (@gallerylist)
    {
      if ($_ eq $gallery) 
        { 
          last; 
        } 
        
      $gallerynum++;
    } 
    
    my $lastgallerynum = $#gallerylist;
    
    if ($lastgallerynum > 1)
      {
        
        $prevgallerynum = $gallerynum;
        --$prevgallerynum;
        $nextgallerynum = $gallerynum;
        ++$nextgallerynum;
        
        if ($prevgallerynum < 0) 
          {
            $prevgallerynum = $lastgallerynum;
          } 
    
        if ($nextgallerynum > $lastgallerynum) 
          {
            $nextgallerynum = "0";
          } 

        $gallery = "$gallerylist[$prevgallerynum]";
        $prevgallery = $gallery;  

        parseconfig("parseindex");
        
        $prevgallerytitle = $indextitle;
        $prevgallerycaption = $indexcaption;
        $prevgallerypreview = $indexpreview;
            
        $gallery = "$gallerylist[$nextgallerynum]";
        $nextgallery = $gallery;  

        parseconfig("parseindex");

        $nextgallerytitle = $indextitle;
        $nextgallerycaption = $indexcaption;
        $nextgallerypreview = $indexpreview;

    my %content = (
        htmlsitename          => $sitename,
        htmltitle             => $title,
        htmllfcgiurl          => $lfcgiurl,
        htmllfdirurl          => $lfdirurl,
        htmlgallery           => $thisgallery,
        htmlgallerycaption    => $gallerycaption,
            htmlnextgallery             => $nextgallery,
            htmlprevgallery             => $prevgallery,
    );
    print template("${lfdir}/templates/starttop.tmpl", \%content);
        
        my %content2 = (
            htmllfcgiurl                => $lfcgiurl,
            htmllfdirurl                => $lfdirurl,
            htmlprevgallery             => $prevgallery,
            htmlnextgallery             => $nextgallery,
            htmlprevgallerytitle        => $prevgallerytitle,
            htmlprevgallerycaption      => $prevgallerycaption,
            htmlprevgallerypreview      => $prevgallerypreview,
            htmlnextgallerytitle        => $nextgallerytitle,
            htmlnextgallerycaption      => $nextgallerycaption,
            htmlnextgallerypreview      => $nextgallerypreview,       

    );

        print template("${lfdir}/templates/startmiddle.tmpl", \%content2);

      }
    
    print template("${lfdir}/templates/startbottom.tmpl", \%content);

    exit;
  }


# SUB: CREATE INDEX
sub lfindex 
  {

    my %content = (
        htmltitle           => $title,
        htmllfcgiurl        => $lfcgiurl,
        htmllfdirurl        => $lfdirurl,
        htmlsitename        => $sitename,

    );
    
    header();

    print template("${lfdir}/templates/galleryindextop3.tmpl", \%content);

    getgalleries();

    my $myxcount;
    $myxcount = 0;
    my $x;
    for $x (reverse(@gallerylist)) 
      {
        $gallery = $x;
        parseconfig("parseindex");
        
        my %listcontent = (
            htmllfcgiurl          => $lfcgiurl,
            htmllfdirurl          => $lfdirurl,
            htmlgallery           => $gallery,
            htmlindextitle        => $indextitle,
            htmlindexcaption      => $indexcaption,
            htmlindexpreview      => $indexpreview,

       );
       if ($myxcount eq 0) {
         print template("${lfdir}/templates/galleryindexitemleft.tmpl", \%listcontent);
         $myxcount = 1;
       } elsif ($myxcount eq 1) { 
         print template("${lfdir}/templates/galleryindexitemcenter.tmpl", \%listcontent);
         $myxcount = 2;
       } elsif ($myxcount eq 2) { 
         print template("${lfdir}/templates/galleryindexitemright.tmpl", \%listcontent);
         $myxcount = 0;

       } else {
         print template("${lfdir}/templates/galleryindexitem.tmpl", \%listcontent);
       }
       #print template("${lfdir}/templates/galleryindexitem.tmpl", \%listcontent);

    }

    print template("${lfdir}/templates/galleryindexbottom3a.tmpl", \%content);
    print template("${lfdir}/galleries/video.inc", \%content);
    print template("${lfdir}/templates/galleryindexbottom3b.tmpl", \%content);
    
    exit;
  }


#SUB: HTML HEADER
sub header 
  {
    print "Content-type: text/html\n\n";
  }


# SUB: TEMPLATE GENERATOR
sub template 
  {
    my ($templatename, $contents) = @_;
    my $text;
    local $/;
    local *TMPL;
    open(TMPL, "< $templatename\0") || return;
    $text = <TMPL>;
    close(TMPL);

    $text =~ s{ %% ( .*? ) %% }
    { exists( $contents->{$1} )
        ? $contents->{$1}
        : ""
    }gsex;
    return $text;
  }


# SUB: ERROR HANDLING
sub error 
  {
    my ($message) = @_;

    my %content = (
      htmlsitename        => $sitename,
      htmlmessage         => $message,
      htmllfcgiurl        => $lfcgiurl,
      htmllfdirurl        => $lfdirurl,

    );

    header();
    print template("${lfdir}/templates/error.tmpl", \%content);

    exit;
  }

sub showexif {
  my ($curfile) = @_;
  my $exif = ImageInfo("$curfile");

# for debug
#foreach (keys %$exif) {
#    print "$_ : $exif->{$_}<br>\n";
#}


my $fl35mm = "($$exif{'FocalLengthIn35mmFormat'}mm)" if ("$$exif{'FocalLengthIn35mmFormat'}" ne "");

my $curfile2 = $curfile;
$curfile2 =~ s/small/original/g;
$curfile2 =~ s/medium/original/g;
$curfile2 =~ s/large/original/g;
my $curfile3 = $curfile2;
$curfile3 =~ s/\/home\/kaz\/htdocs-kishk.org\///;

print << "(EOF)" if (-f $curfile2);
<center><small><a href=/savefile.php?file=$curfile3 title="Click here to save printable version"><img src=/img/print.png border=0></a></small></center>
(EOF)


print << "(EOF)" if ($$exif{'ISO'} ne "");
<link rel="stylesheet" type="text/css" media="all" href="/css/table.css" />
<table align=center class=videotable style="font-size: 70%;">
<tr bgcolor=CCCCCC>
 <td>File Size</td>
 <td>Image Size</td>
 <td>ISO</td>
 <td>Shutter speed</td>
 <td>F Number</td>
 <td>Focal length (35mm)</td>
 <td>Hyperfocal Distance</td>
</tr>
<tr>
 <td>$$exif{'FileSize'}</td>
 <td>$$exif{'ImageSize'}</td>
 <td>$$exif{'ISO'}</td>
 <td>$$exif{'ShutterSpeed'}</td>
 <td>$$exif{'FNumber'}</td>
 <td>$$exif{'FocalLength'} $fl35mm</td>
 <td>$$exif{'HyperfocalDistance'}</td>
</tr>
<tr bgcolor=CCCCCC>
 <td>Focus Mode</td>
 <td>AF Aperture</td>
 <td>AF Area Mode</td>
 <td>AF Point</td>
 <td>AF Points Used</td>
 <td>Focus Position</td>
 <td>Focus Distance</td>
</tr>
<tr>
 <td>$$exif{'FocusMode'}</td>
 <td>$$exif{'AFAperture'}</td>
 <td>$$exif{'AFAreaMode'}</td>
 <td>$$exif{'AFPoint'}</td>
 <td>$$exif{'AFPointsUsed'}</td>
 <td>$$exif{'FocusPosition'}</td>
 <td>$$exif{'FocusDistance'}</td>
</tr>
<tr bgcolor=CCCCCC>
 <td>Light Source</td>
 <td colspan=2>Flash</td>
 <td>Flash Setting</td>
 <td>Flash Type</td>
 <td>Depth of Field</td>
 <td>Shutter Count</td>
</tr>
<tr>
 <td>$$exif{'LightSource'}</td>
 <td colspan=2>$$exif{'Flash'}</td>
 <td>$$exif{'FlashSetting'}</td>
 <td>$$exif{'FlashType'}</td>
 <td>$$exif{'DOF'}</td>
 <td>$$exif{'ShutterCount'}</td>
</tr>
<tr bgcolor=CCCCCC>
 <td colspan=2>Copyright</td>
 <td>Date/Time Original</td>
 <td colspan=4>Lens ID</td>
<tr>
 <td colspan=2>$$exif{'Copyright'}</td>
 <td colspan=1>$$exif{'DateTimeOriginal'}</td>
 <td colspan=4>$$exif{'LensID'}</td>
</tr>
</table>
(EOF)

print << "(EOF)" if ($$exif{'ISO'} eq "");
<link rel="stylesheet" type="text/css" media="all" href="/css/table.css" />
<table align=center class=videotable style="font-size: 70%;">
<tr bgcolor=CCCCCC>
 <td>Copyright</td>
 <td>Date/Time Original</td>
 <td>File Size</td>
 <td>Image Size</td>
</tr>
<tr>
 <td>$$exif{'Copyright'}</td>
 <td>$$exif{'DateTimeOriginal'}</td>
 <td>$$exif{'FileSize'}</td>
 <td>$$exif{'ImageSize'}</td>
</tr>
</table>

(EOF)

}
