#!/usr/bin/perl # Change LINE 1 to point to your server's Perl5. # Variables used by all scripts: /Web_store/ws_global.setup # Variables specific to ws_400CS.cgi: /Databases/outlet.setup # File Permissions: 755 -rwxr-xr-x # NOTE: If you change the filename "outlet.setup", change the value # of $default_setup_file below to reflect the file's new name. ############################################################################ # ws400CS.cgi - VERSION: 4.14.02 CS - Frames Support # ############################################################################ # Copyright (c) 1996 - 2001, RDC Software # Full copyright notice can be found in the following files for the # listed license type: # Single User License: /Docs/Copyright_SingleUser.html # Server License: /Docs/Copyright_Server.html # Created: 07/30/96 Last Modified: 05/13/2001 # WebStore@cgiCentral.net http://www.cgiCentral.net # RDC Software, Route 3, Box 29B, Grapeland, TX 75844, USA # This copyright notification can not be altered or removed from this file. #==========================================================================# # ws400CS.cgi is a perl script for UNIX systems which allows # you to sell merchandise over the Internet via web browsers. # If your domain has a specific directory configured for perl scripts, such # as cgi-bin, place all .cgi files and ws_global.setup in the cgi-bin # directory, otherwise, the .cgi files and ws_global.setup may be left in # the /Web_store directory or placed in a directory of your choosing. # The /Web_store directory and all sub-directories must be placed in a # directory which can parse HTML files and output graphic files to the # http daemon. # The directory which is accessed with the URL http://www.YourDomain.xxx # or any sub-directory under this directory is normally the correct location # for the /Web_store directory structure. # Perl scripts can not be placed in any directory assigned to MS Frontpage. #==========================================================================# # BUTTOM IMAGE TYPES IN WEBSTORE # # For details on in WebStore (and where to place them), # # SEARCH FOR: **Buttom Images in WebStore** ############################################################################ # DEFINE VARIABLES # $default_setup_file is the setup file used if the URL pointing to # ws400CS.cgi does not contain a name=value pair for 'store' in the # query string: ws400CS.cgi?store=outlet $default_setup_file = 'outlet.setup'; # If you change the filename of the global setup file, # change: 'ws_global.setup' &file_status(__FILE__, __LINE__, 'req', './ws_global.setup'); # $main_script_url is the absolute NON SECURE URL for ws400CS.cgi. # This script uses $main_script_url for all processes until the # client goes to the order form. # If the client's web browser is not capable of SSL transmissions, # $main_script_url is used to construct the
used on # the order form. # If you change the filename of this script, change 'ws400CS.cgi' $main_script_url .= '/'.'ws400CS.cgi'; # $ssl_url is the absolute SECURE URL for ws400CS.cgi. # If $use_ssl=1, and the client's web browser is capable of SSL # transmissions, this script will use $ssl_url to construct the # used on the order form. # If you are not using SSL, set $ssl_url equal to $main_script_url. # If you change the filename of this script, change 'ws400CS.cgi' $ssl_url .= '/'.'ws400CS.cgi'; # End DEFINE VARIABLES ############################################################################ $version = '4.14.02'; $|=1; # Enable command buffering - force fflush(3) after every print if (defined($ENV{'REQUEST_METHOD'})) { %in = &ReadParse } # Eliminate perl warning: Use of uninitialized value else { foreach ('category','chkClientAccess','frames','getClientForm','mdyClientRecord','page','pcat','pwd','uid') { $in{$_} = '' } } if ($in{'store'}) { $store = $in{'store'} } else { $store = $default_setup_file } # Accept filename without .setup extension $store .= '.setup' if $store !~ /\.setup$/; &file_status(__FILE__, __LINE__, 'req', $data_directory.'/'.$store, $libr_directory.'/'.'WSLib.pl', ); $script_url = $main_script_url; if ($password_file) { $real_clnt_dir = $clnt_directory; $clnt_directory = $rstr_directory; $real_cart_dir = $cart_directory; $cart_directory = $rcrt_directory; $client_file = $password_file; if ($in{'getClientForm'}) { $in{'mdyClientRecord'} = 'Y'; $in{'getClientForm'} = ''; } } else { $real_cart_dir = $real_clnt_dir = $def_username = $def_password = '' } # Demo mode if (defined($demo) && ($demo || defined($in{'demo'}))) { if ($demo_form_file) { foreach (reverse sort keys %form_files) { push(@{ $form_files{$_+1} },($demo_form_file,'Demonstration Order Form')); last; } } if ($demo) { $in{'demo'} = $demo = 'Y' } else { $in{'demo'} = $demo = '1' } } else { $demo = '' } if (defined($in{'form_file'}) && $in{'form_file'}) { $a = $in{'formfile'} = $in{'form_file'}; } elsif ((defined($in{'formfile'}) && $in{'formfile'})) { $a = $in{'formfile'} } else { foreach (sort keys %form_files) { $a = $in{'formfile'} = $_; last; } } $form_file = $form_files{$a}[0]; undef $a; $form_file =~ s/\s+//g; if (scalar(keys %form_files) > 1) { $form_files = 'Y' } else { $form_files = '' } # Accept filenames without .setup extension foreach ($client_file,$country_file,$default_setup_file,$form_file,$pre_form_file,$reseller_file) { $_ .= '.setup' if $_ ne '' && $_ !~ /\.setup$/ } # Common font and color attributes $data_font = '2' if !$data_font || $data_font !~ /^\d+$/; $header_font = '3' if !$header_font || $header_font !~ /^\d+$/; $dt_font = $data_font; $data_font = qq!SIZE="$data_font"!; $header_font = qq!SIZE="$header_font"!; $data_face = qq! FACE="$data_face"! if $data_face ne ''; $header_face = qq! FACE="$header_face"! if $header_face ne ''; $border_bkg_clr = qq! BGCOLOR="$border_bkg_clr"! if $border_bkg_clr ne ''; $data_bkg_clr = qq! BGCOLOR="$data_bkg_clr"! if $data_bkg_clr ne ''; $dsc_hr_bkg_clr = qq! BGCOLOR="$dsc_hr_bkg_clr"! if $dsc_hr_bkg_clr ne ''; $header_bkg_clr = qq! BGCOLOR="$header_bkg_clr"! if $header_bkg_clr ne ''; $modify_bkg_clr = qq! BGCOLOR="$modify_bkg_clr"! if $modify_bkg_clr ne ''; $data_fnt_clr = qq! COLOR="$data_fnt_clr"! if $data_fnt_clr ne ''; $dsc_hr_fnt_clr = qq! COLOR="$dsc_hr_fnt_clr"! if $dsc_hr_fnt_clr ne ''; $header_fnt_clr = qq! COLOR="$header_fnt_clr"! if $header_fnt_clr ne ''; $modify_fnt_clr = qq! COLOR="$modify_fnt_clr"! if $modify_fnt_clr ne ''; $dh_fnt_tag = ""; $dt_fnt_tag = ""; $hr_fnt_tag = ""; $hrd_fnt_tag = ""; $md_fnt_tag = ""; $nc_fnt_tag = ""; $smdt_fnt_tag = ""; $error_bkg_clr = ' BGCOLOR="#000000"'; $error_fnt_clr = ' COLOR="#FFFF00"'; $error_fnt_tag = ""; $search_border = $table_border; $SPACE = ' '; $table_open = ""; $c_col_spc = ""; $ch_col_spc = ""; $m_col_spc = ""; $mh_col_spc = ""; # Absolute addressing $data_file1 = $data_file; $data_file = $data_directory.'/'.$data_file; $count_file = $stat_directory.'/'.$count_file if $count_file; # Access counter # Client order form files if ($client_file) { $access_attempts = '3' if $access_attempts < 2 || $access_attempts > 10 } else { $client_delete_age = $in{'pwd'} = $in{'uid'} = $in{'client_form'} = '' } # Browser type $browser = $ENV{'HTTP_USER_AGENT'}; $in{'no_search'} = $in{'ns'} = $in{'submit_search'} = '' if !$search_engine; if ($frameset_file) { $target = ' TARGET="_top"' } else { $target = '' } &dbase_error if @duplicate_ids; # Currency if (defined($currency)) { $currency =~ s/\s{2,}/ /g; $currency =~ s/^\s+|\s+$//g; } else { $currency = '' } $currency = '$' if $currency !~ /\S+/; $currency .= ' ' if length($currency) > 1; # Buy Item - View Item $in{'buy_item'} = $in{'view_item'} = '' if $item_fld_num !~ /^\d+$/; if ($in{'cart_id'}) { $cart_id = $in{'cart_id'}; $user_cart = $cart_directory.'/'.$cart_id.'.cart'; $processed_cart = $cart_directory.'/'.'PROC-'.$cart_id.'.cart'; if ($in{'nc'} eq $cart_id && $in{'frames'} eq 'main') { my ($a); delete $in{'nc'}; delete $in{'frames'}; $del_carts = 'Y'; if ($in{'nc_category'}) { $in{'category'} = $in{'nc_category'}; delete $in{'nc_category'}; } elsif (!$in{'nc_add_cart'} && $in{'nc_page'}) { $in{'category'} = $in{'nc_page'}; delete $in{'nc_page'}; } foreach (sort keys %in) { if ($_ =~ /^nc_/) { $a = $_; $a =~ s/^nc_//; $in{$a} = $in{$_}; delete $in{$_}; } } } $frame_access = 'N'; &reseller; # Expired or client modified cart &error('E') if !-e $user_cart; # Security details incomplete &error('S') if $password_file && (!$in{'uid'} || !$in{'pwd'}); # Cart status $modify = $order1 = $order2 = ''; ++$modify if $in{'submit_changes'} || $in{'submit_deletion'} || $in{'delete_item'} || $in{'modify_cart'}; ++$order1 if $in{'security'} || $in{'sslForm'}; ++$order2 if $in{'chkForm'} || $in{'faxOrder'} || $in{'chgShip'}; if ($modify.$order1.$order2) { # Empty cart if (-z $user_cart) { if ($order1.$order2) { $msg = $button_4_txt } elsif ($in{'modify_cart'}) { $msg = $button_1_txt } else { $msg = 'Modify Cart' } &frontpage("$msg not available: $SPACE$SPACE Your shopping cart is empty $SPACE"); } # Minimum order value elsif ($in{'security'}) { &get_form($form_file); &count_cart_rows; &frontpage("$button_4_txt not available: $SPACE$min_order_msg") if $minimum_order; } @name_values = (); } $mozilla_use_ssl = ''; if ($use_ssl && !$in{'no_ssl'}) { if ($browser =~ /^Mozilla/) { ++$mozilla_use_ssl } elsif ($use_ssl eq '1') { $use_ssl = '2' } # SSL if ($in{'sslForm'} eq '1' || $order2) { $graphics_url = $ssl_graphics_url; $main_script_url = $ssl_url; &print_cont; } elsif (!$order1) { &print_cont } } else { $in{'sslForm'} = '1' if $in{'no_ssl'} =~ /^N/; &print_cont; $in{'no_ssl'} = 'Y'; } } # Assign cart id else { &print_cont; # Referring page my $refer = ''; if ($in{'rfw'}) { $refer = $in{'rfw'} } elsif ($in{'ref'}) { $refer = $in{'ref'} } elsif ($ENV{'HTTP_REFERER'}) { $refer = $ENV{'HTTP_REFERER'}; $refer = (split(/\#/,$refer))[0] if $refer =~ /\#/; $refer = (split(/\?/,$refer))[0] if $refer =~ /\?/; } $in{'rfw'} = $refer; if ($log_file && $refer && $refer ne $main_script_url) { push(@name_values,'ref'); $in{'ref'} = $refer; } elsif ($in{'ref'}) { undef $in{'ref'} } &reseller; # Prevent invalid form access foreach ( 'chgShip','chkForm','delete_item','faxOrder','modify_cart','name_vals','noLoad', 'no_ssl','security','sslForm','submit_changes','submit_deletion') { undef $in{$_} if defined($in{$_}) } if ($in{'buy_item'}) { push(@name_values,'buy_item') } elsif ($in{'view_item'}) { push(@name_values,'view_item') } elsif ($in{'add_cart'}) { foreach (keys %in) { push(@name_values,$_) if $_ =~ /^\d+$|^[d]{1,2}[12]{1}_\d+$|^item_id_/ } if (@name_values) { push(@name_values,'add_cart') } else { delete $in{'add_cart'} } } elsif ($in{'submit_search'}) { push(@name_values,'price_arg','price_val','product_arg','submit_search','text_arg','text_val') } if ($in{'frontpage'} && !$password_file) { if (!$in{'cd'}) { &get_form($form_file); &del_vars('OrderForm',$form_file,'Y'); } } elsif ($password_file || ($client_file && ((defined($in{$usr_fld_name}) && $in{$usr_fld_name} ne '') || (defined($in{$pwd_fld_name}) && $in{$pwd_fld_name} ne '') || $in{'uid'} ne '' || $in{'pwd'} ne '' || "$in{'getClientForm'}$in{'mdyClientRecord'}$in{'chkClientAccess'}" ne '' || defined($in{'client_form'})))) { $access_msg = $no_client = $cart_id = ''; # Disable error messaging - first access if (!defined($in{$usr_fld_name}) && !defined($in{$pwd_fld_name}) && !defined($in{'uid'}) && !defined($in{'pwd'})) { $first_access = 'Y' } elsif (defined($in{'client_form'})) { $first_access = '0'; foreach ($usr_fld_name,$pwd_fld_name,'uid','pwd') { if (defined($in{$_}) && $in{$_} !~ /\w+/) { undef($in{$_}); ++$first_access; } elsif (!defined($in{$_})) { ++$first_access } } $first_access = '' if $first_access != 4; } delete $in{'client_form'}; &get_form($client_file); $in{'uid'} =~ s/\s+//g if defined($in{'uid'}); $in{'pwd'} =~ s/\s+//g if defined($in{'pwd'}); if ($password_file) { $in{'uid'} = $in{$usr_fld_name} if (defined($in{$usr_fld_name}) && ($in{$usr_fld_name} && !$in{'uid'} || $in{$usr_fld_name} eq $def_username)); $in{'pwd'} = $in{$pwd_fld_name} if (defined($in{$pwd_fld_name}) && ($in{$pwd_fld_name} && !$in{'pwd'} || $in{$pwd_fld_name} eq $def_password)); if ($def_username ne '' && $def_password ne '' && $in{'uid'} eq $def_username && $in{'pwd'} eq $def_password) { $in{'ud'} = $in{'uid'}; $in{'pd'} = $in{'pwd'}; $in{'uid'} = $in{'pwd'} = $in{'RetrieveRecord'} = $in{'chkClientAccess'} = ''; $getClientForm = 'Y'; } } else { $button_2 = qq!\n ! } if ($in{'RetrieveRecord'} && !&get_client_record('Y')) { &prtClientForm('ClientAccess', %ClientAccess) if $r_attempts > 0; } elsif ($in{'mdyClientRecord'} && &get_client_record('Y')) { &prtClientForm('ClientForm', %ClientForm) } if ($in{'chkClientAccess'}) { &chkClient('ClientAccess', %ClientAccess) } if ($in{'chkClientForm'}) { &chkClientForm() } if ($in{'getClientForm'} || $getClientForm) { if ($password_file) { $in{'uid'} = $in{$usr_fld_name} = '' if $in{$usr_fld_name} eq $def_username && $def_username ne ''; $in{'pwd'} = $in{$pwd_fld_name} = '' if $in{$pwd_fld_name} eq $def_password && $def_password ne ''; $in{'ud'} = $in{'pd'} = ''; } elsif ($in{'getClientForm'}) { &get_client_record() } if ($in{'getClientForm'} || $getClientForm eq 'Y') { &prtClientForm('ClientForm', %ClientForm) } elsif ($password_file) { &access_denied } else { &del_vars() } } elsif ($chkClientAccess || $no_client || !&get_client_record('Y')) { if ($r_attempts > 0) { &prtClientForm('ClientAccess', %ClientAccess) } elsif ($password_file) { &access_denied } else { &del_vars() } } else { &del_vars('ClientAccess', %ClientAccess) } } # Check files for Perl errors - Telnet or ?env= for web browser elsif (defined($in{'env'}) || !defined($ENV{'REQUEST_METHOD'})) { $cart_id = ''; $in{'env'} .= ''; &file_status(__FILE__, __LINE__, 'req', $libr_directory.'/'.'WSForms.pl', $data_directory.'/'.$country_file, $data_directory.'/'.$form_file, ); my $file = ''; if ($in{'env'} =~ /authorizenet/i) { $file = 'WSAuthorizeNet.pl' } elsif ($in{'env'} =~ /surepay/i) { $file = 'WSSurepay.pl' } elsif ($merchant_file =~ /authorizenet/i) { $file = 'WSAuthorizeNet.pl' } elsif ($merchant_file =~ /surepay/i) { $file = 'WSSurepay.pl' } &file_status(__FILE__, __LINE__, 'req', $libr_directory.'/'.$file) if $file; &del_vars('OrderForm',$form_file); } # Check system files &system_files; # Assign cart id &date_time; my ($a, $b, $cartID); $cartID = sprintf("%02d%02d%02d%02d%02d%05d",$year,$mon,$mday,$hour,$min,$$); $cart_id = $cartID; &make_dir($cart_directory, '777') if $password_file && !-e $cart_directory && $real_cart_dir && -e $real_cart_dir; # Check cart id for uniqueness $a = '0'; while (-e $cart_directory.'/'."$cart_id.cart") { &file_error( 'System Error in Shopping Cart Routine', 'Can not create unique shopping cart file after 5 attempts.', "$cart_id.cart already exists in $cart_directory.", 'Error occurred at LINE '.__LINE__.' in '.__FILE__.'.', &file_perm('666',"$cart_id.cart") ) if $a == 5; srand (time|$$); $b = int(rand(1000)); $cart_id = $cartID.'-'.$b; ++$a; } $user_cart = $cart_directory.'/'.$cart_id.'.cart'; $cart = ''; &write_cart; $in{'no_search'} = $in{'ns'} = 'Y' if $in{'no_search'} || $search_engine eq '2'; # Preserve possible incoming query string - Frameset loading # Pass specific function for "main" frame to frameset query strings if ($frameset_file) { if ($in{'frames'} eq 'frameset' && $in{'category'} =~ /\.htm[l]*$/i) { $frame_file = $in{'category'}; delete $in{'frames'}; delete $in{'category'}; } else { $frame_file = $frameset_file } if ($in{'frames'} ne 'frameset' && $in{'category'} ne $frameset_file && $in{'page'} ne $frameset_file && $in{'pcat'} ne $frameset_file) { $in{'nc'} = $cart_id; if (defined(@name_values)) { foreach (sort @name_values) { $in{'no_search'} = $in{'ns'} = '' if $_ eq 'submit_search'; if (defined($in{$_})) { $in{'nc_'.$_} = &convert_hex($in{$_}); delete $in{$_}; } } } foreach ('category','d1','d2','dbase_chk','frontpage','item_id','item_pr','rsc_nf','page','pcat') { $in{'nc_'.$_} = &convert_hex($in{$_}) if defined($in{$_}) && $in{$_} ne '' } if ($in{'frames'} eq 'Y') { $in{'nc_frames'} = 'Y'; delete $in{'frames'}; } if ($in{'form'}) { $in{'nc_form'} = $in{'form'}; delete $in{'form'}; } } $frame_access = 'Y'; } else { $frame_access = 'N' } $new_cart = ''; undef(@name_values); $del_carts = 'Y'; } #==========================================================================# # **Buttom Images in WebStore** #==========================================================================# # # INPUT TYPES USING IMAGES MUST BE PLACED BELOW THESE COMMENTS # # The commands above this line determine the value of $graphics_url # when this script is configured for use with SSL. # #==========================================================================# # "Add to Cart" BUTTOM IMAGE EXAMPLE # # $button_5 = qq!\n !; # #==========================================================================# # # If you use image buttons which require a secure URL (https://), # set in this script. # # # If you do not use SSL, the SRC attribute may be relative: # # SRC="Graphics/ImageFilename" # # Relative location of an image file is "relative to" the location of # the WebStore script. # # To replace buttons, search for: !; $button_2 = qq!\n !; $button_4 = qq!\n !; } $item_id = $in{'item_id'}; $pcat = $in{'pcat'}; if ($in{'page'} =~ /\.htm[l]*$/i) { $page = $in{'page'} } else { $page = $in{'page'} = '' } $button_3 = qq!\n ! if ($page && $page ne $frontpage_file && $page ne $search_tips) || ($pcat && $pcat ne $frontpage_file); $button_5 = qq!\n ! if !$add_cart_button; $rst_button = qq!!; $max_items = '5' if $max_items == 0 || $max_items !~ /^\d+$/; if ($in{'no_search'} && !$in{'frontpage'}) { $s_engine = $search_engine; $search_engine = $in{'submit_search'} = $in{'search'} = ''; } # Preserve category paging values if ($in{'cpage'}) { $cpage = $in{'cpage'}; $next = $in{'next'}; $previous = $in{'previous'}; $curr_item = $in{'curr_item'}; $total_items = $in{'total_item'}; $first = $in{'first'}; } # Preserve search engine values elsif ($in{'submit_search'} || $in{'search'}) { $search = $in{'search'}; # Active Search $text_val = $in{'text_val'}; # Text for Search $text_arg = $in{'text_arg'}; # Phrase, Keywords Search $price_val = $in{'price_val'}; # Price value $price_arg = $in{'price_arg'}; # Equal To, Greater Than, Less Than $product_arg = $in{'product_arg'}; # Categories $next = $in{'next'}; # Submit - Display Next Chunk $previous = $in{'previous'}; # Submit - Display Previous Chunk $curr_item = $in{'curr_item'}; # End Current Displayed Chunk $total_items = $in{'total_item'}; # Total Items - Current Search $first = $in{'first'}; # First Item - Last Display Chunk } else { $price_val = $text_val = '' } ############################################ # View Item, Buy Item, Add to Cart $cart_error = $change_qty = ''; # View Item if ($in{'view_item'}) { &check_page; &disp_sale_items; } # Buy Item elsif ($in{'buy_item'}) { &check_page; &check_cart; my (@ct_row, @CART1, $row); @CART1 = (); # Go through database &read_open($data_file); while () { s/\s+$//; next if /^$|^COMMENT:/i; if (&item_row($_) && $in{'buy_item'} eq $db_row[$item_fld_num]) { # Display items with drop down select values if ($db_row[0] =~ /\w+/ || $db_row[1] =~ /\w+/) { $in{'category'} = $db_id_num; push(@buy_item,$_); close(FILE); &disp_sale_items; } # Check list of items $modified = ''; if ($cart) { while (@CART) { $row = shift(@CART); @ct_row = split(/\|/,$row); #qqq if ($dbase_id_fld_num =~ /\d+/) { $ctdb_id_num = $ct_row[$dbase_id_fld_num+1] } else { $ctdb_id_num = $ct_row[$#ct_row-1] } if ($db_id_num eq $ctdb_id_num) { $item_qty = shift(@ct_row); ++$item_qty; unshift(@ct_row,$item_qty); $row = join('|',@ct_row); ++$modified; } push(@CART1,$row); } @CART = @CART1; @CART1 = (); } # Item added to cart push(@CART,'1|'.&filter_fields) if !$modified; close(FILE); $cart = join('',@CART); &write_cart; # Send client to View/Modify page &change_quantity if !$display_category; &frontpage if !$in{'category'}; # Send client to Category page &disp_sale_items; } # End if (&item_row($_)) } # End while () close(FILE); &frontpage("Item $in{'buy_item'} not available in $data_file1 $SPACE") if !$in{'category'} || $in{'category'} eq $frontpage_file; $cart_error = &cart_msg('Item',"$in{'buy_item'} not available in $data_file1"); &disp_sale_items; } # Add to Cart elsif ($in{'add_cart'}) { if ($item_id || defined($search) || $in{'category'} ne '') { $no_category = '' } else { $no_category = '1' } # Check for positve integers if (!&check_keys) { $cart_error = &cart_msg($button_5_txt,'No item selected for purchase'); delete $in{'add_cart'}; if ($in{'category'} || $search) { &disp_sale_items } elsif (defined(%no_items)) { %items = %no_items } elsif (!defined(%items)) { &frontpage } } &check_cart; my ($a, @ct_row, @CART1, $row); @CART1 = (); # Go through database &read_open($data_file); while () { s/\s+$//; next if /^$|^COMMENT:/i; if (&item_row($_) && defined($items{$db_id_num})) { if ($no_category) { $in{'category'} = $db_row[$category_fld_num]; $no_category = ''; if (defined(%no_items)) { close(FILE); &disp_sale_items; } } # Check list of items # Construct color - size fields $e = 'dd1_'.$db_id_num; $f = 'dd2_'.$db_id_num; # Submission error check push(@{ $cart_errors{$db_id_num} },qq!No $field_names[0] Selected!) if $db_row[0] =~ /\w+/ && !$in{$e}; push(@{ $cart_errors{$db_id_num} },qq!No $field_names[1] Selected!) if $db_row[1] =~ /\w+/ && !$in{$f}; # Item Page Error if (defined($item_id) && $item_id eq $db_id_num) { $dd_hdr1 = $dropdowns1 = $drop_down_error1 = ''; if ($db_row[0] =~ /\w+/ && (!defined($in{'d1'}) || $in{'d1'} eq '')) { $dd_hdr1 = $field_names[0]; $dropdowns1 = 'No d1= in query string'; } if ($db_row[1] =~ /\w+/ && (!defined($in{'d2'}) || $in{'d2'} eq '')) { if ($dd_hdr1) { $dd_hdr1 .= ' and '; $dropdowns1 .= " $SPACE$SPACE "; } $dropdowns1 .= 'No d2= in query string'; $dd_hdr1 .= $field_names[1]; } if ($dd_hdr1) { $a = ''; foreach ('category','page','pcat','item_pr','item_id','d1','d2') { $a .= '&'.$_.'='.$in{$_} if defined($in{$_}) } $a =~ s/^&/?/; $dropdowns1 = "$dropdowns1
\n\t".&convert_ext($a). "
\n\tRecord $item_id in $data_file1: $SPACE$SPACE "; $dropdowns1 .= $field_names[0].' = '; if ($db_row[0] ne '') { $dropdowns1 .= $db_row[0] } else { $dropdowns1 .= 'NONE' } $dropdowns1 .= " $SPACE$SPACE ".$field_names[1].' = '; if ($db_row[1] ne '') { $dropdowns1 .= $db_row[1] } else { $dropdowns1 .= 'NONE' } $dropdowns1 .= '

'; $dd_hdr1 .= ' not defined in query string on HTML page'; $drop_down_error1 = 'Y'; close(FILE); &disp_sale_items; } } if (!defined(%cart_errors)) { $modified = ''; # Add selected color $db_row[0] = $db_row[0].'~~'.$in{$e} if $db_row[0] =~ /\w+/; # Add selected size $db_row[1] = $db_row[1].'~~'.$in{$f} if $db_row[1] =~ /\w+/; if ($cart) { while (@CART) { $row = shift(@CART); @ct_row = split(/\|/,$row); #qqq if ($dbase_id_fld_num =~ /\d+/) { $ctdb_id_num = $ct_row[$dbase_id_fld_num+1] } else { $ctdb_id_num = $ct_row[$#ct_row-1] } if ($db_id_num eq $ctdb_id_num && $db_row[0] eq $ct_row[1] && $db_row[1] eq $ct_row[2]) { $item_qty = shift(@ct_row); $item_qty += $in{'item_id_'.$db_id_num}; unshift(@ct_row,$item_qty); $row = join('|',@ct_row); ++$modified; } push(@CART1,$row); } @CART = @CART1; @CART1 = (); } # Item added to cart push(@CART,$in{'item_id_'.$db_id_num}.'|'.&filter_fields) if !$modified; } delete $items{$db_id_num}; last if !scalar(keys %items); } # End if (&item_row($_)) } # End while () close(FILE); if (defined($modified) && !$cart_error && !defined(%cart_errors)) { $cart = join('',@CART); &write_cart; # Send client to Category page &disp_sale_items if $display_category; # Send client to View/Modify page &change_quantity; } elsif ($item_id) { $cart_error = &cart_msg('Item Page',"Record number $item_id not available in $data_file1"); &disp_sale_items; } elsif (%no_items || $no_category) { &frontpage("Items on HTML page not available in $data_file1 $SPACE") } elsif (defined(%cart_errors)) { $cart_error = 'Y'; delete $in{'add_cart'}; } elsif ($cart_error) { delete $in{'add_cart'} } } ############################################ # Print View/Modify Cart Form &change_quantity if $in{'modify_cart'}; # Print Delete Item Form &delete_item if $in{'delete_item'}; ############################################ # Modify Item Quantity in Cart if ($in{'submit_changes'}) { # Check for positve integers if (&check_keys && !defined(%cart_errors)) { # Open cart and go through it my $modified = $cart = ''; &read_open($user_cart); while () { &get_cart_row($_); $e = 'dd1_'.$ct_rw_num; # Color field $f = 'dd2_'.$ct_rw_num; # Size field #qqq $cart .= $in{'item_id_'.$ct_rw_num}.'|'; # Add dbase row to $cart $c = '0'; foreach $b (@ct_row) { # Color index and color if (!$c && $in{$e} && $b =~ /~{2}/) { $cart .= (split(/~{2}/,$b))[0].'~~'.$in{$e}.'|' } # Size index and size elsif ($c == 1 && $in{$f} && $b =~ /~{2}/) { $cart .= (split(/~{2}/,$b))[0].'~~'.$in{$f}.'|' } else { $cart .= $b.'|' } ++$c; } chop $cart; # Remove last | ++$modified if $quantity ne $in{$ct_rw_num} || $in{$e} ne (split(/~{2}/,$dd1_string))[1] || $in{$f} ne (split(/~{2}/,$dd2_string))[1]; } close(FILE); &write_cart if $modified; } # Send client to View/Modify &change_quantity; } ############################################ # Delete Item from Cart if ($in{'submit_deletion'}) { my ($del, %items); # Filter out alpha keys #qqq foreach (keys %in) { if ($in{$_} && $_ =~ /^item_id_/) { $_ =~ s/^item_id_//; $items{$_}++; } } if (scalar(keys %items)) { $cart = $del = ''; &read_open($user_cart); while () { &get_cart_row($_); # Delete checked rows if (defined($items{$ct_rw_num})) { delete $items{$ct_rw_num}; ++$del; } else { $cart .= $_ } } close(FILE); &write_cart if $del; # Print Delete Form if ($cart && $del) { &delete_item } # Display category for empty cart elsif (!$cart) { if (!$search && ($in{'category'} eq $frontpage_file || !$in{'category'})) { &frontpage() } else { &disp_sale_items } } } # Print View/Modify page &change_quantity; } ############################################ # Choose Transmission Method &security if $in{'security'}; ############################################ if ($client_file && $in{'client_form'}) { $access_msg = ''; &get_form($client_file); if (($in{'uid'} && $in{'pwd'} && !"$in{'chkClientAccess'}$in{'chkClientForm'}$in{'getClientForm'}$in{'RetrieveRecord'}") || ($in{'getClientForm'} && $in{$usr_fld_name} && $in{$usr_fld_name})) { &prtClientForm('ClientForm', %ClientForm) if &get_client_record() } # Update client record &chkClient('ClientRetrieve', %ClientRetrieve) if $in{'chkClientAccess'}; # Update/Create client record &chkClientForm() if $in{'chkClientForm'}; if (defined($r_attempts) && $r_attempts == 0) { &del_vars() } # Create or update client record elsif ($in{'getClientForm'} || $getClientForm) { &prtClientForm('ClientForm', %ClientForm) } elsif ($chkClientAccess || $in{'client_form'}) { &prtClientForm('ClientRetrieve', %ClientRetrieve) } } ############################################ if ($in{'chkform'}) { &get_form($in{'form'}); %Form = &check_form('Form', %Form); &check_fields('Form', %Form) if !$form_error; if (!$error_msg && $form eq $reseller_file) { # Create $reseller_code $reseller_code = &getResellerCode if $reseller_data_file || $reseller_spreadsheet; if ($reseller_spreadsheet) { if (!&write_lock($data_directory.'/'.$reseller_spreadsheet, '10')) { &wrtResellerFile($reseller_code) } else { $error_msg = "\n\tServer Busy: $SPACE Please ".&submit_anchor(keys %Form).' this form again.' } } } if (!$error_msg) { delete $in{'chkform'}; delete $in{'form'}; %Form = &get_mail_vars(%Form); &get_email(%Form); # &send_mail(From, To, Subject, Body) if ($in{$client_email}) { &send_mail("$in{$client_name} \<$in{$client_email}\>", $admin_email, $email_subject, $admin_msg); $demo .= 'E-mail to Client - ' if $demo; &send_mail($company_email, $demo."$in{$client_name} \<$in{$client_email}\>", $email_subject, $client_msg); &join_list($in{'joinlist'}); } else { &send_mail($company_email, $admin_email, $email_subject, $admin_msg) } if ($in{'frontpage'} || $in{'category'} eq $frontpage_file || (!$in{'category'} && $page eq $frontpage_file)) { &frontpage() } elsif ($in{'frames'} eq 'main') { delete $in{'frames'} } &disp_sale_items if $in{'category'} =~ /^\d+$/; } else { $in{'chkform'} = 'Y' } } ############################################ # Print Requested Form if ($in{'form'} || $in{'chkform'}) { $in{'frames'} = $in{'category'} = '' if $in{'frames'} =~ /^frameset$|^main$/; &get_form($in{'form'}); &get_client_record() if $client_file && $in{'uid'} && $in{'pwd'} && !$in{'chkform'}; &html_header($email_subject); &count_cart_rows; %Form = &check_form('Form', %Form) if !$form_check; &pre_form_html if $pre_form && !$form_error; &hidden_form_tags(); &form_title('Form', %Form); &print_form('Form', %Form); &form_trailer_html if $form_trailer && !$form_error; &html_trailer; } ############################################ if ($in{'chkForm'} || $in{'faxOrder'}) { &get_form($form_file); %OrderForm = &check_form('OrderForm', %OrderForm); &count_cart_rows if !$grand_total; &check_fields('OrderForm', %OrderForm) if !$form_error; if (!$error_msg && $in{'chkForm'} && $merchant_file =~ /\w+/) { my $file = ''; if ($merchant_file =~ /surepay/i) { $file = 'WSSurepay.pl' } elsif ($merchant_file =~ /authorizenet/i) { $file = 'WSAuthorizeNet.pl' } if ($file) { &file_status(__FILE__, __LINE__, 'req', $libr_directory.'/'.$file); &exec_auth($cart_id); } } if (!$error_msg) { if (!$in{'faxOrder'}) { $send_order = 'Y'; delete $in{'chkForm'}; } } else { $in{'chkForm'} = 'Y' } } ############################################ # Print Order Form # Client has finished shopping and requested order form # Client has toggled sales tax from order form if ($in{'sslForm'} || $in{'chkForm'} || $in{'chgShip'}) { &get_form($form_file); if ($mozilla_use_ssl && $in{'sslForm'} && $in{'sslForm'} ne '1') { my $qs = ''; if ($in{'name_vals'}) { @name_values = (split(/\|/,$in{'name_vals'}),'name_vals') } elsif ($ship_method) { $qs = '&ship='.$ship_method } print "Location: $ssl_url\?sslForm=1\&store=$store\&cart_id=$cart_id\&formfile=$in{'formfile'}$qs".&query_string()."\n\n"; exit; } elsif ($in{'name_vals'}) { foreach ('form_file') { $in{'name_vals'} =~ s/$_\|{0,1}//g } @name_values = (split(/\|/,$in{'name_vals'}),'name_vals'); } if ($client_file && $in{'c_file'} && $in{'uid'} && $in{'pwd'} && !defined($no_client) && (!defined($in{'noLoad'}) || $in{'noLoad'} eq 'N')) { &get_client_record(); $ship_method = $in{'ship'} if $in{'ship'}; $in{'noLoad'} = 'Y'; } &sales_tax; &count_cart_rows if !$grand_total; %OrderForm = &check_form('OrderForm', %OrderForm) if !$form_check; &html_header('Order Form'); &pre_form_html if $pre_form && !$form_error; $in{'category'} = $in{'page'} = $in{'pcat'} = $cpage = $item_id = $search = $search_engine = ''; undef $grand_total; &hidden_form_tags(); &form_title('OrderForm', %OrderForm); if(!$form_error) { &disp_cart_table_vars('0'); if ($disp_ship) { $table_rowspan += 2 } else { ++$table_rowspan } &table_title($global_page_title,$modify_table_border,''); # table headers &table_header(); # cart contents while (@CART) { &get_cart_row(shift(@CART)); &print_cart_row(); } $ship_dd = 'chgShip'; &ship_tax; if ($frameset_file && !$in{'no_ssl'} && ($use_ssl == 1 || $use_ssl == 2)) { if ($browser =~ /MSIE/) { $ssl_img = 'security.MSIE.gif' } else { $ssl_img = 'security.Netscape.gif' } if (-r $grph_directory.'/'.$ssl_img) { $ssl_img = qq!!; print "\n

\n$table_open

$SPC$SPACE$SPC$SPACE
$ssl_img$SPACE$SPACESecure Frame$SPACE$SPACE$ssl_img
\n"; } } print "\n"; } &print_form('OrderForm', %OrderForm); &form_trailer_html if $form_trailer && !$form_error; if (defined($debug_txt) && $debug_txt) { print $debug_txt; print &print_vars if defined(&print_vars); print "\n\n\n"; print &version($version.' CS'); exit; } else { &html_trailer } } ############################################ # Category Page if ($in{'category_page'}) { if ($pcat && !$page) { $page = $in{'category'} = $pcat; $button_3 = $pcat = $in{'pcat'} = ''; } elsif ($pcat) { $in{'category'} = $pcat; $pcat = $in{'pcat'} = ''; } else { $in{'category'} = $in{'page'} } undef $item_id; delete $in{'d1'}; delete $in{'d2'}; &disp_sale_items; } ############################################ # Send In Order # Send order to administrator if ($send_order || $in{'faxOrder'}) { &error('P') if -e $processed_cart; # y - year # m - month # d - day # h - hour $save_orders = '' if $save_orders !~ /[ymdh]/i; $print_tags = 'Y'; &sales_tax; # Set colors for web browser printing $background = $bgcolor = $text_color = $link_color = $vlink_color = $alink_color = $data_fnt_clr = $data_bkg_clr = $dsc_hr_fnt_clr = $dsc_hr_bkg_clr = $header_fnt_clr = $header_bkg_clr = $modify_bkg_clr = $modify_fnt_clr = $modify_table_border = ''; $background = ''; # Background Image $bgcolor = '#FFFFFF'; # White $text_color = '#000000'; # Black $link_color = '#0000FF'; # Blue $vlink_color = '#0000A0'; # Dark Blue $alink_color = '#FF0000'; # Red $modify_spc_width = '15'; %OrderForm = &get_mail_vars(%OrderForm); %mail_order = ('1' => ['af',$admin_email]) if !defined(%mail_order) || !scalar(keys %mail_order); if ($send_order) { &html_header("$in{$client_name}'s Order: $cart_id Has Been Sent"); &hidden_form_tags(); if ($client_file) { $uid = $pwd = ''; ($uid,$pwd) = &filter_vars($in{$usr_fld_name},$in{$pwd_fld_name}); $uid = $in{$usr_fld_name} = $in{'uid'} if !$uid && $in{'uid'}; $pwd = $in{$pwd_fld_name} = $in{'pwd'} if !$pwd && $in{'pwd'}; $pwd = $in{$pwd_fld_name} = &password if !$pwd; $in{'uid'} = $uid; $in{'pwd'} = $pwd; } &print_order_get_email; # Admin and reseller e-mail &sendmail(%mail_order); # Client confirmation e-mail $in{'x_Email_Customer'} = '' if !defined($in{'x_Email_Customer'}); if ($in{'x_Email_Customer'} ne 'TRUE') { $demo .= 'E-mail to Client - ' if $demo; # &send_mail(From, To, Subject, Body) &send_mail($company_email, $demo."$in{$client_name} \<$in{$client_email}\>", $email_subject, $client_msg); } if ($client_file && $in{'uid'} && $in{'pwd'}) { foreach (sort keys %OrderForm) { $a = $OrderForm{$_}[2]; $b = $OrderForm{$_}[0]; if ($in{'unf_'.$b} && $a =~ /^textarea$/i) { $in{$b} = $in{'unf_'.$b}; delete $in{'unf_'.$b}; } } &wrtClientFile; } &wrtOrderFile if $save_orders && !$demo; } # Print order to client's web browser else { &html_header("$in{$client_name}\'s Order to Web Browser for Printing"); &hidden_form_tags(); $data_font = 'SIZE=3'; &print_order_get_email; # Admin and reseller e-mail &sendmail(%mail_order) if $fax_email; } # End if ($send_order) if ($processed_cart && ($delete_cart || $save_orders)) { &write_open($processed_cart,''); print FILE join('',@CART); close(FILE); system("chmod 666 $processed_cart"); } &join_list($in{'joinlist'}); # Delete Client Files - 30 day interval $client_delete_age =~ s/\s+//g; if ($client_delete_age =~ /^[1-9]{1}\d*$/) { $age_file = $clnt_directory.'/'.'delete.client.age.file'; if (!-e $age_file || -M $age_file > 30) { $a = $client_delete_age; if ($a > 1) { $b = 's' } else { $b = '' } $a = sprintf("%d",$a*30); &age_file($age_file,'Files older than '."$client_delete_age month$b at 30 day"); &delete_files(__FILE__,__LINE__,$clnt_directory,'.client',$a); } } exit; } ############################################ # Submit Search if ($in{'submit_search'}) { undef $curr_item; delete $in{'curr_item'}; undef $total_items; delete $in{'total_item'}; undef $first; delete $in{'first'}; undef $item_id; &submit_search; } if (!$in{'frontpage'} && ($next || $previous || $first)) { &disp_sale_items if $cpage; &submit_search; } if (!$in{'frontpage'} && $in{'search'}) { # Send client to View/Modify page when item is ordered &change_quantity if !$in{'continue_shopping'} && !$display_category && -s $user_cart; # Send client to search page they ordered from &disp_sale_items; } ############################################ # Frames control if (!$frameset_file && $in{'frames'}) { if ($in{'frames'} ne 'Y') { $in{'category'} = $in{'frames'} = '' } elsif ($in{'category'} =~ /\.htm[l]*$/i) { &print_file($in{'category'}) } } elsif ($in{'frames'} || $frame_file) { $frame_file = $in{'category'} if $in{'frames'} =~ /^frameset$|^Y$/ && $in{'category'} =~ /\.htm[l]*$/i; &print_file($frame_file) if $frame_file; } # page= pcat= shift if (!$in{'frontpage'} && !$in{'category'}) { $page = $in{'page'} = $pcat if !$page && $pcat; $in{'category'} = $page if $page; if ($pcat) { $page = $in{'page'} = $pcat; $pcat = $in{'pcat'} = ''; } } # Print front page &frontpage() if $in{'frontpage'} || !$in{'category'} || $in{'category'} eq $frontpage_file; # Display selected category/page &disp_sale_items; # END MAIN PROGRAM ABOVE ############################################ # SUBROUTINES BELOW ############################################ # Print Modify Quantity Form sub change_quantity { my ($a); $a = $in{'tax'} = ''; $change_qty = 'Y'; $title = 'View/Modify Cart Item'; &count_cart_rows; $title .= 's' if $row_count > 1; # Output header &html_header($title); # Preface View/Modify pages if (defined(%cart_errors)) { print &cart_errors } elsif ($pre_view_modify) { &pre_view_modify_html } &hidden_form_tags(); undef $grand_total; &disp_cart_table_vars('1'); # title row &table_title($title,$modify_table_border,''); # table headers &table_header('Quantity'); #qqq while (@CART) { &get_cart_row(shift(@CART)); # table row of textbox, cart contents, and spacer if (defined(%cart_errors)) { $a = $in{'item_id_'.$ct_rw_num} } else { $a = $quantity } &print_cart_row(qq!'); } &ship_tax; if ($row_count > 1) { $a = 's' } else { $a = '' } print qq!\n\n

\n\n

\n !; &common_buttons; print "\n$rst_button\n
\n\n\n"; &html_trailer; } ############################################ # Print Delete Item Form sub delete_item { my $title = 'Delete Cart Item'; &count_cart_rows; $title .= 's' if $row_count > 1; # page header &html_header($title); # Preface View/Modify pages &pre_view_modify_html if $pre_view_modify; &hidden_form_tags(); undef $grand_total; &disp_cart_table_vars('1'); # title row &table_title($title,$modify_table_border,''); # table headers &table_header('Delete'); while (@CART) { &get_cart_row(shift(@CART)); # table row of checkbox, cart contents, and spacer &print_cart_row(qq!!); } &ship_tax; print qq!\n\n

\n\n

\n !; &common_buttons; print "\n
\n\n\n"; &html_trailer; } ############################################ sub frontpage { my ($msg) = @_; $cpage = $item_id = $page = $in{'page'} = $in{'pcat'} = $in{'ship'} = $in{'tax'} = ''; if ($in{'ns'} || $in{'no_search'}) { $no_search = 'Y'; delete $in{'no_search'}; } $search_engine = $s_engine if $s_engine; $in{'category'} = $frontpage_file; &get_html_page($frontpage_file); while (@HTML_FILE) { $row = shift(@HTML_FILE); if ($row =~ /$SPACE\n\n<\!-- Error Message -->\n
\n$table_open $dt_fnt_tag$SPACE $msg \n
\n" } elsif ($cart_error) { print $cart_error } &hidden_form_tags() if $bdy_frm_tags == 1; } elsif ($row =~ m#\n

$SPACE\n"; &subtotal_msg; print "\n\n

\n"; } else { print "\n
\n"; } print "

$button_1$button_4\n" if $button_1.$button_4; if ($search_engine) { $print_tips = '1'; &search_engine_form; } print "\n

\n\n\n"; # Provide html below form buttons of frontpage &frontpage_trailer_html if $frontpage_trailer; # Print access counter if readable if ($count_file && -r $count_file) { &write_lock($count_file, '2') if -e $count_file.'.lock'; &read_open($count_file); while () { $count = $_ } close(FILE); $count =~ s/\s+//g; # Count file contains valid count if ($count =~ /[1-9]/) { $a = $count; ++$a if defined($del_carts); $a = (split(/\./,&format_num($a,'Y')))[0]; if ($counter_label) { $counter_label = "$counter_label $SPACE" } else { $counter_label = '' } $count_bkg_clr = qq! BGCOLOR="$count_bkg_clr"! if $count_bkg_clr ne ''; $count_fnt_clr = qq! COLOR="$count_fnt_clr"! if $count_fnt_clr ne ''; print "\n
\n

$SPACE\n\n
$nc_fnt_tag$counter_label
$SPACE$a$SPACE
\n

\n\n"; } } &html_trailer; } else { &substitute($row,$frame_access) } } # End while @HTML_FILE exit; } ############################################ sub print_cont { print "Content-type: text/html\n\n" if !$content_type && defined($ENV{'REQUEST_METHOD'}); $content_type = '1'; } ############################################ sub print_file { my ($page) = @_; &get_html_page($page); while (@HTML_FILE) { &substitute(shift(@HTML_FILE),$frame_access) } print &version($version.' CS'); exit; } ############################################ sub print_text_file { my ($file, $prefix) = @_; my $exist = ''; if (defined($prefix) && $prefix ne '') { $prefix .= '.' } else { $prefix = '' } if ($file =~ /\w+/) { $file =~ s/\s+/_/g; $file .= '.txt' if $file !~ /\.txt$/; if (-r $html_directory.'/'.$prefix.$file) { ++$exist } else { print "\n\n\n"; $file = 'DEFAULT.txt'; } } else { $file = 'DEFAULT.txt' } my $txt_file = $html_directory.'/'.$prefix.$file; if ($exist || -r $txt_file) { $file = $prefix.&convert_ext($file); print "\n\n\n"; my @FILE = &get_file($txt_file); while (@FILE) { &substitute(shift(@FILE)."\n",'') } print "\n\n\n"; } } ############################################ # FILE access sub read_open { my ($file) = @_; open(FILE, $file) || &open_error('File', $file, 'Read File', __FILE__, __LINE__, '644'); seek(FILE, 0, 0); } sub write_open { my ($file, $app) = @_; open(FILE, ">$app$file") || &open_error('File', $file, 'Write File', __FILE__, __LINE__, '666'); } sub write_cart { &write_open($user_cart,''); print FILE $cart; close(FILE); system("chmod 666 $user_cart"); } ############################################ sub submit_search { my ($a, $b, %cat, $dbase_chk, %db_nums); &count_cart_rows; if ($text_val ne '') { $text_val =~ s/[`^{}\[\]|#]+//g; $text_val =~ s/\s{2,}/ /g; $text_val =~ s/(^\s+|\s+$)//g; @keywords = split(/\s+/,$text_val) if $text_val ne ''; } if ($price_val ne '') { $price_val =~ tr/0-9./ /c; $price_val =~ s/\s+//g; $price_val =~ s/\D/ /g; ($dollars,$cents,$a) = split(/\s+/,$price_val,3); $price_val = &format_num($dollars.'.'.$cents); $price_val = '' if $price_val <= 0; } if (!$product_arg || $product_arg eq $categories_desc) { $product_arg = ''; foreach (@categories) { $cat{$_}++ } } if (defined($in{'env'}) && $in{'env'} =~ /dbase/i) { $dbase_chk = '1'; %db_nums = (); } else { $dbase_chk = '' } $row_count = 0; &read_open($data_file); while () { s/\s+$//; next if /^$|^COMMENT:/i; if (&item_row($_) && &valid_id($db_id_num)) { $a = $db_row[$category_fld_num]; # Duplicate id checking if ($dbase_chk) { if (defined($db_nums{$db_id_num})) { close(FILE); &dbase_error; } $db_nums{$db_id_num}++; } if ($product_arg && $a eq $product_arg) { push(@SEARCH_CONTENTS,$_); ++$row_count; } elsif (!$product_arg) { if (defined($cat{$a})) { push(@SEARCH_CONTENTS,$_); ++$row_count; } } # Exit FILE - category found elsif ($row_count && !$dbase_chk) { last } } } close(FILE); $match_found = $row_count = $search_rows = 0; &next_prev_first; while (@SEARCH_CONTENTS) { $matched_row = shift(@SEARCH_CONTENTS); @db_row = split(/\|/,$matched_row); $item_price = &format_num($db_row[$price_fld_num]) if $price_val; if ($price_val && $text_val ne '') { if ($text_arg =~ /^K/) { foreach (@keywords) { if ($matched_row =~ /\b$_\b/i) { &eq_gt_lt; last; } } } else { &eq_gt_lt if $matched_row =~ /$text_val/i } } elsif ($text_val ne '') { if ($text_arg =~ /^K/) { foreach (@keywords) { if ($matched_row =~ /\b$_\b/i) { ++$match_found; last; } } } else { ++$match_found if $matched_row =~ /$text_val/i } } elsif ($price_val) { &eq_gt_lt } else { ++$match_found } # End if ($price_val && $text_val ne '') if ($match_found) { &next_prev; $match_found = 0; } } # End while (@SEARCH_CONTENTS) $next = 1 if !$next && !$previous && ($search_rows > $max_items); # "Keywords" or "Keyword" chop $text_arg if $text_val ne '' && $text_arg =~ /^K/ && (scalar(@keywords) == 1); # Search arguments found - display matches to client if ($row_count) { &html_header('Search Results'); if (defined(%cart_errors)) { print &cart_errors } elsif ($cart_error) { print $cart_error } elsif ($pre_category) { &pre_category_html; &print_text_file($product_arg,'C-HDR') if $pre_category eq '2'; } $search_tags = 'Y'; &hidden_form_tags(); &disp_table_vars(@SEARCH_RESULT); $table_title .= ' - Search Results' if $table_title; &table_title($table_title,$table_border,$table_width); $b = (split(/\./,&format_num($curr_item,'Y')))[0]; if ($max_items == 1 || ($first == $total_items)) { $a = '' } else { $a = 's'; $b = (split(/\./,&format_num($first_item,'Y')))[0].' - '.$b; } print "\n$hrd_fnt_tag${SPACE}Search returned item$a ". "$b of ".(split(/\./,&format_num($total_items,'Y')))[0]." for$SPACE "; print "$SPACE\L$text_arg ".&convert_ext($text_val)."$SPACE " if $text_val ne ''; print "$SPACE\L$price_arg $currency".&format_num($price_val,'Y')."$SPACE " if $price_val; if (!$product_arg) { print "$SPACEall categories$SPACE " } else { print "$SPACE".&convert_ext($product_arg)."$SPACE " } print '
'; &print_fields(@SEARCH_RESULT); print "\n$SPACE" if $table_border; print "\n\n
" if !$table_width; &print_next_prev; print "\n" if $next || $previous; print "\n\n

\n\n

$button_5$button_1$button_2$button_3$button_4\n$rst_button\n
\n\n\n"; undef $search_tags; &hidden_form_tags(); print "

$SPACE\n\n

"; &search_engine_form; print "
\n\n\n"; if ($category_trailer) { &category_trailer_html; &print_text_file($product_arg,'C-TRL') if $category_trailer eq '2'; } } else { &html_header('Search Results'); &hidden_form_tags(); print "
\n"; $nothing_found = 1; &search_engine_form; print "

$button_1$button_2$button_3$button_4\n

\n\n\n"; } # End if ($row_count) &html_trailer; } ############################################ sub next_prev_first { if ($next || $previous || $first) { if ($next) { # More items to display NEXT if (($curr_item + $max_items) < $total_items) { $first_item = ($curr_item + 1); $next = $previous = 1; } # No more items to display NEXT elsif (($curr_item + $max_items) >= $total_items) { $first_item = ($curr_item + 1); $next = 0; $previous = 1; } } elsif ($first && $in{'continue_shopping'}.$in{'submit_deletion'}.$in{'add_cart'}.$cart_error) { $first_item = $first; if (($first - $max_items) <= 0) { $previous = 0 } else { $previous = 1 } if (($first_item + $max_items - 1) >= $total_items) { $next = 0 } else { $next = 1 } } elsif ($first && $previous) { $first_item = ($first - $max_items); if (($first - 1 - $max_items) <= 0) { $previous = 0 } else { $previous = 1 } $next = 1; } $last_item = ($first_item + $max_items - 1); } else { $first_item = $curr_item = 1; $last_item = $max_items; } # End if ($next || $previous || $first) $first = $first_item; } ############################################ sub next_prev { ++$search_rows; if ($next || $previous) { if (($search_rows >= $first_item) && ($search_rows <= $last_item)) { $curr_item = $search_rows; ++$row_count; push(@SEARCH_RESULT,$matched_row); } } else { ++$total_items if !$in{'total_item'}; if ($search_rows <= $last_item) { $curr_item = $search_rows; ++$row_count; push(@SEARCH_RESULT,$matched_row); } } } ############################################ sub print_next_prev { if ($next || $previous) { print "\n\n

\n\n

"; # Singular/plural button wording if ($max_items == 1) { $g = '' } else { $g = 's' } if ($max_items == 1 || ($total_items - $curr_item <= 1)) { $h = '' } else { $h = 's' } print qq!\n ! if $previous; print qq!\n ! if $next; } } ############################################ sub eq_gt_lt { if ($price_arg =~ /^E/ && $item_price == $price_val) { ++$match_found } elsif ($price_arg =~ /^G/ && $item_price > $price_val) { ++$match_found } elsif ($price_arg =~ /^L/ && $item_price < $price_val) { ++$match_found } } ############################################ sub search_engine_form { my ($a, $b, $msg, $opt_sel1, $opt_sel2, $opt_sel3, $price_value, $qs, $rows, $text_value); $qs = $price_value = $text_value = ''; $text_value = ' VALUE="'.&convert_ext($text_val).'"' if $text_val ne ''; $price_value = ' VALUE="'.&format_num($price_val,'Y').'"' if $price_val ne ''; # $opt_sel1 if (!$text_arg || $text_arg =~ /^K/) { $opt_sel1 = qq!\n\t

$SPACE\n" if !$row_count; print "\n\n$table_open\n"; if ($search_border) { if ($nothing_found) { $rows = 6 } else { $rows = 5 } print "$SPACE". "$SPACE". "$SPACE\n" } print qq!$hr_fnt_tag$SPACE Search $global_page_title $SPACE $SPACE $ch_col_spc $tips $SPACE $ch_col_spc $SPACE Do not use your "Enter key" use the "SEARCH" button.\n!; $product_arg = '' if $product_arg eq $categories_desc; if ($nothing_found) { $msg = ''; $msg = "$text_arg" if $text_val ne ''; if ($price_val ne '') { $msg .= ' and ' if $msg; $msg .= "$field_names[$price_fld_num]"; } if ($msg && $product_arg) { $msg = $msg." not found in $product_arg" } elsif ($msg && !$product_arg) { $msg .= ' not found in All Categories' } elsif ($product_arg) { $msg = "$product_arg not found" } else { $msg = 'No categories configured for Search' } print "\n$hrd_fnt_tag$SPACE$msg$SPACE\n"; } print "\n$SPACE\n" if $search_border; print "\n"; } ############################################ sub get_cart_row { my ($row) = @_; @ct_row = split(/\|/,$row); $quantity = shift(@ct_row); $dd1_string = shift(@ct_row); $dd2_string = shift(@ct_row); $ct_rw_num = $ct_row[$#ct_row]; chop $ct_rw_num; if (!$admin_msg) { unshift(@ct_row,$dd2_string); unshift(@ct_row,$dd1_string); if ($dbase_weights) { $wt_string = $ct_row[$ship_fld_num]; $wt_string =~ tr/0-9./ /c; $wt_string =~ s/\s+//g; $wt_string = sprintf("%.4f",$wt_string); } elsif (defined($ship_fld_num)) { $sp_string = $ct_row[$ship_fld_num]; $sp_string =~ s/\s+//g; } return; } # Remove color code, size code, delimiters for e-mail and order page if ($dd2_string =~ /~{2}/) { unshift(@ct_row,(split(/~{2}/,$dd2_string))[1]) } else { unshift(@ct_row,$dd2_string) } if ($dd1_string =~ /~{2}/) { unshift(@ct_row,(split(/~{2}/,$dd1_string))[1]) } else { unshift(@ct_row,$dd1_string) } } ############################################ sub get_form { return if $form; ($form) = @_; $form .= '.setup' if $form !~ /\.setup$/; &form_error('FORM File not Found') if $form ne $form_file && !-e $data_directory.'/'.$form; &file_status(__FILE__, __LINE__, 'req', $libr_directory.'/'.'WSForms.pl', $data_directory.'/'.$form, ); # Separation permits redefinition of $country_file in $form &file_status(__FILE__, __LINE__, 'req', $data_directory.'/'.$country_file); if ($form eq $form_file) { if (defined(%OrderForm)) { &getOrderFormVars } else { &form_error('%OrderForm not Defined') } } elsif (defined(%OrderForm)) { &form_error('Invalid %OrderForm Use') } elsif ($cart_id) { if ($in{'form'} && !defined(%Form)) { &form_error('%Form not Defined') } elsif ($in{'client_form'} && !defined(%ClientForm)) { &form_error('%ClientForm not Defined') } } if ($dt_font > 3) { $dt_font = '2'; $data_font = 'SIZE=2'; $header_font = 'SIZE=3'; } sub form_error { my ($error) = @_; $in{'client_form'} = $in{'form'} = ''; &frontpage("$error: $SPACE$SPACE $data_directory/$form $SPACE"); } } ############################################ sub drop_down { my ($num, @elements) = @_; my ($a, $b, $c, $element); $b = $c = ''; if ($cart_error && $in{$num} ne '') { $c = &convert_ext($in{$num}); $b = ' VALUE="'.$c.'"'; $c .= " \n\t".' ".&drop_down('dd1_'.$id_num, @{ $DD1_FIELDS{$dd1} })."$SPACE "; } else { $b = 'No values in $DD1_FIELDS{'.$dd1.'}' } } else { $b = '$DD1_FIELDS{'.$dd1.'} not defined'; ++$d; } $dropdowns .= "$SPACE $smdt_fnt_tag$b $SPACE " if $b; } # Size field if ($dd2 ne '') { if (defined($DD2_FIELDS{$dd2})) { $a = join('',@{ $DD2_FIELDS{$dd2} }); $a =~ s/\s+//g; if ($a =~ /\w+/) { $dropdowns .= "$SPACE $dt_fnt_tag$field_names[1] ".&drop_down('dd2_'.$id_num, @{ $DD2_FIELDS{$dd2} })."$SPACE "; } else { $c = 'No values in $DD2_FIELDS{'.$dd2.'}' } } else { $c = '$DD2_FIELDS{'.$dd2.'} not defined'; ++$d; } $dropdowns .= "$SPACE $smdt_fnt_tag$c $SPACE " if $c; } if ($b || $c) { $drop_down_error = 'Y'; if ($b && $c) { $a = 's' } else { $a = '' } $dd_hdr = "Error${a} in $store"; if ($d) { if ($search || $in{'submit_search'} || $in{'category'} !~ /\.htm[l]*$/) { $dd_hdr .= " or record $id_num in $data_file1" } elsif ($in{'item_id'} && $in{'category'} =~ /\.htm[l]*$/) { $dd_hdr .= ' or query string on HTML page' } } } } ############################################ # Read $file sub get_file { my ($file) = @_; my (@FILE, $contents); &read_open($file); read(FILE, $contents, -s $file); close(FILE); #qqq if ($in{'rsc'} && $in{'r_data'} && defined(@reseller_include_files) && @reseller_include_files) { my ($a, $logo, $logo_img, %RESELLERS, @r_data, $text, $text_file); $logo = $logo_directory.'/'.$in{'rsc'}; foreach ('.gif','.jpg','.jpeg','.png') { next if !-e $logo.$_ || !-r $logo.$_; $logo_img = qq!!; $logo_img = qq!$logo_img! if defined($in{'rsc_rfw'}) && $in{'rsc_rfw'} =~ /^http:/; last; } %RESELLERS = (); @r_data = split(/\|/,$in{'r_data'}); foreach (sort keys %RESELLER_FIELDS) { $a = $RESELLER_FIELDS{$_}[0]; $RESELLERS{$a} = shift(@r_data); delete $RESELLERS{$a} if $a =~ /img$|imgSave$/i || (defined($RESELLERS{$a}) && $RESELLERS{$a} !~ /\w+/); } delete $RESELLERS{'name'} if defined($RESELLERS{'company'}); foreach (@reseller_include_files) { $file = $_; $text_file = $html_directory.'/'.$file; next if $_ !~ /\w+/ || $contents !~ // || !-e $text_file; &read_open($text_file); read(FILE, $text, -s $text_file); close(FILE); $text = (split(/__END__/,$text))[0]; foreach (keys %RESELLERS) { $text =~ s//$RESELLERS{$_}/gi } $text =~ s//$logo_img/gi if $logo_img; $contents =~ s//$text/gi; } } if (defined(@include_files) && @include_files) { my ($text, $text_file); foreach (@include_files) { $file = $_; $text_file = $html_directory.'/'.$file; next if $_ !~ /\w+/ || $contents !~ // || !-e $text_file; &read_open($text_file); read(FILE, $text, -s $text_file); close(FILE); $contents =~ s//\n$text\n/g; } } $contents =~ s/\n

\n$table_open $dt_fnt_tag$SPACE $type Error: $SPACE$msg $SPACE \n
\n"; } ############################################ sub print_search { &hidden_form_tags(); print "\n
\n"; &search_engine_form; if ($minimum_order || $grand_total) { print "\n

$SPACE\n\n"; &subtotal_msg; } print "

\n\n
\n

$button_1$button_2$button_4\n

\n\n\n"; } ############################################ # Print HTML page or database category sub disp_sale_items { &submit_search if $search && !$in{'category_page'}; my ($a, $b, $category, $dbase_chk, %db_nums, $value); &count_cart_rows; $row_count = $in{'tax'} = ''; $cart_error = &cart_errors if defined(%cart_errors); if (defined(@buy_item)) { $row_count = 1; $category = $db_row[$category_fld_num]; @CATEGORY_CONTENTS = @buy_item; } else { if ($in{'category'} =~ /\.htm[l]*$/i && !$in{'view_item'}) { #qqq &frontpage("Invalid Database Id in Query String: $SPACE$SPACE \&item_id=$item_id $SPACE$SPACE Id's are Numeric Only $SPACE") if $item_id && $dbase_id_fld_num !~ /\d+/ && $item_id !~ /^\d+$/; undef $cpage; $page = $in{'page'} = $in{'category'} if !$page && !$pcat; if (-e $html_directory.'/'.$in{'category'}) { &get_html_page($in{'category'}) } else { &frontpage("HTML File not Found: $SPACE$SPACE $html_directory/$in{'category'} $SPACE") } while (@HTML_FILE) { $row = shift(@HTML_FILE); # Search engine help page if ($search_engine && $search_tips && $in{'category'} eq $search_tips) { if ($row =~ /\n

$SPACE\n"; if ($item_id) { &get_drop_downs($in{'d1'}, $in{'d2'}, $in{'item_id'}) if $in{'d1'} ne '' || $in{'d2'} ne ''; my $x = $in{'item_pr'}; if ($x ne '') { $x = &format_num($x,'Y') } else { $x = 'N/A' } print "$table_open\n"; $this_bg_clr = $data_bkg_clr; $value = ''; if ($cart_error) { $a = $in{'item_id'}; $value = ' VALUE="'.&convert_ext($in{$a}).'"' if $in{$a} ne ''; } if (defined(%cart_errors)) { if ($dropdowns) { $a = '9' } else { $a = '7' } print qq!Top\n!; } if ($drop_down_error && $drop_down_error1) { $dd_hdr .= " $SPACE
\n\t$SPACE ".$dd_hdr1; $drop_down_error .= $drop_down_error1; $dropdowns .= '


'.$dropdowns1; } elsif (!$drop_down_error && $drop_down_error1) { $dd_hdr = $dd_hdr1; $drop_down_error = $drop_down_error1; $dropdowns = $dropdowns1; } &add_cart_button; if ($dropdowns || $drop_down_error) { # Quantity, drop downs, and Price if ($minimum_order || $grand_total) { print "$dt_fnt_tag$subtotal_msg$min_order_msg\n" } else { $this_bg_clr = $dsc_hr_bkg_clr; } # %DD1_FIELDS - %DD2_FIELDS error if (!$drop_down_error) { print "$SPACE $dh_fnt_tag${SPACE}Quantity$SPACE$SPACE $dh_fnt_tag$dd_hdr$ch_col_spc $dh_fnt_tag$SPACE$field_names[$price_fld_num]$SPACE $SPACE"; } else { print "$SPACE $error_fnt_tag$dd_hdr $SPACE" } print qq!\n$ch_col_spc $ac_button $dropdowns$ch_col_spc $dt_fnt_tag $x $ch_col_spc\n!; } # Quantity and Price - No drop downs else { print "$dh_fnt_tag$subtotal_msg$min_order_msg\n" if $minimum_order || $grand_total; print qq!$ch_col_spc $dt_fnt_tagQuantity: $SPACE $ac_button $dt_fnt_tag$field_names[$price_fld_num]: $SPACE $x $ch_col_spc\n!; } print "\n
\n\n
\n

$SPACE\n\n$button_5 "; } else { if ($minimum_order || $grand_total) { &subtotal_msg; print "

\n\n
\n

"; } } print $button_1; print $button_2 if $in{'category'} ne $frontpage_file; print $button_3 if $page ne $in{'category'}; if ($in{'d1'} ne '' || $in{'d2'} ne '') { print "$button_4\n$rst_button\n\n" } else { print "$button_4\n\n"; } &search_engine_form if $search_engine; print "

\n\n\n"; # Output frontpage trailer html &frontpage_trailer_html if $frontpage_trailer && $in{'category'} eq $frontpage_file; &html_trailer; } else { &substitute($row,''); print $cart_error if $row =~ /) { s/\s+$//; next if /^$|^COMMENT:/i; if (&item_row($_) && &valid_id($db_id_num)) { # Duplicate id checking if ($dbase_chk) { if (defined($db_nums{$db_id_num})) { close(FILE); &dbase_error; } $db_nums{$db_id_num}++; } if ($in{'view_item'}) { next if $in{'view_item'} ne $db_row[$item_fld_num]; $category = $db_row[$category_fld_num]; $in{'category'} = $db_id_num; undef @CATEGORY_CONTENTS; push(@CATEGORY_CONTENTS,$_); $row_count = 1; last if !$dbase_chk; } elsif ($in{'category'} eq $db_id_num) { $category = $db_row[$category_fld_num]; undef @CATEGORY_CONTENTS; push(@CATEGORY_CONTENTS,$_); $row_count = 1; last if !$dbase_chk; } elsif ($db_row[$category_fld_num] eq $in{'category'}) { push(@CATEGORY_CONTENTS,$_); ++$row_count; } # Exit FILE - complete category found elsif ($row_count && !$dbase_chk) { last } } } close(FILE); if (!$row_count) { if ($in{'view_item'}) { &frontpage("Item $in{'view_item'} not available in $data_file1 $SPACE") } elsif ($in{'category'} =~ /^\d+$/) { &frontpage("Record number $in{'category'} not available in $data_file1 $SPACE") } else { &frontpage("No records available for $in{'category'} in $data_file1 $SPACE") } } elsif ($row_count > $max_items) { $cpage = 'Y'; $row_count = $search_rows = 0; &next_prev_first; while (@CATEGORY_CONTENTS) { $matched_row = shift(@CATEGORY_CONTENTS); &next_prev; } undef @CATEGORY_CONTENTS; unshift(@CATEGORY_CONTENTS,@SEARCH_RESULT); undef @SEARCH_RESULT; $next = 1 if !$next && !$previous; } } # End if (defined(@buy_item)) $category = $in{'category'} if !$category; $category = &convert_ext($category); &html_header($category); # Preface category pages if ($cart_error) { print $cart_error } elsif ($pre_category) { &pre_category_html; &print_text_file($in{'category'},'C-HDR') if $pre_category eq '2'; } &hidden_form_tags(); &disp_table_vars(@CATEGORY_CONTENTS); # title row &table_title($table_title,$table_border,$table_width); print "\n$hrd_fnt_tag"; if ($cpage) { $b = (split(/\./,&format_num($curr_item,'Y')))[0]; if ($max_items == 1 || ($first == $total_items)) { $a = '' } else { $a = 's'; $b = (split(/\./,&format_num($first_item,'Y')))[0].' - '.$b; } print "${SPACE}Item$a $b of ".(split(/\./,&format_num($total_items,'Y')))[0]."$SPACE "; } print "$SPACE$category$SPACE"; &print_fields(@CATEGORY_CONTENTS); print "\n$SPACE" if $table_border; print "\n\n" if !$table_width; &print_next_prev; print "\n" if $next || $previous; print "\n\n

\n\n

$button_5$button_1$button_2$button_3$button_4\n$rst_button\n
\n\n\n"; if ($category_trailer) { &category_trailer_html; &print_text_file($in{'category'},'C-TRL') if $category_trailer eq '2'; } &html_trailer; } ############################################ sub item_row { my ($row) = @_; @db_row = split(/\|/,$row); #qqq if ($dbase_id_fld_num =~ /\d+/) { $db_id_num = $db_row[$dbase_id_fld_num] } else { $db_id_num = $db_row[$#db_row] } # Item row return(1) if $db_id_num ne '' && $db_row[$category_fld_num] ne ''; return(); } ############################################ sub valid_id { my ($num) = @_; #qqq return(1) if ($dbase_id_fld_num =~ /\d+/ && $num =~ /\S+/) || $num =~ /^\d+$/; close(FILE); &dbase_error; } ############################################ sub dbase_error { my ($a, $b, $c, $d, $e, $f, $alpha, $file1, $file2, @inv_ids, @dirs, @dup_ids, %db_nums, $font1, $font2, $match, @nums, $script, $special); &read_open($data_file); while () { s/\s+$//; next if /^$|^COMMENT:/i; if (&item_row($_)) { $a = $db_id_num; if (defined($db_nums{$a})) { push(@dup_ids,''.&convert_ext($a).' - '.$db_row[$category_fld_num].' Category') } else { $db_nums{$a}++ } #qqq if ($dbase_id_fld_num !~ /\d+/ && $a !~ /^\d+$/) { push(@inv_ids,''.&convert_ext($a).' - '.$db_row[$category_fld_num].' Category'); $special = $a =~ tr/A-Za-z0-9_/ /c if !$special; $alpha = $a =~ tr/0-9/ /c if !$alpha; } } } close(FILE); $a = ''; if (@duplicate_ids && !@dup_ids && !@inv_ids) { $c = $d = $e = $font1 = $font2 = $match = ''; $f = '.'; if (scalar(@duplicate_ids) > 1) { $b = 's' } else { $b = '' } if (!$in{'cart_id'} || !$in{'category'} || $ENV{'QUERY_STRING'}) { if ($ENV{'QUERY_STRING'}) { $a = 'Invalid Query String'; $e = 'query strings'; $font1 = ''; $font2 = ''; $c = '?'.$ENV{'QUERY_STRING'}; $c =~ s/&/&/g; foreach (@duplicate_ids) { foreach $d (@nums) { if ($d eq $_) { ++$match; last; } } if (!$match) { $c =~ s/\&$_=/\&$font1$_$font2=/g; $c =~ s/^\?$_=/\?$font1$_$font2=/; push(@nums,$_); } else { $match = '' } } $d = ''; $c =~ s/&/&/g; $c = ' in query string:
'."\n    $c
"; if ($ENV{'HTTP_REFERER'} =~ /\.[sp]{0,1}htm[l]{0,1}$/i) { $d = qq!Error occurred on $ENV{'HTTP_REFERER'}! } } elsif ($ENV{'HTTP_REFERER'} =~ /\.[sp]{0,1}htm[l]{0,1}$/i) { $c = qq! on $ENV{'HTTP_REFERER'}! } } elsif ($in{'category'} =~ /\.htm[l]*$/i) { $c = ' on '.$html_directory.'/'.$in{'category'} } if (!$a) { $a = 'Form name=value Error'.$b; $f = ':
    <INPUT TYPE="text" NAME="'.$duplicate_ids[0].'" SIZE=3 MAXLENGTH=5>
'; $e = 'quantity text inputs'; } $d = "Duplicated name=value pair$b:".&id_errors(@duplicate_ids) if !$d; &file_error( $a,"Duplicate ${font1}name${font2}=value pair$b$c", $d, "Database Id name=value pairs defined in $e must be unique$f", &file_perm() ); } if (@dup_ids) { if (scalar(@dup_ids) > 1) { $b = 's' } else { $b = '' } $a .= "\nDuplicated Database Id Number$b:"; $a .= &id_errors(@dup_ids); } if (@inv_ids) { if (scalar(@inv_ids) > 1) { $b = 's' } else { $b = '' } $a .= "\n"; $a .= 'Alpha' if $alpha; $a .= ' and ' if $alpha && $special; $a .= 'Special' if $special; $a .= " Characters in Database Id Number$b:"; $a .= &id_errors(@inv_ids); $c = ' are numeric only (0-9) and'; } $file1 = 'ws_editor.cgi'; if ($ENV{'SCRIPT_FILENAME'} =~ m#^/#) { @dirs = split(/\//,$ENV{'SCRIPT_FILENAME'}); $file2 = pop(@dirs); $script = join('/',@dirs).'/'.$file1; if (-r $script && -x $script) { $script_url =~ s/$file2$/$file1/g; $file1 = qq!$file1!; } } if (scalar(@dup_ids) + scalar(@inv_ids) > 1) { $b = 's' } else { $b = '' } &file_error("Invalid Database Id$b", "Invalid Database Id Number$b in $data_file", $a, "Database id numbers$c must be unique to each item in the database.", "Correct id numbers with $file1 using Sort/Add or Sort/Remove.", &file_perm()); sub id_errors { my (@errors) = @_; my $a = ''; $a .= "\n\t
    "; foreach (sort @errors) { $a .= "\n\t
  • $_" } $a .= "\n\t
"; } } ############################################ sub substitute { my ($row, $front_frames) = @_; my $qs = ''; if ($row =~ /cart_id=/) { # Allow setup file switching if ($store ne $default_setup_file && $row !~ /store=/) { $qs .= '&store='.$store; $qs =~ s/\.setup$//; } # No search engine $qs .= '&no_search='.$no_search.$in{'no_search'} if ($no_search || $in{'no_search'}) && $row !~ /no_search=/; $q_string = &query_string() if !defined($q_string); # Substitute &page= if it does not exists in $row if (!$front_frames) { $qs .= '&page='.$page if $page && $row !~ /page=/ } # Preserve incoming query string - Frames and new cart file elsif ($front_frames eq 'Y' && $in{'nc'} eq $cart_id && !$new_cart) { $new_cart = '&nc='.$cart_id; foreach (sort keys %in) { $new_cart .= '&'.$_.'='.$in{$_} if $_ =~ /^nc_/ } $new_cart =~ s/\s+/+/g; } $row =~ s/cart_id=/cart_id=$cart_id$qs$new_cart$q_string&dci=/g; } if (defined($bdy_frm_tags) && $bdy_frm_tags > 1) { if (!defined($CART_ID)) { $CART_ID = qq!!; $CART_ID .= qq!\n! if defined($in{'env'}); my @a = ('c_file','demo','no_search','ns','no_ssl','pwd','uid'); push(@a, @rs_fields) if $rs_code ne ''; foreach (sort @a) { $CART_ID .= qq!\n' if defined($in{$_}) && $in{$_} ne ''; } $HIDDEN_TAGS = $CART_ID; foreach ('store','category','frames','form','page','pcat','item_id','item_pr','d1','d2','rfw') { $HIDDEN_TAGS .= qq!\n' if defined($in{$_}) && $in{$_} ne ''; } $PAGE = qq!! if $page; $STORE = qq!!; } $row =~ s/<\!--\s*CART_ID\s*-->/$CART_ID/g; $row =~ s/<\!--\s*HIDDEN_TAGS\s*-->/$HIDDEN_TAGS/g; $row =~ s/<\!--\s*PAGE\s*-->/$PAGE/g if defined($PAGE); $row =~ s/<\!--\s*STORE\s*-->/$STORE/g; } print $row; } ############################################ sub hidden_form_tags { my ($form) = @_; my (@tags); %form_tags = (); print qq!\n
!; print qq!\n! if $cart_id; &print_tags('c_file','demo','uid','pwd','page','pcat','formfile'); if (!$form) { @tags = ('category','name_vals'); push(@tags,'retry') if !defined($first_access); if (defined($send_order)) { push(@tags,'ship'); &print_form_tags(%OrderForm); } elsif (defined($print_tags)) { &print_tags(@client_fields) } elsif ($in{'form'}) { push(@tags,'form','frames','ship') } elsif ($in{'client_form'} || !$cart_id) { push(@tags,'client_form','frames','ship') } elsif (defined(%ClientForm)) { push(@tags,'ship') } } elsif ($in{'client_form'} || !$cart_id) { @tags = ('category','frames') } &print_tags('item_id','item_pr','d1','d2') if $item_id || (!$cart_id && $in{'item_id'}); if (!$cart_id) { &print_tags(@name_values) if @name_values; &print_tags('pd','ud') if $password_file; } print qq!\n! if $in{'no_search'}; print qq!\n! if $in{'ns'}; print qq!\n! if $in{'no_ssl'}; # Preserve search variables if ($cart_id && ($cpage || ($search_engine && ($in{'submit_search'} || $search)))) { if ($cpage) { print qq!\n! } else { print qq!\n! } # View/Modify, Invalid Value, Minimum Order, and # Return to Category pages during a search if (defined($search_tags) || ($cpage.$search && (($in{'add_cart'} && !$display_category) || ($in{'submit_deletion'} && -s $user_cart) || "$in{'submit_changes'}$in{'modify_cart'}$in{'delete_item'}$in{'security'}"))) { &print_tags('text_val','price_val','text_arg','price_arg','product_arg'); if (defined($search_tags)) { &item_tags } else { &print_tags('first','curr_item','total_item') } } else { &item_tags } } # End if ($search_engine &print_tags(@rs_fields) if $rs_code ne ''; push(@tags,'tax'); &print_tags(@tags); print qq!\n! if defined($in{'env'}); print qq!\n! if defined($security) && $security; print qq!\n! if defined($in{'noLoad'}); print "\n\n"; } ############################################ sub item_tags { if ($next || $previous || $first) { print qq!\n !; } } sub print_tags { my (@array) = @_; %form_tags = () if !defined(%form_tags); foreach (sort @array) { if (!defined($form_tags{$_})) { print qq!\n' if defined($in{$_}) && ($in{$_} ne '' || !$cart_id); $form_tags{$_}++; } } } ############################################ sub print_cart_row { my ($type) = @_; my ($a, $al, $b, $client_dd1, $client_dd2, $dd1_index, $dd2_index, $font1, $font2, $subtotal, $x); print "\n"; if ($type) { if (!defined(%cart_errors)) { $a = $m_col_spc } else { $a = qq!!; if (defined($cart_errors{$ct_rw_num})) { $a .= qq!Top$SPACE$SPACE! } else { $a .= $SPACE } $a .= ''; } print "$type\n$a\n"; } ($dd1_index, $client_dd1) = split(/~{2}/,$dd1_string) if $ct_row[0] =~ /~{2}/; ($dd2_index, $client_dd2) = split(/~{2}/,$dd2_string) if $ct_row[1] =~ /~{2}/; foreach (@modify_display_numbers) { $font1 = $md_fnt_tag; $font2 = ''; if ($_ eq '0') { if (!$change_qty && $ct_row[0] =~ /~{2}/) { $ct_row[$_] = &convert_ext($client_dd1) } # drop down for Change Quantitiy elsif ($change_qty && $ct_row[0] =~ /~{2}/) { $a = 'dd1_'.$ct_rw_num; $b = qq!'; $ct_row[$_] = $b; $font1 = $font2 = ''; } else { $ct_row[$_] = '' } } if ($_ eq '1') { if (!$change_qty && $ct_row[1] =~ /~{2}/) { $ct_row[$_] = &convert_ext($client_dd2) } # drop down for Change Quantitiy elsif ($change_qty && $ct_row[1] =~ /~{2}/) { $a = 'dd2_'.$ct_rw_num; $b = qq!'; $ct_row[$_] = $b; $font1 = $font2 = ''; } else { $ct_row[$_] = '' } } $x = $ct_row[$_]; if ($x eq '') { $x = 'N/A' } elsif ($_ eq $price_fld_num) { $x = &format_num($x,'Y') } if ($modify_fields_array{$_} =~ /^(left|center|right)$/i) { $al = $modify_fields_array{$_} } else { $al = 'left' } print "$font1$x$font2\n$m_col_spc\n"; } # End foreach (@modify_display_numbers) print "$md_fnt_tag$quantity\n$m_col_spc\n"; $subtotal = &format_num($quantity*$ct_row[$price_fld_num]); $grand_total += $subtotal; print "$md_fnt_tag".&format_num($subtotal,'Y')." \n\n$m_row_spc\n\n"; } ############################################ sub subtotal_msg { $subtotal_msg = '' if !$grand_total; print "\n<\!-- Subtotal Table -->\n$table_open $dt_fnt_tag$subtotal_msg$min_order_msg \n"; } ############################################ sub print_fields { my (@ITEMS) = @_; my ($a, $b, $c, $al, $align, $b_inner_img_clr, $b_outer_img_clr, $e_inner_img_clr, $e_outer_img_clr, $img_LRT, $height, $img_src, $item_ref, $l_img_src, $no_img, $r_img_src, $t_img_src, $table_align, $value, $width, $x, $y); if ($img_spacing >= $spc_width && $img_spacing !~ /^\D+$/) { $height = $img_spacing } elsif ($spc_width && $spc_width !~ /^\D+$/) { $img_spacing = $height = $spc_width } else { $img_spacing = $height = 7 } $img_padding = '0' if !$img_padding || $img_padding =~ /\D/; if ($outer_clr_width && $outer_img_clr ne '') { $outer_img_clr = qq! BGCOLOR="$outer_img_clr"! } else { $outer_clr_width = '0'; $outer_img_clr = ''; } if ($inner_clr_width && $inner_img_clr ne '') { $inner_img_clr = qq! BGCOLOR="$inner_img_clr"! } else { $inner_clr_width = '0'; $inner_img_clr = ''; } $subtotal_msg = '' if !$grand_total; print "\n$dh_fnt_tag$subtotal_msg$min_order_msg" if $minimum_order || $grand_total; &add_cart_button; my $spc_row1 = "\n\t "; my $spc_row2 = "\n\t "; my $spc_row3 = " "; my $TABLE = qq!\n\t!; $item_separator =~ s/^\s+//g; $item_separator =~ s/\s+$//g; if ($item_separator) { $item_separator =~ s/\s{2,}/ /g; $item_separator = "\n\n\n\n
\n
\n". '"; $img_LRT = 'T'; } $img_src = &chk_cart_id($img_src, $x); $b_inner_img_clr = $b_outer_img_clr = $e_outer_img_clr = $e_inner_img_clr = ''; if ($img_border || ($outer_clr_width && $outer_img_clr)) { $b_outer_img_clr = "
!; last; } $img_src = (split(/~~/,$db_row[$image_fld_num]))[0].'~~'.$img_src if $img_src && $db_row[$image_fld_num] =~ /^\w{1,2}~~/; $item_ref = qq!!; } $img_src = $db_row[$image_fld_num] if !$img_src && length($db_row[$image_fld_num]) > 6; if ($img_src) { if ($img_src =~ /~~/) { ($img_LRT, $img_src) = split(/~~/,$img_src) } else { $img_LRT = 'L' } # syntax check if ($img_src !~ /((]+/i && $img_src !~ /((]+/i) { $t_img_src = "\n\t $error_fnt_tag$SPACEImage Syntax Error: $SPACE Record id $db_id_num, field $image_fld_num in $data_file1$SPACE
$SPACE".&convert_ext($img_src)."$SPACE
"; $e_outer_img_clr = '
'; } if ($inner_clr_width && $inner_img_clr) { $b_inner_img_clr = ""; $e_inner_img_clr = '
'; } $img_src = "
$b_outer_img_clr$b_inner_img_clr$img_src$e_inner_img_clr$e_outer_img_clr
"; if ($img_LRT eq 'R') { $r_img_src = "$img_src"; $l_img_src = $c_col_spc; $align = 'left'; $table_align = 'right'; } elsif ($img_LRT =~ /^T/) { $img_width = ' WIDTH="100%"' if $table_width; if ($img_LRT eq 'TR') { $a = 'right'; $align = 'left'; } elsif ($img_LRT eq 'TL') { $a = 'left' } else { $a = $align = 'center' } $t_img_src .= "\n\t$img_src" if !$t_img_src; $l_img_src = $r_img_src = $c_col_spc; $table_align = 'center'; } else { $l_img_src = "$img_src"; $r_img_src = $c_col_spc; } } else { $l_img_src = $r_img_src = $c_col_spc; $no_img = '1'; } print "\n\n\n"; print "\n
\n" if $table_width && $table_tag; $a = $value = ''; if (defined(%cart_errors)) { $item_ref = qq!!; $value = ' VALUE="'.&convert_ext($in{$db_id_num}).'"' if $in{$db_id_num} ne ''; $item_ref .= qq!$SPACETop$SPACE! if defined($cart_errors{$db_id_num}); } elsif (!$item_ref) { $item_ref = qq!! } print "\n$b"; } elsif ($db_row[$a] ne '') { print "\n\t
$item_ref". "\n\t$t_img_src"; $dropdowns = $dd_hdr = ''; &get_drop_downs($db_row[0], $db_row[1], $db_id_num) if $db_row[0] ne '' || $db_row[1] ne ''; if ($db_row[$price_fld_num] ne '') { $price = &format_num($x,'Y') } else { $price = 'N/A' } # Output rows admin has set for display print $spc_row1 if $no_img; print "\n\t$l_img_src\n\n\t"; if (@vertical_numbers) { my ($att, $tag1, $tag2, $tag3, $tag4, $val, $label, $no_label); my $tag = ''; print $TABLE; foreach (@vertical_numbers) { ($a, $att) = split(/:/,$_); if ($a eq '') { print $spc_row2; next; } if ($fields_array{$a} =~ /^(left|center|right)$/i) { $al = $fields_array{$a} } else { $al = 'left' } $tag1 = $tag2 = $tag3 = $tag4 = ''; # Field labels if ($att !~ /N/) { if ($att =~ /U/) { $tag1 = ''.$tag1; $tag2 .= ''; } if ($att =~ /I/) { $tag1 = ''.$tag1; $tag2 .= ''; } if ($att =~ /B/) { $tag1 = ''.$tag1; $tag2 .= ''; } if ($a ne '0') { $val = ' VALIGN=top' } else { $val = '' } $label = "$dt_fnt_tag$tag1$field_names[$a]:$tag2 $SPACE$label".&drop_down('dd1_'.$db_id_num, @{ $DD1_FIELDS{$a} }).'' } if ($db_row[1] ne '') { $a = $db_row[1]; if ($no_label) { $c = $label } else { $c = "$c".&drop_down('dd2_'.$db_id_num, @{ $DD2_FIELDS{$a} }).'' } if ($no_label) { $c = $label } else { $c = "$c$dt_fnt_tag$tag3$currency $price$tag4"; if ($no_label) { $c = $label } else { $c = "$c\n\t$TABLE\n\t!. "$ac_button\n\t
"; $no_label = ''; } else { $label = ""; $no_label = 'Y'; } # Field contents if ($att =~ /u/) { $tag3 = ''.$tag3; $tag4 .= ''; } if ($att =~ /i/) { $tag3 = ''.$tag3; $tag4 .= ''; } if ($att =~ /b/) { $tag3 = ''.$tag3; $tag4 .= ''; } if ($db_row[$a] ne '') { $y = &chk_cart_id($db_row[$a], $x) } else { $y = $SPACE } if ($a eq '0') { next if $drop_down_error; $b = ''; ++$dd_print; if ($db_row[0] ne '') { $a = $db_row[0]; $b .= "\n\t
$dt_fnt_tag$tag1$field_names[1]:$tag2 $SPACE" } $b .= "\n\t
$dt_fnt_tag${tag1}$field_names[$price_fld_num]:$tag2 $SPACE" } print "\n\t
$dt_fnt_tag${tag1}Quantity:$tag2 $SPACE" } print qq!\n\t
$TABLE" if $no_label && $tag; if ($a ne $price_fld_num) { print "\n\t$label$dt_fnt_tag$tag3$db_row[$a]$tag4 $SPACE" } else { print "\n\t$label$dt_fnt_tag$tag3$currency $price$tag4" } if ($no_label) { print "\n\t$TABLE"; ++$tag; } } } print "\n\t$r_img_src\n"; $tag = '1'; foreach (@display_numbers) { next if $db_row[$_] eq ''; print "\n\t"; if ($tag < 2) { print "\n\t". "\n\t"; ++$tag; } print $spc_row2 if $tag =~ /[13579]$/; $y = &chk_cart_id($db_row[$_], $x); if ($fields_array{$_} =~ /^(left|center|right)$/i) { $al = $fields_array{$_} } else { $al = 'left' } print "\n\t"; } print "\n\t
$dt_fnt_tag$y
\n" if $tag > 1; } else { print $TABLE; $a = $display_numbers[scalar(@display_numbers) - 1]; foreach (@display_numbers) { next if $db_row[$_] eq ''; $y = &chk_cart_id($db_row[$_], $x); if ($fields_array{$_} =~ /^(left|center|right)$/i) { $al = $fields_array{$_} } else { $al = 'left' } print "\n\t". "\n\t$dt_fnt_tag$y"; print $spc_row2 if $_ ne $a; } print "\n\t$r_img_src"; print $spc_row1 if $t_img_src.$no_img; print "\n\t\n"; } if ($dropdowns && !$dd_print) { # Quantity, drop downs, and Price print "\n$TABLE"; # %DD1_FIELDS - %DD2_FIELDS error if (!$drop_down_error) { print "\n\t$SPC $dh_fnt_tag${SPACE}Quantity$SPACE$SPACE $dh_fnt_tag$dd_hdr$ch_col_spc $dh_fnt_tag$SPACE$field_names[$price_fld_num]$SPACE $SPC"; } else { print "\n\t$SPACE $error_fnt_tag$dd_hdr $SPACE" } print qq!\n\n\t$c_col_spc $ac_button $dropdowns$c_col_spc $dt_fnt_tag$price $c_col_spc !; } # Quantity and Price - No drop downs elsif (!$dd_print) { print qq!\n\t$TABLE $ch_col_spc ${dt_fnt_tag}Quantity: $SPACE $ac_button $dt_fnt_tag$field_names[$price_fld_num]: $SPACE $price$SPACE $ch_col_spc !; } # Item spacing print "\n$spc_row3" if !$item_separator && (@ITEMS || $table_border); if ($table_width && @ITEMS) { if (@ITEMS >= 1) { print "\n\n
"; $table_tag = 'Y'; print $item_separator if $item_separator; } else { $table_tag = '' } } } # End while (@ITEMS) print "\n\n\n" if $table_width; } ############################################ sub add_cart_button { my ($img, $att) = split(/:/,$add_cart_button); $img =~ s/\s+//g; if ($att =~ /\w+/ && $att !~ /VALUE|NAME/i) { $att =~ s/\s+/ /g; $att =~ s/^\s+|\s+$//g; $att = ' '.$att; } else { $att = '' } $ac_button = ''; if ($img =~ /\.(gif|jpg|jpeg)$/i && -r $grph_directory.'/'.$img) { $ac_button = qq!! } elsif ($add_cart_button) { $ac_button = qq!! } if ($ac_button) { $ac_button = "$SPACE$ac_button$SPACE" } else { $ac_button = "$SPC" } } ############################################ sub chk_cart_id { my ($field, $price) = @_; my $qs = ''; if ($field =~ /cart_id=/) { # Allow setup file switching if ($store ne $default_setup_file && $field !~ /store=/) { $qs .= '&store='.$store; $qs =~ s/\.setup$//; } # No search engine $qs .= '&no_search=Y' if $in{'no_search'} && $field !~ /no_search=/; $q_string = &query_string() if !defined($q_string); # No item price or item id for URLs with inner document links if ($field !~ /cart_id=#/) { $qs .= '&item_id='.$db_id_num.'&item_pr='.$price; $qs .= '&d1='.$db_row[0] if $db_row[0] ne ''; $qs .= '&d2='.$db_row[1] if $db_row[1] ne ''; } $field =~ s/cart_id=/cart_id=$cart_id$qs$q_string&dci=/g; } return $field; } ############################################ sub error { my ($error) = @_; my ($hdr_txt, $msg1, $msg2, $remedy, $spc); $error = 'P' if $error eq 'E' && -e $processed_cart; if ($error eq 'E') { $hdr_txt = 'Expired Shopping Cart'; $msg1 = 'Your shopping cart expired.'."\n\t".'Please return to the front page'; } elsif ($error eq 'P') { $hdr_txt = 'Processed Order'; $msg1 = 'Your order has been processed.'."\n\t".'Please return to the front page'; } elsif ($error eq 'S') { $hdr_txt = 'Security Details Incomplete'; $msg1 = 'Your shopping cart was canceled due to missing security details.'."\n\t". 'Please re-submit your security details'; unlink($user_cart); foreach ('category','c_file','pwd','uid') { undef $in{$_} if defined($in{$_}) } } $msg1 .= ' and a new shopping cart will be issued.'; &html_header($hdr_txt); $main_script_url = $script_url; $cart_id = ''; $msg2 = 'Thank you.'; # Frames if ($frameset_file) { $remedy = qq!s $graphics_url = $ssl_graphics_url if $use_ssl && !$in{'no_ssl'} && "$in{'sslForm'}$in{'chkForm'}$in{'faxOrder'}$in{'chgShip'}"; &print_java('page_on.gif'); $remedy = qq!$remedy onMouseOver="deselect(0); window.status='Link to Front Page'; return true" onClick="select(0); window.status=''; return true" onMouseOut ="deselect(0); window.status=''; return true">!. qq!Front Page!; } # Images not readable or do not exist else { $msg2 = qq!$remedy onMouseOver="window.status='Link to Front Page'; return true" onClick="window.status=''; return true" onMouseOut ="window.status=''; return true">Front Page!; $remedy = 'Thank you.'; } $remedy = "$hrd_fnt_tag$remedy"; } # No frames else { $in{'cd'} = 'Y'; push(@name_values,'cd'); &hidden_form_tags(); $remedy = qq!!; } # End if ($frameset_file) $spc = "$SPACE"; print "\n

$SPACE\n\n

\n"; print "\n" if $table_border; print " $spc $spc $spc "; print "\n" if $table_border; print "\n
$SPACE$SPACE$SPACE
$hr_fnt_tag$hdr_txt
${dt_fnt_tag}$msg1
$dt_fnt_tag$msg2
$remedy
$SPACE
\n
\n\n\n\n"; &html_trailer; } ############################################ sub ship_tax { my ($a, $b, $font_tag); &get_shipping if $shipping || @subtotal_ship; $discount_total = '' if !defined($discount_total) || $discount_total !~ /[1-9]/; $ship_total = '' if !defined($ship_total) || $ship_total !~ /[1-9\.]/; $grand_total = &format_num($grand_total); $sub_total = $grand_total; $font_tag = ""; # sales tax when client goes to order form if ($in{'tax'} eq 'Y') { $sales_tax = &format_num(($grand_total - $discount_total) * $tax_rate); $final_total = &format_num($grand_total + $ship_total + $sales_tax - $discount_total,'Y'); $grand_total = &format_num($grand_total,'Y'); $sales_tax = &format_num($sales_tax,'Y'); print "${nc_fnt_tag}Subtotal $nc_fnt_tag$grand_total "; &print_discount if $discount_total ne ''; &print_ship if $ship_total ne ''; print "\n$nc_fnt_tag$tax_label $nc_fnt_tag$sales_tax \n ${font_tag}Total $font_tag$currency $final_total \n\n"; } else { # "Subtotal" for client who isn't done shopping if (!$in{'tax'}) { $a = 'Subtotal'; $final_total = $grand_total; } # "Total" when client goes to order form (no sales tax) else { $a = 'Total'; $final_total = $grand_total + $ship_total - $discount_total; $grand_total = &format_num($grand_total,'Y'); print "${nc_fnt_tag}Subtotal $nc_fnt_tag$grand_total "; &print_discount if $discount_total ne ''; &print_ship if $ship_total ne ''; } $final_total = &format_num($final_total,'Y'); print "$font_tag". "$a\n$font_tag$currency $final_total \n\n"; } if ($ship_dd && $ship_total ne '') { print "${dh_fnt_tag}Shipping $table_open $SPACE ". &ship_select. qq! $mh_col_spc $SPACE\n\n\n!; } print "$min_order_msg\n" if $minimum_order; print "$SPACE\n" if $modify_table_border; print "" if $in{'faxOrder'}.$send_order; print "\n\n"; sub print_ship { $ship_total = &format_num($ship_total,'Y'); print qq!\n$nc_fnt_tag$SPACE$shp_label $nc_fnt_tag$ship_total !; } sub print_discount { $discount_total = &format_num($discount_total,'Y'); print "\n$nc_fnt_tag$SPACE$dsc_label $nc_fnt_tag$discount_total "; } } ############################################ sub format_num { my ($num, $commas) = @_; $num =~ tr/0-9./ /c; $num =~ s/\s+//g; my $round_num = sprintf("%.4f",$num); chop $round_num; my $thousandths = chop $round_num; $round_num += .01 if $thousandths > 4; $round_num = sprintf("%.2f",$round_num); if ($commas) { while ($round_num =~ s/(\d)(\d\d\d)(?!\d)/$1,$2/g) {} } return $round_num; } ############################################ # Begin construction of colored table # $table_rowspan = number of rows # $table_colspan = number of field columns and associated spacer columns # $border_colspan = total colspan of table, including ornamental border sub disp_table_vars { my (@ITEMS) = @_; @display_numbers = &filter_array('',@display_numbers); @vertical_numbers = &filter_array('Y',@vertical_numbers); @vertical_numbers = () if !defined(@vertical_numbers); $table_width =~ s/\s+//g; if ($table_width =~ /^\d{2,}[\%]$|^\d{3}$/) { $table_width = ' WIDTH="'.$table_width.'"'; $table_border = ''; } else { $item_separator = $table_width = ''; my $a = '3'; foreach (@vertical_numbers) { if ($_ =~ /^[01]{1}[:]*/) { --$a; last; } } $table_rowspan = ($row_count * $a) + 1; # 1 row for header if (@vertical_numbers) { while (@ITEMS) { &item_row(shift(@ITEMS)); foreach (@display_numbers) { if ($db_row[$_] =~ /\w+/) { ++$table_rowspan; last; } } } } ++$table_rowspan if $table_border; ++$table_rowspan if $table_title; ++$table_rowspan if $minimum_order || $grand_total; } $table_colspan = ''; $border_colspan = '3'; } ############################################ # Begin construction of colored table sub disp_cart_table_vars { my ($col) = @_; # Data, header, subtotal $table_rowspan = ($row_count * 2) + 6; # Sales tax ++$table_rowspan if $in{'tax'} eq 'Y'; # Discount ++$table_rowspan if $discount; # No shipping $table_rowspan -= 2 if !$shipping || (defined($ship_fld_num) && $ship_grand_total eq '' && $ship_weight eq ''); # $table_colspan = number of field columns and associated spacer columns # $border_colspan = total colspan of table, including ornamental border # $Total_colspan = colspan for printing "Subtotal" or "Total" label # 4 columns reserved for printing dollar amount of Subtotal or Total @modify_display_numbers = &filter_array('',@modify_display_numbers); $table_colspan = ((scalar(@modify_display_numbers) + 2 + $col) * 2) - 1; $border_colspan = $table_colspan + 2; $Total_colspan = $table_colspan - 4; $table_colspan = ' COLSPAN='.$table_colspan; # Minimum Order message row if ($minimum_order) { ++$table_rowspan; $min_order_msg = "\n$dh_fnt_tag$min_order_msg"; } $m_row_spc = ""; } ############################################ sub table_title { my ($title, $rows, $width) = @_; print "\n

\n\n

\n"; print "\n". "$SPACE" if $rows; print "\n$hr_fnt_tag$SPACE $title $SPACE" if $title ne ''; } ############################################ sub table_header { my ($title) = @_; print "\n\n"; print "$mh_col_spc\n" if $title; foreach (@modify_display_numbers) { print "$mh_col_spc\n" } # Add Quantity and Subtotal print "$mh_col_spc\n\n\n"; } ############################################ # Count items in client's cart - store in @CART # Determin minimum order sub count_cart_rows { my ($a, $match, $qty, @SP_STRING, @SP_STRING1, $unit_pr, $units_pr); @CART = (); $minimum_order =~ tr/0-9./ /c; $minimum_order =~ s/\s+//g; if (-s $user_cart) { $grand_total = $row_count = 0; &read_open($user_cart); while () { ++$row_count; push(@CART,$_); } close(FILE); # Check client's subtotal exceeds minimum order value my @CART1 = @CART; while (@CART1) { &get_cart_row(shift(@CART1)); if ($shipping && ($sp_string ne '' || $wt_string > 0)) { if ($sp_string =~ /:/) { $sp_string .= ':'; if (@SP_STRING) { while (@SP_STRING) { $a = shift(@SP_STRING); if ($a =~ /^$sp_string/) { ($unit_pr,$units_pr,$qty) = split(/:/,$a); $qty += $quantity; push(@SP_STRING1, $unit_pr.':'.$units_pr.':'.$qty); ++$match; } else { push(@SP_STRING1,$a) } } if (!$match) { push(@SP_STRING1,$sp_string.$quantity) } else { undef $match } unshift(@SP_STRING,@SP_STRING1); undef @SP_STRING1; } else { push(@SP_STRING,$sp_string.$quantity) } } elsif ($sp_string ne '') { $ship_grand_total += $quantity * $sp_string } elsif ($wt_string) { $ship_weight += $wt_string * $quantity } } $subtotal = &format_num($quantity*$ct_row[$price_fld_num]); $grand_total += $subtotal; $discount_quantity += $quantity if defined(@quantity_discount); if ($free_ship && $grand_total >= $free_ship) { undef @SP_STRING; undef @subtotal_ship; $free_ship = $shipping = $ship_grand_total = ''; } } $discount = &get_discount if $discount; if (@SP_STRING) { while (@SP_STRING) { $a = shift(@SP_STRING); ($unit_pr,$units_pr,$qty) = split(/:/,$a); --$qty; $units_pr = &format_num($units_pr); $ship_grand_total += ($unit_pr + ($units_pr * $qty)); } } $disp_ship = 'Y' if $shipping && ((defined($ship_fld_num) && $ship_grand_total.$ship_weight) || !defined($ship_fld_num)); $grand_total = &format_num($grand_total); $minimum_order = '' if $minimum_order && $grand_total >= $minimum_order; $subtotal_msg = "$SPACE Order Subtotal: $SPACE$currency".&format_num($grand_total,'Y')." $SPACE"; } else { $button_1 = $button_4 = '' } if ($minimum_order) { $button_4 = ''; $minimum_order = &format_num($minimum_order); $min_order_msg = "$SPACE Our Minimum Order is $currency".&format_num($minimum_order,'Y')." $SPACE"; } else { $minimum_order = '' } } ############################################ sub file_status { my ($file, $line, $type, @files) = @_; my ($a, $b, $c, $contents, $error, $write_test); if ($type eq 'req') { $a = '644'; $b = 'require'; } elsif ($type eq 'r') { $a = '644'; $b = 'read'; } else { $a = '666'; $b = 'access'; } $c = "Error occurred at LINE $line in $file."; foreach (@files) { if ($type eq 'req' && -r $_) { if (defined($ENV{'REQUEST_METHOD'})) { eval { require $_ }; if ($@) { $@ =~ s/^\s+//; $@ =~ s/\s+$//; $@ =~ s//>/g; $@ =~ s/\n+/

\n\n/g; &file_error('Internal Server Error', "The following error exists in $_:\n
\n$@\n
", &file_perm()); } } else { require $_ } } elsif (!-e $_) { if ($type eq 'w') { &write_open($_,''); close(FILE); system("chmod 666 $_"); } else { &file_error('File not Found', "Can not $b $_", $c, 'Verify the file exists and filename spelling is correct for this file.', &file_perm($a,$_)) } } elsif (!-r $_) { $error = 'No Read'; $error .= '/Write' if $type eq 'w' && !-w $_; $error .= ' Permission'; } elsif ($type eq 'w' && !-w $_) { $write_test = $_.'.writetest'; open(WRITE_TEST, ">$write_test") || ++$error; if (!$error) { close(WRITE_TEST); &read_open($_); read(FILE, $contents, -s $_); close(FILE); unlink($_); &write_open($_,''); print FILE $contents; close(FILE); undef $contents; system("chmod 666 $_"); unlink($write_test); } $error = 'No Write Permission' if !-w $_ || $error; } if ($error) { unlink($_.'.lock') if -e $_.'.lock'; &file_error($error, "Can not $b $_", $c, &file_perm($a,$_)); } } } ############################################ sub open_error { my ($file_dir, $file, $section, $script, $line, $rw) = @_; my ($a, $b, $c); foreach ($client_lock, $file, $reseller_lock) { unlink($_.'.lock') if $_ && -e $_.'.lock' } $a = $b = $c = ''; if ($file_dir =~ /^F/) { my @dirs = split(m#/#,$file); $a = ' /'.$dirs[$#dirs-1].' directory permissions, '; $b = ','; } $c = $file if $rw; &file_error("$file_dir Access Error", "Can not access $file in $section Routine", "Error occurred at LINE $line in $script.", "Verify$a the \l$file_dir exists$b and \l$file_dir permissions are correct.", &file_perm($rw,$c)); } ############################################ sub file_perm { my ($perm, $file) = @_ if @_; my ($a, $b, $dir, @dirs, $envmsg, $error, $font1, $font2, $font3, $mode, $msg, $pre1, $pre2); %in = &ReadParse if defined($ENV{'REQUEST_METHOD'}) && $file =~ /global\.setup$/; $a = $error = '0'; $b = $envmsg = $msg = ''; my $space = ' '; if (defined($ENV{'REQUEST_METHOD'})) { $font1 = ''; $font2 = ''; $font3 = ''; $pre1 = '
'."\n"; $pre2 = '
'."\n\n"; } else { $font1 = $font2 = $font3 = ''; $pre1 = "\n\n"; $pre2 = "\n\n\n"; } if (defined($basedir)) { $cart_directory = $real_cart_dir if $cart_directory eq $rcrt_directory; $clnt_directory = $real_clnt_dir if $clnt_directory eq $rstr_directory; @dirs = ( $banr_directory,$cart_directory,$clnt_directory,$data_directory,$grph_directory, $html_directory,$libr_directory,$logs_directory,$logo_directory,$mail_directory, $pgp_directory, $rcrt_directory,$rstr_directory,$stat_directory,$user_directory, $basedir ); foreach (sort @dirs) { if ($_ && !-e $_) { $msg .= $space.$font1.'Directory not found: '."$_$font3\n"; ++$error; ++$dir; } elsif ($_) { $mode = (stat($_))[2]; if ($_ =~ /^($banr_directory|$basedir|$grph_directory|$html_directory|$libr_directory|$logo_directory|$pgp_directory)$/) { if (($mode & 0755) != 0755) { $msg .= $space.$font1.'Change to 755: '."$_$font3\n"; ++$error; } elsif ($_ !~ /^($libr_directory|$pgp_directory)$/) { $msg .= $space.'755 = '."$_\n" } } elsif ($_ =~ /^($clnt_directory|$data_directory|$stat_directory|$cart_directory|$logs_directory|$mail_directory|$rcrt_directory|$rstr_directory|$user_directory)$/) { if (($mode & 0777) != 0777) { $msg .= $space.$font1.'Change to 777: '."$_$font3\n"; ++$error; } else { $msg .= $space.'777 = '."$_\n" } } ++$dir; } } } else { @dirs = () } if (defined($in{'env'}) || ($error && $error == @dirs) || (!$font1 && ($error || $file))) { $a = '0'; foreach (sort keys %ENV) { $a = length($_) if length($_) > $a } $envmsg .= 'Environment Variables:'.$pre1; foreach (sort keys %ENV) { $envmsg .= $space.sprintf("%-${a}.${a}s",$_).' = '.$ENV{$_}."\n" if $_ !~ /^USER|USER$/i && $ENV{$_} ne '' } $envmsg =~ s/\s+$//; if ((defined($in{'env'}) && $in{'env'} =~ /env/) || !$font1) { if (defined(@INC)) { $a = '0'; $envmsg .= $pre2."\@INC:".$pre1; foreach (sort @INC) { $envmsg .= $space.$_."\n" if $_ =~ m#/# } $envmsg =~ s/\s+$//; } if (defined(%INC)) { $a = '0'; foreach (sort keys %INC) { $a = length($_) if length($_) > $a } $envmsg .= $pre2.'%INC:'.$pre1; foreach (sort keys %INC) { $envmsg .= $space.sprintf("%-${a}.${a}s",$_).' = '.$INC{$_}."\n" if $INC{$_} ne '' } $envmsg =~ s/\s+$//; } } $a = $]; $a =~ s/\s+/ /g; $a =~ s/ {2,}/ /g; $envmsg .= $pre2.'System Files:'.$pre1.$space.'Perl Version = '."$a\n"; $a = '12'; foreach ('perl','pgp','pgpe','nslookup','sendmail') { if ($_ eq 'nslookup' && defined($nslookup) && $nslookup =~ /$_$/ && -e $nslookup) { $b = $nslookup } elsif ($_ eq 'pgp' && defined($pgp) && $pgp =~ /$_$/ && -e $pgp) { $b = $pgp } elsif ($_ eq 'pgpe' && defined($pgp) && $pgp =~ /$_$/ && -e $pgp) { $b = $pgp } elsif ($_ eq 'sendmail' && defined($sendmail) && $sendmail =~ /$_$/ && -e $sendmail) { $b = $sendmail } else { $b = `which $_` } if ($b =~ m#^/#) { $b =~ s/\s+$//; $envmsg .= $space.sprintf("%-${a}.${a}s",$_).' = '.$b."\n" } } $envmsg =~ s/\s+$//; $envmsg .= $pre2; } if ($error) { $dir = $font1.'Directory'.$font3; $msg = $space.$font1.'Invalid Value: UNIX path in $basedir of ws_global.setup is not correct'."$font3\n\n$msg" if $error == @dirs; } elsif ($dir) { $dir = 'Directory' } else { $dir = '' } if ($file) { if (-e $file) { $a = "Change to $perm: " } elsif ($perm eq '666') { $a = 'Can not create: ' } else { $a = 'File not found: ' } $msg = "$space$font2$a$file$font3\n\n$msg"; $file = ''; $file = ' and ' if $dir; $file .= $font2.'File'.$font3; } if (!$error && !$file) { $a= ' Test OK' } else { $a = '' } if ($font1) { if ($error || $envmsg) { return "$dir$file Permissions$a:$pre1$msg$pre2$envmsg" } else { return() } } elsif ($error || $file) { print "\n\n$dir$file Permissions$a:\n\n$msg\n\n$envmsg"; exit; } } ############################################ sub file_error { my (@error_msg) = @_; my ($a); &print_cont; print qq!\n\n$error_msg[0]\n\n\n

$error_msg[0]

\n!; foreach $a (1 .. $#error_msg) { print "

$error_msg[$a]

\n" } print "\n\n\n\n"; exit; # Eliminate perl warning: Used only once @email_numbers = @quantity_discount = (); $client_lock = $dbase_weights = $delete_cart = $discount_quantity = $dsc_label = $duplicate_buttons = $fax_email = $modify_spc_height = $pre_form_file = $reseller_lock = $shp_label = $sub_total = $tax_label = $tax_rate = $hour = $min = $time = $year = ''; } ############################################ # Prevent multiple $file access sub GetFileLock { my ($file) = @_; if (-e $file) { # Delete lock file, older than 5 minutes, no write permission if (-M $file > .0035 || !-w $file) { unlink($file) } # Set $end, wait 60 seconds else { my $end = (60 + time); while (-e $file && time < $end) { sleep(1) } } } open(LOCK_FILE, ">$file") || &open_error('File', $file, 'Write Lock File', __FILE__, __LINE__, '666'); print LOCK_FILE 'WebStore'."\n"; close(LOCK_FILE); system("chmod 666 $file"); } ############################################ # Print links at bottom of all pages sub html_trailer { if ($rs_code ne '') { if ($in{'rsc_mail'} ne '') { $email_link_url = $in{'rsc_mail'}; $email_link_title = 'Mail to: '.$email_link_url; } if ($in{'rsc_name'} ne '' && $in{'rsc_rfw'} =~ /^http:/) { $return_link_url = $in{'rsc_rfw'}; $return_link_title = $in{'rsc_name'}; } } if ($return_link_url.$email_link_url) { print qq!\n\n
\n

\n


\n\n

\n

$SPACE$SPACE
$dh_fnt_tag$title$dh_fnt_tag$field_names[$_]${dh_fnt_tag}Qty${dh_fnt_tag}Subtotal
\n\n
$nc_fnt_tag!; print qq!$return_link_title! if $return_link_url; print ' | ' if $return_link_url && $email_link_url; print qq!$email_link_title! if $email_link_url; print "
\n
"; } print qq!
Copyright © 1999 - 2009 All rights reserved. Website designed and maintained by Security Base.com. Legal Notice
\n!; print qq!\n!; print &print_vars if ((defined($in{'debug'}) && $in{'debug'}) || (defined($in{'env'}) && $in{'env'} =~ /debug/i)) && defined(&print_vars); print "\n\n\n\n".&version($version.' CS'); # First access, cart not deleted if (defined($del_carts) && !defined($in{'cd'})) { # Using access counter if ($count_file) { unlink($count_file) if -e $count_file && (!-r $count_file || (-z $count_file && -M $count_file > .0035)); if (!&write_lock($count_file, '15')) { &GetFileLock("$count_file.lock"); my $num = '0'; if (-e $count_file) { &file_status(__FILE__, __LINE__, 'w', $count_file) if !-w $count_file; &read_open($count_file); while () { $num = $_ } close(FILE); $num =~ s/\s+//g; } if ($start_count) { $start_count =~ tr/0-9/ /c; $start_count =~ s/\s+//g; $num = $start_count if $start_count && $start_count > $num; } $num = $count if defined($count) && $count > $num; ++$num; &write_open($count_file,''); print FILE "$num\n"; close(FILE); system("chmod 666 $count_file"); unlink("$count_file.lock"); } } # Using log file if ($log_file) { my ($refer, $rem_host); my $log_file = $stat_directory.'/'.$log_file; # 01/Mar/1998 08:16:10 PM &date_time if !defined($four_digit_year); my @months = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); my $date = "$mday/$months[$mon-1]/$four_digit_year $time"; $browser = '[not defined]' if !defined($browser) || $browser !~ /\w+/; if (defined($in{'ref'}) && $in{'ref'} =~ /\w+/) { $refer = $in{'ref'} } else { $refer = '[not defined]' } if (!defined($ENV{'REMOTE_ADDR'})) { $rem_addr = '[not defined]' } elsif ($ENV{'REMOTE_ADDR'}) { $rem_addr = $ENV{'REMOTE_ADDR'} } else { $rem_addr = '[not supplied]' } if (!defined($ENV{'REMOTE_HOST'})) { $rem_host = '[not defined]' } elsif ($ENV{'REMOTE_HOST'}) { $rem_host = $ENV{'REMOTE_HOST'} } else { $rem_host = '[not supplied]' } &GetFileLock("$log_file.lock"); my $app = ''; if (-e $log_file) { if (!-r $log_file) { unlink($log_file) } else { &file_status(__FILE__, __LINE__, 'w', $log_file) if !-w $log_file; $app = '>' if $file_length && -s $log_file < $file_length; } } open(STATS, ">$app$log_file") || &open_error('File', $log_file, 'Write Log File', __FILE__, __LINE__, '666'); print STATS 'DATE BROWSER '. 'HTTP_REFERER '. 'REMOTE_ADDR REMOTE_HOST'."\n\n" if !$app; write STATS; close(STATS); system("chmod 666 $log_file"); unlink("$log_file.lock"); # format STATS = output format used for $log_file. format STATS = @<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $date, $browser, $refer, $rem_addr, $rem_host . } # Delete cart files if ($delete_age) { my ($a, $age_file, @files); $delete_age =~ s/\s+//g; $delete_age = '6' if $delete_age !~ /^[1-9]{1}\d*\.{0,1}\d*$/; $a = sprintf("%.3f",$delete_age/24); $age_file = $cart_directory.'/'.'delete.cart.age.file'; if (!-e $age_file || -M $age_file > $a) { &age_file($age_file,$delete_age.' hour'); &delete_files(__FILE__,__LINE__,$cart_directory,'.cart',$a); } } } exit; } ############################################ sub ReadParse { my ($a, $b, %db_nums, $key, $val, %in, @in, $in); if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $in, $ENV{'CONTENT_LENGTH'}) } else { $in = $ENV{'QUERY_STRING'} } @in = split(/[&;]/,$in); foreach $a (0 .. $#in) { $in[$a] =~ s/\+/ /g; $in[$a] =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; ($key, $val) = split(/=/,$in[$a],2); #qqq if ($key =~ /^item_id_[\S]+$|^\d+$/) { $b = $key; $b =~ s/^item_id_//; push(@duplicate_ids,$b) if defined($db_nums{$b}); $db_nums{$b}++; } elsif ($key =~ /\.[xy]{1}$/) { $b = $key; $b =~ s/\.[xy]{1}$//g; $in{$b} .= $val; } $in{$key} .= "\0" if defined($in{$key}); $in{$key} .= $val; } return %in; } ############################################ sub print_java { my (@images) = @_; foreach (@images) { $image_list.= qq!\n\t"$graphics_url/$_",! } chop $image_list; print qq! \n!; } ############################################ sub query_string { my ($form_qs) = @_; $form_qs = '' if !defined($form_qs); my $qs = ''; %query_string = () if !defined(%query_string); # User id and demo mode $qs .= &query('c_file','demo','uid','pwd'); # Reseller $qs .= &query(@rs_fields) if $rs_code ne ''; # Add to cart - frameset document $qs .= &query(@name_values) if defined(@name_values); # Client order form fields $qs .= &query(@client_fields) if $form_qs; # No search enabled $qs .= '&ns=Y' if $in{'ns'}; # Test mode $qs .= '&env='.$in{'env'} if defined($in{'env'}); return $qs; sub query { my (@array) = @_; my $qs = ''; foreach (sort @array) { if (!defined($query_string{$_})) { $qs .= '&'.$_.'='.&convert_hex($in{$_}) if defined($in{$_}) && $in{$_} ne '' && length($in{$_}) < 2048; $query_string{$_}++; } } return $qs; } } ############################################ sub reseller { if (!$reseller_data_file) { $rs_code = $reseller_file = $reseller_spreadsheet = ''; return; } if (defined($in{'rsc'}) && $in{'rsc'} ne '') { $rs_code = $in{'rsc'}; @rs_fields = ('rfw','rsc'); if ($in{'rsc_nf'}) { push(@rs_fields,'rsc_nf'); return; } push(@rs_fields,'r_data','rsc_name','rsc_mail','rsc_rfw'); return if $in{'r_data'}; my $file = $data_directory.'/'.$reseller_data_file; if (!$cart_id && -e $file) { my ($a, $db_row, @db_row, $read_file, $records, @records, $row); my $readonly = $file.'.readonly'; &print_cont; if (-e $readonly) { $read_file = $readonly } else { $read_file = '' } my $time_out = &write_lock($file, '2'); if ($time_out && $read_file) { $file = $read_file; &write_lock($file, '2'); } &read_open($file); while () { push(@records,$_) } close(FILE); # Update read only file if (!$time_out && (!$read_file || -s $readonly != -s $file)) { if (!&write_lock($readonly, '2')) { &GetFileLock("$readonly.lock"); &file_status(__FILE__, __LINE__, 'w', $readonly) if !-w $readonly; &write_open($readonly,''); print FILE join('',@records); close(FILE); system("chmod 666 $readonly"); unlink("$readonly.lock"); } } $a = '0'; if (scalar(@records) > 3000) { $records = 'Y' } else { $records = '' } while (@records) { $row = shift(@records); $row =~ s/\s+$//; next if $row =~ /^$|^COMMENT:/i; @db_row = split(/\|/,$row); if ($db_row[0] eq $in{'rsc'}) { # Remove Password, Date, and Id pop(@db_row); pop(@db_row); pop(@db_row); $in{'r_data'} = join('|',@db_row); foreach ($rsc_name_fld_num,$rsc_mail_fld_num,$rsc_urlpage_fld_num) { $_ =~ s/\s+//g; $_ =~ s/^0// if $_ ne '0'; } $in{'rsc_name'} = $db_row[$rsc_name_fld_num] if $rsc_name_fld_num =~ /^\d+$/; $in{'rsc_mail'} = $db_row[$rsc_mail_fld_num] if $rsc_mail_fld_num =~ /^\d+$/; $in{'rsc_rfw'} = $db_row[$rsc_urlpage_fld_num] if $rsc_urlpage_fld_num =~ /^\d+$/; last; # Reseller found } if ($records) { ++$a; print sprintf("%1000s",' ') if $a =~ /500$/; } } print "\n" if $a >= 500; } # Reseller not found if (!defined($in{'r_data'})) { @rs_fields = ('rfw','rsc','rsc_nf'); $in{'rsc_nf'} = 'Y'; foreach (sort keys %RESELLER_FIELDS) { $a = $RESELLER_FIELDS{$_}[0]; delete $in{$a} if defined($in{$a}) && $a ne 'rsc'; } } } else { $rs_code = '' } } ############################################ sub age_file { my ($file, $sch) = @_; unlink($file) if !-w $file; &write_open($file,''); print FILE 'Delete File Scheduler: '.$sch.' intervals'."\n"; close(FILE); system("chmod 666 $file"); } ############################################ sub check_cart { $cart = ''; @CART = (); $row_num = '0'; if (-s $user_cart) { my ($num, @row); &read_open($user_cart); while () { push(@CART,$_); s/\s+$//; @row = split(/\|/); $num = pop(@row); $row_num = $num if $num > $row_num; } close(FILE); $cart = '1'; } # Save fields for View/Modify and E-mail receipts %save_fld = (); &file_status(__FILE__, __LINE__, 'req', $data_directory.'/'.$form_file) if !defined(%SHIPPING); if (defined($SHIPPING{1}[0]) && $SHIPPING{1}[0] =~ /\d+/) { $SHIPPING{1}[0] =~ s/\s+//g; my $a = (split(/:/,$SHIPPING{1}[0]))[0]; $save_fld{$a}++; } #qqq foreach ($dbase_id_fld_num, $item_fld_num, $price_fld_num, @email_numbers, @modify_display_numbers) { $save_fld{$_}++ if !defined($save_fld{$_}) && $_ =~ /\d+/ } } ############################################ sub check_page { if (($in{'category'} =~ /\.htm[l]*$/i && $in{'category'} ne $frontpage_file) || $page) { if (!$page) { $page = $in{'page'} = $in{'category'} } elsif (!$in{'category'}) { $in{'category'} = $page } $button_3 = qq!\n !; } } ############################################ # Eliminate non-essential fields in cart sub filter_fields { my @row = (); my $a = $#db_row; # Eliminate non-essential fields $save_fld{$a}++ if !defined($save_fld{$a}); for ($a = 0; $a < @db_row; ++$a) { if (defined($save_fld{$a})) { push(@row,$db_row[$a]) } else { push(@row,'') } } ++$row_num; # Cart dbase number return join('|',@row).'|'.$row_num."\n"; } # End of file