#!/usr/bin/perl # patch by bill #$ENV{PATH} = ''; #$ENV{SHELL} = ''; #delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # Make %ENV safer ################################################################################################ #END USER LICENSE AGREEMENT CartIt version 8.0 Release 1.0 # # # This End User License Agreement ("EULA") is a legal agreement between you # (either an individual or a single entity) (Hereinafter, "END USER", or "YOU") # and CartIt Corporation (Hereinafter, "CARTIT CORPORATION" or "WE") for the # CARTIT CORPORATION software product accompanying this EULA (Hereinafter "SOFTWARE"), # which includes computer software and may include associated media, printed materials, # and "online" or electronic documentation. By installing, copying, or otherwise using # SOFTWARE, YOU agree to be bound by the terms of this EULA. If YOU do not agree to the # terms of this EULA, do not install, copy, or use SOFTWARE. # # LICENSE GRANT: (i) CARTIT CORPORATION grants YOU a license to use one copy of the # SOFTWARE. YOU may not modify or disable any licensing or control features of # the SOFTWARE. (ii) The SOFTWARE is licensed to YOU to be installed and used # on one machine only. (iii) SOFTWARE is licensed to operate on or for one # domain name only. (iv) Only one company may use the SOFTWARE for its intended # purpose on the domain name. This company may not sell the products or services # of other companies in the capacity of an online mall or buyer service. If more # than one company wishes to use the SOFTWARE they must purchase a separate license. # (v) YOU may use the SOFTWARE only in the form originally supplied by CARTIT CORPORATION. # YOU may not modify, decompile, disassemble, translate or reverse engineer the SOFTWARE, # in whole or in part, and may not sublicense, rent, lease or otherwise disclose or # disseminate the SOFTWARE to any third party except in accordance with the provisions # of this Section. YOU may not copy the SOFTWARE, in whole or in part, other than for # the sole purpose of backup or archive, provided that YOU reproduce all copyright, # trademark, confidential or other proprietary notices. # # UPGRADES: (i) CARTIT CORPORATION is not required to notify YOU of or to provide YOU # freely with any upgrades to the SOFTWARE. (ii) If the SOFTWARE is being provided as an # upgrade to an older version, YOU are required to destroy all copies of the older version # of the SOFTWARE and all its components and your license to use the older version is terminated. # # TECHNICAL SUPPORT: While CARTIT CORPORATION does provides very professional and extensive # technical support and detailed documentation, CARTIT CORPORATION does not warrant or # guarantee that WE will provide technical support for any SOFTWARE. # # WARRANTY: (i) CARTIT CORPORATION warrants that for a term of sixty (60) days from the date # of delivery to END USER the SOFTWARE will perform substantially in accordance with the # documentation provided. (ii) If the END USER asserts a defect in the SOFTWARE during the # above defined warranty period, END USER shall be entitled as its sole remedy, and at CARTIT # CORPORATION'S sole option and expense, to have the defective SOFTWARE replaced by # CARTIT CORPORATION with SOFTWARE that substantially conforms to the documentation. # (iii) If the replacement does not rectify the defect, or if the replacement is unduly delayed, # END USER shall be entitled to a refund not to exceed the amount paid for the SOFTWARE. # (iv) CARTIT CORPORATION shall not be liable under this warranty if its testing or examination # discloses that the alleged defect in the SOFTWARE does not exist or was caused by END USER'S # or any third party's misuse, neglect, improper installation or testing, lack of technical skills, # insufficient hardware, software, or server calibration, unauthorized attempts to repair or modify, # or any other cause beyond the range of the intended use of the SOFTWARE, or by accident, or acts # of God. (v) CARTIT CORPORATION DOES NOT WARRANT THAT THE FUNCTIONS CONTAINED WITHIN THE SOFTWARE # WILL MEET END USER'S REQUIREMENTS, OR WILL OPERATE IN ANY COMBINATION WHICH MAY BE SELECTED FOR # USE BY END USER, OR THAT OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE, OR THAT # ANY DEFECTS THAT MAY EXIST IN THE SOFTWARE WILL BE CORRECTED. THIS WARRANTY IS IN LIEU OF ALL # OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTIES OF MERCHANTABILITY OR FITNESS FOR # A PARTICULAR PURPOSE. # # LIMITATION OF LIABILITY: EXCEPT AS PROHIBITED BY LAW, CARTIT CORPORATION'S ENTIRE LIABILITY ARISING # OUT OF THIS EULA SHALL BE LIMITED TO THE ORIGINAL AMOUNT PAID BY YOU FOR THE SOFTWARE. IN NO EVENT # SHALL CARTIT CORPORATION BE LIABLE FOR COSTS OF PROCUREMENT OF SUBSTITUTE GOODS AND SERVICES, LOSS # OF USE, DATA, OR PROFITS, OR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES, ARISING OUT OF # OR IN CONNECTION WITH THIS EULA OR THE USE OR PERFORMANCE OF SOFTWARE HOWEVER CAUSED AND ON ANY THEORY # OF LIABILITY, WHETHER IN AN ACTION FOR CONTRACT OR TORT (INCLUDING NEGLIGENCE) OR OTHERWISE, AND # WHETHER OR NOT CARTIT CORPORATION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # COPYRIGHT: All title and copyrights in and to the SOFTWARE (including but not limited to any images, # photographs, animations, video, audio, music, text, and "applets" incorporated into the SOFTWARE), # the accompanying printed materials, and any copies of the SOFTWARE are owned by CARTIT CORPORATION # or its suppliers. The SOFTWARE is protected by copyright laws and international treaty provisions. # Therefore, YOU must treat the SOFTWARE like any other copyrighted material. YOU may not copy the # printed materials, if any, accompanying the SOFTWARE. # # TRADE SECRETS: The SOFTWARE contains trade secrets and proprietary know-how that belongs to CARTIT # CORPORATION and is being made available to YOU in strict confidence. ANY USE OR DISCLOSURE OF THE # SOFTWARE, OR OF ITS ALGORITHMS, PROTOCOLS OR INTERFACES, OTHER THAN IN STRICT ACCORDANCE WITH THIS # EULA, MAY BE ACTIONABLE AS A VIOLATION OF OUR TRADE SECRET RIGHTS. # # U.S. GOVERNMENT RESTRICTED RIGHTS: The SOFTWARE and documentation are provided with RESTRICTED RIGHTS. # Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph # (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 or subparagraphs # (c)(1) and (2) of the Commercial Computer Software-Restricted Rights at 48 CFR 52.227-19, as applicable. # Manufacturer is CartIt Corporation/2457-A S. Hiawassee Road #305/Orlando, Florida 32835 # USA. # # EXPORT RESTRICTIONS: YOU agree that YOU do not intend to, nor will YOU, directly or indirectly, # export or transmit the SOFTWARE or related documentation to any country to which such export # or transmission is restricted by any applicable U.S. regulation or statute, without the prior # written consent, if required, of the Bureau of Export Administration of the U.S. Department of # Commerce, or such other governmental entity that may have jurisdiction over such export or transmission. # # TERMINATION: (i) CARTIT CORPORATION may terminate this EULA if YOU fail to comply with the terms and # conditions of this EULA. In such event, YOU must destroy all copies of the SOFTWARE and all of its # component parts and documentation. (ii) In such event YOU will not be entitled to any refund in part # of in full. ################################################################################################ $|=1; %COUNTRIES = ( 'Albania'=>'AL', 'Algeria'=>'DZ', 'American Samoa'=>'AS', 'Andorra'=>'AD', 'Anguilla'=>'AI', 'Antigua'=>'AG', 'Argentina'=>'AR', 'Aruba'=>'AW', 'Australia'=>'AU', 'Austria'=>'AT', 'Azores'=>'AP', 'Bahamas'=>'AS', 'Bahrain'=>'BH', 'Bangladesh'=>'BD', 'Barbados'=>'BB', 'Barbuda'=>'BC', 'Belgium'=>'BE', 'Belize'=>'BZ', 'Belarus'=>'BY', 'Benin'=>'BJ', 'Bermuda'=>'BM', 'Bolivia'=>'BO', 'Bonaire'=>'BL', 'Botswana'=>'BW', 'Brazil'=>'BR', 'British Virgin Islands'=>'VG', 'Brunei'=>'BN', 'Bulgaria'=>'BG', 'Burkina Faso'=>'BF', 'Burundi'=>'BI', 'Cambodia'=>'KH', 'Cameroon'=>'CM', 'Canada'=>'CA', 'Canary Islands'=>'CE', 'Cape Verde Islands'=>'CV', 'Cayman Islands'=>'KY', 'Central African Republic'=>'CF', 'Chad'=>'TD', 'Channel Islands'=>'NN', 'Chile'=>'CL', 'China, Peoples Republic of'=>'CN', 'Christmas Island'=>'CX', 'Cocos Islands'=>'CC', 'Colombia'=>'CO', 'Congo'=>'CG', 'Cook Islands'=>'CK', 'Costa Rica'=>'CR', 'Croatia'=>'HR', 'Curacao'=>'CB', 'Cyprus'=>'CY', 'Czech Republic'=>'CZ', 'Denmark'=>'DK', 'Djibouti'=>'DJ', 'Dominica'=>'DM', 'Dominican Republic'=>'DO', 'Ecuador'=>'EC', 'Egypt'=>'EG', 'El Salvador'=>'SV', 'England'=>'EN', 'Equitorial Guinea'=>'GQ', 'Eritrea'=>'ER', 'Estonia'=>'EE', 'Ethiopia'=>'ET', 'Faeroe Islands'=>'FO', 'Fiji'=>'FJ', 'Finland'=>'FI', 'France'=>'FR', 'French Guiana'=>'GF', 'French Polynesia'=>'PF', 'Gabon'=>'GA', 'Gambia'=>'GM', 'Germany'=>'DE', 'Ghana'=>'GH', 'Gibraltar'=>'GI', 'Greece'=>'GR', 'Greenland'=>'GL', 'Grenada'=>'GD', 'Guadeloupe'=>'GP', 'Guam'=>'GU', 'Guatemala'=>'GT', 'Guinea'=>'GN', 'Guinea-Bissau'=>'GW', 'Guyana'=>'GY', 'Haiti'=>'HT', 'Holland'=>'HO', 'Honduras'=>'HN', 'Hong Kong'=>'HK', 'Hungary'=>'HU', 'Iceland'=>'IS', 'India'=>'IN', 'Indonesia'=>'ID', 'Iran'=>'IR', 'Iraq'=>'IQ', 'Ireland'=>'IE', 'Israel'=>'IL', 'Italy'=>'IT', 'Ivory Coast (Cote d\'Ivoire)'=>'CI', 'Jamaica'=>'JM', 'Japan'=>'JP', 'Jordan'=>'JO', 'Kazakhstan'=>'KZ', 'Kenya'=>'KE', 'Kiribati'=>'KI', 'Korea, South'=>'KR', 'Kosrae'=>'KO', 'Kuwait'=>'KW', 'Kyrgyzstan'=>'KG', 'Laos'=>'LA', 'Latvia'=>'LV', 'Lebanon'=>'LB', 'Lesotho'=>'LS', 'Liberia'=>'LR', 'Liechtenstein'=>'LI', 'Lithuania'=>'LT', 'Luxembourg'=>'LU', 'Macau'=>'MO', 'Macedonia'=>'MK', 'Madagascar'=>'MG', 'Madeira'=>'ME', 'Malawi'=>'MW', 'Malaysia'=>'MY', 'Maldives'=>'MV', 'Mali'=>'ML', 'Malta'=>'MT', 'Marshall Islands'=>'MH', 'Martinique'=>'MQ', 'Mauritania'=>'MR', 'Mauritius'=>'MU', 'Mexico'=>'MX', 'Micronesia'=>'FM', 'Monaco'=>'MC', 'Montserrat'=>'MS', 'Morocco'=>'MA', 'Mozambique'=>'MZ', 'Myanmar'=>'MM', 'Namibia'=>'NA', 'Nepal'=>'NP', 'Netherlands'=>'NL', 'Netherlands Antilles'=>'AN', 'Nevis'=>'NV', 'New Caledonia'=>'NC', 'New Zealand'=>'NZ', 'Nicaragua'=>'NI', 'Niger'=>'NE', 'Nigeria'=>'NG', 'Niue'=>'NU', 'Norfolk Island'=>'NF', 'Northern Ireland'=>'NB', 'Northern Mariana Islands'=>'MP', 'Norway'=>'NO', 'Oman'=>'OM', 'Pakistan'=>'PK', 'Palau'=>'PW', 'Panama'=>'PA', 'Papua New Guinea'=>'PG', 'Paraguay'=>'PY', 'Peru'=>'PE', 'Philippines'=>'PH', 'Poland'=>'PL', 'Ponape'=>'PO', 'Portugal'=>'PT', 'Puerto Rico'=>'PR', 'Qatar'=>'QA', 'Reunion'=>'RE', 'Romania'=>'RO', 'Rota'=>'RT', 'Russia'=>'RU', 'Rwanda'=>'RW', 'Saba'=>'SS', 'Saipan'=>'SP', 'Saudi Arabia'=>'SA', 'Scotland'=>'SF', 'Senegal'=>'SN', 'Seychelles'=>'SC', 'Sierra Leone'=>'SL', 'Singapore'=>'SG', 'Slovak Republic'=>'SK', 'Slovenia'=>'SI', 'Solomon Islands'=>'SB', 'South Africa'=>'ZA', 'Spain'=>'ES', 'Sri Lanka'=>'LK', 'St. Barthelemy'=>'NT', 'St. Christopher'=>'SW', 'St. Croix'=>'SX', 'St. Eustatius'=>'EU', 'St. John'=>'UV', 'St. Kitts'=>'KN', 'St. Lucia'=>'LC', 'St. Maarten'=>'MB', 'St. Martin'=>'TB', 'St. Thomas'=>'VL', 'St. Vincent and the Grenadines'=>'VC', 'Sudan'=>'SD', 'Suriname'=>'SR', 'Swaziland'=>'SZ', 'Sweden'=>'SE', 'Switzerland'=>'CH', 'Syria'=>'SY', 'Tahiti'=>'TA', 'Taiwan'=>'TW', 'Tajikistan'=>'TJ', 'Tanzania'=>'TZ', 'Thailand'=>'TH', 'Tinian'=>'TI', 'Togo'=>'TG', 'Tonga'=>'TO', 'Tortola'=>'TL', 'Trinidad & Tobago'=>'TT', 'Truk'=>'TU', 'Tunisia'=>'TN', 'Turkey'=>'TR', 'Turks and Caicos Islands'=>'TC', 'Tuvalu'=>'TV', 'U.S. Virgin Islands'=>'VI', 'Uganda'=>'UG', 'Ukraine'=>'UA', 'Union Island'=>'UI', 'United Arab Emirates'=>'AE', 'United Kingdom'=>'GB', 'United States'=>'US', 'Uruguay'=>'UY', 'Uzbekistan'=>'UZ', 'Vanuatu'=>'VU', 'Venezuela'=>'VE', 'Vietnam'=>'VN', 'Virgin Gorda'=>'VR', 'Wake Island'=>'WK', 'Wales'=>'WL', 'Wallis and Futuna Islands'=>'WF', 'Western Samoa'=>'WS', 'Yap'=>'YA', 'Yemen'=>'YE', 'Zaire'=>'ZR', 'Zambia'=>'ZM', 'Zimbabwe'=>'ZW' ); %STATES =('AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'DC' => 'District of Columbia', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming', 'AA' => 'AP', 'AE' => 'AE', 'AP' => 'AP' ); #--------------------------------------------------------------------------------- sub get_configs{ open (FILE, "$data_directory/config") ||&system_busy('No config file found, you need to configure your options in CommerceBuddy then publish those options before CartIt will work. This is covered in the installation manual.'); my @CONFIGS = (); close(FILE); chomp(@CONFIGS); foreach $config (@CONFIGS){ my ($name, $value) = split(/\|/,$config); $USERCONFIGS{$name} = $value; #Global } $got_configs =1; } #--------------------------------------------------------------------------------- sub get_hash{ my($file) = shift; $file=(&remove_specials($file)); my(%R); my $activefile = "$data_directory/$file"; $activefile = "$cart_directory/$cart_ID\.session" if($file eq 'SESSION_FILE'); return()if(!-e "$activefile"); open (FILE, "$activefile") || return(); my @HASHFILE = (); close(FILE); chomp(@HASHFILE); foreach $config (@HASHFILE){ my ($name, $value) = split(/\|/,$config,2); $R{$name} = $value; } return(%R); } #--------------------------------------------------------------------------------- sub get_taxes{ my($t,@TAX,@FILE); local(@TAXES); open (FILE, "$data_directory/taxes.txt") || return(0); @FILE = (); close(FILE); chomp(@FILE); foreach $t (@FILE){ $ISLOGIC_TAXES=1 if($t =~/^##|^#!/); @TAX = split(/\|/,$t); push(@TAXES,[@TAX]); } return(@TAXES); #GLOBAL } #--------------------------------------------------------------------------------- sub parse_form{ if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); }else{ ($ENV{'REQUEST_METHOD'} eq 'POST'); if($ENV{'CONTENT_LENGTH'}>33000){&system_error('Spam avoided!');} read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } foreach $pair (@pairs) { local($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/ge; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9]{2})/pack("C", hex($1))/ge; $value =~ s/[\|`;]//g; $value=~ s/^\s+//g; $value =~ s//>/g; $value =~ s/\n/\\n/g; $value =~ s/"/"/g; &get_impacts($name,$value); } } #--------------------------------------------------------------------------------- sub get_cart_id{ &system_error("The Shopping Carts directory ($cart_directory) does not exist.","Error message displayed.") unless (-d "$cart_directory"); $cart_ID = $CARTITSESSION{'account'} if(!$cart_ID); # if active, use first. $cart_ID = $WEBDAT{'cid'}if(!$cart_ID); # use STATE info Pass next. $cart_ID = &get_cookie('cid')if(!$cart_ID); # If only session cookies OK. $cart_ID = &get_cookie('shopping_id')if(!$cart_ID);# for persistent cookies. $cart_ID = &gen_unique_id if(!$cart_ID); $cart_ID = &remove_specials($cart_ID); if (!-e "$cart_directory/$cart_ID.cart"){ open(NEWCART, ">>$cart_directory/$cart_ID.cart"); close (NEWCART); chmod(0777, "$cart_directory/$cart_ID.cart"); } if (!-e "$cart_directory/$cart_ID.saved"){ open(NEWCART, ">>$cart_directory/$cart_ID.saved"); close (NEWCART); chmod(0777, "$cart_directory/$cart_ID.saved"); } &cartitsession_read; } sub do_activate_session{ return if(!$CARTITSESSION{'logged_in'} && !$CARTITSESSION{'account'}); $cart_ID = $CARTITSESSION{'account'}; return if($CARTITSESSION{'ses_pureactive'}); rename("$cart_directory/$CARTITSESSION{'old_cartid'}.saved","$cart_directory/$cart_ID.saved")if(-e "$cart_directory/$CARTITSESSION{'old_cartid'}.saved"); rename("$cart_directory/$CARTITSESSION{'old_cartid'}.gift","$cart_directory/$cart_ID.gift")if(-e "$cart_directory/$CARTITSESSION{'old_cartid'}.gift"); my @totalfile; if(-e "$cart_directory/$CARTITSESSION{'old_cartid'}.cart"){ &cartitsession_rewrite; if (-s "$cart_directory/$CARTITSESSION{'old_cartid'}.cart"){ open(MYFILE, "$cart_directory/$CARTITSESSION{'old_cartid'}.cart"); @totalfile=(); close(MYFILE); chomp(@totalfile); } unlink("$cart_directory/$CARTITSESSION{'old_cartid'}.cart"); open(NEWCART, ">>$cart_directory/$cart_ID.cart"); print NEWCART @totalfile; close (NEWCART); chmod(0777, "$cart_directory/$cart_ID.cart"); } &cartitsession_update('ses_pureactive',1); } #--------------------------------------------------------------------------------- sub gen_unique_id{ my($id) = time() . $$; $id =~s/\D//g; return($id); } #--------------------------------------------------------------------------------- sub list_it{ my($addmessage) = 1; my($new_mail,$file) = @_; return(0)if($file eq ""); return(0) if(!defined($WEBDAT{'subscribe'})); $file = &remove_specials($file); return(0)if(($new_mail =~ /[,|\/\\]|(@.*@)|(\.\.)|(\.$)/) || ($new_mail !~/^[\w\-\.]+[\%\+]?[\w\-\.]*\@[0-9a-zA-Z\-]+\.[0-9a-zA-Z\-\.]+$/)); return(0)if(!-e "$data_directory/$file.list"); if (&file_lock('mailing')){ open(LIST, "$data_directory/$file.list") ||&emergency_unlock_file('mailing','Could not open list file'); while (){ chomp($_); if ($_ eq $new_mail){ my($addmessage) = 0; last; } } close(LIST); } if(!$addmessage){ &unlock_file('mailing'); return(0); } open (LIST, ">>$data_directory/$file.list") ||&emergency_unlock_file('mailing','Could not open list file'); print LIST "$new_mail\n"; close (LIST); &unlock_file('mailing') } #--------------------------------------------------------------------------------- sub search_db{ my($file, $field, $string) =@_; my(@RESULTS,@REC); $file = &remove_specials($file); return()if(!-e "$data_directory/$file"); return()if(-z "$data_directory/$file"); open (FILE, "$data_directory/$file") ||return(); my ($LINE) = ; close(FILE); my @FILETEST = split(/\|/,$LINE); return()if((@FILETEST)< $field +1); open (FILE, "$data_directory/$file") ||return(); while(){ chomp($_); @REC = split(/\|/,$_); if(!$search_strict){ if($REC[$field] =~ /\Q$string\E/io){ push(@RESULTS,[@REC]); } }else{ if($REC[$field] eq "$string"){ push(@RESULTS,[@REC]); } } } close(FILE); return(@RESULTS); } #--------------------------------------------------------------------------------- sub delete_account{ &system_busy('Account file in in heavy use.') if(!&file_lock('accounts')); if(open(FILE, "$data_directory/account.new")){ @FILELINES = (); close(FILE); if(open(FILE, ">$data_directory/account.new")){ foreach $fineline (@FILELINES){ chomp($fineline); @REC = split(/\|/,$fineline); if($REC[2] ne "$WEBDAT{'email'}" || $REC[1] ne "$WEBDAT{'pass'}"){ print FILE "$fineline\n"; }else{ $result++; } } close(FILE); } &unlock_file('accounts'); #NOW! } return($result); } #--------------------------------------------------------------------------------- sub make_cartitadd{ my ($description, $price, $weight,$taxable,$smarttax) = @_; if ($description ne "" && $price > 0){ print sprintf("",$price); } } #--------------------------------------------------------------------------------- sub print_image{ if($_[0] ne ""){ print "\"[IMAGE]\""; } } #--------------------------------------------------------------------------------- sub print_link{ my($text, $url) = @_; if($text ne "" && $url ne ""){ print "$text"; }elsif($text ne ""){ print "$text"; } } #--------------------------------------------------------------------------------- sub errorform{ $USERCONFIGS{'form_reject_reason'} =shift; &print_http_header if(!$http_header_printed); print &get_file_as_iostring('checkout_form_reject_error.html'); exit; } #--------------------------------------------------------------------------------- #--------------------------------------------------------------------------------- sub send_mail{ my($to_mail, $from,$subject,$body,$content_type) = @_; return(0)if(!&valid_mail($to_mail)); if($MAIL =~ /\//){ return(0)if(@_ <= 3 || !-e $MAIL); $content_type = "text/plain" if($content_type eq ""); open (MAIL, "|$MAIL -t") ||&system_busy; print MAIL "To: $to_mail\n"; print MAIL "From: $from\n"; print MAIL "Content-type: $content_type\n"; print MAIL "Subject: $subject\n\n"; print MAIL "$body\n"; close(MAIL); return(1); }elsif($MAIL ne ''){ $remote_smtp_server = $MAIL; $remote_smtp_server =~ s/^\s+//g; $remote_smtp_server =~ s/\s+$//g; $body =~ s/^\./\.\./gm; $body =~ s/\r\n/\n/g; $body =~ s/\n/\r\n/g; if (!$to_mail){ &write_error('No to mail address', 'No Mail Sent'); return(0); } my($proto) = (getprotobyname('tcp'))[2]; my($port) = (getservbyname('smtp', 'tcp'))[2]; my($remote_smtp_serveraddr) = (gethostbyname($remote_smtp_server))[4]; if (!defined($remote_smtp_serveraddr)){ &write_error('SMTP Server address not resolved, update $MAIL to a valid SMTP server address.', 'No Mail Sent'); return(0); } if (!socket(MAIL,2,1, $proto)){ &write_error('MAIL: Could not find socket', 'No Mail Sent'); return(0); } if (!connect(MAIL, pack('Sna4x8',2, $port, $remote_smtp_serveraddr))){ &write_error('MAIL: Could not connect to socket', 'No Mail Sent'); return(0); } my($oldfh) = select(MAIL); $| = 1; select($oldfh); $_ = ; if (/^[45]/){ close(MAIL); &write_error("SMTP Server returned '$_' error upon connect", 'No Mail Sent'); return(0); } # START TALKING! print MAIL "helo $MAIL\r\n"; $_ = ; if(/^[45]/){ close(MAIL); chop($_); &write_error("SMTP Server returned '$_' error upon helo", 'No Mail Sent'); return(0); } print MAIL "mail from: <$from>\r\n"; $_ = ; if (/^[45]/){ close(MAIL); chop($_); &write_error("SMTP Server returned '$_' error upon telling server who mail was from", 'No Mail Sent'); return(0); } print MAIL "rcpt to: <$to_mail>\r\n"; $_ = ; if (/^[45]/){ close(MAIL); chomp($_); &write_error("SMTP Server returned '$_' error upon telling server who mail was to", 'No Mail Sent'); return(0); } print MAIL "data\r\n"; $_ = ; if (/^[45]/){ close MAIL; chomp($_); &write_error("SMTP Server returned '$_' error upon requesting to send \"data\"", 'No Mail Sent'); return(0); } print MAIL "To: $to_mail\r\n"; print MAIL "From: $from\r\n"; if($content_type ne ""){ print MAIL "Content-type: $content_type\n"; } print MAIL "Subject: $subject\r\n\r\n"; print MAIL "$body"; print MAIL "\r\n.\r\n"; $_ = ; if (/^[45]/) { close(MAIL); &write_error('SMTP Server returned 45 error after feeding message body', 'No Mail Sent'); return(0); } print MAIL "quit\r\n\r\n"; close(MAIL); return(1); } return(0); } #--------------------------------------------------------------------------------- sub print_http_header{ return()if($http_header_printed); my($ctype) = shift; $ctype = "text/html" if($ctype eq ""); if($NOCACHE){ print "Cache-Control: no-cache\n"; print "Pragma: no-cache\n"; } print "Content-type: $ctype\n\n"; $http_header_printed = 1; } #--------------------------------------------------------------------------------- sub strip_html{ my($line) = $_[0]; $line =~ s/\s+/ /g; $line =~ s//>/g; return($line); } #--------------------------------------------------------------------------------- sub file_lock{ my($locfile) = shift; return(0)if($locfile eq "" || $locfile =~ /\W/ || length($locfile > 25)); $locfile = &remove_specials($locfile); $locfile = "$data_directory/$locfile.lock"; return(0) if(-e "$data_directory/manager.lock"); my($i) = 0; while(-e "$locfile" && $i<=4){ sleep(1); $i++; } if(-e "$locfile"){ if (-M "$locfile" > 0.0035){ unlink("$locfile"); } } if(!-e $locfile){ open(FLOCK,">$locfile"); print FLOCK "1"; close(FLOCK); chmod(0777, "$locfile"); return(1); }else{ &system_busy; } } #--------------------------------------------------------------------------------- sub system_error{ my($outmessage,$action) = @_; open (FILE, ">>$data_directory/cartiterror.log") || exit; my($message) = time() . "\|"; $message .= $ENV{'SCRIPT_NAME'} . "\|"; $message .= $ENV{'REMOTE_ADDR'} . "\|"; $message .= $ENV{'HTTP_USER_AGENT'} . "\|"; $message .= $outmessage . "\|"; $message .= $action; $message =~ s/\n/ /g; print FILE "$message\n"; close(FILE); chmod(0777, "$data_directory/cartiterror.log"); &print_http_header; &print_document_top('Form Input Rejected'); print " 
\n"; print "
\n"; print "\n"; print "

Ouch!

\n"; print "This application has experianced a non fatal error!

\n"; print "

\n"; &print_document_foot; exit; } #--------------------------------------------------------------------------------- sub write_error{ my($message,$action) = @_; my($write_m); open (FILE, ">>$data_directory/cartiterror.log") || return(0); $write_m .= time() . '|'; $write_m .= $ENV{'SCRIPT_NAME'} . '|'; $write_m .= $ENV{'REMOTE_ADDR'} . '|'; $write_m .= $ENV{'HTTP_USER_AGENT'} . '|'; $write_m .= $message . '|'; $write_m .= $action; $write_m =~ s/\n/ /g; print FILE "$write_m\n"; close(FILE); return(); } #--------------------------------------------------------------------------------- sub set_cookie{ return(0)if($http_header_printed); my ($name, $value, $expires_in, $in_type) =@_; return(0)if($name eq "" || $value eq "" || $expires_in eq "" || $in_type eq ""); my %equation = ( 'hours' => '3600', 'days' => '86400', 'months' => '2628000', 'years' => '31536000' ); if($in_type eq 'session'){ print sprintf("Set-Cookie:%s\=%s; path=/; domain=$domain_name\n",urlencode($name),urlencode($value)); }else{ $equation{$in_type} = 100 if(!exists($equation{$in_type})); $mygmt = gmtime((time() + ($expires_in * $equation{$in_type}))); print sprintf("Set-Cookie:%s\=%s; expires=$mygmt; path=/; domain=$domain_name\n",urlencode($name),urlencode($value)); } } #--------------------------------------------------------------------------------- sub get_cookie{ my($name)=$_[0]; $name = urlencode($name); return() if($name eq ""); if($ENV{'HTTP_COOKIE'}=~/$name/){ # fix urchin my %mycookie = map split (/=/), split (/; /,$ENV{HTTP_COOKIE}); my(%mycookie); my (@dough) = split (/; /,$ENV{HTTP_COOKIE}); for (@dough) { my($key,$val) = split (/=/,$_); $mycookie{$key} = $val; } # end fix if($mycookie{$name}){ return(urldecode($mycookie{$name})) }else{ return(); } } } #--------------------------------------------------------------------------------- sub remove_specials{ my($string,$method) = @_; $string =~s/[^\w\.]//ig; return($string); } #--------------------------------------------------------------------------------- sub write_to_file{ my($filename,$string) = @_; $filename =&remove_specials($filename); return(0) if(!-e "$data_directory/$filename"); if(!$overwrite_file_go){ open (FILE, ">>$data_directory/$filename") || return(); }else{ open (FILE, ">$data_directory/$filename") || return(); } print FILE "$string"; close(FILE); } #--------------------------------------------------------------------------------- sub get_file_as_string{ my($file) = shift; $file=(&remove_specials($file)); return()if($file eq "" || !-e "$data_directory/$file"); open(FILE, "$data_directory/$file") || return(); my(@LINES)=; close(FILE); $file_lines = join('',@LINES); return($file_lines) } sub parse_to_io_string{ my $string = shift; return('') if($string eq ''); $string =~ s/%io_web_(\w+)%/$WEBDAT{$1}/ig; $string =~ s/%io_ses_(\w+)%/$SESSION{$1}/ig; $string =~ s/%io_env_(\w+)%/$ENV{$1}/ig; $string =~ s/%io_(\w+)%/$USERCONFIGS{$1}/ig; if(@SSL_RESULT){ $string =~ s/%sslresult_(\d+)%/$SSL_RESULT[$1]/ig; } return($string); get_webdat_io; } sub get_webdat_io{ return if($GOT_WEBDAT_IO); $USERCONFIGS{'account_number'} = $WEBDAT{'account'}; $USERCONFIGS{'account_password'} = $WEBDAT{'db_pass'}; $USERCONFIGS{'account_notes'} = $WEBDAT{'notes'}; $USERCONFIGS{'shopper_email'} = $WEBDAT{'email'}; $USERCONFIGS{'shopper_company'} = $WEBDAT{'businessname'}; $USERCONFIGS{'shopper_name'} = $WEBDAT{'nameoncard'}; $USERCONFIGS{'shopper_street'} = $WEBDAT{'street'}; $USERCONFIGS{'shopper_city'} = $WEBDAT{'city'}; $USERCONFIGS{'shopper_state'} = $WEBDAT{'state'}; $USERCONFIGS{'shopper_zip'} = $WEBDAT{'zip'}; $USERCONFIGS{'shopper_country'} = $WEBDAT{'country'}; $USERCONFIGS{'shopper_phone'} = $WEBDAT{'phone'}; $USERCONFIGS{'shipping_company'} = $WEBDAT{'businessname2'}; $USERCONFIGS{'shipping_name'} = $WEBDAT{'receiveby'}; $USERCONFIGS{'shipping_street'} = $WEBDAT{'street2'}; $USERCONFIGS{'shipping_city'} = $WEBDAT{'city2'}; $USERCONFIGS{'shipping_state'} = $WEBDAT{'state2'}; $USERCONFIGS{'shipping_zip'} = $WEBDAT{'zip2'}; $USERCONFIGS{'shipping_country'} = $WEBDAT{'country2'}; $USERCONFIGS{'shipping_phone'} = $WEBDAT{'phone2'}; $USERCONFIGS{'cvv2'} = $WEBDAT{'cvv2'}; $USERCONFIGS{'cgibin'} = $USERCONFIGS{'cgi_bin'}; $USERCONFIGS{'sslcgibin'} = $USERCONFIGS{'ssl_cgi_bin'}; if($USERCONFIGS{'use_ssl'}){ $USERCONFIGS{'pref_cgibin'} = $USERCONFIGS{'ssl_cgi_bin'}; }else{ $USERCONFIGS{'pref_cgibin'} = $USERCONFIGS{'cgi_bin'}; } my $name_parts = split(/ /,$WEBDAT{'nameoncard'}); if($name_parts>2){ # this seems silly my $tnc = $WEBDAT{'nameoncard'}; $tnc =~ s/\s*(\w+)\s*(\w+)\s*(.*)//; $USERCONFIGS{'logical_shopper_fname'}=$1; $USERCONFIGS{'logical_shopper_mname'}=$2; $USERCONFIGS{'logical_shopper_lname'}=$3; }else{ ($USERCONFIGS{'logical_shopper_fname'},$USERCONFIGS{'logical_shopper_lname'})= split(/ /,$WEBDAT{'nameoncard'},3); }# Done! $USERCONFIGS{'shipping_country_code'} = $WEBDAT{'country2'}; $USERCONFIGS{'shopper_country_code'} = $WEBDAT{'country'}; if($WEBDAT{'country'} eq "US"){ $USERCONFIGS{'shopper_state_int'} = ""; $USERCONFIGS{'shopper_state_us'} = $WEBDAT{'state'}; }else{ $USERCONFIGS{'shopper_state_int'} = $WEBDAT{'state'}; $USERCONFIGS{'shopper_state_us'} = ""; } if($PROCESS_COUNTRY){ foreach $countryn (sort keys %COUNTRIES){ if($COUNTRIES{"$countryn"} eq "$WEBDAT{'country2'}"){ $USERCONFIGS{'shipping_country'} = $countryn; } if($COUNTRIES{"$countryn"} eq "$WEBDAT{'country'}"){ $USERCONFIGS{'shopper_country'} = $countryn; } } } $GOT_WEBDAT_IO =1; } # ---------------------------------------------------------------------------------------- sub get_file_as_iostring{ my($file) = shift; $file=(&remove_specials($file)); my($filestring); return()if($file eq "" || !-e "$data_directory/$file"); open(FILE, "$data_directory/$file") || return(); my(@LINES)=; close(FILE); $filestring = join('',@LINES); $USERCONFIGS{'stylesheet_content'} = &get_file_as_string('stylesheet.html'); &get_webdat_io; $filestring =~ s/%io_web_(\w+)%/$WEBDAT{$1}/ig; $filestring =~ s/%io_smartstring_(\w+)%/$SMARTSTRING{$1}/ig; $filestring =~ s/%io_ses_(\w+)%/$SESSION{$1}/ig; $filestring =~ s/%io_env_(\w+)%/$ENV{$1}/ig; $filestring =~ s!([^){ print $_; } close(FILE); return(1); } #--------------------------------------------------------------------------------- sub get_top_band{ my $return_data = ''; if($USERCUSTOM{'print_top_band'}){ $return_data .= "\n"; $return_data .= " \n"; $return_data .= " \n"; $return_data .= " \n"; $return_data .= "
Store Entrance\n"; $return_data .= " \n"; $return_data .= " Checkout \n"; if($USERCONFIGS{'use_ssl'}){ $return_data .= " $USERCUSTOM{'FREE_ACCOUNT'} \n"; }else{ $return_data .= " $USERCUSTOM{'FREE_ACCOUNT'} \n"; } $return_data .= "\n"; $return_data .= " Empty Cart
\n"; } } #--------------------------------------------------------------------------------- sub show_cartit{ #$show_cartit++; #die if($show_cartit ==2); my($editable)=shift; my($i,$thecolor,@FCART,$numprodincart,%SPECIALTAXES,$taxableshiptotal,$taxabletotal,$asc,$totalgiftfee,$DOSAVED); $gtotal =0; local $total=0; local $truetotal=0; if (-z "$cart_directory/$cart_ID.cart"){ my $CARTIT = ''; if(&has_saved_cart){ $CARTIT .= &get_top_band; $CARTIT .= &get_file_as_iostring('header_empty_but_saved.html'); $CARTIT .= &show_later_cart if(&has_saved_cart); $CARTIT .= &get_file_as_iostring('footer.html'); return $CARTIT; }else{ $USERCONFIGS{'stylesheet_content'} = &get_file_as_string('stylesheet.html'); $CARTIT = &get_file_as_iostring('cartit_shopping_cart_empty.html'); return $CARTIT; } } &get_discount; $/='{ENDCARTITITEM}'; open(CART, "$cart_directory/$cart_ID.cart") ||&system_busy; @FCART = (); close(CART); chomp(@FCART); $/="\n"; # Global: $total $GLOBAL_HAS_GIFTS = &check_gift_items(@FCART); my($lineitem,$return_data ); my($tablecolor) = 0; if ($editable){ $return_data .= &get_top_band; $return_data .= &get_file_as_iostring('header.html'); if($WEBDAT{'cartit_dynamic_file'} ne ""){ if($WEBDAT{'cartit_dynamic_file'} =~ /\.html$/){ $return_data .= get_file_as_string($WEBDAT{'cartit_dynamic_file'}); } } $return_data .= "
" if(!$NOCENTER_CARTIT); $return_data .= "\n"; $return_data .= ""; $return_data .= ""; $return_data .= ""; $return_data .= "
"; if($CARTITSESSION{'logged_in'} ==1){ $return_data .= "Welcome back $CARTITSESSION{'fullname'}. This is your personal shopping cart!" }else{ $return_data .= "You are not signed in to your account, please sign in for special features!"; $return_data .= "

NOTE: Be sure to sign in. If you do not sign in to your account, your "Saved for Later" shopping list will NOT be saved for your next visit. If you checkout online today, you will automatically be signed in and your items will be saved for future shopping." if(&has_saved_cart); } if($WEBDAT{'sfl'} && !$WEBDAT{'savcart'}){ $return_data .= '

'; $return_data .= "Item successfully moved to your "Saved for Later" shopping list (Look below the shopping cart)."; if($WARN_GIFT_MOVE){ $return_data .= "
Please note that gift recipients can not be saved in your "Saved for Later" shopping list at this time."; } $return_data .= '
'; } $return_data .= "

"; $return_data .= "
" if(!$NOCENTER_CARTIT); $return_data .= "
\n"; $return_data .= " "; $return_data .= " \n"; if($WEBDAT{'ref'}){ $return_data .= "\n"; }elsif($ENV{'HTTP_REFERER'} ne ""){ $return_data .= "\n"; }else{ $return_data .= "\n"; } } $return_data .= "
" if(!$NOCENTER_CARTIT); $return_data .= "\n"; $return_data .= "\n"; $return_data .= "\n"; $return_data .= "\n" if($editable); if($USERCONFIGS{'go_gift'}){ $return_data .= "\n" } $return_data .= "\n" if($editable); $return_data .= "\n"; $return_data .= ""; $return_data .= "\n"; $return_data .= "\n"; #$styleline = '0'; for($i=0;$i<@FCART;$i++){ ($quantity,$sku,$description,$description_ext,$price,$weight,$id,$taxable,$smarttaxname,$smarttaxperc,$smartistaxable,$smartcondition,$mref,$giftname,$giftfee,$discountcode) = split(/\|/,$FCART[$i]); ($isqdisced,$price) = &get_discount_amountofcode($quantity,$price,$discountcode); $amount = sprintf("%.2f",$quantity*$price); $trueamount = $amount; $totalgiftfee += ($giftfee *$quantity); if($discount >0){ $trueamount = sprintf("%.2f",($trueamount - ($trueamount *$discount))); $total_discount += sprintf("%.2f",($amount *$discount)); } if(($smarttaxname ne "")&&(($smartcondition eq "" || $TCONDITIONS{$smartcondition} ==1))){ if(!$SPECIALTAXES{$smarttaxname}){ $asc .= '*'; $SPECIALTAXES{"\_$smarttaxname"} = $asc; } $SPECIALTAXES{$smarttaxname} += sprintf("%.2f",($trueamount * $smarttaxperc)); } $total += sprintf("%.2f",$amount); $truetotal += sprintf("%.2f",$trueamount); if($taxable){ if($smartistaxable){ $taxabletotal += sprintf("%.2f",($trueamount + ($trueamount * $smarttaxperc))); }else{ $taxabletotal += sprintf("%.2f",$trueamount) } } $numprodincart+=$quantity; $return_data .= "\n"; $return_data .= "'; $return_data .= "" if($editable); if($USERCONFIGS{'go_gift'}){ $return_data .= ""; } $return_data .= "" if($editable); $return_data .= "\n"; $return_data .= "\n"; $return_data .= "\n"; $return_data .=''; $tablecolor++; $tablecolor=0 if($tablecolor==2); } undef(@FCART); $total = sprintf("%.2f",$total); $return_data .= ""; my $colspan = $USERCONFIGS{'go_gift'} ? "6" : "5"; if($editable){ $return_data .= ""; $return_data .= "\n"; if($total_discount > 0){ $total_discount = sprintf("%.2f",$total_discount); $return_data .= ''; if($editable){ $return_data .= ""; $return_data .= "\n"; } foreach $stax (sort keys %SPECIALTAXES){ if($stax!~/^_/){ $return_data .= ''; if($editable){ $return_data .= ""; $return_data .= "\n"; } } if($totalgiftfee>0){ $truetotal = sprintf("%.2f",$totalgiftfee+$truetotal); if($USERCONFIGS{'wrapping_is_taxable'}){ $taxabletotal = sprintf("%.2f",$taxabletotal += $totalgiftfee); } $return_data .= ''; if($editable){ $return_data .= ""; $return_data .= sprintf("\n"; } if(($total!=$truetotal)&&($editable)){ $return_data .= ''; if($editable){ $return_data .= "\n"; } if ($editable){ $return_data .= "
QuantityDeleteGiftLaterDescriptionUnit Price Total
"; if($editable){ $return_data .= ""; }else{ $return_data .= "$quantity"; } $return_data .= '$USERCUSTOM{'TRASH_CAN'}"; if($editable){ $return_data .= sprintf("",urlencode($giftname)); $return_data .= $giftname ne '' ? "$USERCUSTOM{'GIFT_CHECK_BOX_ON'}" : "$USERCUSTOM{'GIFT_CHECK_BOX_OFF'}"; }else{ $return_data .= $giftname ne '' ? "Yes" : "No"; } $return_data .= "" if($editable); $return_data .= "$USERCUSTOM{'SAVE_FOR_LATER'}"; if($sku ne ""){ $return_data .= '(' . $USERCUSTOM{'SKU_DISPLAY_TEXT'} . $sku . ') '; } if($mref ne "" && $editable){ $return_data .= " $description"; }else{ $return_data .= " $description"; } if(($smarttaxname ne "")&&(($smartcondition eq "" || $TCONDITIONS{$smartcondition} == 1))){ $return_data .= $SPECIALTAXES{"\_$smarttaxname"}; } $return_data .= " $description_ext "; if($isqdisced){ $return_data .= sprintf("Your quantity discount for this item is %2d%. This discount is reflected in the unit price of this item.",$isqdisced * 100); } if($USERCONFIGS{'go_gift'}){ if($giftname ne ""){ if($editable){ $return_data .= sprintf("
[This item is a gift for "$giftname"]",urlencode($giftname)); }else{ $return_data .= "
[This item is a gift for "$giftname"]"; } } } $return_data .= "
$price$amount
\n"; }else{ $return_data .= "\n"; } $return_data .= "Subtotal"; $return_data .= "$USERCONFIGS{'money_sign'}"; $return_data .= $total; $return_data .= "
\n"; }else{ $return_data .= "\n"; } $return_data .= "$discounttype$USERCONFIGS{'money_sign'}"; $return_data .= $total_discount; $return_data .= "
\n"; }else{ $return_data .= "\n"; } $return_data .= "$SPECIALTAXES{'_'.$stax}$stax"; $return_data .= sprintf("%.2f",$SPECIALTAXES{$stax}); $truetotal += $SPECIALTAXES{$stax}; $return_data .= "
\n"; }else{ $return_data .= "\n"; } $return_data .= "Gift Wrapping Options$USERCONFIGS{'money_sign'}%.2f",$totalgiftfee); $return_data .= "
\n"; }else{ $return_data .= "\n"; } $return_data .= sprintf("New Subtotal$USERCONFIGS{'money_sign'}%.2f",$truetotal); $return_data .= "
\n"; if(&got_currency_opts){ $return_data .= "
\n"; $return_data .= ""; if($CARTITSESSION{'currency_symbol'} ne '' && $CARTITSESSION{'currency_conversion'} ne '' && $editable){ $return_data .= "",$truetotal,$truetotal*$CARTITSESSION{'currency_conversion'}); } $return_data .= "
\n"; $return_data .= sprintf("Estimated conversion of $USERCONFIGS{'money_sign'}%.2f $USERCONFIGS{'def_money_sign_text'} to $CARTITSESSION{'currency_text'} is: [$CARTITSESSION{'currency_symbol'}] %.2f
Currency Conversion Options"; $return_data .= "

\n"; } $return_data .= " 

"; $return_data .= "

\n"; $return_data .= ""; $return_data .= "\n"; if($USERCONFIGS{'ssl_only'}){ $return_data .= '\n"; if(!$USERCONFIGS{'ssl_only'}){ $return_data .= "\n"; } $return_data .= "\n"; $return_data .= "
$USERCUSTOM{'MODIFY_CART'}'; }else{ $return_data .= ""; } if($USERCONFIGS{'use_ssl'}){ $return_data .= "$USERCUSTOM{'CHECK_OUT_SECURE'}"; } $return_data .= " "; $return_data .= ""; if(!$USERCONFIGS{'use_ssl'}){ $return_data .= "$USERCUSTOM{'CHECK_OUT_ONE_OPTION'}"; }else{ $return_data .= "$USERCUSTOM{'CHECK_OUT_NON_SECURE'}"; } $return_data .= "

\n"; $return_data .= &show_later_cart if(&has_saved_cart); } $gtotal = $truetotal; if(!$editable){ my($fee,$ship); if($USERCONFIGS{'use_shipping'}){ ($fee,$ship) = split(/\^/,$WEBDAT{'web_shipping_fee'}); if($fee > 0 || $ship ne ''){ $return_data .= ""; $return_data .= "\n"; $return_data .= "\n"; $return_data .= "$ship\n"; $return_data .= "\n"; $return_data .= "$fee\n"; } } $gtotal += $fee; $taxableshiptotal =($fee + $taxabletotal); if(@taxes){ for($i=0;$i<@taxes;$i++){ ($nil,$nil1,$l,$p,$ts) = split(/\^/,$taxes[$i]); if($ts){ $taxherefee = sprintf("%.2f",$taxableshiptotal * $p); }else{ $taxherefee = sprintf("%.2f",$taxabletotal * $p); } $gtotal += $taxherefee; if($taxherefee>0){ $return_data .= "\n"; $return_data .= ""; $return_data .= "\n"; $return_data .= "$l\n"; $return_data .= "\n"; $return_data .= "$USERCONFIGS{'money_sign'}$taxherefee\n"; $return_data .= "\n"; $return_data .= "\n"; } }# END LOOP }# END TAX if($WEBDAT{'method'} eq "3" && $USERCONFIGS{'codfee'} > 0){ $return_data .= "\n"; $return_data .= "C.O.D. Fee\n"; $return_data .= "\n"; $return_data .= "$USERCONFIGS{'money_sign'}$USERCONFIGS{'codfee'}\n"; $gtotal += $USERCONFIGS{'codfee'}; } $gtotal = sprintf("%.2f",$gtotal); if($discounttype eq "Total Savings With Coupon"){ $return_data .= "\n\n"; } $return_data .= "\n\n"; $return_data .= "\n\n"; $return_data .= ""; $return_data .= "\n"; $return_data .= "GRAND TOTAL\n"; $return_data .= "\n"; $return_data .= "$USERCONFIGS{'money_sign'}$gtotal\n"; $return_data .= "

\n"; if($CARTITSESSION{'currency_symbol'} ne '' && $CARTITSESSION{'currency_conversion'} ne ''){ $return_data .= "

\n"; $return_data .= ""; $return_data .= "",$truetotal,$truetotal*$CARTITSESSION{'currency_conversion'}); $return_data .= "
\n"; $return_data .= sprintf("Estimated conversion of $USERCONFIGS{'money_sign'}%.2f $USERCONFIGS{'def_money_sign_text'} to $CARTITSESSION{'currency_text'} is: [$CARTITSESSION{'currency_symbol'}]%.2f

\n"; } } $USERCONFIGS{'cart_total'} =$gtotal; $USERCONFIGS{'cart_sub_total'} =$total; if($editable){ $return_data .= get_file_as_iostring('footer.html'); } return($return_data); } # ------------------------------------------------------------------------------------------------ sub get_cart_total{ my(@FCART,$total,$itemline,$ret_shipping_total); $/='{ENDCARTITITEM}'; open(CART, "$cart_directory/$cart_ID.cart") || return(0); @FCART = (); close(CART); $/="\n"; $GLOBAL_HAS_GIFTS = &check_gift_items(@FCART); &get_discount; foreach $itemline (@FCART){ ($quantity,$sku,$description,$description_ext,$price,$weight,$id,$taxable,$smarttaxname,$smarttaxperc,$smartistaxable,$smartcondition,$mref,$giftname,$giftfee,$discountcode) = split(/\|/,$itemline); ($isqdisced,$price) = &get_discount_amountofcode($quantity,$price,$discountcode); $amount = sprintf("%.2f",$quantity*$price); $amount += ($giftfee *$quantity); if($discount > 0){ $amount = sprintf("%.2f",($amount - ($amount * $discount))); } # These fees are based on after discount prices. $CUSTOM_SHIPPING_WEIGHT_HASH{"$weight"} += $quantity; $CUSTOM_SHIPPING_TOTAL_WEIGHT += ($quantity * $weight); $CUSTOM_SHIPPING_ITEMS_IN_CART +=$quantity; $CUSTOM_SHIPPING_PRICES_IN_CART{"$amount"}+=$quantity; $CUSTOM_SHIPPING_CART_TOTAL +=$amount; $CUSTOM_SHIPPING_CONNECT_HASHD{"$id"}=[$weight,$quantity]; if(($smarttaxname ne "")&&(($smartcondition eq "" || $TCONDITIONS{$smartcondition} == 1))){ $amount = sprintf("%.2f",$amount + ($amount * $smarttaxperc)); } $total += sprintf("%.2f",$amount); } $USERCONFIGS{'cart_total'} =$total; return(sprintf("%.2f",$total)); } # ------------------------------------------------------------------------------------------------ sub get_impacts{ my($name,$value) = @_; my($t,$d,$p,$w,$n); if($name =~ /^sop/ && $value ne ""){ push (@sop, $value); }elsif(($name =~ /^eop\_.+/)&&($value ne "")){ $n = $name; ($t,$p) = split(/\_/,$n); push (@eop, "$p\^$value"); }elsif($name =~ /^cartitq\_\d+/){ $n = $name; ($d,$p)=split(/_/,$name); $ITEMS{"$p"} = $value; }elsif(($name =~ /^addit.?/) && ($value ne "")){ push(@addit, $value); }elsif(($name =~ /^textadd_.+\_/) && ($value ne "")){ $n = $name; ($n,$t,$p) = split(/\_/,$n); push(@textadd, "$t\^$value\^$p"); }elsif(($name =~ /^cartitqa\_.+\_\d+/) && ($value ne "")&&($value!~/\D/)){ $n = $name; ($n,$d,$p,$w,$t,$st) = split(/\_/,$n); push(@cartitqa, "$d\^$p\^$w\^$t\^$st\^$value"); }elsif($name eq "checkout_taxes"){ push(@taxes,"$value"); my($n,$d)=split(/\^/,$value); $TCONDITIONS{$n}=1; }elsif($name eq "cartit_gid"){ push(@gift_ids,"$value"); }else{ $WEBDAT{$name} = $value; } } # ---------------------------------------------------------------------------------------- sub get_date{ my($mytime,$include_time) = @_; my %months = ( 'Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12' ); my($day, $month, $mday, $time, $year) = split(/\s+/,localtime($mytime)); $mday = '0' . "$mday"if(length($mday) == 1); if($UK_TIME_FORMAT){ if($include_time){ return("$mday/$months{$month}/$year $time"); }else{ return("$mday/$months{$month}/$year"); } }else{ if($include_time){ return("$months{$month}/$mday/$year $time"); }else{ return("$months{$month}/$mday/$year"); } } } # ---------------------------------------------------------------------------------------- sub check_user_data{ $ISERROR =0; $WEBDAT{'state'}= uc($WEBDAT{'state'}); $WEBDAT{'state2'} = uc($WEBDAT{'state2'}); if(!valid_mail($WEBDAT{'email'})){ &errorform('The e-mail address you entered was invalid. America Online users: please include @aol.com in your e-mail address. Compuserve users: do not include commas in your e-mail address. '); } if($WEBDAT{'nameoncard'} eq ""){ $ERROR{'nameoncard'} = &get_error_string('No name was entered.'); $ISERROR = 1; } if($WEBDAT{'street'} eq ""){ $ERROR{'street'} = &get_error_string('No street address was entered.'); $ISERROR = 1; } if($WEBDAT{'city'} eq ""){ $ERROR{'city'} = &get_error_string('No city was entered.'); $ISERROR = 1; } if(($WEBDAT{'country'} eq "US") && ($WEBDAT{'state'} eq "")){ $ERROR{'state'} = &get_error_string('You specified the United States as your country, but you did not enter a U.S. state.'); $ISERROR = 1; } if($WEBDAT{'zip'} eq ""){ $ERROR{'zip'} = &get_error_string('No zip / postal code was entered.'); $ISERROR = 1; } if((length($WEBDAT{'zip'})!=5)&&($WEBDAT{'country'} eq "US")){ $ERROR{'zip'} = &get_error_string('U.S. residents should enter their 5 digit zip code.'); $ISERROR = 1; } if(($WEBDAT{'country'} eq "US") && (!exists($STATES{"$WEBDAT{'state'}"}))){ $ERROR{'state'} = &get_error_string('U.S. residents should enter a 2 character state code.'); $ISERROR = 1; } if($WEBDAT{'country'} eq ""){ $ERROR{'country'} = &get_error_string('No country was selected.'); $ISERROR = 1; } if($WEBDAT{'phone'} eq ""){ $ERROR{'phone'} = &get_error_string('No phone number was entered.'); $ISERROR = 1; } #SHIP if($WEBDAT{'sameasbilling'} ne '1'){ if($WEBDAT{'receiveby'} eq ""){ $ERROR{'receiveby'} = &get_error_string('No name was entered.'); $ISERROR = 1; } if($WEBDAT{'street2'} eq ""){ $ERROR{'street2'} = &get_error_string('No street address was entered.'); $ISERROR = 1; } if($WEBDAT{'city2'} eq ""){ $ERROR{'city2'} = &get_error_string('No city was entered.'); $ISERROR = 1; } if(($WEBDAT{'country2'} eq "US") && ($WEBDAT{'state2'} eq "")){ $ERROR{'state2'} = &get_error_string('You specified the United States as your country, but you did not enter a U.S. state.'); $ISERROR = 1; } if($WEBDAT{'zip2'} eq ""){ $ERROR{'zip'} = &get_error_string('No zip / postal code was entered.'); $ISERROR = 1; } if((length($WEBDAT{'zip2'})!=5)&&($WEBDAT{'country2'} eq "US")){ $ERROR{'zip2'} = &get_error_string('U.S. residents should enter their 5 digit zip code.'); $ISERROR = 1; } if(($WEBDAT{'country2'} eq "US") && (!exists($STATES{"$WEBDAT{'state2'}"}))){ $ERROR{'state2'} = &get_error_string('U.S. residents should enter a 2 character state code.'); $ISERROR = 1; } if($WEBDAT{'country2'} eq ""){ $ERROR{'country2'} = &get_error_string('No country was selected.'); $ISERROR = 1; } if($WEBDAT{'phone2'} eq ""){ $ERROR{'phone2'} = &get_error_string('No phone number was entered.'); $ISERROR = 1; } } if($ISERROR){ &account_manager($WEBDAT{'creatingnew'}); } } #--------------------------------------------------------------------------------- sub get_error_string{ local($error) =shift; return("**See Below: $error"); } #--------------------------------------------------------------------------------- sub get_account{ my($found)= 0; my($check_exists_only)= shift; my(@RECORD); $search_strict =1; if(&file_lock('accounts')){ @RECORD=&search_db('account.new',2,uc($WEBDAT{'email'})); &unlock_file('accounts'); #NOW! }else{ &system_busy; } $search_strict =0; if(!@RECORD){ $account_char = get_fileid_ofacount($WEBDAT{'email'}); return()if($account_char eq ""); $account_char .= "." . "accounts"; if(&file_lock('accounts')){ &make_account_active($account_char); &unlock_file('accounts'); #NOW! }else{ &system_busy; } $search_strict =1; if(&file_lock('accounts')){ @RECORD=&search_db('account.new',2,uc($WEBDAT{'email'})); &unlock_file('accounts'); #NOW! }else{ &system_busy; } $search_strict =0; } $i=0; return(0)if(!@RECORD); return(1)if($check_exists_only==1); $ACCOUNT_EXISTS = 1; if(!$check_exists_only){ for($i=0;$i<@RECORD;$i++){ if($WEBDAT{'pass'} eq $RECORD[$i][1]){ $found=1; last; } } return(0)if(!$found); } $WEBDAT{'account'} = $RECORD[$i][0]; $WEBDAT{'db_pass'} = $RECORD[$i][1]; $WEBDAT{'email'} = $RECORD[$i][2]; $WEBDAT{'businessname'} = $RECORD[$i][3]; $WEBDAT{'nameoncard'} = $RECORD[$i][4]; $WEBDAT{'street'} = $RECORD[$i][5]; $WEBDAT{'city'} = $RECORD[$i][6]; $WEBDAT{'state'} = $RECORD[$i][7]; $WEBDAT{'zip'} = $RECORD[$i][8]; $WEBDAT{'country'} = $RECORD[$i][9]; $WEBDAT{'phone'} = $RECORD[$i][10]; $WEBDAT{'businessname2'} = $RECORD[$i][11]; $WEBDAT{'receiveby'} = $RECORD[$i][12]; $WEBDAT{'street2'} = $RECORD[$i][13]; $WEBDAT{'city2'} = $RECORD[$i][14]; $WEBDAT{'state2'} = $RECORD[$i][15]; $WEBDAT{'zip2'} = $RECORD[$i][16]; $WEBDAT{'country2'} = $RECORD[$i][17]; $WEBDAT{'phone2'} = $RECORD[$i][18]; $WEBDAT{'notes'} = $RECORD[$i][19]; $WEBDAT{'subscribe'} = $RECORD[$i][20]; $session_poweruser =1; &cartitsession_update('account',$WEBDAT{'account'}); &cartitsession_update('email',$WEBDAT{'email'}); &cartitsession_update('fullname',$WEBDAT{'nameoncard'}); &cartitsession_update('logged_in',1); &cartitsession_update('old_cartid',$cart_ID) if($WEBDAT{'account'} ne $cart_ID); &cartitsession_rewrite; &do_activate_session if($WEBDAT{'ao'} == 2); $session_poweruser =0; return(1); } #--------------------------------------------------------------------------------- sub valid_mail{ ############################################################################################## # This function "valid_mail" and only this function in this application is public domain. # This function was written by the boys and girls in WWW-Scripts several years ago. ############################################################################################## my($email) = shift; return(0)if(($email eq "") || (length($email)<5)); if(($email =~ /[,|\/\\]|(@.*@)|(\.\.)|(\.$)/) || ($email !~/^[\w\-\.]+[\%\+]?[\w\-\.]*\@[0-9a-zA-Z\-]+\.[0-9a-zA-Z\-\.]+$/)){ return(0); }else{ return(1); } } #--------------------------------------------------------------------------------- sub get_fileid_ofacount{ my($account) = shift; my($tmp); return()if($account eq ""); $tmp = uc(substr($account,0,1)); if($tmp !~ /[A-Z]/){ $tmp = 'NA'; } return ($tmp); } #--------------------------------------------------------------------------------- sub count_file{ my($counter_file) = shift; $counter_file = &remove_specials($counter_file); return(0)if($counter_file eq ""); if(&file_lock("$counter_file")){ open(FILE, "$data_directory/$counter_file.count") ||&emergency_unlock_file($counter_file,'Could not open count file for reading'); $ret_num=(); close(FILE); $ret_num++; if(!-w "$data_directory/$counter_file.count"){ &emergency_unlock_file($counter_file,'CartIt does not have write permission to all counter files'); } open(FILE, ">$data_directory/$counter_file.count") || &emergency_unlock_file($counter_file,'Could not open count file for writing'); print FILE "$ret_num"; close(FILE); &unlock_file("$counter_file"); return($ret_num); }else{ &system_busy; } } #--------------------------------------------------------------------------------- sub read_directory{ my($directory,$filter) = @_; return(0)if(!-d "$directory"); opendir (DIR, "$directory") || return(0); if($filter ne ""){ @files = grep(/$filter/, readdir(DIR)); }else{ @files = readdir(DIR); } closedir (DIR); return(@files); } #--------------------------------------------------------------------------------- sub print_document_top{ my($title) = shift; &print_http_header; print "\n"; print "\n"; print "$title\n"; put_file('stylesheet.html'); print "\n"; if($USERCUSTOM{'htmlbody'} eq ''){ print "$USERCONFIGS{'body'}\n"; }else{ print "$USERCUSTOM{'htmlbody'}\n"; } } #--------------------------------------------------------------------------------- sub print_document_foot{ print ""; } #--------------------------------------------------------------------------------- sub getcartfile{ local(@cart); return()if(!-e "$cart_directory/$cart_ID.cart"); $/='{ENDCARTITITEM}'; open(CART, "$cart_directory/$cart_ID.cart") || &system_busy; @cart = (); close(CART); $/="\n"; return(@cart); } #--------------------------------------------------------------------------------- sub get_discount{ $discount = 0; $discounttype = ''; if($USERCONFIGS{'all_account_discount'} > 0){ $discount = $USERCONFIGS{'all_account_discount'}; $discounttype= "Account Holder's Discount" } if($USERCUSTOM{'allow_cookie_discounts'} ==1){ my($cookie) = &get_cookie('cartit_discount'); ($mytext,$mysave) = split(/::/,$cookie); if($mysave<$USERCUSTOM{'MAX_COOKIE_DISCOUNT'}){ if(($mytext ne "") && ($mysave ne "") && ($mysave>=$discount)){ $discount = $mysave; $discounttype= 'Total '.$mytext.' Savings'; } } } if($WEBDAT{'coupon'} ne ""){ $WEBDAT{'coupon'} = uc($WEBDAT{'coupon'}); %COUPONS = &get_hash('coupons.txt'); if($COUPONS{$WEBDAT{'coupon'}} >= $discount){ $discount = $COUPONS{$WEBDAT{'coupon'}}; $discounttype= 'Total Savings With Coupon'; }else{ if($COUPONS{$WEBDAT{'coupon'}} eq ""){ $discounttype = '(Coupon code was invalid) ' . $discounttype ; }else{ $discounttype = '(The coupon was not used because the saving from this discount was greater.) ' . $discounttype; } } } } #--------------------------------------------------------------------------------- sub urlencode{ $value=shift; $value =~ s/([^a-zA-Z0-9])/'%'.unpack("H*",$1)/ge; $value =~ tr/ /+/; return $value; }; #--------------------------------------------------------------------------------- sub urldecode{ $value=shift; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/~!/ ~!/g; return $value; } #--------------------------------------------------------------------------------- sub make_account_active{ my($write_data); $account_char= shift; return()if($account_char eq ""); $WEBDAT{'email'} = uc($WEBDAT{'email'}); return()if(!-e "$data_directory/$account_char"); open (FILE, "$data_directory/$account_char") ||return(); open (TMP, ">$data_directory/$account_char.tmp") ||return(); while(){ chomp($_); @REC = split(/\|/,$_); if($REC[2] eq "$WEBDAT{'email'}"){ $write_data .= "$_\n"; }else{ print TMP "$_\n"; } } close(FILE); close(TMP); chmod(0777,"$data_directory/$account_char.tmp"); if($write_data ne ""){ if($write_data =~ /\n$/){ chop($write_data); } open(NEWA, ">>$data_directory/account.new")||return(); print NEWA "$write_data\n"; close(NEWA); } unlink("$data_directory/$account_char"); rename("$data_directory/$account_char.tmp","$data_directory/$account_char"); } #--------------------------------------------------------------------------------- sub get_year{ my($day, $month, $mday, $time, $year) = split(/\s+/,localtime(time())); return(substr($year,2,2)); } #--------------------------------------------------------------------------------- sub system_busy{ my $mes_txt = shift; print_http_header; print_document_top('System Busy'); print "\n"; print "

System Busy

\n"; print "

\n"; print "

\n"; print "\n"; print " \n"; print " \n"; print " \n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
\n"; print "The system reported a busy signal. This rare error is usually experienced for seconds.\n"; print "

\n"; print " You can click your web browser's Back button and \n"; print "attempt to submit your information again.\n"; print "

\n"; print " If this error persists PLEASE\n"; print " inform the webmaster \n"; print "that the shopping cart is reporting a \"System Busy\" error message.\n"; print "

$mes_txt\n"; print "

\n"; print "
\n"; print "
\n"; print_document_foot; exit; } #--------------------------------------------------------------------------------- sub unlock_file{ my($locfile)=shift; return(0)if($locfile eq "" || $locfile =~ /\W/ || length($locfile > 25)); unlink("$data_directory/$locfile.lock")if(-e "$data_directory/$locfile.lock"); return(0)if(-e "$data_directory/$locfile.lock"); return(1); } #--------------------------------------------------------------------------------- sub emergency_unlock_file{ my($locfile, $message)=@_; die if($locfile eq "" || $locfile =~ /\W/ || length($locfile > 25)); unlink("$data_directory/$locfile.lock")if(-e "$data_directory/$locfile.lock"); die if(-e "$data_directory/$locfile.lock"); &write_error($message,'Script called die!'); die; } #--------------------------------------------------------------------------------- sub write_invoice_status{ my $order_number = shift; my $write_string = shift; return(0) if($order_number eq '' || $write_string eq ''); open(MYFILE, ">>$data_directory/invoice_status.dat") || return(0); print MYFILE "$order_number\|$write_string\n"; close(MYFILE); return(1); } #--------------------------------------------------------------------------------- sub mark_invoice{ my $order_number = shift; my $command = shift; my $rstring = shift; return(0) if($command eq '' || $order_number eq ''); open(MYFILE, ">>$data_directory/invoice_markers.dat") || return(0); print MYFILE "$order_number\|$command\n"; close(MYFILE); &lognoteapi($order_number,'',"Invoice Marked $command by system: $rstring"); return(1); } #--------------------------------------------------------------------------------- sub check_required_fields{ my(@RF,$ck_fn,$r); local($ck_fv); return() if($WEBDAT{'required_fields'} eq ""); @RF = split(/::/,$WEBDAT{'required_fields'}); foreach $r (@RF){ ($ck_fn,$ck_fv) = split(/\^/,$r); if($WEBDAT{$ck_fn} eq ""){ &errorform($ck_fv); exit; } } } #--------------------------------------------------------------------------------- sub lognoteapi{ my($invoice,$date,$note) = @_; if(length($note) > 254){ $note = substr($note,0,254); } exit if($invoice eq ""); exit if($note eq ""); if($date eq ''){ my($mytime) = time(); $date =&get_date($mytime,1); } exit if(!&file_lock('notesapi')); open (FILE, ">>$data_directory/notes.api") ||&emergency_unlock_file('notesapi','Could not open the "notes.api" file'); print FILE "$invoice\|$date\|$note\n"; close(FILE); &unlock_file('notesapi'); } #--------------------------------------------------------------------------------- sub get_discount_amountofcode{ my($myquantity,$myamount,$codestuff) = @_; return(0,$myamount) if($codestuff eq ""); # return($myamount ) if($godiscount eq ""); my($godiscount) = 0; my($part); @PARTS = split(/#/,$codestuff); foreach $part (@PARTS){ my($dfrom, $dto, $damount) = split(/:/,$part); if(($myquantity >= $dfrom)&&($myquantity <= $dto || $dto eq "+")){ $godiscount=($damount / 100); last; } } return("",$myamount ) if($godiscount ==0); return($godiscount,sprintf("%.2f",$myamount * (1-$godiscount))); } #--------------------------------------------------------------------------------- sub set_cart_status{ if(!-e "$cart_directory/$cart_ID.cart"){ &print_http_header; print &get_file_as_iostring('cartit_shopping_cart_empty.html'); exit(0); } if (-z "$cart_directory/$cart_ID.cart"){ &print_http_header; print &get_file_as_iostring('cartit_shopping_cart_empty.html'); exit(0); } } ###################################################################### # Used to add to a session or to edit a session item. # i.e. when adding an existing session item, the session # item will be updated, not added. ###################################################################### #--------------------------------------------------------------------------------- sub cartitsession_update{ my($name,$value) = @_; return(0) if($name eq '' || $value eq ''); if($CARTITSESSION{"$name"} eq ''){ open(SESFILE, ">>$cart_directory/$cart_ID.session"); print SESFILE "$name|$value\n"; close(SESFILE); chmod(0777, "$cart_directory/$cart_ID.session"); $CARTITSESSION{"$name"} = $value; }else{ $CARTITSESSION{"$name"} = $value; &session_rewrite unless($session_poweruser); } } #--------------------------------------------------------------------------------- sub cartitsession_remove{ my($name) = shift; return(0)if(!exists($CARTITSESSION{$name})); $CARTITSESSION{$name} = ''; &session_rewrite unless($session_poweruser); } #--------------------------------------------------------------------------------- sub cartitsession_read{ undef(%CARTITSESSION); %CARTITSESSION= &get_hash('SESSION_FILE'); } #--------------------------------------------------------------------------------- sub cartitsession_rewrite{ my $x; open(SESFILE, ">$cart_directory/$cart_ID.session"); foreach $x (keys %CARTITSESSION){ print SESFILE "$x|$CARTITSESSION{$x}\n" if($CARTITSESSION{$x} ne ''); } close(SESFILE); &cartitsession_read unless($session_poweruser); } #--------------------------------------------------------------------------------- sub set_currency{ if($WEBDAT{'currency_value'} eq '-1'){ $session_poweruser =1; &cartitsession_remove('currency_symbol'); &cartitsession_remove('currency_text'); &cartitsession_remove('currency_conversion'); &cartitsession_rewrite; $session_poweruser =0; return; } if(-e "$data_directory/currency.txt"){ if(-s "$data_directory/currency.txt"){ open(MYFILE, "$data_directory/currency.txt"); my @currencies=(); close(MYFILE); chomp(@currencies); my @cline = split(/\|/,$currencies[$WEBDAT{'currency_value'}]); $session_poweruser =1; &cartitsession_update('currency_symbol',$cline[1]); &cartitsession_update('currency_text',$cline[0]); &cartitsession_update('currency_conversion',$cline[2]); &cartitsession_rewrite; $session_poweruser =0; } } } #--------------------------------------------------------------------------------- sub shopper_ban_message{ &print_http_header; print &get_file_as_iostring('shopper_banned.html'); exit(0); } #--------------------------------------------------------------------------------- sub shopper_banned{ my $iptb = $ENV{'REMOTE_ADDR'}; return(0)if(!-e "$cart_directory/$iptb.banned"); return(0)if(-M "$cart_directory/$iptb.banned" >3); return(1); } #--------------------------------------------------------------------------------- sub ban_shopper_ip{ my $iptb = $ENV{'REMOTE_ADDR'}; open(MYFILE, ">>$cart_directory/$iptb.banned"); print MYFILE "1"; close(MYFILE); } #--------------------------------------------------------------------------------- sub got_currency_opts{ return(0)if(!-e "$data_directory/currency.txt"); return(0)if(-z "$data_directory/currency.txt"); return(1); } #--------------------------------------------------------------------------------- sub has_saved_cart{ return(0)if(!-e "$cart_directory/$cart_ID.saved"); return(0)if(-z "$cart_directory/$cart_ID.saved"); return(1); } #--------------------------------------------------------------------------------- sub oztoreal{ my $cal = shift; return(int($cal/16),($cal % 16)); } #--------------------------------------------------------------------------------- sub convert_to_oz{ my $datain = shift; return($datain) if($USERCONFIGS{'shipping_method'} ne 'livemethods'); return($datain) if($USERCONFIGS{'read_weight_method'} == 0); return($datain*16) if($USERCONFIGS{'read_weight_method'} == 1); return(&convertozlb($datain,'tooz')) if($USERCONFIGS{'read_weight_method'} == 2); } #--------------------------------------------------------------------------------- sub convertozlb{ my ($weight,$conversion) =@_; my ($lb,$oz) = (0,0); if($weight =~/\./){ ($lb,$oz) = split(/\./,$weight); }else{ $lb = $weight; } $lb = $lb > 0 ? (16 * $lb) : 0; if($conversion eq 'tooz'){ return($lb+$oz); }elsif($conversion eq 'tolb'){ return($oz == 0 ? ($lb/16) : (($lb/16)+1)); }elsif($conversion eq 'tolboz'){ return(($lb/16),$oz); } } #--------------------------------------------------------------------------------- sub addozlb{ # Must be an easier way = change base. my ($current, $pusher) = @_; my ($cw,$co,$pw,$po,$ret,$cal) = (0,0,0,0,0,0); if($current =~/\./){ ($cw,$co) = split(/\./,$current); }else{ $cw = $current; } $cw = $cw > 0 ? (16 * $cw) : 0; if($pusher =~/\./){ ($pw,$po) = split(/\./,$pusher); }else{ $pw = $pusher; } $pw = $pw > 0 ? (16 * $pw) : 0; $cal = ($cw+$pw+$co+$po); return(int($cal/16) . "." . ($cal % 16)); } #--------------------------------------------------------------------------------- sub get_currency_list{ my $return_data = ''; return('')if(!-e "$data_directory/currency.txt"); return('')if(-z "$data_directory/currency.txt"); $return_data .= " 

\n"; $return_data .= ""; open(MYFILE, "$data_directory/currency.txt"); my @currencies=(); close(MYFILE); chomp(@currencies); $return_data .= ""; for($i=0;$i<@currencies;$i++){ my @line_c = split(/\|/,$currencies[$i]); $return_data .= ""; } $return_data .= "\n"; $return_data .= "
Prices are shown in $USERCONFIGS{'def_money_sign_text'}. Show conversion for:
$USERCONFIGS{'money_sign'}Default ($USERCONFIGS{'def_money_sign_text'})1.0
$line_c[1]$line_c[0]$line_c[2]

\n"; return($return_data); } #--------------------------------------------------------------------------------- sub show_later_cart{ my($i,$thecolor,@FCART,$numprodincart,%SPECIALTAXES,$taxableshiptotal,$taxabletotal,$asc,$totalgiftfee ); return('')if (-z "$cart_directory/$cart_ID.saved"); $/='{ENDCARTITITEM}'; open(CART, "$cart_directory/$cart_ID.saved") ||&system_busy; @FCART = (); close(CART); chomp(@FCART); $/="\n"; my $cart_size = @FCART; my($lineitem,$return_data); my($tablecolor) = 0; $return_data .= " 

\n"; $return_data .= "You have $cart_size item(s) in your "Saved for Later" shopping list.\n"; $return_data .= "
"; $return_data .= "
" if(!$NOCENTER_CARTIT); $return_data .= "\n"; $return_data .= "\n"; $return_data .= "\n"; $return_data .= "\n" ; $return_data .= "\n"; $return_data .= "\n"; $return_data .= ""; $return_data .= "\n"; $return_data .= "\n"; for($i=0;$i<@FCART;$i++){ ($quantity,$sku,$description,$description_ext,$price,$weight,$id,$taxable,$smarttaxname,$smarttaxperc,$smartistaxable,$smartcondition,$mref,$giftname,$giftfee,$discountcode) = split(/\|/,$FCART[$i]); ($isqdisced,$price) = &get_discount_amountofcode($quantity,$price,$discountcode); $amount = sprintf("%.2f",$quantity*$price); $trueamount = $amount; $totalgiftfee += ($giftfee *$quantity); if($discount >0){ $trueamount = sprintf("%.2f",($trueamount - ($trueamount *$discount))); $total_discount += sprintf("%.2f",($amount *$discount)); } if(($smarttaxname ne "")&&(($smartcondition eq "" || $TCONDITIONS{$smartcondition} ==1))){ if(!$SPECIALTAXES{$smarttaxname}){ $asc .= '*'; $SPECIALTAXES{"\_$smarttaxname"} = $asc; } $SPECIALTAXES{$smarttaxname} += sprintf("%.2f",($trueamount * $smarttaxperc)); } $total += sprintf("%.2f",$amount); $truetotal += sprintf("%.2f",$trueamount); if($taxable){ if($smartistaxable){ $taxabletotal += sprintf("%.2f",($trueamount + ($trueamount * $smarttaxperc))); }else{ $taxabletotal += sprintf("%.2f",$trueamount) } } $numprodincart+=$quantity; $return_data .= "\n"; $return_data .= "'; $return_data .= "'; $return_data .= "\n"; $return_data .= ""; $return_data .= "\n"; $return_data .= "\n"; $return_data .=''; $tablecolor++; $tablecolor=0 if($tablecolor==2); } undef(@FCART); $return_data .= "
QuantityDeleteDescriptionMoveUnit Price Total
"; $return_data .= "$quantity"; $return_data .= '$USERCUSTOM{'TRASH_CAN'}"; $return_data .= '"; if($sku ne ""){ $return_data .= '(' . $USERCUSTOM{'SKU_DISPLAY_TEXT'} . $sku . ') '; } if($mref ne ""){ $return_data .= " $description"; }else{ $return_data .= " $description"; } if(($smarttaxname ne "")&&(($smartcondition eq "" || $TCONDITIONS{$smartcondition} == 1))){ $return_data .= $SPECIALTAXES{"\_$smarttaxname"}; } $return_data .= " $description_ext "; if($isqdisced){ $return_data .= sprintf("Your quantity discount for this item is %2d%. This discount is reflected in the unit price of this item.",$isqdisced * 100); } if($USERCONFIGS{'go_gift'}){ if($giftname ne ""){ $return_data .= "
[This item is a gift for "$giftname"]"; } } $return_data .= "
$USERCUSTOM{'MOVE_TO_CART'}$price$amount

\n"; } sub check_gift_items{ return(-1) if(!$USERCONFIGS{'go_gift'}); return(-1) if(!-e "$cart_directory/$cart_ID.cart"); return(-1) if(-z "$cart_directory/$cart_ID.cart"); my @cartit_records=@_; my @items; my $r; my $giftcounter; my $itemstotal; if(!@cartit_records){ $/='{ENDCARTITITEM}'; open(CART, "$cart_directory/$cart_ID.cart") || return(-1); @cartit_records = (); close(CART); $/="\n"; } $itemstotal=@cartit_records; foreach $r (@cartit_records){ @items = split(/\|/,$r); $giftcounter++ if($items[13] ne ''); } # -1 above is no cart to compare to or not gift module. return(0) if($giftcounter==0); # No items are gifts return(1) if($itemstotal==$giftcounter);# All items are gifts; return(2) if($giftcounter>0) # some items are gifts } 1; # No Lies!