#!/usr/bin/perl # ^^ The line above needs to point to the Perl intrepreter on your system. # Ask your sys admin for the correct path, or type 'which perl' at the unix # prompt. You need Perl 5 or higher. type 'perl -v' to get your version. ############################################################################ ################## # RediCart v3.9.5 ################## ############################################################################### # THIS SCRIPT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER # EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. # # THE PROVIDERS OF THIS SOFTWARE ASSUME NO RESPONSIBILITY FOR ANY DAMAGES # SUFFERED AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE. IN NO # EVENT WILL ANY PROVIDERS OF THIS SOFTWARE BE LIABLE FOR ANY LOST REVENUE, PROFIT # OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE # DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, # ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF THE # PROVIDERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ############################################################################## ############################################################################ # AUTHOR INFORMATION ############################################################################ # S-Mart Shopping Cart Script v1.9 # Shop smart. Shop S-Mart. # Written by Barry Robison. (brobison@rcinet.com) # This script uses code written by Matt Wright. # Please visit his site at http://worldwidemart.com # Selling the code for this program without prior written consent of the # author(s) is expressly forbidden. Obtain permission before # redistributing this software over the Internet or in any other medium. # In all cases copyright and header must remain intact. # # All customization requests to be sent to brobinson@rcinet.com. ############################################################################ ############################################################################ # MAKE NO CHANGES BELOW THIS LINE. ############################################################################ $ENV{'REMOTE_HOST'} = $ENV{'REMOTE_ADDR'}; # Measure CPU time usage; $start = (times)[0]; # Get rid of NULL; $zero - '0'; require 'smart.cfg'; use vars qw($tmpdir $storename %shipping2 %shipping3 $trackurl $useverify $usertime $orderdir $usercurr $trackdb); my($incoming, @pairs, %FORM); $incoming = $ENV{'QUERY_STRING'}; @pairs = split(/&/, $incoming); foreach $pair (@pairs) { my($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } # Get command variables $command = $FORM{'command'}; $pos = $FORM{'pos'}; $type = $FORM{'type'}; $cmdlinegroup = $FORM{'group'}; # Parse form input &parse_form; # Get the date &get_date; # Get their hostname #if ($usecookie eq '1') { #require 'cookie.lib'; #&get_cookie; #} #else { &get_host; #} # See if they have a cart already, if not, make one &check_file; # See what they want to do. # Add an item to the cart. if ($command eq 'add') { &add_item; } # Change a quantity of an item in the cart, if at zero, delete it elsif ($command eq 'change') { &change_items; } # Show the order form. Get their name, phone number, CC info, etc.. elsif ($command eq 'buy1') { &buy_items1; } # Process the order form info, mail out receipt, and order elsif ($command eq 'buy2') { &buy_items1; } # Show current cart elsif ($command eq 'review') { &review_items; } # List items, based on database call elsif ($command eq 'listitems') { &gen_page; } # Show a databae frontend. elsif ($command eq 'showstore') { &show_store; } # Delete a whole cart elsif ($command eq 'delete') { &delete_cart; } # Calculate shipping elsif ($command eq 'calcship') { &calc_shipping; } elsif ($command eq 'setship') { &set_shipping; } elsif ($command eq 'removetax') { &remove_tax; } elsif ($command eq 'addtax') { &add_tax; } elsif ($command eq 'removetax2') { &remove_tax2; } elsif ($command eq 'addtax2') { &add_tax2; } elsif ($command eq 'retaddr') { &ret_addr; } elsif ($command eq 'calccurr') { &calc_currency; } elsif ($command eq 'setcurr') { &set_currency; } else { &show_store; } # Subroutines: # Generate page, based on database search sub gen_page { my($SIZE,$max,$i,$itemid,$name,$price,$descrip,$image,$weight,$itemurl,$group); &print_header; # Table header, change this for table options! print "
\n"; print "\n"; open (FILE,"$resourcedb") || die "Content-type: text/html\n\nCan't Open $resourcedb(r): $!\n"; my(@LINES)=; close(FILE); $SIZE=@LINES; if ($type eq 'all') { $max = $pos + $numtolist; if ($max > $SIZE) { $max = $SIZE; } for ($i=$pos;$i<$max;$i++) { $_=$LINES[$i]; ($itemid, $name, $price, $descrip, $image, $weight, $itemurl, $group) = split(/\|/,$_); &print_item; } print "
\n"; if ($max < $SIZE) { print "
Next $numtolist items
\n"; } } if ($type eq 'search') { my($matches) = 0; my($i) = $pos; while (($matches < $numtolist) && ($i < $SIZE)) { $_=$LINES[$i]; if (m/$FORM{'search'}/i) { $matches++; ($itemid, $name, $price, $descrip, $image, $weight, $itemurl, $group) = split(/\|/,$_); &print_item; } $i++; } print "\n"; if ($i < $SIZE) { print "
\n"; print "\n"; print "\n"; print "
\n"; } } if ($type eq 'group') { my($matches) = 0; my($i) = $pos; while (($matches < $numtolist) && ($i < $SIZE)) { $_=$LINES[$i]; ($itemid, $name, $price, $descrip, $image, $weight, $itemurl, $group) = split(/\|/,$_); if ($group eq $FORM{'group'} || $group eq $cmdlinegroup) { $matches++; &print_item; } $i++; } print "\n"; if ($i < $SIZE) { if ($cmdlinegroup) { print "Continue Search\n"; } else { print "Continue Search\n"; } } } &print_footer; sub print_item { print "
\n"; # Hide the weight for later use print "\n"; print "\n"; # If you want to redirect, keep this in! if ($useredirect eq '1') { print "\n"; } # For showing product images if ($image) { print "\n"; } else { print "\n"; } # If the item has a URL, make it a link if ($itemurl) { print "$name\n"; } else { print "$name\n"; } # Print other info #Price print "\$ $price\n"; #Quantity print "\n"; #Add button print "\n"; #Description print "$descrip\n"; # Close print "
\n"; } ## END print_item } ## END gen_page # Show front end of database store. sub show_store { &print_header; print "
\n"; print "
\n"; print "List all items available
\n
\n
Search for a particular item(s):
\n"; print "\n
List all:
\n"; print "
\n
"; if ($usetrack eq 1) { print "
Track an Order
\n"; } print "
\n"; &print_footer; } ## END show_store # Print the HTML header sub print_header { print "Content-type: text/html\n\n"; open (HEADER,"$basepath/$header") || print "Could not open $basepath/$header $! \n"; while (
) { print $_; } close(HEADER); } #Print the HTML footer sub print_footer { open (FOOTER,"$basepath/$footer") || print "Could not open $basepath/$footer $! \n"; while (