<?

/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

album.php version 1.2
an automated web photo album
coded by T-rev 2004

requires consecutively numbered .jpg photos

separate thumbnail images not required, but if present must be numbered 
 corresponding to full-size images.

customize by modifying only:
 1) user settings directly below
 2) top-of-page HTML
 3) bottom-of-page HTML

EXAMPLE--if photo filenames range from DCP_0247.jpg to DCP_0273.jpg, and thumbnail 
filenames range from DCP_0247t.jpg to DCP_0273t.jpg then the settings should be as
follows:

E           $first = 247;      # EXAMPLE number of the first photo.
 X           $last = 273;      # EXAMPLE number of the last photo.
  A        $digits = 4;        # EXAMPLE number of digits of photo numbers.
   M       $prefix = "DCP_";   # EXAMPLE photo filename prefix.
    P      $suffix = ".JPG";   # EXAMPLE photo filename suffix.
     L     $thumbs = "1";      # EXAMPLE "1" if separate thumbnail images, otherwise "0".
      E   $tprefix = "DCP_";   # EXAMPLE thumbnail filename prefix.
       S  $tsuffix = "t";      # EXAMPLE thumbnail filename suffix.

 $title = array( "",                           # don't modify this line.
E                "Jim",                        # image 247 title.  image titles optional, not required.
 X               "Sue",                        # image 248 title.
  A              "",                           # image 249 has no title.
   M             "Mary",                       # image 250 title.
E   P            "John",                       # 251.
 X   L           "Pat",                        # 252, etc.  copy lines as needed.
  A   E          "Jim&#39;s hat",              # 253 appears as «Jim's Hat».  must use &#39; for apostrophe.
   M   S         "Sue and &quot;friend&quot;", # 254 appears as «Sue and "friend"».  must use &quot; for quotation mark.
    P            "Pam",                        # 255.
     L    263 => "Jim",                        # 263.  256 thru 262 have no title; the "263 =>" skips ahead to 263.
      E          "Pat",                        # 264.  continues from previous line, if lines are sorted in ascending order.
       S       )

NOTE that THE ABOVE NOT THE ACTUAL SETTINGS, but only an example.  the 
settings that you must modify are directly below.

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/


/*          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            ******************  BEGIN USER SETTINGS  ******************
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          */

   $first = 1;                # number of the first photo.
    $last = 165;              # number of the last photo.
  $digits = 3;                # number of digits of photo numbers.
  $prefix = "mexico-2004-";   # photo filename prefix.
  $suffix = ".jpg";           # photo filename suffix.
  $thumbs = "1";              # "1" if separate thumbnail images, otherwise "0".
 $tprefix = "s-mexico-2004-"; # thumbnail filename prefix.
 $tsuffix = "";               # thumbnail filename suffix.

 $title = array( "",   # don't modify this line.
1 => "morning hack after night in Odessa",
2 => "morning hack after night in Odessa",
3 => "gathered to pray before 2nd travel day",
4 => "gathered to pray before 2nd travel day",
5 => "gathered to pray before 2nd travel day",
6 => "gathered to pray before 2nd travel day",
7 => "lunch and frisbee stop",
8 => "water for charlie&#39;s radiator",
9 => "water break for laura and héctor",
10 => "getting some help",
11 => "lance",
12 => "jon",
13 => "brenda, jess & becky",
14 => "tom and val",
15 => "sophia and kellie",
16 => "jess, travis, becky",
17 => "freddie",
18 => "joey, kristina",
19 => "jake",
20 => "tar paper and bird blocks",
29 => "bus passing",
30 => "tar babes",
36 => "&quot;pink caddy&quot;",
38 => "jordan",
39 => "lance",
40 => "jess, kendra, travis",
41 => "rooftop view",
45 => "the RV is another american group",
46 => "rooftops",
60 => "centerline joists...",
62 => "tazmania abarrotes in background",
69 => "big red",
72 => "little helper",
73 => "joseph, andy",
75 => "kellie and joseph",
76 => "chicken wire and plywood",
77 => "eric, jordan?, travis",
78 => "laura de-bubbling chicken wire",
81 => "first stucco layer",
82 => "lunch",
83 => "it was nice",
89 => "new shade",
90 => "new window",
100 => "back door",
113 => "fanta break time",
115 => "tazmania abarrotes",
116 => "amor campsite",
119 => "smoke in the flash",
124 => "long exposure",
131 => "my flash in sam&#39;s long exposure",
133 => "stars and toilet",
134 => "freddie and kids",
135 => "joey and kids",
137 => "me and laura",
138 => "sophia",
139 => "sam gesturing inexplicably",
140 => "jordan not feeling well",
141 => "stucco window",
142 => "tom&#39;s popular magic show",
147 => "group and house",
148 => "midair hack in camp",
153 => "lance&#39;s hole",
165 => "saluting the jeans",
 );


/*           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             ******************  END USER SETTINGS  ******************
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~           */

$page  = $_GET['page'];
$photo = $_GET['photo'];
$show  = $_GET['show'];

$mode = "";
if (($photo < $first) || ($photo > $last)) {$photo = "";}
if ($photo != "") {$mode = "display";}

$total = 1 + $last - $first;

switch ($mode) {
case "":

?>


<!--       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
           ******************  Begin top-of-page HTML  ****************** 
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        --> 

<HTML>
<HEAD>
   <TITLE>Mexico 2004</TITLE>
   <BASE TARGET="_top">
<LINK REL="shortcut icon" HREF="/favicon.ico">
</HEAD>
<BODY>

<CENTER>

<P>
<FONT SIZE=+1>2004 Mexico Trip</FONT>


<!--        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
            ******************  End top-of-page HTML ******************  
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~          --> 

<?

 if ($thumbs!="1") {
  $wcode = " WIDTH=150";
  $tprefix = $prefix;
  $tsuffix = $suffix;
 }

if (($show < 1) || ($show=="")) {$show = 9;}

$totpages = ceil($total / $show);

if ($page > $totpages) {$page = $totpages;}
if (($page < 1) || ($page=="")) {$page = 1;}

$start = $first + ($show * ($page - 1));
$end = $start + $show - 1;
if ($end > $last) {$end = $last;}

$startd = $start + 1 - $first;
$endd = $end + 1 - $first;

$prev = $page - 1;
$next = $page + 1;


echo "<A NAME='top' /><FONT SIZE=+1>Images <B>$startd&#150;$endd</B> of <B>$total</B></FONT> &nbsp; \n\n";


echo "<BR>\n";


if ($page != 1) {echo "<FONT SIZE=+1><A HREF='$PHP_SELF?page=$prev&show=$show' TITLE='Preceding Page'>Previous</A></FONT>&nbsp; \n\n";}

echo "<FONT SIZE=+1>\n";
  $number = 1;
    while ($number <= $totpages):
      if ((abs($number - $page) < 6) || (($number - 1)*($number - $totpages)*($number % 10)==0)) {
        if ($number==$page) {
          echo "<B>$number</B>\n";}
        else {
          echo "<A HREF='$PHP_SELF?page=$number&show=$show' TITLE='Page $number'>$number</A>\n";}
      } else if (($number - $page - 6)*($number - 2)*(($number - 1) % 10)==0) {echo "...\n";}
      $number++;
    endwhile;
echo "</FONT>\n\n";

if ($page != $totpages) {echo "<FONT SIZE=+1><A HREF='$PHP_SELF?page=$next&show=$show' TITLE='Next Page'>Next</A></FONT> &nbsp; \n\n";}


echo "<P>\n";


  $number = $start;
    while (($number <= $last) && ($number < $start + $show)):
      $numt = $number + 1 - $first;
      $snum = strval($number);
        while (strlen($snum) < $digits):
          $snum = "0" . $snum;
        endwhile;
      echo "<A HREF='$PHP_SELF?photo=$number&show=$show' TITLE='Image $numt of $total&#10;$title[$numt]&#10;Click for larger view'><IMG SRC='$tprefix$snum$tsuffix.jpg'$wcode /></A> &nbsp;\n";
      $number++;
    endwhile;


echo "\n<BR>\n";


echo "  <FORM METHOD='get' NAME='resize' ACTION='$PHP_SELF'>\n";
echo "    <INPUT TYPE='hidden' NAME='page' VALUE='$page' />\n\n";

if ($page != 1) {echo "<FONT SIZE=+1><A HREF='$PHP_SELF?page=$prev&show=$show' TITLE='Preceding Page'>Previous</A></FONT> &nbsp; \n\n";}

echo "<FONT SIZE=+1>Page <B>$page</B> of <B>$totpages</B></FONT> &nbsp; \n\n";

if ($page != $totpages) {echo "<FONT SIZE=+1><A HREF='$PHP_SELF?page=$next&show=$show' TITLE='Next Page'>Next</A></FONT>\n\n";}

echo "<BR>\n";

echo "  Thumbnails per page:\n";
echo "    <SELECT NAME='show' onChange=\"forms['resize'].submit() \">\n";
  for ($i=3; $i<51; $i++):
    if ($i==$show) {echo "      <OPTION VALUE='$i' SELECTED='true'>$i</OPTION>\n";}
    else           {echo "      <OPTION VALUE='$i'>$i</OPTION>\n";}
  endfor;
echo "    </SELECT> &nbsp; \n\n";

echo "<BR>\n";
echo "<FONT SIZE=-1><A HREF='http://home.t-rev.net/photos/album.php.html' TITLE='Feel free to use this.'>source code for this page</A></FONT>\n\n";

echo "  </FORM>\n\n";

echo "<P>\n\n";

?>

<!--     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
         ******************  Begin bottom-of-page HTML  ****************** 
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       --> 

<HR>
<P>
All these photos can be downloaded at maximum resolution  
<A HREF=mexico-2004-all.zip>here</A> (45.4MB .zip file).<BR>
Joseph has another photo album from the trip <A HREF="http://linux.csce.uark.edu/~jlr09/mexico2004/">here</A>.

<P>
To see the <B>2004 Trip Journal</B> <A HREF="journal/">click here</A>.

<P>
Back to the <A HREF="../mexico.htm">Main Mexico Page</A>, 
 the <A HREF="../">Main Photo Album</A> or 
 my <A HREF="../../">Home Page</A></CENTER>

</BODY>
</HTML>

<!--      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
          ******************  End bottom-of-page HTML  ****************** 
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~        --> 

<?

break;
case "display":

  $numt = $photo + 1 - $first;
  $page = ceil($numt / $show);
   $snum = strval($photo);
    while (strlen($snum) < $digits):
      $snum = "0" . $snum;
    endwhile;
  $prev = $photo - 1;
  $next = $photo + 1;


    echo "<HTML>\n<HEAD>\n<TITLE>Image $numt of $total &nbsp; $title[$numt]</TITLE>\n<LINK REL=\"shortcut icon\" HREF=\"/favicon.ico\">
\n</HEAD>\n<BODY>\n\n";
    echo "<CENTER>\n\n<P>\n<FONT SIZE=+2>Image $numt of $total &nbsp; &nbsp; $title[$numt]</FONT>\n\n";

    echo "<TABLE ALIGN='center'><TR><TD WIDTH=80 ALIGN='left'>\n";

  if ($photo != $first) {echo "    <FONT SIZE=+1><A HREF='$PHP_SELF?photo=$prev&show=$show' TITLE='Preceding Image'>Previous</A></FONT>&nbsp; \n";}

    echo "  &nbsp;</TD><TD WIDTH=200 ALIGN='center'>\n";

  echo "    <FONT SIZE=+1><A HREF='$PHP_SELF?page=$page&show=$show' TITLE='Thumbnail view'>Back to thumbnails</A></FONT>\n";

    echo "  </TD><TD WIDTH=80 ALIGN='right'>&nbsp;\n";

  if ($photo != $last) {echo "    <FONT SIZE=+1><A HREF='$PHP_SELF?photo=$next&show=$show' TITLE='Next Image'>Next</A></FONT>&nbsp; \n";}

    echo "  </TD></TR></TABLE><TABLE ALIGN='center'><TR><TD ALIGN='center'>\n";

echo "\n      <A HREF='$PHP_SELF?photo=$next&show=$show' TITLE='Next Image'><IMG SRC='$prefix$snum$suffix' ALT='Image $numt of $total&#10;$title[$numt]' BORDER=0 /></A>\n\n";

    echo "  </TD></TR></TABLE><TABLE ALIGN='center'><TR><TD ALIGN='left'>\n";

  if ($photo != $first) {echo "    <FONT SIZE=+1><A HREF='$PHP_SELF?photo=$prev&show=$show' TITLE='Preceding Image'>Previous</A></FONT>&nbsp; \n";}

    echo "  &nbsp;</TD><TD WIDTH=200 ALIGN='center'>\n";

  echo "    <FONT SIZE=+1><A HREF='$PHP_SELF?page=$page&show=$show' TITLE='Thumbnail view'>Back to thumbnails</A></FONT>\n";

    echo "  </TD><TD WIDTH=80 ALIGN='right'>&nbsp;\n";

  if ($photo != $last) {echo "    <FONT SIZE=+1><A HREF='$PHP_SELF?photo=$next&show=$show' TITLE='Next Image'>Next</A></FONT>&nbsp; \n";}

    echo "</TD></TR></TABLE>\n\n";

    echo "</BODY>\n</HTML>\n";


break;
}

?>