grrrrrrrrrrrrrrrrr!

Problems installing or using the NOP Design Free Shopping Cart. **ARCHIVE** Please post new topics to one of the groups below.

Moderator: scott

grrrrrrrrrrrrrrrrr!

Postby JIMC » Thu Jan 23, 2003 5:21 pm

Having seemingly succesfully reaching a point of getting
my shopping cart to the final order form processing stage...
i find the the 'checkout.pl' script will not execute the form.
The .pl script resides in the local cgi-bin but just gives me
a 'cgiwrap' error it is CHMOD 755 (COBALT RAC SERVER)
This is the link to the shop:
http://www.ivisco.co.uk/prostabeta/offers.htm

And below i have pasted the .pl script (for my example renamed 'checkout1.pl') as i've been trying a few versions.

Desperate for some HEEELP!

#!/usr/bin/perl
#=====================================================================||
# NOP Design JavaScript Shopping Cart ||
# PERL CGI Checkout Module ||
# ||
# For more information on SmartSystems, or how NOPDesign can help you ||
# Please visit us on the WWW at http://www.nopdesign.com ||
# ||
# Javascript portions of this shopping cart software are available as ||
# freeware from NOP Design. You must keep this comment unchanged in ||
# your code. For more information contact FreeCart@NopDesign.com. ||
# ||
# JavaScript Shop Module, V.4.4.0 ||
#=====================================================================||
# ||
# Function: Writes available form elements from the NOP ||
# Free Cart (http://www.nopdesign.com/freecart) ||
# and other form elements to an email file, and ||
# send user confirmation ||
# ||
#=====================================================================||
require 5.001;

########################################################################
# #
# User defined variables: #
# $header - string value containing the complete #
# path of the HTML page header #
# $footer - string value containing the complete #
# path of the HTML page footer #
# $mailprogram - string value containing the complete path to #
# the sendmail binary on the system. #
# $youremail - string value containing the email address to #
# send catalog orders in EMAIL or BOTH modes #
# **Don't forget to put a \ before the @ in your #
# email address. ie. spam\@nopdesign.com*** #
# $returnpage - URL to send user when checkout is complete #
# $csvfilename - string value containing the complete #
# path of the user database. #
# $csvquote - string value containing what to use for quotes #
# in the csv file (typically "" or \") #
# $mode - string value containing 'EMAIL', 'FILE' or #
# 'BOTH' to determine if the script should send #
# an email to you with the new order, write the #
# order to a CSV file, or do both. #
########################################################################
$header = "header.html";
$footer = "footer.html";
$mailprogram = "/usr/lib/sendmail -t";
$returnpage = "/";
$youremail = "jim\@channell.co.uk";
$csvfilename = "orders.csv";
$csvquote = "\"\"";
$mode = "BOTH";


#These are required fields. I recommend enforcing these by javascript,
#but let's just make sure here as well.
@required = (
'b_first',
'b_last',
'b_addr',
'b_city',
'b_county',
'b_postcode',
'b_phone',
'b_email'
'b_cardtype'
'b_cardname'
'b_cardnumber'
'b_expiry'
);

##############################################################
#FUNCTION: urlDecode #
#RETURNS: The decoded string. #
#PARAMETERS: An encoded string. #
#PURPOSE: Decodes a URL encoded string. #
##############################################################
sub urlDecode {
my ($string) = @_;
$string =~ tr/+/ /;
$string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg;
$string =~ s/['"]/\'/g;
return ($string);
}

##############################################################
#FUNCTION: processCGI #
#RETURNS: #
#PARAMETERS: #
#PURPOSE: Retrieves form data submitted via the 'GET' #
# method and decodes it. You may then access #
# the passed in variables via calls to $[name] #
# where [name] is the name of the form element. #
##############################################################
sub processCGI {
local ($cgiData, $key, $value, $pair, @pairs);

if ($ENV{'REQUEST_METHOD'} eq 'GET') { $cgiData = $ENV{'QUERY_STRING'}; }
else { $cgiData = <STDIN>; }
@pairs = split (/&/, $cgiData);
foreach $pair (@pairs) {
($key, $value) = split (/\=/, $pair);
$key = &urlDecode($key);
$value = &urlDecode($value);
if(defined ${$key}){
${$key} .= ", ".$value;
}else{
${$key} = $value;
}
}
}

##############################################################
#FUNCTION: doFormError #
#RETURNS: #
#PARAMETERS: A error message string. #
#PURPOSE: Generates an HTML page indicating a form #
# submission error occurred. #
##############################################################
sub doFormError {
my ($errString) = @_;

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;

print "Content-type: text/html\n\n";

print @LINES;

print "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
print "$errString<BR><BR>\n";
print "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;
print @LINES;

exit;
}

##############################################################
#FUNCTION: doError #
#RETURNS: #
#PARAMETERS: A error message string. #
#PURPOSE: Generates an HTML page indicating an error #
# occurred. #
##############################################################
sub doError {
my ($errString) = @_;
print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;

print @LINES;

print "$errString<BR><BR>\n";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;
print @LINES;

exit;
}

##############################################################
#FUNCTION: invalidE #
#RETURNS: 1 if invalid, 0 if valid. #
#PARAMETERS: An email address variable. #
#PURPOSE: Checks to see if a submitted email address is #
# of the valid form 'x@y'. #
##############################################################
sub invalidE {
my ($szEmail) = @_;
my ($user, $host);

$szEmail =~ tr/A-Z/a-z/;
if ($szEmail =~ /\s/) { return 1; }
($user, $host) = split (/\@/, $szEmail);
if ($host =~ /compuserve/i) { ; }
else {
if (! $user =~ /\D/) { return 1; }
if (! $host =~ /\D/) { return 1; }
if (substr ($user,0,1) !~ /[a-z]/) { return 1; }
}
if ($szEmail =~ /\w+\@[\w|\.]/) { return 0; }
else { return 1; }
}


sub populateDateVar {
@months = ();
push(@months,"January");
push(@months,"February");
push(@months,"March");
push(@months,"April");
push(@months,"May");
push(@months,"June");
push(@months,"July");
push(@months,"August");
push(@months,"September");
push(@months,"October");
push(@months,"November");
push(@months,"December");
@days = ();
push(@days,"Sunday");
push(@days,"Monday");
push(@days,"Tuesday");
push(@days,"Wednesday");
push(@days,"Thursday");
push(@days,"Friday");
push(@days,"Saturday");
($sec,$min,$hour,$day,$month,$year,$day2) =
(localtime(time))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($day < 10) { $day = "0$day"; }
$year += "1900";

#$todaysdate = "$months[$month] $day, $year $hour:$min:$sec";
}


##############################################################
##############################################################
### MAIN ###
##############################################################
##############################################################

# process the form input.
&processCGI;
&populateDateVar;

foreach $check(@required) {
unless ($check) {
doFormError("It appears that you forgot to fill in the <strong>$check</strong> field.");
exit;
}
}

# checks for valid email address
if( &invalidE($b_email) ){
doFormError('You submitted an invalid email address.');
}


if( $mode eq "BOTH" || $mode eq "EMAIL") {
# Send email order to you...
open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $b_email\n";
print MAIL "Subject: New Online Order\n";
print MAIL "\n\n";
print MAIL "A new order has been received. A summary of this order appears below.\n";
print MAIL "\n";
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
print MAIL " \n";
print MAIL "Bill To: \n";
print MAIL "-------- \n";
print MAIL " $b_first $b_last \n";
print MAIL " $b_addr \n";
print MAIL " $b_addr2 \n";
print MAIL " $b_city, $b_state $b_zip \n";
print MAIL " $b_phone \n";
print MAIL " $b_fax \n";
print MAIL " $b_email \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Ship To: \n";
print MAIL "-------- \n";
print MAIL " $s_first $s_last \n";
print MAIL " $s_addr \n";
print MAIL " $s_addr2 \n";
print MAIL " $s_city, $s_state $s_zip \n";
print MAIL " $s_phone \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Qty Price(\$) Product ID - Product Name\n";
print MAIL "===================================================================== \n";
print MAIL "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n";
if( $NAME_2 ) {print MAIL "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $NAME_3 ) {print MAIL "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";}
if( $NAME_4 ) {print MAIL "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";}
if( $NAME_5 ) {print MAIL "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";}
if( $NAME_6 ) {print MAIL "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";}
if( $NAME_7 ) {print MAIL "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";}
if( $NAME_8 ) {print MAIL "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";}
if( $NAME_9 ) {print MAIL "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";}
if( $NAME_10 ){print MAIL "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";}
if( $NAME_11 ){print MAIL "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";}
if( $NAME_12 ){print MAIL "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";}
if( $NAME_13 ){print MAIL "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";}
print MAIL "===================================================================== \n";
print MAIL "SUBTOTAL: $SUBTOTAL \n";
print MAIL "TOTAL: $TOTAL \n";
print MAIL "\n";
print MAIL "FREIGHT: $SHIPPING \n";
print MAIL "\n\n";
print MAIL "Comments: \n";
print MAIL "--------- \n";
print MAIL "$comment \n";
print MAIL " \n";
close MAIL;
}


if( $mode eq "BOTH" || $mode eq "FILE") {

$csvcomments = $comment;
#$csvcomments =~ s/\"/$csvquote/ig;

open (CSVF,">>$csvfilename");
print CSVF "\"";
print CSVF "$months[$month] $day, $year $hour:$min:$sec";
print CSVF "\",\"";
print CSVF "$b_first";
print CSVF "\",\"";
print CSVF "$b_last";
print CSVF "\",\"";
print CSVF "$b_addr";
print CSVF "\",\"";
print CSVF "$b_addr2";
print CSVF "\",\"";
print CSVF "$b_city";
print CSVF "\",\"";
print CSVF "$b_state";
print CSVF "\",\"";
print CSVF "$b_zip";
print CSVF "\",\"";
print CSVF "$b_phone";
print CSVF "\",\"";
print CSVF "$b_fax";
print CSVF "\",\"";
print CSVF "$b_email";
print CSVF "\",\"";
print CSVF "$s_first";
print CSVF "\",\"";
print CSVF "$s_last";
print CSVF "\",\"";
print CSVF "$s_addr";
print CSVF "\",\"";
print CSVF "$s_addr2";
print CSVF "\",\"";
print CSVF "$s_city";
print CSVF "\",\"";
print CSVF "$s_state";
print CSVF "\",\"";
print CSVF "$s_zip";
print CSVF "\",\"";
print CSVF "$s_phone";
print CSVF "\",\"";
print CSVF "$QUANTITY_1";
print CSVF "\",\"";
print CSVF "\$$PRICE_1";
print CSVF "\",\"";
print CSVF "$ID_1";
print CSVF "\",\"";
print CSVF "$NAME_1";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_1";
print CSVF "\",\"";
print CSVF "$QUANTITY_2";
print CSVF "\",\"";
print CSVF "\$$PRICE_2";
print CSVF "\",\"";
print CSVF "$ID_2";
print CSVF "\",\"";
print CSVF "$NAME_2";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_2";
print CSVF "\",\"";
print CSVF "$QUANTITY_3";
print CSVF "\",\"";
print CSVF "\$$PRICE_3";
print CSVF "\",\"";
print CSVF "$ID_3";
print CSVF "\",\"";
print CSVF "$NAME_3";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_3";
print CSVF "\",\"";
print CSVF "$QUANTITY_4";
print CSVF "\",\"";
print CSVF "\$$PRICE_4";
print CSVF "\",\"";
print CSVF "$ID_4";
print CSVF "\",\"";
print CSVF "$NAME_4";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_4";
print CSVF "\",\"";
print CSVF "$QUANTITY_5";
print CSVF "\",\"";
print CSVF "\$$PRICE_5";
print CSVF "\",\"";
print CSVF "$ID_5";
print CSVF "\",\"";
print CSVF "$NAME_5";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_5";
print CSVF "\",\"";
print CSVF "$QUANTITY_6";
print CSVF "\",\"";
print CSVF "\$$PRICE_6";
print CSVF "\",\"";
print CSVF "$ID_6";
print CSVF "\",\"";
print CSVF "$NAME_6";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_6";
print CSVF "\",\"";
print CSVF "$QUANTITY_7";
print CSVF "\",\"";
print CSVF "\$$PRICE_7";
print CSVF "\",\"";
print CSVF "$ID_7";
print CSVF "\",\"";
print CSVF "$NAME_7";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_7";
print CSVF "\",\"";
print CSVF "$QUANTITY_8";
print CSVF "\",\"";
print CSVF "\$$PRICE_8";
print CSVF "\",\"";
print CSVF "$ID_8";
print CSVF "\",\"";
print CSVF "$NAME_8";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_8";
print CSVF "\",\"";
print CSVF "$QUANTITY_9";
print CSVF "\",\"";
print CSVF "\$$PRICE_9";
print CSVF "\",\"";
print CSVF "$ID_9";
print CSVF "\",\"";
print CSVF "$NAME_9";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_9";
print CSVF "\",\"";
print CSVF "$QUANTITY_10";
print CSVF "\",\"";
print CSVF "\$$PRICE_10";
print CSVF "\",\"";
print CSVF "$ID_10";
print CSVF "\",\"";
print CSVF "$NAME_10";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_10";
print CSVF "\",\"";
print CSVF "$QUANTITY_11";
print CSVF "\",\"";
print CSVF "\$$PRICE_11";
print CSVF "\",\"";
print CSVF "$ID_11";
print CSVF "\",\"";
print CSVF "$NAME_11";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_11";
print CSVF "\",\"";
print CSVF "$QUANTITY_12";
print CSVF "\",\"";
print CSVF "\$$PRICE_12";
print CSVF "\",\"";
print CSVF "$ID_12";
print CSVF "\",\"";
print CSVF "$NAME_12";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_12";
print CSVF "\",\"";
print CSVF "$QUANTITY_13";
print CSVF "\",\"";
print CSVF "\$$PRICE_13";
print CSVF "\",\"";
print CSVF "$ID_13";
print CSVF "\",\"";
print CSVF "$NAME_13";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_13";
print CSVF "\",\"";
print CSVF "$SUBTOTAL";
print CSVF "\",\"";
print CSVF "$TOTAL";
print CSVF "\",\"";
print CSVF "$SHIPPING";
print CSVF "\",\"";
print CSVF "$comment";
print CSVF "\"\n";
close CSVF;
}



# Send email conformation to the customer.....
open (MAIL,"|$mailprogram");
print MAIL "To: $b_email\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: Order Confirmation\n";
print MAIL "\n\n";
print MAIL "A new order has been received. A summary of this order appears below.\n";
print MAIL "\n";
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
print MAIL " \n";
print MAIL "Bill To: \n";
print MAIL "-------- \n";
print MAIL " $b_first $b_last \n";
print MAIL " $b_addr \n";
print MAIL " $b_addr2 \n";
print MAIL " $b_city, $b_county $b_postcode \n";
print MAIL " $b_phone \n";
print MAIL " $b_fax \n";
print MAIL " $b_email \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Ship To: \n";
print MAIL "-------- \n";

if ( $s_addr eq "" ) {
print MAIL " Use Billing Address\n";
} else {
print MAIL " $s_first $s_last \n";
print MAIL " $s_addr \n";
print MAIL " $s_addr2 \n";
print MAIL " $s_city, $s_county $s_postcode \n";
print MAIL " $s_phone \n";
}

print MAIL " \n";
print MAIL " \n";
print MAIL "Qty Price(\$) Product ID - Product Name\n";
print MAIL "===================================================================== \n";
print MAIL "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n";
if( $NAME_2 ) {print MAIL "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $NAME_3 ) {print MAIL "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";}
if( $NAME_4 ) {print MAIL "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";}
if( $NAME_5 ) {print MAIL "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";}
if( $NAME_6 ) {print MAIL "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";}
if( $NAME_7 ) {print MAIL "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";}
if( $NAME_8 ) {print MAIL "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";}
if( $NAME_9 ) {print MAIL "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";}
if( $NAME_10 ){print MAIL "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";}
if( $NAME_11 ){print MAIL "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";}
if( $NAME_12 ){print MAIL "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";}
if( $NAME_13 ){print MAIL "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";}
print MAIL "===================================================================== \n";
print MAIL "SUBTOTAL: $SUBTOTAL \n";
print MAIL "TOTAL: $TOTAL \n";
print MAIL "\n";
print MAIL "FREIGHT: $SHIPPING \n";
print MAIL "\n\n";
print MAIL "Comments: \n";
print MAIL "--------- \n";
print MAIL "$comment \n";
print MAIL " \n";
close MAIL;


print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;
print @LINES;

print "<h2>Thank you</h2>";
print "Thank you for your Prostabeta order from our online store. You will receive a confirmation email of your order ";
print "momentarily. Please contact us at sales@gh3.co.uk if you have any questions or concerns.";
print "<P>";
print "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
print "<P>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;

print @LINES;

exit;



AND THIS IS THE 'nopcart1.js' ALSO RENAMED(with my edits)

//=====================================================================||
// NOP Design JavaScript Shopping Cart ||
// ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com ||
// ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design. You must keep this comment unchanged in ||
// your code. For more information contact FreeCart@NopDesign.com. ||
// ||
// JavaScript Shop Module, V.4.3.0 ||
//=====================================================================||

//---------------------------------------------------------------------||
// Global Options ||
// ---------------- ||
// Shopping Cart Options, you can modify these options to change the ||
// the way the cart functions. ||
// ||
// Options For Everyone: ||
// ===================== ||
// * Language: string, the two digit language code to display user ||
// messages in. Supported languages: ||
// * English (en) ||
// * MonetarySymbol: string, the symbol which represents dollars/euro, ||
// in your locale. ||
// * DisplayNotice: true/false, controls whether the user is provided ||
// with a popup letting them know their product is added to the cart ||
// * DisplayShippingColumn: true/false, controls whether the managecart||
// and checkout pages display shipping cost column. ||
// * DisplayShippingRow: true/false, controls whether the managecart ||
// and checkout pages display shipping cost total row. ||
// * DisplayTaxRow: true/false, controls whether the managecart ||
// and checkout pages display tax cost total row. ||
// * TaxRate: number, your area's current tax rate, ie: if your tax ||
// rate was 7.5%, you would set TaxRate = 0.075 ||
// * TaxByRegion: true/false, when set to true, the user is prompted ||
// with TaxablePrompt to determine if they should be charged tax. ||
// In the USA, this is useful to charge tax to those people who live ||
// in a particular state, but no one else. ||
// * TaxPrompt: string, popup message if user has not selected either ||
// taxable or nontaxable when TaxByRegion is set to true. ||
// * TaxablePrompt: string, the message the user is prompted with to ||
// select if they are taxable. If TaxByRegion is set to false, this ||
// has no effect. Example: 'Arizona Residents' ||
// * NonTaxablePrompt: string, same as above, but the choice for non- ||
// taxable people. Example: 'Other States' ||
// * MinimumOrder: number, the minium dollar amount that must be ||
// purchased before a user is allowed to checkout. Set to 0.00 ||
// to disable. ||
// * MinimumOrderPrompt: string, Message to prompt users with when ||
// they have not met the minimum order amount. ||
// ||
// Payment Processor Options: ||
// ========================== ||
// * PaymentProcessor: string, the two digit payment processor code ||
// for support payment processor gateways. Setting this field to ||
// anything other than an empty string will override your OutputItem ||
// settings -- so please be careful when receiving any form data. ||
// Support payment processor gateways are: ||
// * Authorize.net (an) ||
// * Worldpay (wp) ||
// * LinkPoint (lp)
// ||
// Options For Programmers: ||
// ======================== ||
// * OutputItem<..>: string, the name of the pair value passed at ||
// checkouttime. Change these only if you are connecting to a CGI ||
// script and need other field names, or are using a secure service ||
// that requires specific field names. ||
// * AppendItemNumToOutput: true/false, if set to true, the number of ||
// each ordered item will be appended to the output string. For ||
// example if OutputItemId is 'ID_' and this is set to true, the ||
// output field name will be 'ID_1', 'ID_2' ... for each item. ||
// * HiddenFieldsToCheckout: true/false, if set to true, hidden fields ||
// for the cart items will be passed TO the checkout page, from the ||
// ManageCart page. This is set to true for CGI/PHP/Script based ||
// checkout pages, but should be left false if you are using an ||
// HTML/Javascript Checkout Page. Hidden fields will ALWAYS be ||
// passed FROM the checkout page to the Checkout CGI/PHP/ASP/Script ||
//---------------------------------------------------------------------||

//Options for Everyone:
Language = 'en';
MonetarySymbol = '£';
DisplayNotice = true;
DisplayShippingColumn = false;
DisplayShippingRow = false;
DisplayTaxRow = true;
TaxRate = 0.00;
TaxByRegion = true;
TaxPrompt = 'Please choose your Postage option';
TaxablePrompt = '1st Class';
NonTaxablePrompt = 'Swift Air';
MinimumOrder = 17.96;
MinimumOrderPrompt = 'Your order is below our minimum order, please order at least 1 item before checkout.';

//Payment Processor Options:
PaymentProcessor = '';

//Options for Programmers:
OutputItemId = 'ID_';
OutputItemQuantity = 'QUANTITY_';
OutputItemPrice = 'PRICE_';
OutputItemName = 'NAME_';
OutputItemShipping = 'SHIPPING_';
OutputItemAddtlInfo = 'ADDTLINFO_';
OutputOrderSubtotal = 'SUBTOTAL';
OutputOrderShipping = 'SHIPPING';
OutputOrderTax = 'TAX';
OutputOrderTotal = 'TOTAL';
AppendItemNumToOutput = true;
HiddenFieldsToCheckout = false;


//---------------------------------------------------------------------||
// Language Strings ||
// ------------------ ||
// Strings displayed to end users, in language specific encoding. ||
// only modify these strings if you wish to change language specific ||
// wording for your site. ||
//---------------------------------------------------------------------||
if ( Language == 'en' || !bLanguageDefined ) {
strSorry = "I'm Sorry, your cart is full, please proceed to checkout.";
strAdded = " added to your shopping cart.";
strRemove = "Click 'Ok' to remove this product from your shopping cart.";
strILabel = "Product Id";
strDLabel = "+Description";
strQLabel = "+Quantity";
strPLabel = "Price";
strSLabel = "Shipping";
strRLabel = "Remove From Cart";
strRButton= "Remove";
strSUB = "SUBTOTAL";
strSHIP = "SHIPPING";
strTAX = "POSTAGE+PACKING";
strTOT = "TOTAL (INCLUDING P+P)";
strErrQty = "Invalid Quantity.";
strNewQty = 'Please enter new quantity:';
bLanguageDefined = true;
}




//=====================================================================||
//---------------------------------------------------------------------||
// NO MODIFICATIONS BELOW THIS LINE ||
//---------------------------------------------------------------------||
//=====================================================================||




//---------------------------------------------------------------------||
// FUNCTION: CKquantity ||
// PARAMETERS: Quantity to ||
// RETURNS: Quantity as a number, and possible alert ||
// PURPOSE: Make sure quantity is represented as a number ||
//---------------------------------------------------------------------||
function CKquantity(checkString) {
var strNewQuantity = "";

for ( i = 0; i < checkString.length; i++ ) {
ch = checkString.substring(i, i+1);
if ( (ch >= "0" && ch <= "9") || (ch == '.') )
strNewQuantity += ch;
}

if ( strNewQuantity.length < 1 )
strNewQuantity = "1";

return(strNewQuantity);
}


//---------------------------------------------------------------------||
// FUNCTION: AddToCart ||
// PARAMETERS: Form Object ||
// RETURNS: Cookie to user's browser, with prompt ||
// PURPOSE: Adds a product to the user's shopping cart ||
//---------------------------------------------------------------------||
function AddToCart(thisForm) {
var iNumberOrdered = 0;
var bAlreadyInCart = false;
var notice = "";
iNumberOrdered = GetCookie("NumberOrdered");

if ( iNumberOrdered == null )
iNumberOrdered = 0;

if ( thisForm.ID_NUM == null )
strID_NUM = "";
else
strID_NUM = thisForm.ID_NUM.value;

if ( thisForm.QUANTITY == null )
strQUANTITY = "1";
else
strQUANTITY = thisForm.QUANTITY.value;

if ( thisForm.PRICE == null )
strPRICE = "0.00";
else
strPRICE = thisForm.PRICE.value;

if ( thisForm.NAME == null )
strNAME = "";
else
strNAME = thisForm.NAME.value;

if ( thisForm.SHIPPING == null )
strSHIPPING = "0.00";
else
strSHIPPING = thisForm.SHIPPING.value;

if ( thisForm.ADDITIONALINFO == null ) {
strADDTLINFO = "";
} else {
strADDTLINFO = thisForm.ADDITIONALINFO[thisForm.ADDITIONALINFO.selectedIndex].value;
}

//Is this product already in the cart? If so, increment quantity instead of adding another.
for ( i = 1; i <= iNumberOrdered; i++ ) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 );
fields[1] = database.substring( Token0+1, Token1 );
fields[2] = database.substring( Token1+1, Token2 );
fields[3] = database.substring( Token2+1, Token3 );
fields[4] = database.substring( Token3+1, Token4 );
fields[5] = database.substring( Token4+1, database.length );

if ( fields[0] == strID_NUM &&
fields[2] == strPRICE &&
fields[3] == strNAME &&
fields[5] == strADDTLINFO
) {
bAlreadyInCart = true;
dbUpdatedOrder = strID_NUM + "|" +
(parseInt(strQUANTITY)+parseInt(fields[1])) + "|" +
strPRICE + "|" +
strNAME + "|" +
strSHIPPING + "|" +
strADDTLINFO;
strNewOrder = "Order." + i;
DeleteCookie(strNewOrder, "/");
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
notice = strQUANTITY + " " + strNAME + strAdded;
break;
}
}


if ( !bAlreadyInCart ) {
iNumberOrdered++;

if ( iNumberOrdered > 40 )
alert( strSorry );
else {
dbUpdatedOrder = strID_NUM + "|" +
strQUANTITY + "|" +
strPRICE + "|" +
strNAME + "|" +
strSHIPPING + "|" +
strADDTLINFO;

strNewOrder = "Order." + iNumberOrdered;
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
SetCookie("NumberOrdered", iNumberOrdered, null, "/");
notice = strQUANTITY + " " + strNAME + strAdded;
}
}

if ( DisplayNotice )
alert(notice);
}


//---------------------------------------------------------------------||
// FUNCTION: getCookieVal ||
// PARAMETERS: offset ||
// RETURNS: URL unescaped Cookie Value ||
// PURPOSE: Get a specific value from a cookie ||
//---------------------------------------------------------------------||
function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);

if ( endstr == -1 )
endstr = document.cookie.length;
return(unescape(document.cookie.substring(offset, endstr)));
}


//---------------------------------------------------------------------||
// FUNCTION: FixCookieDate ||
// PARAMETERS: date ||
// RETURNS: date ||
// PURPOSE: Fixes cookie date, stores back in date ||
//---------------------------------------------------------------------||
function FixCookieDate (date) {
var base = new Date(0);
var skew = base.getTime();

date.setTime (date.getTime() - skew);
}


//---------------------------------------------------------------------||
// FUNCTION: GetCookie ||
// PARAMETERS: Name ||
// RETURNS: Value in Cookie ||
// PURPOSE: Retrieves cookie from users browser ||
//---------------------------------------------------------------------||
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;

while ( i < clen ) {
var j = i + alen;
if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));
i = document.cookie.indexOf(" ", i) + 1;
if ( i == 0 ) break;
}

return(null);
}


//---------------------------------------------------------------------||
// FUNCTION: SetCookie ||
// PARAMETERS: name, value, expiration date, path, domain, security ||
// RETURNS: Null ||
// PURPOSE: Stores a cookie in the users browser ||
//---------------------------------------------------------------------||
function SetCookie (name,value,expires,path,domain,secure) {
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
}


//---------------------------------------------------------------------||
// FUNCTION: DeleteCookie ||
// PARAMETERS: Cookie name, path, domain ||
// RETURNS: null ||
// PURPOSE: Removes a cookie from users browser. ||
//---------------------------------------------------------------------||
function DeleteCookie (name,path,domain) {
if ( GetCookie(name) ) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}


//---------------------------------------------------------------------||
// FUNCTION: MoneyFormat ||
// PARAMETERS: Number to be formatted ||
// RETURNS: Formatted Number ||
// PURPOSE: Reformats Dollar Amount to #.## format ||
//---------------------------------------------------------------------||
function moneyFormat(input) {
var dollars = Math.floor(input);
var tmp = new String(input);

for ( var decimalAt = 0; decimalAt < tmp.length; decimalAt++ ) {
if ( tmp.charAt(decimalAt)=="." )
break;
}

var cents = "" + Math.round(input * 100);
cents = cents.substring(cents.length-2, cents.length)
dollars += ((tmp.charAt(decimalAt+2)=="9")&&(cents=="00"))? 1 : 0;

if ( cents == "0" )
cents = "00";

return(dollars + "." + cents);
}


//---------------------------------------------------------------------||
// FUNCTION: RemoveFromCart ||
// PARAMETERS: Order Number to Remove ||
// RETURNS: Null ||
// PURPOSE: Removes an item from a users shopping cart ||
//---------------------------------------------------------------------||
function RemoveFromCart(RemOrder) {
if ( confirm( strRemove ) ) {
NumberOrdered = GetCookie("NumberOrdered");
for ( i=RemOrder; i < NumberOrdered; i++ ) {
NewOrder1 = "Order." + (i+1);
NewOrder2 = "Order." + (i);
database = GetCookie(NewOrder1);
SetCookie (NewOrder2, database, null, "/");
}
NewOrder = "Order." + NumberOrdered;
SetCookie ("NumberOrdered", NumberOrdered-1, null, "/");
DeleteCookie(NewOrder, "/");
location.href=location.href;
}
}


//---------------------------------------------------------------------||
// FUNCTION: ChangeQuantity ||
// PARAMETERS: Order Number to Change Quantity ||
// RETURNS: Null ||
// PURPOSE: Changes quantity of an item in the shopping cart ||
//---------------------------------------------------------------------||
function ChangeQuantity(OrderItem,NewQuantity) {
if ( isNaN(NewQuantity) ) {
alert( strErrQty );
} else {
NewOrder = "Order." + OrderItem;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 );
fields[1] = database.substring( Token0+1, Token1 );
fields[2] = database.substring( Token1+1, Token2 );
fields[3] = database.substring( Token2+1, Token3 );
fields[4] = database.substring( Token3+1, Token4 );
fields[5] = database.substring( Token4+1, database.length );

dbUpdatedOrder = fields[0] + "|" +
NewQuantity + "|" +
fields[2] + "|" +
fields[3] + "|" +
fields[4] + "|" +
fields[5];
strNewOrder = "Order." + OrderItem;
DeleteCookie(strNewOrder, "/");
SetCookie(strNewOrder, dbUpdatedOrder, null, "/");
location.href=location.href;
}
}


//---------------------------------------------------------------------||
// FUNCTION: GetFromCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page ||
// **DEPRECATED FUNCTION, USE ManageCart or Checkout** ||
//---------------------------------------------------------------------||
function GetFromCart( fShipping ) {
ManageCart( );
}


//---------------------------------------------------------------------||
// FUNCTION: RadioChecked ||
// PARAMETERS: Radio button to check ||
// RETURNS: True if a radio has been checked ||
// PURPOSE: Form fillin validation ||
//---------------------------------------------------------------------||
function RadioChecked( radiobutton ) {
var bChecked = false;
var rlen = radiobutton.length;
for ( i=0; i < rlen; i++ ) {
if ( radiobutton[i].checked )
bChecked = true;
}
return bChecked;
}


//---------------------------------------------------------------------||
// FUNCTION: QueryString ||
// PARAMETERS: Key to read ||
// RETURNS: value of key ||
// PURPOSE: Read data passed in via GET mode ||
//---------------------------------------------------------------------||
QueryString.keys = new Array();
QueryString.values = new Array();
function QueryString(key) {
var value = null;
for (var i=0;i<QueryString.keys.length;i++) {
if (QueryString.keys[i]==key) {
value = QueryString.values[i];
break;
}
}
return value;
}

//---------------------------------------------------------------------||
// FUNCTION: QueryString_Parse ||
// PARAMETERS: (URL string) ||
// RETURNS: null ||
// PURPOSE: Parses query string data, must be called before Q.S. ||
//---------------------------------------------------------------------||
function QueryString_Parse() {
var query = window.location.search.substring(1);
var pairs = query.split("&"); for (var i=0;i<pairs.length;i++) {
var pos = pairs[i].indexOf('=');
if (pos >= 0) {
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
QueryString.keys[QueryString.keys.length] = argname;
QueryString.values[QueryString.values.length] = value;
}
}
}


//---------------------------------------------------------------------||
// FUNCTION: ManageCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page ||
//---------------------------------------------------------------------||
function ManageCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fShipping = 0; //Shipping amount
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)

iNumberOrdered = GetCookie("NumberOrdered");
if ( iNumberOrdered == null )
iNumberOrdered = 0;

if ( bDisplay )
strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
"<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +
"<TD CLASS=\"nopheader\"><B>"+strRLabel+"</B></TD></TR>";

if ( iNumberOrdered == 0 ) {
strOutput += "<TR><TD COLSPAN=6 CLASS=\"nopentry\"><CENTER><BR><B>Your cart is empty</B><BR><BR></CENTER></TD></TR>";
}

for ( i = 1; i <= iNumberOrdered; i++ ) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 ); // Product ID
fields[1] = database.substring( Token0+1, Token1 ); // Quantity
fields[2] = database.substring( Token1+1, Token2 ); // Price
fields[3] = database.substring( Token2+1, Token3 ); // Product Description
fields[4] = database.substring( Token3+1, Token4 ); // Shipping Cost
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fShipping += (parseInt(fields[1]) * parseFloat(fields[4]) );
fTax = (fTotal * TaxRate);
strTotal = moneyFormat(fTotal);
strTax = moneyFormat(fTax);
strShipping = moneyFormat(fShipping);

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"nopentry\">" + fields[0] + "</TD>";

if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

strOutput += "<TD CLASS=\"nopentry\"><INPUT TYPE=TEXT NAME=Q SIZE=2 VALUE=\"" + fields[1] + "\" onChange=\"ChangeQuantity("+i+", this.value);\"></TD>";
strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

if ( DisplayShippingColumn ) {
if ( parseFloat(fields[4]) > 0 )
strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
}

strOutput += "<TD CLASS=\"nopentry\" ALIGN=CENTER><input type=button value=\" "+strRButton+" \" onClick=\"RemoveFromCart("+i+")\" class=\"nopbutton\"></TD></TR>";
}

if ( AppendItemNumToOutput ) {
strFooter = i;
} else {
strFooter = "";
}
if ( HiddenFieldsToCheckout ) {
strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemShipping + strFooter + "\" value=\"" + fields[4] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
}

}

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strTotal + "</B></TD>";
strOutput += "</TR>";

if ( DisplayShippingRow ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strSHIP+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}

if ( DisplayTaxRow || TaxByRegion ) {
if ( TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>";
strOutput += "<input type=radio name=\""+OutputOrderTax+"\" value=\"" + strTax + "\">";
strOutput += TaxablePrompt + ":" + MonetarySymbol + strTax;
strOutput += "<BR><input type=radio name=\""+OutputOrderTax+"\" value=\"6.50\">";
strOutput += NonTaxablePrompt + ":" + MonetarySymbol + "6.50";
strOutput += "</B></TD>";
strOutput += "</TR>";
} else {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + strTax + "</B></TD>";
strOutput += "</TR>";
}
}

if ( !TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=4><B>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
strOutput += "</TR>";
}
strOutput += "</TABLE>";

if ( HiddenFieldsToCheckout ) {
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + strTax + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
}
}
g_TotalCost = (fTotal + fShipping + fTax);

document.write(strOutput);
document.close();
}

//---------------------------------------------------------------------||
// FUNCTION: ValidateCart ||
// PARAMETERS: Form to validate ||
// RETURNS: true/false ||
// PURPOSE: Validates the managecart form ||
//---------------------------------------------------------------------||
var g_TotalCost = 0;
function ValidateCart( theForm ) {
if ( TaxByRegion ) {
if ( !RadioChecked(eval("theForm."+OutputOrderTax)) ) {
alert( TaxPrompt );
return false;
}
}

if ( MinimumOrder >= 0.01 ) {
if ( g_TotalCost < MinimumOrder ) {
alert( MinimumOrderPrompt );
return false;
}
}

return true;
}

//---------------------------------------------------------------------||
// FUNCTION: CheckoutCart ||
// PARAMETERS: Null ||
// RETURNS: Product Table Written to Document ||
// PURPOSE: Draws current cart product table on HTML page for ||
// checkout. ||
//---------------------------------------------------------------------||
function CheckoutCart( ) {
var iNumberOrdered = 0; //Number of products ordered
var fTotal = 0; //Total cost of order
var fTax = 0; //Tax amount
var fShipping = 0; //Shipping amount
var strTotal = ""; //Total cost formatted as money
var strTax = ""; //Total tax formatted as money
var strShipping = ""; //Total shipping formatted as money
var strOutput = ""; //String to be written to page
var bDisplay = true; //Whether to write string to the page (here for programmers)
var strPP = ""; //Payment Processor Description Field

iNumberOrdered = GetCookie("NumberOrdered");
if ( iNumberOrdered == null )
iNumberOrdered = 0;

if ( TaxByRegion ) {
QueryString_Parse();
fTax = parseFloat( QueryString( OutputOrderTax ) );
strTax = moneyFormat(fTax);
}

if ( bDisplay )
strOutput = "<TABLE CLASS=\"nopcart\"><TR>" +
"<TD CLASS=\"nopheader\"><B>"+strILabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strDLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strQLabel+"</B></TD>" +
"<TD CLASS=\"nopheader\"><B>"+strPLabel+"</B></TD>" +
(DisplayShippingColumn?"<TD CLASS=\"nopheader\"><B>"+strSLabel+"</B></TD>":"") +
"</TR>";

for ( i = 1; i <= iNumberOrdered; i++ ) {
NewOrder = "Order." + i;
database = "";
database = GetCookie(NewOrder);

Token0 = database.indexOf("|", 0);
Token1 = database.indexOf("|", Token0+1);
Token2 = database.indexOf("|", Token1+1);
Token3 = database.indexOf("|", Token2+1);
Token4 = database.indexOf("|", Token3+1);

fields = new Array;
fields[0] = database.substring( 0, Token0 ); // Product ID
fields[1] = database.substring( Token0+1, Token1 ); // Quantity
fields[2] = database.substring( Token1+1, Token2 ); // Price
fields[3] = database.substring( Token2+1, Token3 ); // Product Description
fields[4] = database.substring( Token3+1, Token4 ); // Shipping Cost
fields[5] = database.substring( Token4+1, database.length ); //Additional Information

fTotal += (parseInt(fields[1]) * parseFloat(fields[2]) );
fShipping += (parseInt(fields[1]) * parseFloat(fields[4]) );
if ( !TaxByRegion ) fTax = (fTotal * TaxRate);
strTotal = moneyFormat(fTotal);
if ( !TaxByRegion ) strTax = moneyFormat(fTax);
strShipping = moneyFormat(fShipping);

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"nopentry\">" + fields[0] + "</TD>";

if ( fields[5] == "" )
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + "</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">" + fields[3] + " - <I>"+ fields[5] + "</I></TD>";

strOutput += "<TD CLASS=\"nopentry\">" + fields[1] + "</TD>";
strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[2]) + "/ea</TD>";

if ( DisplayShippingColumn ) {
if ( parseFloat(fields[4]) > 0 )
strOutput += "<TD CLASS=\"nopentry\">"+ MonetarySymbol + moneyFormat(fields[4]) + "/ea</TD>";
else
strOutput += "<TD CLASS=\"nopentry\">N/A</TD>";
}

strOutput += "</TR>";
}

if ( AppendItemNumToOutput ) {
strFooter = i;
} else {
strFooter = "";
}
if ( PaymentProcessor != '' ) {
//Process description field for payment processors instead of hidden values.
//Format Description of product as:
// ID, Name, Qty X
strPP += fields[0] + ", " + fields[3];
if ( fields[5] != "" )
strPP += " - " + fields[5];
strPP += ", Qty. " + fields[1] + "\n";
} else {
strOutput += "<input type=hidden name=\"" + OutputItemId + strFooter + "\" value=\"" + fields[0] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemQuantity + strFooter + "\" value=\"" + fields[1] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemPrice + strFooter + "\" value=\"" + fields[2] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemName + strFooter + "\" value=\"" + fields[3] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemShipping + strFooter + "\" value=\"" + fields[4] + "\">";
strOutput += "<input type=hidden name=\"" + OutputItemAddtlInfo + strFooter + "\" value=\"" + fields[5] + "\">";
}

}

if ( bDisplay ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSUB+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTotal + "</B></TD>";
strOutput += "</TR>";

if ( DisplayShippingRow ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strSHIP+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strShipping + "</B></TD>";
strOutput += "</TR>";
}

if ( DisplayTaxRow || TaxByRegion ) {
strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTAX+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + strTax + "</B></TD>";
strOutput += "</TR>";
}

strOutput += "<TR><TD CLASS=\"noptotal\" COLSPAN=3><B>"+strTOT+"</B></TD>";
strOutput += "<TD CLASS=\"noptotal\" COLSPAN=2 ALIGN=RIGHT><B>" + MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "</B></TD>";
strOutput += "</TR>";

strOutput += "</TABLE>";


if ( PaymentProcessor == 'an') {
//Process this for Authorize.net WebConnect
strOutput += "<input type=hidden name=\"x_Version\" value=\"3.0\">";
strOutput += "<input type=hidden name=\"x_Show_Form\" value=\"PAYMENT_FORM\">";
strOutput += "<input type=hidden name=\"x_Description\" value=\""+ strPP + "\">";
strOutput += "<input type=hidden name=\"x_Amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
} else if ( PaymentProcessor == 'wp') {
//Process this for WorldPay
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
strOutput += "<input type=hidden name=\"amount\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
} else if ( PaymentProcessor == 'lp') {
//Process this for LinkPoint
strOutput += "<input type=hidden name=\"mode\" value=\"fullpay\">";
strOutput += "<input type=hidden name=\"chargetotal\" value=\""+ moneyFormat((fTotal + fShipping + fTax)) + "\">";
strOutput += "<input type=hidden name=\"tax\" value=\""+ MonetarySymbol + strTax + "\">";
strOutput += "<input type=hidden name=\"subtotal\" value=\""+ MonetarySymbol + strTotal + "\">";
strOutput += "<input type=hidden name=\"shipping\" value=\""+ MonetarySymbol + strShipping + "\">";
strOutput += "<input type=hidden name=\"desc\" value=\""+ strPP + "\">";
} else {
strOutput += "<input type=hidden name=\""+OutputOrderSubtotal+"\" value=\""+ MonetarySymbol + strTotal + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderShipping+"\" value=\""+ MonetarySymbol + strShipping + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTax+"\" value=\""+ MonetarySymbol + strTax + "\">";
strOutput += "<input type=hidden name=\""+OutputOrderTotal+"\" value=\""+ MonetarySymbol + moneyFormat((fTotal + fShipping + fTax)) + "\">";
}
}

document.write(strOutput);
document.close();
}

//=====================================================================||
// END NOP Design SmartPost Shopping Cart ||
//=====================================================================||
Last edited by JIMC on Thu Jan 23, 2003 6:45 pm, edited 2 times in total.
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

Postby missy » Thu Jan 23, 2003 6:04 pm

You do not have a location of header or footer file. Sometimes when the script is calling for these and it doesn't find those files it will not work

$header = "";
$footer = "";
$mailprogram = "/usr/lib/sendmail -t";
$returnpage = "/";
$youremail = "jim\@channell.co.uk";
$csvfilename = "orders.csv";
$csvquote = "\"\"";
$mode = "MAIL";

Just a suggestion.

missy
missy
 
Posts: 13
Joined: Wed Jan 22, 2003 10:17 pm
Location: Alaska

mmm...

Postby JIMC » Thu Jan 23, 2003 6:14 pm

Ok ta...just tried that unfortunalty it makes no difference...thxs 4 the suggestion tho missy
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

Permissions?

Postby winkphoto » Thu Jan 23, 2003 6:29 pm

Has the permissions for the .PL files been set to 755?

The error I got didn't refer to permissions, however, it seems to be looking for a file or directory that doesn't exist.

You also have a typo in the PL script:
This is just above the typo
Code: Select all
# $mode - string value containing 'EMAIL', 'FILE' or #
# 'BOTH' to determine if the script should send #
# an email to you with the new order, write the #
# order to a CSV file, or do both. #


Then, your variable is:
Code: Select all
$mode = "MAIL";


instead of EMAIL, FILE or BOTH.

Try changing that to see if it makes the script work.

Regards,

Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

Postby Stefko » Thu Jan 23, 2003 6:41 pm

Incorrect line feeds. Windows editors have the habit of inserting incompatible line feeds. Edit your script files with a Script editor, e.g.: PCE (Perl Code Editor - free download at http://www.perlvision.com), and convert windows linefeeds to Unix linefeeds

I have experienced CGIWrap errors until line ends were set to Unix

Hope that helps!!
KFL Technologies
Web-Enabled Solutions
e-Commerence Solutions
Stefko
Contributor / Guru
 
Posts: 833
Joined: Wed Sep 18, 2002 1:11 am
Location: Wichita, KS

I'll try that tooo and see

Postby JIMC » Thu Jan 23, 2003 6:43 pm

Hi Marc...thanks for responding

Well i've changed $mode to 'BOTH'....(grrr nothing has changed!)

Typo??? can't see it!

Yes it is CHMOD set to 755

Without seeing the 'typo' all remains the same

JIMC
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

The typo was

Postby winkphoto » Thu Jan 23, 2003 7:07 pm

The typo was usiing MAIL instead of EMAIL

Sorry that didn't help.

do you have the path to the sendmail program aas wwell as PERL correct from your service provider?

There will be logs that they can look at that may point you in the right direction. Possibly even giving you a line number from the log where the error occurred.

Regards,

Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

sendmail path!

Postby JIMC » Thu Jan 23, 2003 7:09 pm

um no I don't but will see if I can find out..ta
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

Postby Steven Nyland » Thu Jan 23, 2003 10:24 pm

[ If it ain't Dutch ... it ain't Much ]
Steven Nyland
Guru
 
Posts: 274
Joined: Thu Jan 02, 2003 1:20 pm
Location: Still here ...

:-)thanks for the link

Postby JIMC » Thu Jan 23, 2003 10:33 pm

Hi......I'm already running another .pl script for a different reason which is
#!/usr/bin/perl (which works ok) and I have the same line in 'checkout.pl' so unfortunately that doesn't seem to be the answer...um
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

Postby Steven Nyland » Thu Jan 23, 2003 10:37 pm

You honest;y have a typo somewhere. Seen it millions of times before and i also encounter the same probs every time. Have someone else read and compare the script!

Steven
[ If it ain't Dutch ... it ain't Much ]
Steven Nyland
Guru
 
Posts: 274
Joined: Thu Jan 02, 2003 1:20 pm
Location: Still here ...

:-( i'll take a scan

Postby JIMC » Thu Jan 23, 2003 10:40 pm

Well i'll take a thorough check through the script and see.
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

GRRRRRRRRRRRR

Postby JIMC » Fri Jan 24, 2003 5:46 pm

This is a copy of the 'checkout.pl' file (which does not work) in my cgi-bin and below that is a copy of another from processor .pl file that does work!
Can anyone see the reasons why or why not other than possibly the "/usr/lib/sendmail -t";

CHECKOUT.PL FILE:

#!/usr/bin/perl
#=====================================================================||
# NOP Design JavaScript Shopping Cart ||
# PERL CGI Checkout Module ||
# ||
# For more information on SmartSystems, or how NOPDesign can help you ||
# Please visit us on the WWW at http://www.nopdesign.com ||
# ||
# Javascript portions of this shopping cart software are available as ||
# freeware from NOP Design. You must keep this comment unchanged in ||
# your code. For more information contact FreeCart@NopDesign.com. ||
# ||
# JavaScript Shop Module, V.4.4.0 ||
#=====================================================================||
# ||
# Function: Writes available form elements from the NOP ||
# Free Cart (http://www.nopdesign.com/freecart) ||
# and other form elements to an email file, and ||
# send user confirmation ||
# ||
#=====================================================================||
require 5.001;

########################################################################
# #
# User defined variables: #
# $header - string value containing the complete #
# path of the HTML page header #
# $footer - string value containing the complete #
# path of the HTML page footer #
# $mailprogram - string value containing the complete path to #
# the sendmail binary on the system. #
# $youremail - string value containing the email address to #
# send catalog orders in EMAIL or BOTH modes #
# **Don't forget to put a \ before the @ in your #
# email address. ie. spam\@nopdesign.com*** #
# $returnpage - URL to send user when checkout is complete #
# $csvfilename - string value containing the complete #
# path of the user database. #
# $csvquote - string value containing what to use for quotes #
# in the csv file (typically "" or \") #
# $mode - string value containing 'EMAIL', 'FILE' or #
# 'BOTH' to determine if the script should send #
# an email to you with the new order, write the #
# order to a CSV file, or do both. #
########################################################################
$header = "header.html";
$footer = "footer.html";
$mailprogram = "/usr/lib/sendmail -t";
$returnpage = "/";
$youremail = "jim\@channell.co.uk";
$csvfilename = "orders.csv";
$csvquote = "\"\"";
$mode = "EMAIL";


#These are required fields. I recommend enforcing these by javascript,
#but let's just make sure here as well.
@required = (
'b_first',
'b_last',
'b_addr',
'b_city',
'b_county',
'b_postcode',
'b_phone',
'b_email',
'b_cardtype',
'b_cardname',
'b_cardnumber',
'b_expiry',
);

##############################################################
#FUNCTION: urlDecode #
#RETURNS: The decoded string. #
#PARAMETERS: An encoded string. #
#PURPOSE: Decodes a URL encoded string. #
##############################################################
sub urlDecode {
my ($string) = @_;
$string =~ tr/+/ /;
$string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg;
$string =~ s/['"]/\'/g;
return ($string);
}

##############################################################
#FUNCTION: processCGI #
#RETURNS: #
#PARAMETERS: #
#PURPOSE: Retrieves form data submitted via the 'GET' #
# method and decodes it. You may then access #
# the passed in variables via calls to $[name] #
# where [name] is the name of the form element. #
##############################################################
sub processCGI {
local ($cgiData, $key, $value, $pair, @pairs);

if ($ENV{'REQUEST_METHOD'} eq 'GET') { $cgiData = $ENV{'QUERY_STRING'}; }
else { $cgiData = <STDIN>; }
@pairs = split (/&/, $cgiData);
foreach $pair (@pairs) {
($key, $value) = split (/\=/, $pair);
$key = &urlDecode($key);
$value = &urlDecode($value);
if(defined ${$key}){
${$key} .= ", ".$value;
}else{
${$key} = $value;
}
}
}

##############################################################
#FUNCTION: doFormError #
#RETURNS: #
#PARAMETERS: A error message string. #
#PURPOSE: Generates an HTML page indicating a form #
# submission error occurred. #
##############################################################
sub doFormError {
my ($errString) = @_;

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;

print "Content-type: text/html\n\n";

print @LINES;

print "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
print "$errString<BR><BR>\n";
print "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;
print @LINES;

exit;
}

##############################################################
#FUNCTION: doError #
#RETURNS: #
#PARAMETERS: A error message string. #
#PURPOSE: Generates an HTML page indicating an error #
# occurred. #
##############################################################
sub doError {
my ($errString) = @_;
print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;

print @LINES;

print "$errString<BR><BR>\n";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;
print @LINES;

exit;
}

##############################################################
#FUNCTION: invalidE #
#RETURNS: 1 if invalid, 0 if valid. #
#PARAMETERS: An email address variable. #
#PURPOSE: Checks to see if a submitted email address is #
# of the valid form 'x@y'. #
##############################################################
sub invalidE {
my ($szEmail) = @_;
my ($user, $host);

$szEmail =~ tr/A-Z/a-z/;
if ($szEmail =~ /\s/) { return 1; }
($user, $host) = split (/\@/, $szEmail);
if ($host =~ /compuserve/i) { ; }
else {
if (! $user =~ /\D/) { return 1; }
if (! $host =~ /\D/) { return 1; }
if (substr ($user,0,1) !~ /[a-z]/) { return 1; }
}
if ($szEmail =~ /\w+\@[\w|\.]/) { return 0; }
else { return 1; }
}


sub populateDateVar {
@months = ();
push(@months,"January");
push(@months,"February");
push(@months,"March");
push(@months,"April");
push(@months,"May");
push(@months,"June");
push(@months,"July");
push(@months,"August");
push(@months,"September");
push(@months,"October");
push(@months,"November");
push(@months,"December");
@days = ();
push(@days,"Sunday");
push(@days,"Monday");
push(@days,"Tuesday");
push(@days,"Wednesday");
push(@days,"Thursday");
push(@days,"Friday");
push(@days,"Saturday");
($sec,$min,$hour,$day,$month,$year,$day2) =
(localtime(time))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($day < 10) { $day = "0$day"; }
$year += "1900";

#$todaysdate = "$months[$month] $day, $year $hour:$min:$sec";
}


##############################################################
##############################################################
### MAIN ###
##############################################################
##############################################################

# process the form input.
&processCGI;
&populateDateVar;

foreach $check(@required) {
unless ($check) {
doFormError("It appears that you forgot to fill in the <strong>$check</strong> field.");
exit;
}
}

# checks for valid email address
if( &invalidE($b_email) ){
doFormError('You submitted an invalid email address.');
}


if( $mode eq "BOTH" || $mode eq "EMAIL") {
# Send email order to you...
open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $b_email\n";
print MAIL "Subject: New Online Order\n";
print MAIL "\n\n";
print MAIL "A new order has been received. A summary of this order appears below.\n";
print MAIL "\n";
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
print MAIL " \n";
print MAIL "Bill To: \n";
print MAIL "-------- \n";
print MAIL " $b_first $b_last \n";
print MAIL " $b_addr \n";
print MAIL " $b_addr2 \n";
print MAIL " $b_city, $b_state $b_zip \n";
print MAIL " $b_phone \n";
print MAIL " $b_fax \n";
print MAIL " $b_email \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Ship To: \n";
print MAIL "-------- \n";
print MAIL " $s_first $s_last \n";
print MAIL " $s_addr \n";
print MAIL " $s_addr2 \n";
print MAIL " $s_city, $s_state $s_zip \n";
print MAIL " $s_phone \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Qty Price(\$) Product ID - Product Name\n";
print MAIL "===================================================================== \n";
print MAIL "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n";
if( $NAME_2 ) {print MAIL "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $NAME_3 ) {print MAIL "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";}
if( $NAME_4 ) {print MAIL "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";}
if( $NAME_5 ) {print MAIL "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";}
if( $NAME_6 ) {print MAIL "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";}
if( $NAME_7 ) {print MAIL "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";}
if( $NAME_8 ) {print MAIL "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";}
if( $NAME_9 ) {print MAIL "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";}
if( $NAME_10 ){print MAIL "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";}
if( $NAME_11 ){print MAIL "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";}
if( $NAME_12 ){print MAIL "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";}
if( $NAME_13 ){print MAIL "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";}
print MAIL "===================================================================== \n";
print MAIL "SUBTOTAL: $SUBTOTAL \n";
print MAIL "TOTAL: $TOTAL \n";
print MAIL "\n";
print MAIL "FREIGHT: $SHIPPING \n";
print MAIL "\n\n";
print MAIL "Comments: \n";
print MAIL "--------- \n";
print MAIL "$comment \n";
print MAIL " \n";
close MAIL;
}


if( $mode eq "BOTH" || $mode eq "FILE") {

$csvcomments = $comment;
#$csvcomments =~ s/\"/$csvquote/ig;

open (CSVF,">>$csvfilename");
print CSVF "\"";
print CSVF "$months[$month] $day, $year $hour:$min:$sec";
print CSVF "\",\"";
print CSVF "$b_first";
print CSVF "\",\"";
print CSVF "$b_last";
print CSVF "\",\"";
print CSVF "$b_addr";
print CSVF "\",\"";
print CSVF "$b_addr2";
print CSVF "\",\"";
print CSVF "$b_city";
print CSVF "\",\"";
print CSVF "$b_state";
print CSVF "\",\"";
print CSVF "$b_zip";
print CSVF "\",\"";
print CSVF "$b_phone";
print CSVF "\",\"";
print CSVF "$b_fax";
print CSVF "\",\"";
print CSVF "$b_email";
print CSVF "\",\"";
print CSVF "$s_first";
print CSVF "\",\"";
print CSVF "$s_last";
print CSVF "\",\"";
print CSVF "$s_addr";
print CSVF "\",\"";
print CSVF "$s_addr2";
print CSVF "\",\"";
print CSVF "$s_city";
print CSVF "\",\"";
print CSVF "$s_state";
print CSVF "\",\"";
print CSVF "$s_zip";
print CSVF "\",\"";
print CSVF "$s_phone";
print CSVF "\",\"";
print CSVF "$QUANTITY_1";
print CSVF "\",\"";
print CSVF "\$$PRICE_1";
print CSVF "\",\"";
print CSVF "$ID_1";
print CSVF "\",\"";
print CSVF "$NAME_1";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_1";
print CSVF "\",\"";
print CSVF "$QUANTITY_2";
print CSVF "\",\"";
print CSVF "\$$PRICE_2";
print CSVF "\",\"";
print CSVF "$ID_2";
print CSVF "\",\"";
print CSVF "$NAME_2";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_2";
print CSVF "\",\"";
print CSVF "$QUANTITY_3";
print CSVF "\",\"";
print CSVF "\$$PRICE_3";
print CSVF "\",\"";
print CSVF "$ID_3";
print CSVF "\",\"";
print CSVF "$NAME_3";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_3";
print CSVF "\",\"";
print CSVF "$QUANTITY_4";
print CSVF "\",\"";
print CSVF "\$$PRICE_4";
print CSVF "\",\"";
print CSVF "$ID_4";
print CSVF "\",\"";
print CSVF "$NAME_4";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_4";
print CSVF "\",\"";
print CSVF "$QUANTITY_5";
print CSVF "\",\"";
print CSVF "\$$PRICE_5";
print CSVF "\",\"";
print CSVF "$ID_5";
print CSVF "\",\"";
print CSVF "$NAME_5";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_5";
print CSVF "\",\"";
print CSVF "$QUANTITY_6";
print CSVF "\",\"";
print CSVF "\$$PRICE_6";
print CSVF "\",\"";
print CSVF "$ID_6";
print CSVF "\",\"";
print CSVF "$NAME_6";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_6";
print CSVF "\",\"";
print CSVF "$QUANTITY_7";
print CSVF "\",\"";
print CSVF "\$$PRICE_7";
print CSVF "\",\"";
print CSVF "$ID_7";
print CSVF "\",\"";
print CSVF "$NAME_7";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_7";
print CSVF "\",\"";
print CSVF "$QUANTITY_8";
print CSVF "\",\"";
print CSVF "\$$PRICE_8";
print CSVF "\",\"";
print CSVF "$ID_8";
print CSVF "\",\"";
print CSVF "$NAME_8";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_8";
print CSVF "\",\"";
print CSVF "$QUANTITY_9";
print CSVF "\",\"";
print CSVF "\$$PRICE_9";
print CSVF "\",\"";
print CSVF "$ID_9";
print CSVF "\",\"";
print CSVF "$NAME_9";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_9";
print CSVF "\",\"";
print CSVF "$QUANTITY_10";
print CSVF "\",\"";
print CSVF "\$$PRICE_10";
print CSVF "\",\"";
print CSVF "$ID_10";
print CSVF "\",\"";
print CSVF "$NAME_10";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_10";
print CSVF "\",\"";
print CSVF "$QUANTITY_11";
print CSVF "\",\"";
print CSVF "\$$PRICE_11";
print CSVF "\",\"";
print CSVF "$ID_11";
print CSVF "\",\"";
print CSVF "$NAME_11";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_11";
print CSVF "\",\"";
print CSVF "$QUANTITY_12";
print CSVF "\",\"";
print CSVF "\$$PRICE_12";
print CSVF "\",\"";
print CSVF "$ID_12";
print CSVF "\",\"";
print CSVF "$NAME_12";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_12";
print CSVF "\",\"";
print CSVF "$QUANTITY_13";
print CSVF "\",\"";
print CSVF "\$$PRICE_13";
print CSVF "\",\"";
print CSVF "$ID_13";
print CSVF "\",\"";
print CSVF "$NAME_13";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_13";
print CSVF "\",\"";
print CSVF "$SUBTOTAL";
print CSVF "\",\"";
print CSVF "$TOTAL";
print CSVF "\",\"";
print CSVF "$SHIPPING";
print CSVF "\",\"";
print CSVF "$comment";
print CSVF "\"\n";
close CSVF;
}



# Send email conformation to the customer.....
open (MAIL,"|$mailprogram");
print MAIL "To: $b_email\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: Order Confirmation\n";
print MAIL "\n\n";
print MAIL "A new order has been received. A summary of this order appears below.\n";
print MAIL "\n";
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
print MAIL " \n";
print MAIL "Bill To: \n";
print MAIL "-------- \n";
print MAIL " $b_first $b_last \n";
print MAIL " $b_addr \n";
print MAIL " $b_addr2 \n";
print MAIL " $b_city, $b_county $b_postcode \n";
print MAIL " $b_phone \n";
print MAIL " $b_fax \n";
print MAIL " $b_email \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Ship To: \n";
print MAIL "-------- \n";

if ( $s_addr eq "" ) {
print MAIL " Use Billing Address\n";
} else {
print MAIL " $s_first $s_last \n";
print MAIL " $s_addr \n";
print MAIL " $s_addr2 \n";
print MAIL " $s_city, $s_county $s_postcode \n";
print MAIL " $s_phone \n";
}

print MAIL " \n";
print MAIL " \n";
print MAIL "Qty Price(\$) Product ID - Product Name\n";
print MAIL "===================================================================== \n";
print MAIL "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n";
if( $NAME_2 ) {print MAIL "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $NAME_3 ) {print MAIL "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";}
if( $NAME_4 ) {print MAIL "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";}
if( $NAME_5 ) {print MAIL "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";}
if( $NAME_6 ) {print MAIL "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";}
if( $NAME_7 ) {print MAIL "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";}
if( $NAME_8 ) {print MAIL "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";}
if( $NAME_9 ) {print MAIL "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";}
if( $NAME_10 ){print MAIL "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";}
if( $NAME_11 ){print MAIL "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";}
if( $NAME_12 ){print MAIL "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";}
if( $NAME_13 ){print MAIL "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";}
print MAIL "===================================================================== \n";
print MAIL "SUBTOTAL: $SUBTOTAL \n";
print MAIL "TOTAL: $TOTAL \n";
print MAIL "\n";
print MAIL "FREIGHT: $SHIPPING \n";
print MAIL "\n\n";
print MAIL "Comments: \n";
print MAIL "--------- \n";
print MAIL "$comment \n";
print MAIL " \n";
close MAIL;


print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;
print @LINES;

print "<h2>Thank you</h2>";
print "Thank you for your Prostabeta order from our online store. You will receive a confirmation email of your order ";
print "momentarily. Please contact us at sales@gh3.co.uk if you have any questions or concerns.";
print "<P>";
print "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
print "<P>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;

print @LINES;

exit;


THE OTHER FORM PROCESSOR .PL (WHICH DOES WORK HA HA)

#!/usr/bin/perl
##############################################################################
# Form Processing: #
# Form to Mail Processor Pro Version 2.55 #
# Author and Developer: MitriDAT info@mitridat.com #
# http://www.mitridat.com #
# Created 10.10.2000 Last Modified 04.10.2001 #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 2000-2001, MitriDAT. All Rights Reserved. #
# #
# Please check the README folder for full details on installation #
# and registration. #
##############################################################################

##############################################################################
# Start Variables

$base_path ='../FP_Templates/';
$mail_cmd = '/usr/sbin/sendmail -t';
@Referers = ('www.ivisco.co.uk','ivisco.co.uk');
$content_type = "Content-Type: text/html\n\n";
#$mailserver = 'smtp.server';

# End Variable
##############################################################################

#*********************** DO NOT EDIT PAST THIS LINE *************************#

use Socket;

$error_loop = 0;
$browser_out = 0;

if ($ENV{'REQUEST_METHOD'} eq 'GET' and not $ENV{'QUERY_STRING'})
{
$ENV{'OUT_TITLE'} = "Form to Mail Processor - Form Processing Pro Script";
$ENV{'OUT_MSG'} = qq|The latest version of this script and the documentation is available
from <a href="http://www.mitridat.com">MitriDAT.|;
@msg = (<DATA>);
@msg = ParseText(@msg);
BrowserOut(@msg);
exit(0);
}
&CheckRef;
&ParseForm;

if ($FORM{'GMT_OFFSET'}) {$FORM{'GMT_OFFSET'} = $FORM{'GMT_OFFSET'};}
else {$FORM{'GMT_OFFSET'}=0;}
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time + $FORM{'GMT_OFFSET'}*3600);
$year += 1900;
if ($hour <= 9) {$hour = '0'.$hour};
if ($min <= 9) {$min = '0'.$min};
if ($sec <= 9) {$sec = '0'.$sec};
if ($mday <= 9) {$mday = '0'.$mday};
if ($mon <= 9) {$mon = '0'.$mon};
$ENV{'DATE_GMT'} = "$hour:$min:$sec $mday\/$mon\/$year GMT$FORM{'GMT_OFFSET'}";

if (@missing_values or @bad_emails or @only_digits or @only_words) { Error('evil values') }

foreach $key (keys %FORM)
{
if ($key =~ /^_send_email/)
{
@lines = ReadFile('Email Template',$FORM{$key});
@lines = ParseText(@lines);
if ($mailserver ne '')
{SendMailBySmtp(@lines);}
else {SendMail(@lines);}
}
elsif ($key =~ /^_out_file/)
{
@lines = ReadFile('Log File',$FORM{$key});
@lines = ParseText(@lines);
LogFile('LogFile Template',@lines);
}
elsif ($key =~ /^_browser_out/ and $browser_out < 2)
{
$browser_out++;
@lines = ReadFile('Browser Template',$FORM{$key});
@lines = ParseText(@lines);
BrowserOut(@lines);
}
elsif ($key =~ /^_redirect/ and $browser_out < 2)
{
$browser_out++;
print "Location: $FORM{$key}\n\n";
}
}

unless ($browser_out)
{
@msg = (<DATA>);
$ENV{'OUT_TITLE'} = "Success";
$ENV{'OUT_MSG'} = "Your enquiry has been delivered. Thank you.";
@msg = ParseText(@msg);
BrowserOut(@msg);
}

exit(0);

sub BrowserOut
{ print "$content_type@_\n" }

sub CheckRef
{
my ($valid_referer, @terms);
if ((@Referers) and ($ENV{'HTTP_REFERER'}))
{
foreach $referer (@Referers)
{
if ($ENV{'HTTP_REFERER'} =~ m|http.*?://$referer|i)
{
$valid_referer++;
last;
}
}
}
else {$valid_referer++;}
unless ($valid_referer)
{
@terms = split(/\//,$ENV{'HTTP_REFERER'});
Error
(
'Bad Referer',
"'$ENV{'HTTP_REFERER'}' is not authorised to use this script. If you want them to be able to,
you should add '$terms[2]' to the referer list."
);
}
}

sub Error
{
++$error_loop;
my $title = shift @_;
my $msg = shift @_;
my @error;

if ($title eq 'evil values')
{
my $val;
if (@missing_values)
{
$msg = qq|<p>The following field(s) are required:</p>\n<table border=0><tr><td><ol>\n|;
foreach $val (@missing_values) { $msg .= "<li>$val\n" }
$msg .= "</ol></td></tr></table>\n";
}
if (@bad_emails)
{
$msg .= qq|<p>The following field(s) require a valid email address:</p>\n<table border=0><tr><td><ol>\n|;
foreach $val (@bad_emails) { $msg .= "<li>$val\n" }
$msg .= "</ol></td></tr></table>\n";
}
if (@only_digits)
{
$msg .= qq|<p>The following field(s) require digits (0-9) only:</p>\n<table border=0><tr><td><ol>\n|;
foreach $val (@only_digits) { $msg .= "<li>$val\n" }
$msg .= "</ol></td></tr></table>\n";
}
if (@only_words)
{
$msg .= qq|<p>The following field(s) require letters (A-Z, 0-9) only:</p>\n<ol type="i">\n|;
foreach $val (@only_words) { $msg .= "<li>$val\n" }
$msg .= "</ol>\n";
}
$title = 'Error - Please check below';
$msg .= qq|<p>Please go back and fill in the fields accordingly.</p>\n|;
}
if ($FORM{'_error_url'}) { print "Location: $FORM{'_error_url'}\n\n" }
elsif ($FORM{'_error_path'} and $error_loop < 2)
{
$ENV{'OUT_TITLE'} = $title;
$ENV{'OUT_MSG'} = $msg;
@error = ReadFile('Error Template',$FORM{'_error_path'});
@error = ParseText(@error);
BrowserOut(@error);
}
else
{
@error = (<DATA>);
$ENV{'OUT_TITLE'} = $title;
$ENV{'OUT_MSG'} = $msg;
@error = ParseText(@error);
BrowserOut(@error);
}
exit(0);
}

sub LogFile
{
my $msg = shift @_;
my $file = shift @_;
$file =~ s#\.\./##g;
$file =~ s/[^\w-\.]//g;
$file = $base_path . $file;
open(FILE,">>$file") or Error('File Access Error',"An error occurred when trying to append to the $msg ($file): $!");
flock(FILE,2) or Error('File Lock Error',"An error occured when locking the $msg ($file): $!.");
print FILE @_;
close(FILE) or Error('File Close Error',"An error occurred when close the $msg ($file): $!.");
}

sub ReadFile
{
my $msg = shift @_;
my $file = shift @_;
$file =~ s#\.\./##g;
$file =~ s/[^\w-\.]//g;
$file = $base_path . $file;
open(FILE, "$file") or Error('File Access Error',"An error occurred when opening the $msg ($file): $!.");
my @lines = (<FILE>);
close(FILE) or Error('File Close Error',"An error occurred when close the $msg ($file): $!.");
return @lines;
}

sub ParseForm
{
my ($key, $prefs, $buffer);
if ($ENV{'REQUEST_METHOD'} eq 'GET')
{ @pairs = split(/&/, $ENV{'QUERY_STRING'}) }
elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer)
}
else {Error('Bad or Unknown Request Method',
"The form's request method must be either 'POST' or 'GET'. Please check your FORM.")}

foreach $pair (@pairs)
{
local($name, $value) = split(/=/, $pair);
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.)*?-->//mg;
$FORM{$name} = $value;
if ($name =~ /_/ and $name !~ /^_/)
{
($prefs, $key) = split /_/, $name, 2;
if ($prefs =~ /r/i and not $value) { push @missing_values, $key }
if ($prefs =~ /e/i and $value and
(($value =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/) or
($value !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/)))
{ push @bad_emails, $key }
if ($prefs =~ /d/i and $value and $value =~ /\D/) { push @only_digits, $key }
if ($prefs =~ /w/i and $value and $value =~ /\W/) { push @only_words, $key }
if ($prefs =~ /s/i and $value) { $value =~ s/^(\s)*//;
$value =~ s/(\s)*$//;
$FORM{$name} = $value; }
}


}
}

sub ParseText
{
my ($line, $key, $value, $sub);
foreach $line (@_)
{
while (($key => $value) = each %FORM)
{ $line =~ s/\[$key\]/$value/ig }
while (($key => $value) = each %ENV)
{ $line =~ s/\[\%$key\]/$value/ig }
$line =~ s/\[[^<](.)*?[^>]\]//g;
}
foreach $line (@_)
{
while ($line =~ /\[<((.)*?)>\]/)
{
$sub = $1;
$sub =~ s/[^\d\+\*\/\-%\.x<>\(\)]//g;
$sub = eval $sub;
$line =~ s/\[<(.)*?>\]/$sub/
}
}
return @_;
}

sub sendmessage
{
local($From, $To, $Subject, $Message) = @_;
local($remotehost, $port) = ($mailserver, 25);
local($proto, $port);
local($error_title) = "Can't send the message.";
$proto = getprotobyname('tcp');
$port=25;

$test = $From;
$test =~ s/<//g;

if (length($test) ne length($From))
{
$fm = $From;
@f = split(/</,$fm);
$f[1] =~ tr/>//d;
$FromName = $f[0];
$From = $f[1];
}
else
{
$FromName = '';
}
socket(S, AF_INET, SOCK_STREAM, $proto) || Error($error_title,"error 1\n");
$sin = sockaddr_in( $port, inet_aton( $remotehost ));
connect(S, $sin) || Error($error_title,"error 3\n");

select(S);
$| = 1;
select(STDOUT);


$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "220") {Error($error_title,"Connect: $l");}
print S "helo $mailserver\r\n";
$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "250") {Error($error_title,"helo: $l");}
print S "mail from: $From\r\n";
$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "250") {Error($error_title,"mail: $l");}
print S "rcpt to: $To\r\n";
$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "250") {Error($error_title,"rcpt: $l");}
print S "data\r\n";
$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "354") {Error($error_title,"data begin: $l");}
print S "Subject: $Subject\r\n";
print S "From: $FromName <$From>\r\n";
print S "To: $To\r\n";
print S "Content-type: text\/plain\r\n";
print S "\r\n";
print S "$Message\r\n";
print S "\r\n.\r\n";
$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "250") {Error($error_title,"data end: $l");}
print S "quit\r\n";
$l = <S>;#print "$l<br>\n";
if (substr($l,0,3) ne "221") {Error($error_title,"quit: $l");}
close(S);
}

sub SendMailBySmtp {

@lsmtp = @_;

$msg_count=0;
foreach $z (@lsmtp)
{$x = substr($z,0,3);
if (uc($x) eq 'TO:'){$msg_count++}}

while ($msg_count != 0)
{
$t = shift @lsmtp;
@to = split(/:/, $t);
$tos = shift @to;
$to = $to[0];
$to =~ tr/ //d;

$af = shift @lsmtp;
@fro = split(/:/, $af);
shift @fro;
$from = $fro[0];

$s = shift @lsmtp;
@subject = split(/:/, $s);
$suj = shift @subject;
$subject = @subject[0];

$lco = @lsmtp;
for ($i=0;$i<$lco;$i++)
{$z = $lsmtp[0];
if (length($z) > 2){last;}
else{$m = shift @lsmtp;}}
$l_msg = "";
$lco = @lsmtp;
for ($i=0;$i<$lco;$i++)
{
$z = $lsmtp[0];
$x = substr($z,0,3);
if (uc($x) eq 'TO:'){last;}
else{$m = shift @lsmtp; $l_msg = "$l_msg$z";}
}
$message = "$l_msg\n";

chomp($from);
chomp($to);
chomp($subject);
sendmessage($from, $to, $subject, $message);

$msg_count--;}
}

sub SendMail
{
if ($mail_cmd ne "") {
open(MAIL,"|$mail_cmd") or Error('Mailer Open Error',"An error occurred when trying to open the mailer ($mail_cmd): $!.");
print MAIL @_;
close(MAIL) or Error('Mail Send Error',"An error occurred when sending the email: $?. Please check the email's headers.");
}
}

__END__

<html>
<head>
<title>[%OUT_TITLE]</title>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="navy" vlink="navy" alink="red"
style="font-family: verdana, arial, sans-serif; font-size: 8;">
<center>

<table border="0" cellpadding="0" cellspacing="0" width="500"
style="font-family: verdana font-size: 12;">
<tr>
<td><h2 align="center">[%OUT_TITLE]</h2>
<p align="center">[%OUT_MSG]</p>
<p align="center"><a href="http://">Form Processo</a><br>
&copy; 2000 <a href="http://">MitriDAT</a></td>
</tr>
</table>
</center>
</body>
</html>
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

Here is what I see:

Postby winkphoto » Fri Jan 24, 2003 5:57 pm

Here is what I see:

This is the location you specify for your sendmail program in checkout.pl
Code: Select all
$mailprogram = "/usr/lib/sendmail -t";

The one from your form mail script:

Code: Select all
$mail_cmd = '/usr/sbin/sendmail -t';


Try modifying the line in checkout.pl to be:
Code: Select all
$mailprogram = "/usr/sbin/sendmail -t";


More than likely, when the script tries to go to the sendmail program, it's choking because it can't find it.

Regards,

Marc
winkphoto
Guru
 
Posts: 176
Joined: Fri Nov 15, 2002 9:21 pm
Location: Nashua, NH

Hi Marc

Postby JIMC » Fri Jan 24, 2003 6:04 pm

I just tried that in another cg-bin with only that .pl file with the change to:
$mailprogram = "/usr/sbin/sendmail -t";
and still no joy...any other suggestions gratfully recieved!
JIMC
 
Posts: 35
Joined: Mon Jan 20, 2003 5:50 pm
Location: UK

Next

Return to Installation and Setup Problems

Who is online

Users browsing this forum: No registered users and 0 guests

cron