#===========================================================================# # EveryAuction 1.51 Addon # Automatic Close/Relist Auctions 1.0a #===========================================================================# # PiTA - Park In The Alley Software (Auction-Script.com) #===========================================================================# # Author: Splatt 11/20/00 # justguns.com auction-script.com compalley.com #---------------------------------------------------------------------------# # Unauthorized redistribution is prohibited!!! # This file is not a part of the EveryAuction GPL. # The use of this script as an intregal part of EveryAuction is prohibited. # You may use this script with EveryAuction using the require statement. #---------------------------------------------------------------------------# # The latest version of my addons can be found at: # www.auction-script.com/addons #===========================================================================# #===========================================================================# # This is NOT for the weak hearted, BACK UP YOUR SCRIPTS!!!!!!!!!!! # BACK UP YOUR SCRIPTS!!!!!!!!!!! # BACK UP YOUR SCRIPTS!!!!!!!!!!! # BACK UP YOUR SCRIPTS!!!!!!!!!!! #===========================================================================# #===========================================================================# # NOTE: DUE TO THE LARGE AMOUNT OF ADD-ONS THAT CHANGE THE DATA FILE STRUCTURE, # I CAN ONLY GIVE THESE INSTRUCTIONS AND EXAMPLES ASSUMING A VIRGIN SCRIPT IS # BEING USED. TIME, SPACE AND THE INFINITE NUMBER OF POSSIBLE COMBINATIONS BEING USED # PROHIBIT ME FROM GIVING ALL THE POSSIBLE DATA FILE SCENARIOS. # # IF YOU ARE NOT USING A VIRGIN SCRIPT, THEN YOU'RE ON YOUR OWN. # I WILL GIVE SOME ADVICE FOR NON-VIRGIN SCRIPT USERS: # # TRIPLE CHECK THE DATA FILE STRUCTURES. # THE FILE STRUCTURES SHOWN HERE MAY BE SLIGHTLY DIFFERENT ON NON-VIRGIN SCRIPTS. # #===========================================================================# #===========================================================================# #--INSTALLATION: STEP ONE---------------------------------------------------# #===========================================================================# # # Find EVERY instance of this in ANY script you use: # # ($title, $reserve, $inc, $desc, $image, @bids) # # RELACE with this: # # ($title, $reserve, $inc, $desc, $image, $relist, @bids) # # Do the same for any similar section that reads the ITEM data file. # #===========================================================================# #===========================================================================# #--INSTALLATION: STEP TWO---------------------------------------------------# #===========================================================================# # # In the "sub procnew" section find this line: # # print NEW "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESC'}\n$form{'IMAGE'}\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]".&parsebid($form{'BID'})."\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}"; # # REPLACE THAT line with THIS line: # # print NEW "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESC'}\n$form{'IMAGE'}\n$form{'RELIST'}\n$form{'ALIAS'}\[\]$form{'EMAIL'}\[\]".&parsebid($form{'BID'})."\[\]".time."\[\]$form{'ADDRESS1'}\[\]$form{'ADDRESS2'}\[\]$form{'ADDRESS3'}"; # #===========================================================================# #===========================================================================# #--INSTALLATION: STEP TWO---------------------------------------------------# #===========================================================================# # # In the "sub new" section find this line: # # print "Days Until Close:
1-14\n"; # # PASTE THIS section below the above line you just found: # # print < # # Auto Relist:
Optional, this will allow you to relist your item up to 5 times until it is sold or you delete it. # # # Number of times to relist item: # # #END_OF_RELIST; # #===========================================================================# #===========================================================================# #--INSTALLATION: STEP THREE-------------------------------------------------# #===========================================================================# # # Again in the "sub procnew" section find this line: # # &oops('You must enter the number of days your auction should run, from 1 to 14.') unless (($form{'DAYS'} > 0) and ($form{'DAYS'} < 15)); # # Paste THIS section below the above line you just found: # # $form{'RELIST'} = "0" unless ($form{'RELIST'}); # #===========================================================================# #===========================================================================# #--INSTALLATION: STEP FOUR--------------------------------------------------# #===========================================================================# # # Name this file as "autorelist.pl" and place in your CGI-BIN directory, # CHMOD it to 755. # # Add the following line to your auction.pl file after the first line: # require "autorelist.pl"; # # Add the following line as the first line under your "sub displist": # # &autorelist; # #===========================================================================# #---------------------------------------------------------------------------# # Sub: AutoRelist. Automatic closing, relisting and emailing routine. #---------------------------------------------------------------------------# sub autorelist { #---------------------------------------------------------------------------# my $doit = 0; my ($key, $bid, $bidtime, $nosellreason, $opening, $opentext, $bidstart, $repostseconds, $repost, $new); my ($resend, $numauct, $winnermessage, $sellermessage, $highbidmessage, $reservemsg, $file, @lastbid, @firstbid); my ($numfile, $closetime, @allfiles, @thebid, $nowtime, $senderrormsg); my ($title, $reserve, $inc, $desc, $image, $location, $payments, $shipping, $condition, $relist, @bids); my ($alias, $email, $maxbid, $time, $name, $address, $city, $state, $postal, $country, $currentbid); #--For each CAT loop section---------------------------# foreach $key (sort keys %category) { opendir THEDIR, "$config{'basepath'}$key" || &oops("SUB: AUTOCLOSE\n\nCategory directory $key could not be opened."); @allfiles = readdir THEDIR; closedir THEDIR; #--For each file loop section--------------------------# FILE: foreach $file (sort { int($a) <=> int($b) } @allfiles) { #--Auction is over section-----------------------------# if (time > $file) { #--File exists section---------------------------------# if (-T "$config{'basepath'}$key/$file") { open THEFILE, "$config{'basepath'}$key/$file"; ($title, $reserve, $inc, $desc, $image, $relist, @bids) = ; chomp($title, $reserve, $inc, $desc, $image, $relist, @bids); @firstbid = split(/\[\]/,$bids[0]); @lastbid = split(/\[\]/,$bids[$#bids]); $nowtime = localtime(time); $closetime = localtime($file); foreach $bid (@bids) { @thebid = split(/\[\]/,$bid); $bidtime = localtime($thebid[3]); } close THEFILE; $opening = $reserve; $opentext = "Your reserve price"; if ($firstbid[2] > $reserve) { $opening = $firstbid[2]; $opentext = "Your opening bid"; } #--Relist Section Loop---------------------------------# if ($relist > 0) { $bidstart = localtime($firstbid[3]); $repostseconds = ($closetime - $bidstart); #--No bids placed section------------------------------# if ($firstbid[0] eq $lastbid[0]) { $nosellreason = "No bids were placed"; $doit = 1; $new = ($repostseconds + time); $new = ($repostseconds + time) until (!(-e "$config{'basepath'}$key/$new.dat")); $senderrormsg = " An item file could not be renamed during the AutoClose Routine. $config{'basepath'}$key/$numfile.dat TO $config{'basepath'}$key/$new.dat"; &sendemail("$config{'admin_address'}", 'nobody', 'Auction Site ERROR', "$senderrormsg") unless rename("$config{'basepath'}$key/$file", "$config{'basepath'}$key/$new.dat"); &oops('incorrect alias') unless (open(REGFILE, ">>$config{'basepath'}$config{'regdir'}/$firstbid[0].dat")); print REGFILE "\n$key$new"; close REGFILE; } #--END: No bids placed section-------------------------# #--Reserve or opening bid not met section--------------# elsif ($lastbid[2] < $opening) { $nosellreason = "$opentext was not met, highest bid was \$$lastbid[2]"; $doit = 1; $new = ($repostseconds + time); $new = ($repostseconds + time) until (!(-e "$config{'basepath'}$key/$new.dat")); $senderrormsg = " An item file could not be renamed during the AutoClose Routine. $config{'basepath'}$key/$file TO $config{'basepath'}$key/$new.dat"; &sendemail("$config{'admin_address'}", 'nobody', 'Auction Site ERROR', "$senderrormsg") unless rename("$config{'basepath'}$key/$file", "$config{'basepath'}$key/$new.dat"); &oops('incorrect alias') unless (open(REGFILE, ">>$config{'basepath'}$config{'regdir'}/$firstbid[0].dat")); print REGFILE "\n$key$new"; close REGFILE; } #--END: Reserve or opening not met section-------------# #-Image Upload-----------------------------------------# # If you ARE using the image upload addon, un-comment # this section. #------------------------------------------------------# #$numauct = $file; #$numauct =~ s/\.dat//; #if ($image ne '') { # $extension = (split(/\./,$image))[-1]; # $imagefile = "$imageuploaddir/$key$numauct.$extension"; # if (-f "$imagefile") { # $image = "$imageuploadurl/$key$new.$extension"; # &oops("Please notify the site administrator that this items image file cannot be renamed.") unless rename("$imagefile", "$imageuploaddir/$key$new.$extension"); # } #} #-Image Upload END-------------------------------------# $relist = ($relist - 1); open THEFILE, ">$config{'basepath'}$key/$new.dat"; print THEFILE "$title\n$reserve\n$inc\n$desc\n$image\n$relist"; $firstbid[3] = time; #-Only keep the initial opening bid--------------------# print THEFILE "\n$firstbid[0]\[\]$firstbid[1]\[\]$firstbid[2]\[\]$firstbid[3]\[\]$firstbid[4]\[\]$firstbid[5]\[\]$firstbid[6]"; #------------------------------------------------------# close THEFILE; if ($doit == 1) { $resend = " Hello $firstbid[0], Thank you for using $config{'sitename'}! The following item has been relisted because it didn't sell: Reason for not selling: $nosellreason The NEW item information re-listed is as follows : Item number : $new Title : $title Length : $repost days Category : $category{$key} URL Below http://$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?category=$key\&item=$new Once again, thank you and please tell a friend about us! Sincerely, $config{'sitename'} "; &sendemail("$firstbid[1]", 'nobody', 'Relist of Auction', "$resend"); sleep 2; # Wait 2 seconds to make sure we don't get duplicate item numbers next FILE; } } #--END: Relist section loop----------------------------# #--CAT <> Closed dir loop------------------------------# if ($key ne $config{'closedir'}) { if ($config{'closedir'}) { umask(000); mkdir("$config{'basepath'}$config{'closedir'}", 0777) unless (-d "$config{'basepath'}$config{'closedir'}"); $senderrormsg = " An item file could not be copied to the closed directory during the AutoClose Routine. $config{'basepath'}$key/$numfile.dat TO $config{'basepath'}$config{'closedir'}/$key$file"; &sendemail("$config{'admin_address'}", 'nobody', 'Auction Site ERROR', "$senderrormsg") unless &movefile("$config{'basepath'}$key/$file", "$config{'basepath'}$config{'closedir'}/$key$file"); $numauct = $file; $numauct =~ s/\.dat//; #-Image Upload-----------------------------------------# # If you ARE using the image upload addon, un-comment # this section. #------------------------------------------------------# #if ($image ne '') { # $extension = (split(/\./,$image))[-1]; # $imagefile = "$imageuploaddir/$key$numauct.$extension"; # if (-f "$imagefile") { # &oops("Please notify the site administrator that this items image file cannot be removed.") unless unlink("$imagefile"); # } #} #-Image Upload END-------------------------------------# #--AccountFirst Closed Item Charge Entry Point---------# # Insert your AF line below if you are using the AF's # # charge when item closes feature # # &transaction_presetrates_closed($firstbid[0], "Auction closed, #$numauct ($title)", $firstbid[2], $lastbid[2], $reserve, 1, 0, 1); #--End-------------------------------------------------# } else { $senderrormsg = " An item file could not be removed during the AutoClose Routine. $config{'basepath'}$key/$file"; &sendemail("$config{'admin_address'}", 'nobody', 'Auction Site ERROR', "$senderrormsg") unless unlink("$config{'basepath'}$key/$file"); } #--Winning bid and seller <> bidder--------------------# if (($lastbid[2] >= $opening) && ($firstbid[0] ne $lastbid[0])) { $winnermessage = " Congratulations! You are the winner of auction number $numauct. Your winning bid was \$$lastbid[2]. Please contact the seller to make arrangements for payment and shipping: $firstbid[4] $firstbid[5] $firstbid[6] $firstbid[1] Thanks for using $config{'sitename'}! "; $sellermessage = " Auction Number $numauct Is Now Closed. The winning bid was \$$lastbid[2] by $lastbid[0]. ($opentext was: \$$opening). Please contact the winning bidder to make any necessary arrangements: $lastbid[4] $lastbid[5] $lastbid[6] $lastbid[1] Thanks for using $config{'sitename'}! "; &sendemail("$lastbid[1]", 'nobody', "Auction Winner: $title", "$winnermessage"); $reservemsg = " "; &sendemail("$firstbid[1]", 'nobody', "Auction Close: $title", "$sellermessage"); } #--END: Winning bid and seller <> bidder---------------# #--No winning bid and seller <> bidder-----------------# elsif ($firstbid[2] ne $lastbid[2]) { $reservemsg = " YOUR RESERVE PRICE WAS NOT MET! (Your reserve was: \$$reserve) The high bid was \$$lastbid[2] by $lastbid[1]. Feel free to repost your auction by following this link: http://$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?action=repost\&repost=$key$file "; &sendemail("$firstbid[1]", 'nobody', "Auction Close: $title", "Auction Number $numauct Is Now Closed.\n\n$reservemsg\n\nThanks for using $config{'sitename'}!"); } #--END: No winning bid and seller <> bidder------------# #--No winning bid and seller = bidder (no bids)--------# else { $reservemsg = " Sorry, no bids were placed on your auction. Feel free to repost your auction by following this link: http://$config{'scripturl'}$ENV{'SCRIPT_NAME'}\?action=repost\&repost=$key$file "; &sendemail("$firstbid[1]", 'nobody', "Auction Close: $title", "Auction Number $numauct Is Now Closed.\n\n$reservemsg\n\nThanks for using $config{'sitename'}!"); } #--END: No winning bid and seller = bidder (no bids)---# } #--END: CAT <> Closed dir loop-------------------------# } #--END: File exists section----------------------------# } #--END: Auction is over section------------------------# } #--END: For each file loop section---------------------# } #--END: For each CAT loop section----------------------# } #--END: Sub AutoClose----------------------------------#