#!/usr/bin/perl

################################################################################
################################################################################
##  _____   _____   _____     _____   _____   _____   _____                   ##
## |_   _| /  _  \ /  _  \   /  ___| /  _  \ /  _  \ |  _  \                  ##
##   | |   | | | | | | | |   | |     | | | | | | | | | | | |                  ##
##   | |   | | | | | | | |   | |  _  | | | | | | | | | | | |                  ##
##   | |   | |_| | | |_| |   | |_| | | |_| | | |_| | | |_| |                  ##
##   |_|   \_____/ \_____/   \_____/ \_____/ \_____/ |_____/                  ##
##      _____   _____   _____   _____   _        _      ___   _____    _____  ##
##     /  ___/ /  _  \ |  ___| |_   _| | |      | |    /   | |  _  \  | ____| ##
##     | |___  | | | | | |__     | |   | |  __  | |   / /| | | |_| |  | |__   ##
##     \___  \ | | | | |  __|    | |   | | /  \ | |  / /_| | |  _  /  |  __|  ##
##      ___| | | |_| | | |       | |   | |/ __ \| | / ___  | | | \ \  | |___  ##
##     /_____/ \_____/ |_|       |_|   |___/  \___|/_/   |_| |_|  \_\ |_____| ##
##                                                                            ##
################################################################################
##                 Software That's So Good... It's Too Good!                  ##
################################################################################
##                                                                            ##
##     Program Name: Image Gallery                                            ##
##     Purpose: Displays all images in a folder                               ##
##     Author: Jeffrey Wong                                                   ##
##     Date: February 12, 2003                                                ##
##     Version: Version 1.2                                                   ##
##     () If there are any bugs, you can fill in the report a bug form        ##
##        avalable at http://www.toogoodsoftware.com                          ##
##     () If you have any suggestions or comments, you can send them to       ##
##        me at http://www.toogoodsoftware.com                                ##
##     () Hope you enjoy the program!                                         ##
##                                                                            ##
##                                                                            ##
################################################################################
################################################################################

################################################################################
#Begin configurations                                                          #
################################################################################
# Square size (number of rows and columns)
$square = 5; # Default is 5 X 5

# Width and Height of each picture on index page
$viewPageWidth=100;
$viewPageHeight=100;

# Width and Height of each picture when viewed magnified
$viewPictureWidth=400;
$viewPictureHeight=400;

# directory of images
$directoryOfImages = "/usr/home/www/virtual/gallery/"; #absolute path to images (include trailing slash) NOT URL!!!

# url to image directory
$imageURL = "http://www.v-world.dn.ua/gallery/"; #include trailing slash

# Admin Details
$password = "passwordqqq"; #admin password

#script url, include ? after gallery.pl
$url = "http://www.v-world.dn.ua/cgi-bin/gallery.pl?";

# Header
# What Is Displayed Before Pictures
sub header {
    print "Content-type: text/html\n\n";
print <<HEADER;

<html>
<head>
<title>Компьютерный клуб &quot;Виртуальный мир&quot;</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<link rel="stylesheet" href="/vworld.css" type="text/css">
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<script language="JavaScript" src="/vote.js"></script>
</head>

<body bgcolor="#000071" text="#FFFFFF" background="/images/bk.gif" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('/images/menu/2_01.gif','/images/menu/2_02.gif','/images/menu/2_03.gif','/images/menu/2_04.gif','/images/menu/2_05.gif','/images/menu/2_06.gif','/images/menu/2_07.gif','/images/upper2.gif')">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/menu_bk.gif">
        <tr valign="top"> 
          <td><a href="http://www.v-world.dn.ua/cgi-bin/news.cgi" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','/images/menu/2_01.gif',1)"><img name="Image2" border="0" src="/images/menu/1_01.gif" width="75" height="81"></a><a href="/about.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','/images/menu/2_02.gif',1)"><img name="Image3" border="0" src="/images/menu/1_02.gif" width="73" height="81"></a><a href="/forum/" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','/images/menu/2_03.gif',1)"><img name="Image4" border="0" src="/images/menu/1_03.gif" width="72" height="81"></a><a href="/cgi-bin/guest.cgi" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','/images/menu/2_04.gif',1)"><img name="Image5" border="0" src="/images/menu/1_04.gif" width="65" height="81"></a><a href="/links.htm" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','/images/menu/2_05.gif',1)"><img name="Image6" border="0" src="/images/menu/1_05.gif" width="65" height="81"></a><a href="/cgi-bin/hero.cgi" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','/images/menu/2_06.gif',1)"><img name="Image7" border="0" src="/images/menu/1_06.gif" width="59" height="81"></a><a href="/cgi-bin/cd.cgi" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','/images/menu/2_07.gif',1)"><img name="Image8" border="0" src="/images/menu/1_07.gif" width="70" height="81"></a><a href="http://chat.v-world.dn.ua" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image81','','/images/menu/2_07.gif',1)"><img name="Image9" border="0" src="/images/menu/1_031.gif" width="70" height="81" alt="Наш чат"></a></td>
          <td width="300"> 
            <div align="right"><img src="/images/menu_right.gif" width="229" height="81" border="0" usemap="#Map2"></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td valign="top"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/logo_bk.gif">
        <tr valign="top"> 
          <td><img src="/images/logo_left.gif" width="204" height="42"></td>
          <td> 
            <div align="right"><img src="/images/logo.gif" width="577" height="42"></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="100%" valign="top">
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top">
                  <table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/news_bk.gif">
                    <tr valign="top"> 
                      <td><img src="/images/title/gal-title.gif" width="304" height="33"></td>
                      <td> 
                        <div align="right"><img src="/images/news_right.gif" width="11" height="33"></div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr>
                <td valign="top">
                  <table width="100%" border="0" cellspacing="5" cellpadding="0">
                    <tr> 
                      <td width="5">&nbsp;</td>
                      <td valign="top"> 

HEADER
}

# Footer
# What Is Displayed After Pictures

sub footer {
print <<FOOTER
                      </td>
                    </tr>
                    <tr> 
                      <td width="5">&nbsp;</td>
                      <td valign="top">

                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
          <td width="244" valign="top" background="/images/vote_bk.gif"> <table width="100%" border="0" cellspacing="5" cellpadding="0">
              <tr valign="middle"> 
                <td align="center"> <p><a href="http://www.ins.dn.ua" target="_blank"><img src="/images/banners/INS1.gif" border="0" alt="Наш интернет провайдер!"></a>&nbsp;</p></td>
                <td align="center"> <a href="http://www.tehnopolis.com.ua" target="_blank"><img src="/images/banners/tp1.gif" width="88" height="31" border="0" alt="Сайт газеты &quot;Технополис&quot;"></a></td>
              </tr>
              <tr valign="middle"> 
                <td align="center"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="88" height="31">
                    <param name="movie" value="/images/banners/uacc_dn_2.swf">
                    <param name="quality" value="high">
                    <embed src="/images/banners/uacc_dn_2.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="88" height="31"></embed></object></td>
                <td align="center"> <div align="center"><a href="http://www.uacc.org.ua"><img src="/images/banners/uacc_banner_main.gif" border="0" alt="ВАКК"></a></div></td>
              </tr>
            </table>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top"><img src="/images/vote.gif" width="244" height="33"></td>
              </tr>
              <tr>
                <td valign="top">
                  <table width="100%" border="0" cellspacing="5" cellpadding="0">
                    <tr>
                      <td valign="top"> <br>
                        <!-- vote -->
                      </td>
                    </tr>
                  </table>
                               
                </td>
              </tr>
              
              <tr>
              <td align="center"><br><br>


            <!-- bigmir)net TOP 100 -->
            <a href=http://www.bigmir.net/?cl=43950 target=_blank> 
            <script language="javascript">
<!--
bmQ='<img src=http://c.bigmir.net/?s43950&t7'
bmD=document
bmD.cookie="b=b"
if(bmD.cookie)bmQ+='&c1'
//-->
</script>
            <script language="javascript1.2">
<!-- 
bmS=screen;bmQ+='&d'+(bmS.colorDepth?bmS.colorDepth:bmS.pixelDepth)+"&r"+bmS.width;
//-->
</script>
            <script language="javascript">
<!--
bmF = bmD.referrer.slice(7);
((bmI=bmF.indexOf('/'))!=-1)?(bmF=bmF.substring(0,bmI)):(bmI=bmF.length);
if(bmF!=window.location.href.substring(7,7+bmI))bmQ+='&f'+escape(bmD.referrer);
bmD.write(bmQ+" border=0 width=88 height=31 alt='bigmir TOP100'>");
//-->
</script>
            </a> <br> 
            <!-- BEGIN OF PING CODE -->
            <a href=http://www.topping.com.ua/ target=_blank><img src=http://counter.topping.com.ua:80/cgi-bin/ping.cgi?121002132547;count17 width=88 height=31 border=0 alt="Rated by PING"></a> 
            <!-- END OF PING CODE -->
            <br> 
            <!--Rating\@Mail.ru COUNTER-->
            <script language="JavaScript">
<!--
d=document;a='';a+=';r='+escape(d.referrer)
js=10//--></script> <script language="JavaScript1.1"><!--
a+=';j='+navigator.javaEnabled()
js=11//--></script> <script language="JavaScript1.2">
<!--
s=screen;a+=';s='+s.width+'*'+s.height
a+=';d='+(s.colorDepth?s.colorDepth:s.pixelDepth)
js=12//--></script> <script language="JavaScript1.3"><!--
js=13//--></script> <script language="JavaScript"><!--
d.write('<a href="http://top.mail.ru/jump?from=454056"'+
' target=_top><img src="http://top.list.ru/counter'+
'?id=454056;t=210;js='+js+a+';rand='+Math.random()+
'" alt="Рейтинг\@Mail.ru"'+' border=0 height=31 width=88></a>')
if(js>11)d.write('<'+'!-- ')//--></script> <noscript>
            <a
target=_top href="http://top.mail.ru/jump?from=454056"><img
src="http://top.list.ru/counter?js=na;id=454056;t=210"
border=0 height=31 width=88
alt="Рейтинг\@Mail.ru"></a> </noscript> <script language="JavaScript"><!--
if(js>11)d.write('--'+'>')//--></script> 
            <!--/COUNTER-->
            <br> 
            <!-- SpyLOG f:0211 -->
            <script language="javascript"><!--
Mu="u4392.53.spylog.com";Md=document;Mnv=navigator;Mp=1;
Mn=(Mnv.appName.substring(0,2)=="Mi")?0:1;Mrn=Math.random();
Mt=(new Date()).getTimezoneOffset();
Mz="p="+Mp+"&rn="+Mrn+"&t="+Mt;
My="";
My+="<a href='http://"+Mu+"/cnt?cid=439253&f=3&p="+Mp+"&rn="+Mrn+"' target='_blank'>";
My+="<img src='http://"+Mu+"/cnt?cid=439253&"+Mz+"&r="+escape(Md.referrer)+"&pg="+escape(window.location.href)+"' border=0  width=88 height=31  alt='SpyLOG'>";
My+="</a>";Md.write(My);//--></script> <noscript>
            <a href="http://u4392.53.spylog.com/cnt?cid=439253&f=3&p=1" target="_blank"> 
            <img src="http://u4392.53.spylog.com/cnt?cid=439253&p=1" alt='SpyLOG' border='0'  width=88 height=31 > 
            </a></noscript> 
            <!-- SpyLOG  -->

              </td></tr>


            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td valign="top">
      <table width="100%" border="0" cellspacing="0" cellpadding="0" background="/images/bottom_bk.gif">
        <tr valign="top"> 
          <td><a href="#top" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','/images/upper2.gif',1)"><img name="Image14" border="0" src="/images/upper1.gif" width="122" height="33"></a></td>
          <td>
            <div align="right"><img src="/images/created.gif" width="440" height="33" usemap="#Map" border="0"></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<map name="Map"> 
  <area shape="rect" coords="-10,15,122,51" href="http://www.efirstudio.com.ua" target="_blank" alt="http://www.efirstudio.com.ua" title="http://www.efirstudio.com.ua">
  <area shape="rect" coords="129,16,268,51" href="mailto:webmaster\@efirstudio.com.ua" alt="Design: Paul V Savchenkov" title="Design: Paul V Savchenkov">
  <area shape="rect" coords="273,16,439,51" href="mailto:usv\@pub.ins.dn.ua" alt="Programming: Sergey Urubkov" title="Programming: Sergey Urubkov">
</map>
<map name="Map2">
  <area shape="rect" coords="25,28,225,40" href="mailto:virtual\@v-world.dn.ua">
</map>
</body>
</html>

FOOTER
}

################################################################################
#Done configurations!!!                                                        #
#DO NOT EDIT BELOW!!!!!                                                        #
################################################################################

$noOfImagesPerPage = $square * $square; # calculate the number of images per page
@allPictures = glob $directoryOfImages."*.*"; # get all pictures from directory

# get commands of URL
if ($ENV{"REQUEST_METHOD"} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; }
else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }
@values = split /&/, $buffer;
foreach $pair (@values)
{
         ($command, $value) = split /=/, $pair;
         $value =~ tr/+/ /;
         $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
         chomp ($value);
         $info{$command}=$value;
}
# end of getting commands from URL

# check where to go to
# view page
if ($command eq "viewpage")
{
     $currentPicture = $noOfImagesPerPage * ($value-1); # determine what page
     $_ = @allPictures;
     if ($value > 0 && $currentPicture < ($noOfImagesPerPage * $value) && $currentPicture < $_)
     {
          &viewpage;
     }
     else {&error;};
}
# view a single picture
elsif ($command eq "viewpicture")
{
     $_ = @allPictures;
     if ($value < $_ && $value > -1)
     {
          &viewpicture;
     }
     else {&error;};
}
# login screen
elsif ($command eq "action" && $value eq "admin")
{
     &admin;
}
# admin screen
elsif ($command eq "password" && $value eq $password)
{
&admin2;
}
# delete picture(s)
elsif ($command eq "action" && $value eq "delete")
{
&delete;
}
# error page
else {&error;};

# display table of pictures
sub viewpage {
    $_ = @allPictures;
    &header;
    # generate table dimensions
    print "<table>\n";
    while ($currentPicture < ($noOfImagesPerPage * $value) && $currentPicture < $_)
    {
            if ($currentPicture % $noOfImagesPerPage !=0 &&$currentPicture % $square == 0)
            {
                 print "</tr>\n<tr>";
            }
            elsif ($currentPicture % $noOfImagesPerPage == 0 || $currentPicture == 0)
            {
                 print "<tr>";
            }
    &getCurrentPictureName;
    print "<td><A href=\"".$url."viewpicture=".$currentPicture."\">\n";
    open Fd, "${directoryOfImages}desc/$currentPictureName.txt";
    my @desc=<Fd>;
    close Fd;
    my $alts=join '<br>',@desc;
    $alts=~s/&/&amp;/gs;
    $alts=~s/"/&quot;/gs;
    $alts=~s/</&lt;/gs;
    $alts=~s/>/&gt;/gs;
    print "<img src=\"${imageURL}th/$currentPictureName\" border=0 alt=\"$alts\">\n";
    print "</td>";
    $currentPicture++;
    }
    print "</tr></table>";
    print "<br>\n";
    # generated navigational links
    print "<Table border=0 width=100%>\n";
    print "<Tr>\n";
    # previous page
    if ($value > 1)
    {
    $previous = $value-1;
    print "<td><center><A href=\"".$url."viewpage=".$previous."\">Previous Page</a></center></td>\n";
    }
    else
    {
    print "<td><center>Previous Page</center></td>\n";
    }
    $_ = @allPictures;
    $tempNoOfPictures=$_;
    $totalPages=1;
    # show total pages
    while ($tempNoOfPictures > $noOfImagesPerPage)
    {
    $tempNoOfPictures-=$noOfImagesPerPage;
    $totalPages++;
    }
    $tempUrl = $url;
    chop ($tempUrl);
    # form to jump pages
    print "<td><center>Page $value of $totalPages\n<br>";
    print "<form action=$tempUrl action=get>\n";
    print "Go To Page: <input type=text name=viewpage size=1>\n";
    print "<input type=submit value=GO!></form></centeR></td>\n";
    # next page
    if ($currentPicture < $_)
    {
    $nextPage = $previous+2;
    printf "<td><center><a href=${url}viewpage=$nextPage>Next Page</a></center></td></tr></table>\n";
    }
    else
    {
    print "<td><Center>Next Page</centeR></td></tr></table>\n";
    }
&linkback;
&footer;
}

sub viewpicture {
    &header;
    # generate table to hold picture
    print "<table border=0 bordercolor=white>\n";
    $lastSlashInCurrentPicture = rindex($allPictures[$value],"/"); # get last slash in absolute path
    $currentPictureName= substr($allPictures[$value], $lastSlashInCurrentPicture+1); # remove absolute path
    print "<tr><td align=center><img src=$imageURL$currentPictureName></td></tr>\n";
    open Fd, "${directoryOfImages}desc/$currentPictureName.txt";
    my @desc=<Fd>;
    close Fd;
    my $alts=join '<br>',@desc;
    $alts=~s/&/&amp;/gs;
    $alts=~s/"/&quot;/gs;
    $alts=~s/</&lt;/gs;
    $alts=~s/>/&gt;/gs;
    print "<tr><td>$alts</td></tr>\n";
    print "</table>\n";
    # generate navigation links
    print "<table width=100\%>";
    print "<tr><td><center>\n";
    # previous picture
    $previousPic = $value -1;
    $_ = @allPictures;
    # calculate total number of pictures
    $currentPage = 1;
    while ($value - ($noOfImagesPerPage * $currentPage) > -1)
    {
         $currentPage++;
    }
    $nextPic = $value + 1;
    if ($previousPic >= 0)
    {
         print "<a href=\"$url"."viewpicture=".$previousPic."\">Previous Pic</a></center></td>\n";
    }
    else {print "Previous Pic</center></td>\n";}
    $temp = $_ -1;
    # show total number of pictures
    print "<Td><center>Picture $value of $temp<br>\n";
    print "1st picture is 0<br>\n";
    $tempUrl = $url;
    chop ($tempUrl);
    print "<form action=$tempUrl method=get>\n";
    print "Go To Picture <input type=text size=1 name=viewpicture>\n";
    print "<input type=submit value=GO!></form><br>\n";
    print "<a href=\"$url"."viewpage=${currentPage}\">Go Back To Page ${currentPage}</a><br>\n";
    print "</center></td>\n";
    # next picture
    if ($nextPic < $_)
    {
         print "<td><center><a href=\"$url"."viewpicture=".$nextPic."\">Next Pic</a>\n";
    }
    else {print "<td><centeR>Next Pic\n";}
    print "</center></td></tr>\n";
    print "</table>\n";
    &linkback;
    &footer;
}

# checks the password
sub admin {
my $tempURL = $url;
chop ($tempURL);
print "Content-type: text/html\n\n";
print "<html><head><title>Image Gallery Admin</title></head>\n";
print "<body><center>\n";
print "<font size=5>Image Gallery Admin</font><br>\n";
print "<form method=post action=$tempURL>\n";
print "<input type=password name=\"password\"><br>\n";
print "<input type=submit value=Login></form>\n";
&linkback;
}

# allows admin to delete and view pictures
sub admin2 {
my $tempURL = $url;
chop ($tempURL);
&header;
# delete pictures from gallery (permanent deletion)
$_ = @allPictures;
print "<table border=1 width=80%>\n";
print "<tr><td><center><b>Delete Images</b></center></td></tr>\n";
print "<tr><td><center>You have $_ pictures in the gallery</center></td></tr>\n";
print "<tr><td>\n";
print "<form method=post action=$tempURL>\n";
print "<table border=1 width=100%>\n";
print "<Tr>\n";
print "<td><center><b>Delete?</b></centeR></td>\n";
print "<td><centeR><b>Picture Name</b></centeR></td>\n";
print "<td><center><b>View Picture</b></centeR></td>\n";
print "</tr>\n";
foreach $currentPicture (@allPictures){
        my $whereIsSlash = rindex ($currentPicture, "/")+1;
        my $filename = substr ($currentPicture, $whereIsSlash);
        print "<tr><td><center>\n";
        print "<select size=1 name=$filename>\n";
        print "<option value=0>Keep\n";
        print "<option value=-1>Delete\n";
        print "</select>\n";
        print "</center></td>\n";
        print "<td><centeR>$filename</center></td>\n";
        print "<td><centeR><a href=$imageURL$filename target=_blank>View Picture</a></centeR></td>\n";
        print "</tr>\n";
        }
print "</table><br>\n";
print "<input type=hidden name=action value=delete>\n";
print "<centeR><input type=submit value=Done></center>\n";
print "</form>\n";
print "</td></tr>\n";
print "</table><br>\n";
&linkback;
&footer;
}

# link back
sub linkback{
# PLEASE KEEP THIS LINK TO TOO GOOD SOFTWARE SO THAT OTHER PEOPLE MAY ALSO GET A COPY OF THIS PROGRAM, THANK YOU!
#print "<center><font size=2><a href=http://www.toogoodsoftware.com target=_blank>Script created by Too Good Software, Image Gallery Version 1.0</a></font></center>";
}

# deletes a picture
sub delete {
my $deleteCount = 0;
&header;
while (($currentPicture, $value)= each %info){
      if ($value == -1){
              unlink $directoryOfImages.$currentPicture;
              $deleteCount++;

      }
}
print "Deleted:  $deleteCount\n <br>";
print "<a href=$url"."action=admin>Go Back To Admin</a>";
&linkback;
&footer;
}

#isolate picture name
sub getCurrentPictureName {
$lastSlashInCurrentPicture = rindex($allPictures[$currentPicture],"/"); # get last slash in absolute path
$currentPictureName= substr($allPictures[$currentPicture], $lastSlashInCurrentPicture+1); # remove absolute path
}

# shows error
sub error {
    &header;
    print "$command and $value \n";
    print "Error: cannot execute $command with a value of $value\n";
    &linkback;
    &footer;
}
