<?php
// PHPSlideShow v0.3 written by Greg Lawler

// v0.2 august 28 2000
// v0.3 september 12 2000 - added support for comments (thanks jonathan)
// v0.3.1 september 29 2000 - added support for image buttons (thanks nicolas)
// v0.3.3 january 9 2001 - added a bit of code so that the pics.txt file is not essential.
//
// from http://www.zinkwazi.com/pages.php?page_name=scripts
// Feel free to use/modify this little script.
// email me at greg@zinkwazi.com if you write any improvements and
// want them included in the next version.
// if you want to send me a gift, i want a hummer (http://www.hummer.com) ;)
// otherwise it's free.
//
// this script comes with no implied warranty. in fact, if it formats your
// system, please don't yell at me... :) (i don't think it will though)
// i will respond to email re bugs though and thanks is always welcome.
// enjoy :)
// greg


// INSTALLATION INSTRUCTIONS
// put this file in a directory that contains your images
// if you only have jpegs for your slide show, you should be good to go now...
//
// v0.3.3 only looks for jpg images by default so if you want to include gifs
// in your slideshow, read on ....
// if you want any comments for your slide show, read on...
//
// make a file (e.g. pics.txt) that contains the image names and descriptions
// with each image name and description on a separate line separated by a semi colon.
// an easy way to do this is type
// ls *.jpg > pics.txt in linux or
// dir *.jpg > pics.txt in dos - you will need edit this with notepad/vi to clean
// out any extra stuff that dir puts in there and to add the semi colon and description.
//
// EXAMPLE pics.txt FILE
//
// greg.jpg;Me
// dog.JPEG;My dog John
// cat;
// tux.Jpg;My friend Tux
//
// NO BLANK LINES either!
// as you can see, not all pics need a description but the ";" is a MUST!
// point your browser at the script and voilla!
//
//////////////////////////////////////////////////////////////////////////////
// variables, modify at will
//
$pic_info_file="pics.txt";
$back_image="left.gif";
$next_image="right.gif";
$header = "PHPSlideshow";
$title = "PHPSlideshow";
//
//////////////////////////////////////////////////////////////////////////////
// html stuff, replace with your sites include() header file
print "<HTML><HEAD><TITLE>$title</TITLE></HEAD>";
print "<BODY>";
print "<CENTER>";
print "<H3><B>$header</H3></B>";

// this part does the work and should need no editing
//
  if ( !file_exists($pic_info_file))
  {
        $dh = opendir( "." );
        while( $file = readdir( $dh ) )
        {
                if (    ereg("jpg$",$file) || ereg("JPG$",$file) ||
                        ereg("jpeg$",$file) || ereg("JPEG$",$file) ||
                        ereg("Jpg$",$file) || ereg("Jpeg$",$file) )
                {
                        $pic_info[] = $file;
                }
        }
  }
  else $pic_info=file("pics.txt");


  $number_of_pics = count ($pic_info);
  if (($picture > $number_of_pics) || ($picture == $number_of_pics) || !$picture)
    $picture = '0';
  $item = explode (";", $pic_info[$picture]);

  // print the description
  print "<b>$item[1]</b><br>";


  $next = $picture + 1;
  if ($picture > 0 ) $back = $picture - 1;
  else $picture = '0';

  // print the next and back links (note $lt; and &gt; to display <> in HTML)
  print "<a href=$PHP_SELF?picture=$back><img src=$back_image border=0 alt=$back_image></a>";
  print "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
  print "<a href=$PHP_SELF?picture=$next><img src=$next_image border=0 alt=$next_image></a><br>";

  // print the image link
  print "<img src=$item[0]><br>&nbsp;<br>";

// end of "work"
//
// html stuff, replace with your sites include() footer file
print "</CENTER></BODY></HTML>";
?>
