#!/usr/bin/perl -T ####################################################################################### # # # HTML-CART # # http://www.html-cart.com # # # # Copyright 2008 Internet Express Products # # # # Version: 3.0.1 Last Modified 04/08/2008 # # # ####################################################################################### # License # ####################################################################################### # # # This software is offered as freeware. # # Permission to use, copy and distribute this software and its documentation is # # hereby granted, with the following restrictions: # # # # You may only distribute this software FREE OF CHARGE, and all copies of the # # distributed package should contain all the UNMODIFIED files that are in the # # original distribution # # # # You are allowed to modify this software in any way you would like, but you may NOT # # distribute the modified code. Modifications are to be distributed as patches to # # the released version, or supplied to the copyright holder to include in the # # original. # # # # You are not allowed to use this software or any part of it for creating another # # program. # # # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND # # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # # IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # # POSSIBILITY OF SUCH DAMAGE. # # # ####################################################################################### BEGIN { open (STDERR, ">html-cart.err");} use CGI qw(:standard); use CGI::Carp qw/fatalsToBrowser/; # configuration variables our ($error, $page); our ($gateway_url, $store_name, $encrypt_key, $taxable_state, $taxable_rate); our ($default_country, @credit_cards, $admin_email, $html_prd_pages, $template_file); our ($secure_url, $secure_order_url, $domain_name_for_cookie, $path_for_cookie, $currency_symbol); our ($BillTo_Zip_error, $ShipTo_Zip_error, $Payment_Card_Type_error, $Payment_Card_Exp_Year_error); our ($BillTo_Name_error, $ShipTo_State_error, $Fax_Number_error, $BillTo_State_error); our ($ShipTo_City_error, $Payment_Card_Exp_Month_error, $ShipTo_Country_error, $Payment_Card_Number_error); our ($Phone_Number_error, $ShipTo_Name_error, $BillTo_City_error, $BillTo_Country_error); our ($ShipTo_Street_Line1_error, $BillTo_Street_Line1_error, $Payment_Card_Id_error); ####################################################################################### # Variables ####################################################################################### require "./admin/config.pl" || die "Can't require ./admin/config.pl"; require "./admin/encode.pl" || die "Can't require ./admin/encode.pl"; $ENV{"PATH"} = ""; our $flags = "-t"; $mailer = '/usr/lib/sendmail'; $mailer1 = '/usr/bin/sendmail'; $mailer2 = '/usr/sbin/sendmail'; if ( -e $mailer) { $mail_program=$mailer; } elsif( -e $mailer1){ $mail_program=$mailer1; } elsif( -e $mailer2){ $mail_program=$mailer2; } else { print "Content-type: text/html\n\n"; print "I can't find sendmail, shutting down...
"; print "Whoever set this machine up put it someplace weird."; exit; } our $mail_program = "$mail_program $flags "; &GetCookies; if ($cookie{'IP'}) { $REMOTE_ADDRESS = $cookie{'IP'}; $REMOTE_ADDRESS =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/; $REMOTE_ADDRESS = "$1.$2.$3.$4"; } else { $REMOTE_ADDRESS = $ENV{'REMOTE_ADDR'}; $REMOTE_ADDRESS =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/; $REMOTE_ADDRESS = "$1.$2.$3.$4"; $cookie{'IP'} = $REMOTE_ADDRESS; &SetCookies; } $shopping_cart = "./shopping_carts/$REMOTE_ADDRESS"; %sc_order_form_array = ('BillTo_Name', 'Name', 'BillTo_Street_Line1', 'Billing Address Street', 'BillTo_City', 'Billing Address City', 'BillTo_State', 'Billing Address State', 'BillTo_Zip', 'Billing Address Zip', 'BillTo_Country', 'Billing Address Country', 'ShipTo_Name', 'Ship To Name', 'ShipTo_Street_Line1', 'Shipping Address Street', 'ShipTo_City', 'Shipping Address City', 'ShipTo_State', 'Shipping Address State', 'ShipTo_Zip', 'Shipping Address Zip', 'ShipTo_Country', 'Shipping Address Country', 'Phone_Number', 'Phone Number', 'Email_Address', 'Email', 'Payment_Card_Type', 'Type of Card', 'Payment_Card_Number', 'Card Number', 'Payment_Card_Id', 'Card Id', 'Payment_Card_Exp_Month', 'Card Expiration Month', 'Payment_Card_Exp_Year', 'Card Expiration Year'); @sc_order_form_required_fields = ("BillTo_Name", "BillTo_Street_Line1", "BillTo_City", "BillTo_State", "BillTo_Zip", "BillTo_Country", "Phone_Number", "Email_Address", "Payment_Card_Type", "Payment_Card_Number", "Payment_Card_Id", "Payment_Card_Exp_Month", "Payment_Card_Exp_Year"); ####################################################################################### $query = new CGI; foreach $sparam ($query->param()) { $form_data{$sparam} = $query->param($sparam); } require "./admin/$gateway-gateway.pl" || die "Can't require ./admin/$gateway-gateway.pl"; &clear_old_carts; if ($form_data{'continue_shopping'}) { print "Location: $html_prd_pages\/$form_data{'page'}\n\n"; exit; } if ($form_data{'order'} || $form_data{'order.x'}) { $error = &add_to_cart; unless ($error) { my ($subtotal, $sales_tax, $shipping_total, $grandtotal, $cartpage) = &display_cart; $page .= $cartpage; } } elsif ($form_data{'display_cart'}) { my ($subtotal, $sales_tax, $shipping_total, $grandtotal, $cartpage) = &display_cart; $page .= $cartpage; } elsif ($form_data{'order_form'}) { $page .= &diplay_order_form; } elsif ($form_data{'confirm_order'}) { $page .= &confirm_order; } elsif ($form_data{"$process_variable"}) { $error = &process_order; unless ($error) { $page .= &thank_you_page; } } elsif ($form_data{'delete_line'}) { &delete_line; my ($subtotal, $sales_tax, $shipping_total, $grandtotal, $cartpage) = &display_cart; $page .= $cartpage; } elsif ($form_data{'clear_cart'}) { unlink $shopping_cart; my ($subtotal, $sales_tax, $shipping_total, $grandtotal, $cartpage) = &display_cart; $page .= $cartpage; } elsif ($form_data{'update_changes'}) { &update_changes; my ($subtotal, $sales_tax, $shipping_total, $grandtotal, $cartpage) = &display_cart; $page .= $cartpage; } else { $page .= "INVALID COMMAND!"; } print "Content-type: text/html\n\n"; open (TEMPLATE, "$template_file") || print "Cant open $template_file
\n"; while (