#!/usr/bin/perl # # BECANADA - ISELL Classifieds Script # Website: http://www.becanada.com/isell/ # E-Mail : sales@becanada.com # Version 3.1 - Add on for Paid Ads Processing system. # Copyright Jan 2003 # # !!!!! WARNING !!!!!! # # # ! DO NOT MODIFY below this line, you will be in violation # of copyrights, and this program will cease to function. # # You may also cause harm to your data files, and server. # # ################################################################## # # Important Settings. # $worth=7; $paypal='txfooddude@internet-grocer.net'; $paypalurl='http://www.internet-grocer.net/cgi/classif/paypal.cgi'; $check2you='n/a'; $ID10="1"; $ID20="2"; $ID50="3"; # # Need product IDS from check2you for 3 links. # # credits are each 'worth' days each. print "Content-type: text/html\n\n"; print qq~
~; } if ($FORM{'action'} eq "Setup New Account") { print qq~ Setup A New Account:
Please fill in the following fields to setup your account.
First Name:
Last Name:
E-Mail Address:
Your ID Number is: $FORM{'accid'} You can now purchase credits instantly... ";
$FORM{'action'} = "Purchase Credits";
}
if ($FORM{'action'} eq "Purchase Credits") {
$match=0;
for ($i=0; $i<@credit ; $i++) {
@words=split(/,/,@credit[$i]);
if ($FORM{'approved'} eq @words[0] || $FORM{'accid'} eq @words[0] ) {
print qq~
To Purchase Credits, click on ONE of the following buttons below - A new window will open.
Use Paypal, Visa, Mastercard, American Express or Online E-Check.
Each "credit" is worth $worth days of ad[s] extension. Credits do not expire, and can be used on any ad or ads at our classifieds site at any time, instantly.
If you currently have credits in your account [ $FORM{'accid'} ] , today's purchase will be ADDED to that balance.
To setup an account and purchase credits click this button:
~;
}
}
#
# Check database, if credits, approve and select update.
#
if ($FORM{'action'} eq "Use") {
$match=0;
for ($i=0; $i<@credit; $i++) {
@words=split(/,/,@credit[$i]);
if ($FORM{'accid'} eq @words[0] && $FORM{'email'} eq @words[3] ) {
print qq~@words[0] , owned by @words[1] @words[2] @words[3] has @words[4] Credits.
Each credit is worth $worth days of ad extension.
~;
$d=$worth;
if (@words[4] > 0) {
print qq~Extend you ad by [please select one]: ~;
for ($x=1;$x<@words[4];$x++) {
print qq~$d Days
~;
}
else {
print qq~You have no credits left, to purchase more instantly click the button below:
~;
}
$match=1;
last;
}
}
if ($match eq "0") {
print qq~No match to ID # $FORM{'accid'} and email $FORM{'email'} . To setup an account and purchase credits click this button:
~;
exit;
}
print "";
}
#
# USe alloted credits, debit credits, update ads.
#
if ($FORM{'action'} eq "Use Credits" && $FORM{'approved'} ne "" ) {
for ($i=0; $i<@credit ; $i++) {
@words=split(/,/,@credit[$i]);
if ($FORM{'approved'} eq @words[0]) {
#
# Now update ad in database HERE with new expiry date.
#
($cg,$data,$singlead,$extra1) = split(/\|/,$ENV{'QUERY_STRING'});
$singlead =~s/[?]//g;
#
# Get -- , category, time string, email to confirm
#
open(FILE, "category.txt" ) || print "I can't open that file\n";
@cats = Your Ad is now live and expiry time has been extended by $t days. ";
last;
}
}
if ($dup eq "1") {
&get_file_lock("$fl2.lock");
open(FILE, ">$fl2") || print "I can't create that file\n";
print FILE @count ;
close(FILE);
&release_file_lock("$fl2.lock");
@words[4]=@words[4] - $FORM{'adlen'};
print qq~Credit[s] Debted today: $FORM{'adlen'} . You have @words[4] credit[s] left. ~;
@credit[$i]=join(",",@words) . "\n";
open(HTML, ">$fl") || print "I can't create that file\n";
print HTML @credit;
close(HTML);
print " Ad Updated. \n";
}
else {
print "ad not found [you may have already updated it].";
}
#
# End update ad.
#
last;
}
}
}
#
# Subs
#
sub get_file_lock
{
local ($lock_file) = @_;
local ($endtime);
$endtime = 500;
$endtime = time + $endtime;
while (-e $lock_file && time < $endtime)
{
sleep(1);
}
open(LOCK_FILE, ">$lock_file") || &file_open_error ("$lock_file",
"Lock File Routine",
__FILE__, __LINE__);
}
sub release_file_lock
{
local ($lock_file) = @_;
close(LOCK_FILE);
unlink($lock_file);
}
~;
}
if ($FORM{'action'} eq "Confirm New Account") {
$fl2="credit-count.txt";
open(FILE, $fl2 ) || print "I can't open that file\n";
$id =
Your Email is: $FORM{'email'}
Once your payment is accepted you will be able to use your credits immediately, close the payment
window and click on 'Use' button at the top of the screen.
~;
$d=$d+$worth;
if ($d>360) { last;}
}
print qq~