#!/usr/bin/perl
#!perl
#!/usr/bin/perl5
#!/usr/local/bin/perl
#!/usr/local/bin/perl5

use vars qw(%config %category %supercat %form %cookie $loginalias $loginpassword);
use POSIX qw(strftime); 
use File::Copy;
use strict;
use CGI (); 
#use FileHandle ();
#use DirHandle ();
use CGI::Carp qw(fatalsToBrowser);

# on Windows NT/2000 servers only you need to specify 
# the drive letter (c:,d:,e:) with the server path to the config.pl file example: 
# require "c:/your/path/cgi-bin/auction/config.pl";

require "config.pl";

###############################################################################
# MakeBid Auction Deluxe Release Version 4.55 First release (8/04/00)
# This copyright notice MUST remain intact
# Copyright © 2000-2007 USANet Creations All rights reserved by the author.
# http://www.usanetcreations.com
#
# 
#       USANET CREATIONS LICENSE AGREEMENT.                        
# The following applies to the MakeBid Auction compilation and any 
# portions of MakeBid Auction it does not conflict with. Whenever this
# policy does conflict with any individual portion of MakeBid Auction,
# it does not apply. In that event this source may not be redistributed or sold without
# permission from USANet Creations. It may be modified for personal customization only,
# By using this script, you are obligated to hold to these conditions, except as 
# regulated by local law.
#
# DISCLAIMER TERMS AND LIABILITY NOTICE: 
# 1) BY USING THIS CODE YOU AGREE TO INDEMNIFY USANET CREATIONS, AND ANY OF ITS EMPLOYEES,
# FROM ANY LIABILITY THAT MIGHT ARISE FROM IT'S USE. USANET CREATIONS WILL NOT BE
# RESPONSIBLE FOR ANY DAMAGES YOUR BUSINESS MAY SUFFER. USE THIS SCRIPT AT YOUR 
# OWN RISK WITH YOUR OWN SITE LIABILITY DISCLAIMERS.  
#
# 2) WE NEITHER MAKE ANY WARRANTY NOR APPROVE THE MAKING OF ANY REPRESENTATION 
# THAT THE SOFTWARE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE 
# WILL BE UNINTERRUPTED OR ERROR FREE. YOU ARE RESPONSIBLE FOR ENSURING THAT THE 
# SOFTWARE WILL SATISFY YOUR REQUIREMENTS.
#
# 3) INSTALLATION/USE/MODIFICATION OF THIS SCRIPT IS AT YOUR OWN RISK!
# USER ASSUMES ANY AND ALL LIABILITY WHILE INSTALLING/USING/MODIFYING THIS SCRIPT! 
#
# 4) USANET CREATIONS RESERVES THE RIGHT TO AMEND OR UPDATE THESE POLICIES 
# WITHOUT NOTICE. 
#
# IF YOU DO NOT AGREE TO THE ABOVE TERMS DO NOT USE THIS SCRIPT!
#
#############################################################################
#
# The accounting system and image uploader are seperate packages created by 
# USANet Creations are not part of the GPL and by not be redistributed 
# or sold without permission from USANet Creations.
#
# In accordance with the GPL, this copyright notice MUST remain intact: 
#
# EveryAuction Release Version 1.51 (5/13/00) 
# Copyright (C) 2000 EverySoft 
# Registered with the United States Copyright Office, TX5-186-526 
# http://www.everysoft.com/ 
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
# When we speak of free software, we are referring to freedom, not
# price.
#
# 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.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
#-###########################################################################
#
# Modification Log (please add new entries to bottom):
#
# * 02/2000
#   Matt Hahnfeld (matth@everysoft.com) - Original Concept and Design
#   Version available from http://www.everysoft.com/
#
# * 09-15-2000
#   Tetramin (email) - SubCategories - AutoBidder
#
# * 07-15-2000
#   USANet Creations (webmaster@usanetcreations.com) - Total Rewrite and modifactions History
#   Latest versions available from http://www.usanetcreations.com/
#
# MakeBid Auction Deluxe Version History
#   version 3.0 (5/01/01) 
#   version 3.10 (5/20/01)
#   version 3.10B (6/8/01
#   version 3.11 (6/15/01) 
#   version 3.11B (6/24/01 
#   version 3.12 (7/14/01)
#   version 3.12B (9/02/01)
#   version 3.15 (9/21/02) 
#   version 3.20 (10/18/01)
#   version 3.25 (11/02/01)
#   version 3.30 (12/14/01)
#   version 3.40 (2/09/02)
#   version 3.45 (2/18/02)
#   version 4.00 (6/08/02)
#   version 4.00.165 (12/17/03)
#   version 4.00.175 (01/23/03)
#   version 4.00.185 (03/14/03)
#   version 4.00.195 (05/21/03)
#   version 4.00.200 (07/18/03)
#   version 4.01 (11/02/03)
#   version 4.10 (12/21/03)
#   version 4.25 (11/28/04)
#   version 4.50 (2/15/06)
#   version 4.55 (6/01/06)
#
# Addons and Modifications 
#
# 1 Payment features such as paynent VIA PayPal, PayByCheck, 2Checkout, Nochex.com 
# 2 Check if credit card is stored be for allowing a reg user to post a new auction item
#   if not stored will ask them to store one be for they can post an item.
# 3 Full auction admin to edit and delete auction items and
#   registered users and ban e-mail
# 4 Sellers can ban bad/non paying bidders from bidding
# 5 Main Page cells for Category, Full Featured, and a Site Map,
# 6 Unlimited Categories with sub categories
# 7 New auction post verification email to seller
# 8 Billing & Payment info sent when a new item posted
# 9 Featured Picture Gallery
# 10 Full Featured, Category Featured, Bold options
# 11 Condition, Shipping, Payment, poster selected and displayed in auction page. 
# 12 Dutch Auctions four diferent versions with Dutch E-Mail to seller/buyer
# 13 Delete closed auctions after X days
# 14 Auto Relist closed auctions 
# 15 Mail This Auction To A Friend stand alone
# 16 Edit Sellers Auction Item stand alone
# 17 Ask Seller A Question Forum style
# 18 View Sellers Other Auction Items
# 19 Seller ban a user from bidding
# 20 View My Bids
# 21 View Closed Auctions you sold and did not sell or Relist Closed
# 22 Buy It Feature for auction items with no bid placed yet.
# 23 FeedBack stand alone
# 24 Stats stand alone
# 25 Suggest a new category
# 26 Report Fraud
# 27 New sendmail to be compatable with UNIX and Windows NT Servers
# 28 (Image link) Auction posting selection with 4 images / 1 large / 3 click to enlarge
# 29 (Image Upload) Auction posting selection with 4 images / 1 large / 3 click to enlarge
# 30 Auction posting selection for music background auction item display
# 31 Description title color size and color
# 32 Description body color size and color
# 33 Users My Page 
# 34 Users Store Front
#
###########################################################################

###############################################
###############################################
#-#############################################
# Main Program
# You do not need to edit anything below this
# line.

#-#############################################
# Sub: Get Form Data
# This gets data from a post.

sub get_form_data {
        my $temp;
        my $buffer;
        my @data;  

        if (($ENV{'REQUEST_METHOD'} ne 'POST') && ($ENV{'REQUEST_METHOD'} ne 'post') && ($ENV{'REQUEST_METHOD'} ne 'GET') && ($ENV{'REQUEST_METHOD'} ne 'get')) {
        &oops("Request Method Not Allowed");
        }
        else { 
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        foreach $temp (split(/&|=/,$buffer)) {
                $temp =~ tr/+/ /;               
                $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; 
                #if ($temp eq 'DESC' !~ /\<(?:[\s\S]*?\s*)?>/g) {
                #if ($temp !~ /\<(?:[\s\S]*?\s*)?>/g) {  
                if ($temp !~ /\<(.+)\>/g) {                 
                $temp =~ s/\r\n/\<BR\>/g; 
                #$temp =~ s/\s(?!\w+)/\&nbsp\;/g;                 
                }
                else {                   
		$temp =~ s/[\r\n]/ /g; 
                $temp =~s/[\~\^]//g; # Remove single word character    
                $temp =~ s/~!/ ~!/g;  # Stop people from using subshells to execute commands
                #$temp =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go; # Stop subshells commands
                #$temp =~ s/([\&;\`'\|\"*\?\~\^\(\)\[\]\{\}\$\n\r])/\\$1/g;
                #$temp =~ s/^\s*cd\s+(.+)//g: 
                $temp =~ s/<*(script)[^>]+>//gi;
                $temp =~ s/<*(applet)[^>]+>//gi;
                $temp =~ s/<*(embed)[^>]+>//gi; 
                $temp =~ s/system\(.+//g; 
                $temp =~ s/alert//g;
                $temp =~ s/param//g;
                $temp =~ s/hash//g;
                $temp =~ s/exec//g;
                $temp =~ s/grep//g;
                $temp =~ s/eval//g;  
                $temp =~ s/chmod//g; 
                $temp =~ s/echo//g; 
                }
                push @data, $temp;
        }
        foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
                $temp =~ tr/+/ /;               
                $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; 
                if ($temp !~ /\<(.+)\>/g) {                 
                $temp =~ s/\r\n/\<BR\>/g; 
                }
                else {                   
		$temp =~ s/[\r\n]/ /g; 
                $temp =~s/[\~\^]//g; # Remove single word character    
                $temp =~ s/~!/ ~!/g;  # Stop people from using subshells to execute commands
                $temp =~ s/<*(script)[^>]+>//gi;
                $temp =~ s/<*(applet)[^>]+>//gi;
                $temp =~ s/<*(embed)[^>]+>//gi; 
                $temp =~ s/system\(.+//g; 
                $temp =~ s/alert//g;
                $temp =~ s/param//g;
                $temp =~ s/hash//g;
                $temp =~ s/exec//g;
                $temp =~ s/grep//g;
                $temp =~ s/eval//g;  
                $temp =~ s/chmod//g; 
                $temp =~ s/echo//g; 
                }
                push @data, $temp;
        }        
        return @data;  
        }
   
}

#-#############################################
# Sub: Pagebreak
# This displays pagebreak links

sub pagebreak  {
    
    my $pagecnt = shift || 0;
    my $firstnumber = 0;
    my $lastnumber = $pagecnt;
    my $next = "Next Page >>";
    my $previous = "<< Previous Page";   
    my $nonext = "";
    my $noprevious = "";   
    my $totalcnt = ($pagecnt + 1);      
    local $_;   

         my $currentpage;         
         ($currentpage = $form{'page'})++;

         if ($pagecnt > 10) {    
         $firstnumber = ($currentpage - 6) if ($currentpage > 6);
         $lastnumber = ($currentpage + 4) if (($currentpage + 4) < $pagecnt);
         }        

            #my $action;
            #foreach(keys %form){
            #next if($_ eq 'pb' || $_ eq 'page');
            #my $f = $form{$_};
            #$f = ~s/(\W)/'%'.unpack("H2", $1)/eg;
            #$action.= '&' if $action;
            #$action.= "$_=$f";
            #}
   
             my $action;
             #foreach(keys %form) {
             foreach(%form) {             
             next if($_ eq 'pb' || $_ eq 'page'); 
             $action .= '&' if $action;
             $action .= "$_=$form{$_}";
             } 
             my($pagebreak) = @_;

      print "<CENTER>";
      ## Print Pagebreak Links ##
      if ($form{page} >= 1) {              
      print " <a href=\"$ENV{'SCRIPT_NAME'}?$action&page=@{[$form{page}-1]}\">$previous</a> ";
      }
      else {
      print " $noprevious "; 
      }
      print "|" unless ($form{pb});
      for ($firstnumber .. ($form{'page'} - 1)) {
      print " <a href=\"$ENV{'SCRIPT_NAME'}?$action&page=$_\">@{[$_+1]}</a> ";  
      }            
      print " <b>$currentpage</b> " unless ($form{pb});
      print " <b>All Items</b> " if ($form{pb});
      for (($form{'page'} + 1) .. $lastnumber) {       
      print " <a href=\"$ENV{'SCRIPT_NAME'}?$action&page=$_\">@{[$_+1]}</a> ";     
      }                
      print " <b>of $totalcnt</b> " unless ($form{pb});
      print "|" unless ($form{pb}) or ($pagecnt eq 0);
      if($pagecnt > 0) {                 
      print " <a href=\"$ENV{'SCRIPT_NAME'}?$action&pb=@{[(1+$pagecnt)*$pagebreak]}\">View All</a> ";
      }
      if ($form{pb}) {        
      print " <a href=\"$ENV{'SCRIPT_NAME'}?$action&page=@{[$form{page}*$pagebreak]}\">Back</a> ";       
      }
      print "|" unless ($form{pb});
      if ($form{page} < $pagecnt) {
      print " <a href=\"$ENV{'SCRIPT_NAME'}?$action&page=@{[$form{page}+1]}\">$next</a> ";
      }
      else {
      print " $nonext ";                 
      }    
      ## END Print Pagebreak Links ##
      print "</CENTER>";

}

#-#############################################
# Sub: Backto
# Provides the category path for the
# supercat add-on.

sub backto{        
	my $Separator = " > ";
	my $Item = "Item";
	my $Home = "Categories";

	my (@backs, $backto, $path, $thispath, $current);
	if($_[0] eq ''){$_[0] = $form{category}}
	$thispath=$_[0];
	if($category{$_[0]} ne ''){
		$thispath=$category{$form{category}};
		while($thispath=~s/^<!--([^\>]*)-->//){
			if($supercat{$1} ne ''){$thispath.=":$1"}
		}
		# $current=$category{$_[0]};##
	}
	@backs=split(/\:/, $thispath);
	foreach (0..($#backs-1)){
		if($supercat{$backs[$_]} ne ''){
			$path.=":$backs[$_]";
			$backto.="$Separator<a href=\"$ENV{'SCRIPT_NAME'}?category=$path&super=true\">$supercat{$backs[$_]}</a>";
		}
	}
	$path.=":$backs[-1]";
	if($supercat{$backs[-1]} ne '' && $category{$_[0]} ne ''){
		if($form{item} ne ''){
                        # ITEM
			$backto.="$Separator<a href=\"$ENV{'SCRIPT_NAME'}?category=$path&super=true\">$supercat{$backs[-1]}</a>$Separator<a href=\"$ENV{'SCRIPT_NAME'}?category=$_[0]&listtype=current\">$category{$_[0]}</a>$Separator$Item";
		}
                else { 
                        # ITEMLIST
			$backto.="$Separator<a href=\"$ENV{'SCRIPT_NAME'}?category=$path&super=true\">$supercat{$backs[-1]}</a>$Separator$category{$_[0]}";
		}
	}elsif($supercat{$backs[-1]} ne ''){ 
                         # SUBCATEGORIES
		$backto.="$Separator$supercat{$backs[-1]}";
	}
	if($backto ne ''){return "<a href=\"$ENV{'SCRIPT_NAME'}\">$Home</a>$backto"}
	else{return ''}
}

#-#############################################
# Sub: Display List Of Items
# This creates a "nice" list of items in a
# category.

sub displist {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

                   my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 )); 
                                         
                   ### 24 Hr clock ######
                   #my $nowtime = localtime(time + ($config{'systemtime'}* 3600 ));   

                   my $backto = &backto;
        print "<H2><center>All Files Listed in Category $category{$form{'category'}}: <br><p></H2></center>";
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";                          
        #-###### Category Featured Auctions ###############   
                print "<center> | <IMG SRC=\"$config{'buyitnowpic'}\">BuyItNow | <IMG SRC=\"$config{'newpic'}\">New | <IMG SRC=\"$config{'picpic'}\">Picture | <IMG SRC=\"$config{'hotpic'}\">Hot | <IMG SRC=\"$config{'endpic'}\">Ending | <IMG SRC=\"$config{'dutchpic'}\">Dutch | <IMG SRC=\"$config{'reservepic'}\">Reserve Price | <IMG SRC=\"$config{'reservemetpic'}\">Reserve Price Met | </center>"; 
        print "<center><A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";      
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";     
        print "</center>";     
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD ALIGN=CENTER WIDTH=\"100%\" BGCOLOR=$config{'featuredcolorhead'}><B><FONT SIZE=3>Featured Listings In $backto</FONT></B></TD></TR>\n";
        print "</TABLE>";
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";           

        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");
        my @allfeatfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $rowcount1 = 0;
        my $featfile;
        foreach $featfile (sort { $a <=> $b } @allfeatfiles) {
                $featfile =~ s/^$config{'basepath'}$form{'category'}\///;
                $featfile =~ s/\.dat$//;          
            
           open FILE, "$config{'basepath'}$form{'category'}/$featfile.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 

                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read last bid
                        #### Added for NEW items.
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]); # read first bid
                        ###### Read the feature Array from the item file ######
                        my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features    
                 
                        #### use commas in the bid price ###
                        if ($config{'currencylayout'} eq 'yes') {
                        $bid =~ s/\G(\d{1,3})(?=(?:\d\d\d)+(?:\.|$))/$1,/g;
                        } 
                              
                        my $timeremain = time_remain($featfile); 
                       
                   if ($feat_cp eq "YES"){
                      my $itemrowcolor1;
                      if ($rowcount1 % 2 == 1) {
                      $itemrowcolor1=$config{'colorevenrow'}
                      }
                      else {
                      $itemrowcolor1=$config{'coloroddrow'}
                      }                      
                      $rowcount1++; 

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($featfile < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");      

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");


                            my $mytitle;
                            if ($feat_yt eq "YES"){  
                            print "<TR BGCOLOR=$config{'boldbackground'}>";
                            }
                            else {
                            print "<TR BGCOLOR=$itemrowcolor1>";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$featfile\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        print "</TABLE>";
        print "</TD></TR></TABLE>";             
        #-###### Standard Item Category List ###############
        print "<p>\&nbsp\;</p>";        
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">\n";
        print "<TR>
<TD ALIGN=CENTER WIDTH=100% BGCOLOR=$config{'regcolorhead'}><FONT SIZE=3><B>Standard Listings In $backto</FONT></B></TD></TR>";
        print "</TABLE>";
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";        
            print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";   
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $rowcount2 = 0;            
        ##### Page Break
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        my $file;
        foreach $file (sort { $a <=> $b } @allfiles) {  
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;     
                 
           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 
                               
                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                        #### Added for NEW items.
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
                        my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features 

                        my $timeremain = time_remain($file);   
                    
                  if (($feat_cp eq "NO") && ($#bids < $config{'hotnum'})) {  
                  if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};               
                      my $itemrowcolor2;
                      if ($rowcount2 % 2 == 1) {
                      $itemrowcolor2=$config{'colorevenrow'}
                      }
                      else {
                      $itemrowcolor2=$config{'coloroddrow'}
                      }                       
                      $rowcount2++; 

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                                         
                            print "<TR BGCOLOR=$config{'boldbackground'}>";
                            }
                            else {
                            print "<TR BGCOLOR=$itemrowcolor2>";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);
        #-###### Hot Items Category List ###############
        print "<p>\&nbsp\;</p>"; 
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD ALIGN=CENTER WIDTH=100% BGCOLOR=$config{'hotcolorhead'}><B><FONT SIZE=3>Hot Items In $backto</FONT></B></TD></TR>";
        print "</TABLE>";
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";   
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");
        my @allhotfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $rowcount3 = 0;    
        my $hotfile;    
        foreach $hotfile (sort { $a <=> $b } @allhotfiles) {
                $hotfile =~ s/^$config{'basepath'}$form{'category'}\///;
                $hotfile =~ s/\.dat$//;                      

           open FILE, "$config{'basepath'}$form{'category'}/$hotfile.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 

                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read last bid
                        #### Added for NEW items.
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]); # read first bid
                        ###### Read the feature Array from the item file ######
                        my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features
                                                 
                        my $timeremain = time_remain($hotfile);
                        
                  if ($#bids >= $config{'hotnum'}){
                      my $itemrowcolor3;
                      if ($rowcount3 % 2 == 1) {
                      $itemrowcolor3 = $config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor3 = $config{'coloroddrow'};
                      }                      
                      $rowcount3++; 

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($hotfile < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){ 
                            print "<TR BGCOLOR=$config{'boldbackground'}>";
                            }
                            else {
                            print "<TR BGCOLOR=$itemrowcolor3>";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$hotfile\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        print "</TABLE>";
        print "</TD></TR></TABLE>";                      
        print "<p>\&nbsp\;</p>";
}

#-#############################################
# Sub: Display List Of Gallery Items
# This creates a "nice" list of items in a
# category.

sub displistgal {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

               my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        print "<center><H2>Gallery Featured Items in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n"; 
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";
        print " Gallery |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";      
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";        
        print "</font></center>";              
        print "<CENTER><TABLE border=\"0\" cellspacing=\"0\" WIDTH=\"90%\"><TR><TD colspan=4 bgcolor=\"$config{'colortablehead'}\"><CENTER><h2><font face=\"arial\" size=\"3\" $config{'colortext'}>Featured Picture GALLERY (Click on an image for more details)</font></CENTER></h2></TD></TR>"; 
        
        my $s = 1;        
        my $pagebreak = int $form{pb} || 24;
        my ($icount, $pcount) = (0,0);
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened."); 
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file; 
        foreach $file (sort { $a <=> $b } @allfiles) {                
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;

           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 

                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);                               
                            my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features  
                         
                            my $timeremain = time_remain($file);

                            my $image = "<IMG SRC=\"$image1\" BORDER=\"0\" WIDTH=\"100\">";
                            if ($gallery eq "Yes") {   
                            if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page}; 
                            
                            print "<TD width=\"25%\" align=\"center\"><A 
HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$image</a><br><FONT SIZE=\"-1\" FACE=\"ARI\"AL><B>$title</B></FONT><br><FONT SIZE=\"-1\" FACE=ARIAL>Current Bid: $config{'currencytype'}$bid</FONT><br><FONT SIZE=\"-1\" FACE=\"ARIAL\">Number of Bids: $#bids</FONT><br><FONT SIZE=\"-1\" FACE=\"ARIAL\">Closes: $timeremain</FONT></TD>" if ($image); 
                               if ($s==4) {
                               print "</TR>";
                               $s = 1;
                               }
                               else {
                               $s++;
                               }         
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"4\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Gallery Items to View</b></TD></TR>";
        }
        if ($s > 1 && $s < 4) { 
        print "</TR>";
        }
        print "</TABLE>";
        print "</CENTER>";
        &pagebreak($pcount,$pagebreak);   
}

#-#############################################
# Sub: Display List Of Featured Items
# This creates a "nice" list of items in a
# category.

sub displistfeat {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

              my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        print "<center><H2>Featured Items in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n";
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";
        print " Featured |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";                
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";               
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";        
        print "</font></center>";             
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";     
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file;
        my $rowcount = 0;
        ##### Page Break 
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        foreach $file (sort { $a <=> $b } @allfiles) {   
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;
                   my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }
                     
           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 
                         
                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);                      
                              
                            my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features                        
                            my $timeremain = time_remain($file);

                        if ($feat_fp eq "YES"){
                            $rowcount++; 
                            if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};  

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                               
                            print "<TR BGCOLOR=\"$config{'boldbackground'}\">";
                            }
                            else {
                            print "<TR BGCOLOR=\"$itemrowcolor\">";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);     
}

#-#############################################
# Sub: Display List Of NEW Items
# This creates a "nice" list of items in a
# category.

sub displistnew {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

               my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        print "<center><H2>New Items in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n";   
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";     
        print " New |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";        
        print "</font></center>";                
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
                print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";     
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file;
        my $rowcount = 0;
        ##### Page Break      
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        foreach $file (sort { $a <=> $b } @allfiles) {  
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;
                   my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }                      

           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 

                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
                          
                            my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features                        
                            my $timeremain = time_remain($file);
                            if (($sellertime + (86400 * $config{'newdays'})) > time){
                             $rowcount++; 
                            if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};  

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                               
                            print "<TR BGCOLOR=\"$config{'boldbackground'}\">";
                            }
                            else {
                            print "<TR BGCOLOR=\"$itemrowcolor\">";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);     
}

#-#############################################
# Sub: Display List Of HOT Items
# This creates a "nice" list of items in a
# category.

sub displisthot {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

               my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        print "<center><H2>Hot Items in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n";
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";
        print " Hot |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";
        print "</font></center>";        
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";    
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");       
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file;
        my $rowcount = 0;
        ##### Page Break        
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        foreach $file (sort { $a <=> $b } @allfiles) {  
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;
                   my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }                      

           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 
                        
                            my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                            my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
                            my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features 
                            my $timeremain = time_remain($file);

                            if ($#bids >= $config{'hotnum'}){
                                $rowcount++; 
                            if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};  

         my $filler = "<IMG SRC=$config{'fillerpic'}>";
        my $new = "<IMG SRC=$config{'newpic'}>" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=$config{'picpic'}>" if ($image1);
          my $hot = "<IMG SRC=$config{'hotpic'}>" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=$config{'endpic'}>" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');          
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');      
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");             

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                               
                            print "<TR BGCOLOR=\"$config{'boldbackground'}\">";
                            }
                            else {
                            print "<TR BGCOLOR=\"$itemrowcolor\">";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);      
}

#-#############################################
# Sub: Display List Of Going Items in 3 hrs 
# This creates a "nice" list of items in a
# category.

sub displistgone {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

              my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        print "<center><H2>Closing Items in 3Hrs in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n";
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";
        print " 3 Hours Left |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";      
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";
        print "</font></center>";        
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
                print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";   
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file;
        my $rowcount = 0;
        ##### Page Break
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        foreach $file (sort { $a <=> $b } @allfiles) {  
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;
                    my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }
                                 
           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 

                                my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                                my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
                                my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features 
                                my $timeremain = time_remain($file);
                        if ($file < (time + (3600 * $config{'goinghours'}))){
                        $rowcount++; 
                        if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};  

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                               
                            print "<TR BGCOLOR=\"$config{'boldbackground'}\">";
                            }
                            else {
                            print "<TR BGCOLOR=\"$itemrowcolor\">";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);    
}

#-#############################################
# Sub: Display List Of Items Closing Today
# This creates a "nice" list of items in a
# category.

sub displistclose {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

               my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        print "<center><H2>Closing Today Items in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n";
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";
        print " Closing Today |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";        
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=dutch\"> Dutch Items</a> |";
        print "</font></center>";        
        print "<TABLE BORDER=0 WIDTH=100%>";
        print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";   
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");  
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file;
        my $rowcount = 0;
        ##### Page Break
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        foreach $file (sort { $a <=> $b } @allfiles) {  
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;
                   my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }
                                
           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 

                            my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                            my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
                            my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features 
                            my $timeremain = time_remain($file);
                        if ($file < (time + 86400)) {
                        $rowcount++; 
                        if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};  

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                               
                            print "<TR BGCOLOR=\"$config{'boldbackground'}\">";
                            }
                            else {
                            print "<TR BGCOLOR=\"$itemrowcolor\">";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);       
}

#-#############################################
# Sub: Display List Of Dutch Items  
# This creates a "nice" list of items in a
# category.

sub displistdutch {

        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

               my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));        
        print "<center><H2>Dutch Items in Category <A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=current\">$category{$form{'category'}}</a>: <br><p><font size=\"-1\"></H2>\n";
        print "<center><b>Current Time: $nowtime $config{'timezone'}</b></center>";
        print " Dutch |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gal\"> Gallery </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=feat\"> Featured </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=new\"> New </A> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=hot\"> Hot </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=close\"> Closing Today </a> |";
        print "<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&listtype=gone\"> 3 Hours Left </a> |";                
        print "</font></center>";       
        print "<TABLE BORDER=\"0\" WIDTH=\"100%\">";
        print "<TR>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Status</B></FONT></TD>
<TD WIDTH=\"60%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Item</B></FONT></TD>
<TD WIDTH=\"5%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>#Bids</B></FONT></TD>
<TD WIDTH=\"15%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>High Bid</B></FONT></TD>
<TD WIDTH=\"10%\" BGCOLOR=\"$config{'colortablehead'}\"><FONT SIZE=\"3\"><B>Closes</B>
</FONT></TD></TR>";    
        opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("Category directory $form{'category'} could not be opened.");  
        my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/$_", (readdir THEDIR);
        closedir THEDIR;
        my $file;
        my $rowcount = 0;
        ##### Page Break       
        my $pagebreak = int $form{pb} || 30;
        my ($icount, $pcount) = (0,0);
        foreach $file (sort { $a <=> $b } @allfiles) {   
                ##### End Page Break
                $file =~ s/^$config{'basepath'}$form{'category'}\///;
                $file =~ s/\.dat$//;
                   my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }
                      
           open FILE, "$config{'basepath'}$form{'category'}/$file.dat";
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;   
           close FILE; 
                chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 
                        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
                        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
                                                 
                            my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features 
                            my $timeremain = time_remain($file);
                            if (($dutch) eq ('yes')) {    
                            $rowcount++; 
                            if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};  

          my $filler = "<IMG SRC=\"$config{'fillerpic'}\">";
          my $new = "<IMG SRC=\"$config{'newpic'}\">" if (($sellertime + (86400 * $config{'newdays'})) > time);
          my $image = "<IMG SRC=\"$config{'picpic'}\">" if ($image1);
          my $hot = "<IMG SRC=\"$config{'hotpic'}\">" if ($#bids >= $config{'hotnum'});
          my $end = "<IMG SRC=\"$config{'endpic'}\">" if ($file < (time + $config{'endhours'} * 86400));         
          my $dutchicon = "<IMG SRC=\"$config{'dutchpic'}\">" if ($dutch eq 'yes');
          my $buyitnow = "<IMG SRC=\"$config{'buyitnowpic'}\">" if (($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0') or ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $bid));      
          my $reserveprice = "<IMG SRC=\"$config{'reservepic'}\">" if ($reserve > '0.00') && ($reserve > $bid) && ($dutch eq 'no');
          my $reservepricemet = "<IMG SRC=\"$config{'reservemetpic'}\">" if ($bid >= $reserve) && ($reserve > '0.00') && ($dutch eq 'no');  
          my $imagedisp = "<IMG SRC=$image1 BORDER=\"0\" WIDTH=\"35\">" if ($image1 ne "");         

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

                            my $mytitle;
                            if ($feat_yt eq "YES"){                               
                            print "<TR BGCOLOR=\"$config{'boldbackground'}\">";
                            }
                            else {
                            print "<TR BGCOLOR=\"$itemrowcolor\">";
                            } 
                            if ($feat_bf eq "YES") {
                            $mytitle = "<B>$title</B>";
                            }
                            else {
                            $mytitle = "$title";
                            }
                            print "<TD>$filler$new$image$hot$end$dutchicon$buyitnow$reserveprice$reservepricemet</TD>"; 
                            print "<TD>$config{'displistfont'}<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$file\">$imagedisp $grabberpic $mytitle</A></TD>";
                            print "<TD>$#bids</TD><TD>$config{'currencytype'}$bid</TD><TD>$timeremain</TD></TR></FONT>\n";
                        }
                }
        
        if ($icount <= 0){
            print "<TR><TD COLSPAN=\"5\" BGCOLOR=\"$config{'colortablebody'}\"><b>No Items to View</b></TD></TR>";
        }
        print "</TABLE>";
### Page Break 
&pagebreak($pcount,$pagebreak);
}

#-#############################################
# Sub: Display Item
# This displays a particular item, its
# description, and its associated bids.

sub dispitem {      
 
              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }
           
        ### Security Check and Remove possible violations ###############
        $form{'category'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        $form{'item'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############

        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($form{'category'},$form{'item'});
                 
       &oops("This item is now closed. You can view this item and bid history using the <A HREF=$ENV{'SCRIPT_NAME'}?action=dispallclosed>All Closed Auctions</A> link then by selecting the item number in question. If you were the seller or the winning bidder, you can use the <font color=\"green\">View Your Closed Won/Sold </font>link from site links menu to view your closed auction items won or sold.") unless ($title);

        my ($highbidder, $reservemsg, $sellerpage, $sellersstore, $bidderpage, $buyitnow);
        my $backto = &backto; 

	my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        my $closetime = strftime "%a %b %d, %I:%M %p", gmtime($form{item} + ($config{'systemtime'}* 3600 ));	
	
        my ($selleralias, $selleremail, $bid, $sellertime, $selleradd1, $selleradd2, $selleradd3, $selleroqty, $sellersoldqty) = &read_bid($bids[0]); # read first bid 
         my $bidstart = strftime "%a %b %d, %I:%M %p", gmtime($sellertime + ($config{'systemtime'}* 3600 ));       
        my $numbids = $#bids;  
        my $firstbid = $bid;          
        my $location = $selleradd3;                  
      
	my ($alias, $email, $lastbid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$numbids]); # read last bid   
       
        my $timeremain;              
        if ((time > int($form{'item'})) && (time < (60 * $config{'aftermin'} + $time))) {
        $timeremain = "$config{'aftermin'} minute extended over time bidding";
        }
        else {
        $timeremain = time_remain($form{item});        
        }

        my $sold;
        if (($dutch eq 'yes') && ($soldqty eq "")) {
        $sold = "Number Sold: <b>None</b>";
        }

        if (($dutch eq 'yes') && ($soldqty ne "")) {
        $sold = "Number Sold: <b>$soldqty</b>";
        }
     
        if ($dutch eq 'no') {
        $sold = "";
        }

        $reservemsg = "";
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(Reserve not met)</FONT>" if (($lastbid < $reserve) && ($dutch eq 'no'));
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(Reserve met)</FONT>" if (($lastbid >= $reserve) && ($reserve > 0) && ($dutch eq 'no'));
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(No Reserve)</FONT> " if (($reserve <= 0)  && ($dutch eq 'no')); 
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(Dutch Fixed Price)</FONT> " if ($dutch eq 'yes');
                         
                my $qacount = 0;              
                if (-e("$config{'basepath'}askseller/$form{'item'}.dat")) {
                open QAFILE, "$config{'basepath'}askseller/$form{'item'}.dat";
                my @qadata = <QAFILE>;
                close QAFILE;                
                $qacount = scalar(@qadata); 
                }
                else {
                $qacount = 0;
                }              

                open (FEEDFILE, "$config{'feeddir'}/$selleralias.dat");
                my ($spositive, $sneutral, $snegative, @suserfeeds) = <FEEDFILE>;
		close FEEDFILE;
		chomp($spositive, $sneutral, $snegative, @suserfeeds);
		my $sellerrating = $spositive - $snegative;                  
                my $sellervotes = $spositive + $sneutral + $snegative;

  my $star1s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($sellerrating >= '4');
  my $star2s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($sellerrating >= '8');
  my $star3s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($sellerrating >= '12');
  my $star4s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($sellerrating >= '16');
  my $star5s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($sellerrating >= '20');

                open (FEEDFILE, "$config{'feeddir'}/$alias.dat");
                my ($bpositive, $bneutral, $bnegative, @buserfeeds) = <FEEDFILE>;
		close FEEDFILE;
		chomp($bpositive, $bneutral, $bnegative, @buserfeeds);
		my $bidderrating = $bpositive - $bnegative;
                my $biddervotes = $bpositive + $bneutral + $bnegative;

  my $star1b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($bidderrating >= '4');
  my $star2b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($bidderrating >= '8');
  my $star3b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($bidderrating >= '12');
  my $star4b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($bidderrating >= '16');
  my $star5b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=\"10\" width=\"10\" border=\"0\">" if ($bidderrating >= '20');
                
        if ($alias eq $selleralias){
	$highbidder = "<font color=red>No bids yet</font>";                		
	}
	else {
	$highbidder = "<font color=\"green\"><b>$alias</b></font> <A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewrate&ALIAS=$alias\">
<!---(bidders's feedback:<font color=\"red\">( $bidderrating )</font> $star1b $star2b $star3b $star4b $star5b)</a> - <a href=\"$ENV{'SCRIPT_NAME'}?action=search&searchtype=viewother&searchstring=$alias\">(bidders auctions)</a>--->";
	}

         if (-f "$config{'basepath'}$config{'mystoredir'}/$selleralias.st") {
         $sellersstore ="
 - <A HREF=\"$ENV{'SCRIPT_NAME'}?action=showstore&user=$selleralias\">(View My Store)</a>";
        }
        else {
        print "";
        }

         if (-f "$config{'basepath'}$config{'mypagedir'}/$selleralias.me") {
         $sellerpage ="
 - <A HREF=\"$ENV{'SCRIPT_NAME'}?action=showme&user=$selleralias\">(View My Page)</a>";
        }
        else {
        print "";
        }
       
        if (($#bids) && (-f "$config{'basepath'}$config{'mypagedir'}/$alias.me")) {
        $bidderpage ="
 - <A HREF=\"$ENV{'SCRIPT_NAME'}?action=showme&user=$alias\">(View My Page)</a>";
        }        
        else {
        print "";
        }

         my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8");

          my $bgmusic = "";
          $bgmusic = "$config{'music1'}" if ($music eq "music1");
          $bgmusic = "$config{'music2'}" if ($music eq "music2");
          $bgmusic = "$config{'music3'}" if ($music eq "music3");
          $bgmusic = "$config{'music4'}" if ($music eq "music4");
          $bgmusic = "$config{'music5'}" if ($music eq "music5");
          $bgmusic = "$config{'music6'}" if ($music eq "music6");
          $bgmusic = "$config{'music7'}" if ($music eq "music7");
          $bgmusic = "$config{'music8'}" if ($music eq "music8"); 

        ### use commas in the bid price ###
        my $chklastbid = $lastbid;
        if ($config{'currencylayout'} eq 'yes') {
        $firstbid  =~ s/\G(\d{1,3})(?=(?:\d\d\d)+(?:\.|$))/$1,/g;
        $lastbid =~ s/\G(\d{1,3})(?=(?:\d\d\d)+(?:\.|$))/$1,/g; 
        $buyit =~ s/\G(\d{1,3})(?=(?:\d\d\d)+(?:\.|$))/$1,/g;
        }
        
if ($config{'backgroungmusic'} eq 'yes') {
    print <<"EOF";
<embed src="$bgmusic" width="0" height="0" loop="true" autoplay="true" hidden="true">
EOF
}

        print <<"EOF";
<p align="center"><b>$backto</b></p>
<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4"><b>$grabberpic $title</b></font></td>
  </tr>
  <tr>
    <td align="center" width="100%"><font size="3"><b>Item #$form{'item'}</b></font><br><center><!---<b>Seller FeedBack: <A HREF="$ENV{'SCRIPT_NAME'}?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}">[ Rating: $sellerrating ] [ Number of Votes/Comments: $sellervotes ]</a></font></b></center></td>--->
  </tr>
</table>
</div>

<div align="center">
<table border="0" width="50%">
  <tr>
    <td><p></td>  
  </tr>
 <tr>
    <td align="center" width="100%">Current Time: $nowtime $config{'timezone'}</td>  
  </tr> 
  <tr>
    <td><p></td>  
  </tr>
</table>
</div>
EOF

           if ($usecounter eq "Yes") {    
   my $totalReads = "0";
   open(COUNT, "$config{'basepath'}$config{'countdir'}/$form{'item'}.dat");
   $totalReads = <COUNT>;   
   close(COUNT);

      ++$totalReads;
      open(COUNT, "> $config{'basepath'}$config{'countdir'}/$form{'item'}.dat");
      if ($config{'flock'}) { 
      flock(COUNT, 2);
      seek COUNT, 0, 0;
      }
      print COUNT "$totalReads";
      close(COUNT);
                          
print <<"EOF";
<table align="center" border="0" bgcolor="#EEEEEE"><tr><td>
<CENTER><FONT SIZE="3">This item has been viewed ( <b>$totalReads</b> )times</FONT></CENTER></td></table>
EOF
            } 

        if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0')) {
print <<"EOF";
<p>
<div align="center">
<table border="0" width="25%" cellpadding="0" cellspacing="0">
<tr>
    <td bgcolor="#CCCCCC"><A HREF="$ENV{'SCRIPT_NAME'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $config{'currencytype'}$buyit<br><center>This option disappears<br>once a bid is placed.</center></td>
</tr>
</table>
</div>
EOF
}

        if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($dutch eq 'no') && ($reserve > '0') && ($reserve > "$chklastbid")) {
print <<"EOF";
<p>
<div align="center">
<table border="0" width="35%" cellpadding="0" cellspacing="0">
<tr>
    <td bgcolor="#CCCCCC"><center><A HREF="$ENV{'SCRIPT_NAME'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $config{'currencytype'}$buyit</center>This option disappears once the reserve price has been met.</td>
</tr>
</table>
</div>
EOF
}

print <<"EOF";
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td width="10%" rowspan="10" valign="top" align="left">
EOF

if ($image1 ne "") {
print <<"EOF";
    <a href="$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$form{'item'}#IMG"><img SRC="$image1" alt="Show picture" border="0" WIDTH="70"><br>View picture</a><br><p>
EOF
}

print <<"EOF";
    <a href="$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$form{'item'}#DESC"><img src="$config{'descicon'}" alt="Show description" border="0" WIDTH="50" HEIGHT="50"></a><br><p>
    <a href="$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$form{'item'}#BID"><img src="$config{'bidicon'}" alt="Bid!"
    border="0" WIDTH="50" HEIGHT="50"></a><br>
    </td>
    <td width="30%">Current Bid: <b>$config{'currencytype'}$lastbid</b> $reservemsg</td>
    <td width="1%"></td>
    <td width="30%">First bid: <b>$config{'currencytype'}$firstbid</b> </td>    
  </tr>
  <tr>
    <td width="30%">Dutch Auction: <b>$dutch</b></td>
    <td width="1%"></td>
    <td width="30%">Quantity: <b>$qty</b>  $sold</td>    
  </tr>
  <tr>
    <td width="30%">Time left: <b>$timeremain</b></td>
    <td width="1%"></td>
    <td width="30%">Number of bids: <b>$#bids</b> <A HREF="$ENV{'SCRIPT_NAME'}?action=bidhistory&category=$form{'category'}&item=$form{'item'}">(bid history)</a></td>    
  </tr>
  <tr>
    <td width="30%">Started: <b>$bidstart</b></td>
    <td width="1%"></td>
    <td width="30%">Seller's Location: <b>$location</b></td>    
  </tr>
  <tr>
    <td width="30%">Ends: <b>$closetime</b></td>
    <td width="1%"></td>
    <td width="30%">Send To Friend: <a href="$ENV{'SCRIPT_NAME'}?action=mailto&category=$form{'category'}&item=$form{'item'}">(mail this auction to a friend)</a></td>   
  </tr>  
  <tr>
    <td width="30%">Track this item: <A HREF="$ENV{'SCRIPT_NAME'}?action=trackitem&category=$form{'category'}&item=$form{'item'}"> (add to your list)</a></td>
    <td width="1%"></td>
    <td width="30%">Ask seller a Question: <A HREF="$ENV{'SCRIPT_NAME'}?action=askquestion&category=$form{'category'}&item=$form{'item'}">(ask or view Q&A <font color="red">( $qacount )</font>)</a></td>   
  </tr>  
</table>
</div>
</font>

<div align="center">
<table border="0" cellpadding="8" cellspacing="0" width="100%">
  <tr>
    <td><p></td>  
  </tr>
  <tr>
    <td width="50%">Seller: <font color="green"><b>$selleralias</b></font> <!---<A HREF="$ENV{'SCRIPT_NAME'}?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}">(sellers's feedback:<font color="red">( $sellerrating )</font> $star1s $star2s $star3s $star4s $star5s)</a> - <a href="$ENV{'SCRIPT_NAME'}?action=search&searchtype=viewother&searchstring=$selleralias">(sellers other auctions)</a> $sellerpage $sellersstore</td>-->    </tr>
  <tr>
    <td><p></td>  
  </tr>       
  <tr>
    <td width="50%">High bidder: $highbidder $bidderpage</td>    
  </tr>   
  <tr>
    <td><p></td>  
  </tr> 
  <tr>
    <td width="30%">Payment Options: <b>$payment</b></td>     
  </tr>   
  <tr>
    <td width="30%">Shipping Terms: <b>$shipping</b></td>  
  </tr>   
  <tr>
    <td width="30%">Condition of Item: <b>$condition</b></td>  
  </tr>
  <tr>
    <td><p></td>  
  </tr> 
  <tr>
    <td width="50%">High Bidder: You may <A HREF="$ENV{'SCRIPT_NAME'}?action=retractbid&category=$form{'category'}&item=$form{'item'}">retract</a> your bid for a good reason.</td>    
  </tr>  
  <tr>      
    <td width="50%">Seller: You may <A HREF="$ENV{'SCRIPT_NAME'}?action=banlogin&category=$form{'category'}&item=$form{'item'}">ban a user</a> from bidding.</td>
  </tr>
  <tr>      
    <td width="50%">Seller: You may <A HREF="$ENV{'SCRIPT_NAME'}?action=sellerlogon&category=$form{'category'}&item=$form{'item'}">update</a> your item Description, change relist times, close this item early or delete this item if no bids have been placed.</td>
  </tr>
  <tr>
    <td><p></td>  
  </tr>
  <tr>
    <td><font size="2" face="Arial"><center>Seller assumes all responsibility for listing this item.<br>
    You should contact the seller to resolve any questions before bidding.<br>
    Currency is $config{'currencytype2'} unless otherwise noted.</center></font></td>
  </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4"><b><a name="DESC"></a><center>Description</center></b></font></td>
  </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="95%">
  <tr>
    <td><p></td>  
  </tr>
  <tr>
    <td>
$desctitcolor$desctitsize<center>$desctit</center>
</FONT></FONT></BOLD></B></I></U></H1></H2></H3></H4></H5></CENTER>
   </td>
   </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="95%">
  <tr>
    <td>
$desccolor$descsize<blockquote>$desc</blockquote>
</FONT></FONT></BOLD></B></I></U></H1></H2></H3></H4></H5></CENTER>
   </td>
   </tr>
</table>
</div>

<div align="center">
<SCRIPT LANGUAGE="JavaScript">
function EnlargeImage(name) {
newsrc = name;
document.images.large.src = newsrc;
}
</SCRIPT>
EOF
if ($image1 ne "") {
print <<"EOF";
<table align="center" border="0" width="95%">
<tr>
<td><a name="IMG"><img name="large" SRC="$image1" BORDER="0"><br><br><br></td>      
EOF
}
if ($image2 ne "") {
print <<"EOF";
<td>
<table border="0"><tr><td colspan="2" align="center"><b>Click Thumbnails For Larger Picture</b></td>
</tr>
EOF
}
if ($image2 ne "") {
print <<"EOF";
<tr>
<td><a href="javascript:EnlargeImage('$image1')"><img SRC="$image1" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($image2 ne "") {
print <<"EOF";
<td><a href="javascript:EnlargeImage('$image2')"><img SRC="$image2" BORDER="0" WIDTH="75"></a></td>
</tr>
EOF
}
if ($image3 ne "") {
print <<"EOF";
<tr>
<td><a href="javascript:EnlargeImage('$image3')"><img SRC="$image3" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($image4 ne "") {
print <<"EOF";
<td><a href="javascript:EnlargeImage('$image4')"><img SRC="$image4" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($image1 ne "") {
print <<"EOF";
</tr>
</table>
</tr>
</table>
</div>
EOF
}

print <<"EOF";
<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4"><b><a name="HIST"></a><center>Bid History</center></b></font></td>
  </tr>
</table>
</div>
EOF

## Start Bid History ######################    
        
        if ($#bids) {                  
                       print "<p><b><center><A HREF=\"$ENV{'SCRIPT_NAME'}?action=bidhistory&category=$form{'category'}&item=$form{'item'}&title=$form{'title'}\">Bids have been placed click here to view the bid history</a></center><br><p></b>";                                     
               	}	
                else {
        print "<FONT SIZE=\"-1\"><h3><center>No bids yet...</center></h3></FONT>";                
        }       
## End Bid History ######################  
        # either the item is closed or we will display a bid form        
        if ((time > int($form{'item'})) && (time > (60 * $config{'aftermin'} + $time))) {
                print "<FONT SIZE=\"-1\" COLOR=\"#FF0000\"><B>BIDDING IS NOW CLOSED</B></FONT><BR>";                
        }
        else {
        #####  Normal Bid Form 
        if ($dutch eq 'no') {           
            my $closetime = localtime($form{'item'});
            my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read the last bid           
            my $lowest_new_bid;
            $lowest_new_bid = (&read_bid($bids[0]))[2];  
            $lowest_new_bid = &parsebid($bid);                       
            $lowest_new_bid = &parsebid($bid + $inc) if ($#bids);

             print <<"EOF";
<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<table width="100%"><tr><td bgcolor="$config{'colortablehead'}">
<font size="4"><b><a name="BID"></a><center>Bidding</center></b></font>
</td></tr></table>
<table width="100%" border="0">
  <tr>
    <td width="70%" bgcolor="$config{'colortablebody'}"><center><font size="4">$title</font><br>
<font size="4">Item # - $form{'item'}</font>
</center>
EOF

        if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($#bids eq '0') && ($dutch eq 'no') && ($reserve <= '0')) {
print <<"EOF";
<br><center><A HREF="$ENV{'SCRIPT_NAME'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $config{'currencytype'}$buyit<br>This option disappears<br>once a bid is placed.</center>
EOF
}
        if (($config{'buyitnow'} eq 'yes') && ($buyit > '0') && ($dutch eq 'no') &&  ($reserve > '0') && ($reserve > $chklastbid)) {
print <<"EOF";
<br><center><A HREF="$ENV{'SCRIPT_NAME'}?action=buyit&CATEGORY=$form{'category'}&ITEM=$form{'item'}">Buy It</a> for $config{'currencytype'}$buyit<br>This option disappears<br>once the reserve price has been met.</center>
EOF
}

print <<"EOF";
<br><p>
EOF

print <<"EOF";
<INPUT TYPE="HIDDEN" NAME="action" VALUE="confirmbid">
<INPUT TYPE="HIDDEN" NAME="ITEM" VALUE="$form{'item'}">
<INPUT TYPE="HIDDEN" NAME="CATEGORY" VALUE="$form{'category'}">
<B>Number of bids:</B> $#bids<BR> 
<B>The High Bid Is:</B> $config{'currencytype'}$bid<BR>
<B>The Lowest You May Bid Is:</B> $config{'currencytype'}$lowest_new_bid  
EOF

                if ($config{'regdir'}) {
                        print <<"EOF";
<TABLE WIDTH="100%"><TR><TD BGCOLOR="$config{'colortablebody'}">
<P><B><A HREF="$ENV{'SCRIPT_NAME'}?action=agree">Registration</A> is required to make a bid!</B>
<P><B>Your Username:</B> <INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias> (used to track your bid)
<BR><B>Your Password:</B> <INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 VALUE=$loginpassword> (must be valid)
<BR><B>Your Bid:</B> $config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE="$lowest_new_bid">
<br><INPUT TYPE=SUBMIT NAME=proxy VALUE="Place A Proxy Bid"></TD></TR></TABLE>
EOF
                }
                else {
                        print <<"EOF";
<TABLE WIDTH="100%"><TR><TD BGCOLOR="$config{'colortablebody'}">
<P><B>Your Username:</B> <INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30> (used to track your bid)
<BR><B>Your E-Mail Address:</B> <INPUT NAME=EMAIL TYPE=TEXT SIZE=30> (must be valid)
<BR><B>Your Bid:</B> $config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE="$lowest_new_bid">
<P><B>Contact Information:</B> (will be given out only to the seller)<BR>
<TT>Full Name: </TT><BR><INPUT NAME=ADDRESS1 TYPE=TEXT SIZE=30><BR>
<TT>Street Address: </TT><BR><INPUT NAME=ADDRESS2 TYPE=TEXT SIZE=30><BR>
<TT>City, State, ZIP: </TT><BR><INPUT NAME=ADDRESS3 TYPE=TEXT SIZE=30><P>
</TD></TR></TABLE>
EOF
                }               
                
print <<"EOF";      
<p><b>Binding contract:</b><br>
<font size="3">&nbsp;&nbsp;By placing a bid you are making a <b>CONTRACT</b> between you and the White Bear Lake Area Historical Society. Once you place a bid, you may not retract it.  In some states, it is illegal to win an auction and not purchase the item.<br>
<p><b>Proxy bidding for all bids:</b><br>
&nbsp;&nbsp;Please bid the <strong>maximum amount</strong>
you are willing to pay for this item. Your maximum amount will be kept <b>secret;</b>
$config{'sitename'} will bid on your behalf as necessary by increasing your bid by the current bid increment up until your maximum is reached. Under no circumstances will Proxy Bidding ever bid More than you specified. The system will send you e-mail when you have been outbid so you can enter a higher Proxy Bid amount. Also, in case of a tie for high bidder, <b>earlier</b> bids take precedence. And, keep in mind that you cannot reduce your maximum bid at a later date.<br>
&nbsp;&nbsp;If you have bid on this item before, note that your new bid must be greater than your previous bid.</font> 
<TD WIDTH="30%" BGCOLOR="$config{'colortablebody'}">
<CENTER><b>How to Bid</b></CENTER><br>
<OL>
        <LI><A HREF="$ENV{'SCRIPT_NAME'}?action=agree">Register to bid</A> - It's free, and required to bid or sell.
        <LI><A HREF="#DESC">Know the Item</a> - Read the full description of the item you are bidding on.
        <LI>If you have questions about the item<br><A HREF="$ENV{'SCRIPT_NAME'}?action=askquestion&category=$form{'category'}&item=$form{'item'}&title=$title">(ask or view Q&A)</a> <B>BEFORE</b> you place a bid.
        <LI>Decide on the price, and submit your bid!
</OL> 
</TD></TR>
</TABLE>
EOF
}
## End Normal Bid Form

        else {
        ##### Go Dutch
        if ($dutch eq 'yes') {        
### Place Bid on a Auction Item  
            $form{'SOLDQTY'} = $soldqty if !($form{'SOLDQTY'});       
            $form{'OQTY'} = $oqty if !($form{'OQTY'});                       
            my $closetime = localtime($form{'item'});
            my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read the last bid          
            my $lowest_new_bid;
            $lowest_new_bid = (&read_bid($bids[0]))[2];             
            $lowest_new_bid = &parsebid($bid);                                
            
             print <<"EOF";
<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<TABLE WIDTH="100%"><TR><TD BGCOLOR="$config{'colortablehead'}">
<FONT SIZE="4"><a name="BID"></A><CENTER><B>Bidding</B></CENTER></FONT>
</TD></TR></TABLE>
<TABLE WIDTH="100%" BORDER="0"><TR><TD WIDTH="70%" BGCOLOR="$config{'colortablebody'}">
<CENTER><font size="4">$title</font><br>
<font size=4>Item # - $form{'item'}</font>
</CENTER>
<INPUT TYPE="HIDDEN" NAME="action" VALUE="confirmdutchbid">
<INPUT TYPE="HIDDEN" NAME="ITEM" VALUE="$form{'item'}">
<INPUT TYPE="HIDDEN" NAME="CATEGORY" VALUE="$form{'category'}">
<B>Item Price Each Is:</B> $config{'currencytype'}$lowest_new_bid
EOF

                if ($config{'regdir'}) {
                        print <<"EOF";
<TABLE WIDTH="100%"><TR><TD BGCOLOR="$config{'colortablebody'}">
<P><B><A HREF="$ENV{'SCRIPT_NAME'}?action=agree">Registration</A> is required to make a bid!</B>
<P><B>Your Username:</B> <INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias> (used to track your bid)
<BR><B>Your Password:</B> &nbsp;<INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 VALUE=$loginpassword> (must be valid)
<BR><B>Your Fixed Dutch Price Is:</B> $config{'currencytype'}$lowest_new_bid
<BR><INPUT NAME=BID TYPE=HIDDEN VALUE="$lowest_new_bid">
<BR><B>Quanty your bidding on:</B> 
<INPUT NAME=OQTY TYPE=TEXT SIZE=6 VALUE="1">
<INPUT TYPE=SUBMIT NAME=dutch VALUE="Place Bid">
</TD></TR></TABLE>
EOF
                }
                else {
                        print <<"EOF";
<TABLE WIDTH="100%"><TR><TD BGCOLOR="$config{'colortablebody'}">
<P><B>Your Username:</B> <INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30> (used to track your bid)
<BR><B>Your E-Mail Address:</B> <INPUT NAME=EMAIL TYPE=TEXT SIZE=30> (must be valid)
<BR><B>Your Bid:</B> $config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE="$lowest_new_bid">
<P><B>Contact Information:</B> (will be given out only to the seller)<BR>
<TT>Full Name: </TT><BR><INPUT NAME=ADDRESS1 TYPE=TEXT SIZE=30><BR>
<TT>Street Address: </TT><BR><INPUT NAME=ADDRESS2 TYPE=TEXT SIZE=30><BR>
<TT>City, State, ZIP: </TT><BR><INPUT NAME=ADDRESS3 TYPE=TEXT SIZE=30><P>
</TD></TR></TABLE>
EOF
       }   
                
print <<"EOF";      
<p><b>Binding contract:</b><br>
<font size="3">&nbsp;&nbsp;By placing a bid you are making a <b>CONTRACT</b> between you and the seller. Once you place a bid, you may not retract it.  In some states, it is illegal to win an auction and not purchase the item.  In other words, if you don't want to pay for it,
don't bid!<br>
<p><B>This is a Dutch Auction!</B><BR> 
Please refer to our rules governing Dutch auctions before bidding.(NOTE:) There is no proxy bidding in a dutch Auction, item price does not change when bidding, When a bid is placed the seller and buyer will be E-Mailed contact information price and quantity of bid, It is up to the buyer and seller to contact each other to make nessary arragments.<p></font> 

<TD WIDTH="30%" BGCOLOR="$config{'colortablebody'}">
<CENTER><b>How to Bid</b></CENTER><br>
<OL>
        <LI><A HREF="$ENV{'SCRIPT_NAME'}?action=agree">Register to bid</A> - It's free, and required to bid or sell.
        <LI><A HREF="#DESC">Know the Item</a> - Read the full description of the item you are bidding on.
        <LI>If you have questions about the item<br><A HREF="$ENV{'SCRIPT_NAME'}?action=askquestion&category=$form{'category'}&item=$form{'item'}&title=$title">(ask or view Q&A)</a> <B>BEFORE</b> you place a bid.
        <LI>Decide on the quantity you need!
</OL> 
</TD></TR>
</TABLE>
EOF
## End Dutch Bid Form
}
}
}
}

#-##########################################
# Allows user to confirm bid

sub confirmbid {


              my ($password, @userbids);

              $form{'ALIAS'} = lc($form{'ALIAS'});
              $form{'ALIAS'} = ucfirst($form{'ALIAS'}); 

        if ($config{'regdir'} ne "") {
        &oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE'}, $form{'IP'}, $form{'REFERRAL'}, $form{'REFNAME'}, @userbids) = &read_reg_file($form{'ALIAS'});        
        &oops('Your password is incorrect.') unless ((lc $password) eq 
(lc $form{'PASSWORD'}));
        }
        &oops('You must enter an alias to track your item.') unless ($form{'ALIAS'});
        &oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
        &oops('You must enter a valid bid amount.') unless ($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/);
        $form{'BID'} = &parsebid($form{'BID'});               
        &oops('You must enter your full name.') unless ($form{'ADDRESS1'});
        &oops('You must enter your street address.') unless ($form{'ADDRESS2'});
        &oops('You must enter you city, state, and zip.') unless ($form{'ADDRESS3'});

#### Checks suspended Users ###############
&checksuspendeduser($form{'ALIAS'});
#### END Checks suspended Users ###############

#### Clean old bid history from users registration data file ###############
&delete_sell_bid_history($form{'ALIAS'});
#### END Clean old bid history from users registration data file ###############

        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
        &oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') if $title eq '';

######## Being called here ############ 
        if ($config{'limitbidding'} eq 'on') {
&limitbidding($form{'CATEGORY'}, $form{'ITEM'}, $form{'ALIAS'}, @userbids);
        }
        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]); # read first bid 
################ for bidding on own item. ###
        &oops('You cannot bid on your own item!') if ($selleralias eq $form{'ALIAS'});
##### End ###############################
##### Seller Ban user #######
my $nobid;
if (open (NOTO, "$config{'basepath'}$config{'bandir'}/$selleralias.txt")) {
        my @allnoto=<NOTO>;
        close NOTO;

        chomp(@allnoto);
        foreach $nobid (@allnoto) {
                if($form{'ALIAS'} eq $nobid){
        &oops('<font size=-1 face=verdana><b>  Sorry... that seller does not allow you to bid on their auctions.</b></font> ');

                }
        }       
}
      
        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read last bid  
############# do not allow a new bid if a the bider already has the high bid #########
     if (($alias eq $form{'ALIAS'}) && ($reserve <= $bid)) {
        &oops('You already have the high bid you can not bid against yourself!');
        }  
        else {           
     if (($alias eq $form{'ALIAS'}) && ($reserve eq '0.00')) {   
        &oops('You already have the high bid you can not bid against yourself!');
        }
        }
########## End ###############
         &oops('<H2>Your bid is too low.  Sorry.</H2>') if ($form{'BID'} < ($bid+$inc) and ($#bids)) or ($form{'BID'} < $bid);
            
            my $lowest_new_bid;
            $lowest_new_bid = (&read_bid($bids[0]))[2];
            $lowest_new_bid = &parsebid($bid);                       
            $lowest_new_bid = &parsebid($bid + $inc) if ($#bids);  

             if (defined ($form{'proxy'})) {              
             print <<"EOF";
        <FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
        <INPUT TYPE=HIDDEN NAME=action VALUE=procbid>
        <INPUT TYPE=HIDDEN NAME=ITEM VALUE=$form{'ITEM'}>
        <INPUT TYPE=HIDDEN NAME=CATEGORY VALUE=$form{'CATEGORY'}>
        <INPUT TYPE=HIDDEN NAME=ALIAS VALUE=$form{'ALIAS'}>
        <INPUT TYPE=HIDDEN NAME=PASSWORD VALUE=$form{'PASSWORD'}>
        <INPUT TYPE=HIDDEN NAME=BID VALUE=$form{'BID'}>  
        <INPUT TYPE=HIDDEN NAME=\"bidtype\" VALUE=\"proxy\">                    
EOF

print "<p><center><h1>Proxy Bid Confirmation</h1></center></p></font>";
print "<p><font SIZE=3>";
print "<center><h3>Review bid for title:<font color=blue> $title</font><br>Item Number: <font color=blue>$form{'ITEM'}</font></h3></center></p></font>";
print "Your bid was in the amount of: <B>$config{'currencytype'}$lowest_new_bid </B><BR>\n";
print "Your maximum bid was in the amount of: <B>$config{'currencytype'}$form{'BID'}</B><BR>";
print "<b>Before finalizing your bid:</b><BR>";
print "<p><b>1.</b>  View <A HREF=$ENV{'SCRIPT_NAME'}\?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}\>comments</a> left by other users in the Feedback Profile for the seller.</b>
 <p><b>2.</b> Understand the seller's payment, shipping terms and conditions. Your bid means that you accept and will comply if you are the winning bidder.
 <p><b>3.</b> If you have any questions contact the seller. 
 <p><b>4.</b> The proxy bid will bid on your behalf as necessary by increasing your bid by the current bid increment until your maximum is reached. This saves you the trouble of having to keep track of the auction as it proceeds and prevents you from being outbid at the last minute.<br><b><font color=red> KEEP IN MIND THAT IF YOUR MAXIMUM BID MEETS OR BEATS THE RESERVE PRICE, THE MINIMUM BID WILL BE SET TO THAT AMOUNT.</font></b>\n";
print "<p>If your bid amount is correct, click the 'place bid' button below. Otherwise, use the back button on your browser to go back and make the necessary corrections. Once you place your bid, you cannot cancel it.\n";
print "<br><p><center><input type=submit value=\"Place Bid\"></center><br></form>\n";
}
        else {
        if (defined ($form{'std'})) { 
        print <<"EOF";
        <FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
        <INPUT TYPE=HIDDEN NAME=action VALUE=procbid>
        <INPUT TYPE=HIDDEN NAME=ITEM VALUE=$form{'ITEM'}>
        <INPUT TYPE=HIDDEN NAME=CATEGORY VALUE=$form{'CATEGORY'}>
        <INPUT TYPE=HIDDEN NAME=ALIAS VALUE=$form{'ALIAS'}>
        <INPUT TYPE=HIDDEN NAME=PASSWORD VALUE=$form{'PASSWORD'}>
        <INPUT TYPE=HIDDEN NAME=BID VALUE=$form{'BID'}>
        <INPUT TYPE=HIDDEN NAME=\"bidtype\" VALUE=\"std\">
EOF

print "<p><center><h1>Standard Bid Confirmation</h1></center></p></font>";
print "<p><font SIZE=3>";
print "<center><h3>Review bid for title:<font color=blue> $title</font><br>Item Number: <font color=blue>$form{'ITEM'}</font></h3></center></p></font>";
print "Your bid was in the amount of: <B>$config{'currencytype'}$form{'BID'}</B><BR>\n";
print "<b>Before finalizing your bid:</b><BR>";
print "<p><b>1.</b>  View <A HREF=$ENV{'SCRIPT_NAME'}\?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}\>comments</a> left by other users in the Feedback Profile for the seller.</b>
 <p><b>2.</b> Understand the seller's payment and shipping terms and conditions. Your bid means that you accept them and will comply if you are the winning bidder.
 <p><b>3.</b> If you have any questions contact the seller before placing a bid.\n"; 
print "<p>If your bid amount is correct, click the 'place bid' button below. Otherwise, use the back button on your browser to go back and make the necessary corrections. Once you place your bid, you cannot cancel it.\n";
print "<br><p><center><input type=submit value=\"Place Bid\"></center><br></form>\n";
}
}

}

#-##########################################
# Allows user to confirm bid

sub confirmdutchbid {

               my ($password, @userbids);

               $form{'ALIAS'} = lc($form{'ALIAS'});
               $form{'ALIAS'} = ucfirst($form{'ALIAS'});   


        if ($config{'regdir'} ne "") {
        &oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE'}, $form{'IP'}, $form{'REFERRAL'}, $form{'REFNAME'}, @userbids) = &read_reg_file($form{'ALIAS'});       
        &oops('Your password is incorrect.') unless ((lc $password) eq 
(lc $form{'PASSWORD'}));
        }
        &oops('You must enter an alias to track your item.') unless ($form{'ALIAS'});
        &oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
        &oops('You must enter a valid dutch bid amount.') unless ($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/);
        $form{'BID'} = &parsebid($form{'BID'});                                 
        &oops('You must enter your full name.') unless ($form{'ADDRESS1'});
        &oops('You must enter your street address.') unless ($form{'ADDRESS2'});
        &oops('You must enter you city, state, and zip.') unless ($form{'ADDRESS3'});

#### Checks suspended Users ###############
&checksuspendeduser($form{'ALIAS'});
#### END Checks suspended Users ###############

#### Clean old bid history from users registration data file ###############
&delete_sell_bid_history($form{'ALIAS'});
#### END Clean old bid history from users registration data file ###############

        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
        &oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') if $title eq '';

######## Being called here ############ 
        if ($config{'limitbidding'} eq 'on') {
&limitbidding($form{'CATEGORY'}, $form{'ITEM'}, $form{'ALIAS'}, @userbids);
        }

        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
################ for bidding on own item. ###
        &oops('You cannot bid on your own item!') if ($selleralias eq $form{'ALIAS'});
##### End ###############################
##### Seller Ban user #######
my $nobid;
if (open (NOTO, "$config{'basepath'}$config{'bandir'}/$selleralias.txt")) {
        my @allnoto=<NOTO>;
        close NOTO;

        chomp(@allnoto);
        foreach $nobid (@allnoto) {
                if($form{'ALIAS'} eq $nobid){
        &oops('<font size=-1 face=verdana><b>  Sorry... that seller does not allow you to bid on their auctions.</b></font> ');

                }
        }       
}
############
#### Dutch Count Quantity ######################
       if(($form{'OQTY'}) > $qty) {
       print "<H2>You may not bid on more items than are available!<br> Check quantity available, then check the number of bids.<br> You need to decrease the number of items that you are bidding on!</H2>\n";       
       } 
######### End Dutch Count Quantity ############# 
        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]);
#########  Dutch Sold Count #############  
        oops('<H2>All dutch items are sold! Or you need to decrease<br> the number of items that you are bidding on!</H2>') if (($soldqty+$form{'OQTY'}) > $qty);                     
######### End Dutch Sold Count ############# 
        oops('<H2>Your bid is too low. Sorry.</H2>') if ($form{'BID'} < ($bid) and ($#bids)) or ($form{'BID'} < $bid);                    
                               
            my $lowest_new_bid;
            $lowest_new_bid = (&read_bid($bids[0]))[2];             
            $lowest_new_bid = &parsebid($bid);  
        
        print <<"EOF";
        <FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
        <INPUT TYPE=HIDDEN NAME=action VALUE=procdutchbid>
        <INPUT TYPE=HIDDEN NAME=ITEM VALUE=$form{'ITEM'}>
        <INPUT TYPE=HIDDEN NAME=CATEGORY VALUE=$form{'CATEGORY'}>
        <INPUT TYPE=HIDDEN NAME=ALIAS VALUE=$form{'ALIAS'}>
        <INPUT TYPE=HIDDEN NAME=PASSWORD VALUE=$form{'PASSWORD'}>
        <INPUT TYPE=HIDDEN NAME=OQTY VALUE=$form{'OQTY'}>
        <INPUT TYPE=HIDDEN NAME=BID VALUE=$form{'BID'}>        
EOF
               
               my $totaldutchprice = &parsebid($form{'OQTY'} * $form{'BID'});    

print "<p><center><h1>Dutch Bid Confirmation</h1></center></p></font>";
print "<p><font SIZE=3>";
print "<center><h3>Review bid for title:<font color=blue> $title</font><br>Item Number: <font color=blue>$form{'ITEM'}</font></h3></center></p></font>";
print "Your bid was in the amount of: <B>$config{'currencytype'}$form{'BID'}</B><BR>\n";
print "The quantity your of order is: <B>$form{'OQTY'}</B><BR>\n";
print "Total price: <B>$config{'currencytype'}$form{'BID'} X $form{'OQTY'} = $config{'currencytype'}$totaldutchprice</B><BR>\n";
print "<p>";
print "<b>Before finalizing your bid:</b><BR>";
print "<p><b>1.</b>  View <A HREF=$ENV{'SCRIPT_NAME'}\?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}\>comments</a> left by other users in the Feedback Profile for the seller.</b>
 <p><b>2.</b> Understand the seller's payment and shipping terms and conditions. Your bid means that you accept them and will comply if you are the winning bidder.
 <p><b>3.</b> If you have any questions contact the seller before placing a bid. 
 <p><b>4.</b>There is no proxy bidding in a dutch Auction, item price does not change when bidding, When a bid is placed the seller and buyer will be E-Mailed contact information price and quantity of bid, It is up to the buyer and seller to contact each other to make nessary arragments.\n";
print "<p>If your bid amount is correct, click the 'place bid' button below. Otherwise, use the back button on your browser to go back and make the necessary corrections. Once you place your bid, you cannot cancel it, and being a dutch item this bid will buy the item.\n";
print "<br><p><center><input type=submit value=\"Place Bid\"></center><br></form>\n";
}

#-#############################################
# Sub: Process Bid
# This processes new bids from a posted form

sub procbid {
        my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        my ($password, @userbids);
              $form{'ALIAS'} = lc($form{'ALIAS'});
              $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        if ($config{'regdir'} ne "") {
        &oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE'}, $form{'IP'}, $form{'REFERRAL'}, $form{'REFNAME'}, @userbids) = &read_reg_file($form{'ALIAS'});       
        &oops('Your password is incorrect.') unless ((lc $password) eq 
(lc $form{'PASSWORD'}));
        }
        &oops('You must enter an alias to track your item.') unless ($form{'ALIAS'});
        &oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
        &oops('You must enter a valid bid amount.') unless ($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/);
        $form{'BID'} = &parsebid($form{'BID'});               
        &oops('You must enter your full name.') unless ($form{'ADDRESS1'});
        &oops('You must enter your street address.') unless ($form{'ADDRESS2'});
        &oops('You must enter you city, state, and zip.') unless ($form{'ADDRESS3'});
        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
        &oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') if $title eq '';
        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]); # read first bid   
################ for bidding on own item. #####################
        &oops('You cannot bid on your own item!') if ($selleralias eq $form{'ALIAS'});
######## End ###############################
        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read last bid   
############# do not allow a new bid if a the bider already has the high bid #########
     if (($alias eq $form{'ALIAS'}) && ($reserve <= $bid)) {
        &oops('You already have the high bid you can not bid against yourself!');
        }  
        else {           
     if (($alias eq $form{'ALIAS'}) && ($reserve eq '0.00')) {   
        &oops('You already have the high bid you can not bid against yourself!');
        }
        }
########## End ###############
         &oops('<H2>Your bid is too low.  Sorry.</H2>') if ($form{'BID'} < ($bid+$inc) and ($#bids)) or ($form{'BID'} < $bid);
  
        if ((time <= $form{'ITEM'}) or (time <= (60 * $config{'aftermin'} + $time))) {    
                &oops('We are unable to append your bid to the auction item. It appears to be a file server permissions problem.') unless (open NEW, ">>$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat");
                if ($config{'flock'}) {
                        flock(NEW, 2);
                        seek(NEW, 0, 2);
                }                
                #################### BEGIN OF AUTOBIDDER #######################
                ## The Bidder And The Autobidder:
                my $mybidder = sub {
print NEW "\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]$_[0]\[\]$_[1]\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'OQTY'}\[\]$form{'SOLDQTY'}"};

                my $autobidder = sub { my (@this) = &read_bid($bids[$#bids]); ($this[2], $this[3]) = ($_[0], $_[1]); print NEW "\n", join("[]", @this)};

                ## Now The Bids:
                if ($form{USEMAXBID} ne '' || !exists $form{USEMAXBID}){
                        $form{MAXBID} = &parsebid($form{BID});
                        $form{BID} = &parsebid($bid);                           
                        $form{BID} = &parsebid($bid + $inc) if ($#bids);                    
                }

                my $proxy = ($time =~ /\d*\#(\d*\.?\d*)/ ? parsebid($1*1) : 0);
                my $message;
                #####################################################
                ## BID WAS IMMEDIATELY BEATEN SO RETURN WITHOUT EMAIL
                if($proxy >= $form{MAXBID} && $#bids >= 0){
                        $form{BID} = &parsebid($form{MAXBID});
                        &$mybidder($form{MAXBID}, "$^T#$form{MAXBID}#beaten");
                        &$autobidder($form{MAXBID}, "$^T#$proxy#");
                        #&$autobidder($form{MAXBID} + $inc, "$^T#$proxy#");
                        $message = "Your bid was beaten by a proxy bid.<br><big><b>You are not the high bidder!</b></big>";                
                }
                ## BID WAS IMMEDIATELY BEATEN BUT SUCCESSFULLY REBID
                elsif($proxy >= $form{BID} && $#bids >= 0) {
                        &$mybidder($form{BID}, "$^T#$form{MAXBID}#beaten");
                        &$autobidder($proxy, "$^T#$proxy#beaten");
                        $form{BID} = &parsebid((($proxy + $inc) > $form{MAXBID}) ? ($form{MAXBID}) : ($proxy + $inc));
                        &$mybidder($form{BID}, "$^T#$form{MAXBID}#");
                        $message = "Your bid has been raised to $form{BID} in order to outbid an old proxy bid";                
                }
                ###################################################
                ## RAISED TO RESERVE PRICE BUT RESERVE WAS TOO HIGH
                else {                        
                        if($reserve > $form{MAXBID} && $form{MAXBID} > $form{BID}){
                                $form{BID} = &parsebid($form{MAXBID});
                                &$mybidder($form{BID}, "$^T#$form{MAXBID}#");
                                $message = "Your bid has been raised to $config{'currencytype'}$form{BID} in order to meet the reserve price.<br>The reserve price is not yet met.";                        
                        }
                        ## SUCCESSFULLY RAISED TO RESERVE PRICE
                        elsif($reserve > $form{BID} && $form{MAXBID} > $form{BID}) {
                                $form{BID} = $reserve;
                                &$mybidder($form{BID}, "$^T#$form{MAXBID}#");
                                $message = "Your bid has been raised in order to meet the reserve price.<br>The reserve price was $config{'currencytype'}$reserve.";                        
                        }
                        #####################
                        ## BID JUST REGULARLY
                        else {
                         if ($form{'bidtype'} eq 'std'){ 
                            $form{BID} = $form{MAXBID}; 
                            &$mybidder($form{BID}, "$^T#$form{MAXBID}#") 
                            } 
                         if ($form{'bidtype'} eq 'proxy'){ 
                            &$mybidder($form{BID}, "$^T#$form{MAXBID}#")

                            }
                      }
                }
                unless ($form{'bidtype'} eq 'std'){ 
                $message .= "<br>The proxy will automatically bid for you until $config{'currencytype'}@{[parsebid($form{MAXBID})]}"
                if ($form{BID} < $form{MAXBID}); 
                } 
                $message = "<p><b>Note:</b><br>$message</p>" if $message;               
                print "$form{'ALIAS'}, your bid has been placed on item number $form{'ITEM'} for $config{'currencytype'}$form{'BID'} on $nowtime $message<p>You may want to print this notice as confirmation of your bid.<P>Go <A HREF=\"$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}\">back to the item</A></p>";
                close NEW;
                return if($proxy >= $form{MAXBID});
                ###################### END OF AUTOBIDDER #########################
                my $flag=0;
                my $userbid;
                foreach $userbid (@userbids) {
                        $flag=1 if ("$form{'CATEGORY'}$form{'ITEM'}" eq $userbid);
                }
                if ($flag==0 && $config{'regdir'} ne "") {
                        &oops('We could not open the registration file.  This could be a server write issue.') unless (open(REGFILE, ">>$config{'regdir'}/$form{'ALIAS'}.dat"));
                        if ($config{'flock'}) {
                        flock(REGFILE, 2);
                        seek(REGFILE, 0, 2);
                        } 
                        print REGFILE "\n$form{'CATEGORY'}$form{'ITEM'}";
                        close REGFILE;
                } 
                #### Sends the buyer and seller the Dutch Bids                       
                my @lastbid = &read_bid($bids[$#bids]); # read last bid   
                my @firstbid =  &read_bid($bids[0]); # read first bid  
                ###### Add for SUB Cats E-Mail Display ####           
                my($key, $disppath, $thispath, @this);
	        foreach $key (keys %category) {
	        	$disppath = '';
		        $thispath = $category{$form{'CATEGORY'}};
              		while($thispath =~ s/^<!--([^\>]*)-->//) {
	          		if($supercat{$1} ne '') {                                
		        	$disppath .= "$supercat{$1} -> $thispath "; 
                                $thispath = '';
			        }
                        }
                }
                ###### END Add for SUB Cats E-Mail Display ####

                if (($lastbid[0] ne $firstbid[0]) && ($alias ne $form{'ALIAS'})) { 
                &sendemail($selleremail, $config{'admin_address'}, 'You Have Another Bid!', 
"Another bid placed on your auction: $title!
Auction number: $form{'ITEM'}
Category: $thispath $disppath

Seller: $selleralias
New Bidder: $form{'ALIAS'}
The current high bid is $config{'currencytype'}$form{'BID'}

If you want to view the bid, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}");
        
                   &sendemail($form{'EMAIL'}, $config{'admin_address'}, 'Bid confirmation', "Bid confirmation on: $title
Auction number: $form{'ITEM'}
Category: $thispath $disppath

Seller: $selleralias
Bidder: $form{'ALIAS'}
The current high bid is $config{'currencytype'}$form{'BID'}

If you want to view the item, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}

Thank you for using the White Bear Lake Area Historical Society Online Auction.");

                &sendemail($email, $config{'admin_address'}, 'You have been outbid!', "You have been outbid on: $title
Auction number: $form{'ITEM'}
Category: $thispath $disppath

Seller: $selleralias
New Bidder: $form{'ALIAS'}
The current high bid is $config{'currencytype'}$form{'BID'}

If you want to view the item or place a higher bid, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}

Thank you for using the White Bear Lake Area Historical Society Online Auction.");
                }               
             if ($lastbid[0] eq $firstbid[0]) {
                &sendemail($selleremail, $config{'admin_address'}, 'Bidding has begun!', "You have a bid on: $title
Auction number: $form{'ITEM'}
Category: $thispath $disppath

Information:
Seller: $selleralias
New Bidder: $form{'ALIAS'}
The current high bid is $config{'currencytype'}$form{'BID'}

If you want to view the bid, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}"); 

                   &sendemail($form{'EMAIL'}, $config{'admin_address'}, 'Bid confirmation', "Bid confirmation on: $title!
Auction number: $form{'ITEM'}
Category: $thispath $disppath

Seller: $selleralias
Bidder: $form{'ALIAS'}
The current high bid is $config{'currencytype'}$form{'BID'}

If you want to view the item, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}

Thank you for using the White Bear Lake Area Historical Society Online Auction"); 
                }
                #### End Sends the buyer and seller placed bids and buyers a outbid notis
         }            
        
}

#-#############################################
# Sub: Process Dutch bids 

sub procdutchbid {
        my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        my ($password, @userbids);
              $form{'ALIAS'} = lc($form{'ALIAS'});
              $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        if ($config{'regdir'} ne "") {
        &oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE'}, $form{'IP'}, $form{'REFERRAL'}, $form{'REFNAME'}, @userbids) = &read_reg_file($form{'ALIAS'});        
        &oops('Your password is incorrect.') unless ((lc $password) eq 
(lc $form{'PASSWORD'}));
        }
        &oops('You must enter an alias to track your item.') unless ($form{'ALIAS'});
        &oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
        &oops('You must enter a valid dutch bid amount.') unless ($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/);
        $form{'BID'} = &parsebid($form{'BID'});                                 
        &oops('You must enter your full name.') unless ($form{'ADDRESS1'});
        &oops('You must enter your street address.') unless ($form{'ADDRESS2'});
        &oops('You must enter you city, state, and zip.') unless ($form{'ADDRESS3'});
        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
        &oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') if $title eq '';
######### check for bidding on own item. ###
        my ($selleralias, $selleremail, $sellerbid, $sellertime, $selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]);
        &oops('You cannot bid on your own dutch item!') if ($selleralias eq $form{'ALIAS'});
##### End check for bidding on own item. ###############################
#### Dutch Count quantity ######################
       if(($form{'OQTY'}) > $qty) {
       print "<H2>You may not bid on more items than are available!<br> Check quantity available, then check the number of bids.<br> You need to decrease the number of items that you are bidding on!</H2>\n";       
       } 
######### End Dutch Count quantity #############          
        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$#bids]); # read last bid   
#########  Dutch Sold Count #############  
        oops('<H2>All dutch items are sold! Or you need to decrease<br> the number of items that you are bidding on!</H2>') if (($soldqty+$form{'OQTY'}) > $qty);                     
######### End Dutch Sold Count #############     
        if ((time <= $form{'ITEM'}) or (time <= (60 * $config{'aftermin'} + $time))) {                                  
        &oops('We are unable to append your bid to the auction item. It appears to be a file server permissions problem.') unless (open NEW, ">>$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat");
                if ($config{'flock'}) {
                        flock(NEW, 2);
                        seek(NEW, 0, 2);
                }  
$form{'SOLDQTY'} = $soldqty+$form{'OQTY'};
                print NEW "\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]$form{'BID'}\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'OQTY'}\[\]$form{'SOLDQTY'}";
		close NEW;	
                my $flag=0;
                my $userbid;
                foreach $userbid (@userbids) {
                        $flag=1 if ("$form{'CATEGORY'}$form{'ITEM'}" eq $userbid);
                }
                if ($flag==0 && $config{'regdir'} ne "") {
                        &oops('We could not open the registration file.  This could be a server write issue.') unless (open(REGFILE, ">>$config{'regdir'}/$form{'ALIAS'}.dat"));
                        if ($config{'flock'}) {
                        flock(REGFILE, 2);
                        seek(REGFILE, 0, 2);
                        } 
                        print REGFILE "\n$form{'CATEGORY'}$form{'ITEM'}";
                        close REGFILE;
                }  
                #### Sends the buyer and seller the Dutch Bids   
                #### Sends the buyer and seller the Dutch Bids                       
                my @lastbid = &read_bid($bids[$#bids]); # read last bid   
                my @firstbid =  &read_bid($bids[0]); # read first bid  
                ###### Add for SUB Cats E-Mail Display ####           
                my($key, $disppath, $thispath, @this);
	        foreach $key (keys %category) {
	        	$disppath = '';
		        $thispath = $category{$form{'CATEGORY'}};
              		while($thispath =~ s/^<!--([^\>]*)-->//) {
	          		if($supercat{$1} ne '') {                                
		        	$disppath .= "$supercat{$1} -> $thispath "; 
                                $thispath = '';
			        }
                        }
                }
                ###### END Add for SUB Cats E-Mail Display ###   
  
                   my $dutchpricexqty = "$lastbid[2] x $form{'OQTY'}"; 
                   my $dutchprice = ($lastbid[2]);
                   my $dutchoqty = ($form{'OQTY'});
                   my $totaldutchprice = &parsebid($dutchoqty * $dutchprice);    
  
	print "<B>$form{'ALIAS'}, your bid has been placed on item number $form{'ITEM'} for the quantity of $form{'OQTY'} at $config{'currencytype'}$form{'BID'} for the total price of $config{'currencytype'}$totaldutchprice $nowtime</B><BR>You may want to print this notice as confirmation of your bid.<P>Go <A HREF=\"$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}\">back to the item</A>\n";

#--Accounting Dutch Sales Item Charge Entry Point---------#
                
         if ($config{'percentageclose'} eq "on") {
              &transaction_percentage_closed($firstbid[0], "Dutch Auction Sale, #$form{'ITEM'} ($title) $dutchpricexqty", $firstbid[2], $totaldutchprice, $reserve);
         }
#--End-------------------------------------------------#  
                               
                &sendemail($selleremail, $config{'admin_address'}, 'New Dutch Bid!', "$selleralias

Dutch Item Title: $title
Auction number $form{'ITEM'}
Category: $thispath $disppath

Information:
Bidders User ID: $form{'ALIAS'}
Bidders E-Mail: $form{'EMAIL'}
DUTCH price: $config{'currencytype'}$form{'BID'}
Quantity bidded on: $form{'OQTY'}
Total price: $dutchprice X $form{'OQTY'} = $totaldutchprice

If you want to view the bid, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}

Now What?
The buyer and seller should contact each other within three business days to complete the sale. Not getting in touch leaves the contract open and can earn you negative feedback.

We hope you have enjoyed using the $config{'sitename'} and will come back often.");
                                
                &sendemail($form{'EMAIL'}, $config{'admin_address'}, 'Your Dutch Bid!', 
"$form{'ALIAS'}

Dutch Item Title: $title
Auction number $form{'ITEM'}
Category: $thispath $disppath

Information:
Seller User ID: $selleralias
Seller E-mail: $selleremail
DUTCH price: $config{'currencytype'}$form{'BID'}
Quantity bidded on: $form{'OQTY'}
Total price: $dutchprice X $form{'OQTY'} = $totaldutchprice

If you want to view you bid, please visit:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}

Now What?
The buyer and seller should contact each other within three business days to complete the sale. Not getting in touch leaves the contract open and can earn you negative feedback.

We hope you have enjoyed using the $config{'sitename'} and will come back often.");
              
               #### End Sends the buyer and seller the Dutch Bids 
        }               
                if (($soldqty+$form{'OQTY'}) eq $qty) {
                &earlydutchclose($form{'CATEGORY'},$form{'ITEM'});
                }
}

#################################
# Closes dutch auction early
# when all dutch items are sold

sub earlydutchclose {

                if ($form{'CATEGORY'} ne $config{'closedir'}) { 
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
               
                my @lastbid = &read_bid($bids[$#bids]);
                my @firstbid =  &read_bid($bids[0]);   
                   my $numauct;
                   $numauct = $form{'ITEM'};
                   $numauct =~ s/\.dat//; 
                                                       
                            my $qtyleft;
                            $qtyleft = $qty - $lastbid[8];                            

        &sendemail($firstbid[1], $config{'admin_address'}, "Auction Close: Item #$numauct \($title\)", 
"$firstbid[4]

Congratulations! This dutch auction has ended early successfully selling all $qty dutch items you listed for auction.
Item #$numauct \($title\)
Starting quantity: $qty
Sold quantity: $lastbid[8]
Items Left: $qtyleft
Item Title: $title

Now What?
The buyer and seller should have received contact info and with quantity ordered at the time dutch bids were placed to be able to contact each other within three business days to complete the sale. Not getting in touch leaves the contract open and can earn you negative feedback.

We hope you have enjoyed using the $config{'sitename'} and will come back often!");
 
         if ($config{'closedir'}) {
         umask(000); # UNIX file permission junk 
         mkdir("$config{'basepath'}$config{'closedir'}", 0777) unless (-d "$config{'basepath'}$config{'closedir'}"); 
                 print "Please notify the site admin that this item cannot be copied to the closed directory even though it is closed.\n" unless &movefile("$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat", "$config{'basepath'}$config{'closedir'}/$form{'CATEGORY'}$form{'ITEM'}.dat");
                 unlink("$config{'basepath'}$config{'countdir'}/$form{'ITEM'}.dat");
                 }
                 else { 
                 print "Please notify the site admin that this item cannot be removed even though it is closed.\n" unless unlink("$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat"); 
                 }        
        }
}

#-#############################################
# Sub New auction posting verify user login 2
# This logs in a user and verifies they 
# have a Credit Card on file before posting a new auction item

sub newlogin {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

     print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><TABLE WIDTH=50% BORDER=0 cellspacing=0 cellpadding=3>
<INPUT TYPE=HIDDEN NAME=action VALUE=verifynewlogin>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Validate Username and Password to post a new auction item.</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:</B></TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias></td></tr>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:</B></TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword></font></TD></TR>
</TABLE>
<INPUT TYPE=SUBMIT VALUE="Submit"></form></CENTER>
EOF
}

###############################################
# Sub New auction posting verify user login 2

sub verifynewlogin {

                umask(000);  # UNIX file permission junk
                mkdir("$config{'creditcarddir'}", 0777) unless (-d "$config{'creditcarddir'}");    
                  
                $form{'ALIAS'} = lc($form{'ALIAS'});
                $form{'ALIAS'} = ucfirst($form{'ALIAS'});       

        if (($form{'ALIAS'} eq "") || ($form{'PASSWORD'} eq "")) {
        &oops("Sorry... you must enter a valid username and password.");        
        } 

        if ($config{'regdir'} ne "") {  
        &oops('Your alias could not be found!') unless my($password, $email, $add1, $add2, $add3, $phone, $ip, $referral, $refname, @userbids) = &read_reg_file($form{'ALIAS'});
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));
        }             
        
#### Checks suspended Users ###############
&checksuspendeduser($form{'ALIAS'});
#### END Checks suspended Users ###############

#### Clean old bid history from users registration data file ###############
&delete_sell_bid_history($form{'ALIAS'});
#### END Clean old bid history from users registration data file ###############       

        if ($config{'AccountStatus'} eq "on") {
        &Account_Status($form{'ALIAS'});
        }

       if ($config{'requirecreditcard'} eq "off") {            
       &selectnew;    
       }
 
if ($config{'requirecreditcard'} eq "on") {             
                umask(000);  # UNIX file permission junk
                mkdir("$config{'creditcarddir'}", 0777) unless (-d "$config{'creditcarddir'}");    

	 open(HTACCESS, ">$config{'creditcarddir'}.htaccess");                 
         print HTACCESS "order deny,allow\ndeny from all" unless (-d "$config{'creditcarddir'}.htaccess");
         close(HTACCESS);
   
    opendir THEDIR, "$config{'creditcarddir'}" || die "Unable to open credit card directory: $!";    
    my @allfiles = readdir THEDIR;
    closedir THEDIR;              
     
     if (-T "$config{'creditcarddir'}$form{'ALIAS'}.bill") { 
        &selectnew; 
        }         
        else {       
        my $ip = $ENV{'REMOTE_ADDR'};                    
print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}><INPUT TYPE=HIDDEN NAME=action VALUE=proccc>
<INPUT TYPE=HIDDEN NAME=ALIAS VALUE=$form{'ALIAS'}><TR BGCOLOR=$config{'colortablehead'}><TD COLSPAN=2 VALIGN=TOP><h3>Your credit card info is required for monthly billing. This is only used to cover the posting fees only if any, and this is a must in order to place a auction item up for bid on $config{'sitename'}.</h3><CENTER><b>For your security your IP address is recorded: <font color=green>$ip</font></B></CENTER> <INPUT TYPE=HIDDEN NAME=IPADDRESS value=$ip></TD></TR><TR><TD VALIGN=TOP>Card Type:</TD><TD><SELECT NAME=CARDTYPE></OPTION><OPTION NAME=CARDTYPE>MasterCard</OPTION><OPTION NAME=CARDTYPE>Visa</OPTION><OPTION NAME=CARDTYPE>Discover</OPTION><OPTION NAME=CARDTYPE>Amex</OPTION></SELECT></TD></TR><TR><TD VALIGN=TOP>Expires \(Month\):
</TD><TD><SELECT NAME=EXPMONTH></OPTION><OPTION NAME=EXPMONTH>Jan</OPTION><OPTION NAME=EXPMONTH>Feb</OPTION><OPTION NAME=EXPMONTH>Mar</OPTION><OPTION NAME=EXPMONTH>Apr</OPTION><OPTION NAME=EXPMONTH>May</OPTION><OPTION NAME=EXPMONTH>Jun</OPTION><OPTION NAME=EXPMONTH>Jul</OPTION><OPTION NAME=EXPMONTH>Aug</OPTION><OPTION NAME=EXPMONTH>Sep</OPTION><OPTION NAME=EXPMONTH>Oct</OPTION><OPTION NAME=EXPMONTH>Nov</OPTION><OPTION NAME=EXPMONTH>Dec</OPTION></SELECT></TD></TR><TR><TD VALIGN=TOP>Expires \(Year\):</TD>
<TD><SELECT NAME=EXPYEAR></OPTION><OPTION NAME=EXPYEAR>2006</OPTION><OPTION NAME=EXPYEAR>2007</OPTION><OPTION NAME=EXPYEAR>2008</OPTION><OPTION NAME=EXPYEAR>2009</OPTION><OPTION NAME=EXPYEAR>20010</OPTION><OPTION NAME=EXPYEAR>2011</OPTION><OPTION NAME=EXPYEAR>2012</OPTION><OPTION NAME=EXPYEAR>2013</OPTION><OPTION NAME=EXPYEAR>2014</OPTION><OPTION NAME=EXPYEAR>2015</OPTION></SELECT></TD></TR>
<TR><TD VALIGN=TOP>Card Number:</TD><TD><INPUT TYPE=TEXT SIZE=16 MAXLENGTH=16 NAME=CARDNUM></TD></TR>
<TD VALIGN=TOP>Card Security Number:<br>This is the 3 digit number on back of the card</TD><TD><INPUT TYPE=TEXT SIZE=16 MAXLENGTH=16 NAME=SECURITYNUM></TD></TR>
<TR><TD VALIGN=TOP>Full Name used on card:</TD><TD VALIGN=TOP><INPUT NAME=NAME TYPE=TEXT SIZE=20></TD></TR><TR><TD VALIGN=TOP>Address used on card:</TD><TD VALIGN=TOP><INPUT NAME=ADDRESS TYPE=TEXT SIZE=20></TD></TR><TR><TD VALIGN=TOP>City used on card:
</TD><TD VALIGN=TOP><INPUT NAME=CITY TYPE=TEXT SIZE=20></TD></TR>
<TR><TD VALIGN=TOP>State used on card:</TD><TD VALIGN=TOP><INPUT NAME=STATE TYPE=TEXT SIZE=20></TD></TR><TR><TD VALIGN=TOP>Zip Code used on card:</TD><TD VALIGN=TOP><INPUT NAME=ZIP TYPE=TEXT SIZE=10><TR><TD VALIGN=TOP>Your area code and phone number:</TD><TD VALIGN=TOP><INPUT NAME=PHONE TYPE=TEXT SIZE=12></TD></TR></TD></TR>
</TABLE><BR><CENTER><INPUT TYPE=SUBMIT VALUE="Process my Credit Card"></CENTER>
</form>
EOF
    }
  }
}

#-#############################################
# Sub Process new credit card
# This will process the users Credit Card for monthly Billing

sub proccc {
 
            &oops('You must enter the card type.') unless ($form{'CARDTYPE'});
            &oops('You must enter the card expire month.') unless ($form{'EXPMONTH'}); 
            &oops('You must enter the card expire year.') unless ($form{'EXPYEAR'}); 
            &oops('You must enter the card number.') unless ($form{'CARDNUM'}); 
            &oops('You must enter your fill name on card.') unless ($form{'NAME'}); 
            &oops('You must enter your address on card.') unless ($form{'ADDRESS'});    
            &oops('You must enter you city and state on card.') unless ($form{'CITY'});    
            &oops('You must enter your zip code on card.') unless ($form{'ZIP'});    
            &oops('You must enter your home phone number.') unless ($form{'PHONE'});    

            &oops('We were unable to write to the user credit card info.') unless (open NEWCC, ">$config{'creditcarddir'}$form{'ALIAS'}.bill");
                        print NEWCC "$form{'CARDNUM'}\n$form{'SECURITYNUM'}\n$form{'EXPMONTH'}\n$form{'EXPYEAR'}\n$form{'CARDTYPE'}\n$form{'PHONE'}\n$form{'LINESPACE'}\n$form{'IPADDRESS'}\n$form{'NAME'}\n$form{'ADDRESS'}\n$form{'CITY'}\n$form{'STATE'}\n$form{'ZIP'}";
                         close NEWCC;

print <<"EOF";
<center>
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<INPUT TYPE=HIDDEN NAME=action VALUE=selectnew>
<INPUT TYPE=SUBMIT VALUE="Credit card verified click here to continue">
</center>
EOF

}

#-#############################################
# Sub: This allows a user to select the image type 
# to be place with a new item to be put up for sale

sub selectnew {

$config{'uploadimagefee2'} = "FREE"  if ($config{'uploadimagefee2'} eq "0.00");

if ($config{'allowimageuploads'} eq 'yes') {
print <<"EOF";
<center><table BGCOLOR=$config{'colortablebody'} BORDER=1 COLS=1 WIDTH="75%">
<tr><td><blockquote><center><b><font color="#000000"><font face=Arial Black size=+2>Option 1</font></font></b></center><b><font face=Arial Black size=+1><font color="#000000">Post a new auction listing and </font>UPLOAD a gif or jpg image \($config{'limit'}k MAX SIZE\) so your buyers may SEE what you are offering for sale. Image upload hosting fee: $config{'uploadimagefee2'}</font></b><p><b><font color="#000000">With this option you have to upload a gif or jpg image picture before you can proceed to the post an auction item form. The image picture has to be somewhere on the hard drive of the computer you are using now!</font></b></blockquote>
    <center><FORM ACTION=$config{'yourphotourl'} METHOD=POST>    
    <input TYPE=SUBMIT VALUE="Post a new auction Option 1"></form></center>
</td></tr>

<tr><td><blockquote><center><b><font color="#000000"><font face=Arial Black size=+2>Option              2</font></font></b></center><b><font color="#000000"><font face=Arial Black size=+1>Post a new auction listing without the auction items image picture being on the computer you are using now by entering a PICTURE's URL location from another Internet Server somewhere                on the Internet on the next posting screen, or post an auction WITHOUT A               PICTURE at all.</font></font></b><b><font color="#000000"></font></b>
<p><b><font color="#000000">You may specify a URL with a picture already web               assessable (already on an internet server) on the next page to do this. Leave the image URL box on the next page BLANK for NO AUCTION PICTURE at all for this auction.</font></b></blockquote>
     <center><FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
     <input TYPE=hidden NAME=action VALUE=new>
     <input TYPE=SUBMIT VALUE="Post a new auction Option 2"></form></center>
</td></tr></table></center>

EOF
       }
       else {
       &new;
       }

}

#-######################################
# Sub: Add New Item
# This allows a new item to be put up for sale

sub new {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }
                    
	my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids); 
             my $startbid1 = "0.00";
             my $reserve1 = "0.00";
             my $inc1 = "1.00";
             my $buyit1 = "0.00";
             my $startbid2 = "0";
             my $reserve2 = "0";
             my $inc2 = "1";
             my $buyit2 = "0";
	if ($form{'REPOST'}) {
		$form{'REPOST'} =~ s/\W//g;
		if (-T "$config{'basepath'}$config{'closedir'}/$form{'REPOST'}.dat") {
        	open THEFILE, "$config{'basepath'}$config{'closedir'}/$form{'REPOST'}.dat";               
		        ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
                        my ($selleralias, $selleremail, $bid, $time, $selleradd1, $selleradd2, $selleradd3, $oqty, $soldqty) = &read_bid($bids[0]); # read first bid
                             $startbid1 = $bid;
                             $reserve1 = $reserve;
                             $inc1 = $inc;
                             $buyit1 = $buyit;
                             $startbid2 = $bid;
                             $reserve2 = $reserve;
                             $inc2 = $inc;
                             $buyit2 = $buyit;                     
			$title =~ s/\"//g;  # quotes cause problems for a text input field
		}
	}

	if ($form{'DUTCHREPOST'}) {
		$form{'DUTCHREPOST'} =~ s/\W//g;
		if (-T "$config{'basepath'}$config{'closedir'}/$form{'DUTCHREPOST'}.dat") {
        	open THEFILE, "$config{'basepath'}$config{'closedir'}/$form{'DUTCHREPOST'}.dat";               
		        ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
                        my ($selleralias, $selleremail, $bid, $time, $selleradd1, $selleradd2, $selleradd3, $oqty, $soldqty) = &read_bid($bids[0]); # read first bid
                             $startbid1 = $bid;
                             $reserve1 = $reserve;
                             $inc1 = $inc;
                             $buyit1 = $buyit;
                             $startbid2 = $bid;
                             $reserve2 = $reserve;
                             $inc2 = $inc;
                             $buyit2 = $buyit;                     
			$title =~ s/\"//g;  # quotes cause problems for a text input field
		}
	}

	if ($form{'SOLDREPOST'}) {
		$form{'SOLDREPOST'} =~ s/\W//g;
		if (-T "$config{'basepath'}$config{'closedir'}/$form{'SOLDREPOST'}.dat") {
        	open THEFILE, "$config{'basepath'}$config{'closedir'}/$form{'SOLDREPOST'}.dat";               
		        ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
                        my ($selleralias, $selleremail, $bid, $time, $selleradd1, $selleradd2, $selleradd3, $oqty, $soldqty) = &read_bid($bids[0]); # read first bid
                             $startbid1 = $bid;
                             $reserve1 = $reserve;
                             $inc1 = $inc;
                             $buyit1 = $buyit;
                             $startbid2 = $bid;
                             $reserve2 = $reserve;
                             $inc2 = $inc;
                             $buyit2 = $buyit;                     
			$title =~ s/\"//g;  # quotes cause problems for a text input field
		}
	}

$config{'listingfee2'} = "FREE"  if ($config{'listingfee2'} eq "0.00");
$config{'feat_full_fee2'} = "FREE"  if ($config{'feat_full_fee2'} eq "0.00");
$config{'feat_cat_fee2'} = "FREE"  if ($config{'feat_cat_fee2'} eq "0.00");
$config{'feat_green_fee2'} = "FREE"  if ($config{'feat_green_fee2'} eq "0.00");
$config{'feat_bold_fee2'} = "FREE"  if ($config{'feat_bold_fee2'} eq "0.00");
$config{'grabberfee2'} = "FREE"  if ($config{'grabberfee2'} eq "0.00");
$config{'galleryfee2'} = "FREE"  if ($config{'galleryfee2'} eq "0.00");
$config{'counterfee2'} = "FREE"  if ($config{'counterfee2'} eq "0.00");
$config{'musicfee2'} = "FREE"  if ($config{'musicfee2'} eq "0.00");

        print <<"EOF";
<p></p>
EOF

if ($config{'postpercentage'} eq 'on') {
        print <<"EOF";
<table align="center" border=1 width="75%" bgcolor="#ffffff">
<tr>
<td WIDTH="46%">Posting percentage commissions based of the starting bid.</td>
<td ALIGN=CENTER WIDTH="54%">0.00 to 150.99 = 2.0%<br>151.00 to 250.99 = 1.80%<br>251.00 to 500.99 = 1.5%<br>501.00 to 999999.99 = 1.3%</td>
</tr>
</table>
EOF
}

if ($config{'percentageclose'} eq 'on') {
        print <<"EOF";
<table align="center" border=1 width="75%" bgcolor="#ffffff">
<tr>
<td WIDTH="46%">Closing percentage commissions based of the winning bid. no commission if not sold!</td>
<td ALIGN=CENTER WIDTH="54%">0.00 to 150.99 = 2.0%<br>151.00 to 250.99 = 1.80%<br>251.00 to 500.99 = 1.5%<br>501.00 to 999999.99 = 1.3%</td>
</tr>
</table>
EOF
}

        print <<"EOF";
<table align="center" border=1 width="75%" bgcolor="#ffffff">
<tr>
<td WIDTH="46%">Auction Insertion Fee</td>
<td ALIGN=CENTER WIDTH="54%">$config{'listingfee2'}</td>
</tr>
</table>
EOF
        
        print <<"EOF";
<p>
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<INPUT TYPE=HIDDEN NAME=REPOST VALUE=$form{'REPOST'}>
<INPUT TYPE=HIDDEN NAME=action VALUE=procnew>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><H2>Post A New Item</H2></TH></TR>

<TR><TD VALIGN=TOP><B>Title/Item Name:<BR></B>No HTML</TD><TD><INPUT NAME=TITLE VALUE=\"$title\" TYPE=TEXT SIZE=55 MAXLENGTH=55></TD></TR>

<TR><TD VALIGN=TOP><B>Category:<BR></B>Select One</TD><TD><SELECT NAME=CATEGORY>
<OPTION SELECTED></OPTION>
EOF

       my($key, $disppath, $thispath, @this);
	foreach $key (keys %category) {
		$disppath = '';
		$thispath = $category{$key};
		while($thispath =~ s/^<!--([^\>]*)-->//){
			if($supercat{$1} ne ''){
			$disppath .= "$supercat{$1} -> ";
			}
		}
		push(@this, ["$disppath$thispath", $disppath, "<OPTION VALUE=\"$key\">$disppath$thispath</OPTION>\n"]);
	}
	foreach $key (sort {lc $a->[0] cmp lc $b->[0]} @this){
		if($key->[1] ne $thispath){
			$thispath=$key->[1];
			print "<option></option>\n"; # Insert a blank option line
		}
		print $key->[2];
	}    

print <<"EOF";   
</SELECT></TD></TR>

<TR><TD VALIGN=TOP><B>Image URL:<BR></B>Optional, should be no larger than 200x200<br> Example:<br>http://www.your.com/images/myimage.gif</TD>
<TD>
Image 1<INPUT NAME=IMAGE1 VALUE=\"$image1\" TYPE=TEXT SIZE=55><br>
Image 2<INPUT NAME=IMAGE2 VALUE=\"$image2\" TYPE=TEXT SIZE=55><br>
Image 3<INPUT NAME=IMAGE3 VALUE=\"$image3\" TYPE=TEXT SIZE=55><br>
Image 4<INPUT NAME=IMAGE4 VALUE=\"$image4\" TYPE=TEXT SIZE=55>
</TD>
</TR>

<TR><TD VALIGN=TOP><B>Days Until Close:<BR></B>1-$config{'listingdays'}</TD><TD><INPUT NAME=DAYS TYPE=TEXT SIZE=2 MAXLENGTH=2 VALUE=$config{'listingdays'}></TD></TR>
<tr>
  <TD VALIGN=TOP><b>Auto Relist:</b><br>
    Optional, this will allow you to relist your item up to 2 times if not sold equal to the same runing days as you entered above.
  </td>
  <td><b>Number of times to relist item:</b><br>
<INPUT NAME=RELIST TYPE=Radio VALUE="0" checked>None<br>
<INPUT NAME=RELIST TYPE=Radio VALUE="1">1<br>
<INPUT NAME=RELIST TYPE=Radio VALUE="2">2<br>
</td></tr>

<TR><TD VALIGN=TOP><B>Description Title Color :<BR></B>This is the font color you would like the decsription title to be.</TD>
<td><INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#000000>" checked><font color=000000>Black</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#0000FF>"><font color=0000FF>Blue</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#EE0000>"><font color=EE0000>Red</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#00AA00>"><font color=00AA00>Green</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#FF9900>"><font color=FF9900>Orange</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#663300>"><font color=663300>Brown</font><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description Title Size :<BR></B>This is the font size you would like the description title to be.</TD>
<td><INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=4>" checked><FONT size=4>4</FONT><br>
<INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=5>"><FONT size=5>5</FONT><br>
<INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=6>"><FONT size=6>6</FONT><br>
<INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=7>"><FONT size=7>7</FONT><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description Title:<BR></B>This is the description title of your item.</TD><TD><TEXTAREA NAME=DESCTIT ROWS=5 COLS=55 WRAP=vertical>$desctit</TEXTAREA></TD></TR>

<TR><TD VALIGN=TOP><B>Description Color :<BR></B>This is the font color you would like the decsription to be.</TD>
<td><INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#000000>" checked><font color=000000>Black</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#0000FF>"><font color=0000FF>Blue</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#EE0000>"><font color=EE0000>Red</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#00AA00>"><font color=00AA00>Green</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#FF9900>"><font color=FF9900>Orange</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#663300>"><font color=663300>Brown</font><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description Size :<BR></B>This is the font size you would like the description to be.</TD>
<td><INPUT NAME=DESCSIZE TYPE=Radio VALUE="<FONT size=4>" checked><FONT size=4>4</FONT><br>
<INPUT NAME=DESCSIZE TYPE=Radio VALUE="<FONT size=5>"><FONT size=5>5</FONT><br>
<INPUT NAME=DESCSIZE TYPE=Radio VALUE="<FONT size=6>"><FONT size=6>6</FONT><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description:<BR></B>May include HTML with no Java Scripting, as Java Scripts will be removed. - The description should include all information the buyer should know including the shipping carrier and shipping fees.</TD><TD><TEXTAREA NAME=DESC ROWS=5 COLS=55 WRAP=vertical>$desc</TEXTAREA></TD></TR>
</TABLE>

<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2>Special Arrangements</b></font></TH></TR>
<TR><TD VALIGN=TOP><B>Payment Type:<BR></B><br>Select the type of payments you will accept.</TD>
<TD><b>Select One</b><BR>
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="See item description for payment methods accepted." checked>See item description for payment methods accepted.<br>---->
<INPUT NAME=PAYMENT TYPE=Radio VALUE="Pay Pal, Master Card, Visa, Discover, Debit Card, or Personal Check">Pay Pal, Master Card, Visa, Discover, Debit Card, or Personal Check<br>
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Visa">Visa<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Debit Card">Debit Card<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal">PayPal<br>------>
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Money Order">Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Personal Check">Personal Check<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Visa">Master Card, Visa<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Visa, Debit Card">Master Card, Visa, Debit Card<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, PayPal">Master Card, PayPal<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Visa, PayPal">Visa, PayPal<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Money Order">PayPal, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Personal Check, Money Order">Personal Check, Money Order<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Personal Check, Money Order">PayPal, Personal Check, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Money Order">Master Card, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Master Card, Money Order">PayPal, Master Card, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Visa, Money Order">Master Card, Visa, Money Order<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master, Visa, Debit, Money order">Master, Visa, Debit, Money order<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Master, Visa, Debit, Money order">PayPal, Master, Visa, Debit, Money order<br>------>
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="N/A">N/A<br>------>
</TD></TR>

<TR><TD VALIGN=TOP><B>Shipping Cost:<BR></B><br>Who will pay the shipping cost of this auction item.</TD>
<TD><b>Select One</b><BR>
<!-----<INPUT NAME=SHIPPING TYPE=Radio VALUE="See Item Description" checked>See Item Description<br>---->
<!-----<INPUT NAME=SHIPPING TYPE=Radio VALUE="Buyer Pays">Buyer Pays<br>---->
<INPUT NAME=SHIPPING TYPE=Radio VALUE="No Shipping Required">No Shipping Required<br>
<!-----<INPUT NAME=SHIPPING TYPE=Radio VALUE="Buyer & Seller Splits">Buyer & Seller Splits<br>----->
<!-----<INPUT NAME=SHIPPING TYPE=Radio VALUE="Pick-Up Only">Pick-Up Only<br>---->
<INPUT NAME=SHIPPING TYPE=Radio VALUE="Pick-Up or Buyer Pays Shipping">Pick-Up or Buyer Pays Shipping<br>
</TD></TR>

<TR><TD VALIGN=TOP><B>Condition:<BR></B><br>Desc the condition of the item your selling at auction.</TD>
<TD><b>Select One</b><BR>
<INPUT NAME=CONDITION TYPE=Radio VALUE="See Item Description" checked>See Item Description<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="New">New<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Great">Great<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Good">Good<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Fair">Fair<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Repairable">Repairable<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="ASIS">ASIS<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="N/A">N/A<br>
</TD>
</TR></TR>
</TABLE>
EOF

if ($config{'allowcounter'} eq "yes") {
print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2><b>This is <font color=red>optional</font>, Will add a counter to your page to monitor your auction page visits.</font></b></TH></TR>

<TR><TD VALIGN=TOP WIDTH=50%><B>Auction Item page view counter:</b><BR>
Counter Fee: <b>$config{'currencytype'}$config{'counterfee2'}</b></TD>
<TD WIDTH=50%><INPUT NAME=USECOUNTER TYPE=Radio VALUE="No" checked>No<br>
<INPUT NAME=USECOUNTER TYPE=Radio VALUE="Yes">Yes</TD>
</TR>
</TABLE>
EOF
}

print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2><b>Sell your auction item with these added options\!</b></font></TH></TR>
<TR><TD COLSPAN=2 VALIGN=TOP><b><font face=arial size=2>The next items are <font color=red>optional</font>, but will make your auction item stand out among others, and will increase the number of bids. <font color=red>These options do have a small fee, and are charged to your account even if you do not sell your item!</font></b></TD></TR>

<TR><TD VALIGN=TOP><B>Attention Grabbers:<BR></B>Really make your auction stand out from the crowd with these special icons for only  <b>$config{'currencytype'}$config{'grabberfee2'}</b></font></TD>
<TD><table BGCOLOR=$config{'colortablebody'} BORDER=2 CELLSPACING=0 CELLPADDING=3 COLS=7 WIDTH=\"350\" >
<INPUT NAME=GRABBER TYPE=Radio VALUE="NONE" checked><b>None</b>
<br>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab1"><IMG SRC=$config{'grabber1'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab2"><IMG SRC=$config{'grabber2'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab3"><IMG SRC=$config{'grabber3'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab4"><IMG SRC=$config{'grabber4'}></td>
</tr>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab5"><IMG SRC=$config{'grabber5'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab6"><IMG SRC=$config{'grabber6'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab7"><IMG SRC=$config{'grabber7'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab8"><IMG SRC=$config{'grabber8'}></td>
</tr>
</table>
EOF

 if ($config{'backgroungmusic'} eq "yes") {
                print <<"EOF";
<TR><TD VALIGN=TOP><B>Auction Back Ground Music:<BR></B>Really make your auction stand out from the crowd with back ground music for only  <b>$config{'currencytype'}$config{'musicfee2'}</b></font></TD>
<TD><table BGCOLOR=$config{'colortablebody'} BORDER=2 CELLSPACING=0 CELLPADDING=3 COLS=7 WIDTH=\"350\" >
<INPUT NAME=MUSIC TYPE=Radio VALUE="NONE" checked><b>None</b>
<br>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music1">$config{'musictitle1'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music2">$config{'musictitle2'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music3">$config{'musictitle3'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music4">$config{'musictitle4'}</td>
</tr>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music5">$config{'musictitle5'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music6">$config{'musictitle6'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music7">$config{'musictitle7'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music8">$config{'musictitle8'}</td>
</tr>
</table>
EOF
}

print <<"EOF";
<TR><TD VALIGN=TOP><B>Full Featured Gallery Listed On The Main Home Page (Must Have a image linked or uploaded):<BR></B>cost: <b>$config{'currencytype'}$config{'galleryfee2'}</b><br>Will be viewed by anyone entering the auction website.<br></TD>
<TD><b>Select One</b><BR>
<INPUT NAME=GALLERY TYPE=Radio VALUE="No" checked>No<br>
<INPUT NAME=GALLERY TYPE=Radio VALUE="Yes">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Full Featured Listed On The Main Home Page:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_full_fee2'}</b><br>Will be viewed by anyone entering the auction website.<br></TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_FP TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_FP TYPE=Radio VALUE="YES">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Category featured list on category page:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_cat_fee2'}</b><br>Will be listed in special feature section of whatever category you place it in.<br></TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_CP TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_CP TYPE=Radio VALUE="YES">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Highlighted $config{'boldbackground'} background title:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_green_fee2'}</b><br>This is a real nice attention grabber.</TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_YT TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_YT TYPE=Radio VALUE="YES">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Bold font title:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_bold_fee2'}</b><br>The famous<b> BOLD TITLE!</b> This is a real nice attention grabber.</TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_BF TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_BF TYPE=Radio VALUE="YES">Yes
</TD></TR>
</TABLE>
EOF

        if ($config{'dutchauctions'} eq "yes") {
                print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2><b>Auction Type Standard or Fixed Price Dutch Auction</b></font></TD></TR>
<TR><TD WIDTH=50% VALIGN=TOP><B>Dutch:<BR></B><br>Select this if you have more than one of the same item for auction.<br><font color="red"><b>price does not change on dutch auction items</b></font></TD>
<TD WIDTH=50%><b>Select One</b><BR>
<INPUT NAME=DUTCH TYPE=Radio VALUE="no" checked>no<br>
<INPUT NAME=DUTCH TYPE=Radio VALUE="yes">yes
</TD></TR>
<TR><TD WIDTH=50% VALIGN=TOP>Quantity if yes dutch selected:</TD>
<TD WIDTH=50%>Quantity <INPUT NAME=QTY TYPE=TEXT SIZE=7 MAXLENGTH=6 VALUE=1>
</TD></TR>
</TABLE>
EOF
          }   

        if ($config{'currencylayout'} eq 'no') {       
print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TD VALIGN=TOP><B>Your Starting Bid, or if this is a Dutch Auction then this is the fixed selling price:</B><br><b>do not include the $config{'currencytype'} sign or a ,</b></TD><TD>$config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=$startbid2>
<TR><TD VALIGN=TOP><B>Your Reserve Price:<BR></B>You are not obligated to sell below this price. Leave 0 for no reserve.<br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=RESERVE TYPE=TEXT SIZE=7 VALUE=$reserve2>
<TR><TD VALIGN=TOP><B>Bid Increment:</B><br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=INC TYPE=TEXT SIZE=7 VALUE=$inc2></TD></TR>
EOF

if ($config{'buyitnow'} eq 'yes') {
print <<"EOF";
<TR><TD VALIGN=TOP><B>Buy It Price:</B><br><b>With this option a buyer can buy your item until the bidding starts for the price you set here</b><br><font color="red"><b>For No (Buy It) feature leave this 0</b><br><b>If DUTCH auction leave this 0</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=BUYIT TYPE=TEXT SIZE=7 VALUE=$buyit2></TD></TR>
EOF
}

print <<"EOF";
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><b>PLEASE NOTE:</b> By placing an item up for bid you are making a <b>CONTRACT</b> between you and the buyer. Once you place an item, you may not retract it and you must sell it for the highest bid. In other words, if you don't want to sell it, don't place it up for bid! <A HREF="$ENV{'SCRIPT_NAME'}?action=agree"> Registration</A> is required to sell an Item.</TD></TR>
<TR><TD VALIGN=TOP><B>Your Username:<BR></B>Used to track your item</TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD VALIGN=TOP><B>Your Password:<BR></B>Must be valid</TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TABLE>
EOF
        }
        else {       
print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TD VALIGN=TOP><B>Your Starting Bid, or if this is a Dutch Auction then this is the fixed selling price:</B><br><b>do not include the $config{'currencytype'} sign or a ,</b></TD><TD>$config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=$startbid1>
<TR><TD VALIGN=TOP><B>Your Reserve Price:<BR></B>You are not obligated to sell below this price. Leave 0.00 for no reserve.<br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=RESERVE TYPE=TEXT SIZE=7 VALUE=$reserve1>
<TR><TD VALIGN=TOP><B>Bid Increment:</B><br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=INC TYPE=TEXT SIZE=7 VALUE=$inc1></TD></TR>
EOF

if ($config{'buyitnow'} eq 'yes') {
print <<"EOF";
<TR><TD VALIGN=TOP><B>Buy It Price:</B><br><b>With this option a buyer can buy your item until the bidding starts for the price you set here</b><br><font color="red"><b>For No (Buy It) feature leave this 0.00</b><br><b>If DUTCH auction leave this 0.00</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=BUYIT TYPE=TEXT SIZE=7 VALUE=$buyit1></TD></TR>
EOF
}
print <<"EOF";
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><b>PLEASE NOTE:</b> By placing an item up for bid you are making a <b>CONTRACT</b> between you and the buyer. Once you place an item, you may not retract it and you must sell it for the highest bid. In other words, if you don't want to sell it, don't place it up for bid! <A HREF="$ENV{'SCRIPT_NAME'}?action=agree"> Registration</A> is required to sell an Item.</TD></TR>
<TR><TD VALIGN=TOP><B>Your Username:<BR></B>Used to track your item</TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD VALIGN=TOP><B>Your Password:<BR></B>Must be valid</TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TABLE>
EOF
        }
        print <<"EOF";
<CENTER><h3>Press the Preview Button Below to Continue.</h3>
<INPUT TYPE=SUBMIT VALUE=Preview><p></CENTER>
EOF
}


#-#############################################
# Sub: Add New Item
# This allows a new item to be put up for sale

sub new2 {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }         
        
        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
             $inc = "1.00"; # default increment
             $title =~ s/\"//g;  # quotes cause problems for a text input field  

$config{'listingfee2'} = "FREE"  if ($config{'listingfee2'} eq "0.00");
$config{'feat_full_fee2'} = "FREE"  if ($config{'feat_full_fee2'} eq "0.00");
$config{'feat_cat_fee2'} = "FREE"  if ($config{'feat_cat_fee2'} eq "0.00");
$config{'feat_green_fee2'} = "FREE"  if ($config{'feat_green_fee2'} eq "0.00");
$config{'feat_bold_fee2'} = "FREE"  if ($config{'feat_bold_fee2'} eq "0.00");
$config{'grabberfee2'} = "FREE"  if ($config{'grabberfee2'} eq "0.00");
$config{'galleryfee2'} = "FREE"  if ($config{'galleryfee2'} eq "0.00");
$config{'counterfee2'} = "FREE"  if ($config{'counterfee2'} eq "0.00");
$config{'musicfee2'} = "FREE"  if ($config{'musicfee2'} eq "0.00");
$config{'uploadimagefee2'} = "FREE"  if ($config{'uploadimagefee2'} eq "0.00");

        print <<"EOF";
<p></p>
EOF

if ($config{'postpercentage'} eq 'on') {
        print <<"EOF";
<table align="center" border=1 width="75%" bgcolor="#ffffff">
<tr>
<td WIDTH="46%">Posting percentage commissions based of the starting bid.</td>
<td ALIGN=CENTER WIDTH="54%">0.00 to 150.99 = 2.0%<br>151.00 to 250.99 = 1.80%<br>251.00 to 500.99 = 1.5%<br>501.00 to 999999.99 = 1.3%</td>
</tr>
</table>
EOF
}

if ($config{'percentageclose'} eq 'on') {
        print <<"EOF";
<table align="center" border=1 width="75%" bgcolor="#ffffff">
<tr>
<td WIDTH="46%">Closing percentage commissions based of the winning bid. no commission if not sold!</td>
<td ALIGN=CENTER WIDTH="54%">0.00 to 150.99 = 2.0%<br>151.00 to 250.99 = 1.80%<br>251.00 to 500.99 = 1.5%<br>501.00 to 999999.99 = 1.3%</td>
</tr>
</table>
EOF
}
        
        print <<"EOF";
<table align="center" border=1 width="75%" bgcolor="#ffffff">
<tr>
<td WIDTH="46%">Auction Insertion Fee</td>
<td ALIGN=CENTER WIDTH="54%">$config{'listingfee2'}</td>
</tr>
</table>
EOF

        print <<"EOF";        
<p>
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<INPUT TYPE=HIDDEN NAME=action VALUE=procnew>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><H2>Post A New Item</H2></TH></TR>

<TR><TD VALIGN=TOP><B>Title/Item Name:<BR></B>No HTML</TD><TD><INPUT NAME=TITLE TYPE=TEXT SIZE=55 MAXLENGTH=55></TD></TR>

<TR><TD VALIGN=TOP><B>Category:<BR></B>Select One</TD><TD><SELECT NAME=CATEGORY>
<OPTION SELECTED></OPTION>
EOF
       my($key, $disppath, $thispath, @this);
	foreach $key (keys %category) {
		$disppath = '';
		$thispath = $category{$key};
		while($thispath =~ s/^<!--([^\>]*)-->//){
			if($supercat{$1} ne ''){
			$disppath .= "$supercat{$1} -> ";
			}
		}
		push(@this, ["$disppath$thispath", $disppath, "<OPTION VALUE=\"$key\">$disppath$thispath</OPTION>\n"]);
	}
	foreach $key (sort {lc $a->[0] cmp lc $b->[0]} @this){
		if($key->[1] ne $thispath){
			$thispath=$key->[1];
			print "<option></option>\n"; # Insert a blank line between Cats
		}
		print $key->[2];
	}    

print <<"EOF";   
</SELECT></TD></TR>

<TR><TD VALIGN=TOP bgcolor=$config{'colortablebody'}><font face=arial size=2><B>Image Uploaded :</B></TD>
<TD>
<INPUT NAME=UPIMAGE1 TYPE=HIDDEN VALUE=\"$form{'UPIMAGE1'}\">
<INPUT NAME=UPIMAGE2 TYPE=HIDDEN VALUE=\"$form{'UPIMAGE2'}\">
<INPUT NAME=UPIMAGE3 TYPE=HIDDEN VALUE=\"$form{'UPIMAGE3'}\">
<INPUT NAME=UPIMAGE4 TYPE=HIDDEN VALUE=\"$form{'UPIMAGE4'}\">
EOF
if ($form{'UPIMAGE1'}) {
print <<"EOF";
Image 1 Uploaded:<b> YES: $form{'UPIMAGE1'}</b><br>
EOF
}
else {
print <<"EOF";
Image 1:<b> NO Image Selected</b><br>
EOF
}
if ($form{'UPIMAGE2'}) {
print <<"EOF";
image 2 Uploaded: <b> YES: $form{'UPIMAGE2'}</b><br>
EOF
}
else {
print <<"EOF";
Image 2:<b> NO Image Selected</b><br>
EOF
}
if ($form{'UPIMAGE3'}) {
print <<"EOF";
image 3 Uploaded: <b> YES: $form{'UPIMAGE3'}</b><br>
EOF
}
else {
print <<"EOF";
Image 3:<b> NO Image Selected</b><br>
EOF
}
if ($form{'UPIMAGE4'}) {
print <<"EOF";
image 4 Uploaded: <b> YES: $form{'UPIMAGE4'}</b><br>
EOF
}
else {
print <<"EOF";
Image 4:<b> NO Image Selected</b><br>
EOF
}
print <<"EOF";
</TD>
</TR>

<TR><TD VALIGN=TOP><B>Days Until Close:<BR></B>1-$config{'listingdays'}</TD><TD><INPUT NAME=DAYS TYPE=TEXT SIZE=2 MAXLENGTH=2 VALUE=$config{'listingdays'}></TD></TR>
<tr>
  <TD VALIGN=TOP><b>Auto Relist:</b><br>
    Optional, this will allow you to relist your item up to 2 times if not sold equal to the same runing days as you entered above.
  </td>
  <td><b>Number of times to relist item:</b><br>
<INPUT NAME=RELIST TYPE=Radio VALUE="0" checked>None<br>
<INPUT NAME=RELIST TYPE=Radio VALUE="1">1<br>
<INPUT NAME=RELIST TYPE=Radio VALUE="2">2<br>
</td></tr>

<TR><TD VALIGN=TOP><B>Description Title Color :<BR></B>This is the font color you would like the decsription title to be.</TD>
<td><INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#000000>" checked><font color=000000>Black</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#0000FF>"><font color=0000FF>Blue</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#EE0000>"><font color=EE0000>Red</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#00AA00>"><font color=00AA00>Green</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#FF9900>"><font color=FF9900>Orange</font><br>
<INPUT NAME=DESCTITCOLOR TYPE=Radio VALUE="<FONT color=#663300>"><font color=663300>Brown</font><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description Title Size :<BR></B>This is the font size you would like the description title to be.</TD>
<td><INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=4>" checked><FONT size=4>4</FONT><br>
<INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=5>"><FONT size=5>5</FONT><br>
<INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=6>"><FONT size=6>6</FONT><br>
<INPUT NAME=DESCTITSIZE TYPE=Radio VALUE="<FONT size=7>"><FONT size=7>7</FONT><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description Title:<BR></B>This is the description title of your item.</TD><TD><TEXTAREA NAME=DESCTIT ROWS=5 COLS=55 WRAP=vertical>$desctit</TEXTAREA></TD></TR>

<TR><TD VALIGN=TOP><B>Description Color :<BR></B>This is the font color you would like the decsription to be.</TD>
<td><INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#000000>" checked><font color=000000>Black</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#0000FF>"><font color=0000FF>Blue</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#EE0000>"><font color=EE0000>Red</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#00AA00>"><font color=00AA00>Green</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#FF9900>"><font color=FF9900>Orange</font><br>
<INPUT NAME=DESCCOLOR TYPE=Radio VALUE="<FONT color=#663300>"><font color=663300>Brown</font><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description Size :<BR></B>This is the font size you would like the description to be.</TD>
<td><INPUT NAME=DESCSIZE TYPE=Radio VALUE="<FONT size=4>" checked><FONT size=4>4</FONT><br>
<INPUT NAME=DESCSIZE TYPE=Radio VALUE="<FONT size=5>"><FONT size=5>5</FONT><br>
<INPUT NAME=DESCSIZE TYPE=Radio VALUE="<FONT size=6>"><FONT size=6>6</FONT><br></td>
</TR>

<TR><TD VALIGN=TOP><B>Description:<BR></B>May include HTML with no Java Scripting, as Java Scripts will be removed. - The description should include all information the buyer should know including the shipping carrier and shipping fees.</TD><TD><TEXTAREA NAME=DESC ROWS=5 COLS=55 WRAP=vertical></TEXTAREA></TD></TR>
</TABLE>

<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2>Special Arrangements</b></font></TH></TR>
<TR><TD VALIGN=TOP><B>Payment Type:<BR></B><br>Select the type of payments you will accept.</TD>
<TD><b>Select One</b><BR>
<!---<INPUT NAME=PAYMENT TYPE=Radio VALUE="See item description for payment methods accepted." checked>See item description for payment methods accepted.<br>----->
<INPUT NAME=PAYMENT TYPE=Radio VALUE="Pay Pal, Master Card, Visa, Discover, Debit Card, or Personal Check">Pay Pal, Master Card, Visa, Discover, Debit Card, or Personal Check<br>
<!---<INPUT NAME=PAYMENT TYPE=Radio VALUE="Visa">Visa<br>---->
<!---<INPUT NAME=PAYMENT TYPE=Radio VALUE="Debit Card">Debit Card<br>--->
<!---<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal">PayPal<br>---->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Money Order">Money Order<br>---->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Personal Check">Personal Check<br>---->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Visa">Master Card, Visa<br>---->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Visa, Debit Card">Master Card, Visa, Debit Card<br>----->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, PayPal">Master Card, PayPal<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Visa, PayPal">Visa, PayPal<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Money Order">PayPal, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Personal Check, Money Order">Personal Check, Money Order<br>----->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Personal Check, Money Order">PayPal, Personal Check, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Money Order">Master Card, Money Order<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Master Card, Money Order">PayPal, Master Card, Money Order<br>----->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master Card, Visa, Money Order">Master Card, Visa, Money Order<br>---->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="Master, Visa, Debit, Money order">Master, Visa, Debit, Money order<br>---->
<!-----<INPUT NAME=PAYMENT TYPE=Radio VALUE="PayPal, Master, Visa, Debit, Money order">PayPal, Master, Visa, Debit, Money order<br>----->
<!----<INPUT NAME=PAYMENT TYPE=Radio VALUE="N/A">N/A<br>----->
</TD></TR>

<TR><TD VALIGN=TOP><B>Shipping Cost:<BR></B><br>Who will pay the shipping cost of this auction item.</TD>
<TD><b>Select One</b><BR>
<!-----<INPUT NAME=SHIPPING TYPE=Radio VALUE="See Item Description" checked>See Item Description<br>----->
<!-----<INPUT NAME=SHIPPING TYPE=Radio VALUE="Buyer Pays">Buyer Pays<br>---->
<INPUT NAME=SHIPPING TYPE=Radio VALUE="No Shipping Required">No Shipping Required<br>
<!----<INPUT NAME=SHIPPING TYPE=Radio VALUE="Buyer & Seller Splits">Buyer & Seller Splits<br>----->
<!----<INPUT NAME=SHIPPING TYPE=Radio VALUE="Pick-Up Only">Pick-Up Only<br>--->
<INPUT NAME=SHIPPING TYPE=Radio VALUE="Pick-Up or Buyer Pays Shipping">Pick-Up or Buyer Pays Shipping<br>
</TD></TR>

<TR><TD VALIGN=TOP><B>Condition:<BR></B><br>Desc the condition of the item your selling at auction.</TD>
<TD><b>Select One</b><BR>
<INPUT NAME=CONDITION TYPE=Radio VALUE="See Item Description" checked>See Item Description<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="New">New<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Great">Great<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Good">Good<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Fair">Fair<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="Repairable">Repairable<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="ASIS">ASIS<br>
<INPUT NAME=CONDITION TYPE=Radio VALUE="N/A">N/A<br>
</TD>
</TR></TR>
</TABLE>
EOF

if ($config{'allowcounter'} eq "yes") {
print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2><b>This is <font color=red>optional</font>, Will add a counter to your page to monitor your auction page visits.</font></b></TH></TR>

<TR><TD VALIGN=TOP WIDTH=50%><B>Auction Item page view counter:</b><BR>
Counter Fee: <b>$config{'currencytype'}$config{'counterfee2'}</b></TD>
<TD WIDTH=50%><INPUT NAME=USECOUNTER TYPE=Radio VALUE="No" checked>No<br>
<INPUT NAME=USECOUNTER TYPE=Radio VALUE="Yes">Yes</TD>
</TR>
</TABLE>
EOF
}

print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TH COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2><b>Sell your auction item with these added options\!</b></font></TH></TR>
<TR><TD COLSPAN=2 VALIGN=TOP><b><font face=arial size=2>The next items are <font color=red>optional</font>, but will make your auction item stand out among others, and will increase the number of bids. <font color=red>These options do have a small fee, and are charged to your account even if you do not sell your item!</font></b></TD></TR>

<TR><TD VALIGN=TOP><B>Attention Grabbers:<BR></B>Really make your auction stand out from the crowd with these special icons for only  <b>$config{'currencytype'}$config{'grabberfee2'}</b></font></TD>
<TD><table BGCOLOR=$config{'colortablebody'} BORDER=2 CELLSPACING=0 CELLPADDING=3 COLS=7 WIDTH=\"350\" >
<INPUT NAME=GRABBER TYPE=Radio VALUE="NONE" checked><b>None</b>
<br>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab1"><IMG SRC=$config{'grabber1'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab2"><IMG SRC=$config{'grabber2'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab3"><IMG SRC=$config{'grabber3'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab4"><IMG SRC=$config{'grabber4'}></td>
</tr>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab5"><IMG SRC=$config{'grabber5'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab6"><IMG SRC=$config{'grabber6'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab7"><IMG SRC=$config{'grabber7'}></td>
<td><INPUT NAME=GRABBER TYPE=Radio VALUE="grab8"><IMG SRC=$config{'grabber8'}></td>
</tr>
</table>
EOF

 if ($config{'backgroungmusic'} eq "yes") {
                print <<"EOF";
<TR><TD VALIGN=TOP><B>Auction Back Ground Music:<BR></B>Really make your auction stand out from the crowd with back ground music for only  <b>$config{'currencytype'}$config{'musicfee2'}</b></font></TD>
<TD><table BGCOLOR=$config{'colortablebody'} BORDER=2 CELLSPACING=0 CELLPADDING=3 COLS=7 WIDTH=\"350\" >
<INPUT NAME=MUSIC TYPE=Radio VALUE="NONE" checked><b>None</b>
<br>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music1">$config{'musictitle1'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music2">$config{'musictitle2'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music3">$config{'musictitle3'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music4">$config{'musictitle4'}</td>
</tr>
<tr ALIGN=CENTER VALIGN=CENTER>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music5">$config{'musictitle5'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music6">$config{'musictitle6'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music7">$config{'musictitle7'}</td>
<td><INPUT NAME=MUSIC TYPE=Radio VALUE="music8">$config{'musictitle8'}</td>
</tr>
</table>
EOF
}

print <<"EOF";
<TR><TD VALIGN=TOP><B>Full Featured Gallery Listed On The Main Home Page (Must Have a image linked or uploaded):<BR></B>cost: <b>$config{'currencytype'}$config{'galleryfee2'}</b><br>Will be viewed by anyone entering the auction website.<br></TD>
<TD><b>Select One</b><BR>
<INPUT NAME=GALLERY TYPE=Radio VALUE="No" checked>No<br>
<INPUT NAME=GALLERY TYPE=Radio VALUE="Yes">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Full Featured Listed On The Main Home Page:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_full_fee2'}</b><br>Will be viewed by anyone entering the auction website.<br></TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_FP TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_FP TYPE=Radio VALUE="YES">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Category featured list on category page:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_cat_fee2'}</b><br>Will be listed in special feature section of whatever category you place it in.<br></TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_CP TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_CP TYPE=Radio VALUE="YES">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Highlighted $config{'boldbackground'} background title:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_green_fee2'}</b><br>This is a real nice attention grabber.</TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_YT TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_YT TYPE=Radio VALUE="YES">Yes
</TD></TR>
<TR><TD VALIGN=TOP><B>Bold font title:<BR></B>cost: <b>$config{'currencytype'}$config{'feat_bold_fee2'}</b><br>The famous<b> BOLD TITLE!</b> This is a real nice attention grabber.</TD>
<TD><b>Select One</b><BR>
<INPUT NAME=FEAT_BF TYPE=Radio VALUE="NO" checked>No<br>
<INPUT NAME=FEAT_BF TYPE=Radio VALUE="YES">Yes
</TD></TR>
</TABLE>
EOF

        if ($config{'dutchauctions'} eq "yes") {
                print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><font face=arial size=2><b>Auction Type Standard or Fixed Price Dutch Auction</b></font></TD></TR>
<TR><TD WIDTH=50% VALIGN=TOP><B>Dutch:<BR></B><br>Select this if you have more than one of the same item for auction.<br><font color="red"><b>price does not change on dutch auction items</b></font></TD>
<TD WIDTH=50%><b>Select One</b><BR>
<INPUT NAME=DUTCH TYPE=Radio VALUE="no" checked>no<br>
<INPUT NAME=DUTCH TYPE=Radio VALUE="yes">yes
</TD></TR>
<TR><TD WIDTH=50% VALIGN=TOP>Quantity if yes dutch selected:</TD>
<TD WIDTH=50%>Quantity <INPUT NAME=QTY TYPE=TEXT SIZE=7 MAXLENGTH=6 VALUE=1>
</TD></TR>
</TABLE>
EOF
          }   

        if ($config{'currencylayout'} eq 'no') {
print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TD VALIGN=TOP><B>Your Starting Bid, or if this is a Dutch Auction then this is the fixed selling price:</B><br><b>do not include the $config{'currencytype'} sign or a ,</b></TD><TD>$config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=0>
<TR><TD VALIGN=TOP><B>Your Reserve Price:<BR></B>You are not obligated to sell below this price. Leave 0 for no reserve.<br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=RESERVE TYPE=TEXT SIZE=7 VALUE=0>
<TR><TD VALIGN=TOP><B>Bid Increment:</B><br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=INC TYPE=TEXT SIZE=7 VALUE=1></TD></TR>
EOF

if ($config{'buyitnow'} eq 'yes') {
print <<"EOF";
<TR><TD VALIGN=TOP><B>Buy It Price:</B><br><b>With this option a buyer can buy your item until the bidding starts for the price you set here</b><br><font color="red"><b>For No (Buy It) feature leave this 0</b><br><b>If DUTCH auction leave this 0</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=BUYIT TYPE=TEXT SIZE=7 VALUE=0></TD></TR>
EOF
}

print <<"EOF";
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><b>PLEASE NOTE:</b> By placing an item up for bid you are making a <b>CONTRACT</b> between you and the buyer. Once you place an item, you may not retract it and you must sell it for the highest bid. In other words, if you don't want to sell it, don't place it up for bid! <A HREF="$ENV{'SCRIPT_NAME'}?action=agree"> Registration</A> is required to sell an Item.</TD></TR>
<TR><TD VALIGN=TOP><B>Your Username:<BR></B>Used to track your item</TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD VALIGN=TOP><B>Your Password:<BR></B>Must be valid</TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TABLE>
EOF
        }
        else {       
print <<"EOF";
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<TR><TD VALIGN=TOP><B>Your Starting Bid, or if this is a Dutch Auction then this is the fixed selling price:</B><br><b>do not include the $config{'currencytype'} sign or a ,</b></TD><TD>$config{'currencytype'}<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=0.00>
<TR><TD VALIGN=TOP><B>Your Reserve Price:<BR></B>You are not obligated to sell below this price. Leave 0.00 for no reserve.<br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=RESERVE TYPE=TEXT SIZE=7 VALUE=0.00>
<TR><TD VALIGN=TOP><B>Bid Increment:</B><br><b>do not include the $config{'currencytype'} sign</b><br><font color="red"><b>This has no effect on Dutch Auctions</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=INC TYPE=TEXT SIZE=7 VALUE=1.00></TD></TR>
EOF

if ($config{'buyitnow'} eq 'yes') {
print <<"EOF";
<TR><TD VALIGN=TOP><B>Buy It Price:</B><br><b>With this option a buyer can buy your item until the bidding starts for the price you set here</b><br><font color="red"><b>For No (Buy It) feature leave this 0.00</b><br><b>If DUTCH auction leave this 0.00</b></font></TD><TD>$config{'currencytype'}<INPUT NAME=BUYIT TYPE=TEXT SIZE=7 VALUE=0.00></TD></TR>
EOF
}
print <<"EOF";
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}><b>PLEASE NOTE:</b> By placing an item up for bid you are making a <b>CONTRACT</b> between you and the buyer. Once you place an item, you may not retract it and you must sell it for the highest bid. In other words, if you don't want to sell it, don't place it up for bid! <A HREF="$ENV{'SCRIPT_NAME'}?action=agree"> Registration</A> is required to sell an Item.</TD></TR>
<TR><TD VALIGN=TOP><B>Your Username:<BR></B>Used to track your item</TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD VALIGN=TOP><B>Your Password:<BR></B>Must be valid</TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TABLE>
EOF
        }
        print <<"EOF";
<CENTER><h3>Press the Preview Button Below to Continue.</h3>
<INPUT TYPE=SUBMIT VALUE=Preview><p></CENTER>
EOF
}

#-#############################################
# Sub: Process New Item
# This processes new item to be put up for
# sale from a posted form

sub procnew {

        my ($password, @userbids, $bid);

                $form{'ALIAS'} = lc($form{'ALIAS'});
                $form{'ALIAS'} = ucfirst($form{'ALIAS'});               
        
        if ($config{'regdir'} ne "") {
                &oops('Your alias could not be found!') unless ($password, $form{'EMAIL'},
$form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE'}, $form{'IP'}, $form{'REFERRAL'}, $form{'REFNAME'}, @userbids) = &read_reg_file($form{'ALIAS'});
                &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));
        }  
        if ($config{'AccountStatus'} eq "on") {
        &Account_Status($form{'ALIAS'});
        }

        &oops('You must enter a title for this item, you left this blank.') unless ($form{'TITLE'} ne "");
        &oops('You must have an item title that is less than 56 characters.') unless (length($form{'TITLE'}) < 56);        
        &oops('You must select a valid category.') unless (-d "$config{'basepath'}$form{'CATEGORY'}" and $category{$form{'CATEGORY'}});
        &oops('You must enter the number of days your auction should run.') unless (($form{'DAYS'} > 0) and ($form{'DAYS'} < $config{'listingdays'} + 1));
        &oops('You must enter an item description.') unless ($form{'DESC'});
        &oops('You must enter an alias to track your item.') unless ($form{'ALIAS'});
        &oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);

    if ($config{'currencylayout'} eq 'no') {
        &oops('You must enter a valid starting bid.') unless (($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/) and ($form{'BID'} >= 01));
        &oops('You must enter a valid bid increment.') unless (($form{'INC'} =~ /^(\d+\.?\d*|\.\d+)$/) and ($form{'INC'} >= 01) or ($form{'DUTCH'} eq "yes"));
        &oops('Your reserve price must be greater than your starting bid price or must be 0 for no reserve.') unless (($form{'RESERVE'} eq '0') or ($form{'RESERVE'} > $form{'BID'}) or ($form{'DUTCH'} eq "yes"));
        &oops('Your BuyItNow price must be equal or greater than your Reserve price or must be 0 for no BuyItNow.') unless (($form{'BUYIT'} eq '0') or ($form{'BUYIT'} >= $form{'RESERVE'}) or ($config{'buyitnow'} eq "no") or ($form{'DUTCH'} eq "yes"));
        &oops('Your BuyNow price must be greater than your Starting bid or must be 0 for no BuyItNow.') unless (($form{'BUYIT'} eq '0') or ($form{'BUYIT'} > $form{'BID'}) or ($config{'buyitnow'} eq "no") or ($form{'DUTCH'} eq "yes"));
        &oops('This is a dutch auction and may not contain a reserve price, the reserve field must be 0 for no reserve.') if (($form{'DUTCH'} eq "yes") && ($form{'RESERVE'} > "0"));
        &oops('This is a dutch auction and may not contain a BuyNow price, the BuyNow field must be 0 for no BuyNow price.') if (($form{'DUTCH'} eq "yes") && ($form{'BUYIT'} > '0'));
        }
    else {
        &oops('You must enter a valid starting bid.') unless (($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/) and ($form{'BID'} >= .01));
        &oops('You must enter a valid bid increment.') unless (($form{'INC'} =~ /^(\d+\.?\d*|\.\d+)$/) and ($form{'INC'} >= .01) or ($form{'DUTCH'} eq "yes"));      
        &oops('You must enter a valid reserver price.') unless (($form{'RESERVE'} =~ /^(\d+\.?\d*|\.\d+)$/));
        &oops('You must enter a valid buyitnow price.') unless (($form{'BUYIT'} =~ /^(\d+\.?\d*|\.\d+)$/) or ($config{'buyitnow'} eq "no"));
        &oops('Your reserve price must be greater than your starting bid price or must be 0.00 for no reserve.') unless (($form{'RESERVE'} eq '0.00') or ($form{'RESERVE'} > $form{'BID'}) or ($form{'DUTCH'} eq "yes"));
        &oops('Your BuyItNow price must be equal or greater than your Reserve price or must be 0.00 for no BuyItNow.') unless (($form{'BUYIT'} eq '0.00') or ($form{'BUYIT'} >= $form{'RESERVE'}) or ($config{'buyitnow'} eq "no") or ($form{'DUTCH'} eq "yes"));
        &oops('Your BuyNow price must be greater than your Starting bid or must be 0.00 for no BuyItNow.') unless (($form{'BUYIT'} eq '0.00') or ($form{'BUYIT'} > $form{'BID'}) or ($config{'buyitnow'} eq "no") or ($form{'DUTCH'} eq "yes"));
        &oops('This is a dutch auction and may not contain a reserve price, the reserve field must be 0.00 for no reserve.') if (($form{'DUTCH'} eq "yes") && ($form{'RESERVE'} > "0.00"));
        &oops('This is a dutch auction and may not contain a BuyNow price, the BuyNow field must be 0.00 for no BuyNow price.') if (($form{'DUTCH'} eq "yes") && ($form{'BUYIT'} > '0.00'));
        }

        &oops('You you have entered more that 1 item in the Quantity field to do so you must select yes to dutch.') if (($form{'DUTCH'} eq "no") && ($form{'QTY'} > "1"));
      
        ### Security Check and Remove possible violations  ############### 
        #$form{'TITLE'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go; # remove shell commands
        $form{'TITLE'} =~ s/<!(?:--[\s\S]*?--\s*)?>\s*//g; # remove comment tags
        $form{'TITLE'} =~s/[\~\^]//g; 
        $form{'TITLE'} =~ s/~!/ ~!/g; 
        $form{'TITLE'} =~ s/<*(javascript)[^>]+>//gi; 
        $form{'TITLE'} =~ s/<*(script)[^>]+>//gi;
        $form{'TITLE'} =~ s/<*(applet)[^>]+>//gi;
        $form{'TITLE'} =~ s/<*(embed)[^>]+>//gi; 
        $form{'TITLE'} =~ s/system\(.+//g; 
        $form{'TITLE'} =~ s/alert//g;
        $form{'TITLE'} =~ s/param//g;
        $form{'TITLE'} =~ s/hash//g;
        $form{'TITLE'} =~ s/exec//g;
        $form{'TITLE'} =~ s/grep//g;
        $form{'TITLE'} =~ s/eval//g; 
        $form{'TITLE'} =~ s/chmod//g; 
        $form{'TITLE'} =~ s/echo//g; 
       
        $form{'DESCTIT'} =~ s/<!(?:--[\s\S]*?--\s*)?>\s*//g; # remove comment tags
        $form{'DESCTIT'} =~s/[\~\^]//g; 
        $form{'DESCTIT'} =~ s/~!/ ~!/g; 
        $form{'DESCTIT'} =~ s/<*(javascript)[^>]+>//gi; 
        $form{'DESCTIT'} =~ s/<*(script)[^>]+>//gi;
        $form{'DESCTIT'} =~ s/<*(applet)[^>]+>//gi;
        $form{'DESCTIT'} =~ s/<*(embed)[^>]+>//gi; 
        $form{'DESCTIT'} =~ s/system\(.+//g; 
        $form{'DESCTIT'} =~ s/alert//g;
        $form{'DESCTIT'} =~ s/param//g;
        $form{'DESCTIT'} =~ s/hash//g;
        $form{'DESCTIT'} =~ s/exec//g;
        $form{'DESCTIT'} =~ s/grep//g;
        $form{'DESCTIT'} =~ s/eval//g; 
        $form{'DESCTIT'} =~ s/chmod//g; 
        $form{'DESCTIT'} =~ s/echo//g; 

        $form{'DESC'} =~ s/<!(?:--[\s\S]*?--\s*)?>\s*//g; # remove comment tags
        $form{'DESC'} =~s/[\~\^]//g; 
        $form{'DESC'} =~ s/~!/ ~!/g; 
        $form{'DESC'} =~ s/<*(javascript)[^>]+>//gi; 
        $form{'DESC'} =~ s/<*(script)[^>]+>//gi;
        $form{'DESC'} =~ s/<*(applet)[^>]+>//gi;
        $form{'DESC'} =~ s/<*(embed)[^>]+>//gi; 
        $form{'DESC'} =~ s/system\(.+//g; 
        $form{'DESC'} =~ s/alert//g;
        $form{'DESC'} =~ s/param//g;
        $form{'DESC'} =~ s/hash//g;
        $form{'DESC'} =~ s/exec//g;
        $form{'DESC'} =~ s/grep//g;
        $form{'DESC'} =~ s/eval//g;    
        $form{'DESC'} =~ s/chmod//g; 
        $form{'DESC'} =~ s/echo//g; 
        ### END Security Check and Remove possible violations  ###############

        $form{'INC'} = &parsebid($form{'INC'});
        $form{'RESERVE'} = &parsebid($form{'RESERVE'}); 
        $form{'INCERMENT'} = 0.00 if ($form{'DUTCH'} eq 'yes'); 
        $form{'BUYIT'} = "0.00"  if ($config{'buyitnow'} eq "no");   
        $form{'BUYIT'} = &parsebid($form{'BUYIT'});             
        $form{'DUTCH'} = "no"  if ($config{'dutchauctions'} eq "no");          
        $form{'QTY'} = "1"  if ($config{'dutchauctions'} eq "no"); 
        $form{'QTY'} = "1"  if ($form{'DUTCH'} eq "no");
        $form{'USECOUNTER'} = "no"  if ($config{'allowcounter'} eq "no"); 
        $form{'MUSIC'} = "NONE"  if ($config{'backgroungmusic'} eq "no"); 
  $form{'IMAGE1'} = "$config{'imageurl'}$form{'UPIMAGE1'}" if ($form{'UPIMAGE1'} ne "");
  $form{'IMAGE2'} = "$config{'imageurl'}$form{'UPIMAGE2'}" if ($form{'UPIMAGE2'} ne "");
  $form{'IMAGE3'} = "$config{'imageurl'}$form{'UPIMAGE3'}" if ($form{'UPIMAGE3'} ne "");
  $form{'IMAGE4'} = "$config{'imageurl'}$form{'UPIMAGE4'}" if ($form{'UPIMAGE4'} ne "");

  #$form{'IMAGE1'} =~ s/[\>\<\a\href\src\=\+]//g; 
  #$form{'IMAGE2'} =~ s/[\>\<\a\href\src\=\+]//g; 
  #$form{'IMAGE3'} =~ s/[\>\<\a\href\src\=\+]//g; 
  #$form{'IMAGE4'} =~ s/[\>\<\a\href\src\=\+]//g; 

        &oops('You must have a image to view to use the Featured Gallery') if (($form{'GALLERY'} eq "Yes") && ($form{'IMAGE1'} eq ""));
        $form{'RELISTCNT'} = "0";
#######################################
## Formatted $bid to = $X.XX
#######################################
	   $bid = &parsebid($form{'BID'});    
        &oops('You must enter your user name.') unless ($form{'ADDRESS1'});
        &oops('You must enter your street address.') unless ($form{'ADDRESS2'});
        &oops('You must enter your city, state, and zip code.') unless ($form{'ADDRESS3'});
   
        my $item_number = ($form{'DAYS'} * 86400 + time);
        $item_number = ($form{'DAYS'} * 86400 + time) until (!(-f "$config{'basepath'}$form{'CATEGORY'}/$item_number.dat"));

#        my $item_number = ($form{'DAYS'} * 86400 + time);
#        my $key;
#        foreach $key (sort keys %category) {
#            opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key #could not be opened.");
#            $item_number = ($form{'DAYS'} * 86400 + time) until (!(-f #"$config{'basepath'}$key/$item_number.dat"));
#             }

	my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));
        my $closetime = strftime "%a %b %d, %I:%M %p", gmtime($item_number + ($config{'systemtime'}* 3600 ));       
	my $timeremain = time_remain($item_number);

        if ($config{postallflag}==1){sleep 1; return}
#        else {
#        if (my $i = &double_check(@userbids)) {        
#        print "<B>You have already posted this item! You got this message if you hit your #browsers refreash or hit submit twice!<br><p><br>$form{'TITLE'} was posted under #$category{$form{'CATEGORY'}}...</B>.<BR>You may want to go to <A #HREF=\"$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$i\">the item</A> to confirm #placement.\n\n";
#        return;
#        }
#        }

        if ($form{'FROMPREVIEW'}) {
                my $key;
                foreach $key (keys %form) {
                        $form{$key} =~ s/\[greaterthansign\]/\>/gs;
                        $form{$key} =~ s/\[lessthansign\]/\</gs;
                        $form{$key} =~ s/\[quotes\]/\"/gs;
                }               

#        umask(000);  # UNIX file permission junk                
#        mkdir("$config{'basepath'}newestitem", 0777) unless (-d #"$config{'basepath'}newestitem");

#        open(NEWESTITEM,">$config{'basepath'}newestitem/newestitem.dat");
#        print (NEWESTITEM "$nowtime");
#        close(NEWESTITEM);

                ### Start Accounting Setup ###
                ## Auction Start percentage rates ##
                if ($config{'postpercentage'} eq "on") {
                &transaction_percentage_postnew($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$form{'BID'}", "$form{'RESERVE'}");
                }                
                if ($config{'listingfee'} < "-0.00") {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'listingfee'}", "New Auction Listing Fee");
                }
	        if (($form{'FEAT_FP'} eq "YES") && ($config{'feat_full_fee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'feat_full_fee'}", "Full Featured Listing Fee");
                }
                if (($form{'FEAT_CP'} eq "YES") && ($config{'feat_cat_fee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'feat_cat_fee'}", "Category Featured Listing Fee");
                }
                if (($form{'FEAT_YT'} eq "YES") && ($config{'feat_green_fee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'feat_green_fee'}", "Yellow Background Fee");
                }
                if (($form{'FEAT_BF'} eq "YES") && ($config{'feat_bold_fee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'feat_bold_fee'}", "Bold Listing Fee");
                }    
                if (($form{'GRABBER'} eq "grab1" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab2" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab3" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab4" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab5" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab6" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab7" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }
                if (($form{'GRABBER'} eq "grab8" ) && ($config{'grabberfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'grabberfee'}", "Attention Grabber Fee");
                }    
                if (($form{'MUSIC'} eq "music1" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music2" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music3" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music4" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music5" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music6" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music7" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'MUSIC'} eq "music8" ) && ($config{'musicfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'musicfee'}", "Back Ground Music Fee");
                }
                if (($form{'GALLERY'} eq "Yes" ) && ($config{'galleryfee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number $form{'TITLE'}", "$config{'galleryfee'}", "Full Featured Picture Gallery Fee");
                }   
                if (($form{'UPIMAGE1'} ne "") && ($config{'uploadimagefee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'uploadimagefee'}", "Auction image 1 upload Fee");
                }    
                if (($form{'UPIMAGE2'} ne "") && ($config{'uploadimagefee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'uploadimagefee'}", "Auction image 2 upload Fee");
                } 
                if (($form{'UPIMAGE3'} ne "") && ($config{'uploadimagefee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'uploadimagefee'}", "Auction image 3 upload Fee");
                } 
                if (($form{'UPIMAGE4'} ne "") && ($config{'uploadimagefee'} < "-0.00")) {
                &apply_transaction($form{'ALIAS'}, "#$item_number ($form{'TITLE'}", "$config{'uploadimagefee'}", "Auction image 4 upload Fee");
                }       
                if (($form{'USECOUNTER'} eq "Yes") && ($config{'counterfee'} < "-0.00")) {
                    &apply_transaction($form{'ALIAS'}, "#$item_number Page Counter Fee", "$config{'counterfee'}", "Auction Page Counter");
                }                
                ### End Accounting Setup ###

sleep 2;  # Wait x random seconds to make sure we don't get duplicate item numbers

              &oops('We are unable to post your item. It appears to be a folder server permissions problem.') unless (open (NEW, ">$config{'basepath'}$form{'CATEGORY'}/$item_number.dat"));
                               
              print NEW "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESCTITCOLOR'}\n$form{'DESCTITSIZE'}\n$form{'DESCTIT'}\n$form{'DESCCOLOR'}\n$form{'DESCSIZE'}\n$form{'DESC'}\n$form{'IMAGE1'}\n$form{'IMAGE2'}\n$form{'IMAGE3'}\n$form{'IMAGE4'}\n$form{'FEAT_FP'}\[\]$form{'FEAT_CP'}\[\]$form{'FEAT_YT'}\[\]$form{'FEAT_BF'}\n$form{'GRABBER'}\n$form{'DUTCH'}\n$form{'QTY'}\n$form{'PAYMENT'}\n$form{'CONDITION'}\n$form{'SHIPPING'}\n$form{'RELIST'}\n$form{'RELISTCNT'}\n$form{'GALLERY'}\n$form{'BUYIT'}\n$form{'MUSIC'}\n$form{'USECOUNTER'}\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]".&parsebid($form{'BID'})."\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'OQTY'}\[\]$form{'SOLDQTY'}";
                close NEW;
                if ($config{'regdir'} ne "") {
                        &oops('We could not open the registration file.  This could be a server write issue.') unless (open(REGFILE, ">>$config{'regdir'}/$form{'ALIAS'}.dat"));
                        if ($config{'flock'}) {
                        flock(REGFILE, 2);
                        seek(REGFILE, 0, 2);
                        } 
                        print REGFILE "\n$form{'CATEGORY'}$item_number";
                        close REGFILE;                         
                } 

                unlink ("$config{'basepath'}$config{'closedir'}/$form{'REPOST'}.dat") if ($form{'REPOST'});

                if ($form{'UPIMAGE1'} ne "") {
File::Copy::move ("$config{'imagebase'}/temp/$form{'UPIMAGE1'}", "$config{'imagebase'}/$form{'UPIMAGE1'}") or oops ("Please notify the site admin that the image cannot be copied from the temp dir to the photo dir.");
           }

           if ($form{'UPIMAGE2'} ne "") {
File::Copy::move ("$config{'imagebase'}/temp/$form{'UPIMAGE2'}", "$config{'imagebase'}/$form{'UPIMAGE2'}") or oops ("Please notify the site admin that the image cannot be copied from the temp dir to the photo dir.");
           }

           if ($form{'UPIMAGE3'} ne "") {
File::Copy::move ("$config{'imagebase'}/temp/$form{'UPIMAGE3'}", "$config{'imagebase'}/$form{'UPIMAGE3'}") or oops ("Please notify the site admin that the image cannot be copied from the temp dir to the photo dir.");
           }

           if ($form{'UPIMAGE4'} ne "") {
File::Copy::move ("$config{'imagebase'}/temp/$form{'UPIMAGE4'}", "$config{'imagebase'}/$form{'UPIMAGE4'}") or oops ("Please notify the site admin that the image cannot be copied from the temp dir to the photo dir.");
           }
           &deltempimage;

                ###### Add for SUB Cats E-Mail Display ####           
                my($disppath, $thispath, @this);
	        foreach $key (keys %category) {
	        	$disppath = '';
		        $thispath = $category{$form{'CATEGORY'}};
              		while($thispath =~ s/^<!--([^\>]*)-->//) {
	          		if($supercat{$1} ne '') {  
                                $disppath .= "$supercat{$1} -> ";
			        }                                
                        }
                }              
                ###### END Add for SUB Cats E-Mail Display ####                
                print "<B>Your item was posted under the category:</B> $disppath $thispath<br><B>Item Number:</B> $item_number<br><B>Title:</B> $form{'TITLE'}</B>
<P>
<A HREF=\"$ENV{'SCRIPT_NAME'}?category=$form{'CATEGORY'}\&item=$item_number\">Click Here</A> to confirm placement of your new item.
<P>
<CENTER>
<FORM ACTION=$ENV{'SCRIPT_NAME'}?action=selectnew METHOD=POST>
<INPUT TYPE=SUBMIT VALUE=\"Post Another Item\">
<FORM>
<P>";

if ($form{'UPIMAGE1'} eq "") {
print "<FORM>
<INPUT TYPE=BUTTON VALUE=\"Post A Similar Item\" NAME=\"#TOP\" onClick=\"history.go(-2)\">
</FORM></CENTER><P>";
}

#### Compute posting charges if any #######
                my $newpostcost = 0.00;
                if ($config{'listingfee2'} > 0.00){
                $newpostcost = &parsebid($newpostcost + $config{'listingfee2'});
                }
                my $ffeatcost = 0.00;
                if ($form{'FEAT_FP'} eq "YES"){
                $ffeatcost = &parsebid($ffeatcost + $config{'feat_full_fee2'});
                }                 
                my $cfeatcost = 0.00;
                if ($form{'FEAT_CP'} eq "YES"){
                $cfeatcost = &parsebid($cfeatcost + $config{'feat_cat_fee2'});
                }                
                my $gboldcost = 0.00;
                if ($form{'FEAT_YT'} eq "YES"){                
                $gboldcost = &parsebid($gboldcost + $config{'feat_green_fee2'});
                }                
                my $boldcost = 0.00;
                if ($form{'FEAT_BF'} eq "YES"){
                $boldcost = &parsebid($boldcost + $config{'feat_bold_fee2'});
                }      
                #####
                my $grabbercost = 0.00;
                if ($form{'GRABBER'} ne "NONE") {
                $grabbercost = &parsebid($grabbercost + $config{'grabberfee2'});
                } 
                #####
                my $musiccost = 0.00;
                if ($form{'MUSIC'} ne "NONE") {
                $musiccost = &parsebid($musiccost + $config{'musicfee2'});
                } 
                #####
                my $gallerycost = 0.00;
                if ($form{'GALLERY'} eq "Yes"){
                $gallerycost = &parsebid($gallerycost + $config{'galleryfee2'});
                } 
                #####
                my $uploadimagecost1 = 0.00;
                if ($form{'UPIMAGE1'} ne "") {
                $uploadimagecost1 = &parsebid($uploadimagecost1 + $config{'uploadimagefee2'});
                }  
                my $uploadimagecost2 = 0.00;
                if ($form{'UPIMAGE2'} ne "") {
                $uploadimagecost2 = &parsebid($uploadimagecost2 + $config{'uploadimagefee2'});
                }   
                my $uploadimagecost3 = 0.00;
                if ($form{'UPIMAGE3'} ne "") {
                $uploadimagecost3 = &parsebid($uploadimagecost3 + $config{'uploadimagefee2'});
                }   
                my $uploadimagecost4 = 0.00;
                if ($form{'UPIMAGE4'} ne "") {
                $uploadimagecost4 = &parsebid($uploadimagecost4 +
$config{'uploadimagefee2'});
                }       
                ########## 
                my $counter = 0.00;
                if ($form{'USECOUNTER'} eq "Yes") {
                $counter = &parsebid($counter + $config{'counterfee2'});
                }      
                ##################################
                ######
                ##################################
                my $totalcost = 0.00;
                if ($config{'listingfee2'} > 0.00){                         
                $totalcost = &parsebid($totalcost + $config{'listingfee2'});
                }                
                if ($form{'FEAT_FP'} eq "YES"){
                $totalcost = &parsebid($totalcost + $config{'feat_full_fee2'});
                }
                if ($form{'FEAT_CP'} eq "YES"){
                $totalcost = &parsebid($totalcost + $config{'feat_cat_fee2'});
                }
                if ($form{'FEAT_YT'} eq "YES"){                
                $totalcost = &parsebid($totalcost + $config{'feat_green_fee2'});
                }
                if ($form{'FEAT_BF'} eq "YES"){
                $totalcost = &parsebid($totalcost + $config{'feat_bold_fee2'});
                }
                ###
                if ($form{'GRABBER'} eq "grab1"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }                
                if ($form{'GRABBER'} eq "grab2"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }               
                if ($form{'GRABBER'} eq "grab3"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});                
                }               
                if ($form{'GRABBER'} eq "grab4"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }                
                if ($form{'GRABBER'} eq "grab5"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }                
                if ($form{'GRABBER'} eq "grab6"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }               
                if ($form{'GRABBER'} eq "grab7"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }                
                if ($form{'GRABBER'} eq "grab8"){
                $totalcost = &parsebid($totalcost + $config{'grabberfee2'});
                }
                ###
                if ($form{'MUSIC'} eq "music1"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }                
                if ($form{'MUSIC'} eq "music2"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music3"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music4"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music5"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music6"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music7"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music8"){
                $totalcost = &parsebid($totalcost + $config{'musicfee2'});
                }
                ######
                if ($form{'GALLERY'} eq "Yes"){
                $totalcost = &parsebid($totalcost + $config{'galleryfee2'});
                }
                #########               
                if ($form{'UPIMAGE1'} ne "") {
                $totalcost = &parsebid($totalcost + $config{'uploadimagefee2'});
                }  
                if ($form{'UPIMAGE2'} ne "") {
                $totalcost = &parsebid($totalcost + $config{'uploadimagefee2'});
                }
                if ($form{'UPIMAGE3'} ne "") {
                $totalcost = &parsebid($totalcost + $config{'uploadimagefee2'});
                }
                if ($form{'UPIMAGE4'} ne "") {
                $totalcost = &parsebid($totalcost + $config{'uploadimagefee2'});
                }       
                if ($form{'USECOUNTER'} eq "Yes"){
                $totalcost = &parsebid($totalcost + $config{'counterfee2'});
                }
                if ($totalcost > 0.00) {
#### Sends the seller a E-Mail of charges if any #######
if ($config{'newpostbill'} eq "on") {
&sendemail($form{'EMAIL'}, $config{'admin_address'}, 'New Auction Listing Bill,', 
"Dear $form{'ALIAS'}

This is your receipt of extra features you selected when you posted 
your new auction item at $config{'sitename'}

Title: $form{'TITLE'} (Item #: $item_number)
Category: $disppath $thispath                            	        
Your Email: $form{'EMAIL'}

New Auction Listing Fee $config{'currencytype'}$newpostcost
Your charges for extra listing feature(s):
Main Page Picture Gallery Featured $config{'currencytype'}$gallerycost
Main Page Featured Listing $config{'currencytype'}$ffeatcost
Category Featured Listing $config{'currencytype'}$cfeatcost
Back Ground Color Listing $config{'currencytype'}$gboldcost
Bold Font Listing $config{'currencytype'}$boldcost
Att Grabber Icon $config{'currencytype'}$grabbercost
BackGround Music $config{'currencytype'}$musiccost
Auction Image 1 Upload Fee $config{'currencytype'}$uploadimagecost1 
Auction Image 2 Upload Fee $config{'currencytype'}$uploadimagecost2
Auction Image 3 Upload Fee $config{'currencytype'}$uploadimagecost3
Auction Image 4 Upload Fee $config{'currencytype'}$uploadimagecost4
Auction Item Counter $config{'currencytype'}$counter
Total Cost of special listings $config{'currencytype'}$totalcost

This is due and payable by the end of the month. 
You can make a payment by using the mail in form below, 
or pay online by loging into your account at: $config{'scripturl'}$ENV{'SCRIPT_NAME'}?action=accountlogin 

Thanks for choosing $config{'sitename'}


###################### Mail In Payment Form ##########################\n\n
Your Name:__________________________________________________________\n
Your user name:_____________________________________________________\n
Address: ___________________________________________________________\n
City and State: ____________________________________________________\n
Auction Item Number: _______________________________________________\n
amount of Payment: $config{'currencytype'}_______________\n\n
Make Checks payable to:
$config{'checkpayableto'}
and send to:
$config{'checkpayableto'}
$config{'mailingaddress'}
$config{'cityandstate'}");
            } 
}
#### End compute charges and Sends the seller a E-Mail of charges if any #######
                             
#### Sends the seller a comfirmation E-Mail #######
&sendemail($form{'EMAIL'}, $config{'admin_address'}, 'Your New Auction Listing,', 
"Dear $form{'ALIAS'}

This note is to confirm your new listing at $config{'sitename'}
Title: $form{'TITLE'} (Item #: $item_number)
Category: $disppath $thispath 

Your Alias: $form{'ALIAS'}
Your Email: $form{'EMAIL'}

Started: $nowtime
Closes: $closetime

Starting Bid: $bid
Increment: $form{'INC'}
Reserve:$form{'RESERVE'}

View Your Item At:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$form{'CATEGORY'}\&item=$item_number

Thanks for choosing $config{'sitename'}");
########## End send the seller a Confirmation E-Mail ######  

#### Sends the site Admin a comfirmation E-Mail #######
if ($config{'newitemsendtoadmin'} eq "on") {
&sendemail($config{'admin_address'}, $config{'admin_address'}, 'Your New Auction Listing,', 
"Dear $form{'ALIAS'}

This note is to confirm your new listing at $config{'sitename'}
Title: $form{'TITLE'} (Item #: $item_number)
Category: $thispath $disppath

Sellers Alias: $form{'ALIAS'}
Sellers Email: $form{'EMAIL'}

Item Started: $nowtime
Item Closes: $closetime

Starting Bid: $bid
Increment: $form{'INC'}
Reserve:$form{'RESERVE'}

View This Item At:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$form{'CATEGORY'}\&item=$item_number");
########## End send the site Admin a Confirmation E-Mail ######
    }                                         
 }   
############### Preview New Post #####################################
        else {                
        
        #-####### For account ballance checker of before posting a new item ########
            if ($config{'PostAccountStatus'} eq "on") {
                my $totalfees = 0.00;
                if ($config{'listingfee2'} > 0.00){                
                $totalfees = &parsebid($totalfees + $config{'listingfee2'});
                }
                if ($form{'FEAT_FP'} eq "YES"){                
                $totalfees = &parsebid($totalfees + $config{'feat_full_fee2'});
                }
                if ($form{'FEAT_CP'} eq "YES"){                
                $totalfees = &parsebid($totalfees + $config{'feat_cat_fee2'});
                }
                if ($form{'FEAT_YT'} eq "YES"){                
                $totalfees = &parsebid($totalfees + $config{'feat_green_fee2'});
                }
                if ($form{'FEAT_BF'} eq "YES"){                
                $totalfees = &parsebid($totalfees + $config{'feat_bold_fee2'});
                }
                ##
                if ($form{'GRABBER'} eq "grab1"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab2"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab3"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab4"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab5"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab6"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab7"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab8"){                
                $totalfees = &parsebid($totalfees + $config{'grabberfee2'});
                }
                ######
                if ($form{'MUSIC'} eq "music1"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music2"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music3"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music4"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music5"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music6"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music7"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music8"){                
                $totalfees = &parsebid($totalfees + $config{'musicfee2'});
                }
                #######
                if ($form{'GALLERY'} eq "Yes"){                
                $totalfees = &parsebid($totalfees + $config{'galleryfee2'});
                }
                ############
                if ($form{'UPIMAGE1'} ne "") {                
                $totalfees = &parsebid($totalfees + $config{'uploadimagefee2'});
                }    
                if ($form{'UPIMAGE2'} ne "") {                
                $totalfees = &parsebid($totalfees + $config{'uploadimagefee2'});
                }  
                if ($form{'UPIMAGE3'} ne "") {                
                $totalfees = &parsebid($totalfees + $config{'uploadimagefee2'});
                }  
                if ($form{'UPIMAGE4'} ne "") {                
                $totalfees = &parsebid($totalfees + $config{'uploadimagefee2'});
                }              
                ##########
                if ($form{'USECOUNTER'} eq "Yes"){                
                $totalfees = &parsebid($totalfees + $config{'counterfee2'});
                }                 
                &Account_Status2($form{'ALIAS'}, $totalfees);
                }
        #-####### For account ballance checker of before posting a new item ########

        my $sold;
        if ($form{'DUTCH'} eq 'yes') {
        $sold = "Number Sold: <b>None</b>";
        }        
     
        if ($form{'DUTCH'} eq 'no') {
        $sold = "";
        }

        my $reservemsg = "";              
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(No Reserve)</FONT> " if (($form{'RESERVE'} <= 0)  && ($form{'DUTCH'} eq 'no')); 
       $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(Reserve Not Met)</FONT> " if (($form{'RESERVE'} > 0)  && ($form{'DUTCH'} eq 'no'));
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=\"2\">(Dutch Fixed Price)</FONT> " if ($form{'DUTCH'} eq 'yes');

          my $bgmusic = "";
          $bgmusic = "$config{'music1'}" if ($form{'MUSIC'} eq "music1");
          $bgmusic = "$config{'music2'}" if ($form{'MUSIC'} eq "music2");
          $bgmusic = "$config{'music3'}" if ($form{'MUSIC'} eq "music3");
          $bgmusic = "$config{'music4'}" if ($form{'MUSIC'} eq "music4");
          $bgmusic = "$config{'music5'}" if ($form{'MUSIC'} eq "music5");
          $bgmusic = "$config{'music6'}" if ($form{'MUSIC'} eq "music6");
          $bgmusic = "$config{'music7'}" if ($form{'MUSIC'} eq "music7");
          $bgmusic = "$config{'music8'}" if ($form{'MUSIC'} eq "music8");

     my $imagedisp1 = "$form{'IMAGE1'}" if ($form{'IMAGE1'} ne "");
     my $imagedisp2 = "$form{'IMAGE2'}" if ($form{'IMAGE2'} ne "");
     my $imagedisp3 = "$form{'IMAGE3'}" if ($form{'IMAGE3'} ne "");
     my $imagedisp4 = "$form{'IMAGE4'}" if ($form{'IMAGE4'} ne "");

     $imagedisp1 = "$config{'imagetempurl'}$form{'UPIMAGE1'}" if ($form{'UPIMAGE1'} ne "");
     $imagedisp2 = "$config{'imagetempurl'}$form{'UPIMAGE2'}" if ($form{'UPIMAGE2'} ne "");
     $imagedisp3 = "$config{'imagetempurl'}$form{'UPIMAGE3'}" if ($form{'UPIMAGE3'} ne "");
     $imagedisp4 = "$config{'imagetempurl'}$form{'UPIMAGE4'}" if ($form{'UPIMAGE4'} ne "");

if ($config{'backgroungmusic'} eq 'yes') {
    print <<"EOF";
<embed src="$bgmusic" width="0" height="0" loop="true" autoplay="true" hidden="true">
EOF
}

print <<"EOF";
<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4" color="#000000"><b>Title: $form{'TITLE'} - Preview</b></font></td>
  </tr>  
</table>
</div>

<p></p>

<p align="center">Current Time: $nowtime $config{'timezone'}</p>

<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td width="10%" rowspan="10" valign="top" align="left"><a href="#DESC"><img src=$config{'descicon'} alt="Show description"
    border="0" WIDTH="50" HEIGHT="50"></a><br>
    <a href="#BID"><img src=$config{'bidicon'} alt="Bid!"
    border="0" WIDTH="50" HEIGHT="50"></a><br>
    </td>
    <td width="30%">Current Bid: <b>$config{'currencytype'}$bid</b> $reservemsg</td>
    <td width="1%"></td>
    <td width="30%">First bid: <b>$config{'currencytype'}$bid</b> </td>    
  </tr>
  <tr>
    <td width="30%">Dutch Auction: <b>$form{'DUTCH'}</b></td>
    <td width="1%"></td>
    <td width="30%">Quantity: <b>$form{'QTY'}</b>  $sold</td>    
  </tr>
  <tr>
    <td width="30%">Time left: <b>$timeremain</b></td>
    <td width="1%"></td>
    <td width="30%">Number of bids: <b>0</b> <a href="#HIST">(bid history)</a></td>    
  </tr>
  <tr>
    <td width="30%">Started: <b>$nowtime</b></td>
    <td width="1%"></td>
    <td width="30%">Location: $form{'ADDRESS3'}<b></b></td>    
  </tr>
  <tr>
    <td width="30%">Ends: <b>$closetime</b></td>
    <td width="1%"></td>
    <td width="30%">Send To Friend:(mail this auction to a friend)</td>   
  </tr>
  <tr>
    <td width="30%">Track this item: (add to your list)</td>
    <td width="1%"></td>
    <td width="30%">Ask seller a Question: (ask or view Q&A)</td>   
  </tr>
</table>
</div>
</font>

<div align="center">
<table border="0" cellpadding="8" cellspacing="0" width="100%">    
  <tr>
    <td><p></td>  
  </tr>
 <tr>
    <!----<td width="50%">Seller:(view seller's feedback)(view sellers other auctions)</td>  ---->
  </tr>
  <tr>
    <td><p></td>  
  </tr>       
  <tr>
    <td width="50%">High bidder: No Bids</td>    
  </tr>   
  <tr>
    <td><p></td>  
  </tr> 
  <tr>
    <td width="30%">Payment Options: <b>$form{'PAYMENT'}</b></td>     
  </tr>   
  <tr>
    <td width="30%">Shipping Terms: <b>$form{'SHIPPING'}</b></td>  
  </tr>   
  <tr>
    <td width="30%">Condition of Item: <b>$form{'CONDITION'}</b></td>  
  </tr>
  <tr>      
    <td width="50%">Seller: You may update your item Description, change relist, or Delete this auction if there are no bids. if there are bids you can not delete it only add to your Description.
  </td>
  <tr>
    <td><p></td>  
  </tr>
  <tr>
    <td><p align="center"><font size=2 face="Arial"><center>Seller assumes all responsibility for listing this item.<br>
    You should contact the seller to resolve any questions before bidding.<br>
    Currency is $config{'currencytype2'} unless otherwise noted.</center></font></td>
  </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4" color="#000000"><b><a name="DESC"></a><center>Description</center></b></font></td>
  </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width=675>
  <tr>
    <td>
<blockquote>
<p>$form{'DESCTITCOLOR'}</p>
<p>$form{'DESCTITSIZE'}</p>
<p><center>$form{'DESCTIT'}</center></p>
</FONT></FONT></BOLD></B></I></U></H1></H2></H3></H4></H5></CENTER></HTML></BODY></HEAD>
</blockquote>
   </td>
   </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="675">
  <tr>
    <td>
<blockquote>
<p>$form{'DESCCOLOR'}</p>
<p>$form{'DESCSIZE'}</p>
<p>$form{'DESC'}</p>
</FONT></FONT></BOLD></B></I></U></H1></H2></H3></H4></H5></CENTER></HTML></BODY></HEAD>
</blockquote>
   </td>
   </tr>
</table>
</div>

<div align="center">
<SCRIPT LANGUAGE="JavaScript">
function EnlargeImage(name) {
newsrc = name;
document.images.large.src = newsrc;
}
</SCRIPT>
EOF
if ($imagedisp1) {
print <<"EOF";
<table align="center" border="0" width="100%">
<tr>
<td><img name="large" SRC="$imagedisp1" BORDER="0"><br><br><br></td>      
EOF
}
if ($imagedisp2) {
print <<"EOF";
<td>
<table border="0"><tr><td colspan="2" align="center"><b>Click Thumbnails For Larger Picture</b></td>
</tr>
EOF
}
if ($imagedisp2) {
print <<"EOF";
<tr>
<td><a href="javascript:EnlargeImage('$imagedisp1')"><img SRC="$imagedisp1" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($imagedisp2) {
print <<"EOF";
<td><a href="javascript:EnlargeImage('$imagedisp2')"><img SRC="$imagedisp2" BORDER="0" WIDTH="75"></a></td>
</tr>
EOF
}
if ($imagedisp3) {
print <<"EOF";
<tr>
<td><a href="javascript:EnlargeImage('$imagedisp3')"><img SRC="$imagedisp3" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($imagedisp4) {
print <<"EOF";
<td><a href="javascript:EnlargeImage('$imagedisp4')"><img SRC="$imagedisp4" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($imagedisp1) {
print <<"EOF";
</tr>
</table>
</tr>
</table>
</div>
EOF
}

                #-####### For billing of Featured addon extras ########
                print "<TABLE WIDTH=100%><TR><TD BGCOLOR=$config{'colortablehead'}>";
                print "<FONT SIZE=+2><B><center>Additional Cost</center></B></FONT></TD</TR></TABLE>";
                
                my $totalcost2 = 0.00;
                if ($config{'listingfee2'} > 0.00){
                print "New Auction Listing Fee: <b>$config{'listingfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'listingfee2'});
                }
                if ($form{'FEAT_FP'} eq "YES"){
                print "Featured on Home Page: <b>$config{'feat_full_fee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'feat_full_fee2'});
                }
                if ($form{'FEAT_CP'} eq "YES"){
                print "Featured on Category Page: <b>$config{'feat_cat_fee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'feat_cat_fee2'});
                }
                if ($form{'FEAT_YT'} eq "YES"){
                print "Back Ground Highlighted Title: <b>$config{'feat_green_fee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'feat_green_fee2'});
                }
                if ($form{'FEAT_BF'} eq "YES"){
                print "Bold Faced Title: <b>$config{'feat_bold_fee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'feat_bold_fee2'});
                }
                ##
                if ($form{'GRABBER'} eq "grab1"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab2"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab3"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab4"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab5"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab6"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab7"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                if ($form{'GRABBER'} eq "grab8"){
                print "Title Att Grabber: <b>$config{'grabberfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'grabberfee2'});
                }
                ######
                if ($form{'MUSIC'} eq "music1"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music2"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music3"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music4"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music5"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music6"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music7"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                if ($form{'MUSIC'} eq "music8"){
                print "Back Ground Music: <b>$config{'musicfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'musicfee2'});
                }
                #######
                if ($form{'GALLERY'} eq "Yes"){
                print "Gallery Featured: <b>$config{'galleryfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'galleryfee2'});
                }
                ############
                if ($form{'UPIMAGE1'} ne "") {
                print "Image 1 upload fee: <b>$config{'uploadimagefee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'uploadimagefee2'});
                }    
                if ($form{'UPIMAGE2'} ne "") {
                print "Image 2 upload fee: <b>$config{'uploadimagefee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'uploadimagefee2'});
                }  
                if ($form{'UPIMAGE3'} ne "") {
                print "Image 3 upload fee: <b>$config{'uploadimagefee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'uploadimagefee2'});
                }  
                if ($form{'UPIMAGE4'} ne "") {
                print "Image 4 upload fee: <b>$config{'uploadimagefee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'uploadimagefee2'});
                }              
                ##########
                if ($form{'USECOUNTER'} eq "Yes"){
                print "Auction Item Counter : <b>$config{'counterfee2'}</b><br>";
                $totalcost2 = &parsebid($totalcost2 + $config{'counterfee2'});
                }                
                #############
                if ($totalcost2 == 0.00){
                print "You selected not to add any additional features!<br>";
                }                    
                print "<hr><b>Total Costs = $config{'currencytype'}$totalcost2</b><br>";
                if (($totalcost2 > 0.00) & ($config{'newpostbill'} eq "on")) {
                print "<b>This bill will be E-Mailed to you shortly, read and follow the instructions in the billing.</b></p>";
                }
                #-####### End For billing of Featured addon extras ########
                print "<HR><B><FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><center>If this looks good, hit</center><BR>";
                print "<center><INPUT TYPE=SUBMIT VALUE=\"Sell It!\"></center><BR>";
                print "<center>otherwise hit the back button on your browser to edit the item.<INPUT TYPE=HIDDEN NAME=FROMPREVIEW VALUE=1></center></B>\n";

                my $key;
                foreach $key (keys %form) {
                        $form{$key} =~ s/\>/\[greaterthansign\]/gs;
                        $form{$key} =~ s/\</\[lessthansign\]/gs;
                        $form{$key} =~ s/\"/\[quotes\]/gs;
                        print "<INPUT TYPE=hidden NAME=\"$key\" VALUE=\"$form{$key}\">\n";
                }                
                print "</FORM>\n";                 
        }                                           
}

#-#########################################
# Double post eliminator
# prevent double posts

sub double_check {
             my $lastbid = pop;
             $lastbid =~ m/(.+)(\d{10})$/;
             my ($key,$file) = ($1,$2);
             return '' unless (-T "$config{'basepath'}$key/$file.dat");
             my @item = &read_item_file($key,$file);
             return $file unless (((((($form{'DAYS'} * 86400) + time) - $file)*-1) > 30) || ($item[0] ne $form{'TITLE'}));
             return '';
     }

#-#############################################
# Sub: Change User Registration Info
# This allows a user to submit VIA a E-mail Form 
# to the sites webmaster updates needed to a 
# users registration account

sub creg {

                my $ip = $ENV{'REMOTE_ADDR'};

        print <<"EOF";
<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">

<TABLE ALIGN="CENTER" WIDTH="80%" BORDER="1" CELLPADDING="0" CELLSPACING="0" BGCOLOR="$config{'colortablehead'}">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="proccreg">
<INPUT TYPE="HIDDEN" NAME="IP" VALUE="$ip">
<TR><TD COLSPAN="2" VALIGN="TOP"><H3>This form will allow you to change your user name, e-mail address, mailing address, and phone number.<br>You must enter accurate data, as a new password will be e-mailed to you. Please be patient after hitting the submit button. Registration changes may take a few minutes.<br><p>Your IP address is: $ip address is recorded for security!</H3></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Your User Name:<BR></B>Required for verification</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ALIAS" TYPE="TEXT" SIZE="30" MAXLENGTH="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Your Current Password:<BR></B>Required for verification</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="OLDPASS" TYPE="PASSWORD" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>E-mail Address:<BR></B>Leave blank if unchanged</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="EMAIL" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Your Full Name:<BR></B>Leave blank if unchanged</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ADDRESS1" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Street Address:<BR></B>Leave blank if unchanged</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ADDRESS2" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>City, State, Zip:<BR></B>Leave blank if unchanged</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ADDRESS3" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Phone Number:<BR></B>Leave blank if unchanged</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="PHONE" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD COLSPAN="2" BGCOLOR="$config{'colortablehead'}"><CENTER><INPUT TYPE="SUBMIT" VALUE="Submit"></CENTER></TD></TR>

</TABLE>

EOF
}

#-#############################################
# Sub: Process Changed Registration
# This modifies an account

sub proccreg {

                $form{'ALIAS'} = ucfirst(lc($form{'ALIAS'}));

        if ($config{'regdir'}) {
                &oops('You must enter your alias so we can validate your account.') unless ($form{'ALIAS'});
                &oops('You must enter your old password so we can validate your account.') unless ($form{'OLDPASS'});
     
        if (($form{'EMAIL'} ne "") && ($form{'EMAIL'} =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $form{'EMAIL'} !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)) {
        &oops('You must enter a valid e-mail address.');
        }    
                                 
                if (my ($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = &read_reg_file($form{'ALIAS'})) {                        
                        &oops('Your old password does not match up.') unless ((lc $password) eq (lc $form{'OLDPASS'}));

$form{'EMAIL'} = lc($form{'EMAIL'});

### Added for Banned-User by E-Mail ####
&banemail;                     
### END - Added for Added for Banned-User by E-Mail ####

### Added for Banned-User by E-Mail ####
&banfreeemail;
### END Added for Banned-User by E-Mail ####

### Added for Ban a User by IP Address ####
&banipaddress;
### END Added for Ban a User by IP Address ####

###Added for Multi-Alias ####
if ($form{'EMAIL'} ne "") {
&multalias;
}
### END - Added for Multi-Alias ####

                        $form{'NEWPASS1'} = $password if !($form{'NEWPASS1'});
                        $form{'ADDRESS1'} = $add1 if !($form{'ADDRESS1'});
                        $form{'ADDRESS2'} = $add2 if !($form{'ADDRESS2'});
                        $form{'ADDRESS3'} = $add3 if !($form{'ADDRESS3'});
                        $form{'PHONE'} = $phone if !($form{'PHONE'});
                        $form{'IP'} = $ip if !($form{'IP'});
                        $form{'REFERRAL'} = $referral if !($form{'REFERRAL'});
                        $form{'REFNAME'} = $refname if !($form{'REFNAME'});
                        $form{'EMAIL'} = $email if !($form{'EMAIL'});

                        my $newpass = &randompass; 

                        &oops('We cannot open your account.  This could be a server data write issue.') unless (open NEWREG, ">$config{'regdir'}/$form{'ALIAS'}.dat");
                        if ($config{'flock'}) {
                        flock(NEWREG, 2);
                        seek(NEWREG, 0, 2);
                        }                         
                        print NEWREG "$newpass\n$form{'EMAIL'}\n$form{'ADDRESS1'}\n$form{'ADDRESS2'}\n$form{'ADDRESS3'}\n$form{'PHONE'}\n$form{'IP'}\n$form{'REFERRAL'}\n$form{'REFNAME'}";
                        my $bid;
                        foreach $bid (@past_bids) {
                                print NEWREG "\n$bid";
                        }                        
                        close NEWREG;

                       print "$form{'ALIAS'}, you should receive an e-mail to $form{'EMAIL'} in a few minutes.  It will contain your new password needed to sell or bid. If you do not get an e-mail, please re-register.\n";
                        &sendemail($form{'EMAIL'}, $config{'admin_address'}, 'New Auction Password', 
"PLEASE DO NOT REPLY TO THIS E-MAIL.\n\n
The changes to your user registration at the White Bear Lake Area Historical Society have been made!\n
Your new password to access your account is: $newpass\n
Your user name is: $form{'ALIAS'}\n\n
Thank you for using the White Bear Lake Area Historical Society Online Auction.");

########## Send Webmaster a email when a user updates Registration ####
                        if ($config{'newregsendtoadmin'} eq "on") {
                        &sendemail($config{'admin_address'}, $config{'admin_address'}, 'User updated Registration', 
"User: $form{'ALIAS'} has updated their registration here at $config{'sitename'}.\n
Contact info:
Old E-Mail: $email   New E-mail: $form{'EMAIL'}
User Real Name: $form{'ADDRESS1'}
Old Address: $add2   New Address: $form{'ADDRESS2'}
Old City and State: $add3   New City and State: $form{'ADDRESS3'}
Old Phone: $phone   New phone: $form{'PHONE'}
Old IP address: $ip   New Ip address: $form{'IP'}");
}
##### END Send Webmaster a email when a user updates Registration ####
                }
                else {
                ######  print "Sorry...  That Username is not valid.  If you do not have an alias (or cannot remember it) you should create a <A HREF=$ENV{'SCRIPT_NAME'}?action=reg>new account</A>.\n";
                        print "Sorry...  That Username is not valid.  If you do not have an alias (or cannot remember it) you should create a <A HREF=\"$ENV{'SCRIPT_NAME'}?action=agree\">new account</A>.\n";
                }
        }
        else {
                print "User Registration is Not Implemented on This Server!  The System Administrator Did Not Specify a Registration Directory...\n";
        }
}       

#-#############################################
# Sub: Change User Password
# change users login password

sub change_password {

                my $ip = $ENV{'REMOTE_ADDR'};

        print <<"EOF";
<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">

<TABLE ALIGN="CENTER" WIDTH="80%" BORDER="1" CELLPADDING="0" CELLSPACING="0" BGCOLOR="$config{'colortablehead'}">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="proc_change_password">
<INPUT TYPE="HIDDEN" NAME="IP" VALUE="$ip">
<TR><TD COLSPAN="2" VALIGN="TOP"><H3>This form will allow you to change your password.<br><p>Your IP address is: $ip address is recorded for security!</H3></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Your Username:<BR></B>Required for verification</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ALIAS" TYPE"=TEXT" SIZE="30" MAXLENGTH="30"></CENTER></TD></TR>

<TR><TD VALIGN=TOP BGCOLOR="$config{'colortablebody'}"><B>Your Current Password:<BR></B>Required for verification</TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="OLDPASS" TYPE="PASSWORD" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Your New Password:<BR></B></TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="NEWPASS1" TYPE="PASSWORD" SIZE="30"></CENTER></TD></TR>

<TR><TD VALIGN="TOP" BGCOLOR="$config{'colortablebody'}"><B>Your New Password Again for Verification:<BR></B></TD><TD BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="NEWPASS2" TYPE="PASSWORD" SIZE="30"></CENTER></TD></TR>

<TR><TD COLSPAN="2" BGCOLOR="$config{'colortablehead'}"><CENTER><INPUT TYPE="SUBMIT" VALUE="Submit"></CENTER></TD></TR>

</TABLE>

EOF
}

#-#############################################
# Sub: Process Changed Password
# This modifies the users password

sub proc_change_password {

               $form{'ALIAS'} = ucfirst(lc($form{'ALIAS'}));

        if ($config{'regdir'}) {
                &oops('You must enter your alias so we can validate your account.') unless ($form{'ALIAS'});
                &oops('You must enter your old password so we can validate your account.') unless ($form{'OLDPASS'});                           
                &oops('You must enter your new password so we can update your account.') unless ($form{'NEWPASS1'});
                &oops('Your new passwords do not match.') unless ($form{'NEWPASS2'} eq $form{'NEWPASS1'});                        
                
                if (my ($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = &read_reg_file($form{'ALIAS'})) {         
                        &oops('Your old password does not match up.') unless ((lc $password) eq (lc $form{'OLDPASS'}));    
    
                        $form{'EMAIL'} = lc($form{'EMAIL'});

                        $form{'NEWPASS1'} = $password if !($form{'NEWPASS1'}); 
                
                        &oops('We cannot open your account.  This could be a server data write issue.') unless (open NEWREG, ">$config{'regdir'}/$form{'ALIAS'}.dat");
                        if ($config{'flock'}) {
                        flock(NEWREG, 2);
                        seek(NEWREG, 0, 2);
                        }  
                        print NEWREG "$form{'NEWPASS1'}\n$email\n$add1\n$add2\n$add3\n$phone\n$form{'IP'}\n$referral\n$refname";
                        my $bid;
                        foreach $bid (@past_bids) {
                                print NEWREG "\n$bid";
                        }                        
                        close NEWREG;                  
                        print "$form{'ALIAS'}, your login password has been changed.\n";
                }
                else {                
                        print "Sorry...  That Username is not valid.  If you do not have an alias (or cannot remember it) you should create a <A HREF=\"$ENV{'SCRIPT_NAME'}?action=agree\">new account</A>.\n";
                }
        }
        else {
                print "User Registration is Not Implemented on This Server!  The System Administrator Did Not Specify a Registration Directory...\n";
        }
}       

#-#############################################
# Sub: User Agreement
# User must read the and accept this agreement before 
# being allowed to register

sub agree {
print "<FORM ACTION=\"$ENV{'SCRIPT_NAME'}\" METHOD=\"POST\">";
print "<TABLE WIDTH=\"100%\" BORDER=\"0\">";
print "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"reg\">";
print "<TR><TD WIDTH=\"100%\"><font Color=\"red\" size=\"+1\"><CENTER><B>User Agreement between you and the White Bear Lake Area Historical Society</B></CENTER></font></TD></TR><TR><TD>";
print "<CENTER><B>The following is the user agreement as presented by the White Bear Lake Area Historical Society. You must agree to these terms before you will be able to bid on items. If you do not accept these terms, please do not use our services.</CENTER></B><HR><P>";
print "<B>Article 1.</B> Eligibility - This auction site is only available to people who are legally able to form binding contracts.  People who are under the age of 18 are not eligible.<P>";
print "<B>Article 2.</B> The White Bear Lake Area Historical Society cannot guarantee the authenticity and quality of said product.  Use of this site is at your own risk, and content is presented 'As-Is'.<P>";
print "<B>Article 3.</B> Bidding - As a user, you may bid on merchandise at the $config{'sitename'}. As a bidder, you know that placing a bid is a binding contract, and the bid cannot be retracted unless due to fault by the seller of typographical error, or other human error on the seller's part. Once you place a bid, and are the winner, you will be obligated to buy the product at the price you indicated as your bid. Placing a bid on this auction site, and winning, then not paying for the product is illegal in most states, and prosecution can result.<P>";
#print "<B>Article 4.</B> Selling Items - As a user, you are welcome to put items up for sale in the $config{'sitename'}. We do have restrictions on what items you may sell, and what you may not sell. You may not sell illegal merchandise, including pirated software and music, firearms, adult videos, or anything that is affiliated with pornography, etc. Items that are up to bids are subject to review by the staff of $config{'sitename'}, and my be removed without prior notice, if in violation with the User Agreement.<P>";
print "<B>Article 4.</B> Privacy - Personal information is not sold, rented, or used without your permission. Personal information sent to a user regarding a product bought on the auction is not to be used for any other purpose, except for communication regarding the auction item.<P>";
print "<B>Article 5.</B> Warranty - The White Bear Lake Area Historical Society provides items on this website in an 'as-is' condition, without warranty. The White Bear Lake Area Historical Society is not liable for any damages resulting in an auction, or your visit to the site.<P>";
print "<B>By Pressing I Accept, You Agree to the terms listed above.</B>";
print "</TD></TR></TABLE><P>";
print "<CENTER><INPUT TYPE=SUBMIT VALUE='I Accept'></CENTER>";
}

#-#############################################
# Sub: New Registration
# This creates a form for registration

sub reg {

         my $ip = $ENV{'REMOTE_ADDR'};

        print <<"EOF";
<H2>New User Registration</H2>
<H3>Your IP address is: $ip and is recorded for security!</H3>

<b>Become a registered user in just 3 easy steps:</b>
<br><p>
<b>Step 1 - Complete registration form below.</b><br>
Fill out the form below accurately. Be sure to include a valid e-mail address, since this is where your temporary password will be sent once you have completed step 1. Please be patient after hitting the submit button.<br><p>

<b>Step 2 - Receive temporary password.</b><br>
You will receive an e-mail from us with your temporary password usually within a few minutes.
<br><p>

<b>Step 3 - After receiving temporary password.</b><br>
You can change your password to something easier to remember by using the "Change Password" link located in the site map.
<br><p>

That's it! You're ready to begin Bidding and or Selling. Thank you for using our auction and Good Luck!
<br><p>

<b><font color="red">Note to AOL and CompuServe Members:</b></font> Make sure your Mail Controls are set to receive emails from $config{'sitename'}. If you have internet e-mail blocked, you will need to update your Mail Controls. To make this update, enter the Keyword "Mail Controls" on AOL or CompuServe.</font>
<br><p>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">

<TABLE ALIGN="CENTER" WIDTH="95%" BORDER="1" CELLPADDING="0" CELLSPACING="0" BGCOLOR="$config{'colortablehead'}">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="procreg">
<INPUT TYPE="HIDDEN" NAME="IP" VALUE="$ip">

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Enter A User Name For Your Account:</B><BR>Used to login to the auction site and to track your auctions and or bids.<BR><FONT COLOR=RED><B>NOTE: Your user name must consists of alphanumeric characters only and no spaces!!</B></FONT></TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ALIAS" TYPE="TEXT" SIZE="30" MAXLENGTH="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Re Enter Your User Name For Verification:</B><BR>Must match your user name entered above</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ALIAS2" TYPE="TEXT" SIZE="30" MAXLENGTH="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Your E-Mail Address:</B><BR>Must be valid, This is also where you will recieve your password needed to login.</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="EMAIL" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Re Enter Your E-Mail Address For Verification:</B><BR>Must match your e-mail address entered above</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="EMAIL2" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Your First and Last Name:</B><BR>&nbsp;</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ADDRESS1" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Your Mailing Address:</B><BR>&nbsp;</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ADDRESS2" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>Your City, State, ZIP Code</B><BR> If not in the US enter your province, country:</B></TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="ADDRESS3" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><b>Your Phone Number:</B><BR>&nbsp;</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="PHONE" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>How did you find us:</B><BR>Select One</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}">
<CENTER><SELECT NAME="REFERRAL">
<OPTION VALUE="registered user">Registered User
<OPTION VALUE="advertisement">Advertisement
<OPTION VALUE="search engine">Search Engine
<OPTION VALUE="friend">Friend
<OPTION VALUE="other">Other
</OPTION></SELECT></CENTER>
</TD></TR>

<TR><TD WIDTH="65%" BGCOLOR="$config{'colortablebody'}"><B>If Referred by a registered user:</B><BR>If you were referred by one of our registered auction users enter their user alias here!!</TD>
<TD WIDTH="35%" BGCOLOR="$config{'colortablebody'}"><CENTER><INPUT NAME="REFNAME" TYPE="TEXT" SIZE="30"></CENTER></TD></TR>

<TR><TD COLSPAN="2" BGCOLOR="$config{'colortablehead'}">&nbsp;<BR><CENTER><B>NOTE: By submitting your registration you are <br> affirming that you are AT LEAST 18 Years of age.</B><BR><INPUT TYPE="SUBMIT" VALUE="Register Me"><BR>&nbsp;</CENTER></TD></TR>

</TABLE>

EOF
}

#-#############################################
# Sub: Process Registration
# This adds new accounts to the database

sub procreg {
                
        if ($config{'regdir'}) {
                umask(000);  # UNIX file permission junk
                mkdir("$config{'regdir'}", 0777) unless (-d "$config{'regdir'}");
     
                  open(HTACCESS, ">$config{'regdir'}/.htaccess");                 
                  print HTACCESS "order deny,allow\ndeny from all" unless (-d "$config{'regdir'}/.htaccess");
                  close(HTACCESS);
                      
               &oops('You must enter an alias that consists of alphanumeric characters.') if $form{'ALIAS'} =~ /\W/ or !($form{'ALIAS'});

               &oops('The user/alias name you entered do not match.') if ($form{'ALIAS'} ne $form{'ALIAS2'});
               &oops('The E-Mail address you entered does not match.') if ($form{'EMAIL'} ne $form{'EMAIL2'});
               
     my $testmail = $form{'EMAIL'};
     if ($testmail =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
             $testmail !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/)
             {
             &oops('You must enter a valid e-mail address.');
             }

$form{'EMAIL'} = lc($form{'EMAIL'});

### Added for Banned-User by E-Mail ####
&banemail;                     
### END - Added for Added for Banned-User by E-Mail ####

### Added for Banned-User by E-Mail ####
&banfreeemail;
### END Added for Banned-User by E-Mail ####

### Added for Ban a User by IP Address ####
&banipaddress;
### END Added for Ban a User by IP Address ####

###Added for Multi-Alias ####
&multalias;
### END - Added for Multi-Alias ####

#               &oops('You must enter your full name so buyers or sellers may contact you.') #if (($form{'ADDRESS1'} = "") or ($form{'ADDRESS1'} = "-") or ($form{'ADDRESS1'} = """") or  #or ($form{'ADDRESS1'} = "''"));
                &oops('You must enter your full name so buyers or sellers may contact you.') unless ($form{'ADDRESS1'});               
                &oops('You must enter a valid street address so buyers or sellers can contact you.') unless ($form{'ADDRESS2'});
                &oops('You must enter a valid city, state, and zip code so buyers or sellers can contact you.') unless ($form{'ADDRESS3'});
                &oops('You must enter your home phone number.') unless ($form{'PHONE'});             
                         
           $form{'ALIAS'} = ucfirst(lc($form{'ALIAS'}));
                     
########### Referral Credit  ###################  

           $form{'REFNAME'} = "NONE"  if ($form{'REFNAME'} eq ""); 
           $form{'REFNAME'} = ucfirst(lc($form{'REFNAME'}));    
                  
           my ($refpassword,$refemail,$refadd1,$refadd2,$refadd3,$refphone,$refip,$refreferral,$refrefname,@refpast_bids) = &read_reg_file($form{'REFNAME'}); 
   
  if (-T "$config{'regdir'}/$form{'REFNAME'}.dat") {   
  if ($config{'referralcredit'} > "0.00") {
          &apply_transaction($form{'REFNAME'}, "New User Referral Credit", "$config{'referralcredit'}", "New User: $form{'ALIAS'} E-mail: $form{'EMAIL'}");
        &sendemail($refemail, $config{'admin_address'}, 'Referral Credit', 
"New User Referral Credit.\n\n
The new user $form{'ADDRESS1'} User alias: $form{'ALIAS'}\n
has registered using you as the referral giving you a creadit of $config{'referralcredit'}\n\n
Thank you for visiting!");
     }
     }
########### END Referral Credit #############

                if (!(-f "$config{'regdir'}/$form{'ALIAS'}.dat")) {
                        &oops('We were unable to write to the user directory.') unless (open NEWREG, ">$config{'regdir'}/$form{'ALIAS'}.dat");
                        my $newpass = &randompass; 
                        if ($config{'flock'}) {
                        flock(NEWREG, 2);
                        seek(NEWREG, 0, 2);
                        }
                        print NEWREG "$newpass\n$form{'EMAIL'}\n$form{'ADDRESS1'}\n$form{'ADDRESS2'}\n$form{'ADDRESS3'}\n$form{'PHONE'}\n$form{'IP'}\n$form{'REFERRAL'}\n$form{'REFNAME'}";
                        close NEWREG;
                        print "$form{'ALIAS'}, you should receive an e-mail to $form{'EMAIL'} in a few minutes.  It will contain your password needed to sell or bid. If you do not get an e-mail, please re-register.\n";
                        
                        &sendemail($form{'EMAIL'}, $config{'admin_address'}, 'Auction Registration Confirmation', 
"PLEASE DO NOT REPLY TO THIS E-MAIL.\n\n
Thank you for registering to use the $config{'sitename'}!\n\n
Your password is: $newpass\n
Your user name (as you entered it) is: $form{'ALIAS'}\n\n
To access the auction site: $config{'scripturl'}$ENV{'SCRIPT_NAME'}\n\n
Thank you for using the $config{'sitename'}!");

########## Send Webmaster a email when a new user registered ####
                        if ($config{'newregsendtoadmin'} eq "on") {
                        &sendemail($config{'admin_address'}, $config{'admin_address'}, 'New User Registered', 
"New User : $form{'ALIAS'}\n
Contact info:
E-mail: $form{'EMAIL'}
Real Name: $form{'ADDRESS1'}
Address: $form{'ADDRESS2'}
City and State: $form{'ADDRESS3'}
Phone: $form{'PHONE'}
Referral Information: $form{'REFERRAL'}
Referred by Name/Alias: $form{'REFNAME'}");
}
##### END Send Webmaster a email when a new user registered ####
####### New Registration Credit ############
                if ($config{'newregcredit'} => "0.00") {
                &apply_transaction($form{'ALIAS'}, "New Registration Credit", "$config{'newregcredit'}", "New Registration Credit");
                }
####### New Registration Credit ############
                }
                else {
                        print "Sorry...  that alias is taken.  Hit back to try again!\n";
                }
        }
        else {
                print "User Registration is Not Implemented on This Server!  The System Administrator Did Not Specify a Registration Directory...\n";
        }
}       

######################################
# Dont allow multiple users with the 
# same email address or IP address

sub multalias {

     my $checkip = $ENV{'REMOTE_ADDR'};

     my $file;
     opendir THEDIR, "$config{'regdir'}" || die "Unable to open directory: $!";
     my @allfiles = readdir THEDIR;
     closedir THEDIR;

            foreach $file (@allfiles) {
              if ($file =~ /\.dat/){ 
                  open REGFILE, "$config{'regdir'}/$file";
                  my($password,$checkemail,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@junk) = <REGFILE>;
                  chomp($password,$checkemail,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@junk);
                  close REGFILE;
      
                       if ($form{'EMAIL'} =~ $checkemail) {
                          &oops("This e-mail address, <b>$form{'EMAIL'}</b>, has already been registered.");
                       }
                       
                }
        }
}

#################################################################
# Ban a Users IP Address 

sub banipaddress {
     
              my $ip = $ENV{'REMOTE_ADDR'};

                              umask(000);  # UNIX file permission junk
                              mkdir("$config{'basepath'}banipdir", 0777) unless (-d "$config{'basepath'}banipdir"); 

     opendir THEDIR, "$config{'basepath'}banipdir" || die "Unable to open directory: $!";
             my @allfiles = readdir THEDIR;
             closedir THEDIR;
             chomp(@allfiles);

                 my $file;
                 foreach $file (@allfiles) {
                 if($ip eq $file){
                     &oops('Sorry... Your IP address has been banned from our system.');                   
                        }                
           }
 }

#################################################################
# Ban Free E-mail Address 

sub banfreeemail {
     
                              umask(000);  # UNIX file permission junk
                              mkdir("$config{'basepath'}banfreeemaildir", 0777) unless (-d "$config{'basepath'}banipdir"); 

     opendir THEDIR, "$config{'basepath'}banfreeemaildir" || die "Unable to open directory: $!";              
             readdir THEDIR;
             readdir THEDIR;
             my @allfiles = readdir THEDIR;
             closedir THEDIR;
             chomp(@allfiles);

                 my $file;
                 foreach $file (@allfiles) {
                 if($form{'EMAIL'} =~ /$file\Z/){
                     &oops('This auction does not accept free e-mail accounts for registration. Please enter a different e-mail address.');                   
                        }                
           }
 }

################################################
# Sub Ban-Email
# Allows administrator to ban certain email addresses from registering.

sub banemail {  
     
                              umask(000);  # UNIX file permission junk
                              mkdir("$config{'basepath'}bannedfile", 0777) unless (-d "$config{'basepath'}banipdir");   

     opendir THEDIR, "$config{'basepath'}bannedfile" || die "Unable to open directory: $!";
          my @allfiles = readdir THEDIR;
             closedir THEDIR;
             chomp(@allfiles);

                 my $file;
                 foreach $file (@allfiles) {
                 if($form{'EMAIL'} eq $file){
                   &oops("Sorry... that email address has been banned from our system.");
                        }                
           }
 }

################################################
# Sub checksuspendeduser
# Allows administrator to suspend certain registed user.

sub checksuspendeduser {
             
                 umask(000);  # UNIX file permission junk
                 mkdir("$config{'basepath'}suspendeddir", 0777) unless (-d "$config{'basepath'}suspendeddir");
                           
        my $Alias = $_[0];

        $Alias =~ s/\W//g;
        $Alias = lc($Alias);
        $Alias = ucfirst($Alias);

     opendir THEDIR, "$config{'basepath'}suspendeddir" || die "Unable to open directory: $!";
             my @allfiles = readdir THEDIR;
             closedir THEDIR;
             chomp(@allfiles);

                 my $file;
                 foreach $file (@allfiles) {     
                 $file =~ s/\.dat//;  
            
                 if($Alias eq $file) {
                    &oops('<font size=-1 face=verdana><b>  Sorry... You registered user account has been suspended by the site administration!</b></font>');                   
                        }                
           }
 }

#-#############################################
# Sub: Select Closed items to view
# This displays closed items

sub viewclosed {
           
        print <<"EOF";
<p><br>
<center><h2>Select the closed auction item(s) you need to view.</h2></center>
<p><br>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="viewclosed1login">
<TABLE ALIGN=CENTER WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<TR><TD COLSPAN="2" BGCOLOR="$config{'colortablehead'}"><b>ITEMS YOU SOLD IN THE LAST $config{'closedays'} DAYS</b></TD></TR>
<TR><TD COLSPAN="2" BGCOLOR="$config{'colortablehead'}"><CENTER><INPUT TYPE="SUBMIT" VALUE="View"></CENTER></TD></TR>
</FORM></TABLE>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE=hidden NAME="action" VALUE="viewclosed2login">
<TABLE ALIGN=CENTER WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>DUTCH ITEMS YOU SOLD IN THE LAST $config{'closedays'} DAYS</b></TD></TR>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><CENTER><INPUT TYPE=SUBMIT VALUE="View"></CENTER></TD></TR>
</FORM></TABLE>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="viewclosed3login">
<CENTER><TABLE ALIGN=CENTER WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>ITEMS YOU BID ON AND WON IN THE LAST $config{'closedays'} DAYS</b></TD></TR>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><CENTER><INPUT TYPE=SUBMIT VALUE="View"></CENTER></TD></TR>
</FORM></TABLE>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="viewclosed4login">
<CENTER><TABLE ALIGN=CENTER WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>DUTCH ITEMS YOU BID ON AND WON IN THE LAST $config{'closedays'} DAYS</b></TD></TR>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><CENTER><INPUT TYPE=SUBMIT VALUE="View"></CENTER></TD></TR>
</FORM></TABLE>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="viewclosed5login">
<CENTER><TABLE ALIGN=CENTER WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>ITEMS NOT RELISTED THAT YOU DID NOT SELL NO BIDS PLACED IN THE LAST $config{'closedays'} DAYS<br><font color=red>These Can Be Relisted</font></b></TD></TR>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><CENTER><INPUT TYPE=SUBMIT VALUE="View"></CENTER></TD></TR>
</FORM></TABLE>

<FORM ACTION="$ENV{'SCRIPT_NAME'}" METHOD="POST">
<INPUT TYPE="hidden" NAME="action" VALUE="viewclosed6login">
<CENTER><TABLE ALIGN=CENTER WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>ITEMS NOT RELISTED THAT YOU HAD BIDS ON BUT LESS THAN YOUR RESERVE IN THE LAST $config{'closedays'} DAYS<br><font color=red>These Can Be Relisted</font></b></TD></TR>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><CENTER><INPUT TYPE=SUBMIT VALUE="View"></CENTER></TD></TR>
</FORM></TABLE>
EOF
}

#-#############################################
# Sub: View Closed 1 login
# This displays closed items

sub viewclosed1login {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

        print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><H2>View Closed Items<br>ITEMS YOU SOLD IN THE LAST $config{'closedays'} DAYS</H2>

<TABLE WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<INPUT TYPE=HIDDEN NAME=action VALUE=viewclosed1list>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Please Note: The closed auctions are deleted $config{'closedays'} days after closing!</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TD></TR></TABLE>
<INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

##############################################
# Sub: View Closed 1 list
# This displays closed items

sub viewclosed1list {

        ### Security Check and Remove possible violations ###############
        $form{'BIDTOVIEW'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        $form{'ALIAS'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'ALIAS'} =~ s/alert//g; 
        $form{'ALIAS'} =~ s/script//g;  
        $form{'PASSWORD'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'PASSWORD'} =~ s/alert//g; 
        $form{'PASSWORD'} =~ s/script//g; 
        ### END Security Check and Remove possible violations ###############

        $form{'ALIAS'} =~ s/\W//g;
        $form{'ALIAS'} = lc($form{'ALIAS'});
        $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        &oops('ALIAS') unless (open(REGFILE,"$config{'regdir'}/$form{'ALIAS'}.dat"));
        my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <REGFILE>;
        chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        close REGFILE;
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));  
  
############ list all auctions the User had Sold ###############
        print "<center>";        

        print"<H2>ITEMS YOU SOLD IN THE LAST $config{'closedays'} DAYS:</H2>\n";

        print"<TABLE WIDTH=100% align=center border=1>\n";
        print "<TR><TD width=10% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Item Number</center></TD>
<TD width=35% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Title</center></TD>
<TD width=5% BORDER=1 BGCOLOR=$config{'colortablehead'}>Num of Bids</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Opening Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Last Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>High Bidder</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Closed On</TD></TR>\n";

             my $rowcount = 0;   
             my $pagebreak = int $form{pb} || 30;
             my ($icount, $pcount) = (0,0);
             my $bid;
             foreach $bid (@past_bids) {
             #foreach $bid (sort { $b <=> $a } @past_bids) {  
                  if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
                     open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
                         my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
                         close THEFILE;
                         chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);

                my @lastbid = split(/\[\]/,$bids[$#bids]);                                   
                my @firstbid = split(/\[\]/,$bids[0]); 
                $bid =~ s/\.dat//; 
                my $numbids = $#bids;                 
                my $itemnum;
                $itemnum = $bid;                         
                $itemnum =~ s/\.dat//; 
                $itemnum =~ /(\d{10})$/;
                $itemnum = $1;  

                               my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }      

                      my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }  
      
                open FEEDFILE, "$config{'feeddir'}/$lastbid[0].dat";                
	        my ($positive, $neutral, $negative, @userfeeds) = <FEEDFILE>;
	        close FEEDFILE;
        	chomp($positive, $neutral, $negative, @userfeeds);
                
                my ($match, $feed, @thefeed, $bidderrating);               
                foreach $feed (@userfeeds) { 
	             @thefeed = split(/\[\]/,$feed);  
 
        if (($thefeed[1] eq $bid) && ($thefeed[0] eq $firstbid[0])) {$match = "1"}

                 }
                 
                 if ($match eq "1") {
	            $bidderrating = "<font color=\"green\">(FeedBack Left)</font>"; 
                    }                 
                 else {
                    $bidderrating = "<A HREF=\"$ENV{'SCRIPT_NAME'}?action=getform&ALIAS=$lastbid[0]&ITEM=$bid\">
(Rate the bidder)</a>";
                    }        

         if (($#bids > 0) && ($dutch eq 'no') && ($firstbid[0] eq $form{'ALIAS'}) && ($lastbid[2] >= $reserve)) {   

         $rowcount++;                         
         if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page}; 

                        print "<TR>
<TD BORDER=1 BGCOLOR=$itemrowcolor><A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewcloseddisp&ALIAS=$form{'ALIAS'}&BIDTOVIEW=$bid\">$itemnum</A></TD>
<TD BGCOLOR=$itemrowcolor>$title $bidderrating</TD>
<TD BGCOLOR=$itemrowcolor>$numbids</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$firstbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$lastbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$lastbid[0]</TD>
<TD BGCOLOR=$itemrowcolor>$closetime</TD></TR>\n";
        }       

        }
        }
        if ($icount <= 0){
            print "<TR><TD COLSPAN=7 BGCOLOR=$config{'colortablebody'}><b>No Auction Items to View</b></TD></TR>";
        }        
        print "</TABLE>\n";
        &pagebreak($pcount,$pagebreak);   
        print "</CENTER></b>";                

} 

#-#############################################
# Sub: View Closed 2 login
# This displays closed items

sub viewclosed2login {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

        print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><H2>View Closed Items<br>DUTCH ITEMS YOU SOLD IN THE LAST $config{'closedays'} DAYS</H2>

<TABLE WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<INPUT TYPE=HIDDEN NAME=action VALUE=viewclosed2list>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Please Note: The closed auctions are deleted $config{'closedays'} after closing!</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TD></TR></TABLE>
<INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

##############################################
# Sub: View Closed 2 List
# This displays closed items

sub viewclosed2list {

        ### Security Check and Remove possible violations ###############
        $form{'ALIAS'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'ALIAS'} =~ s/alert//g; 
        $form{'ALIAS'} =~ s/script//g;  
        $form{'PASSWORD'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'PASSWORD'} =~ s/alert//g; 
        $form{'PASSWORD'} =~ s/script//g; 
        ### END Security Check and Remove possible violations ###############

        $form{'ALIAS'} =~ s/\W//g;
        $form{'ALIAS'} = lc($form{'ALIAS'});
        $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        &oops('ALIAS') unless (open(REGFILE,"$config{'regdir'}/$form{'ALIAS'}.dat"));
        my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <REGFILE>;
        chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        close REGFILE;
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));    
 
    if ($config{'dutchauctions'} eq "yes") {
        print "<center>";
        
        print"<H2>DUTCH ITEMS YOU SOLD IN THE LAST $config{'closedays'} DAYS:</H2>\n";

        print"<TABLE WIDTH=100% align=center border=1>\n";
        print "<TR><TD width=10% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Item Number</center></TD>
<TD width=35% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Title</center></TD>
<TD width=5% BORDER=1 BGCOLOR=$config{'colortablehead'}>Num of Bids</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Dutch Price</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Total Sold Quantity</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Dutch Bidder</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Closed On</TD></TR>\n";

             my $rowcount = 0;   
             my $pagebreak = int $form{pb} || 30;
             my ($icount, $pcount) = (0,0);
             my $bid;
             foreach $bid (@past_bids) {
             #foreach $bid (sort { $b <=> $a } @past_bids) {   
                 if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
                     open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
                         my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
                         close THEFILE;
                         chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);


                my @lastbid = split(/\[\]/,$bids[$#bids]);
                my @firstbid = split(/\[\]/,$bids[0]);
                $bid =~ s/\.dat//; 
                my $numbids = $#bids; 
                my $itemnum;
                $itemnum = $bid;                         
                $itemnum =~ s/\.dat//; 
                $itemnum =~ /(\d{10})$/;
                $itemnum = $1;    

                                               my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }      

                      my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};
                      }         
  
############ list all dutch auctions the User had Sold ###############     
                for (my $i=1; $i<scalar(@bids); $i++) {
                my ($alias, $email, $dutchbid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$i]);

                open FEEDFILE, "$config{'feeddir'}/$alias.dat";                
	        my ($positive, $neutral, $negative, @userfeeds) = <FEEDFILE>;
	        close FEEDFILE;
        	chomp($positive, $neutral, $negative, @userfeeds);
                
                my ($match, $feed, @thefeed, $bidderrating);               
                foreach $feed (@userfeeds) { 
	             @thefeed = split(/\[\]/,$feed);  
         
        if (($thefeed[1] eq $bid) && ($thefeed[0] eq $firstbid[0])) {$match = "1"}
       
                 }
                 
                 if ($match eq "1") {
	            $bidderrating = "<font color=\"green\">(FeedBack Left)</font>"; 
                    }                 
                 else {
                    $bidderrating = "<A HREF=\"$ENV{'SCRIPT_NAME'}?action=getform&ALIAS=$alias&ITEM=$bid\">
(Rate the bidder)</a>";
                    }   

         if (($#bids > 0) && ($dutch eq 'yes') && ($firstbid[0] eq $form{'ALIAS'})) {
      
         $rowcount++;                         
         if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};   

                print "<TR><TD BORDER=1 BGCOLOR=$itemrowcolor><A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewcloseddisp&ALIAS=$form{'ALIAS'}&BIDTOVIEW=$bid&DUTCHBIDDER=$alias\">$itemnum</A></TD>
<TD BGCOLOR=$itemrowcolor>$title $bidderrating</TD>
<TD BGCOLOR=$itemrowcolor>$numbids</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$dutchbid</TD>
<TD BGCOLOR=$itemrowcolor>X $oqty</TD> 
<TD BGCOLOR=$itemrowcolor>$alias</TD>
<TD BGCOLOR=$itemrowcolor>$closetime</TD></TR>\n";
               }
               } 

        }
        }
        if ($icount <= 0){
            print "<TR><TD COLSPAN=7 BGCOLOR=$config{'colortablebody'}><b>No Auction Items to View</b></TD></TR>";
        }        
        print "</TABLE>\n";
        &pagebreak($pcount,$pagebreak);  
        print "</CENTER></b>";        
}    

} 

#-#############################################
# Sub: View Closed 3 login
# This displays closed items

sub viewclosed3login {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

        print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><H2>View Closed Items<br>ITEMS YOU BID ON AND WON IN THE LAST $config{'closedays'} DAYS</H2>

<TABLE WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<INPUT TYPE=HIDDEN NAME=action VALUE=viewclosed3list>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Please Note: The closed auctions are deleted $config{'closedays'} after closing!</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TD></TR></TABLE>
<INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

##############################################
# Sub: View Closed 3 List
# This displays closed items

sub viewclosed3list {

        ### Security Check and Remove possible violations ###############
        $form{'ALIAS'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'ALIAS'} =~ s/alert//g; 
        $form{'ALIAS'} =~ s/script//g;  
        $form{'PASSWORD'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'PASSWORD'} =~ s/alert//g; 
        $form{'PASSWORD'} =~ s/script//g; 
        ### END Security Check and Remove possible violations ###############

        $form{'ALIAS'} =~ s/\W//g;
        $form{'ALIAS'} = lc($form{'ALIAS'});
        $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        &oops('ALIAS') unless (open(REGFILE,"$config{'regdir'}/$form{'ALIAS'}.dat"));
        my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <REGFILE>;
        chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        close REGFILE;
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));  
  
################## list all auctions the user has won #####################
        print "<center>";
       
        print"<H2>ITEMS YOU HAVE BID ON AND WON IN THE LAST $config{'closedays'} DAYS:</H2>\n";
        print"<H3>Below is a list of auctions that user $form{'ALIAS'} won.</H3>\n";

        print"<TABLE WIDTH=100% align=center border=1>\n";
        print "<TR><TD width=10% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Item Number</center></TD>
<TD width=35% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Title</center></TD>
<TD width=5% BORDER=1 BGCOLOR=$config{'colortablehead'}>Num of Bids</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Opening Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Last Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Seller</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Closed On</TD></TR>\n";

             my $rowcount = 0;   
             my $pagebreak = int $form{pb} || 30;
             my ($icount, $pcount) = (0,0);
             my $bid;
             foreach $bid (@past_bids) {
             #foreach $bid (sort { $b <=> $a } @past_bids) {   
                  if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
                     open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
                         my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
                         close THEFILE;
                         chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);

                my @lastbid = split(/\[\]/,$bids[$#bids]);                                   
                my @firstbid = split(/\[\]/,$bids[0]);
                $bid =~ s/\.dat//; 
                my $numbids = $#bids; 
                my $itemnum;
                $itemnum = $bid;                         
                $itemnum =~ s/\.dat//; 
                $itemnum =~ /(\d{10})$/;
                $itemnum = $1;     

                                               my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }      
                
                      my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};   
                      }                          	
                          
                open FEEDFILE, "$config{'feeddir'}/$firstbid[0].dat";                
	        my ($positive, $neutral, $negative, @userfeeds) = <FEEDFILE>;
	        close FEEDFILE;
        	chomp($positive, $neutral, $negative, @userfeeds);
                
                my ($match, $feed, @thefeed, $sellerrating);               
                foreach $feed (@userfeeds) { 
	             @thefeed = split(/\[\]/,$feed);  
 
        if (($thefeed[1] eq $bid) && ($thefeed[0] eq $lastbid[0])) {$match = "1"}

                 }
                 
                 if ($match eq "1") {
	            $sellerrating = "<font color=\"green\">(FeedBack Left)</font>"; 
                    }                 
                 else {
                    $sellerrating = "<A HREF=\"$ENV{'SCRIPT_NAME'}?action=getform&ALIAS=$firstbid[0]&ITEM=$bid\">
(Rate the seller)</a>";
                    }

                if (($#bids > 0) && ($dutch eq 'no') && ($lastbid[0] eq $form{'ALIAS'}) && ($lastbid[2] >= $reserve)) {    

         $rowcount++;                         
         if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};   
                          
                        print "<TR><TD BORDER=1 BGCOLOR=$itemrowcolor><A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewcloseddisp&ALIAS=$form{'ALIAS'}&BIDTOVIEW=$bid\">$itemnum</A></TD>
<TD BGCOLOR=$itemrowcolor>$title $sellerrating</TD>
<TD BGCOLOR=$itemrowcolor>$numbids</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$firstbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$lastbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$firstbid[0]</TD>
<TD BGCOLOR=$itemrowcolor>$closetime</TD></TR>\n";
        }

        }
        }
        if ($icount <= 0){
            print "<TR><TD COLSPAN=7 BGCOLOR=$config{'colortablebody'}><b>No Auction Items to View</b></TD></TR>";
        }        
        print "</TABLE>\n";
        &pagebreak($pcount,$pagebreak);  
        print "</CENTER></b>";                

}         

#-#############################################
# Sub: View Closed 4 login
# This displays closed items

sub viewclosed4login {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

        print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><H2>View Closed Items<br>DUTCH ITEMS YOU BID ON AND WON IN THE LAST $config{'closedays'} DAYS</H2>

<TABLE WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<INPUT TYPE=HIDDEN NAME=action VALUE=viewclosed4list>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Please Note: The closed auctions are deleted $config{'closedays'} after closing!</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TD></TR></TABLE>
<INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

##############################################
# Sub: View Closed 4 List
# This displays closed items

sub viewclosed4list {

        ### Security Check and Remove possible violations ###############
        $form{'ALIAS'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'ALIAS'} =~ s/alert//g; 
        $form{'ALIAS'} =~ s/script//g;  
        $form{'PASSWORD'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'PASSWORD'} =~ s/alert//g; 
        $form{'PASSWORD'} =~ s/script//g; 
        ### END Security Check and Remove possible violations ###############

        $form{'ALIAS'} =~ s/\W//g;
        $form{'ALIAS'} = lc($form{'ALIAS'});
        $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        &oops('ALIAS') unless (open(REGFILE,"$config{'regdir'}/$form{'ALIAS'}.dat"));
        my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <REGFILE>;
        chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        close REGFILE;
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));  
  
################## list all dutch auctions the user has won #####################
    if ($config{'dutchauctions'} eq "yes") {
        print "<center>";
        
        print"<H2>DUTCH ITEMS YOU HAVE BID ON AND WON IN THE LAST $config{'closedays'} DAYS:</H2>\n";
        print"<H3>Below is a list of auctions that user $form{'ALIAS'} won.</H3>\n";

        print"<TABLE WIDTH=100% align=center border=1>\n";
        print "<TR><TD width=10% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Item Number</center></TD>
<TD width=35% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Title</center></TD>
<TD width=5% BORDER=1 BGCOLOR=$config{'colortablehead'}>Num of Bids</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Dutch Price</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Total Ordered Quantity</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Dutch Bidder</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Closed On</TD></TR>\n";

             my $rowcount = 0;   
             my $pagebreak = int $form{pb} || 30;
             my ($icount, $pcount) = (0,0);
             my $bid;
             foreach $bid (@past_bids) {
             #foreach $bid (sort { $b <=> $a } @past_bids) {  
                  if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
                     open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
                         my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
                         close THEFILE;
                         chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);

                my @lastbid = split(/\[\]/,$bids[$#bids]);
                my @firstbid = split(/\[\]/,$bids[0]);
                $bid =~ s/\.dat//; 
                my $numbids = $#bids; 
                my $itemnum;
                $itemnum = $bid;                         
                $itemnum =~ s/\.dat//; 
                $itemnum =~ /(\d{10})$/;
                $itemnum = $1;    

                                               my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }      

                      my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};   
                      } 

#### Dutch Items you have bidded on and won ###    
                for (my $i=1; $i<scalar(@bids); $i++) {
                my ($alias, $email, $dutchbid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$i]);
   
                open FEEDFILE, "$config{'feeddir'}/$firstbid[0].dat";                
	        my ($positive, $neutral, $negative, @userfeeds) = <FEEDFILE>;
	        close FEEDFILE;
        	chomp($positive, $neutral, $negative, @userfeeds);
                
                my ($match, $feed, @thefeed, $sellerrating);               
                foreach $feed (@userfeeds) { 
	             @thefeed = split(/\[\]/,$feed);  
 
        if (($thefeed[1] eq $bid) && ($thefeed[0] eq $alias)) {$match = "1"}

                 }
                 
                 if ($match eq "1") {
	            $sellerrating = "<font color=\"green\">(FeedBack Left)</font>"; 
                    }                 
                 else {
                    $sellerrating = "<A HREF=\"$ENV{'SCRIPT_NAME'}?action=getform&ALIAS=$firstbid[0]&ITEM=$bid\">
(Rate the seller)</a>";
                    }

           if (($#bids > 0) && ($dutch eq 'yes') && ($alias eq $form{'ALIAS'})) {

         $rowcount++;                         
         if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};   

                print "<TR><TD BORDER=1 BGCOLOR=$itemrowcolor><A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewcloseddisp&ALIAS=$form{'ALIAS'}&BIDTOVIEW=$bid&DUTCHBIDDER=$alias\">$itemnum</A></TD>
<TD BGCOLOR=$itemrowcolor>$title $sellerrating</TD>
<TD BGCOLOR=$itemrowcolor>$numbids</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$dutchbid</TD>
<TD BGCOLOR=$itemrowcolor>X $oqty</TD> 
<TD BGCOLOR=$itemrowcolor>$alias</TD>
<TD BGCOLOR=$itemrowcolor>$closetime</TD></TR>\n";
               }            
               }   
                 
        }
        }
         if ($icount <= 0){
            print "<TR><TD COLSPAN=7 BGCOLOR=$config{'colortablebody'}><b>No Auction Items to View</b></TD></TR>";
        }        
        print "</TABLE>\n";
        &pagebreak($pcount,$pagebreak);
        print "</CENTER></b>"; 
}                 

} 

#-#############################################
# Sub: View Closed 5 login
# This displays closed items

sub viewclosed5login {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

        print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><H2>View Closed Items<br>ITEMS NOT RELISTED THAT YOU DID NOT SELL NO BIDS PLACED IN THE LAST $config{'closedays'} DAYS</H2>

<TABLE WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<INPUT TYPE=HIDDEN NAME=action VALUE=viewclosed5list>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Please Note: The closed auctions are deleted $config{'closedays'} after closing!</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TD></TR></TABLE>
<INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

##############################################
# Sub: View Closed 5 List
# This displays closed items

sub viewclosed5list {

        ### Security Check and Remove possible violations ###############
        $form{'ALIAS'} =~ s/[\>\<\"\'\}\{\)\(\%\&\+\\]//g; 
        $form{'ALIAS'} =~ s/alert//g; 
        $form{'ALIAS'} =~ s/script//g;  
        $form{'PASSWORD'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'PASSWORD'} =~ s/alert//g; 
        $form{'PASSWORD'} =~ s/script//g; 
        ### END Security Check and Remove possible violations ###############

        $form{'ALIAS'} =~ s/\W//g;
        $form{'ALIAS'} = lc($form{'ALIAS'});
        $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        &oops('ALIAS') unless (open(REGFILE,"$config{'regdir'}/$form{'ALIAS'}.dat"));
        my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <REGFILE>;
        chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        close REGFILE;
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));  
  
################## list all auctions the User listed and no bids placed ###############  
        print "<center>";
       
        print"<H2>ITEMS NOT RELISTED THAT YOU DID NOT SELL NO BIDS PLACED IN THE LAST $config{'closedays'} DAYS:</H2><H4>These can be relisted<H4>\n";

        print"<TABLE WIDTH=100% align=center border=1>\n";
        print "<TR><TD width=10% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Item Number</center></TD>
<TD width=35% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Title</center></TD>
<TD width=5% BORDER=1 BGCOLOR=$config{'colortablehead'}>Num of Bids</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Opening Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Last Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>High Bidder</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Closed On</TD></TR>\n";

             my $bid;
             my $rowcount = 0;   
             my $pagebreak = int $form{pb} || 30;
             my ($icount, $pcount) = (0,0);
             foreach $bid (@past_bids) {
             #foreach $bid (sort { $b <=> $a } @past_bids) {   
                  if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
                     open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
                         my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
                         close THEFILE;
                         chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);

                my @lastbid = split(/\[\]/,$bids[$#bids]);                                   
                my @firstbid = split(/\[\]/,$bids[0]);
                $bid =~ s/\.dat//; 
                my $numbids = $#bids; 
                my $itemnum;
                $itemnum = $bid;                         
                $itemnum =~ s/\.dat//; 
                $itemnum =~ /(\d{10})$/;
                $itemnum = $1;                     
                
                               my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }      

                      my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};   
                      }  

         ## list all auctions the User listed and no bids placed #### 
         if (($#bids eq 0) && ($firstbid[0] eq $form{'ALIAS'}) && ($relist eq $relistcnt)) {
         $rowcount++;                         
         if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};    
   
                       print "<TR><TD BORDER=1 BGCOLOR=$itemrowcolor><A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewcloseddisp&ALIAS=$form{'ALIAS'}&BIDTOVIEW=$bid\">$itemnum</A></TD>
<TD BGCOLOR=$itemrowcolor>$title</TD>
<TD BGCOLOR=$itemrowcolor>$numbids</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$firstbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$lastbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$lastbid[0]</TD>
<TD BGCOLOR=$itemrowcolor>$closetime</TD></TR>\n";
        }

        }
        }
         if ($icount <= 0){
            print "<TR><TD COLSPAN=7 BGCOLOR=$config{'colortablebody'}><b>No Auction Items to View</b></TD></TR>";
        }        
        print "</TABLE>\n";
        &pagebreak($pcount,$pagebreak);
        print "</CENTER></b>";                

}   

#-#############################################
# Sub: View Closed 6 login
# This displays closed items

sub viewclosed6login {

              my ($loginalias, $loginpassword) = setlogin();
              $loginalias = ucfirst lc $loginalias;
              my($password, $undef) = &read_reg_file($loginalias);
              if(lc $password ne lc $loginpassword || $password eq ''){ $loginalias = $loginpassword = '' }

        print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<CENTER><H2>View Closed Items<br>ITEMS NOT RELISTED THAT YOU HAD BIDS ON BUT LESS THAN YOUR RESERVE IN THE LAST $config{'closedays'} DAYS</H2>

<TABLE WIDTH="75%" BORDER="0" cellspacing="0" cellpadding="0">
<INPUT TYPE=HIDDEN NAME=action VALUE=viewclosed6list>
<TR><TD COLSPAN=2 BGCOLOR=$config{'colortablehead'}><b>Please Note: The closed auctions are deleted $config{'closedays'} after closing!</b></TD></TR>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Username:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30 VALUE=$loginalias>
<TR><TD BGCOLOR=$config{'colortablebody'}><B>Your Password:<BR></B>Required for verification</TD>
<TD BGCOLOR=$config{'colortablebody'}><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30 MAXLENGTH=30 VALUE=$loginpassword>
</TD></TR></TABLE>
<INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

##############################################
# Sub: View Closed 6 List
# This displays closed items

sub viewclosed6list {

        ### Security Check and Remove possible violations ###############
        $form{'ALIAS'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'ALIAS'} =~ s/alert//g; 
        $form{'ALIAS'} =~ s/script//g;  
        $form{'PASSWORD'} =~ s/[\>\<\"\'\}\{\)\(\=\%\&\+]//g; 
        $form{'PASSWORD'} =~ s/alert//g; 
        $form{'PASSWORD'} =~ s/script//g; 
        ### END Security Check and Remove possible violations ###############

        $form{'ALIAS'} =~ s/\W//g;
        $form{'ALIAS'} = lc($form{'ALIAS'});
        $form{'ALIAS'} = ucfirst($form{'ALIAS'});
        &oops('ALIAS') unless (open(REGFILE,"$config{'regdir'}/$form{'ALIAS'}.dat"));
        my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <REGFILE>;
        chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        close REGFILE;
        &oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));  
  
###### list all auctions the User listed bids placed but less than reserve ########### 
        print "<center>";
       
        print"<H2>ITEMS NOT RELISTED THAT YOU HAD BIDS ON BUT LESS THAN YOUR RESERVE IN THE LAST $config{'closedays'} DAYS:</H2><H4>These can be relisted<H4>\n";

        print"<TABLE WIDTH=100% align=center border=1>\n";
        print "<TR><TD width=10% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Item Number</center></TD>
<TD width=35% BORDER=1 BGCOLOR=$config{'colortablehead'}><center>Title</center></TD>
<TD width=5% BORDER=1 BGCOLOR=$config{'colortablehead'}>Num of Bids</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Opening Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Last Bid</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>High Bidder</TD>
<TD width=12% BORDER=1 BGCOLOR=$config{'colortablehead'}>Closed On</TD></TR>\n";

            my $rowcount = 0;   
            my $pagebreak = int $form{pb} || 30;
            my ($icount, $pcount) = (0,0);
            my $bid;
            foreach $bid (@past_bids) {
            #foreach $bid (sort { $b <=> $a } @past_bids) {   
               if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
                  open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
                  my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
                  close THEFILE;
                  chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);

                my @lastbid = split(/\[\]/,$bids[$#bids]);                                   
                my @firstbid = split(/\[\]/,$bids[0]); 
                $bid =~ s/\.dat//;
                my $numbids = $#bids;
                my $itemnum;
                $itemnum = $bid;                         
                $itemnum =~ s/\.dat//; 
                $itemnum =~ /(\d{10})$/;
                $itemnum = $1; 

                                               my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }      

                      my $itemrowcolor;
                      if ($rowcount % 2 == 1) {
                      $itemrowcolor=$config{'colorevenrow'};
                      }
                      else {
                      $itemrowcolor=$config{'coloroddrow'};   
                      }
         
          if (($#bids > 0) && ($firstbid[0] eq $form{'ALIAS'}) && ($lastbid[2] < $reserve) && ($relist eq $relistcnt)) {                
                
         $rowcount++;                         
         if(++$icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page};   

                       print "<TR><TD BORDER=1 BGCOLOR=$itemrowcolor><A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewcloseddisp&ALIAS=$form{'ALIAS'}&BIDTOVIEW=$bid\">$itemnum</A></TD>
<TD BGCOLOR=$itemrowcolor>$title</TD>
<TD BGCOLOR=$itemrowcolor>$numbids</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$firstbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$config{'currencytype'}$lastbid[2]</TD>
<TD BGCOLOR=$itemrowcolor>$lastbid[0]</TD>
<TD BGCOLOR=$itemrowcolor>$closetime</TD></TR>\n";
        }

        }
        }
        if ($icount <= 0){
            print "<TR><TD COLSPAN=7 BGCOLOR=$config{'colortablebody'}><b>No Auction Items to View</b></TD></TR>";
        }        
        print "</TABLE>\n";
        &pagebreak($pcount,$pagebreak); 
        print "</CENTER></b>";                

} 

#-#############################################
# Sub: View Closed disp
# This displays closed items

sub viewcloseddisp {

        ### Security Check and Remove possible violations ###############
        $form{'BIDTOVIEW'} =~ s/\W//g;
        $form{'BIDTOVIEW'} =~s/[;<>\*\|'&\$!?#\(\)\[\]\{\}:'"\\]//go;
        ### END Security Check and Remove possible violations ###############
   
        open (THEFILE, "$config{'basepath'}$config{'closedir'}/$form{'BIDTOVIEW'}.dat") or &oops('We cannot open the item you are looking for.  This could be a server read issue.');
        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <THEFILE>;
        close THEFILE;
        chomp($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
        my ($highbidder, $reservemsg, $sellerpage, $bidderpage);
        my $backto = &backto;                  

        my $nowtime = strftime "%a %b %d, %I:%M %p", gmtime(time + ($config{'systemtime'}* 3600 ));       

        my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = &read_feature($feature); #read features
 
        my ($selleralias, $selleremail, $bid, $sellertime, $selleradd1, $selleradd2, $selleradd3, $selleroqty, $sellersoldqty) = &read_bid($bids[0]); # read first bid 

        my @lastbid = split(/\[\]/,$bids[$#bids]);
        my $bidstart = localtime($sellertime);
        my $numbids = $#bids;  
        my $firstbid = $bid;          
        my $location = $selleradd3;  
            my $itemnum;
            $itemnum = $form{'BIDTOVIEW'};                      
            $itemnum =~ s/\.dat//; 
            $itemnum =~ /(\d{10})$/;
            $itemnum = $1;                   
      
      my ($alias, $email, $lastbid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$numbids]); # read last bid   
            
                                       my ($closetime, $closetime1, $closetime2);
                if ($lastbid[10] eq "endearly") {
                $closetime2 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[11] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Seller Closed Early</font> $closetime2";
                }   
                elsif ($lastbid[9] ne "") {
                $closetime1 = strftime "%a %b %d, %I:%M %p", gmtime($lastbid[3] + ($config{'systemtime'}* 3600 ));    
                $closetime = "<font color=\"red\">Buy It Used</font> $closetime1";
                }                 
                else {
                $closetime = strftime "%a %b %d, %I:%M %p", gmtime($itemnum + ($config{'systemtime'}* 3600 ));                
                }            
	my $timeremain = time_remain($form{item}); 

                if ($dutch eq 'yes') {  
                $alias = $form{'DUTCHBIDDER'};
                }

        $reservemsg = "";
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=2>(Reserve not met)</FONT>" if (($lastbid < $reserve) && ($dutch eq 'no'));
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=2>(Reserve met)</FONT>" if (($lastbid >= $reserve) && ($reserve > 0) && ($dutch eq 'no'));
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=2>(No Reserve)</FONT> " if (($reserve <= 0)  && ($dutch eq 'no')); 
        $reservemsg = "<FONT FACE=\"Arial\" COLOR=\"#FFOOOO\" SIZE=2>(Dutch Fixed Price)</FONT> " if ($dutch eq 'yes');
      
                open (FEEDFILE, "$config{'feeddir'}/$selleralias.dat");
                my ($spositive, $sneutral, $snegative, @suserfeeds) = <FEEDFILE>;
		close FEEDFILE;
		chomp($spositive, $sneutral, $snegative, @suserfeeds);
		my $sellerrating = $spositive - $snegative;                  
                my $sellervotes = $spositive + $sneutral + $snegative;

  my $star1s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($sellerrating >= '4');
  my $star2s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($sellerrating >= '8');
  my $star3s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($sellerrating >= '12');
  my $star4s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($sellerrating >= '16');
  my $star5s = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($sellerrating >= '20');

                open (FEEDFILE, "$config{'feeddir'}/$alias.dat");
                my ($bpositive, $bneutral, $bnegative, @buserfeeds) = <FEEDFILE>;
		close FEEDFILE;
		chomp($bpositive, $bneutral, $bnegative, @buserfeeds);
		my $bidderrating = $bpositive - $bnegative;
                my $biddervotes = $bpositive + $bneutral + $bnegative;

  my $star1b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($bidderrating >= '4');
  my $star2b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($bidderrating >= '8');
  my $star3b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($bidderrating >= '12');
  my $star4b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($bidderrating >= '16');
  my $star5b = "<img src=\"$config{'imagedir'}/stargreen.gif\" hight=10 width=10 border=0>" if ($bidderrating >= '20');
                   
        if ($alias eq $selleralias){
	$highbidder = "<font color=red>No bids yet</font>";                		
	}
	else {
	$highbidder = "<font color=green><b>$alias</b></font> <A HREF=\"$ENV{'SCRIPT_NAME'}?action=viewrate&ALIAS=$alias\">
(bidders's feedback:<font color=red>( $bidderrating )</font> $star1b $star2b $star3b $star4b $star5b)</a> - <a href=\"$ENV{'SCRIPT_NAME'}?action=search&searchtype=viewother&searchstring=$alias\">(bidders auctions)</a>";
	}   
                           
         if (-f "$config{'basepath'}$config{'mypagedir'}/$selleralias.me") {
         $sellerpage ="
<A HREF=\"$ENV{'SCRIPT_NAME'}?action=showme&user=$selleralias\">(View My Page)</a>";
        }
        else {
        print "";
        }
         
        if (($#bids) && (-f "$config{'basepath'}$config{'mypagedir'}/$alias.me")) {
        $bidderpage ="
 - <A HREF=\"$ENV{'SCRIPT_NAME'}?action=showme&user=$alias\">(View My Page)</a>";
        }        
        else {
        print "";
        }

          my $grabberpic = "";
          $grabberpic = "<IMG SRC=\"$config{'grabber1'}\" border=\"0\">" if ($grabber eq "grab1");
          $grabberpic = "<IMG SRC=\"$config{'grabber2'}\" border=\"0\">" if ($grabber eq "grab2");
          $grabberpic = "<IMG SRC=\"$config{'grabber3'}\" border=\"0\">" if ($grabber eq "grab3");
          $grabberpic = "<IMG SRC=\"$config{'grabber4'}\" border=\"0\">" if ($grabber eq "grab4");
          $grabberpic = "<IMG SRC=\"$config{'grabber5'}\" border=\"0\">" if ($grabber eq "grab5");
          $grabberpic = "<IMG SRC=\"$config{'grabber6'}\" border=\"0\">" if ($grabber eq "grab6");
          $grabberpic = "<IMG SRC=\"$config{'grabber7'}\" border=\"0\">" if ($grabber eq "grab7");
          $grabberpic = "<IMG SRC=\"$config{'grabber8'}\" border=\"0\">" if ($grabber eq "grab8"); 

          my $bgmusic = "";
          $bgmusic = "$config{'music1'}" if ($form{'MUSIC'} eq "music1");
          $bgmusic = "$config{'music2'}" if ($form{'MUSIC'} eq "music2");
          $bgmusic = "$config{'music3'}" if ($form{'MUSIC'} eq "music3");
          $bgmusic = "$config{'music4'}" if ($form{'MUSIC'} eq "music4");
          $bgmusic = "$config{'music5'}" if ($form{'MUSIC'} eq "music5");
          $bgmusic = "$config{'music6'}" if ($form{'MUSIC'} eq "music6");
          $bgmusic = "$config{'music7'}" if ($form{'MUSIC'} eq "music7");
          $bgmusic = "$config{'music8'}" if ($form{'MUSIC'} eq "music8");

if ($config{'backgroungmusic'} eq 'yes') {
    print <<"EOF";
<embed src="$bgmusic" width="0" height="0" loop="true" autoplay="true" hidden="true">
EOF
}

        print <<"EOF";
<p align="center"><b>$backto</b></p>
<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4"><b>$grabberpic $title</b></font></td>
  </tr>
  <tr>
    <td align="center" width="100%"><font size="3"><b>Item #$itemnum</b></font><br><center><!---<b>Seller FeedBack: <A HREF="$ENV{'SCRIPT_NAME'}?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}">[ Rating: $sellerrating ] [ Number of Votes/Comments: $sellervotes ]</a></font></b></center></td>--->
  </tr>
</table>
</div>

<p></p>

<p align="center">Current Time: $nowtime $config{'timezone'}</p>
EOF

           if ($usecounter eq "Yes") {    
   open(READCOUNT,"$config{'basepath'}$config{'countdir'}/$form{'item'}.dat");
   my $totalReads = <READCOUNT>;
   chomp $totalReads;
   close(READCOUNT);
                          
print <<"EOF";
<table align="center" border="0" bgcolor="#EEEEEE"><tr><td>
<CENTER><FONT SIZE="3">This closed item was viewed ( <b>$totalReads</b> )times</FONT></CENTER></td></table>
EOF
            } 

        print <<"EOF";
<div align="center">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td width="10%" rowspan="10" valign="top" align="left"><a href="#DESC"><img src=$config{'descicon'} alt="Show description"
    border="0" WIDTH="50" HEIGHT="50"></a><br>
    <a href="#BID"><img src=$config{'bidicon'} alt="Bid!"
    border="0" WIDTH="50" HEIGHT="50"></a><br>
    </td>
    <td width="30%">Current Bid: <b>$config{'currencytype'}$lastbid</b> $reservemsg</td>
    <td width="1%"></td>
    <td width="30%">First bid: <b>$config{'currencytype'}$firstbid</b> </td>    
  </tr>
  <tr>
    <td width="30%">Dutch Auction: <b>$dutch</b></td>
    <td width="1%"></td>
    <td width="30%">Quantity: <b>$qty</b>  Sold: <b>$soldqty</b></td>    
  </tr>
  <tr>
    <td width="30%">Time left: <b>$timeremain</b></td>
    <td width="1%"></td>
    <td width="30%">Number of bids: <b>$#bids</b> <a href="#HIST">(bid history)</a></td>    
  </tr>
  <tr>
    <td width="30%">Started: <b>$bidstart</b></td>
    <td width="1%"></td>
    <td width="30%">Seller's Location: <b>$location</b></td>    
  </tr>
  <tr>
    <td width="30%">Closed on: <b>$closetime</b></td>
    <td width="1%"></td>
    <td width="30%">Ask seller a Question: <A HREF="$ENV{'SCRIPT_NAME'}?action=askquestion&category=$form{'category'}&item=$itemnum">(ask or view Q&A)</a></td>   
  </tr>
</table>
</div>
</font>

<div align="center">
<table border="0" cellpadding="8" cellspacing="0" width="100%">
  <tr>
    <td><p></td>  
  </tr>   
  <tr>
    <td width="50%">Seller: <font color=green><b>$selleralias</b></font> <A HREF="$ENV{'SCRIPT_NAME'}?action=viewrate&ALIAS=$selleralias&ITEM=$form{'item'}">(sellers's feedback:<font color=red>( $sellerrating )</font> $star1s $star2s $star3s $star4s $star5s)</a> - <a href="$ENV{'SCRIPT_NAME'}?action=search&searchtype=viewother&searchstring=$selleralias">(sellers other auctions)</a> - $sellerpage</td>  
  </tr>
  <tr>
    <td><p></td>  
  </tr>       
  <tr>
    <td width="50%">High bidder: $highbidder $bidderpage</td>    
  </tr>
  <tr>
    <td><p></td>  
  </tr>   
 <tr>
    <td width="30%">Payment Options: <b>$payment</b></td>     
  </tr>   
  <tr>
    <td width="30%">Shipping Terms: <b>$shipping</b></td>  
  </tr>   

  <tr>
    <td width="30%">Condition of Item: <b>$condition</b></td>  
  </tr>
  <tr>
    <td><p></td>  
  </tr>
  <tr>
    <td><p align="center"><font size=2 face="Arial">Seller assumes all responsibility for listing this item.<br>
    You should contact the seller to resolve any questions before bidding.<br>
    Currency is $config{'currencytype2'} unless otherwise noted.</font></td>
  </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4" color="#000000"><b><a name="DESC"></a><center>Description</center></b></font></td>
  </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width=675>
  <tr>
    <td>
<blockquote>
<p>$desctitcolor</p>
<p>$desctitsize</p>
<p><center>$desctit</center></p>
</FONT></FONT></BOLD></B></I></U></H1></H2></H3></H4></H5></CENTER></HTML></BODY></HEAD>
</blockquote>
   </td>
   </tr>
</table>
</div>

<div align="center">
<table border="0" cellspacing="0" width="675">
  <tr>
    <td>
<blockquote>
<p>$desccolor</p>
<p>$descsize</p>
<p>$desc</p>
</FONT></FONT></BOLD></B></I></U></H1></H2></H3></H4></H5></CENTER></HTML></BODY></HEAD>
</blockquote>
   </td>
   </tr>
</table>
</div>

<div align="center">
<SCRIPT LANGUAGE="JavaScript">
function EnlargeImage(name) {
newsrc = name;
document.images.large.src = newsrc;
}
</SCRIPT>
EOF
if ($image1 ne "") {
print <<"EOF";
<table align="center" border="0" width="100%">
<tr>
<td><img name="large" SRC="$image1" BORDER="0"><br><br><br></td>      
EOF
}
if ($image2 ne "") {
print <<"EOF";
<td>
<table border="0"><tr><td colspan="2" align="center"><b>Click Thumbnails For Larger Picture</b></td>
</tr>
EOF
}
if ($image2 ne "") {
print <<"EOF";
<tr>
<td><a href="javascript:EnlargeImage('$image1')"><img SRC="$image1" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($image2 ne "") {
print <<"EOF";
<td><a href="javascript:EnlargeImage('$image2')"><img SRC="$image2" BORDER="0" WIDTH="75"></a></td>
</tr>
EOF
}
if ($image3 ne "") {
print <<"EOF";
<tr>
<td><a href="javascript:EnlargeImage('$image3')"><img SRC="$image3" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($image4 ne "") {
print <<"EOF";
<td><a href="javascript:EnlargeImage('$image4')"><img SRC="$image4" BORDER="0" WIDTH="75"></a></td>
EOF
}
if ($image1 ne "") {
print <<"EOF";
</tr>
</table>
</tr>
</table>
</div>
EOF
}

print <<"EOF";
<div align="center">
<table border="0" cellspacing="0" width="100%" bgcolor="$config{'colortablehead'}">
  <tr>
    <td align="center" width="100%"><font size="4" color="#000000"><b><a name="HIST"></a><center>Bid History</center></b></font></td>
  </tr>
</table>
</div>
</div>
EOF

## Start Bid History ######################    
        my $lowest_new_bid;
        if ($#bids) {                
                        my $bidtime = strftime "%a %b %d, %I:%M %p", gmtime($time + ($config{'systemtime'}* 3600 ));
###### Dutch
                if (($selleralias eq $form{'ALIAS'}) && ($lastbid >= $reserve) && ($dutch eq 'no')) {
print "<P><H2>Congratulations on selling your item!</H2><P>\n";
print "<B>Buyer Contact Information:</B><BR><b><I>Alias</I></b>: $alias<BR><b><I>E-Mail</I></b>: $email<BR><P><b><I>Name and Address</I></b>:<BR>$add1<BR>$add2<BR>$add3<P><B>The Winning Bid:</B> $config{'currencytype'}$lastbid<P>\n";                        
                        print "<br>";
                }
                else {
                if (($selleralias eq $form{'ALIAS'}) && ($dutch eq 'yes')) {
                   print "<p><H2>Buyers info on your dutch auction</H2><hr>";
                        for (my $i=1; $i<scalar(@bids); $i++) {
                        my ($alias, $email, $dutchbid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$i]);
                        
                    print "<B>Buyer Contact Information:</B><BR><b><I>Bidders Alias:</I></b> $alias<BR><b><I>Bidders E-Mail:</I></b> $email<BR><P><b><I>Real Name:</I></b> $add1<BR><b><I>Address:</b></I> $add2<BR><b><I>City and State:</b></I> $add3<P><B>Dutch bid and quanity ordered:</B><br> $config{'currencytype'}$dutchbid X the quantity of: $oqty</B>"; 
                    print "<hr>";
                }                
                }
}
}

       if (($#bids) && ($selleralias ne $form{'ALIAS'}) && ($dutch eq 'yes')) {
           for (my $i=1; $i<scalar(@bids); $i++) {
           my ($alias, $email, $dutchbid, $time, $add1, $add2, $add3, $oqty, $soldqty) = &read_bid($bids[$i]);

           if ($form{'ALIAS'} eq $alias) {
              print "<P><H2>Your Dutch Bid and Quantity: $oqty X $config{'currencytype'}$lastbid</H2>";
print "<P><B>Seller Contact Information:</B><BR><b><I>Alias</I></b>: $selleralias<BR><b><I>E-Mail</I></b>: $selleremail<BR><P><b><I>Name and Address</I></b>:<BR>$selleradd1<BR>$selleradd2<BR>$selleradd3<P>\n";
          }
          }
          }  

if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($qty > $soldqty) && ($relist eq $relistcnt) && ($dutch eq 'yes')) {
print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><b>Since this is a dutch auction and all your items did not sell, you may repost THIS item if you want to:</b>
<INPUT TYPE=SUBMIT VALUE=\"Repost\">
<INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\">
<INPUT TYPE=HIDDEN NAME=DUTCHREPOST VALUE=\"$form{'BIDTOVIEW'}\">
</FORM>\n";
}
if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($qty > $soldqty) && ($relist > $relistcnt) && ($dutch eq 'yes')) {
print "<h2>THIS ITEM WAS AUTO RELISTED ALL YOUR DUTCH ITEMS WHERE NOT SOLD</h2>\n";
}
if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($qty eq $soldqty) && ($relist > $relistcnt) && ($dutch eq 'yes')) {
print "<h2>ALL YOUR DUTCH WAS SOLD</h2>\n";
}
else {
if (($#bids eq 0) && ($selleralias eq $form{'ALIAS'}) && ($lastbid eq $bid) && ($relist eq $relistcnt) && ($dutch eq 'yes')) {
print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><b>Since NO BIDS WHERE PLACED the dutch item(s) you may repost this dutch auction if you want to:</b>
<INPUT TYPE=SUBMIT VALUE=\"Repost\">
<INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\">
<INPUT TYPE=HIDDEN NAME=REPOST VALUE=\"$form{'BIDTOVIEW'}\">
</FORM>\n";
}
if (($#bids eq 0) && ($selleralias eq $form{'ALIAS'}) && ($lastbid eq $bid) && ($relist > $relistcnt) && ($dutch eq 'yes')) {
print "<h2>THE DUTCH ITEM(s) WAS AUTO RELISTED NO BIDS WERE PLACED</h2>\n";
}
}

######## End Dutch   
############Author USANet Creations.com###################  
if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($lastbid < $reserve) && ($relist eq $relistcnt) && ($dutch eq 'no')) {
print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><b>Since the reserve was not met, you may repost THIS item if you want to:</b> 
<INPUT TYPE=SUBMIT VALUE=\"Repost\">
<INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\">
<INPUT TYPE=HIDDEN NAME=REPOST VALUE=\"$form{'BIDTOVIEW'}\">
</FORM>\n";
}
if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($lastbid < $reserve) && ($relist > $relistcnt) && ($dutch eq 'no')) {
print "<h2>THIS ITEM WAS AUTO RELISTED RESERVE WAS NOT MET</h2>\n";
}
if (($#bids) && ($selleralias ne $form{'ALIAS'}) && ($lastbid >= $reserve) && ($dutch eq 'no')) {
print "<P><H2>You were a high bidder!</H2><P>\n";
print "<B>Seller Contact Information:</B><BR><b><I>Alias</I></b>: $selleralias<BR><b><I>E-Mail</I></b>: $selleremail<BR><P><b><I>Name and Address</I></b>:<BR>$selleradd1<BR>$selleradd2<BR>$selleradd3<P><B>Your High Bid:</B> $config{'currencytype'}$lastbid<P>\n";
}
else {
if (($#bids eq 0) && ($selleralias eq $form{'ALIAS'}) && ($relist eq $relistcnt) && ($dutch eq 'no')) {
print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><b>Since this item did not sell, you may repost THIS item if you want to:</b>
<INPUT TYPE=SUBMIT VALUE=\"Repost\">
<INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\">
<INPUT TYPE=HIDDEN NAME=REPOST VALUE=\"$form{'BIDTOVIEW'}\">
</FORM>\n";
}
if (($#bids eq 0) && ($selleralias eq $form{'ALIAS'})  && ($relist > $relistcnt) && ($dutch eq 'no')) {
print "<h2>THIS ITEM WAS AUTO RELISTED NO BIDS WHERE PLACED</h2>\n";
}
}

######## Repost Sold Auction Items #########
#if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($dutch eq 'no')) {
#print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><b>This item was sold! But if you still #have more of these items to sell you may repost THIS item if you want to:</b>
#<INPUT TYPE=SUBMIT VALUE=\"Repost\">
#<INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\">
#<INPUT TYPE=HIDDEN NAME=SOLDREPOST VALUE=\"$form{'BIDTOVIEW'}\">
#</FORM>\n";
#}
######## End Repost Sold Auction Items #########

######## Repost Sold Dutch Auction Items #########
#if (($#bids) && ($selleralias eq $form{'ALIAS'}) && ($dutch eq 'yes')) {
#print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><b>All Your items where sold! But if #you still have more of these items to sell you may repost THIS item if you want to:</b>
#<INPUT TYPE=SUBMIT VALUE=\"Repost\">
#<INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\">
#<INPUT TYPE=HIDDEN NAME=DUTCHREPOST VALUE=\"$form{'BIDTOVIEW'}\">
#</FORM>\n";
#}
######## End Repost Sold Dutch Auction Items #########

}

#################################################
# Checks auction items and closes the ones
# whose ran out of time, and repost them
# at user requiest and send seller a 
# relist confirmation email.

sub chkclose {      
        my $cat;
        foreach $cat (keys %category) {
                opendir THEDIR, "$config{'basepath'}$cat" or next;                
                my @allfiles = grep -T, map "$config{'basepath'}$cat/$_", (readdir THEDIR);
                closedir THEDIR;
                my $file;
                FILE: foreach $file (@allfiles) {                                       
                        $file =~ s/^$config{'basepath'}$cat\///;
                        $file =~ s/\.dat$//;
                             
                        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($cat,$file);   
          
              my @lastbid = &read_bid($bids[$#bids]);
              my @firstbid =  &read_bid($bids[0]);  

              my $closed = int($file);
              my $start = $firstbid[3];
              my $runtime = ($closed - $start);             
             
              my $qtyleft;
              $qtyleft = $qty - $lastbid[8];

              my $new = ($runtime + time);
              $new = ($runtime + time) until (!(-e "$config{'basepath'}$cat/$new.dat"));
            
         if ((time > int($file)) && (time > (60 * $config{'aftermin'} + $lastbid[3]))) {
                     
#--Relist Section--------------------------------------#    

         ######## Relist normal auction items with bids but less than reserve ######   
         
         if (($#bids) && ($dutch eq 'no') && ($relist > $relistcnt) && ($lastbid[2] < $reserve) && ($reserve > '0.00')) {  
   
sleep 1;  # Wait 1 seconds to make sure we don't get duplicate item numbers

open REGFILE, ">>$config{'regdir'}/$firstbid[0].dat";
if ($config{'flock'}) {
flock(REGFILE, 2);
seek(REGFILE, 0, 2);
} 
print REGFILE "\n$cat$new";
close REGFILE;

++$relistcnt; 
open THEFILE, ">$config{'basepath'}$cat/$new.dat";
print THEFILE 
"$title\n$reserve\n$inc\n$desctitcolor\n$desctitsize\n$desctit\n$desccolor\n$descsize\n$desc\n$image1\n$image2\n$image3\n$image4\n$feature\n$grabber\n$dutch\n$qty\n$payment\n$condition\n$shipping\n$relist\n$relistcnt\n$gallery\n$buyit\n$music\n$usecounter";

print THEFILE "\n$firstbid[0]\[\]$firstbid[1]\[\]$firstbid[2]\[\]".time."\[\]$firstbid[4]\[\]$firstbid[5]\[\]$firstbid[6]\[\]$firstbid[7]\[\]$firstbid[8]";
close THEFILE;                

              if ($config{'relistemail'} eq "on") {
              &sendemail($firstbid[1], $config{'admin_address'}, "Your Auction Item Relisted", 
"Your auction titled: $title
Item number: $file has been relisted.
The new auction item number is: $new
Reason: Reserve not met, highest bid was $config{'currencytype'}$lastbid[2]

Click here to rview your new relisted auction item:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$cat&item=$new

Once again, thank you and please tell a friend about us!

Sincerely,
$config{'sitename'}");
  }  
                
       &sendemail($lastbid[1], $config{'admin_address'}, "Auction Ended: Item #$file \($title\)", 
"$lastbid[4]

You were the high bidder on auction number $file \($title\) Unfortunately, your bid did not meet the seller\'s reserve price...

Seller User ID: $firstbid[0]
Seller E-mail: $firstbid[1]

Your bid was in the amount of $config{'currencytype'}$lastbid[2].
Unfortunately, your bid did not meet the seller\'s reserve price...
This auction item was relisted and the new auction listing is: 
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$cat&item=$new
if you wont to try agin!

We hope you have enjoyed using the $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");

unlink("$config{'basepath'}$cat/$file.dat");
unlink("$config{'basepath'}$config{'countdir'}/$file.dat"); 
unlink ("$config{'basepath'}askseller/$file.dat");

}  
##### Relist auction items with no bids ######

           elsif (($#bids eq 0) && ($dutch eq 'no') && ($relist > $relistcnt)) {    

sleep 1;  # Wait 1 seconds to make sure we don't get duplicate item numbers
            
open REGFILE, ">>$config{'regdir'}/$firstbid[0].dat";
if ($config{'flock'}) {
flock(REGFILE, 2);
seek(REGFILE, 0, 2);
} 
print REGFILE "\n$cat$new";
close REGFILE;

++$relistcnt; 
open THEFILE, ">$config{'basepath'}$cat/$new.dat";
print THEFILE 
"$title\n$reserve\n$inc\n$desctitcolor\n$desctitsize\n$desctit\n$desccolor\n$descsize\n$desc\n$image1\n$image2\n$image3\n$image4\n$feature\n$grabber\n$dutch\n$qty\n$payment\n$condition\n$shipping\n$relist\n$relistcnt\n$gallery\n$buyit\n$music\n$usecounter";

print THEFILE "\n$firstbid[0]\[\]$firstbid[1]\[\]$firstbid[2]\[\]".time."\[\]$firstbid[4]\[\]$firstbid[5]\[\]$firstbid[6]\[\]$firstbid[7]\[\]$firstbid[8]";
close THEFILE;
                
           if ($config{'relistemail'} eq "on") {
           &sendemail($firstbid[1], $config{'admin_address'}, "Your Auction Item Relisted", 
"Your auction titled: $title
Item number: $file has been relisted.
The new auction item number is: $new
Reason: No bids were placed

Click here to rview your new relisted auction item:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$cat&item=$new

Once again, thank you and please tell a friend about us!

Sincerely,
$config{'sitename'}");              
  }  

unlink("$config{'basepath'}$cat/$file.dat");
unlink("$config{'basepath'}$config{'countdir'}/$file.dat"); 
unlink ("$config{'basepath'}askseller/$file.dat");

}  
######## Relist dutch auction items with some sold items but with items left ######

            elsif (($#bids) && ($dutch eq 'yes') && ($relist > $relistcnt) && ($qty > $lastbid[8])) {
 
sleep 1;  # Wait 1 seconds to make sure we don't get duplicate item numbers

open REGFILE, ">>$config{'regdir'}/$firstbid[0].dat";
if ($config{'flock'}) {
flock(REGFILE, 2);
seek(REGFILE, 0, 2);
} 
print REGFILE "\n$cat$new";
close REGFILE;
                             
$qty = $qty -$lastbid[8];

++$relistcnt; 
open THEFILE, ">$config{'basepath'}$cat/$new.dat";
print THEFILE 
"$title\n$reserve\n$inc\n$desctitcolor\n$desctitsize\n$desctit\n$desccolor\n$descsize\n$desc\n$image1\n$image2\n$image3\n$image4\n$feature\n$grabber\n$dutch\n$qty\n$payment\n$condition\n$shipping\n$relist\n$relistcnt\n$gallery\n$buyit\n$music\n$usecounter";

print THEFILE "\n$firstbid[0]\[\]$firstbid[1]\[\]$firstbid[2]\[\]".time."\[\]$firstbid[4]\[\]$firstbid[5]\[\]$firstbid[6]\[\]$firstbid[7]\[\]$firstbid[8]";
close THEFILE;
               
              if ($config{'relistemail'} eq "on") {                            
              &sendemail($firstbid[1], $config{'admin_address'}, "Your Auction Item Relisted", 
"Your auction titled: $title
Item number: $file has been relisted.
The new auction item number is: $new
Reason: This is a dutch auction and you still have $qtyleft items left!

Starting Quantity: $qty
Sold Quantity: $lastbid[8]
Items Left: $qtyleft

Click here to rview your new relisted auction item:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$cat&item=$new

Once again, thank you and please tell a friend about us!

Sincerely,
$config{'sitename'}");
  }

&closeit($cat,$file);  

}
###### Relist dutch auction items with no items sold, no bids ############      

            elsif (($#bids eq 0) && ($dutch eq 'yes') && ($relist > $relistcnt)) { 
  
sleep 1;  # Wait 1 seconds to make sure we don't get duplicate item numbers
                         
open REGFILE, ">>$config{'regdir'}/$firstbid[0].dat";
if ($config{'flock'}) {
flock(REGFILE, 2);
seek(REGFILE, 0, 2);
} 
print REGFILE "\n$cat$new";
close REGFILE;

++$relistcnt; 
open THEFILE, ">$config{'basepath'}$cat/$new.dat";
print THEFILE 
"$title\n$reserve\n$inc\n$desctitcolor\n$desctitsize\n$desctit\n$desccolor\n$descsize\n$desc\n$image1\n$image2\n$image3\n$image4\n$feature\n$grabber\n$dutch\n$qty\n$payment\n$condition\n$shipping\n$relist\n$relistcnt\n$gallery\n$buyit\n$music\n$usecounter";

print THEFILE "\n$firstbid[0]\[\]$firstbid[1]\[\]$firstbid[2]\[\]".time."\[\]$firstbid[4]\[\]$firstbid[5]\[\]$firstbid[6]\[\]$firstbid[7]\[\]$firstbid[8]";
close THEFILE;

              if ($config{'relistemail'} eq "on") {
              &sendemail($firstbid[1], $config{'admin_address'}, "Your Auction Item Relisted", 
"Your auction titled: $title
Item number: $file has been relisted.
The new auction item number is: $new
Reason: This is a dutch auction and there were no bids

Starting Quantity: $qty
Sold Quantity: 0

Click here to rview your new relisted auction item:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?category=$cat&item=$new

Once again, thank you and please tell a friend about us!

Sincerely,
$config{'sitename'}");
  }   

unlink("$config{'basepath'}$cat/$file.dat");
unlink("$config{'basepath'}$config{'countdir'}/$file.dat"); 
unlink ("$config{'basepath'}askseller/$file.dat");

}
#--End Relist------------------------------------------#                                  
        else {         
        &closeit($cat,$file);                      
        } 
                        }
                }
        }
        
}

#-#############################################
# Close Auction items and send seller and buyer
# an email, This sets an item's status to closed.
# and moves them to the closed dir

sub closeit {
        my ($cat,$item) = @_;
        
        if ($cat ne $config{'closedir'}) {
                my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = &read_item_file($cat,$item);
                
                my @lastbid = &read_bid($bids[$#bids]);
                my @firstbid =  &read_bid($bids[0]);   
                   my $numauct;
                   $numauct = $item;
                   $numauct =~ s/\.dat//;                                     
                            my $qtyleft;
                            $qtyleft = $qty - $lastbid[8];
                                         
          if (($#bids) && ($lastbid[2] >= $reserve) && ($dutch eq 'no')) {

#--Accounting Closed Item Percentage---------#
                
         if ($config{'percentageclose'} eq "on") {
              &transaction_percentage_closed($firstbid[0], "Auction closed, #$numauct ($title)", "$firstbid[2]", "$lastbid[2]", "$reserve");

}        
#--End-------------------------------------------------#                  
                        
                        &sendemail($lastbid[1], $config{'admin_address'}, "Auction closed and you WON: Item #$numauct \($title\)", 
"$lastbid[4]

Congratulations! 

You have won:
Item Title: #$numauct \($title\)
Final Price: $config{'currencytype'}$lastbid[2]

Click here to review the auction item:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?action=dispallclosed2&DISPCLOSED=$cat$numauct.dat

To make arrangements for payment, to schedule pick-up or coordinate shipping, please reply to this email.  Please indicate your preferences from the options listed below:
1.      Pay via PayPal and pick up in person.  Once you reply, you will receive a separate PayPal invoice via email.  When your payment has been received, we will then contact you to schedule your pick-up time.
2.      Pick up your item and pay in person.  When we receive your reply, we will contact you to schedule your pick-up time.
3.      If you cannot pick up your item, Call 651-407-5327 to charge by phone and coordinate shipping.

Remember: The White Bear Lake Area Historical Society will not ask you for sensitive personal information such as your password, credit card and bank account numbers, Social Security numbers, etc. in an email

Thank you for your contribution and for making this auction a success.  All proceeds benefit the White Bear Lake Area Historical Society.  We hope you have enjoyed using the White Bear Lake Area Historical Society Online Auction and will visit often!");
                        }            
                        if (($#bids) && ($lastbid[2] >= $reserve) && ($dutch eq 'no')) {
                        &sendemail($firstbid[1], $config{'admin_address'}, "Auction closed and you SOLD: Item #$numauct \($title\)", 
"$firstbid[4]

Congratulations! 

You have won:
Item Title: #$numauct \($title\)
Final Price: $config{'currencytype'}$lastbid[2]

Click here to review the auction item:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?action=dispallclosed2&DISPCLOSED=$cat$numauct.dat

To make arrangements for payment, to schedule pick-up or coordinate shipping, please reply to this email.  Please indicate your preferences from the options listed below:
1.      Pay via PayPal and pick up in person.  Once you reply, you will receive a separate PayPal invoice via email.  When your payment has been received, we will then contact you to schedule your pick-up time.
2.      Pick up your item and pay in person.  When we receive your reply, we will contact you to schedule your pick-up time.
3.      If you cannot pick up your item, Call 651-407-5327 to charge by phone and coordinate shipping.

Remember: The White Bear Lake Area Historical Society will not ask you for sensitive personal information such as your password, credit card and bank account numbers, Social Security numbers, etc. in an email

Thank you for your contribution and for making this auction a success.  All proceeds benefit the White Bear Lake Area Historical Society.  We hope you have enjoyed using the White Bear Lake Area Historical Society Online Auction and will visit often!");
                        }                                               
                        if (($#bids) && ($lastbid[2] < $reserve) && ($dutch eq 'no')) {
                        &sendemail($firstbid[1], $config{'admin_address'}, "Auction Ended: Item #$numauct \($title\)", 
"$firstbid[4]

Auction #$numauct \($title\) is now closed.

Unfortunately, You reserve price was not met. and your auto relist times has ran out or you did not select auto relist feature if not sold you may repost your item by using the closed auction manager at:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?action=closed.

Good Luck on the next time around. Thank you for using $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");
                        }              
                        if (($#bids) && ($lastbid[2] < $reserve) && ($dutch eq 'no')) {
                        &sendemail($lastbid[1], $config{'admin_address'}, "Auction Ended: Item #$numauct \($title\)", 
"$lastbid[4]

You were the high bidder on auction number $item \($title\) Unfortunately, your bid did not meet the seller\'s reserve price...

Seller User ID: $firstbid[0]
Seller E-mail: $firstbid[1]

Your bid was in the amount of $config{'currencytype'}$lastbid[2].
Unfortunately, your bid did not meet the seller\'s reserve price...
You may still wish to contact the seller to negotiate a fair price.  This does not mean that they have to reply as they are not required to sell to anyone if their reserve price was not met.
If you do wish to contact them, you may do so at the following e-mail address.
$firstbid[1]

We hope you have enjoyed using the $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");                       
                        }            
                        if (($#bids eq 0) && ($dutch eq 'no')) {
                        &sendemail($firstbid[1], $config{'admin_address'}, "Auction Ended: Item #$numauct \($title\)", 
"$firstbid[4]

Auction #$numauct \($title\) is now closed.

Unfortunately, there were no bids on your item. and your auto relist times has ran out or you did not select auto the relist feature if not sold, you may repost your item by using the closed auction manager at:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?action=closed

Good Luck on the next time around. Thank you for using $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");
                        }                  
                        ## Start Closing dutch auction items and send the e-mail ##
                        if (($#bids) && ($dutch eq 'yes') && ($lastbid[8] eq $qty)) {
                        &sendemail($firstbid[1], $config{'admin_address'}, "Auction Close: Item #$numauct \($title\)", 
"$firstbid[4]

Congratulations! This auction has successfully ended and all $qty dutch items were sold.
Item #$numauct \($title\)
Starting Quantity: $qty
Sold Quantity: $lastbid[8]
Items Left: $qtyleft
Item Title: $title

Now What?
The buyer and seller should have received contact info and with Quantity ordered at at the time dutch bids were placed to be able to contact each other within three business days to complete the sale. Not getting in touch leaves the contract open and can earn you negative feedback.

We hope you have enjoyed using the $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");                       
                      }  
                      if (($#bids) && ($dutch eq 'yes') && ($qty > $lastbid[8]) && ($relist eq $relistcnt)) { 
                      &sendemail($firstbid[1], $config{'admin_address'}, "Auction Close: Item #$numauct \($title\)", 
"$firstbid[4]

Congratulations! Your dutch auction has ended but you still have $qtyleft items left!
Item #$numauct \($title\)
Starting Quantity: $qty
Sold Quantity: $lastbid[8]
Items Left: $qtyleft
Item Title: $title
 
 You still have $qtyleft items left. and your auto relist times has ran out or you did not select auto the relist feature if not sold, you may repost your item by using the closed auction manager at:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?action=closed

Now What?
The buyer and seller should have received contact info a the time dutch bids were placed to be able to contact each other within three business days to complete the sale. Not getting in touch leaves the contract open and can earn you negative feedback.

We hope you have enjoyed using the $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");                     
                      }                       
                      if (($#bids eq 0) && ($dutch eq 'yes')) {
                      &sendemail($firstbid[1], $config{'admin_address'}, "Auction Close: Item #$numauct \($title\)", 
"$firstbid[4]

Your dutch auction has ended, but were no bids on your items.
Item #$numauct \($title\)
Quantity: $qty
Item Title: $title

Unfortunately, there were no bids on your item. and your auto relist times has ran out or you did not select the auto relist feature if not sold, you may repost your item by using the closed auction manager at:
$config{'scripturl'}$ENV{'SCRIPT_NAME'}?action=closed

We hope you have enjoyed using the $config{'sitename'} and will come back often!

Remember: $config{'sitename'} will not ask you for sensitive personal information 
such as your password, credit card and bank account numbers, 
Social Security numbers, etc. in an email. 

All Rights Reserved. Designated trademarks
and brands are the property of their respective owners.");
                      }                       
                      
                      if ($config{'closedir'}) {
                      umask(000);  # UNIX file permission junk
                      mkdir("$config{'basepath'}$config{'closedir'}", 0777) unless (-d "$config{'basepath'}$config{'closedir'}");             
                        print "Please notify the site admin that this item cannot be copied to the closed directory even though it is closed.\n" unless &movefile("$config{'basepath'}$cat/$item.dat", "$config{'basepath'}$config{'closedir'}/$cat$item.dat");                  
                }
                else {
                print "Please notify the site admin that this item cannot be removed even though it is closed.\n" unless unlink("$config{'basepath'}$cat/$item.dat");
                }            
        } 

}

#########################################################################
# This subroutine will delete closed auctions in the closed dir
# and item uploaded images older than X days old that you set 
# up in your config.cgi file under $config{'closedays'}

sub delclosed { 

            umask(000);  # UNIX file permission junk
            mkdir("$config{'basepath'}$config{'closedir'}", 0777) unless (-d "$config{'basepath'}$config{'closedir'}");

     opendir THEDIR, "$config{'basepath'}$config{'closedir'}" or oops("Unable to open the closed directory");
     my @allfiles = readdir THEDIR; 
     closedir THEDIR;
        my $file;
        foreach $file ( @allfiles ) {                 
              my $filetime;
              $filetime = $file;
              $filetime =~ s/\.dat//;  
              $filetime =~ /(\d{10})$/;
              #$filetime =~ s/\.dat$//; 
              #$filetime =~ s/(.+)(\d{10})$//; 
              $filetime = $1;
                              
                 if ((time - $filetime) > ($config{'closedays'} * 86400)) {
                     unlink ("$config{'basepath'}$config{'closedir'}/$file"); 
                     unlink ("$config{'basepath'}askseller/$file"); 
                     unlink("$config{'basepath'}$config{'countdir'}/$file"); 
                          
                 }
        }
}

#-#############################################
# Sub: when a user post a auction item and or bids 
# on a auction item that item number is recorded to 
# that users registration data file so after X days 
# delete the item number recorded to the user 
# registration data file.   

sub delete_sell_bid_history { 

                    $form{'ALIAS'} = lc($form{'ALIAS'});
                    $form{'ALIAS'} = ucfirst($form{'ALIAS'});   

                    open REGFILE, "$config{'regdir'}/$form{'ALIAS'}.dat";
my($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@bids) = <REGFILE>;
                    close REGFILE;
chomp($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@bids);
                 
                    open REGFILE, ">$config{'regdir'}/$form{'ALIAS'}.dat";
                    if ($config{'flock'}) {
                    flock(REGFILE, 2);
                    seek(REGFILE, 0, 2);
                    } 
                    print REGFILE "$password\n$email\n$add1\n$add2\n$add3\n$phone\n$ip\n$referral\n$refname";
                        my $bid;
                        foreach $bid (@bids) {                            
                            my $bidrecord = $bid;
                            $bidrecord =~ /(\d{10})$/;  
                            $bidrecord = $1;  
                            if (($bidrecord + ($config{'closedays'} * 86400)) > time) {
                            print REGFILE "\n$bid";
                            } 
                            }                                    
                            close REGFILE; 
                            
}

###############################################
# Sub Image Delete
# Automatically deletes images from your server 

sub delimage {

umask(000);  # UNIX file permission junk
mkdir("$config{'imagebase'}", 0777) unless (-d "$config{'imagebase'}");
mkdir("$config{'imagebase'}/temp/", 0777) unless (-d "$config{'imagebase'}/temp/");

    opendir THEDIR, "$config{'imagebase'}" or &oops("Image directory could not be opened.");
    my @allfiles = readdir THEDIR;
    closedir THEDIR;
        my $file;        
        foreach $file ( @allfiles ) {            
                my $ext = (split(/\./,$file))[-1];                    
                my $tempfile = $file;
                $tempfile =~ s/\.$ext$//;       

                my $current_time = time;       
       if ($current_time > $tempfile) {       
           unlink ("$config{'imagebase'}/$file");      
           }
        } 
&deltempimage;
}

###############################################
# Sub Temp Image Delete
# Automatically deletes temp images from your server 

sub deltempimage {
     
         #######################################
         # Set the time to delete image from temp dir
         # 60 = 1 min, 900 = 15 min
         $config{'updel'} = 900;
         #######################################

    opendir THEDIR, "$config{'imagebase'}/temp" or &oops("Image directory could not be opened."); 
    my @allfiles = readdir THEDIR;
    closedir THEDIR;
        my $file;        
        foreach $file ( @allfiles ) {             
                my $ext = (split(/\./,$file))[-1];                    
                my $tempfile = $file;
                $tempfile =~ s/\.$ext$//;                           
                     my $uptime = ($config{'delimagedays'} * 86400 + time);
                     my $comparetime = ($uptime - $tempfile);

           if ($comparetime > $config{'updel'}) {
           unlink ("$config{'imagebase'}/temp/$file");      
           }
        } 
}

#-#############################################
# Send E-mail
# This is a real quick mailer that
# should work on any platform.
# Takes:
# (To, From, Subject, Message)

sub sendemail {        
        
    my ($to,$from,$subject,$message) = @_;        
    if ($config{'smtp_addr'}) { 
    if (!$to) { return -8; }
    my ($proto, $port, $smtpaddr);
    my ($AF_INET)     =  2;
    my ($SOCK_STREAM) =  1;
    $proto = (getprotobyname('tcp'))[2];
    $port = 25;
    #$port = 587;
    $smtpaddr = ($config{'smtp_addr'} =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
                    ? pack('C4',$1,$2,$3,$4)
                    : (gethostbyname($config{'smtp_addr'}))[4];
    if (!defined($smtpaddr)) { return -1; }
    if (!socket(S, $AF_INET, $SOCK_STREAM, $proto))             { return -2; }
    if (!connect(S, pack('Sna4x8', $AF_INET, $port, $smtpaddr))) { return -3; }
    # my($oldfh) = select(S); $| = 1; select($oldfh);
    select(S);
    $| = 1;
    select(STDOUT);
    $_ = <S>; if (/^[45]/) { close S; return -4; }
    print S "Helo localhost\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }
    print S "Mail from: $from\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }   
    print S "Rcpt to: $to\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -6; }    
    print S "data\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -5; }
    print S "Content-Type: text/plain; charset=us-ascii\r\n";
    print S "To: $to\r\n";
    print S "From: $from\r\n";
    print S "Reply-to: $from\r\n" if $from;
    print S "Subject: $subject\r\n\r\n";
    print S "$message";
    print S "\r\n.\r\n";
    $_ = <S>; if (/^[45]/) { close S; return -7; }
    print S "quit\r\n";
    $_ = <S>;
    close S;
    return 1;
    }
    else {
          #open (MAIL, "|$config{'mailprog'} -t");
          open MAIL, "|$config{'mailprog'} -t";
          print MAIL "To: $to\n";
	  print MAIL "From: $from\n";
	  print MAIL "Subject: $subject\n";
	  print MAIL "Reply-To: $from\n\n";
	  print MAIL "$message\n\n";
          close MAIL;

          ### - Use this one if you have problems with AOL not getting e-mails - ###
          #open (MAIL, "|$config{'mailprog'} -i -t");
          #print MAIL "To: $to\nFrom: $from\nSubject: $subject\n\n$message\n\n";
          #close MAIL;
          }
}

#-#############################################
# Sub: Random Password
# This generates psudo-random 8-letter
# passwords

sub randompass {
        # Your Words Here:
        my @passset = qw/Money Venus Peach Oak Space Lucky Moon Typo Radio Match Clock Ping Tech/;
        srand(time ^ $$);
        my $digits;
        for (1..3){ $digits .= (0..9)[int(rand(10))] }
        my $randpass = $passset[int(rand($#passset + 1))];
        $randpass .= '-' if($randpass =~ /[iloILO\d]$/ || $digits =~ /^[01]/);
        $randpass .= $digits;
        return $randpass;
}

#-#############################################
# Sub: parse bid
# This formats a bid amount to look good...
# ie. $###.##

sub parsebid {
        $_[0] =~ s/\,//g; 
        my @bidamt = split(/\./, $_[0]);
        $bidamt[0] = "0" if (!($bidamt[0]));
        $bidamt[0] = int($bidamt[0]);
        $bidamt[1] = substr($bidamt[1], 0, 2);
        $bidamt[1] = "00" if (length($bidamt[1]) == 0);
        $bidamt[1] = "$bidamt[1]0" if (length($bidamt[1]) == 1);
        if ($config{'currencylayout'} eq 'no') {
        return "$bidamt[0]";
        }
        else {
        return "$bidamt[0].$bidamt[1]";
        }

}

#-#############################################
# Sub: Oops!
# This generates an error message and dies.

sub oops {

        print "<table align=\"center\" border=\"0\" width=\"90%\" cellspacing=0 cellpadding=0>";
        print "<tr><td width=\"90%\" bgcolor=\"$config{'colortablehead'}\">";
        print "<center><h2>User Error</center></h2>";
        print "</td></td>";
        print "<tr><td width=\"90%\" bgcolor=\"$config{'colortablebody'}\">";
        print "<p><font color=\"#FF0000\"><h3>Error:</font><br>$_[0]</h3><P>Please hit the back < button on your browser to try again or contact the auction administrator at <a href=\"mailto:$config{'admin_address'}\">$config{'admin_address'}</a> if you believe this to be a server problem.<p>\n";
        print "</td></tr>";
        print "</table>";
        print "$config{'footer'}";
        
        exit;

}

#-#############################################
# Sub: Movefile(file1, file2)
# This moves a file.  Quick and dirty!

sub movefile {
        my ($firstfile, $secondfile) = @_;
        return 0 unless open(FIRSTFILE,$firstfile);
        my @lines=<FIRSTFILE>;
        close FIRSTFILE;
        return 0 unless open(SECONDFILE,">$secondfile");
        my $line;
        foreach $line (@lines) {
                print SECONDFILE $line;
        }
        close SECONDFILE;
        return 0 unless unlink($firstfile);
        return 1;
}

#-#############################################
# Sub: Read Reg File (alias)
# Reads a registration file

sub read_reg_file {
        my $alias = shift;
        return '' unless $alias;
        # verify the user exists
        &oops('Your alias may not contain any non-word characters.') if $alias =~ /\W/;
        $alias = ucfirst(lc($alias));
        return '' unless -r "$config{'regdir'}/$alias.dat" and -T "$config{'regdir'}/$alias.dat";
        open FILE, "$config{'regdir'}/$alias.dat";
        my ($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids) = <FILE>;
        close FILE;
        chomp ($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
        return ($password,$email,$add1,$add2,$add3,$phone,$ip,$referral,$refname,@past_bids);
}

#-#############################################
# Sub: Read Item File (cat, item)
# Reads an item file

sub read_item_file {
        my ($cat, $item) = @_;
        # verify the category exists
        return '' unless ($cat) and ($item);
        &oops('The category may not contain any non-word characters.') if $cat =~ /\W/;
        return '' unless $category{$cat};
        # verify the item exists
        &oops('The item number may not contain any non-numeric characters.') if $item =~ /\D/;        
        
        return '' unless (-T "$config{'basepath'}$cat/$item.dat") and (-R "$config{'basepath'}$cat/$item.dat");

        #return '' unless 0||#1>>noconfuse(ea;-)

        open FILE, "$config{'basepath'}$cat/$item.dat";
        my ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids) = <FILE>;
        close FILE;
        chomp ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
        return ($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @bids);
}

#-#############################################
# Sub: Read Bid Information (bid_string)
# Reads an item file

sub read_bid {
        my $bid_string = shift;
        my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty) = split(/\[\]/,$bid_string);
        return ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqty, $soldqty);
}

#-#############################################
# Sub: Read Feature Information (feat_string)
# Reads an item file

sub read_feature {
        my $feat_string = shift;
        my ($feat_fp, $feat_cp, $feat_yt, $feat_bf) = split(/\[\]/,$feat_string);
        return ($feat_fp, $feat_cp, $feat_yt, $feat_bf);
}

#-#############################################
# Sub: Time Remain
# Displays Time, uh, Remain.

sub time_remain($) {

    my $diff = $_[0] - time;

    if($diff < 0){ 
    return "<font color=red>Closed</font>" 
    }

    my $days  = int ( $diff                                  / 86400);
    my $hours = int (($diff - $days * 86400)                 / 3600 );
    my $mins  = int (($diff - $days * 86400 - $hours * 3600) / 60   );
    my $secs = int ($diff-($days*86400)-($hours*3600)-($mins*60));

    if($days > 1) {
        return "<nobr>$days Days $hours Hrs</nobr>";
        }
        elsif($days == 1) {
        return "<nobr>1 Day $hours Hrs</nobr>";
        }
        elsif($hours > 12) {
        return "<nobr>$hours Hrs $mins Mins</nobr>";
        }
        elsif($hours > 0) {
        return "<nobr><font color=\"red\">$hours Hrs $mins Mins</font></nobr>";
        }
        else {
        return "<nobr><font color=\"red\">$mins Mins $secs Secs</font></nobr>";
        }

}

#-#############################################
# Checks the last time the chkclose, delclosed and delimage
# subs has run, and if longer thsn X time runs it agin
# this is to speed up the closing runtimes and reduce server load

sub checkstarttime {                                     

#########################################
# How many minutes past last run
# to start run agin. To run every time
# auction is called set to zero BUT NOT RECOMMENDED!!

$config{'nextchkclosed'} = 5; # 5 = every 5 minutes

$config{'nextdelclosed'} = 1440; # 1440 = every 24 hrs

$config{'nextdelimages'} = 720;  # 720 = every 12 hrs

######### check for closing items ###############

        open(CHKCLOSED, "$config{'basepath'}chkclosed.txt");
        my($chkclosed) = <CHKCLOSED>;        
        chomp($chkclosed);   
        close(CHKCLOSED);     

          if (($chkclosed + (60 * $config{'nextchkclosed'})) < time) {
                 open(CHKCLOSED, ">$config{'basepath'}chkclosed.txt");                 
                 print CHKCLOSED time;
                 close(CHKCLOSED); 
                      ### Run These if time has expired sence last run #### 
                      &chkclose;                       
                      ### END Run These if time has expired sence last run ####  
                      } 

######## delete expired closed items ##########

        open(DELCLOSED, "$config{'basepath'}delclosed.txt");
        my($delclosed) = <DELCLOSED>;        
        chomp($delclosed);   
        close(DELCLOSED);     

          if (($delclosed + (60 * $config{'nextdelclosed'})) < time) {
                 open(DELCLOSED, ">$config{'basepath'}delclosed.txt");                 
                 print DELCLOSED time;
                 close(DELCLOSED); 
                      ### Run These if time has expired sence last run ####
                      &delclosed;
                      ### END Run These if time has expired sence last run ####  
                      }     

######## delete expired closed uploaded images ##########

        open(DELIMAGES, "$config{'basepath'}delimages.txt");
        my($delimages) = <DELIMAGES>;        
        chomp($delimages);   
        close(DELIMAGES);     

          if (($delimages + (60 * $config{'nextdelimages'})) < time) {
                 open(DELIMAGES, ">$config{'basepath'}delimages.txt");                 
                 print DELIMAGES time;
                 close(DELIMAGES); 
                      ### Run These if time has expired sence last run ####
                      &delimage;
                      ### END Run These if time has expired sence last run ####  
                      }        
                
}

#-##########################################################
# Limit user bidding if feedback is less than X
# amount set up in the config.pl file

sub limitbidding { 
         
              umask(000);  # UNIX file permission junk              
              mkdir("$config{'feeddir'}", 0777) unless (-d "$config{'feeddir'}");
          
              my ($ItemCat, $ItemNumber, $Alias, @BidsParam) = @_; 

              my ($current_bids, $BidUpdate, $ItemBids, $bid, $User_bid, $j, $tempstring, $itemnum, $Category, @ParsedBid, @Bid_History, @ItemBids, @bids);

   if (!(-e "$config{'feeddir'}/$Alias.dat")){ 
      open(FEEDFILE, ">$config{'feeddir'}/$Alias.dat");
      print FEEDFILE "0\n0\n0\n";
      close FEEDFILE;
      }
      open(FEEDFILE, "$config{'feeddir'}/$Alias.dat");                
      my ($positive, $neutral, $negative, @userfeeds) = <FEEDFILE>;
      close FEEDFILE;
      chomp($positive, $neutral, $negative, @userfeeds);
            
            $current_bids = 0; 
            $BidUpdate = 0; 

            if (! @BidsParam) {
            my($password, $email, $add1, $add2, $add3, $phone, $ip, $referral, $refname, @bids) = &read_reg_file($Alias);
            }
            else {
            @bids = @BidsParam;
            }

        foreach $bid (@bids) { 
                $itemnum = $bid;
                $itemnum =~ s/\D+//g; 
                $itemnum =~ /(\d{10})$/;         
                $itemnum = $1;                   
                next if ($itemnum < time);
                $tempstring = substr($bid, 0, -9);  
                $tempstring = substr($bid, -10, -9);  

                        if ($tempstring =~ /[A-Za-z]/) {  
                        $tempstring = substr($bid, -9);  
                        $Category = substr($bid, 0, -9);  
                        }  
                        elsif ($tempstring =~ /[0-9]/) {   
                        $tempstring = substr($bid, -10);  
                        $Category = substr($bid, 0, -10);  
                        }  

              my($title, $reserve, $inc, $desctitcolor, $desctitsize, $desctit, $desccolor, $descsize, $desc, $image1, $image2, $image3, $image4, $feature, $grabber, $dutch, $qty, $payment, $condition, $shipping, $relist, $relistcnt, $gallery, $buyit, $music, $usecounter, @ItemBids) = &read_item_file($Category, $itemnum);               
                   
              foreach $ItemBids (@ItemBids) { 
                      if ($j == 0) { 
                      $j++; # Skip the first bid as its the sellers start bid 
                      next; 
                      } 
                      @ParsedBid = split(/\[\]/,$ItemBids); 
                      $User_bid = 1 if ($ParsedBid[0] eq $Alias); 
                      $j++; 
                      } 
                      if ($User_bid == 1) { 
                      $Bid_History[$current_bids++] = $itemnum; 
                      next; 
                      } 
              } 
              foreach $bid (@Bid_History) { 
              $BidUpdate = 1 if ($bid eq $ItemNumber); 
              }  
       
              if (($current_bids > $config{'bidsallowed'}) && ($BidUpdate eq 0)) {
                  &oops("$Alias, you may not bid on more items at the current time since you have reached the maximum allowed bid limit of ($config{'bidsallowed'}). <b>Till you have $config{'feedbackpoints'} positive feedback ratings you're only allowed to place bids on $config{'bidsallowed'} auction items or you have ($config{'bidsallowed'}) auction items posted that is counted as a bid as well.</b>") unless($positive > $config{'feedbackpoints'});
        }
              
}
