#!/usr/local/bin/perl
#######################################################################
#
# Image Index 1.0
# Show all .gif and .jpg images in a given directory 
#
# Goto sections marked 1. and 2. and 3. to make program changes.
# Then place this script in your CGI-BIN folder.
#
# Copyright 1999, Mike Hundt, All Rights Reserved
#  email - mchundt@nglic.com
#
#######################################################################
# VARIABLES USED IN CODE
$pos=0;
$upname="";
$count=0;
# 1. BELOW IS THE URL TO THE GRAPHIC IMAGES
$imgpath="http://intranet/graphics/bullets/";
#######################################################################

# 2. CHANGE THE DIRECTORY BELOW TO REPRESENT WHERE THE IMAGES TO SHOW ARE.
#    THIS IS SET UP FOR A PATH ON AN NT SERVER, YOU MUST CHANGE FOR UNIX SYSTEMS.
#    A UNIX PATH WOULD BE SOMETHING LIKE... /home/user/public_html/graphics/
opendir(CURDIR,"E:\\www\\graphics\\bullets\\")||die("Cannot open Directory!");

@names=readdir(CURDIR);
print "Content-type: text/html", "\n\n";
print "<html><head><title>Bullets</title></head>\n";
print "<BODY><TABLE BORDER='0' CELLPADDING=4 CELLSPACING =0 WIDTH='100%'>\n";
print "<p align=center><font face=Verdana, Arial, san serif SIZE=+1>Bullets</font></p>\n
<blockquote><blockquote>
<p><font face='Verdana, Arial, san serif' SIZE=-1>You will find these graphics at i://www/graphics/bullets.</font></p>
</blockquote></blockquote>";
for $name(@names)
{
  if ($count==0)
    {
      print "<TR>\n";
    }
  $upname=uc($name);
  $pos=index($upname,".GIF");
  if ($pos > 0)
    {
      print "<TD ALIGN='CENTER'><IMG SRC='".$imgpath.$name."'><BR><font face='Verdana, Arial, san serif' SIZE=-1>$name</font></TD>\n";
      $count=$count+1;
    }
# IF YOU HAVE FILES ENDING LIKE .JPEG CHANGE BELOW TO .JP
    $pos=index($upname,".JPG");
  if ($pos > 0)
    {
      print "<TD ALIGN='CENTER'><IMG SRC='".$imgpath.$name."'><BR><font face='Verdana, Arial, san serif' SIZE=-1>$name</font></TD>\n";
      $count=$count+1;
    }

# 3. CHANGE THE NUMBER BELOW TO HOW MANY COLUMNS TO DISPLAY ACCROSS THE PAGE.
  if ($count==4)
    {
      print "</TR>\n";
      $count=0;
    }
}
closedir(CURDIR);
if ($count>0)
  {
    print "</TR>\n";
  }
print "</TABLE></body></html>\n";


