#======================================================# # EveryAuction Addon # Automatic Close/Relist Auctions 2.3b #------------------------------------------------------# # Portions of this code are from the following add-on: # Subject: Auto-Close 1.1 # Name: Craig # Time/Date: 14:48:29 9/23/98 #======================================================# # PiTA - Park In The Alley Software (Auction-Script.com) #======================================================# # Author: Splatt 09/11/00 # justguns.com auction-script.com compalley.com #------------------------------------------------------# # Unauthorized redistribution is prohibited!!! # The latest version of my addons can be found at: # www.auction-script.com/addons #======================================================# This add-on will replace your existing autoclose add-on (if you have one) incorporating a auction relist option if the item does not sell. 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. #=====================================================================================# #=====================================================================================# First thing, find EVERY instance of these in ANY script you use: ($title, $reserve, $inc, $desc, $image, @bids) = ; chomp($title, $reserve, $inc, $desc, $image, @bids); RELACE those with these: ($title, $reserve, $inc, $desc, $image, $relist, @bids) = ; chomp($title, $reserve, $inc, $desc, $image, $relist, @bids); Do the same for any similar section that reads the ITEM data file. #=====================================================================================# #=====================================================================================# In the "sub procnew" section find this line: print NEWAUCTION "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESC'}\n$form{'IMAGE'}"; REPLACE THAT line with THIS section: #--Repost Addon----------------------------------------# #print NEWAUCTION "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESC'}\n$form{'IMAGE'}"; print NEWAUCTION "$form{'TITLE'}\n$form{'RESERVE'}\n$form{'INC'}\n$form{'DESC'}\n$form{'IMAGE'}\n$form{'relist'}"; #--End-------------------------------------------------# NOTE: If you're using one of the item editing add-ons, you'll need to change the line(s) that print to the item file to reflect the new $relist ($form{'relist'}) and $relistcnt variables. #=====================================================================================# #=====================================================================================# In the "sub newitem" section find this line: Days Until Close:
1-14 Paste THIS section below the above line you just found: 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: #=====================================================================================# #=====================================================================================# Again in the "sub procnew" section find this line: &oops('DAYS') unless (($form{'DAYS'} > 0) && ($form{'DAYS'} < 15)); Paste THIS section below the above line you just found: #--Repost Addon----------------------------------------# $form{'relist'} = "0" unless ($form{'relist'}); #--End-------------------------------------------------# #=====================================================================================# #=====================================================================================# Comment out your existing autoclose sub for safety then paste this below the existing sub (for simplicity and safety). NOTE: If you don't already have the autoclose add-on installed, paste the section below to the bottom of your auction script. Then add the following to your dispcat sub: &autoclose; #------------------------------------------------------# # Sub: Automatic Close/Relist Auctions 2.3b (09/11/00) # Author: Splatt (www.compalley.com/addons) #------------------------------------------------------# # Portions of this code are from the following add-on: # Subject: Auto-Close 1.1 # Name: Craig # Time/Date: 14:48:29 9/23/98 #------------------------------------------------------# sub autoclose { #------------------------------------------------------# $doit = 0; # Leave set at 0 #--For each CAT loop section---------------------------# foreach $key (sort keys %category) { opendir THEDIR, "$basepath$key" || die "Unable to open directory: $!"; @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 "$basepath$key/$file") { open THEFILE, "$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); $repost = ($repostseconds / 86400); #--Reserve or opening bid not met section--------------# if ($lastbid[2] < $opening) { $nosellreason = "$opentext was not met, highest bid was \$$lastbid[2]"; $doit = 1; $new = ($repostseconds + time); $new = ($repostseconds + time) until (!(-e "$basepath$key/$new.dat")); print "Please notify the site administrator that this item file cannot be renamed.\n" unless rename("$basepath$key/$file", "$basepath$key/$new.dat"); &oops('incorrect alias') unless (open(REGFILE, ">>$basepath$regdir/$firstbid[0].dat")); print REGFILE "\n$key$new"; close REGFILE; } #--END: Reserve or opening not met section-------------# #--No bids placed section------------------------------# elsif ($firstbid[0] eq $lastbid[0]) { $nosellreason = "No bids were placed"; $doit = 1; $new = ($repostseconds + time); $new = ($repostseconds + time) until (!(-e "$basepath$key/$new.dat")); print "Please notify the site administrator that this item file cannot be renamed.\n" unless rename("$basepath$key/$file", "$basepath$key/$new.dat"); &oops('incorrect alias') unless (open(REGFILE, ">>$basepath$regdir/$firstbid[0].dat")); print REGFILE "\n$key$new"; close REGFILE; } #--END: No bids placed section-------------------------# #-Image Upload-----------------------------------------# # If you are not using the image upload addon, comment # out 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"; print "Please notify the site administrator that this items image file cannot be renamed.\n" unless rename("$imagefile", "$imageuploaddir/$key$new.$extension"); } } #-Image Upload END-------------------------------------# $relist = ($relist - 1); open THEFILE, ">$basepath$key/$new.dat"; print THEFILE "$title\n$reserve\n$inc\n$desc\n$image\n$relist"; $firstbid[3] = time; #-Keep the entire bid history--------------------------# # foreach $bid (@bids) { # print THEFILE "\n$bid"; # } #------------------------------------------------------# #-Only keep the initial opening bid--------------------# print "\n$firstbid"; #------------------------------------------------------# close THEFILE; if ($doit == 1) { $resend = " Hello $firstbid[0], Thank you for using $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://$scripturl$ENV{'SCRIPT_NAME'}\?$key\&$new Once again, thank you and please tell a friend about us! Sincerely, $sitename "; &sendemail($firstbid[1],'Relist of Auction', 'nobody', $mailserver, $resend); sleep 2; # Wait 2 seconds to make sure we don't get duplicate item numbers next FILE; } } #--END: Relist section loop----------------------------# if ($key ne $closedir) { if ($closedir) { umask(000); mkdir("$basepath$closedir", 0777) unless (-d "$basepath$closedir"); print "Please notify the site administrator that this item cannot be copied to the closed directory even though it is closed.\n" unless &movefile("$basepath$key/$file", "$basepath$closedir/$key$file"); $numauct = $file; $numauct =~ s/\.dat//; #-Image Upload-----------------------------------------# # If you are not using the image upload addon, comment # out this section. #------------------------------------------------------# if ($image ne '') { $extension = (split(/\./,$image))[-1]; $imagefile = "$imageuploaddir/$key$numauct.$extension"; if (-f "$imagefile") { print "Please notify the site administrator that this items image file cannot be removed.\n" 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 { print "Please notify the site administrator that this item cannot be removed even though it is closed.\n" unless unlink("$basepath$key/$file"); } 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 $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 $sitename! "; &sendemail($lastbid[1], "Auction Winner: $title", 'nobody', $mailserver, $winnermessage); $reservemsg = " "; &sendemail($firstbid[1], "Auction Close: $title", 'nobody', $mailserver, $sellermessage); } else { if ($firstbid[2] ne $lastbid[2]) { $highbidmessage = " You were the high bidder on auction number $numauct. Your bid was \$$lastbid[2]. Unfortunately, your bid did not meet the seller's reserve price... You may still wish to contact the seller to negotiate a fair price: $firstbid[4] $firstbid[5] $firstbid[6] $firstbid[1] Thanks for using $sitename! "; &sendemail($lastbid[1], "Auction Close: $title", 'nobody', $mailserver, $highbidmessage); $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://$scripturl$ENV{'SCRIPT_NAME'}\?1\&1\&v "; } else { $reservemsg = " Sorry, no bids were placed on your auction. Feel free to repost your auction by following this link: http://$scripturl$ENV{'SCRIPT_NAME'}\?1\&1\&v "; } } &sendemail($firstbid[1], "Auction Close: $title", 'nobody', $mailserver, "Auction Number $numauct Is Now Closed.\n\n$reservemsg\n\nThanks for using $sitename!"); } } #--END: File exists section----------------------------# } #--END: Auction is over section------------------------# } #--END: For each file loop section---------------------# } #--END: For each CAT loop section----------------------# } #--END: Sub AutoClose----------------------------------#