#!/usr/bin/perl
use vars qw(%config %category %form %Cats1 %Cats2 %Cats3 %Cats4 %Cats5 %Cats6 %02d);
use strict;
 
#-###########################################################################
# /usr/bin/perl
# EveryAuction Release Version 1.5 Beta 5 (2/16/00)
# Copyright (C) 2000 EverySoft
# 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.
# 
# 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:
# * Matt Hahnfeld (matth@everysoft.com) - Original Concept and Design
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Subcategories
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - User Stats
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - All Items
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Hot Items
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - New Items
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Ending Items
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Classifieds & Wanted Ads
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - User Agreement
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Search Modification
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Display Category with Subcategories
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Quick Navigation on item display
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Buy-It Button
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Feedback 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - lost password 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Forgot Alias 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Phone Number 1.8
# * Lion (unknown email)(unknown website) - Auto Close - Used with permission 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Help Bid 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Help Post 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - FAQ 1.8
# * Michael Bruce (ezcomp@worldspy.net)(http://www.e-zauctionsoftware.com/) - Minor formatting changes 1.8
#
#-###########################################################################

#-#############################################
# Configuration Section
# Edit these variables!
local %config;

# The Base Directory.  We need an
# absolute path for the base directory.
# Include the trailing slash.  THIS SHOULD
# NOT BE WEB-ACCESSIBLE!

$config{'basepath'} = '/u/ursite/auctiondata8/';
my $no_bids1;
open THEBIDS, "$config{'basepath'}/no_bids1.txt";
($no_bids1) = <THEBIDS>;
close THEBIDS;

my $no_post;
open THEPOST, "$config{'basepath'}/no_post1.txt";
($no_post) = <THEPOST>;
close THEPOST; 

my $no_viewed;
open THEVIEWED, "$config{'basepath'}/no_viewe1.txt";
($no_viewed) = <THEVIEWED>;
close THEVIEWED;

my $no_user;
open THEUSER, "$config{'basepath'}/no_user1.txt";
($no_user) = <THEUSER>;
close THEUSER;




# Define Help bid File location
$config{'helpbid'} = 'http://www.ursite.com/helpbid.htm';
# Define Help Post File location
$config{'helppost'} = 'http://www.ursite.com/helppost.htm';
# Define Help FAQ File location
$config{'helpfaq'} = 'http://www.ursite.com/helpfaq.htm';
# Define Help User Agreement File location
$config{'helpagree'} = 'http://www.ursite.com/helpagree.htm';




################################ Buttons for item display ############################
$config{'vf'} = "\"http://www.ursite.com/images/vfeed.gif\" WIDTH=\"100\" HEIGHT=\"21\" BORDER=\"0\" ALT=\"View Users Feedback\"";

$config{'bn'} = "\"http://www.ursite.com/images/bnow.gif\" WIDTH=\"100\" HEIGHT=\"31\" BORDER=\"0\" ALT=\"Buy-It Now !! Need it NOW? Get it NOW!\"";

$config{'pb'} = "\"http://www.ursite.com/images/pbid.gif\" WIDTH=\"75\" HEIGHT=\"21\" BORDER=\"0\" ALT=\"Place your bid for this item\"";

$config{'vn'} = "\"http://www.ursite.com/images/view.gif\" WIDTH=\"50\" HEIGHT=\"21\" BORDER=\"0\" ALT=\"View other items like this.\"";

# Feedback Directory
# This is where feedback will be stored
$config{'feeddata'} = 'feed';

# Feedback Script
# This is where feedback Script is located
$config{'feedscript'} = 'http://www.ursite.com/cgi-bin/feed.cgi';


# Closed Auction Directory
# This is where closed auction items are stored.
# Leave this blank if you don't want to store
# closed auctions.  It can potentially take
# up quite a bit of disk space.

$config{'closedir'} = 'closed';

# User Registration Directory
# This is where user registrations are stored.
# Leave this blank if you don't want to
# require registration.  It can potentially
# take up quite a bit of disk space.

$config{'regdir'} = 'reg';

#####################
# Pic Icon
$config{'imageiconpath'} = "<img src=\"http://www.ursite.com/cam.gif\" width=\"32\" height=\"27\" border=\"0\">";

####################
# View new items
# $newdays = number of days item is considered new
# $newiconpath = URL to an icon for displaying
$config{'newdays'} = 1;
$config{'newiconpath'} = "<IMG SRC=\"http://www.ursite.com/new.gif\" width=\"26\" height=\"21\" border=\"0\">";

###################
# View Hot Items
$config{'hotitemnum'} = 2;
$config{'hoticonpath'} = "<IMG SRC=\"http://www.ursite.com/hot.gif\" width=\"28\" height=\"11\" border=\"0\">";

######################3
# View ending soon items
# $endhours = number of hours left in auction to be considered closing soon
# $endiconpath = URL to an icon for displaying
$config{'endhours'}  = 24;
$config{'endiconpath'} ="<IMG SRC=\"http://www.ursite.com/ending.gif\" width=\"41\" height=\"10\" border=\"0\">";


# List each directory and its associated
# category name.  These directories should
# be subdirectories of the base directory.

%category = (
	category01 => 'cat1',
	category02 => 'cat2',
	category03 => 'cat3',
	category04 => 'cat4',
	category05 => 'cat5',
	category06 => 'cat6',
	category07 => 'cat7',
	category08 => 'cat8',
	category09 => 'cat9',
	category10 => 'cat10',
	category11 => 'cat11',
	category12 => 'cat12',
	category13 => 'cat13',
	category14 => 'cat14',
	category15 => 'cat15',
	category16 => 'cat16',
	category17 => 'cat17',
	category18 => 'cat18',
	category19 => 'cat19',
	category20 => 'cat20',
	category21 => 'cat21',
	category22 => 'cat22',
	category23 => 'cat23',
	category24 => 'cat24',
	category25 => 'cat25',
	category26 => 'cat26',
	category27 => 'cat27',
	category28 => 'cat28',
	category29 => 'cat29',
	category30 => 'cat30',
	category31 => 'cat31',
);

%Cats1 = (
	category01 => 'cat1',
	category02 => 'cat2',
	category03 => 'cat3',
	category04 => 'cat4',
	category05 => 'cat5',
);
%Cats2 = (
	category06 => 'cat6',
	category07 => 'cat7',
	category08 => 'cat8',
	category09 => 'cat9',
	category10 => 'cat10',
);
%Cats3 = (
	category11 => 'cat11',
	category12 => 'cat12',
	category13 => 'cat13',
	category14 => 'cat14',
	category15 => 'cat15',
);
%Cats4 = (
	category16 => 'cat16',
	category17 => 'cat17',
	category18 => 'cat18',
	category19 => 'cat19',
	category20 => 'cat20',
);
%Cats5 = (
	category21 => 'cat21',
	category22 => 'cat22',
	category23 => 'cat23',
	category24 => 'cat24',
	category25 => 'cat25',
);
%Cats6 = (
	category26 => 'cat26',
	category27 => 'cat27',
	category28 => 'cat28',
	category29 => 'cat29',
	category30 => 'cat30',
	category31 => 'cat31',
);

# This is the password for deleting auction
# items.

$config{'adminpass'} = 'beta';

# You need to assign either a mail program or
# a mail host so confirmation e-mails can
# be sent out.
# Leave one commented and one uncommented.
#
# YOU NEED EITHER A MAIL PROGRAM

$config{'mailprog'} = '/usr/sbin/sendmail -t';
#
# OR YOU NEED A MAIL HOST (SMTP)

#$config{'mailhost'} = 'localhost';

# This line should be your e-mail address

$config{'admin_address'} = 'YOU@YOU.net';

# This line should point to the URL of
# your server.  It will be used for sending
# "you have been outbid" e-mail.  The script
# name and auction will be appended to the
# end automatically, so DO NOT use a trailing
# slash.  If you do not want to send outbid
# e-mail, leave this blank.

$config{'scripturl'} = 'www.ursite.net';

# This will let you define colors for the
# tables that are generated and the
# other page colors.  The default colors
# create a nice "professional" look.  Must
# be in hex format.

$config{'colortablehead'} = '#CCCCCC';
$config{'colortablebody'} = '#EEEEEE';
$config{'colortablebody2'} = '#EEEEEE';
$config{'colortableborder'} = '#000000';

# Site Name (will appear at the top of each page)

$config{'sitename'} = 'E-Z Auction Software';
$config{'sitename2'} = 'E-ZAuctionSoftware';
$config{'mailurl'} = 'http://www.ursite.net/cgi-bin/auction.cgi';

# You can configure your own header which will
# be appended to the top of each page.

$config{'header'} =<<"EOF";
<HTML>
<HEAD>
	<TITLE>$config{'sitename'} - Powered By E-ZAuctionSoftware</TITLE>
</HEAD>
<BODY TEXT=#000000 BGCOLOR=#FFFFFF LINK=#000088 VLINK=#000088 ALINK=#000088 MARGINHEIGHT=0 topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0">

	<TABLE WIDTH=100\% BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0><TR><TD VALIGN=TOP WIDTH=80\%>
		<FONT SIZE=+2><A HREF=$ENV{'SCRIPT_NAME'}>$config{'sitename'}</a></FONT>

	</TD></TR></TABLE>
	
EOF

# You can configure your own footer which will
# be appended to the bottom of each page.
# Although not required, a link back to
# everysoft.com or E-Z Auction Software will help to support future
# development.

$config{'footer'} =<<"EOF";
<P>
<CENTER><FONT SIZE=-1><I>Powered By <A HREF=http://www.e-zauctionsoftware.com/>E-ZAuctionSoftware 1.8A</A></I></FONT><P><BR>$config{'dsl'}<P><BR>$config{'va'}</CENTER>
</BODY>
</HTML>
EOF

# Sniper Protection...  How many minutes
# past last bid to hold auction.  If auctions
# should close at exactly closing time, set
# to zero.

$config{'aftermin'} = 5;

# File locking enabled?  Should be 1 (yes)
# for most systems, but set to 0 (no) if you
# are getting flock errors or the script
# crashes.

$config{'flock'} = 0;

# User Posting Enabled- 1=yes 0=no

$config{'newokay'} = 1;

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

#-#############################################
# Print The Page Header
#
print "Content-type: text/html\n\n";
print $config{'header'};
#
#-#############################################

local %form = &get_form_data;
if ($form{'action'} eq 'new') { &new; }
elsif ($form{'action'} eq 'repost') { &new; }
elsif ($form{'action'} eq 'repostc') { &newc; }  #repost classified
elsif ($form{'action'} eq 'repostw') { &newwa; }  #repost Wanted
elsif ($form{'action'} eq 'newc') { &newc; }  #classified
elsif ($form{'action'} eq 'neww') { &newwa; }  #wanted
elsif ($form{'action'} eq 'dc') { &dispclass; }  # viewclassified
elsif ($form{'action'} eq 'wa') { &dispwa; }  # viewwanted
elsif ($form{'action'} eq 'buyit') { &dispbuy; }  # allows buying
elsif ($form{'action'} eq 'buyitc') { &dispbuyc; }  # allows buying classifieds
elsif ($form{'action'} eq 'procbuy') { &procbuy; } # Processes Buying
elsif ($form{'action'} eq 'procbuyc') { &procbuyc; } # Processes Buying classifieds
elsif ($form{'action'} eq 'procnew') { &procnew; }
elsif ($form{'action'} eq 'procbid') { &procbid; }
elsif ($form{'action'} eq 'allnew') { &allnew; }  #all new
elsif ($form{'action'} eq 'allhot') { &allhot; }  #all hot
elsif ($form{'action'} eq 'allend') { &allend; }  #all ending
elsif ($form{'action'} eq '1') { &scat1; }  #Show Main Cat 1
elsif ($form{'action'} eq '2') { &scat2; }  #Show Main Cat 2
elsif ($form{'action'} eq '3') { &scat3; }  #Show Main Cat 3
elsif ($form{'action'} eq '4') { &scat4; }  #Show Main Cat 4
elsif ($form{'action'} eq '5') { &scat5; }  #Show Main Cat 5
elsif ($form{'action'} eq '6') { &scat6; }  #Show Main Cat 6
elsif ($form{'action'} eq 'lp') { &lp; }    #lost password form
elsif ($form{'action'} eq 'lp2') { &lp2; }  # processes lost password
elsif ($form{'action'} eq 'la') { &la; }    #lost alias form
elsif ($form{'action'} eq 'la2') { &la2; }  # processes lost alias 
elsif ($form{'action'} eq 'reg') { &reg; }
elsif ($form{'action'} eq 'creg') { &creg; }
elsif ($form{'action'} eq 'procreg') { &procreg; }
elsif ($form{'action'} eq 'chreg') { &chreg; }
elsif ($form{'action'} eq 'proccreg') { &proccreg; }
elsif ($form{'action'} eq 'helpbid') { &helpbid; } # Display Help bid File
elsif ($form{'action'} eq 'helppost') { &helppost; } # Display Help Post File
elsif ($form{'action'} eq 'helpfaq') { &helpfaq; } # Display Help Faq File
elsif ($form{'action'} eq 'helpagree') { &helpagree; } # Display Help File
elsif ($form{'action'} eq 'closed') { &viewclosed1; }
elsif ($form{'action'} eq 'closed2') { &viewclosed2; }
elsif ($form{'action'} eq 'closed3') { &viewclosed3; }
elsif ($form{'action'} eq 'admin') { &admin; }
elsif ($form{'action'} eq 'procadmin') { &procadmin; }
elsif ($form{'action'} eq 'search1') { &start_search; }
elsif ($form{'action'} eq 'search') { &procsearch; }
elsif ($form{'action'} eq 'all') { &view_all; }
elsif ($form{'item'} eq int($form{'item'}) and $category{$form{'category'}}) { &dispitem; }
elsif ($category{$form{'category'}}) { &displist; }
else { &dispcat; }

#-#############################################
# Print The Page Footer
#
print "<P ALIGN=CENTER>[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}>Category List</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=new>Post New Auction</FONT></A>]&nbsp;&nbsp;" if ($config{'newokay'});
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=newc>Post New Classified</FONT></A>]&nbsp;&nbsp;" if ($config{'newokay'});
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=neww>Post New Wanted Ad</FONT></A>]&nbsp;&nbsp;" if ($config{'newokay'});
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=reg>New Registration</FONT></A>]&nbsp;&nbsp;" if ($config{'regdir'});
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=chreg>Change Registration</FONT></A>]&nbsp;&nbsp;" if ($config{'regdir'});
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=closed>Closed Auctions</FONT></A>]&nbsp;&nbsp;" if ($config{'regdir'}) and ($config{'closedir'});
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=search1>Search</FONT></A>]&nbsp;&nbsp;<BR>";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=all>All Items</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=allnew>All New Items</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=allhot>All Hot Items</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=allend>Closing Soon</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=helpbid>Help on Bidding</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=helppost>Help on Posting</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=helpfaq>FAQ</FONT></A>]&nbsp;&nbsp;";
print "[<FONT SIZE=-1><A HREF=$ENV{'SCRIPT_NAME'}?action=helpagree>Review User Agreement</FONT></A>]&nbsp;&nbsp;";
print "</P>\n";
print $config{'footer'};
#
#-#############################################

#-#############################################
# Sub: Display List Of Categories
# This creates a "nice" list of categories.

sub dispcat {
	
	print "<center><font size=\"+2\">Welcome to $config{'sitename'}</font>";
	print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><br>";
	print "<TABLE WIDTH=600 BORDER=1 bordercolor=$config{'colortableborder'} BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0><TR><TD ALIGN=CENTER Valign=top>\n";
################  <---------------------COPY HERE TO END COPY TO ADD ANOTHER row of CATEGORYs   ------------>#######################	


	print "<TABLE WIDTH=200 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	print "<TR><TD colspan=2 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 1</a></B></TD></TR>";
		my $key;
		foreach $key (sort keys %Cats1) {
			umask(000);  # UNIX file permission junk
			mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
			opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
			my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
			closedir DIR;
			print "<TR><TD><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key>$category{$key}</a></B></td><td align=center>$numfiles</td></TR> ";
			}
	print "</TABLE></td>\n";
	
	
		print "<td align=center valign=top><TABLE WIDTH=200 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
		print "<TR><TD colspan=2 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=2>Main Category 2</a></B></TD></TR>";
			my $key;
			foreach $key (sort keys %Cats2) {
				umask(000);  # UNIX file permission junk
				mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
				opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
				my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
				closedir DIR;
				print "<TR><TD><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key>$category{$key}</a></B></td><td align=center>$numfiles</td></TR> ";
				}
	print "</TABLE>\n";
	
	print "<td align=center valign=top><TABLE WIDTH=200 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
			print "<TR><TD colspan=2 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=3>Main Category 3</a></B></TD></TR>";
				my $key;
				foreach $key (sort keys %Cats3) {
					umask(000);  # UNIX file permission junk
					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
					closedir DIR;
					print "<TR><TD><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key>$category{$key}</a></B></td><td align=center>$numfiles</td></TR> ";
					}
	print "</TABLE>";
	

		
	
################  <--------------------- END CUT HERE TO ADD ANOTHER row of CATEGORYs   ------------>#######################	
	print "</td></tr><tr><td valign=top>";
################  <---------------------COPY HERE TO END COPY TO ADD ANOTHER row of CATEGORYs   ------------>#######################	


	print "<TABLE WIDTH=200 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	print "<TR><TD colspan=2 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=4>Main Category 4</a></B></TD></TR>";
		my $key;
		foreach $key (sort keys %Cats4) {
			umask(000);  # UNIX file permission junk
			mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
			opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
			my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
			closedir DIR;
			print "<TR><TD><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key>$category{$key}</a></B></td><td align=center>$numfiles</td></TR> ";
			}
	print "</TABLE></td>\n";
	
	
		print "<td align=center valign=top><TABLE WIDTH=200 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
		print "<TR><TD colspan=2 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=5>Main Category 5</a></B></TD></TR>";
			my $key;
			foreach $key (sort keys %Cats5) {
				umask(000);  # UNIX file permission junk
				mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
				opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
				my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
				closedir DIR;
				print "<TR><TD><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key>$category{$key}</a></B></td><td align=center>$numfiles</td></TR> ";
				}
	print "</TABLE>\n";
	
	print "<td align=center valign=top><TABLE WIDTH=200 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
			print "<TR><TD colspan=2 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=6>Main Category 6</a></B></TD></TR>";
				my $key;
				foreach $key (sort keys %Cats6) {
					umask(000);  # UNIX file permission junk
					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
					closedir DIR;
					print "<TR><TD><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key>$category{$key}</a></B></td><td align=center>$numfiles</td></TR> ";
					}
	print "</TABLE>";
	

		
	
################  <--------------------- END CUT HERE TO ADD ANOTHER row of CATEGORYs   ------------>#######################	
	
	print "</table><TABLE WIDTH=550 BORDER=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0><TR>";
	print "<TD width=40 align=right><font color=\"#ff0000\" size=\"-1\">$no_user </font></td><td width=130><font size=\"-1\">Registered Users</font></td>";
	print "<TD width=40 align=right><font color=\"#ff0000\" size=\"-1\">$no_post </font></td><td width=100><font size=\"-1\">Items Posted</font></td>";
	print "<TD width=40 align=right><font color=\"#ff0000\" size=\"-1\">$no_viewed </font></td><td width=80><font size=\"-1\">Page Views</font></td>";
	print "<TD width=40 align=right><font color=\"#ff0000\" size=\"-1\">$no_bids1 </font></td><td width=80><font size=\"-1\">Bids Placed</font></td></tr></table></CENTER>\n";
	print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";

}

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

sub displist {
        print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
	&displistf;
	&chkclose;
	print "<center><H2>$category{$form{'category'}}</H2>\n";
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablebody'}><B>Auction</b></TD><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><A HREF=$ENV{'SCRIPT_NAME'}\?action=dc&category=$form{'category'}>Classifieds</a></TD><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><A HREF=$ENV{'SCRIPT_NAME'}\?action=wa&category=$form{'category'}>Want Ads</a></TD></TR></table>\n";
	
	
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Item</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Closes</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Num Bids</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>High Bid</B></TD></TR>\n";
	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'}/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
	closedir THEDIR;
	my $file;
	foreach $file (@allfiles) {
		$file =~ s/^$config{'basepath'}$form{'category'}\///;
		$file =~ s/\.dat$//;
		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$file)) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
			my @closetime = localtime($file);
			my @firstbid =  &read_bid($bids[0]);
			my $timediff = ($file - time);
			$closetime[4]++;
			print "<TR><TD BGCOLOR=$config{'colortablebody'}><A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'category'}\&item=$file>$title</A>" if ($type eq 'Auction');
			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if (($image) && ($type eq 'Auction'));
			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3]) && ($type eq 'Auction')) ;
			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if (($config{'hotitemnum'} <= $#bids) && ($type eq 'Auction'));
			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600) && ($type eq 'Auction'));
			print "</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$closetime[4]/$closetime[3]</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$#bids</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>\$$bid</TD></TR>\n" if ($type eq 'Auction');
		}
	}
	print "</TABLE>\n";
	print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

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

sub displistf {

	print "<center><H2>$category{$form{'category'}} Featured Items</H2>\n";
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Item</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Closes</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Num Bids</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>High Bid</B></TD></TR>\n";
	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'}/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
	closedir THEDIR;
	my $file;
	foreach $file (@allfiles) {
		$file =~ s/^$config{'basepath'}$form{'category'}\///;
		$file =~ s/\.dat$//;
		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$file)) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
			my @closetime = localtime($file);
			my @firstbid =  &read_bid($bids[0]);
			my $timediff = ($file - time);
			$closetime[4]++;
			print "<TR><TD BGCOLOR=$config{'colortablebody'}><A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'category'}\&item=$file>$title</A>" if ($feat eq 'Yes');
			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if (($image) && ($feat eq 'Yes'));
			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3]) && ($feat eq 'Yes')) ;
			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if (($config{'hotitemnum'} <= $#bids) && ($feat eq 'Yes'));
			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600) && ($feat eq 'Yes'));
			print "&nbsp;&nbsp;&nbsp;[A] " if (($type eq 'Auction') && ($feat eq 'Yes'));
			print "&nbsp;&nbsp;&nbsp;[C] " if (($type eq 'Classified') && ($feat eq 'Yes'));
			print "&nbsp;&nbsp;&nbsp;[W] " if (($type eq 'Wanted') && ($feat eq 'Yes'));
			print "</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$closetime[4]/$closetime[3]</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$#bids</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>\$$bid</TD></TR>\n" if ($feat eq 'Yes');
		}
	}
	print "</TABLE><BR>\n";
	
}


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

sub dispclass {
        print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
	&displistf;
	print "<center><H2>$category{$form{'category'}}</H2>\n";
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><A HREF=$ENV{'SCRIPT_NAME'}\?action=$category{$form{'category'}}&category=$form{'category'}>Auctions</a></TD><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablebody'}> <B>View Classifieds</B></TD><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><A HREF=$ENV{'SCRIPT_NAME'}\?action=wa&category=$form{'category'}>Want Ads</a></TD></TR></table>\n";
	
	
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Item</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Closes</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Num Bids</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>High Bid</B></TD></TR>\n";
	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'}/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
	closedir THEDIR;
	my $file;
	foreach $file (@allfiles) {
		$file =~ s/^$config{'basepath'}$form{'category'}\///;
		$file =~ s/\.dat$//;
		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$file)) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
			my @closetime = localtime($file);
			my @firstbid =  &read_bid($bids[0]);
			my $timediff = ($file - time);
			$closetime[4]++;
			print "<TR><TD BGCOLOR=$config{'colortablebody'}><A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'category'}\&item=$file>$title</A>" if ($type eq 'Classified');
			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if (($image) && ($type eq 'Classified'));
			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3]) && ($type eq 'Classified')) ;
			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if (($config{'hotitemnum'} <= $#bids) && ($type eq 'Classified'));
			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600) && ($type eq 'Classified'));
			print "</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$closetime[4]/$closetime[3]</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$#bids</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>\$$bid</TD></TR>\n" if ($type eq 'Classified');
		}
	}
	print "</TABLE>\n";
	print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

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

sub dispwa {
        print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
	&displistf;
	print "<center><H2>$category{$form{'category'}}</H2>\n";
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><A HREF=$ENV{'SCRIPT_NAME'}\?action=$category{$form{'category'}}&category=$form{'category'}>Auctions</a></TD><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><A HREF=$ENV{'SCRIPT_NAME'}\?action=dc&category=$form{'category'}>Classifieds</a></TD><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablebody'}><B>Want Ads</B></TD></TR></table>\n";
	
	
	print "<TABLE BORDER=1 WIDTH=600 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'}>\n";
	
	print "<TR><TD width=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Item</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Closes</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Num Bids</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>High Bid</B></TD></TR>\n";
	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'}/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
	closedir THEDIR;
	my $file;
	foreach $file (@allfiles) {
		$file =~ s/^$config{'basepath'}$form{'category'}\///;
		$file =~ s/\.dat$//;
		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$file)) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
			my @closetime = localtime($file);
			my @firstbid =  &read_bid($bids[0]);
			my $timediff = ($file - time);
			$closetime[4]++;
			print "<TR><TD BGCOLOR=$config{'colortablebody'}><A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'category'}\&item=$file>$title</A>" if ($type eq 'Wanted');
			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if (($image) && ($type eq 'Wanted'));
			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3]) && ($type eq 'Wanted')) ;
			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if (($config{'hotitemnum'} <= $#bids) && ($type eq 'Wanted'));
			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600) && ($type eq 'Wanted'));
			print "</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$closetime[4]/$closetime[3]</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$#bids</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>\$$bid</TD></TR>\n" if ($type eq 'Wanted');
		}
	}
	print "</TABLE>\n";
	print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}
#-#############################################
# Sub: Display Item
# This displays a particular item, its
# description, and its associated bids.

sub dispitem {
	&oops("Item $form{'item'} could not be opened.") unless (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$form{'item'}));
	my $nowtime = localtime(time);
	my $closetime = localtime($form{'item'});
	my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[0]); # read first bid
	my $nowtime = localtime;
	my $key;
	my $file;
	
	
	if ($type eq 'Auction'){
	print <<"EOF";
	<a name="top"><!--Top of Page--></a>
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr bgcolor="#FFFFFF">
	<td>
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0><tr align=center bgcolor="#FFFFFF"><td>
	&nbsp;
	</td></tr>
	<TR align="center" bgcolor="#FF9933">
	<TD align=right>&nbsp;Current Time:$nowtime</TD>
	</TR>
	<tr bgcolor=$config{'colortablebody'}>
	<td>
	<table cellpadding=5 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 width=100%>
	<tr>
	<td valign=top>
	<font size=+1><A HREF=$ENV{'SCRIPT_NAME'}?action=search1><b>Search</A></b> </font>
	</td>
	<form method="post" action="$ENV{'SCRIPT_NAME'}?"> 
	<td valign=top align=right>
	<font size=-1> <b>Browse:</b> 
	<select name=\"category\">
	<option>&nbsp;</option>
EOF
			
			my $key;
			foreach $key (sort keys %category) {
				umask(000);  # UNIX file permission junk
				mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
				opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
				my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
				closedir DIR;
				print "<option value=\"$key\"><B>$category{$key}</option></b>\n";
			}
	print <<"EOF";
	</select>
	<input type="submit" Value="GO!">
	</td></form></font>
	</tr></table>
	</td></tr></table>
	</td></tr></table>
	<table width="100%" border=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr><td width=60% align="left">
	   
	      <font face=verdana,arial,helvetica size=-2><a href=$ENV{'SCRIPT_NAME'}?>Home</a>     /
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>$category{$form{'category'}}</a>               / 
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>Auctions</a>     /      
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$form{'item'}>     $title</a>     </font>
	</td>
	<td width="40%" align="right">
	<font face=verdana,arial,helvetica size=-2> <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>view more like this</a></font>
	</td></tr></table>
	
	
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr valign=top>
	  <td width=155>
	<table width=155 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablehead'}>
	<tr valign=bottom align=center><td><B>Explore This Item</B></td></tr>
	<tr><td>     
	<TABLE border=0 width= 100% cellpadding=1 cellspacing=0 bgcolor=#CCCC99 ><TR> <TD width=100%>
	<TABLE width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100%> 
	
	<table border=0 cellspacing=0 cellpadding=2 width=100%> 
	
EOF
	print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1><b><font color=#CC6600>Shipping Method</font></b></font></td></tr>";
	print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$ship</font></td></tr>";
	print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1><b><font color=#CC6600>Payment Options</font></b></font></td></tr>";
	print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay0</font></td></tr>" if $pay0 ne "" ;
	print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay1</font></td></tr>" if $pay1 ne "" ;
	print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay2</font></td></tr>" if $pay2 ne "" ;
	print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay3</font></td></tr>" if $pay3 ne "" ;
	print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay4</font></td></tr>" if $pay4 ne "" ;
	print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay5</font></td></tr>" if $pay5 ne "" ;
	print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay6</font></td></tr>" if $pay6 ne "" ;
	print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay7</font></td></tr>" if $pay7 ne "" ;
	print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-2>$pay8</font></td></tr>" if $pay8 ne "" ;
	
	
	
	print <<"EOF";
	
	<tr><td colspan=2 align=center><strong><font face=verdana,arial,helvetica size=-1 color=#CC6600>Similar Items</font></strong></td></tr>
	<tr><td colspan=2 align=center> <font face=verdana,arial,helvetica size=-1>
	<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
				<INPUT TYPE=HIDDEN NAME=searchstring VALUE="$title">
				<INPUT TYPE=image VALUE="View" SRC=$config{'vn'}>
				<INPUT TYPE=HIDDEN NAME=action VALUE="search">
				<INPUT TYPE=HIDDEN NAME=searchtype VALUE="keyword">
	</td></tr></form>
	<tr><td colspan=2><strong><font face=verdana,arial,helvetica size=-1 color=#CC6600>Share your thoughts</font></strong></td></tr>
	<tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1><A HREF=mailto:enter_your_friends_email_here?subject=$title-at-$config{'sitename2'}>E-Mail a Friend<BR>about this Auction</a></font></td></tr>
	
	</table>
	</TD> </TR> </TABLE> </TD> </TR> </TABLE>  </td></tr></table>
	 </td>
	    <td>&nbsp;</td>
	    <td valign=top>
	
	
	<table border=0 width=100%>
	<tr valign="top"><td  align="left">
	
	   <font size=+1><b>$title</b></font><BR>
EOF
	print " <font size=-1><I><a href=\"\#pic\">Image Below</a></I></font>" if $image ne "";

	
	print <<"EOF";
	
	 <br>
	 <p>
	 
	 	<strong><font face=verdana,arial,helvetica size=-1>Seller:</font></strong>&nbsp;
	 	<font face=verdana,arial,helvetica size=-1><A HREF=mailto:$email?subject=$title\aat\a$config{'sitename'}>$alias</A></font>
EOF
##################################################################################################begin Feedback addon
&oops('ALIAS') unless (open(REGFILE, "$config{'basepath'}$config{'feeddata'}/$alias.dat"));
		my (@userbids) = <REGFILE>;
		close REGFILE;
		my $pt=0;
		my $nt=0;
		my $nnt=0;
		my @thebid;
		my $ot;
		my $fc;
		foreach $bid (@userbids) {
				@thebid = split(/\[\]/,$bid);

				#print "<table border=\"1\" bordercolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\" width=\"500\" bgcolor=\"#c0c0c0\">";
				#print "<tr><td width=75>Feedback by:</td><td>Item</td><td>Rating</td></tr>";
				#print "<tr><td>$thebid[3]</td><td>$thebid[5]</td>";
				if ($thebid[0] eq "1"){
				$pt++;
				#print "<td width=75><font color=\"#009933\"><b>Positive </b></font></td>"
				}
				else {
				
				}
				if ($thebid[1] eq "1"){
				$nt++;
				#print "<td width=75>Neutral</td>"
				   }
				else {
								
				}
				if ($thebid[2] eq "1"){
				$nnt++;
				#print "<td width=75><font color=\"#ff0000\">Negative </font></td>"
				 }
				else {
												
				}
				#print "</tr><tr><td colspan=3 align=center>Comment</td></tr><tr><td colspan=3>$thebid[6]</td></tr></table><br>";
			
	}
	$ot = $pt - $nnt;
	if ($ot < 0){
	$fc = "#ff0000";
	}
	else {
	}
	if ($ot == 0){
	$fc = "#000000";
	}
	else {
	}
	if ($ot > 0){
	$fc = "#009933";
	}
	else {
	}
	 
	 print <<"EOF";

		<table border="0" bordercolor="#000000" cellspacing="0" cellpadding="0" width="75" bgcolor="#ffffff">
		<tr>
			       <td align=center colspan=3><font color=\"$fc\"><b>Rating $ot</b></font> </td>
			</tr>
			<tr><td align=center>
			<form action="$config{'feedscript'}" METHOD=POST><input name="action" type="hidden" value="vrate">
			<input name="ALIAS" type="hidden" value="$alias">
			<input type="image" Value="View Rating" SRC=$config{'vf'}>
							 
		 </td></tr></form>
</table></center>	      

EOF

	
	#end Feedback addon	


	print <<"EOF";
	
<br>
	<strong><font face=verdana,arial,helvetica size=-1>Starting Bid:</font></strong>&nbsp;
	<strong><font face=verdana,arial,helvetica size=-1>\$$bid</font></strong>

	
	
	
	
	<br>
	<strong><font face=verdana,arial,helvetica size=-1>Closes :</font></strong>&nbsp;
		<font face=verdana,arial,helvetica size=-1>$closetime <BR><FONT SIZE=-2 color=#FF0000>Or $config{'aftermin'} minutes after last bid...</FONT></font>
	<br>
	<strong><font face=verdana,arial,helvetica size=-1>Number of Bids:</font></strong>&nbsp;
		<font face=verdana,arial,helvetica size=-1>$#bids </font>
        <br>
	<strong><font face=verdana,arial,helvetica size=-1>Bidding History:<BR></font></strong>&nbsp;
	<font face=verdana,arial,helvetica size=-1>
EOF
	my $lowest_new_bid;
	if ($#bids) {
		shift @bids; # remove the first bid (start bid)
		for (my $i=0; $i<scalar(@bids); $i++) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$i]);
			my $bidtime = localtime($time);
			print "<FONT SIZE=-1>$alias \($bidtime\) - \$$bid</FONT><BR>";
		$lowest_new_bid = &parsebid($bid+$inc);
		}
		
		
	}
	

	
	
			else {
				print "<FONT SIZE=-1>No bids yet...</FONT> Do I Hear \$$bid ?<BR>";
				$lowest_new_bid = (&read_bid($bids[0]))[2];
				
	}
	
	
	
	
	
		my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]); # read the last bid
		if ((time > int($form{'item'})) && (time > (60 * $config{'aftermin'} + $time))) {
		####
		print "</td><td>&nbsp;</td>";
		print "<td align=\"right\" width=\"180\">";
		print "<div align=\"center\">";
		print "<table border=0 cellspacing=0 cellpadding=0 width=\"180\"><tr><td align=center bgcolor=$config{'colortablehead'}>";
		print "<FONT SIZE=+1><B>Place A Bid</B></FONT></td></tr></table>";
		print "<TABLE border=0 width= 180 cellpadding=1 cellspacing=0 bgcolor=\#CCCC99  cellspacing=0 cellpadding=0><TR> <TD width=100\%><TABLE width=100\% border=0 cellpadding=4 cellspacing=0 bgcolor=\#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100\%>";
		print "<div align=\"center\">";
		
			print "<FONT SIZE=-1 COLOR=#FF0000><B>BIDDING IS NOW CLOSED</B></FONT><BR>";
			&closeit($form{'category'},$form{'item'});
		}
	else {
&count_viewed;
	print "</td><td>&nbsp;</td>";
	print "<td align=\"right\" width=\"180\">";
	print "<div align=\"center\">";
	print "<table border=0 cellspacing=0 cellpadding=0 width=\"180\"><tr><td align=center bgcolor=$config{'colortablehead'}>";
	print "<FONT SIZE=+1><B>Place A Bid</B></FONT></td></tr></table>";
	print "<TABLE border=0 width= 180 cellpadding=1 cellspacing=0 bgcolor=\#CCCC99  cellspacing=0 cellpadding=0><TR> <TD width=100\%><TABLE width=100\% border=0 cellpadding=4 cellspacing=0 bgcolor=\#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100\%>";
	print "<div align=\"center\">";
	print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>";
	print "<INPUT TYPE=HIDDEN NAME=action VALUE=procbid>";
	print "<INPUT TYPE=HIDDEN NAME=ITEM VALUE=\"$form{'item'}\">";
	print "<INPUT TYPE=HIDDEN NAME=CATEGORY VALUE=\"$form{'category'}\">";
	print "<font face=verdana,arial,helvetica size=-1>The High Bid Is:</font><br> \$$bid<BR>";
	print "<font face=verdana,arial,helvetica size=-2 color=\"#FF0000\">(Reserve Auction)</FONT><BR>" if ($bid < $reserve);
	print "<font face=verdana,arial,helvetica size=-2>(reserve price met)</FONT><BR>" if (($bid >= $reserve) and ($reserve > 0));
	print "<font face=verdana,arial,helvetica size=-1>Minimum Bid</font><br> \$$lowest_new_bid";
	print "<BR><B><A HREF=$ENV{'SCRIPT_NAME'}?action=reg><font color=\"#FF0000\" size=\"-1\">Registration</A> is required!</font></B>";
	print "<br><B>Your Handle/Alias:</B><br>";
	print "<i><font size=\"-1\"><A HREF=$ENV{'SCRIPT_NAME'}?action=la>Forgot it\?<BR></a></font></i>";
	print "<INPUT NAME=ALIAS TYPE=TEXT SIZE=15 MAXLENGTH=30> ";
	print "<BR><B>Your Password:</B><BR>";
	print "<i><font size=\"-1\"><A HREF=$ENV{'SCRIPT_NAME'}?action=lp>Forgot it\?<BR></a></font></i>";
	print "<INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=15 MAXLENGTH=30> ";
        print "<BR><B>Your Bid:</B> \$<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=\"$lowest_new_bid\">";
        print "<INPUT TYPE=image VALUE=\"Place Bid\" SRC=$config{'pb'}></form>";
        print "<br><hr><font face=verdana,arial,helvetica size=-1><b>Buy-It Price<font color=#FF3366> \$$buyit</font></b></font><FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><INPUT TYPE=HIDDEN NAME=action VALUE=\"buyit\"><INPUT TYPE=HIDDEN NAME=category VALUE=\"$form{'category'}\"><INPUT TYPE=HIDDEN NAME=item VALUE=\"$form{'item'}\"><INPUT TYPE=image VALUE=\"image\" SRC=$config{'bn'}></form>" if ($buyit ne "");
	
	
}
	print <<"EOF";
	<P></div>
	</TD> </TR> </TABLE> </TD> </TR> </TABLE> 
	</td></tr></table></td></tr></table>
	<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="#FF9933"><td>
		&nbsp;
	</td></tr></table>
	<center><FONT SIZE=+1><B>Description</B></FONT></center>
	<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="$config{'colortablebody'}"><td>
			&nbsp;
	</td></tr></table>
	
	$desc</FONT></FONT></B></I></U></H1></H2></H3></H4></H5>
	
	<a name="bid">
	
	
EOF
	print "<center><a name=\"pic\"><IMG SRC=$image></center>" if ($image ne "");
	print <<"EOF";
		<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="$config{'colortablebody'}"><td>
				&nbsp;
	</td></tr></table>
EOF
}

#####################################CLASSIFIEDS
	if ($type eq 'Classified'){
				
	 print <<"EOF";
	<a name="top"><!--Top of Page--></a>
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr bgcolor="#FFFFFF">
	<td>
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0><tr align=center bgcolor="#FFFFFF"><td>
	&nbsp;
	</td></tr>
	<TR align="center" bgcolor="#FF9933">
	<TD><CENTER><font face=verdana,arial,helvetica size=+2><B>Classified Ad</B></font></center></TD>
	</TR>
	<tr bgcolor=$config{'colortablebody'}>
	<td>
	<table cellpadding=5 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 width=100%>
	<tr>
	<td valign=top>
	<font size=+1><A HREF=$ENV{'SCRIPT_NAME'}?action=search1><b> Search</A></b> </font>
	</td>
	<form method="post" action="$ENV{'SCRIPT_NAME'}?"> 
		<td valign=top align=right>
		<font size=-1> <b>Browse:</b> 
		<select name=\"category\">
		<option>&nbsp;</option>
EOF
				
				my $key;
				foreach $key (sort keys %category) {
					umask(000);  # UNIX file permission junk
					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
					closedir DIR;
					print "<option value=\"$key\"><B>$category{$key}</option></b>\n";
				}
		print <<"EOF";
		</select>
	<input type="submit" Value="GO!">
	</td></form></font>
	</tr></table>
	</td></tr></table>
	</td></tr></table>
	<table width="100%" border=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr><td width=60% align="left">
	   
	      <font face=verdana,arial,helvetica size=-2><a href=$ENV{'SCRIPT_NAME'}?>Home</a>     / 
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>$category{$form{'category'}}</a>               / 
	      <a href=$ENV{'SCRIPT_NAME'}?action=dc&category=$form{'category'}>Classifieds</a>     /      
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$form{'item'}>     $title</a>     </font>
	</td>
	<td width="40%" align="right">
	<font face=verdana,arial,helvetica size=-2> <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>view more like this</a></font>
	</td></tr></table>
	
	
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr valign=top>
	  <td width=155>
	<table width=155 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablehead'}>
	<tr valign=bottom align=center><td><B>Explore This Item</B></td></tr>
	<tr><td>     
	<TABLE border=0 width= 100% cellpadding=1 cellspacing=0 bgcolor=#CCCC99 ><TR> <TD width=100%>
	<TABLE width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100%> 
	
	<table border=0 cellspacing=0 cellpadding=2 width=100%> 
	
	
EOF
		print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1><b><font color=#CC6600>Shipping Method</font></b></font></td></tr>";
		print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$ship</font></td></tr>";
		print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1><b><font color=#CC6600>Payment Options</font></b></font></td></tr>";
		print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay0</font></td></tr>" if $pay0 ne "" ;
		print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay1</font></td></tr>" if $pay1 ne "" ;
		print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay2</font></td></tr>" if $pay2 ne "" ;
		print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay3</font></td></tr>" if $pay3 ne "" ;
		print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay4</font></td></tr>" if $pay4 ne "" ;
		print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay5</font></td></tr>" if $pay5 ne "" ;
		print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay6</font></td></tr>" if $pay6 ne "" ;
		print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay7</font></td></tr>" if $pay7 ne "" ;
		print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-2>$pay8</font></td></tr>" if $pay8 ne "" ;
		
		
		
	print <<"EOF";
	

	<tr><td colspan=2 align=center><strong><font face=verdana,arial,helvetica size=-1 color=#CC6600>Similar Items</font></strong></td></tr>
	<tr><td colspan=2 align=center> <font face=verdana,arial,helvetica size=-1>
	<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
				<INPUT TYPE=HIDDEN NAME=searchstring VALUE="$title">
				<INPUT TYPE=image VALUE="View" SRC=$config{'vn'}>
				<INPUT TYPE=HIDDEN NAME=action VALUE="search">
				<INPUT TYPE=HIDDEN NAME=searchtype VALUE="keyword">
	</td></tr></form>
	<tr><td colspan=2><strong><font face=verdana,arial,helvetica size=-1 color=#CC6600>Share your thoughts</font></strong></td></tr>
	<tr><td colspan=2 align=center><font face=verdana,arial,helvetica size=-2><A HREF=mailto:enter_your_friends_email_here?subject=$title-at-$config{'sitename2'}>E-Mail a friend about<BR>this Classified Ad</a></font></td></tr>
	
	</table>
	</TD> </TR> </TABLE> </TD> </TR> </TABLE>  </td></tr></table>
	 </td>
	    <td>&nbsp;</td>
	    <td valign=top>
	
	
	<table border=0 width=100%>
	<tr valign="top"><td  align="left">
	
	   <font size=+1><b>$title</b></font><BR>
EOF
	print " <font size=-1><I><a href=\"\#pic\">Image Below</a></I></font>" if $image ne "";

	
	print <<"EOF";
	
	 <br>
	 <p>
	 
	 	<strong><font face=verdana,arial,helvetica size=-1>Seller:</font></strong>&nbsp;
	 	<font face=verdana,arial,helvetica size=-1><A HREF=mailto:$email?subject=$title\aat\a$config{'sitename'}>$alias</A></font>
	 </font><br>
	 
EOF
##################################################################################################begin Feedback addon
&oops('ALIAS') unless (open(REGFILE, "$config{'basepath'}$config{'feeddata'}/$alias.dat"));
		my (@userbids) = <REGFILE>;
		close REGFILE;
		my $pt=0;
		my $nt=0;
		my $nnt=0;
		my @thebid;
		my $ot;
		my $fc;
		foreach $bid (@userbids) {
				@thebid = split(/\[\]/,$bid);

				#print "<table border=\"1\" bordercolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\" width=\"500\" bgcolor=\"#c0c0c0\">";
				#print "<tr><td width=75>Feedback by:</td><td>Item</td><td>Rating</td></tr>";
				#print "<tr><td>$thebid[3]</td><td>$thebid[5]</td>";
				if ($thebid[0] eq "1"){
				$pt++;
				#print "<td width=75><font color=\"#009933\"><b>Positive </b></font></td>"
				}
				else {
				
				}
				if ($thebid[1] eq "1"){
				$nt++;
				#print "<td width=75>Neutral</td>"
				   }
				else {
								
				}
				if ($thebid[2] eq "1"){
				$nnt++;
				#print "<td width=75><font color=\"#ff0000\">Negative </font></td>"
				 }
				else {
												
				}
				#print "</tr><tr><td colspan=3 align=center>Comment</td></tr><tr><td colspan=3>$thebid[6]</td></tr></table><br>";
			
	}
	$ot = $pt - $nnt;
	if ($ot < 0){
	$fc = "#ff0000";
	}
	else {
	}
	if ($ot == 0){
	$fc = "#000000";
	}
	else {
	}
	if ($ot > 0){
	$fc = "#009933";
	}
	else {
	}
	 
	 print <<"EOF";

		<table border="0" bordercolor="#000000" cellspacing="0" cellpadding="0" width="75" bgcolor="#ffffff">
		<tr>
			       <td align=center colspan=3><font color=\"$fc\"><b>Rating $ot</b></font> </td>
			</tr>
			<tr><td align=center>
			<form action="$config{'feedscript'}" METHOD=POST><input name="action" type="hidden" value="vrate">
			<input name="ALIAS" type="hidden" value="$alias">
			<input type="image" Value="View Rating" SRC=$config{'vf'}>
							 
		 </td></tr></form>
</table></center>	      

EOF

	
	#end Feedback addon	


	print <<"EOF";
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	<strong><font face=verdana,arial,helvetica size=-1>Sell Price:</font></strong>&nbsp;
	<strong><font face=verdana,arial,helvetica size=-1>\$$bid</font></strong>

	
	
	
	
	<br>
	<strong><font face=verdana,arial,helvetica size=-1>Closes :</font></strong>&nbsp;
		<font face=verdana,arial,helvetica size=-1>$closetime </font>
	<br>
	
EOF

		
		my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]); # read the last bid
		if ((time > int($form{'item'})) && (time > (60 * $config{'aftermin'} + $time))) {
		####
		print "</td><td>&nbsp;</td>";
		print "<td align=\"right\" width=\"180\">";
		print "<div align=\"center\">";
		print "<table border=0 cellspacing=0 cellpadding=0 width=\"180\"><tr><td align=center bgcolor=$config{'colortablehead'}>";
		print "<FONT SIZE=+1><B>Purchase</B></FONT></td></tr></table>";
		print "<TABLE border=0 width= 180 cellpadding=1 cellspacing=0 bgcolor=\#CCCC99  cellspacing=0 cellpadding=0><TR> <TD width=100\%><TABLE width=100\% border=0 cellpadding=4 cellspacing=0 bgcolor=\#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100\%>";
		print "<div align=\"center\">";
		print "<FONT SIZE=-1 COLOR=#FF0000><B>ITEM IS NOW CLOSED</B></FONT><BR>";
					&closeit2($form{'category'},$form{'item'});
				}
	else {
			
&count_viewed;
		print "</td><td>&nbsp;</td>";
		print "<td align=\"right\" width=\"180\">";
		print "<div align=\"center\">";
		print "<table border=0 cellspacing=0 cellpadding=0 width=\"180\"><tr><td align=center bgcolor=$config{'colortablehead'}>";
		print "<FONT SIZE=+1><B>Purchase Now</B></FONT></td></tr></table>";
		print "<TABLE border=0 width= 180 cellpadding=1 cellspacing=0 bgcolor=\#CCCC99  cellspacing=0 cellpadding=0><TR> <TD width=100\%><TABLE width=100\% border=0 cellpadding=4 cellspacing=0 bgcolor=\#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100\%>";
		print "<div align=\"center\">";
		print "Contact Seller:<BR> <A HREF=mailto:$email?subject=$title\aat\a$config{'sitename'}><FONT SIZE=+1 COLOR=#FF0000>$alias</font></A>";
		print "<br><hr><font face=verdana,arial,helvetica size=-1><b>Buy-It Price<font color=#FF3366> \$$bid</font></b></font><FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST><INPUT TYPE=HIDDEN NAME=action VALUE=\"buyitc\"><INPUT TYPE=HIDDEN NAME=category VALUE=\"$form{'category'}\"><INPUT TYPE=HIDDEN NAME=item VALUE=\"$form{'item'}\">";
		
		print "<INPUT TYPE=image VALUE=\"Place Bid\" SRC=$config{'pb'}></form>";
}
		print <<"EOF";
		
	<P></div>
	</TD> </TR> </TABLE>  </TD> </TR> </TABLE> 
	</td></tr></table></td></tr></table>
	<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="#FF9933"><td>
		&nbsp;
	</td></tr></table>
	<center><FONT SIZE=+1><B>Description</B></FONT></center>
	<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="$config{'colortablebody'}"><td>
			&nbsp;
	</td></tr></table>
	
	$desc</FONT></FONT></B></I></U></H1></H2></H3></H4></H5>
	
	<a name="bid">
	
	
EOF
	print "<center><a name=\"pic\"><IMG SRC=$image></center>" if ($image ne "");
	print "<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor=\"$config{'colortablebody'}\"><td>";
	print "&nbsp;</td></tr></table>";
		
		
	}		
	
	####################WANTED ADS
	
	if ($type eq 'Wanted'){
				
	 print <<"EOF";
	<a name="top"><!--Top of Page--></a>
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr bgcolor="#FFFFFF">
	<td>
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0><tr align=center bgcolor="#FFFFFF"><td>
	&nbsp;
	</td></tr>
	<TR align="center" bgcolor="#FF9933">
	<TD><CENTER><font face=verdana,arial,helvetica size=+2><B>Wanted Ad</B></font></center></TD>
	</TR>
	<tr bgcolor=$config{'colortablebody'}>
	<td>
	<table cellpadding=5 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 width=100%>
	<tr>
	<td valign=top>
	<font size=+1><A HREF=$ENV{'SCRIPT_NAME'}?action=search1><b> Search</A></b> </font>
	</td>
	<form method="post" action="$ENV{'SCRIPT_NAME'}?"> 
		<td valign=top align=right>
		<font size=-1> <b>Browse:</b> 
		<select name=\"category\">
		<option>&nbsp;</option>
EOF
				
				my $key;
				foreach $key (sort keys %category) {
					umask(000);  # UNIX file permission junk
					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
					closedir DIR;
					print "<option value=\"$key\"><B>$category{$key}</option></b>\n";
				}
		print <<"EOF";
		</select>
	<input type="submit" Value="GO!">
	</td></form></font>
	</tr></table>
	</td></tr></table>
	</td></tr></table>
	<table width="100%" border=0 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr><td width=60% align="left">
	   
	      <font face=verdana,arial,helvetica size=-2><a href=$ENV{'SCRIPT_NAME'}?>Home</a>     / 
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>$category{$form{'category'}}</a>               / 
	      <a href=$ENV{'SCRIPT_NAME'}?action=wa&category=$form{'category'}>Want Ads</a>     /      
	      <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}&item=$form{'item'}>     $title</a>     </font>
	</td>
	<td width="40%" align="right">
	<font face=verdana,arial,helvetica size=-2> <a href=$ENV{'SCRIPT_NAME'}?category=$form{'category'}>view more like this</a></font>
	</td></tr></table>
	
	
	<table border=0 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	<tr valign=top>
	  <td width=155>
	<table width=155 bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0 bgcolor=$config{'colortablehead'}>
	<tr valign=bottom align=center><td><B>Explore This Item</B></td></tr>
	<tr><td>     
	<TABLE border=0 width= 100% cellpadding=1 cellspacing=0 bgcolor=#CCCC99 ><TR> <TD width=100%>
	<TABLE width=100% border=0 cellpadding=0 cellspacing=0 bgcolor=#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100%> 
	
	<table border=0 cellspacing=0 cellpadding=2 width=100%> 
	
		
EOF
			print "<tr><td colspan=2 align=center><font face=verdana,arial,helvetica size=-1><b><font color=#CC6600>Shipping Method</font></b><BR>(requested)</font></td></tr>";
			print "<tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$ship</font></td></tr>";
			print "<tr><td colspan=2 align=center><font face=verdana,arial,helvetica size=-1><b><font color=#CC6600>Payment Options</b></font><br>(requested)</font></td></tr>";
			print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay0</font></td></tr>" if $pay0 ne "" ;
			print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay1</font></td></tr>" if $pay1 ne "" ;
			print " <tr>  <td width=2>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay2</font></td></tr>" if $pay2 ne "" ;
			print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay3</font></td></tr>" if $pay3 ne "" ;
			print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay4</font></td></tr>" if $pay4 ne "" ;
			print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay5</font></td></tr>" if $pay5 ne "" ;
			print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay6</font></td></tr>" if $pay6 ne "" ;
			print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-1>$pay7</font></td></tr>" if $pay7 ne "" ;
			print " <tr>  <td width=1>&nbsp;</td><td> <font face=verdana,arial,helvetica size=-2>$pay8</font></td></tr>" if $pay8 ne "" ;
			
			
			
	print <<"EOF";
	
	
	
	
	
	<tr><td colspan=2 align=center><strong><font face=verdana,arial,helvetica size=-1 color=#CC6600>Similar Items</font></strong></td></tr>
	<tr><td colspan=2 align=center><font face=verdana,arial,helvetica size=-1>
	<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
				<INPUT TYPE=HIDDEN NAME=searchstring VALUE="$title">
				<INPUT TYPE=image VALUE="View" SRC=$config{'vn'}>
				<INPUT TYPE=HIDDEN NAME=action VALUE="search">
				<INPUT TYPE=HIDDEN NAME=searchtype VALUE="keyword">
	</td></tr></form>
	<tr><td colspan=2 align=center><strong><font face=verdana,arial,helvetica size=-1 color=#CC6600>Share your thoughts</font></strong></td></tr>
	<tr><td colspan=2 align=center><font face=verdana,arial,helvetica size=-1><A HREF=mailto:enter_your_friends_email_here?subject=$title-at-$config{'sitename2'}>e-mail a friend about this Wanted Ad</a></font></td></tr>
	
	</table>
	</TD> </TR> </TABLE> </TD> </TR> </TABLE>  </td></tr></table>
	 </td>
	    <td>&nbsp;</td>
	    <td valign=top>
	
	
	<table border=0 width=100%>
	<tr valign="top"><td  align="left">
	
	   <font size=+1><b>$title</b></font><BR>
EOF
	print " <font size=-1><I><a href=\"\#pic\">Image Below</a></I></font>" if $image ne "";

	
	print <<"EOF";
	
	 <br>
	 <p>
	 
	 	<strong><font face=verdana,arial,helvetica size=-1>Buyer:</font></strong>&nbsp;
	 	<font face=verdana,arial,helvetica size=-1><A HREF=mailto:$email?subject=$title\aat\a$config{'sitename'}>$alias</A></font>
	 </font>
	 
EOF
##################################################################################################begin Feedback addon
&oops('ALIAS') unless (open(REGFILE, "$config{'basepath'}$config{'feeddata'}/$alias.dat"));
		my (@userbids) = <REGFILE>;
		close REGFILE;
		my $pt=0;
		my $nt=0;
		my $nnt=0;
		my @thebid;
		my $ot;
		my $fc;
		foreach $bid (@userbids) {
				@thebid = split(/\[\]/,$bid);

				#print "<table border=\"1\" bordercolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\" width=\"500\" bgcolor=\"#c0c0c0\">";
				#print "<tr><td width=75>Feedback by:</td><td>Item</td><td>Rating</td></tr>";
				#print "<tr><td>$thebid[3]</td><td>$thebid[5]</td>";
				if ($thebid[0] eq "1"){
				$pt++;
				#print "<td width=75><font color=\"#009933\"><b>Positive </b></font></td>"
				}
				else {
				
				}
				if ($thebid[1] eq "1"){
				$nt++;
				#print "<td width=75>Neutral</td>"
				   }
				else {
								
				}
				if ($thebid[2] eq "1"){
				$nnt++;
				#print "<td width=75><font color=\"#ff0000\">Negative </font></td>"
				 }
				else {
												
				}
				#print "</tr><tr><td colspan=3 align=center>Comment</td></tr><tr><td colspan=3>$thebid[6]</td></tr></table><br>";
			
	}
	$ot = $pt - $nnt;
	if ($ot < 0){
	$fc = "#ff0000";
	}
	else {
	}
	if ($ot == 0){
	$fc = "#000000";
	}
	else {
	}
	if ($ot > 0){
	$fc = "#009933";
	}
	else {
	}
	 
	 print <<"EOF";

		<table border="0" bordercolor="#000000" cellspacing="0" cellpadding="0" width="75" bgcolor="#ffffff">
		<tr>
			       <td align=center colspan=3><font color=\"$fc\"><b>Rating $ot</b></font> </td>
			</tr>
			<tr><td align=center>
			<form action="$config{'feedscript'}" METHOD=POST><input name="action" type="hidden" value="vrate">
			<input name="ALIAS" type="hidden" value="$alias">
			<input type="image" Value="View Rating" SRC=$config{'vf'}>
							 
		 </td></tr></form>
</table></center>	      

EOF

	
	#end Feedback addon	


	print <<"EOF";
	 	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 
	<strong><font face=verdana,arial,helvetica size=-1>High Price:</font></strong>&nbsp;
	<strong><font face=verdana,arial,helvetica size=-1>\$$bid</font></strong>

	
	
	
	
	<br>
	<strong><font face=verdana,arial,helvetica size=-1>Closes :</font></strong>&nbsp;
		<font face=verdana,arial,helvetica size=-1>$closetime </font>
	<br>
	
EOF

		
		my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]); # read the last bid
		if ((time > int($form{'item'})) && (time > (60 * $config{'aftermin'} + $time))) {
		####
		print "</td><td>&nbsp;</td>";
		print "<td align=\"right\" width=\"180\">";
		print "<div align=\"center\">";
		print "<table border=0 cellspacing=0 cellpadding=0 width=\"180\"><tr><td align=center bgcolor=$config{'colortablehead'}>";
		print "<FONT SIZE=+1><B>Purchase</B></FONT></td></tr></table>";
		print "<TABLE border=0 width= 180 cellpadding=1 cellspacing=0 bgcolor=\#CCCC99  cellspacing=0 cellpadding=0><TR> <TD width=100\%><TABLE width=100\% border=0 cellpadding=4 cellspacing=0 bgcolor=\#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100\%>";
		print "<div align=\"center\">";
		print "<FONT SIZE=-1 COLOR=#FF0000><B>ITEM IS NOW CLOSED</B></FONT><BR>";
					&closeit3($form{'category'},$form{'item'});
				}
	else {
			
&count_viewed;
		print "</td><td>&nbsp;</td>";
		print "<td align=\"right\" width=\"180\">";
		print "<div align=\"center\">";
		print "<table border=0 cellspacing=0 cellpadding=0 width=\"180\"><tr><td align=center bgcolor=$config{'colortablehead'}>";
		print "<FONT SIZE=+1><B>Sell Now</B></FONT></td></tr></table>";
		print "<TABLE border=0 width= 180 cellpadding=1 cellspacing=0 bgcolor=\#CCCC99  cellspacing=0 cellpadding=0><TR> <TD width=100\%><TABLE width=100\% border=0 cellpadding=4 cellspacing=0 bgcolor=\#CCCC99><TR> <TD bgcolor=$config{'colortablebody'} valign=top width=100\%>";
		print "<div align=\"center\">";
		print "<FONT SIZE=-1><I>The Maximum the Buyer is willing to Pay</I></font><BR><FONT SIZE=+1 COLOR=#FF0000> \$$bid</font><br>";
		print "Contact Buyer:<BR> <A HREF=mailto:$email?subject=$title\aat\a$config{'sitename'}><FONT SIZE=+1 COLOR=#FF0000>$alias</font></A>";
		
}
		print <<"EOF";
		
	<P></div>
	</TD> </TR> </TABLE>  </TD> </TR> </TABLE> 
	</td></tr></table></td></tr></table>
	<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="#FF9933"><td>
		&nbsp;
	</td></tr></table>
	<center><FONT SIZE=+1><B>Description</B></FONT></center>
	<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor="$config{'colortablebody'}"><td>
			&nbsp;
	</td></tr></table>
	
	$desc</FONT></FONT></B></I></U></H1></H2></H3></H4></H5>
	
	<a name="bid">
	
	
EOF
	print "<center><a name=\"pic\"><IMG SRC=$image></center>" if ($image ne "");
	print "<table border=0 width=100% cellspacing=0 cellpadding=0><tr align=center bgcolor=\"$config{'colortablebody'}\"><td>";
	print "&nbsp;</td></tr></table>";			
				
				
				
				
				
				
				
				
				
				
				
				
				
	}	
	

}
#-#############################################
# Sub: Buy It
# This begins the process of allowing items to be purchased

sub dispbuy {

	&oops("Item $form{'item'} could not be opened.") unless (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$form{'item'}));
	my $nowtime = localtime(time);
	my $closetime = localtime($form{'item'});
	my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[0]); # read first bid
	my $nowtime = localtime;
	my $key;
	my $file;
	print <<"EOF";
	<br>
	<table border=2 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
		<TR align="center" bgcolor="#FF9933">
		<TD align=right>&nbsp;Current Time:$nowtime</TD>
	</TR></table>
	<center><i><font face="bookman old style" color="#000000" size="+1">Buy-It Now Rules and User Agreement</font></i></center><br>
	<table border=2 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
		
		<TR align="center" bgcolor="$config{'colortablebody'}">
		<TD align=right>&nbsp;</TD>
	</TR></table>
	<B>By Using our Buy-It Now Feature You agree:<BR></b>
	  <li>
	  <ul>To Pay the Seller the full Amount of the Buy-It Now Price.</ul>
	  <ul>You are positive you Want to purchase the item.</ul>
	  <ul>You will respond to the Sellers Contact attempts.</ul>
	  <ul>You are able to enter into a Binding legal Contract.</ul>
 	 </li>
 	 <FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
	 <INPUT TYPE=HIDDEN NAME=action VALUE=procbuy>
	 <INPUT TYPE=HIDDEN NAME=ITEM VALUE=\"$form{'item'}\">
	<INPUT TYPE=HIDDEN NAME=CATEGORY VALUE=\"$form{'category'}\">
 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Item Title:</b> $title<BR>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Seller:</b> $alias<BR> 
 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><A HREF=$ENV{'SCRIPT_NAME'}?action=reg><font color=\"#FF0000\" size=\"-1\">Registration</A> is required!</font></B>
	<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i><font size=\"-1\"><A HREF=$ENV{'SCRIPT_NAME'}?action=la>Forgot it\?</a></font></i>
	<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Your Handle/Alias:</B><INPUT NAME=ALIAS TYPE=TEXT SIZE=15 MAXLENGTH=30> 
	<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i><font size=\"-1\"><A HREF=$ENV{'SCRIPT_NAME'}?action=lp>Forgot it\?</a></font></i>
	
	<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Your Password:</B> <INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=15 MAXLENGTH=30> 
	<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Buy-It Now Price:</B> \$$buyit<INPUT NAME=BID TYPE=HIDDEN VALUE=\"$buyit\"><BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=SUBMIT VALUE=\"Buy-It Now\"></form>
        
        
        <table border=2 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
			<TR align="center" bgcolor="#FF9933">
			<TD align=right>&nbsp;</TD>
	</TR></table>
 	 
EOF
		


		

}
#-#############################################
# Sub: Buy It
# This begins the process of allowing items to be purchased

sub dispbuyc {

	&oops("Item $form{'item'} could not be opened.") unless (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'category'},$form{'item'}));
	my $nowtime = localtime(time);
	my $closetime = localtime($form{'item'});
	my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[0]); # read first bid
	my $nowtime = localtime;
	my $key;
	my $file;
	print <<"EOF";
	
	<br>
		<table border=2 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
			<TR align="center" bgcolor="#FF9933">
			<TD align=right>&nbsp;Current Time:$nowtime</TD>
		</TR></table>
		<center><i><font face="bookman old style" color="#000000" size="+1">Buy-It Now Rules and User Agreement</font></i></center><br>
		<table border=2 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
			
			<TR align="center" bgcolor="$config{'colortablebody'}">
			<TD align=right>&nbsp;</TD>
	</TR></table>
	<B>By Using our Buy-It Now Feature You agree:<BR></b>
	  <li>
	  <ul>To Pay the Seller the full Amount of the Buy-It Now Price.</ul>
	  <ul>You are positive you Want to purchase the item.</ul>
	  <ul>You will respond to the Sellers Contact attempts.</ul>
	  <ul>You are able to enter into a Binding legal Contract.</ul>
 	 </li>
 	 <FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
	 <INPUT TYPE=HIDDEN NAME=action VALUE=procbuyc>
	 <INPUT TYPE=HIDDEN NAME=ITEM VALUE=\"$form{'item'}\">
	<INPUT TYPE=HIDDEN NAME=CATEGORY VALUE=\"$form{'category'}\">
 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Item Title:</b> $title<BR>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Seller:</b> $alias<BR> 
 	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><A HREF=$ENV{'SCRIPT_NAME'}?action=reg><font color=\"#FF0000\" size=\"-1\">Registration</A> is required!</font></B>
	<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i><font size=\"-1\"><A HREF=$ENV{'SCRIPT_NAME'}?action=la>Forgot it\?</a></font></i>
	
	<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Your Handle/Alias:</B> <INPUT NAME=ALIAS TYPE=TEXT SIZE=15 MAXLENGTH=30> 
	<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i><font size=\"-1\"><A HREF=$ENV{'SCRIPT_NAME'}?action=lp>Forgot it\?</a></font></i>
	
	<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Your Password:</B> <INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=15 MAXLENGTH=30> 
	<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>Buy-It Now Price:</B> \$$bid<INPUT NAME=BID TYPE=HIDDEN VALUE=\"$bid\"><BR>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=SUBMIT VALUE=\"Buy-It Now\"></form><br>
        
        
 	 <table border=2 width=100% bordercolor=$config{'colortableborder'} cellspacing=0 cellpadding=0>
	 			<TR align="center" bgcolor="#FF9933">
	 			<TD align=right>&nbsp;</TD>
	</TR></table>
EOF
		


		

}
#-#############################################
# Sub: Process Buy-It
# This processes Buy-It from a posted form

sub procbuy {
	my $cat;
	my ($password, @userbids);
	if ($config{'regdir'} ne "") {
		&oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE1'}, $form{'PHONE2'}, $form{'PHONE3'}, @userbids) = &read_reg_file($form{'ALIAS'});
		$form{'ALIAS'} = ucfirst(lc($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'});
	&oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') unless my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
	my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
	if ((time <= $form{'ITEM'}) or (time <= (60 * $config{'aftermin'} + $time))) {
		&oops('Your bid is too low.  Sorry.') if ($form{'BID'} < ($bid+$inc) and ($#bids)) or ($form{'BID'} < $bid);
		&oops('We are unable to append your bid to the auction item.  It appears to be a file write problem.') unless (open NEW, ">>$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat");
		if ($config{'flock'}) {
			flock(NEW, 2);
			seek(NEW, 0, 2);
		}
		
		print NEW "\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]$form{'BID'}\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'PHONE1'}\[\]$form{'PHONE2'}\[\]$form{'PHONE3'}";
		close NEW;
		
		print "<B>$form{'ALIAS'},$form{'CATEGORY'}$form{'ITEM'} your have Purchased item number $form{'ITEM'} for \$$form{'BID'} on ".scalar(localtime(time)).".</B><BR>You may want to print this notice as confirmation of your Purchase.<P>Please give the seller 24 Hours to contact you.<P>Go <A HREF=\"$ENV{'SCRIPT_NAME'}\?\">back to the Auction</A>\n";
		&closeitb($form{'CATEGORY'},$form{'ITEM'});
		&count_bid;
		
		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{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat"));
			print REGFILE "\n$form{'CATEGORY'}$form{'ITEM'}";
			close REGFILE;
			
		}
		&sendemail($email, $config{'admin_address'}, 'Item Sold!', "Item : $title\! Has Been Sold Using the Buy-It Button. Please Visit $config{'sitename'} again.") if ($config{'scripturl'} and $#bids);

	}
	else {
		print "Item number $form{'ITEM'} in category $form{'CATEGORY'} is now closed!<BR>Sorry...\n";
	}
	
}
#-#############################################
# Sub: Process Buy-It
# This processes Buy-It from a posted form

sub procbuyc {
	my $cat;
	my ($password, @userbids);
	if ($config{'regdir'} ne "") {
		&oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE1'}, $form{'PHONE2'}, $form{'PHONE3'}, @userbids) = &read_reg_file($form{'ALIAS'});
		$form{'ALIAS'} = ucfirst(lc($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'});
	&oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') unless my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
	my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
	if ((time <= $form{'ITEM'}) or (time <= (60 * $config{'aftermin'} + $time))) {
		&oops('Your bid is too low.  Sorry.') if ($form{'BID'} < ($bid+$inc) and ($#bids)) or ($form{'BID'} < $bid);
		&oops('We are unable to append your bid to the auction item.  It appears to be a file write problem.') unless (open NEW, ">>$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat");
		if ($config{'flock'}) {
			flock(NEW, 2);
			seek(NEW, 0, 2);
		}
		
		print NEW "\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]$form{'BID'}\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'PHONE1'}\[\]$form{'PHONE2'}\[\]$form{'PHONE3'}";
		close NEW;
		
		print "<B>$form{'ALIAS'},$form{'CATEGORY'}$form{'ITEM'} your have Purchased Classified ad item number $form{'ITEM'} for \$$form{'BID'} on ".scalar(localtime(time)).".</B><BR>You may want to print this notice as confirmation of your Purchase.<P>Please give the seller 24 Hours to contact you.<P>Go <A HREF=\"$ENV{'SCRIPT_NAME'}\?\">back to the Auction</A>\n";
		&closeitb($form{'CATEGORY'},$form{'ITEM'});
		&count_bid;
		
		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{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat"));
			print REGFILE "\n$form{'CATEGORY'}$form{'ITEM'}";
			close REGFILE;
			
		}
		&sendemail($email, $config{'admin_address'}, 'Classified Item Sold!', "Item : $title\! Has Been Sold Using the Buy-It Button. Please Visit $config{'sitename'} again.") if ($config{'scripturl'} and $#bids);

	}
	else {
		print "Item number $form{'ITEM'} in category $form{'CATEGORY'} is now closed!<BR>Sorry...\n";
	}
	
}



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

sub new {
	
	my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
	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, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
			$title =~ s/\"//g;  # quotes cause problems for a text input field
		}
	}
	my $inc ='1.00'; # default increment
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<H2>Post A New Auction Item  </H2>
<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>
<TABLE WIDTH=100% BORDER=1 bordercolor=#000000 BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0>
<INPUT TYPE=HIDDEN NAME=action VALUE=procnew>
<INPUT TYPE=HIDDEN NAME=TYPE VALUE=Auction>
<TR><TD width=50 VALIGN=TOP><B>Title/Item Name:</B></TD><TD><INPUT NAME=TITLE VALUE=\"$title\" TYPE=TEXT SIZE=50 MAXLENGTH=50><BR>No HTML</TD></TR>
<TR><TD VALIGN=TOP><B>Category:</B></TD><TD><SELECT NAME=CATEGORY>
<OPTION SELECTED></OPTION>
EOF
	my $key;
	foreach $key (sort keys %category) {
		print "<OPTION VALUE=\"$key\">$category{$key}</OPTION>\n";
	}
	print <<"EOF";
</SELECT>Select One</TD></TR>
<TR><TD VALIGN=TOP><B>Image URL:</B></TD><TD><INPUT NAME=IMAGE VALUE=\"$image\" TYPE=TEXT SIZE=50 VALUE="http://"><BR>Optional, should be no larger than 200x200</TD></TR>
<TR><TD VALIGN=TOP><B>Featured Item:</B></TD>
<TD><select name="FEAT" value="$feat">
    <option selected>No
	<option>Yes
    	</select>
</TD></TR>
<TR><TD VALIGN=TOP><B>Days Until Close:</B></TD><TD><INPUT NAME=DAYS TYPE=TEXT SIZE=3 MAXLENGTH=3>1-14 Days</TD></TR>



<TR><TD VALIGN=TOP><B>Shipping Method:</B></TD>
<TD><select name="SHIP" value=$ship>
    <option selected>See Description
	<option>Download
    	<option>Fed-Ex
	<option>UPS
	<option>Priority Mail
	<option>U.S. Mail
	<option>Pick-Up
	<option>Truck
</select></TD></TR>
<TR><TD VALIGN=TOP colspan=2><B>Payment Method(s):</B><br> Choose all payment methods you will accept.</TD><tr>
<TR><TD colspan=2 VALIGN=TOP align=center>
<table width=500 border=0><tr>
       <td width=150><input name="PAY0" type="radio" value="See Description">See Description</td>
       <td width=150><input name="PAY1" type="radio" value="Cash">Cash</td>
       <td width=200><input name="PAY2" type="radio" value="Check">Check</td>
</tr><tr>
       <td width=150><input name="PAY3" type="radio" value="Money Order">Money Order</td>
       <td width=150><input name="PAY4" type="radio" value="Visa">Visa</td>
       <td width=200><input name="PAY5" type="radio" value="Mastercard">Mastercard</td>
</tr><tr>
       <td width=150><input name="PAY6" type="radio" value="Amex">Amex</td>
       <td width=150><input name="PAY7" type="radio" value="Discover">Discover</td>
       <td width=200><input name="PAY8" type="radio" value="Online Payment service">Online Payment service</td>
</tr></table></TD><tr>







<TR><TD COLSPAN="2" VALIGN=TOP><B>Description:<BR></B>May include HTML - This should include the condition of the item, payment and shipping information, and
any other information the buyer should know.<BR>
<CENTER><a href="http://e-zauction.virtualave.net/cgi-bin/test.cgi?" target=new>Use our FREE Ad Formatter Here</a></CENTER></TD></tr>
<TR><TD COLSPAN="2" VALIGN=TOP ALIGN=CENTER><TEXTAREA NAME=DESC ROWS=15 COLS=85>$desc</TEXTAREA></TD></TR>
<TR><TD COLSPAN=2 VALIGN=TOP>Please note that by placing an item up for bid you are making a contract 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!</TD></TR>
<TR><TD VALIGN=TOP><B>Your Handle/Alias:</B></TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30><font color="#FF0000">** Required **</FONT><BR><B><A HREF="$ENV{'SCRIPT_NAME'}?action=reg">Registration</A> is required to post or bid!</B></TD></TR>
<TR><TD VALIGN=TOP><B>Your Password:</B></TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30><font color="#FF0000">** Required **</FONT></TD></TR>
<TR><TD VALIGN=TOP><B>Your Starting Bid:</B></TD><TD>\$<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=0><font color="#FF0000">** Required **</FONT></td></tr>
<TR><TD VALIGN=TOP><B>Your Reserve Price:</B></TD><TD>\$<INPUT NAME=RESERVE TYPE=TEXT SIZE=7 VALUE=0><BR>You are not obligated to sell below this price.  Leave blank if none.</TD></TR>
<TR><TD VALIGN=TOP><B>Bid Increment:</B></TD><TD>\$<INPUT NAME=INC TYPE=TEXT SIZE=7 VALUE="$inc"></TD></TR>
<TR><TD VALIGN=TOP><B>Buy-It Price:</B></TD><TD>\$<INPUT NAME=BUYIT TYPE=TEXT SIZE=7 VALUE="$buyit"><BR>If you want to set an Immediate sale Price. Enter the amount here and Bidder will have the Option to buy this item before the Auction Closes.  Leave blank if none.</TD></TR></TABLE>
EOF
	
	print <<"EOF";
<CENTER><INPUT TYPE=SUBMIT VALUE=Preview></CENTER>
EOF
print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

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

sub newc {
	
	my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
	if ($form{'REPOSTC'}) {
		$form{'REPOSTC'} =~ s/\W//g;
		if (-T "$config{'basepath'}$config{'closedir'}/$form{'REPOSTC'}.dat") {
			open THEFILE, "$config{'basepath'}$config{'closedir'}/$form{'REPOSTC'}.dat";
			($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
			$title =~ s/\"//g;  # quotes cause problems for a text input field
		}
	}
	my $inc ='1.00'; # default increment
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<H2>Post A New Classified Ad  </H2>
<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><br>
<TABLE WIDTH=100% BORDER=1 bordercolor=#000000 BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0>
<INPUT TYPE=HIDDEN NAME=action VALUE=procnew>
<INPUT TYPE=HIDDEN NAME=TYPE VALUE=Classified>
<TR><TD width=50 VALIGN=TOP><B>Title/Item Name:</B></TD><TD><INPUT NAME=TITLE VALUE=\"$title\" TYPE=TEXT SIZE=50 MAXLENGTH=50><BR>No HTML</TD></TR>
<TR><TD VALIGN=TOP><B>Category:</B></TD><TD><SELECT NAME=CATEGORY>
<OPTION SELECTED></OPTION>
EOF
	my $key;
	foreach $key (sort keys %category) {
		print "<OPTION VALUE=\"$key\">$category{$key}</OPTION>\n";
	}
	print <<"EOF";
</SELECT>Select One</TD></TR>
<TR><TD VALIGN=TOP><B>Image URL:</B></TD><TD><INPUT NAME=IMAGE VALUE=\"$image\" TYPE=TEXT SIZE=50 VALUE="http://"><BR>Optional, should be no larger than 200x200</TD></TR>
<TR><TD VALIGN=TOP><B>Featured Item:</B></TD>
<TD><select name="FEAT" value="$feat">
    <option selected>No
	<option>Yes
    	</select>
</TD></TR>


<TR><TD VALIGN=TOP><B>Days Until Close:</B></TD><TD><INPUT NAME=DAYS TYPE=TEXT SIZE=2 MAXLENGTH=3>1-14 Days</TD></TR>


<TR><TD VALIGN=TOP><B>Shipping Method:</B></TD>
<TD><select name="SHIP" value=$ship>
    <option selected>See Description
	<option>Download
    	<option>Fed-Ex
	<option>UPS
	<option>Priority Mail
	<option>U.S. Mail
	<option>Pick-Up
	<option>Truck
</select></TD></TR>
<TR><TD VALIGN=TOP colspan=2><B>Payment Method(s):</B><br> Choose all payment methods you will accept.</TD><tr>
<TR><TD colspan=2 VALIGN=TOP align=center>
<table width=500 border=0><tr>
       <td width=150><input name="PAY0" type="radio" value="See Description">See Description</td>
       <td width=150><input name="PAY1" type="radio" value="Cash">Cash</td>
       <td width=200><input name="PAY2" type="radio" value="Check">Check</td>
</tr><tr>
       <td width=150><input name="PAY3" type="radio" value="Money Order">Money Order</td>
       <td width=150><input name="PAY4" type="radio" value="Visa">Visa</td>
       <td width=200><input name="PAY5" type="radio" value="Mastercard">Mastercard</td>
</tr><tr>
       <td width=150><input name="PAY6" type="radio" value="Amex">Amex</td>
       <td width=150><input name="PAY7" type="radio" value="Discover">Discover</td>
       <td width=200><input name="PAY8" type="radio" value="Online Payment service">Online Payment service</td>
</tr></table></TD><tr>





<TR><TD COLSPAN="2" VALIGN=TOP><B>Description:<BR></B>May include HTML - This should include the condition of the item, payment and shipping information, and
any other information the buyer should know.<BR>
<CENTER><a href="http://e-zauction.virtualave.net/cgi-bin/test.cgi?" target=new>Use our FREE Ad Formatter Here</a></CENTER></TD></tr>
<TR><TD COLSPAN="2" VALIGN=TOP ALIGN=CENTER><TEXTAREA NAME=DESC ROWS=15 COLS=85>$desc</TEXTAREA></TD></TR>
<TR><TD COLSPAN=2 VALIGN=TOP>Please note that by placing an item up for bid you are making a contract 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!</TD></TR>
<TR><TD VALIGN=TOP><B>Your Handle/Alias:</B></TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30><font color="#FF0000">** Required **</FONT><BR><B><A HREF="$ENV{'SCRIPT_NAME'}?action=reg">Registration</A> is required to post or bid!</B></TD></TR>
<TR><TD VALIGN=TOP><B>Your Password:</B></TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30><font color="#FF0000">** Required **</FONT></TD></TR>
<TR><TD VALIGN=TOP><B>Your Sale Price:</B></TD><TD>\$<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=0><font color="#FF0000">** Required **</FONT><BR>You are not obligated to sell below this price.</td></tr>
<INPUT NAME=RESERVE TYPE=hidden SIZE=7 VALUE=0>
<INPUT NAME=INC TYPE=hidden SIZE=7 VALUE="$inc"></TABLE>
EOF
	
	print <<"EOF";
<CENTER><INPUT TYPE=SUBMIT VALUE=Preview></CENTER>
EOF
print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

#-#############################################
# Sub: Add New Wanted Ad
# This allows a new classified to be put up for sale

sub newwa {
	
	my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
	if ($form{'REPOSTW'}) {
		$form{'REPOSTW'} =~ s/\W//g;
		if (-T "$config{'basepath'}$config{'closedir'}/$form{'REPOSTW'}.dat") {
			open THEFILE, "$config{'basepath'}$config{'closedir'}/$form{'REPOSTW'}.dat";
			($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
			$title =~ s/\"//g;  # quotes cause problems for a text input field
		}
	}
	my $inc ='1.00'; # default increment
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<H2>Post A New Wanted Ad  </H2>
<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><br>
<TABLE WIDTH=100% BORDER=1 bordercolor=#000000 BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0>
<INPUT TYPE=HIDDEN NAME=action VALUE=procnew>
<INPUT TYPE=HIDDEN NAME=TYPE VALUE=Wanted>
<TR><TD width=50 VALIGN=TOP><B>Title/Item Name:</B></TD><TD><INPUT NAME=TITLE VALUE=\"$title\" TYPE=TEXT SIZE=50 MAXLENGTH=50><BR>No HTML</TD></TR>
<TR><TD VALIGN=TOP><B>Category:</B></TD><TD><SELECT NAME=CATEGORY>
<OPTION SELECTED></OPTION>
EOF
	my $key;
	foreach $key (sort keys %category) {
		print "<OPTION VALUE=\"$key\">$category{$key}</OPTION>\n";
	}
	print <<"EOF";
</SELECT>Select One</TD></TR>
<TR><TD VALIGN=TOP><B>Image URL:</B></TD><TD><INPUT NAME=IMAGE VALUE=\"$image\" TYPE=TEXT SIZE=50 VALUE="http://"><BR>Optional, should be no larger than 200x200</TD></TR>
<TR><TD VALIGN=TOP><B>Days Until Close:</B></TD><TD><INPUT NAME=DAYS TYPE=TEXT SIZE=3 MAXLENGTH=3>1-14 Days</TD></TR>
<TR><TD VALIGN=TOP><B>Featured Item:</B></TD>
<TD><select name="FEAT" value="$feat">
    <option selected>No
	<option>Yes
    	</select>
</TD></TR>


<TR><TD VALIGN=TOP><B>Shipping Method:</B></TD>
<TD><select name="SHIP" value=$ship>
    <option selected>See Description
	<option>Download
    	<option>Fed-Ex
	<option>UPS
	<option>Priority Mail
	<option>U.S. Mail
	<option>Pick-Up
	<option>Truck
</select></TD></TR>
<TR><TD VALIGN=TOP colspan=2><B>Payment Method(s):</B><br> Choose all payment methods you will accept.</TD><tr>
<TR><TD colspan=2 VALIGN=TOP align=center>
<table width=500 border=0><tr>
       <td width=150><input name="PAY0" type="radio" value="See Description">See Description</td>
       <td width=150><input name="PAY1" type="radio" value="Cash">Cash</td>
       <td width=200><input name="PAY2" type="radio" value="Check">Check</td>
</tr><tr>
       <td width=150><input name="PAY3" type="radio" value="Money Order">Money Order</td>
       <td width=150><input name="PAY4" type="radio" value="Visa">Visa</td>
       <td width=200><input name="PAY5" type="radio" value="Mastercard">Mastercard</td>
</tr><tr>
       <td width=150><input name="PAY6" type="radio" value="Amex">Amex</td>
       <td width=150><input name="PAY7" type="radio" value="Discover">Discover</td>
       <td width=200><input name="PAY8" type="radio" value="Online Payment service">Online Payment service</td>
</tr></table></TD><tr>




<TR><TD COLSPAN="2" VALIGN=TOP><B>Description:<BR></B>May include HTML - This should include the condition of the item, payment and shipping information, and
any other information the buyer should know.<BR>
<CENTER><a href="http://e-zauction.virtualave.net/cgi-bin/test.cgi?" target=new>Use our FREE Ad Formatter Here</a></CENTER></TD></tr>
<TR><TD COLSPAN="2" VALIGN=TOP ALIGN=CENTER><TEXTAREA NAME=DESC ROWS=15 COLS=85>$desc</TEXTAREA></TD></TR>
<TR><TD COLSPAN=2 VALIGN=TOP>Please note that by placing an item up for bid you are making a contract 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!</TD></TR>
<TR><TD VALIGN=TOP><B>Your Handle/Alias:</B></TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30><font color="#FF0000">** Required **</FONT><BR><B><A HREF="$ENV{'SCRIPT_NAME'}?action=reg">Registration</A> is required to post or bid!</B></TD></TR>
<TR><TD VALIGN=TOP><B>Your Password:</B></TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30><font color="#FF0000">** Required **</FONT></TD></TR>
<TR><TD VALIGN=TOP><B>Your Max Price:</B></TD><TD>\$<INPUT NAME=BID TYPE=TEXT SIZE=7 VALUE=0><font color="#FF0000">** Required **</FONT><BR>This is the Maximum You want to pay for this item.</td></tr>
<INPUT NAME=RESERVE TYPE=hidden SIZE=7 VALUE=0>
<INPUT NAME=INC TYPE=hidden SIZE=7 VALUE="$inc"></TABLE>
EOF
	
	print <<"EOF";
<CENTER><INPUT TYPE=SUBMIT VALUE=Preview></CENTER>
EOF
print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}


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

sub procnew {
	my ($password, @userbids);
	if ($config{'regdir'} ne "") {
		&oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE1'}, $form{'PHONE2'}, $form{'PHONE3'}, @userbids) = &read_reg_file($form{'ALIAS'});
		$form{'ALIAS'} = ucfirst(lc($form{'ALIAS'}));
		&oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));
	}
	&oops('You must have an item title that is up to 50 characters.') unless ($form{'TITLE'} && (length($form{'TITLE'}) < 51));
	$form{'TITLE'} =~ s/\</\&lt\;/g;
	$form{'TITLE'} =~ s/\>/\&gt\;/g;
        &oops('You must select a valid category.') unless (-d "$config{'basepath'}$form{'CATEGORY'}" and $category{$form{'CATEGORY'}});
	$form{'IMAGE'} = "" if ($form{'IMAGE'} eq "http://");
	&oops('You must enter the number of days your auction should run, from 1 to 14.') unless (($form{'DAYS'} > 0) and ($form{'DAYS'} < 15));
	&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'} =~ /^.+\@.+\..+$/);
	&oops('You must enter a valid starting bid.') unless ($form{'BID'} =~ /^(\d+\.?\d*|\.\d+)$/);
	&oops('You must enter a valid bid increment.') unless (($form{'INC'} =~ /^(\d+\.?\d*|\.\d+)$/) and ($form{'INC'} >= .01));
	$form{'INC'} = &parsebid($form{'INC'});
	$form{'RESERVE'} = &parsebid($form{'RESERVE'});
	&oops('You must enter your full 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"));
	if ($form{'FROMPREVIEW'}) {
		my $key;
		foreach $key (keys %form) {
			$form{$key} =~ s/\[greaterthansign\]/\>/gs;
			$form{$key} =~ s/\[lessthansign\]/\</gs;
			$form{$key} =~ s/\[quotes\]/\"/gs;
		}
		&oops('We are unable to post your item.  This could be a write permissions problem.') unless (open (NEW, ">$config{'basepath'}$form{'CATEGORY'}/$item_number.dat"));
		print NEW "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESC'}\n$form{'IMAGE'}\n$form{'TYPE'}\n$form{'BUYIT'}\n$form{'SHIP'}\n$form{'PAY0'}\n$form{'PAY1'}\n$form{'PAY2'}\n$form{'PAY3'}\n$form{'PAY4'}\n$form{'PAY5'}\n$form{'PAY6'}\n$form{'PAY7'}\n$form{'PAY8'}\n$form{'FEAT'}\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]".&parsebid($form{'BID'})."\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'PHONE1'}\[\]$form{'PHONE2'}\[\]$form{'PHONE3'}";
		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{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat"));
			print REGFILE "\n$form{'CATEGORY'}$item_number";
			close REGFILE;
		}
		print "<B>$form{'TITLE'} was posted as a $form{'TYPE'}  under $category{$form{'CATEGORY'}}...</B>.<BR>You may want to go to <A HREF=\"$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$item_number\">the item</A> to confirm placement.\n\n";
	}
	else {
		my $nowtime = localtime(time);
		my $closetime = localtime($item_number);
		print "<H2>$form{'TITLE'} PREVIEW $form{'TYPE'}</H2><HR><FONT SIZE=+1><B>Information</B></FONT><HR>\n";
		print "<TABLE WIDTH=100\%><TR>";
		print "<TD BGCOLOR=$config{'colortablebody'}><IMG SRC=$form{'IMAGE'}></TD>" if ($form{'IMAGE'});
		print "<TD><TABLE BORDER=1><TR><TD BGCOLOR=$config{'colortablehead'}><B>$form{'TITLE'}</B></TD></TR><TR><TD BGCOLOR=$config{'colortablebody'}><B>Category:</B> <A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}>$category{$form{'CATEGORY'}}</A></TD></TR><TR><TD BGCOLOR=$config{'colortablebody'}><B>Offered By:</B> <A HREF=mailto:$form{'EMAIL'}>$form{'ALIAS'}</A></TR></TD><TR><TD BGCOLOR=$config{'colortablebody'}><B>Current Time:</B> $nowtime</TD></TR><TR><TD BGCOLOR=$config{'colortablebody'}><B>Closes:</B> $closetime<BR><FONT SIZE=-2>Or $config{'aftermin'} minutes after last bid...</FONT></TD></TR><TR><TD BGCOLOR=$config{'colortablebody'}><B>Number of Bids:</B> 0</TD></TR><TR><TD BGCOLOR=$config{'colortablebody'}><B>Last Bid:</B> \$$form{'BID'}</TD></TR>";
		print "<TR><TD BGCOLOR=$config{'colortablebody'}><B>Buy-It Price:</B> \$$form{'BUYIT'}</TD></TR>" if ($form{'BUYIT'} ne "");
		print "</TABLE></TD></TR></TABLE>\n";
		print "<HR><FONT SIZE=+1><B>Description</B></FONT><HR>$form{'DESC'}</FONT></FONT></B></I></U></H1></H2></H3></H4></H5>";
		print "<HR><B><FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>If this looks good, hit <INPUT TYPE=SUBMIT VALUE=\"Post Item\">, else hit the back button on your browser to edit the item.<INPUT TYPE=HIDDEN NAME=FROMPREVIEW VALUE=1></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";
		&count_post;
	}
}

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

sub procbid {
	my ($password, @userbids);
	if ($config{'regdir'} ne "") {
		&oops('Your alias could not be found!') unless ($password, $form{'EMAIL'}, $form{'ADDRESS1'}, $form{'ADDRESS2'}, $form{'ADDRESS3'}, $form{'PHONE1'}, $form{'PHONE2'}, $form{'PHONE3'}, @userbids) = &read_reg_file($form{'ALIAS'});
		$form{'ALIAS'} = ucfirst(lc($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'});
	&oops('The item number you entered cannot be found.  Maybe it has closed or it was moved since you last loaded the page.') unless my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($form{'CATEGORY'},$form{'ITEM'});
	my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
	if ((time <= $form{'ITEM'}) or (time <= (60 * $config{'aftermin'} + $time))) {
		&oops('Your bid is too low.  Sorry.') if ($form{'BID'} < ($bid+$inc) and ($#bids)) or ($form{'BID'} < $bid);
		&oops('We are unable to append your bid to the auction item.  It appears to be a file write problem.') unless (open NEW, ">>$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat");
		if ($config{'flock'}) {
			flock(NEW, 2);
			seek(NEW, 0, 2);
		}
		print NEW "\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]$form{'BID'}\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}\[\]$form{'PHONE1'}\[\]$form{'PHONE2'}\[\]$form{'PHONE3'}";
		close NEW;
		print "<B>$form{'ALIAS'}, your bid has been placed on item number $form{'ITEM'} for \$$form{'BID'} on ".scalar(localtime(time)).".</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";
		&count_bid;
		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{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat"));
			print REGFILE "\n$form{'CATEGORY'}$form{'ITEM'}";
			close REGFILE;
		}
		&sendemail($email, $config{'admin_address'}, 'You\'ve been outbid!', "You have been outbid on $title\!  If you want to place a higher bid, please visit\:\n\n\thttp://$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$form{'CATEGORY'}\&item=$form{'ITEM'}\n\nThe current high bid is \$$form{'BID'}.") if ($config{'scripturl'} and $#bids);
	}
	else {
		print "Item number $form{'ITEM'} in category $form{'CATEGORY'} is now closed!<BR>Sorry...\n";
	}
}


#-#############################################
# Sub: Change Registration
# This allows a user to change information

sub chreg {
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<center><H2>Change Contact Information</H2>
<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><br>
<TABLE WIDTH=500 BORDER=1 bordercolor=$config{'colortablehead'} BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0>
<INPUT TYPE=HIDDEN NAME=action VALUE=proccreg>
<TR><TD COLSPAN=2 VALIGN=TOP align=center><B> This form will allow you to change your
contact information.</B>
</TD></TR>
<TR><TD VALIGN=TOP><B>Your Handle/Alias:<BR></B>Required for verification</TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30>
<TR><TD VALIGN=TOP><B>Your Current Password:<BR></B>Required for verification</TD><TD><INPUT NAME=OLDPASS TYPE=PASSWORD SIZE=30>
<TR><TD VALIGN=TOP><B>Your New Password:<BR></B>Leave blank if unchanged</TD><TD><INPUT NAME=NEWPASS1 TYPE=PASSWORD SIZE=30>
<TR><TD VALIGN=TOP><B>Your New Password Again:<BR></B>Leave blank if unchanged</TD><TD><INPUT NAME=NEWPASS2 TYPE=PASSWORD SIZE=30>
<TR><TD VALIGN=TOP colspan=2><B>Contact Information:<BR></B><center>Leave blank if unchanged</center></TD></tr>
<Td>Full Name: </Td><td><INPUT NAME=ADDRESS1 TYPE=TEXT SIZE=30></td></tr>
<Td>Street Address: </Td><td><INPUT NAME=ADDRESS2 TYPE=TEXT SIZE=30></td></tr>
<Td>City, State, ZIP: </Td><td><INPUT NAME=ADDRESS3 TYPE=TEXT SIZE=30></TD></TR>
<TR><TD>Phone Number: </TD><TD> ( <INPUT NAME=PHONE1 TYPE=TEXT SIZE=3 maxlength=3> ) <INPUT NAME=PHONE2 TYPE=TEXT SIZE=3 maxlength=3> - <INPUT NAME=PHONE3 TYPE=TEXT SIZE=4 maxlength=4></TD></TR></TABLE>
</TABLE>
<INPUT TYPE=SUBMIT VALUE="Change Registration"></CENTER>
EOF
print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

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

sub proccreg {
	if ($config{'regdir'}) {
		&oops('Your 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{'ADDRESS1'}) {
			&oops('You must enter all of your contact information.  Please enter your street address.') unless ($form{'ADDRESS2'});
			&oops('You must enter all of your contact information.  Please enter your city, state, and zip.') unless ($form{'ADDRESS3'});
		}
		if ($form{'NEWPASS1'}) {
			&oops('Your new passwords do not match.') unless ($form{'NEWPASS2'} eq $form{'NEWPASS1'});
		}
		if (my ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@past_bids) = &read_reg_file($form{'ALIAS'})) {
			$form{'ALIAS'} = ucfirst(lc($form{'ALIAS'}));
			&oops('Your old password does not match up.') unless ((lc $password) eq (lc $form{'OLDPASS'}));
			$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{'PHONE1'} = $phone1 if !($form{'PHONE1'});
			$form{'PHONE2'} = $phone2 if !($form{'PHONE2'});
			$form{'PHONE3'} = $phone3 if !($form{'PHONE3'});
			&oops('We cannot open your account.  This could be a server data write issue.') unless (open NEWREG, ">$config{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat");
			print NEWREG "$form{'NEWPASS1'}\n$email\n$form{'ADDRESS1'}\n$form{'ADDRESS2'}\n$form{'ADDRESS3'}\n$form{'PHONE1'}\n$form{'PHONE2'}\n$form{'PHONE3'}";
			my $bid;
			foreach $bid (@past_bids) {
				print NEWREG "\n$bid";
			}
			close NEWREG;
			print "$form{'ALIAS'}, your information has been successfully 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=reg>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: New Registration Agreement
# This is a form informing new users of your Site Rules

sub reg {
	print <<"EOF";
<CENTER><FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<H2>New User Agreement</H2>
<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>
<INPUT TYPE=HIDDEN NAME=action VALUE=creg>
<TABLE WIDTH=100% BORDER=1 bordercolor=#000000 BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0>
<TR><TD COLSPAN=2 VALIGN=TOP BGCOLOR=$config{'colortablehead'}> <CENTER><font size=+1>Terms of Registration for $config{'sitename'}</font> <BR>
<I>You must Agree to all terms and conditions of this document before registering with this Auction Site.</I></CENTER> </td></tr>
<TR><TD><I>Article 1:</I></td>
<TD width="500"> Eligibility of membership - This auction site ( $config{'sitename'} ) is only available to people who are legally able to form binding contracts with you and the seller/buyer of an auction item. People who are of under age of 18 are not eligible for membership due to security precautions that can result as of those members.<BR><U> If you do not meet these requirements, you are not eligible to use these auction services.</U> </td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>
<TR><TD><I>Article 2:</I></td>
<TD width="500"> $config{'sitename'} is only providing auction services - We only provide services to people interested in selling and buying merchandise via internet auction. We do not have control over the items that are posted in the auction site, and cannot guarantee the authenticity and quality of a said product. We are not responsible for the actions the sellers takes, before, during, and after the auction, typographical errors, mis-prints, loss of merchandise/money, damage or failure of equipment, due to your visit to this auction site.<BR><U> Use of this site is at your own risk, and content is presented 'As-Is'</U>. </td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>
<TR><TD><I>Article 3:</I></td>
<TD width="500"><I>Article 3a:</I>&nbsp;&nbsp;&nbsp;<U>Bidding and Selling </U>- As a user, you may bid and/or sell merchandise over $config{'sitename'} .<BR><I>Article 3b:</I>&nbsp;&nbsp;&nbsp;<U> As a bidder</U> - you know that placing a bid is a binding contract with you and the seller, and the bid cannot be retracted unless due to fault by the seller of typographical error, or other error, due to human error on the seller's part. Once you place a bid, and if you win, you will be obligated to buy the product at the said 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 to you.<BR><I>Article 3c:</I>&nbsp;&nbsp;&nbsp;<U> As a seller</U> - the item that you place up for bids must be real. Pre-sales are not accepted. Once a bid has been placed for your item, you are being placed in a binding contract with the potential buyer of the product, if that bid shall be the highest bid. Once the auction is over, if over reserve price, you are obligated to sell to the potential buyer which is the highest bidder in your auction. If, reserve price was not met, you are not obilgated in any way to sell this item at all. As a seller, you are not in any way to bid on your own items. If reported, your auction will be deleted.</td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>
<TR><TD><I>Article 4:</I></td>
<TD width="500"> Posting Items - As a user, you are welcome to post 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, or anything that is affiliated with Violence, 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. </td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>
<TR><TD><I>Article 5:</I></td>
<TD width="500"> Charges - Posting an item up for bid, bidding on an item, and registering are free at $config{'sitename'}. Do not abuse this privilege. </td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>
<TR><TD><I>Article 6:</I></td>
<TD width="500"> Privacy - We gather your information so that other people will have it on hand when they win your auction, or you win their auction. Personal information is not sold, rented, without yuor permission. Personal information sent to a user regarding a product bought or sold on the auction is not to be used for any other purpose, except for communication concerning the auction item. </td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>
<TR><TD><I>Article 7:</I></td>
<TD width="500"> Warranty - $config{'sitename'} provide this website in an 'as-is' condition, without a warranty or condition. $config{'sitename'} is not liable for any damages resulting in an auction, or your visit to the site. </td></tr>
<TD COLSPAN=2 VALIGN=TOP>&nbsp;</td></tr>


</table>
<CENTER><INPUT TYPE=SUBMIT VALUE="I Agree"></CENTER>
EOF
print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

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

sub creg {
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<center><H2>New User Registration</H2>
<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>
<TABLE WIDTH=500 BORDER=1 bordercolor=#000000 BGCOLOR=$config{'colortablebody'} cellspacing=0 cellpadding=0>
<INPUT TYPE=HIDDEN NAME=action VALUE=procreg>
<TR><TD COLSPAN=2 VALIGN=TOP>This form will allow you to register to buy or sell
auction items.  You must enter accurate data, and your new password will be e-mailed
to you.  Please be patient after hitting the submit button.  Registration may take
a few seconds.</TD></TR>
<TR><TD VALIGN=TOP><B>Your Handle/Alias:<BR></B>Used to track your post</TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30></TD></TR>
<TR><TD VALIGN=TOP><B>Your E-Mail Address:<BR></B>Must be valid</TD><TD><INPUT NAME=EMAIL TYPE=TEXT SIZE=30></TD></TR>
<TR><TD VALIGN=TOP COLSPAN=2><B>Contact Information:<BR></B><center>Will be given out only to the buyer or seller</center></TD></TR>
<TR><TD>Full Name: </TD><TD><INPUT NAME=ADDRESS1 TYPE=TEXT SIZE=30></TR>
<TR><TD>Street Address: </TD><TD><INPUT NAME=ADDRESS2 TYPE=TEXT SIZE=30></TR>
<TR><TD>City, State, ZIP: </TD><TD><INPUT NAME=ADDRESS3 TYPE=TEXT SIZE=30></TD></TR>
<TR><TD>Phone Number: </TD><TD> ( <INPUT NAME=PHONE1 TYPE=TEXT SIZE=3 maxlength=3> ) <INPUT NAME=PHONE2 TYPE=TEXT SIZE=3 maxlength=3> - <INPUT NAME=PHONE3 TYPE=TEXT SIZE=4 maxlength=4></TD></TR></TABLE>
<CENTER><INPUT TYPE=SUBMIT VALUE="Register Me"></CENTER>
EOF
print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}

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

sub procreg {
	if ($config{'regdir'}) {
		umask(000);  # UNIX file permission junk
		mkdir("$config{'basepath'}$config{'regdir'}", 0777) unless (-d "$config{'basepath'}$config{'regdir'}");		
		&oops('You must enter an alias that consists of alphanumeric characters.') if $form{'ALIAS'} =~ /\W/ or !($form{'ALIAS'});
		&oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
		&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 an Area code so buyers or sellers can contact you.') unless ($form{'PHONE1'});
		&oops('You must enter a Phone number so buyers or sellers can contact you.') unless ($form{'PHONE2'});
		&oops('You must enter a Phone number so buyers or sellers can contact you.') unless ($form{'PHONE3'});
		$form{'ALIAS'} = ucfirst(lc($form{'ALIAS'}));
		if (!(-f "$config{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat")) {
			&oops('We were unable to write to the user directory.') unless (open NEWREG, ">$config{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat");
			my $newpass = &randompass; 
			print NEWREG "$newpass\n$form{'EMAIL'}\n$form{'ADDRESS1'}\n$form{'ADDRESS2'}\n$form{'ADDRESS3'}\n$form{'PHONE1'}\n$form{'PHONE2'}\n$form{'PHONE3'}";
			close NEWREG;
			print "<P>$form{'ALIAS'},<BR> You should receive an e-mail to $form{'EMAIL'} in a few minutes.  It will contain your password needed to post or bid. <BR> You may change your password once you receive it.<P><CENTER> <STRONG> If you do not get an e-mail, please re-register.</STRONG></CENTER>\n";
			&sendemail($form{'EMAIL'}, $config{'admin_address'}, 'Auction Password', "PLEASE DO NOT REPLY TO THIS E-MAIL.\n\nThank you for registering to use the online auctions at $config{'sitename'}!\n\nTo return to our Auction site Visit this URL $config{'mailurl'}\n\nYour new password is: $newpass\nYour alias (as you entered it) is: $form{'ALIAS'}\n\nThank you for visiting!");
		&count_user;
		}
		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";
	}
	#####################Begins Feedback addon
	if ($config{'feeddata'}) {
			umask(000);  # UNIX file permission junk
		mkdir("$config{'basepath'}$config{'feeddata'}", 0777) unless (-d "$config{'basepath'}$config{'feeddata'}");
	if (!(-f "$config{'basepath'}$config{'feeddata'}/$form{'ALIAS'}.dat")) {
		&oops('We were unable to write to the user directory.') unless (open NEWFEED, ">$config{'basepath'}$config{'feeddata'}/$form{'ALIAS'}.dat");
		print NEWFEED "";
		close NEWFEED;
		}
		else {
				print "User Registration is Not Implemented on This Server!  The System Administrator Did Not Specify a Registration Directory...\n";
	}
	}
	#####################Ends Feedback addon
}	


#-#############################################
# Sub: Admin
# Allows the administrator to delete items.

sub admin {
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<H2>Delete Items</H2>
<TABLE WIDTH=100% BORDER=1 BGCOLOR=$config{'colortablebody'}>
<INPUT TYPE=HIDDEN NAME=action VALUE=procadmin>
<TR><TD COLSPAN=2 VALIGN=TOP> This form will allow you to delete an item.  You will need the
administrator password that should be configured in the script.
</TD></TR>
<TR><TD VALIGN=TOP><B>Category:<BR></B>Select One</TD><TD><SELECT NAME=CATEGORY>
<OPTION SELECTED></OPTION>
EOF
	my $key;
	foreach $key (sort keys %category) {
		print "<OPTION VALUE=\"$key\">$category{$key}</OPTION>\n";
	}
	print <<"EOF";
</SELECT></TD></TR>
<TR><TD VALIGN=TOP><B>Item Number:<BR></B></TD><TD><INPUT NAME=ITEM TYPE=TEXT SIZE=30 MAXLENGTH=30>
<TR><TD VALIGN=TOP><B>Administrator Password:<BR></B>Required for verification</TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30>
</TD></TR></TABLE>
<CENTER><INPUT TYPE=SUBMIT VALUE="Delete Item"></CENTER>
EOF
}

#-#############################################
# Sub: Process Admin
# Allows the administrator to delete items.

sub procadmin {
	if (lc($form{'PASSWORD'}) eq lc($config{'adminpass'})) {
		&oops('Bad Item Category or Number!') unless &read_item_file($form{'CATEGORY'},$form{'ITEM'});
		if (unlink("$config{'basepath'}$form{'CATEGORY'}/$form{'ITEM'}.dat")) {
			print "File Successfully Removed!\n";
		}
		else {
			print "File Could Not Be Removed!\n";
		}
	}
	else {
		print "Sorry...  Incorrect administrator password for delete!\n";
	}
}
#-#############################################
# Sub: Close Auction Buy It
# This sets an item's status to closed.

sub closeitb {
	my ($cat,$item) = @_;
	if ($cat ne $config{'closedir'}) {
		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($cat,$item);
		my @lastbid = &read_bid($bids[$#bids]);
		my @firstbid =  &read_bid($bids[0]);
		if ($#bids) {
			if ($lastbid[2] >= $reserve) {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You are the winner of auction number $item.\nYour winning bid was \$$lastbid[2].\n\nPlease contact the seller to make arrangements for payment and shipping:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			else {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You were the high bidder on auction number $item.\nYour bid was \$$lastbid[2].\n\nUnfortunately, your bid did not meet the seller\'s reserve price...\n\nYou may still wish to contact the seller to negotiate a fair price:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			#&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
		}
		else {
			&sendemail($firstbid[1], $config{'admin_address'}, "Auction Close: $title", "Auction number $item is now closed.\nThere were no bids on your item.  You may repost your item by using the closed auction manager at http://$config{'scripturl'}$ENV{'SCRIPT_NAME'}.  Thanks for using $config{'sitename'}!");
		}
		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");
		}
	}
}
#-#############################################
# Sub: Close Auction
# This sets an item's status to closed.

sub closeit {
	my ($cat,$item) = @_;
	if ($cat ne $config{'closedir'}) {
		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($cat,$item);
		my @lastbid = &read_bid($bids[$#bids]);
		my @firstbid =  &read_bid($bids[0]);
		if ($#bids) {
			if ($lastbid[2] >= $reserve) {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You are the winner of auction number $item.\nYour winning bid was \$$lastbid[2].\n\nPlease contact the seller to make arrangements for payment and shipping:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			else {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You were the high bidder on auction number $item.\nYour bid was \$$lastbid[2].\n\nUnfortunately, your bid did not meet the seller\'s reserve price...\n\nYou may still wish to contact the seller to negotiate a fair price:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			#&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
		}
		else {
			&sendemail($firstbid[1], $config{'admin_address'}, "Auction Close: $title", "Auction number $item is now closed.\nThere were no bids on your item.  You may repost your item by using the closed auction manager at http://$config{'scripturl'}$ENV{'SCRIPT_NAME'}.  Thanks for using $config{'sitename'}!");
		}
		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");
		}
	}
}
#-#############################################
# Sub: Close Classifieds
# This sets a Classified ad status to closed.

sub closeit2 {
	my ($cat,$item) = @_;
	if ($cat ne $config{'closedir'}) {
		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($cat,$item);
		my @lastbid = &read_bid($bids[$#bids]);
		my @firstbid =  &read_bid($bids[0]);
		if ($#bids) {
			if ($lastbid[2] >= $reserve) {
				&sendemail($lastbid[1], $firstbid[1], "Classifieds Close: $title", "Congratulations!  You have purchased Classified number $item.\nYour winning bid was \$$lastbid[2].\n\nPlease contact the seller to make arrangements for payment and shipping:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Classifieds Close: $title", "Classified number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			else {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You were the high bidder on auction number $item.\nYour bid was \$$lastbid[2].\n\nUnfortunately, your bid did not meet the seller\'s reserve price...\n\nYou may still wish to contact the seller to negotiate a fair price:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			#&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
		}
		else {
			&sendemail($firstbid[1], $config{'admin_address'}, "Classified ad Close: $title", "Classified ad $item is now closed.\nWe Hope that you were able to sell your Item.   Thanks for using $config{'sitename'}!");
		}
		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");
		}
	}
}
#-#############################################
# Sub: Close Wanted Ad
# This sets a Wanted ad status to closed.

sub closeit3 {
	my ($cat,$item) = @_;
	if ($cat ne $config{'closedir'}) {
		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($cat,$item);
		my @lastbid = &read_bid($bids[$#bids]);
		my @firstbid =  &read_bid($bids[0]);
		if ($#bids) {
			if ($lastbid[2] >= $reserve) {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You are the winner of auction number $item.\nYour winning bid was \$$lastbid[2].\n\nPlease contact the seller to make arrangements for payment and shipping:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			else {
				&sendemail($lastbid[1], $firstbid[1], "Auction Close: $title", "Congratulations!  You were the high bidder on auction number $item.\nYour bid was \$$lastbid[2].\n\nUnfortunately, your bid did not meet the seller\'s reserve price...\n\nYou may still wish to contact the seller to negotiate a fair price:\n\n$firstbid[4]\n$firstbid[5]\n$firstbid[6]\n$firstbid[7]-$firstbid[8]-$firstbid[9]\n$firstbid[1]\n\nThanks for using $config{'sitename'}!");
				&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[7]-$lastbid[8]-$lastbid[9]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
			}
			#&sendemail($firstbid[1], $lastbid[1], "Auction Close: $title", "Auction number $item is now closed.\nThe high bid was \$$lastbid[2] (your reserve was: \$$reserve).\n\nPlease contact the high bidder to make any necessary arrangements:\n\n$lastbid[4]\n$lastbid[5]\n$lastbid[6]\n$lastbid[1]\n\nThanks for using $config{'sitename'}!");
		}
		else {
			&sendemail($firstbid[1], $config{'admin_address'}, "Wanted Ad Close: $title", "Wanted Ad $item is now closed.\nWe Hope that you were able to Find the Item you requested.   Thanks for using $config{'sitename'}!");
		}
		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");
		}
	}
}
#-#############################################
# SUB: Send E-mail
# This is a real quick-and-dirty mailer that
# should work on any platform.  It is my first
# attempt to work with sockets, so if anyone
# has any suggestions, let me know!
#
# Takes:
# (To, Subject, From, Message)

sub sendemail {
        my ($to,$from,$subject,$message) = @_;
        my $trash;
        if ($config{'mailhost'}) {
		eval('use IO::Socket; 1;') or &oops("IO::Socket could not be loaded by the script.  Please see the script documentation for details.  It looks like this server is using perl version $].  IO::Socket may not be included with versions of perl prior to 5.00404."); # don't cause errors on machines where IO::Socket is not available
                my $remote;
                $remote = IO::Socket::INET->new("$config{'mailhost'}:smtp(25)");
                $remote->autoflush();
                print $remote "HELO\r\n";
                $trash = <$remote>;
                print $remote "MAIL From:<$config{'admin_address'}>\r\n";
                $trash = <$remote>;
                print $remote "RCPT To:<$to>\r\n";
                $trash = <$remote>;
                print $remote "DATA\r\n";
                $trash = <$remote>;
                print $remote "From: <$from>\r\nSubject: $subject\r\n\r\n";
                print $remote $message;
                print $remote "\r\n.\r\n";
                $trash = <$remote>;
                print $remote "QUIT\r\n";
        }
        else {
                open MAIL, "|$config{'mailprog'}";
                print MAIL "To: $to\nFrom: $from\nSubject: $subject\n\n$message\n\n";
                close MAIL;
        }
}

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

sub get_form_data {
        my $temp;
        my $buffer;
        my @data;
        read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        foreach $temp (split(/&|=/,$buffer)) {
                $temp =~ tr/+/ /;
                $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
		$temp =~ s/[\r\n]/ /g;
                push @data, $temp;
        }
        foreach $temp (split(/&|=/,$ENV{'QUERY_STRING'})) {
                $temp =~ tr/+/ /;
                $temp =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
		$temp =~ s/[\r\n]/ /g;
                push @data, $temp;
        }
        return @data;
}

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

sub randompass {
	srand(time ^ $$);
	my @passset = ('a'..'k', 'm'..'n', 'p'..'z', '2'..'9');
	my $randpass = "";
	for (my $i=0; $i<8; $i++) {
		$randpass .= $passset[int(rand($#passset + 1))];
	}
	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);
	return "$bidamt[0].$bidamt[1]";
}

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

sub oops {
	print "<P><HR SIZE=1 NOSHADE><FONT COLOR=#FF0000><B>Error:</B></FONT><BR>$_[0]<P>Please hit the back browser on your browser to try again or contact <A HREF=\"mailto:$config{'admin_address'}\">the auction administrator</A> if you belive this to be a server problem.<HR SIZE=1 NOSHADE>\n";
	print $config{'footer'};
	die "Error: $_[0]\n";
}

#-#############################################
# 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{'basepath'}$config{'regdir'}/$alias.dat" and -T "$config{'basepath'}$config{'regdir'}/$alias.dat";
	open FILE, "$config{'basepath'}$config{'regdir'}/$alias.dat";
	my ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@past_bids) = <FILE>;
	close FILE;
	chomp ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@past_bids);
	return ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@past_bids);
}

#-#############################################
# Sub: Read Feed File (alias)
# Reads a Feedback file

sub read_feed_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{'basepath'}$config{'feeddata'}/$alias.dat" and -T "$config{'basepath'}$config{'feeddata'}/$alias.dat";
	open FILE, "$config{'basepath'}$config{'feeddata'}/$alias.dat";
	my ($p,$n,$nn,$alias2,$item,$title,$rates,@past_feeds) = <FILE>;
	close FILE;
	chomp ($p,$n,$nn,$alias2,$item,$title,$rates,@past_feeds);
	return ($p,$n,$nn,$alias2,$item,$title,$rates,@past_feeds);
}

#-#############################################
# 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 =~ /\N/;
	return '' unless -T "$config{'basepath'}$cat/$item.dat" and -R "$config{'basepath'}$cat/$item.dat";
	open FILE, "$config{'basepath'}$cat/$item.dat";
	my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <FILE>;
	close FILE;
	chomp ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
	return ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @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, $phone1, $phone2, $phone3) = split(/\[\]/,$bid_string);
	return ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3);
}
#-#############################################
# Sub: Read Feed Information (feed_string)
# Reads a feedback file
#
sub read_feed {
	my $feed_string = shift;
	my ($p, $n, $nn, $alias2, $item, $title, $rates) = split(/\[\]/,$feed_string);
	return ($p, $n, $nn, $alias2, $item, $title, $rates);
}
#-#############################################
# Sub: Start Search
# Gives Search its own page

sub start_search {

print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
		  print <<"EOF";
		  <CENTER>
			<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
			Search by Keyword <BR>
			<INPUT TYPE=TEXT NAME=searchstring>
			<INPUT TYPE=SUBMIT VALUE="Search">
			<INPUT TYPE=HIDDEN NAME=action VALUE="search">
			<INPUT TYPE=HIDDEN NAME=searchtype VALUE="keyword">
			</form>
			<BR>
			<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
			Search by Username <BR>
			<INPUT TYPE=TEXT NAME=searchstring>
			<INPUT TYPE=SUBMIT VALUE="Search">
			<INPUT TYPE=HIDDEN NAME=action VALUE="search">
			<INPUT TYPE=HIDDEN NAME=searchtype VALUE="username"> 
		</FORM>
		</center>
EOF
print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}
#-#############################################
# Sub: Process Search
# This displays search results

sub procsearch {
	print "<center><H2>Search Results for $form{'searchstring'}</H2>\n";
	print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
	print "<TABLE BORDER=1 WIDTH=600>\n";
	print "<TR><TD WIDTH=200 ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Item</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Closes</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>Num Bids</B></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B>High Bid</B></TD></TR>\n";
	my $key;
	foreach $key (sort keys %category) {
		opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
		my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
		closedir THEDIR;
		my $file;
		foreach $file (@allfiles) {
			$file =~ s/^$config{'basepath'}$key\///;
			$file =~ s/\.dat$//;
			if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
				my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
				my @closetime = localtime($file);
				$closetime[4]++;
				my @firstbid =  &read_bid($bids[0]);
				my $timediff = ($file - time);
				if($form{'searchtype'} eq 'keyword' and ($title =~ /$form{'searchstring'}/i) || ($desc =~ /$form{'searchstring'}/i)) {
					print "<TR><TD BGCOLOR=$config{'colortablebody'}><A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
					print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
					print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
					print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
					print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
					print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
					print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
					print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
					print "</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$closetime[4]/$closetime[3]</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$#bids</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>\$$bid</TD></TR>\n";
				}
				elsif($form{'searchtype'} eq 'username' and join(' ',@bids) =~ /$form{'searchstring'}/i) {
					print "<TR><TD BGCOLOR=$config{'colortablebody'}><A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
					
			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
			print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
			print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
			print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
			
			print "</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$closetime[4]/$closetime[3]</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>$#bids</TD><TD ALIGN=CENTER BGCOLOR=$config{'colortablebody'}>\$$bid</TD></TR>\n";
				}
			}
		}
	}
	print "</TABLE>\n";
	print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
}
#-#############################################
# Sub: Closed items 1
# This displays closed items

sub viewclosed1 {
	print <<"EOF";
<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>
<center><H2>View Closed Items</H2>
<TABLE WIDTH=600 BORDER=1 BGCOLOR=$config{'colortablebody'} bordercolor=$config{'colortablehead'} cellspacing=0 cellpadding=0>
<INPUT TYPE=HIDDEN NAME=action VALUE=closed2>
<TR><TD COLSPAN=2 VALIGN=TOP> This form will allow you to view the
status and contact information for closed auction items you bid on or listed for auction.
</TD></TR>
<TR><TD VALIGN=TOP><B>Your Username:</B></TD><TD><INPUT NAME=ALIAS TYPE=TEXT SIZE=30 MAXLENGTH=30> <font color="#ff0000">** Required **</font></td></tr>
<TR><TD VALIGN=TOP><B>Your Password:</B></TD><TD><INPUT NAME=PASSWORD TYPE=PASSWORD SIZE=30> <font color="#ff0000">** Required **</font></TD></TR>
</TABLE>
<CENTER><INPUT TYPE=SUBMIT VALUE="View Closed Items"></CENTER>
EOF
}

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

sub viewclosed2 {
	&oops('Your alias could not be found!') unless my ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@past_bids) = &read_reg_file($form{'ALIAS'});
	&oops('Your password is incorrect.') unless ((lc $password) eq (lc $form{'PASSWORD'}));
	&oops('PASSWORD') unless ((lc $password) eq (lc $form{'PASSWORD'}));
	print "<center>";
	print "<FORM METHOD=POST ACTION=\"$ENV{'SCRIPT_NAME'}\">\n";
	print "<INPUT TYPE=HIDDEN NAME=action VALUE=closed3><INPUT TYPE=HIDDEN NAME=ALIAS VALUE=\"$form{'ALIAS'}\"><INPUT TYPE=HIDDEN NAME=PASSWORD VALUE=\"$form{'PASSWORD'}\">";
	print"<TABLE WIDTH=600 BORDER=1 BGCOLOR=$config{'colortablebody'}>\n";
	my $bid;
	foreach $bid (@past_bids) {
		if (-T "$config{'basepath'}$config{'closedir'}/$bid.dat") {
			open THEFILE, "$config{'basepath'}$config{'closedir'}/$bid.dat";
			my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
			close THEFILE;
			chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
			
			print "<TR><TD width=50 align=center><input name=\"BIDTOVIEW\" type=\"radio\" value=\"$bid\"></TD><TD width=550>&nbsp;&nbsp; $bid: &nbsp;&nbsp;&nbsp;&nbsp; $title</TD></TR>\n";
		}
	}
	print "</TABLE><INPUT TYPE=SUBMIT VALUE=\"View My Status\"></FORM>\n";
}

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

sub viewclosed3 {
	$form{'BIDTOVIEW'} =~ s/\W//g;
	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, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
	close THEFILE;
	chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
	print "<H2>$title</H2>\n";
	print "<HR><FONT SIZE=+1><B>Description</B></FONT><HR>$desc</FONT></FONT></B></I></U></H1></H2></H3></H4></H5>";
	print "<HR><FONT SIZE=+1><B>Bid History</B></FONT><HR>\n";
	if ($#bids) {
		#shift @bids; # remove the first bid (start bid)
		for (my $i=0; $i<scalar(@bids); $i++) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$i]);
			my $bidtime = localtime($time);
			print "<FONT SIZE=-1>$alias \($bidtime\) - \$$bid</FONT><BR>";
		}
	}
	else {
		print "<FONT SIZE=-1>No bids were placed...</FONT><BR>";
	}
	print "<P>Reserve was: \$$reserve<BR>\n";
	print "<HR><FONT SIZE=+1><B>Contact Information</B></FONT><HR>\n";
	if (ucfirst(lc($form{'ALIAS'})) eq (&read_bid($bids[0]))[0]) {
		print "You were the seller...<P>\n";
		my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
	if (ucfirst(lc($form{'ALIAS'})) eq $alias) {
		print "There were no Bidders\n";
		}
	else {
		###################Begin Feedback addon Seller Rate
		 print "\n <FORM ACTION=\"$config{'feedscript'}\" METHOD=POST>";
		 print "\n <input name=\"action\" type=\"hidden\" value=\"rate\">";
		 print "\n <input name=\"ALIAS\" type=\"hidden\" value=\"$alias\">";
		 print "\n <input name=\"ALIAS2\" type=\"hidden\" value=\"$form{'ALIAS'}\">";
		 print "\n <input name=\"PASSWORD\" type=\"hidden\" value=\"$form{'PASSWORD'}\">";
		 print "\n <input name=\"TITLE\" type=\"hidden\" value=\"$title\">";
		 print "\n <input name=\"ITEM\" type=\"hidden\" value=\"$form{'BIDTOVIEW'}\">";
		 print "\n <input type=\"submit\" value=\"Rate Buyer\">";
 		 print "\n </form>";
 		###################END Feedback Addon	
 		
 		print "<B>Buyer Information:</B><br>";
		print "<I>Alias</I>: $alias<BR><I>E-Mail</I>: $email<BR><I>Address</I>: $add1<BR>$add2<BR>$add3<BR>($phone1) $phone2-$phone3<P><B>High Bid:</B> \$$bid\n";
		
		
		print "<P><B>Bidder Contact Info:</B><BR>\n";
		for (my $i=0; $i<scalar(@bids); $i++) {
			my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$i]);
			print "<FONT SIZE=-1>$alias - <A HREF=\"mailto:$email\">$email</A></FONT><BR>\n";
		}
	}
	if ($type eq 'Auction'){
	         print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>You may repost this item if you want to: <INPUT TYPE=SUBMIT VALUE=\"Repost\"><INPUT TYPE=HIDDEN NAME=action VALUE=\"repost\"><INPUT TYPE=HIDDEN NAME=REPOST VALUE=\"$form{'BIDTOVIEW'}\"></FORM>\n";
	}
	elsif ($type eq 'Classified'){  
		print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>You may repost this item if you want to: <INPUT TYPE=SUBMIT VALUE=\"Repost\"><INPUT TYPE=HIDDEN NAME=action VALUE=\"repostc\"><INPUT TYPE=HIDDEN NAME=REPOSTC VALUE=\"$form{'BIDTOVIEW'}\"></FORM>\n";
	}
	else {  
		print "<FORM ACTION=$ENV{'SCRIPT_NAME'} METHOD=POST>You may repost this item if you want to: <INPUT TYPE=SUBMIT VALUE=\"Repost\"><INPUT TYPE=HIDDEN NAME=action VALUE=\"repostw\"><INPUT TYPE=HIDDEN NAME=REPOSTW VALUE=\"$form{'BIDTOVIEW'}\"></FORM>\n";
	}
	
	}
	elsif (ucfirst(lc($form{'ALIAS'})) eq (&read_bid($bids[$#bids]))[0]) {
		my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]);
		print "You were a high bidder...<P>\n";
		print "<B>Your High Bid:</B> \$$bid<P>\n";
		my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[0]);
		###################Begin Feedback addon Seller Rate
		print "\n <FORM ACTION=\"$config{'feedscript'}\" METHOD=POST>";
		print "\n <input name=\"action\" type=\"hidden\" value=\"rate\">";
		print "\n <input name=\"ALIAS\" type=\"hidden\" value=\"$alias\">";
		print "\n <input name=\"ALIAS2\" type=\"hidden\" value=\"$form{'ALIAS'}\">";
		print "\n <input name=\"PASSWORD\" type=\"hidden\" value=\"$form{'PASSWORD'}\">";
		print "\n <input name=\"TITLE\" type=\"hidden\" value=\"$title\">";
		print "\n <input name=\"ITEM\" type=\"hidden\" value=\"$form{'BIDTOVIEW'}\">";
		print "\n <input type=\"submit\" value=\"Rate Seller\">";
		print "\n </form>";
 		###################END Feedback Addon	
		print "<B>Seller Information:</B><BR><I>Alias</I>: $alias<BR><I>E-Mail</I>: $email<BR><I>Address</I>: $add1<BR>$add2<BR>$add3<BR>($phone1) $phone2-$phone3<P>\n";
		print "<I>Remember, the seller is not required to sell unless your bid price was above the reserve price...</I>";
	}
	else {
		print "You were not a winner...  No further contact information is available.\n";
	}
}
###############################################
# Sub: View All Items
# This Displays all Items up for Bid

sub view_all {
		
		print "<CENTER><H2>All Items</H2>\n";
		print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
		print "<TABLE BORDER=1 BGCOLOR=$config{'colortablebody'} WIDTH=600 CELLSPACING=0 CELLPADDING=0>\n";
		print "<TR BGCOLOR=$config{'colortablehead'}><TD ALIGN=CENTER width=300><B>Item</B></TD><TD WIDTH=60 ALIGN=CENTER><B>Closes</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Num Bids</B></TD><TD WIDTH=80 ALIGN=CENTER><B>High Bid</B></TD><TD WIDTH=100 ALIGN=CENTER><B>High Bidder</B></TD></TR>\n";
		my $key;
		foreach $key (sort keys %category) {
		opendir THEDIR, "$config{'basepath'}$key" || die "Unable to open directory: $!";
		my @allfiles = readdir THEDIR;
		closedir THEDIR;
		my $file;
		foreach $file (sort { int($a) <=> int($b) } @allfiles) {
		if (-T "$config{'basepath'}$key/$file") {
		open THEFILE, "$config{'basepath'}$key/$file";
		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
		close THEFILE;
		chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
		my @lastbid = split(/\[\]/,$bids[$#bids]);
		$file =~ s/\.dat//;
		my @closetime = localtime($file);
		$closetime[4]++;
		my @firstbid =  &read_bid($bids[0]);
		my $timediff = ($file - time);
		print "<TR><td><A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</a>";
		print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
		print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
		print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
		print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
		print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
		print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
 		
		print "</td> <td ALIGN=CENTER>$closetime[4]/$closetime[3]</td> <td ALIGN=CENTER>$#bids </td> <td ALIGN=CENTER>$lastbid[2]</td> <td ALIGN=CENTER>$lastbid[0]</td></tr>";
		}
	}
}
		print "</table>";
		print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";

}
##############################################
# Sub: Count Bids 1.0
# This increments the number for the stats

sub count_bid {
my $LOCK_EX;
my $bid;
open (DAT, "$config{'basepath'}/no_bids1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
$bid = <DAT>;
close(DAT);

my $new_bid = $bid + 1;

open (OUT, ">$config{'basepath'}/no_bids1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
print OUT "$new_bid";
close(OUT);

}
##############################################
# Sub: Count Posts 1.0
# This increments the number for the stats

sub count_post {
my $LOCK_EX;
my $post;
open (DAT, "$config{'basepath'}/no_post1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
$post = <DAT>;
close(DAT);

my $new_post = $post + 1;

open (OUT, ">$config{'basepath'}/no_post1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
print OUT "$new_post";
close(OUT);

}

##############################################
# Sub: Count Viewed 1.0
# This increments the number for the stats

sub count_viewed {
my $LOCK_EX;
my $viewed;
open (DAT, "$config{'basepath'}/no_viewe1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
$viewed = <DAT>;
close(DAT);

my $new_viewed = $viewed + 1;

open (OUT, ">$config{'basepath'}/no_viewe1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
print OUT "$new_viewed";
close(OUT);

} 
##############################################
# Sub: Users 1.0
# This increments the number for the stats

sub count_user {
my $LOCK_EX;
my $user;
open (DAT, "$config{'basepath'}/no_user1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
$user = <DAT>;
close(DAT);

my $new_user = $user + 1;

open (OUT, ">$config{'basepath'}/no_user1.txt");
if ($LOCK_EX){
flock(DAT, $LOCK_EX); #Locks the file
}
print OUT "$new_user";
close(OUT);

} 
 ##############################################
 # Sub: ALL NEW
 # This Displays all new
 
 sub allnew {
 		print "<CENTER><H2>All New Items</H2>\n";
 		print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><br>";
 		print "<TABLE BORDER=1 BGCOLOR=$config{'colortablebody'} WIDTH=600 CELLSPACING=0 CELLPADDING=0>\n";
 		print "<TR BGCOLOR=$config{'colortablehead'}><TD ALIGN=CENTER width=280><B>Item</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Closes</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Num Bids</B></TD><TD WIDTH=80 ALIGN=CENTER><B>High Bid</B></TD><TD WIDTH=100 ALIGN=CENTER><B>High Bidder</B></TD></TR>\n";
 		my $key;
 		foreach $key (sort keys %category) {
 		opendir THEDIR, "$config{'basepath'}$key" || die "Unable to open directory: $!";
 		my @allfiles = readdir THEDIR;
 		closedir THEDIR;
 		my $file;
 		foreach $file (sort { int($a) <=> int($b) } @allfiles){
 		if (-T "$config{'basepath'}$key/$file") {
 		open THEFILE, "$config{'basepath'}$key/$file";
 		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
 		close THEFILE;
 		chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
 		my @firstbid =  &read_bid($bids[0]);
 		my @lastbid = split(/\[\]/,$bids[$#bids]);
 		$file =~ s/\.dat//;
 		my @closetime = localtime($file);
 		$closetime[4]++;
 		my @firstbid =  &read_bid($bids[0]);
		my $timediff = ($file - time);
 		print "<TR><td><A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</a>" if (time<($config{'newdays'} * 86400 + $firstbid[3]));
 		print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if (($image) && (time<($config{'newdays'} * 86400 + $firstbid[3])));
		print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
		print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
		print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;[A] " if (($type eq 'Auction') && (time<($config{'newdays'} * 86400 + $firstbid[3])));
		print "&nbsp;&nbsp;&nbsp;[C] " if (($type eq 'Classified') && (time<($config{'newdays'} * 86400 + $firstbid[3])));
		print "&nbsp;&nbsp;&nbsp;[W] " if (($type eq 'Wanted') && (time<($config{'newdays'} * 86400 + $firstbid[3])));
 		print "</td> <td ALIGN=CENTER>$closetime[4]/$closetime[3]</td> <td ALIGN=CENTER>$#bids </td> <td ALIGN=CENTER>$lastbid[2]</td> <td ALIGN=CENTER>$lastbid[0]</td></tr>" if (time<($config{'newdays'} * 86400 + $firstbid[3]));
 		}
 	}
 }
 		print "</table>";
		print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
 
 } 

 ##############################################
 # Sub: ALL Hot
 # This Displays all hot
 
 sub allhot {
 		print "<CENTER><H2>All HOT Items</H2>\n";
 		print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><BR>";
 		print "<TABLE BORDER=1 BGCOLOR=$config{'colortablebody'} WIDTH=600 CELLSPACING=0 CELLPADDING=0>\n";
 		print "<TR BGCOLOR=$config{'colortablehead'}><TD ALIGN=CENTER width=300><B>Item</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Closes</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Num Bids</B></TD><TD WIDTH=80 ALIGN=CENTER><B>High Bid</B></TD><TD WIDTH=100 ALIGN=CENTER><B>High Bidder</B></TD></TR>\n";
 		my $key;
 		foreach $key (sort keys %category) {
 		opendir THEDIR, "$config{'basepath'}$key" || die "Unable to open directory: $!";
 		my @allfiles = readdir THEDIR;
 		closedir THEDIR;
 		my $file;
 		foreach $file (sort { int($a) <=> int($b) } @allfiles) {
 		if (-T "$config{'basepath'}$key/$file") {
 		open THEFILE, "$config{'basepath'}$key/$file";
 		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
 		close THEFILE;
 		chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
 		my @firstbid =  &read_bid($bids[0]);
 		my @lastbid = split(/\[\]/,$bids[$#bids]);
 		$file =~ s/\.dat//;
 		my @closetime = localtime($file);
 		$closetime[4]++;
 		my @firstbid =  &read_bid($bids[0]);
		my $timediff = ($file - time);
 		print "<TR><td><A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</a>" if ($config{'hotitemnum'} <= $#bids);
		print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image) & ($config{'hotitemnum'} <= $#bids);
		print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) & ($config{'hotitemnum'} <= $#bids);
		print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
		print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600)) & ($config{'hotitemnum'} <= $#bids);
 		print "&nbsp;&nbsp;&nbsp;[A] " if (($type eq 'Auction') && ($config{'hotitemnum'} <= $#bids));
		print "&nbsp;&nbsp;&nbsp;[C] " if (($type eq 'Classified') && ($config{'hotitemnum'} <= $#bids));
		print "&nbsp;&nbsp;&nbsp;[W] " if (($type eq 'Wanted') && ($config{'hotitemnum'} <= $#bids));
 		print "</td> <td ALIGN=CENTER>$closetime[4]/$closetime[3]</td> <td ALIGN=CENTER>$#bids </td> <td ALIGN=CENTER>$lastbid[2]</td> <td ALIGN=CENTER>$lastbid[0]</td></tr>" if ($config{'hotitemnum'} <= $#bids);
 		}
 	}
 }
 		print "</table>";
 		print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";

 
 } 
 
 ##############################################
  # Sub: ALL End
  # This Displays all Ending
  
  sub allend {
  		print "<CENTER><H2>All Ending Items</H2>\n";
  		print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table><br>";
  		print "<TABLE BORDER=1 BGCOLOR=$config{'colortablebody'} WIDTH=600 CELLSPACING=0 CELLPADDING=0>\n";
  		print "<TR BGCOLOR=$config{'colortablehead'}><TD ALIGN=CENTER width=300><B>Item</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Closes</B></TD><TD WIDTH=80 ALIGN=CENTER><B>Num Bids</B></TD><TD WIDTH=80 ALIGN=CENTER><B>High Bid</B></TD><TD WIDTH=100 ALIGN=CENTER><B>High Bidder</B></TD></TR>\n";
  		my $key;
  		foreach $key (sort keys %category) {
  		opendir THEDIR, "$config{'basepath'}$key" || die "Unable to open directory: $!";
  		my @allfiles = readdir THEDIR;
  		closedir THEDIR;
  		my $file;
  		foreach $file (sort { int($a) <=> int($b) } @allfiles) {
  		if (-T "$config{'basepath'}$key/$file") {
  		open THEFILE, "$config{'basepath'}$key/$file";
  		my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = <THEFILE>;
  		close THEFILE;
  		chomp($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids);
  		my @firstbid =  &read_bid($bids[0]);
  		my @lastbid = split(/\[\]/,$bids[$#bids]);
  		$file =~ s/\.dat//;
  		my $timediff = ($file - time);
  		my @closetime = localtime($file);
  		$closetime[4]++;
  		my @firstbid =  &read_bid($bids[0]);
		my $timediff = ($file - time);
  		print "<TR><td><A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</a>" if ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image) & ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) & ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids) & ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
		print "&nbsp;&nbsp;&nbsp;[A] " if (($type eq 'Auction') && ($timediff < ($config{'endhours'} * 3600)));
		print "&nbsp;&nbsp;&nbsp;[C] " if (($type eq 'Classified') && ($timediff < ($config{'endhours'} * 3600)));
		print "&nbsp;&nbsp;&nbsp;[W] " if (($type eq 'Wanted') && ($timediff < ($config{'endhours'} * 3600)));
  		print "</td> <td ALIGN=CENTER>$closetime[4]/$closetime[3]</td> <td ALIGN=CENTER>$#bids </td> <td ALIGN=CENTER>$lastbid[2]</td> <td ALIGN=CENTER>$lastbid[0]</td></tr>" if ($timediff < ($config{'endhours'} * 3600));
  		}
  	}
  }
  		print "</table>";
 		print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
  
 } 
	
 ##############################################
  # Sub: Show Main Cat1
  # This Displays all Items in Cat 1
  
  sub scat1 {
  			print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
  			print "<BR><CENTER><TABLE WIDTH=100%  cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} BORDER=1 bordercolor=$config{'colortableborder'}>\n";
			print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 1</a></B></TD></TR>\n";
				my $key;
				foreach $key (sort keys %Cats1) {
					umask(000);  # UNIX file permission junk
					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
					closedir DIR;
					print "<TR><TD width=100%><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key><font size=+1><I>$category{$key}</I></font></a></B>\n";
					opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
										  	my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
										  	closedir THEDIR;
										  	my $file;
										  	print "<center><BR><table width=90\% cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'}>\n";
										  	print "<tr><td align=center><B>Item</B></td><TD width=30 align=center><B>Closes</B></td><td width=30 align=center><B>Bids</B></td></tr>";
										  	foreach $file (@allfiles) {
										  		$file =~ s/^$config{'basepath'}$key\///;
										  		$file =~ s/\.dat$//;
										  		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
										  			my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
										  			my @closetime = localtime($file);
										  			my @firstbid =  &read_bid($bids[0]);
										  			my $timediff = ($file - time);
										  			$closetime[4]++;
										  			print "<TR><TD>&nbsp;&nbsp;&nbsp;<A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
										  			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
										  			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
										  			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
										  			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
										  			print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
										  			print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
										  			print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
										  			print "</td><td align=center>$closetime[4]/$closetime[3]</td><td align=center>$#bids</td></tr>\n";
										  		}
										  		
										  	}
													print "</table>";
					print "</td><tr> ";
					}
	print "</TABLE></td>\n";
	print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
  
 } 
##############################################
  # Sub: Show Main Cat2
  # This Displays all Items in Cat 2
  
  sub scat2 {
  			print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
  			print "<BR><CENTER><TABLE WIDTH=100%  cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} BORDER=1 bordercolor=$config{'colortableborder'}>\n";
			print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 2</a></B></TD></TR>\n";
				my $key;
				foreach $key (sort keys %Cats2) {
					umask(000);  # UNIX file permission junk
					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
					closedir DIR;
					print "<TR><TD width=100%><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key><font size=+1><I>$category{$key}</I></font></a></B>\n";
					opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
										  	my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
										  	closedir THEDIR;
										  	my $file;
										  	print "<center><BR><table width=90\% cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'}>\n";
										  	print "<tr><td align=center><B>Item</B></td><TD width=30 align=center><B>Closes</B></td><td width=30 align=center><B>Bids</B></td></tr>";
										  	foreach $file (@allfiles) {
										  		$file =~ s/^$config{'basepath'}$key\///;
										  		$file =~ s/\.dat$//;
										  		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
										  			my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
										  			my @closetime = localtime($file);
										  			my @firstbid =  &read_bid($bids[0]);
										  			my $timediff = ($file - time);
										  			$closetime[4]++;
										  			print "<TR><TD>&nbsp;&nbsp;&nbsp;<A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
										  			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
										  			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
										  			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
										  			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
										  			print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
										  			print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
										  			print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
										  			print "</td><td align=center>$closetime[4]/$closetime[3]</td><td align=center>$#bids</td></tr>\n";
										  		}
										  		
										  	}
													print "</table>";
					print "</td><tr> ";
					}
	print "</TABLE></td>\n";
	print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
  
 } 
 ##############################################
   # Sub: Show Main Cat3
   # This Displays all Items in Cat 3
   
   sub scat3 {
   			print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
   			print "<BR><CENTER><TABLE WIDTH=100%  cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} BORDER=1 bordercolor=$config{'colortableborder'}>\n";
 			print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 3</a></B></TD></TR>\n";
 				my $key;
 				foreach $key (sort keys %Cats3) {
 					umask(000);  # UNIX file permission junk
 					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
 					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
 					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
 					closedir DIR;
 					print "<TR><TD width=100%><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key><font size=+1><I>$category{$key}</I></font></a></B>\n";
 					opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
 										  	my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
 										  	closedir THEDIR;
 										  	my $file;
 										  	print "<center><BR><table width=90\% cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'}>\n";
 										  	print "<tr><td align=center><B>Item</B></td><TD width=30 align=center><B>Closes</B></td><td width=30 align=center><B>Bids</B></td></tr>";
 										  	foreach $file (@allfiles) {
 										  		$file =~ s/^$config{'basepath'}$key\///;
 										  		$file =~ s/\.dat$//;
 										  		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
 										  			my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
 										  			my @closetime = localtime($file);
 										  			my @firstbid =  &read_bid($bids[0]);
 										  			my $timediff = ($file - time);
 										  			$closetime[4]++;
 										  			print "<TR><TD>&nbsp;&nbsp;&nbsp;<A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
 										  			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
 										  			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
 										  			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
 										  			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
 										  			print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
 										  			print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
										  			print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
 										  			print "</td><td align=center>$closetime[4]/$closetime[3]</td><td align=center>$#bids</td></tr>\n";
 										  		}
 										  		
 										  	}
 													print "</table>";
 					print "</td><tr> ";
 					}
 	print "</TABLE></td>\n";
 	print "<BR><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
   
 } 
  ##############################################
    # Sub: Show Main Cat4
    # This Displays all Items in Cat 4
    
    sub scat4 {
    			print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
    			print "<BR><CENTER><TABLE WIDTH=100%  cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} BORDER=1 bordercolor=$config{'colortableborder'}>\n";
  			print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 4</a></B></TD></TR>\n";
  				my $key;
  				foreach $key (sort keys %Cats4) {
  					umask(000);  # UNIX file permission junk
  					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
  					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
  					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
  					closedir DIR;
  					print "<TR><TD width=100%><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key><font size=+1><I>$category{$key}</I></font></a></B>\n";
  					opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
  										  	my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
  										  	closedir THEDIR;
  										  	my $file;
  										  	print "<center><BR><table width=90\% cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'}>\n";
  										  	print "<tr><td align=center><B>Item</B></td><TD width=30 align=center><B>Closes</B></td><td width=30 align=center><B>Bids</B></td></tr>";
  										  	foreach $file (@allfiles) {
  										  		$file =~ s/^$config{'basepath'}$key\///;
  										  		$file =~ s/\.dat$//;
  										  		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
  										  			my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
  										  			my @closetime = localtime($file);
  										  			my @firstbid =  &read_bid($bids[0]);
  										  			my $timediff = ($file - time);
  										  			$closetime[4]++;
  										  			print "<TR><TD>&nbsp;&nbsp;&nbsp;<A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
  										  			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
  										  			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
  										  			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
  										  			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
										  			print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
										  			print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
										  			print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
  										  			print "</td><td align=center>$closetime[4]/$closetime[3]</td><td align=center>$#bids</td></tr>\n";
  										  		}
  										  		
  										  	}
  													print "</table>";
  					print "</td><tr> ";
  					}
  	print "</TABLE></td>\n";
  	print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
    
 } 
  ##############################################
    # Sub: Show Main Cat5
    # This Displays all Items in Cat 5
    
    sub scat5 {
    			print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
    			print "<BR><CENTER><TABLE WIDTH=100%  cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} BORDER=1 bordercolor=$config{'colortableborder'}>\n";
  			print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 5</a></B></TD></TR>\n";
  				my $key;
  				foreach $key (sort keys %Cats5) {
  					umask(000);  # UNIX file permission junk
  					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
  					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
  					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
  					closedir DIR;
  					print "<TR><TD width=100%><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key><font size=+1><I>$category{$key}</I></font></a></B>\n";
  					opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
  										  	my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
  										  	closedir THEDIR;
  										  	my $file;
  										  	print "<center><BR><table width=90\% cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'}>\n";
  										  	print "<tr><td align=center><B>Item</B></td><TD width=30 align=center><B>Closes</B></td><td width=30 align=center><B>Bids</B></td></tr>";
  										  	foreach $file (@allfiles) {
  										  		$file =~ s/^$config{'basepath'}$key\///;
  										  		$file =~ s/\.dat$//;
  										  		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
  										  			my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
  										  			my @closetime = localtime($file);
  										  			my @firstbid =  &read_bid($bids[0]);
  										  			my $timediff = ($file - time);
  										  			$closetime[4]++;
  										  			print "<TR><TD>&nbsp;&nbsp;&nbsp;<A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
  										  			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
  										  			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
  										  			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
  										  			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
										  			print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
										  			print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
										  			print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
  										  			print "</td><td align=center>$closetime[4]/$closetime[3]</td><td align=center>$#bids</td></tr>\n";
  										  		}
  										  		
  										  	}
  													print "</table>";
  					print "</td><tr> ";
  					}
  	print "</TABLE></td>\n";
  	print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
    
 } 
 
 ##############################################
# Sub: Show Main Cat6
# This Displays all Items in Cat 6
	   
	   sub scat6 {
	   			print "<table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
	   			print "<BR><CENTER><TABLE WIDTH=100%  cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} BORDER=1 bordercolor=$config{'colortableborder'}>\n";
	 			print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead'}><B><A HREF=$ENV{'SCRIPT_NAME'}?action=1>Main Category 6</a></B></TD></TR>\n";
	 				my $key;
	 				foreach $key (sort keys %Cats6) {
	 					umask(000);  # UNIX file permission junk
	 					mkdir("$config{'basepath'}$key", 0777) unless (-d "$config{'basepath'}$key");
	 					opendir DIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
	 					my $numfiles = scalar(grep -T, map "$config{'basepath'}$key/$_", readdir DIR);
	 					closedir DIR;
	 					print "<TR><TD width=100%><B><A HREF=$ENV{'SCRIPT_NAME'}?category=$key><font size=+1><I>$category{$key}</I></font></a></B>\n";
	 					opendir THEDIR, "$config{'basepath'}$key" or &oops("Category directory $key could not be opened.");
	 										  	my @allfiles = grep -T, map "$config{'basepath'}$key/$_", sort { int($a) <=> int($b) } (readdir THEDIR);
	 										  	closedir THEDIR;
	 										  	my $file;
	 										  	print "<center><BR><table width=90\% cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'}>\n";
	 										  	print "<tr><td align=center><B>Item</B></td><TD width=30 align=center><B>Closes</B></td><td width=30 align=center><B>Bids</B></td></tr>";
	 										  	foreach $file (@allfiles) {
	 										  		$file =~ s/^$config{'basepath'}$key\///;
	 										  		$file =~ s/\.dat$//;
	 										  		if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($key,$file)) {
	 										  			my ($alias, $email, $bid, $time, $add1, $add2, $add3) = &read_bid($bids[$#bids]);
	 										  			my @closetime = localtime($file);
	 										  			my @firstbid =  &read_bid($bids[0]);
	 										  			my $timediff = ($file - time);
	 										  			$closetime[4]++;
	 										  			print "<TR><TD>&nbsp;&nbsp;&nbsp;<A HREF=$ENV{'SCRIPT_NAME'}\?category=$key\&item=$file>$title</A>";
	 										  			print "&nbsp;&nbsp;&nbsp;$config{'imageiconpath'}" if ($image);
	 										  			print "&nbsp;&nbsp;&nbsp;$config{'newiconpath'} " if (time<($config{'newdays'} * 86400 + $firstbid[3])) ;
	 										  			print "&nbsp;&nbsp;&nbsp;$config{'hoticonpath'} " if ($config{'hotitemnum'} <= $#bids);
	 										  			print "&nbsp;&nbsp;&nbsp;$config{'endiconpath'} " if ($timediff < ($config{'endhours'} * 3600));
										  				print "&nbsp;&nbsp;&nbsp;[A] " if ($type eq 'Auction');
										  				print "&nbsp;&nbsp;&nbsp;[C] " if ($type eq 'Classified');
										  				print "&nbsp;&nbsp;&nbsp;[W] " if ($type eq 'Wanted');
	 										  			print "</td><td align=center>$closetime[4]/$closetime[3]</td><td align=center>$#bids</td></tr>\n";
	 										  		}
	 										  		
	 										  	}
	 													print "</table>";
	 					print "</td><tr> ";
	 					}
	 	print "</TABLE></td>\n";
	 	print "<br><table border=\"2\" bordercolor=\"#000000\" bgcolor=\"#FF9933\" cellspacing=\"0\" cellpadding=\"0\" width=\"100\%\"><tr><td>&nbsp;</td></tr></table>";
	   
 } 
 
##############################################
# Sub: Lost password
# form for requesting password

sub lp {
	print <<"EOF";
<center><FORM METHOD=POST ACTION=\"$ENV{'SCRIPT_NAME'}\">
<input name="action" type="hidden" value="lp2">
<table cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'} width="500">
<TR><TD VALIGN=TOP colspan=2 align=center><B>YOUR IP address:<BR></B>Recorded
for security reasons</TD></Tr>
<tr><TD colspan=2 align=center>$ENV{'REMOTE_ADDR'}<INPUT
TYPE=HIDDEN NAME=IP VALUE=$ENV{'REMOTE_ADDR'}>
</td></tr>
<tr>
<td width=100>Alias<br><i><font color="#ff0000" size="-1">Required</font></i></td>
<td><input name="ALIAS" type="text" value="" size=25 maxlength=30></td>
</tr>
<tr>
<td width=100>E-Mail<br><i><font color="#ff0000" size="-1">Required</font></i></td>
<td><input name="EMAIL" type="text" value="" size=25 maxlength=30><br><font color="#000000" size="-1">Used to verify your alias.</font></td>
</tr>
</table>

<input type="submit" value="Get Password">
</form>			
	
	
EOF
} 


#############################################
# Sub: Process lost password
# processes lost password

sub lp2 {
	&oops('You must enter an alias that consists of alphanumeric characters.') if $form{'ALIAS'} =~ /\W/ or !($form{'ALIAS'});
	&oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
		
	$form{'ALIAS'} =~ s/\W//g;
	$form{'ALIAS'} = lc($form{'ALIAS'});
	$form{'ALIAS'} = ucfirst($form{'ALIAS'});
	&oops('Your ALIAS does not exist') unless (open(REGFILE, "$config{'basepath'}$config{'regdir'}/$form{'ALIAS'}.dat"));
	my ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@junk) = <REGFILE>;
	chomp($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@junk);
	close REGFILE;
	&oops('your EMAIL Does not match our records') unless ((lc $email) eq (lc $form{'EMAIL'}));
	&sendemail($email, $config{'admin_address'}, "Auction Password Request", "Our system has received a request for your password from IP address $form{'IP'} due to it being lost.\n\nYour password is: $password \r\n\n   Thanks for using $config{'sitename'}!");
		
	print "<center>$form{'ALIAS'}... Your password has been sent to your registered email.";
	

}

##############################################
# Sub: Lost Alias
# form for requesting Alias

sub la {
	print <<"EOF";
<center><FORM METHOD=POST ACTION=\"$ENV{'SCRIPT_NAME'}\">
<input name="action" type="hidden" value="la2">
<table cellspacing=0 cellpadding=0 bgcolor=$config{'colortablebody2'} border=1 bordercolor=$config{'colortableborder'} width="500">
<tr>
<td width=100>E-Mail<br><i><font color="#ff0000" size="-1">Required</font></i></td>
<td><input name="EMAIL" type="text" value="" size=25 maxlength=30><br><font color="#000000" size="-1">Used to verify your alias.</font></td>
</tr>
</table>

<input type="submit" value="Get Alias">
</form>			
	
	
EOF
} 


#############################################
# Sub: Process lost Alias
# processes lost Alias

sub la2 {
	my $file;
	&oops('You must enter a valid e-mail address.') unless ($form{'EMAIL'} =~ /^.+\@.+\..+$/);
	$form{'EMAIL'} = lc($form{'EMAIL'});
	opendir THEDIR, "$config{'basepath'}$config{'regdir'}" || die "Unable to open directory: $!";
	my @allfiles = readdir THEDIR;
	closedir THEDIR;
	foreach $file (sort { int($a) <=> int($b) } @allfiles) {
	if ("$config{'basepath'}$config{'regdir'}/$file" =~ /\.dat/) {
	open THEFILE, "$config{'basepath'}$config{'regdir'}/$file";
	my ($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@junk) = <THEFILE>;
	close THEFILE;
	chomp($password,$email,$add1,$add2,$add3,$phone1,$phone2,$phone3,@junk);
	if ($form{'EMAIL'} =~ /$email/) {
	 $file =~ s/\.dat//;
	my $username = $file; 
	print "<center>The Alias for $form{'EMAIL'} is <b>$username</b></center>.<br>";
	}

	}
	
	}
print "<center> <font color=\"#000000\" size=\"-1\"><i>If no Alias is listed the email address you gave is not registered</i></font></center>";

}
#################################################
# Sub: checkclosed (lion)
# checks all of the items, and closes the ones whose ran out of time
# 


sub chkclose {
	my $cat;
	foreach $cat (keys %category) {
		opendir THEDIR, "$config{'basepath'}$cat" or next;
		my @allfiles = (readdir THEDIR);
		closedir THEDIR;
		my $file;
		foreach $file (@allfiles) {
		unless ($file eq "." || $file eq "..") {
			$file =~ s/^$config{'basepath'}$form{'category'}\///;
			$file =~ s/\.dat$//;
			if (my ($title, $reserve, $inc, $desc, $image, $type, $buyit, $ship, $pay0, $pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $feat, @bids) = &read_item_file($cat,$file)) {
				my ($alias, $email, $bid, $time, $add1, $add2, $add3, $phone1, $phone2, $phone3) = &read_bid($bids[$#bids]); # read the last bid
				if ((time > int($file)) &&
					(time > (60 * $config{'aftermin'} + $time))) {
				if ($type eq 'Auction'){
					&closeit($cat,$file);
					}
				elsif ($type eq 'Classified'){
					&closeit2($cat,$file);
					}
				else {
					&closeit3($cat,$file);
					}
				
				
				
				}
			}
		}
		}
	}
	
}
#############################################
# Sub: Display How to Bid
# Displays the HTML help file in the provided path
# This could be How to Post, How to Bid or a FAQ.
# Remember the header and footer of your auction site is appended to this HTML file.

sub helpbid{

open(MYHEADER, "$config{'helpbid'}");
print while (<MYHEADER>);
close MYHEADER;

}

#############################################
# Sub: Display How to Post
# Displays the HTML help file in the provided path
# This could be How to Post, How to Bid or a FAQ.
# Remember the header and footer of your auction site is appended to this HTML file.

sub helppost{

open(MYHEADER, "$config{'helppost'}");
print while (<MYHEADER>);
close MYHEADER;

}

#############################################
# Sub: Display FAQ
# Displays the HTML help file in the provided path
# This could be How to Post, How to Bid or a FAQ.
# Remember the header and footer of your auction site is appended to this HTML file.

sub helpfaq{

open(MYHEADER, "$config{'helpfaq'}");
print while (<MYHEADER>);
close MYHEADER;

}

#############################################
# Sub: Display Help
# Displays the HTML help file in the provided path
# This is how a user can view the User Agreement without the form used for signing up.
# Remember the header and footer of your auction site is appended to this HTML file.

sub helpagree{

open(MYHEADER, "$config{'helpagree'}");
print while (<MYHEADER>);
close MYHEADER;

}




