#!/usr/local/bin/perl ######################################################################## # Application Code # ######################################################################## $| = 1; if ($ENV{'REMOTE_ADDR'} eq "65.54.164.86") { exit; } &require_supporting_libraries (__FILE__, __LINE__, "./Library/web_store.setup.html"); &require_supporting_libraries (__FILE__, __LINE__, "./Library/html_stuff.pl", "./Library/db-lib.pl", "$sc_cgi_lib_path", "$sc_html_setup_file_path", "$sc_mail_lib_path", "./Library/file_functions.pl", "./Library/info_pages.pl", "./Library/search_save.pl", "./Library/cookie.lib", "./Library/blu.pl", "./Library/contact.pl", "./Library/tool_box.pl", "./Library/secure_site.pl", "./Library/clearance.pl", "./Library/IP_Lookup.pl", "./Library/last_update.pl"); &read_and_parse_form_data; &get_date; &IP_Lookup; if ((($city eq "Amsterdam") || ($state eq "Amsterdam")) && ($country eq "NL")) { exit; } open (DAT,">>follow.txt"); if ($LOCK_EX){ flock(DAT, $LOCK_EX); #Locks the file } $date = &get_date; print DAT "$date|$form_data{'cart_id'}|$form_data{'prodDetailID'}|$form_data{'item'}|$form_data{'com'}|$form_data{'check_digit'}|$form_data{'clearance'}|$form_data{'setup_file'}|$form_data{'search_string'}|$IP_Lookup\n"; close (DAT); #$form_data{'item'} = ""; ## Comment this out to use Black Arrow $page = $form_data{'page'}; $page =~ /([\w\-\=\+\/]+)\.(\w+)/; $page = "$1.$2"; $page = "" if ($page eq "."); $page =~ s/^\/+//; # Get rid of any residual / prefix $search_request = $form_data{'search_request_button'}; if (!$form_data{'cart_id'}) { &GetCookies('cart_id'); $form_data{'cart_id'} = $Cookies{'cart_id'}; } if ($form_data{'admin_user'} eq "") { &GetCookies('admin_user'); $form_data{'admin_user'} = $Cookies{'admin_user'}; } $cart_id = $form_data{'cart_id'}; if ($cart_id =~ /^(\w+)$/) { $cart_id = $1; } else { $cart_id = ""; } print "Content-type: text/html\n"; $Cookie_Exp_Date = ''; $Cookie_Path = ''; $Cookie_Domain = '.abarcodebusiness.com'; $Secure_Cookie = '0'; &SetCookies('cart_id',"$cart_id"); &SetCookies('admin_user',"$form_data{'admin_user'}"); if ($form_data{'save_in_cookie'} eq "on") { &SetCookieExpDate('Wed, 30-Dec-2020 00:00:00 GMT'); &SetSecureCookie('1'); &SetCompressedCookies("form_data", "fname",$form_data{'fname'}, "lname",$form_data{'lname'}, "phone",$form_data{'phone'}, "fax",$form_data{'fax'}, "email",$form_data{'email'}, "URL",$form_data{'URL'}, "bill_company",$form_data{'bill_company'}, "bill_address1",$form_data{'bill_address1'}, "bill_address2",$form_data{'bill_address2'}, "bill_city",$form_data{'bill_city'}, "bill_state",$form_data{'bill_state'}, "bill_zip",$form_data{'bill_zip'}, "bill_country",$form_data{'bill_country'}, "mail_address1",$form_data{'mail_address1'}, "mail_address2",$form_data{'mail_address2'}, "mail_city",$form_data{'mail_city'}, "mail_state",$form_data{'mail_state'}, "mail_zip",$form_data{'mail_zip'}, "mail_country",$form_data{'mail_country'}); } if ($form_data{'setup_file'} ne "") { $setup_file = $form_data{'setup_file'}; $setup_file =~ /([\w-.]+setup[\w-.]+)/; $untainted_setup_file = $1; &require_supporting_libraries (__FILE__, __LINE__, "./Setup_files/$untainted_setup_file"); } $sc_cart_path = "$sc_user_carts_directory_path/$cart_id.cart"; &error_check_form_data; $popup_window = ""; if ($cart_id eq "") { &delete_old_carts; &assign_a_unique_shopping_cart_id; ### Seasonal popup window ## $popup_window = qq~ ~; $popup_window = ""; # Comment this out to use seasonal popup above ### Thank_you popup window ## $popup_window = qq~ ~; #$popup_window = ""; # Comment this out to use seasonal popup above } $are_any_query_fields_filled_in = "no"; foreach $query_field (@sc_db_query_criteria) { @criteria = split(/\|/, $query_field); if ($form_data{$criteria[0]} ne "") { $are_any_query_fields_filled_in = "yes"; } } ####################################################################### # Navigation Menu # ####################################################################### if (($form_data{'order_form_button'} ne "") || ($form_data{'submit_order_form_button'} ne "")) { $site_url = $secure_url_link; } if ($form_data{'abort_head'} eq "") { &head_html; } if ($form_data{'search_term_log'} ne "") { &search_save; } if ($form_data{'setup_file'} ne "") { if ($form_data{'setup_file'} eq "label_search.setup.pl") { $form_data{'sort_by'} = 4; } elsif ($form_data{'setup_file'} eq "search_list.setup.pl") { $form_data{'sort_by'} = 3; } elsif ($form_data{'setup_file'} eq "site_search.setup.pl") { $form_data{'sort_by'} = 6; } elsif ($form_data{'setup_file'} eq "used_equipment.setup.pl") { $form_data{'sort_by'} = 6; } elsif ($form_data{'setup_file'} eq "bck.setup.pl") { $form_data{'sort_by'} = 43; } &titles_1; &left_menu_bar; &search_database; &footer; exit; } elsif ($form_data{'blu_download'} ne "") { &titles_1; &left_menu_bar; &blu_demo; &footer; exit; } elsif ($form_data{'toolbox'} ne "") { &titles_1; &left_menu_bar; &toolbox; &footer; exit; } elsif ($form_data{'display'} eq "edit") { &require_supporting_libraries (__FILE__, __LINE__, "./Library/display.pl"); &titles_1; &left_menu_bar; &display; &footer; exit; } elsif ($form_data{'blu_pop'} ne "") { &blu_pop; exit; } elsif ($form_data{'clearance'} ne "") { &titles_1; &left_menu_bar; &clearance; &footer; exit; } elsif ($form_data{'custom_database'} ne "") { &titles_1; &left_menu_bar; &custom_database; &footer; exit; } elsif ($form_data{'secure'} ne "") { &secure; exit; } elsif ($form_data{'faqs'} ne "") { &titles_1; &left_menu_bar; &require_supporting_libraries (__FILE__, __LINE__, "./Library/faqs_parse.pl"); &footer; exit; } elsif ($form_data{'barcodebasics'} ne "") { &titles_1; &left_menu_bar; &barcodebasics; &footer; exit; } elsif ($form_data{'webmail'} ne "") { &titles_1; &left_menu_bar; &contact_process; &footer; exit; } elsif ($form_data{'contact'} ne "") { &titles_1; &left_menu_bar; &contact; &footer; exit; } elsif ($form_data{'forms'} ne "") { &titles_1; &left_menu_bar; &file_downloads; &footer; exit; } elsif ($form_data{'service'} ne "") { &titles_1; &left_menu_bar; &repair; &footer; exit; } elsif ($form_data{'pre_printed_upc'} ne "") { &titles_1; &left_menu_bar; &pre_printed_upc; &footer; exit; } elsif ($form_data{'apply_for_upc'} ne "") { &titles_1; &left_menu_bar; &apply_for_upc; &footer; exit; } elsif ($form_data{'terms'} ne "") { &titles_1; &left_menu_bar; &termsofsale; &footer; exit; } elsif ($form_data{'check_digit'} ne "") { &titles_1; &left_menu_bar; use LWP::Simple; $product_url_temp .= "http://www.abarcodebusiness.com/check_digit.html"; $page_temp = get($product_url_temp); print "$page_temp"; &footer; exit; } ## ## Load up the product pages ## ## elsif ($form_data{'prodDetailID'} ne "") { &titles_1; &left_menu_bar; &require_supporting_libraries (__FILE__, __LINE__, "./Library/settings.pl", "./Library/url_parse.pl", "./Library/image_parse.pl", "./Library/link_parse.pl"); if ($site eq "new") { &require_supporting_libraries (__FILE__, __LINE__, "./Library/header_parse.pl", "./Library/cart_parse_new.pl"); } if ($site eq "old") { if ($form_data{'item'} ne "") { &require_supporting_libraries (__FILE__, __LINE__, "./Library/cart_parse_old.pl"); # Load page based on Item # $product_url_temp .= "$product_url$form_data{'item'}"; use LWP::Simple; $page = get($product_url_temp); $cache_page = $page; &image_parse; &link_parse; &cart_parse_old; } else { &require_supporting_libraries (__FILE__, __LINE__, "./Library/propietary_hardware.pl"); &propietary_items; } &footer; exit; } else { #use LWP::Simple; $product_url .= "$form_data{'prodDetailID'}\&listProducts=$form_data{'listProducts'}"; $page = get($product_url); &image_parse; &link_parse; if ($site eq "new") { &header_parse; } &cart_parse; print "$page"; &footer; exit; } } elsif ($form_data{'media_search'} ne "") { &titles_1; &left_menu_bar; &require_supporting_libraries (__FILE__, __LINE__, "./Library/settings.pl", "./Library/url_parse.pl", "./Library/image_parse.pl", "./Library/link_parse.pl", "./Library/media_parse.pl"); use LWP::Simple; $product_url = "$media_url\&SEARCH_INPUT\%3C\%3EsearchFor=$form_data{'search_term'}"; $page = get($product_url); &image_parse; &link_parse; &cart_parse; print "$page"; &footer; exit; } elsif ($form_data{'add_to_cart_button'} ne "") { &titles_1; &left_menu_bar; &add_to_the_cart; &footer; exit; } elsif ($form_data{'modify_cart_button'} ne "") { &titles_1; &left_menu_bar; &display_cart_contents; &footer; exit; } elsif ($form_data{'change_quantity_button'} ne "") { &titles_1; &left_menu_bar; &output_modify_quantity_form; &footer; exit; } elsif ($form_data{'submit_change_quantity_button'} ne "") { &titles_1; &left_menu_bar; &modify_quantity_of_items_in_cart; &footer; exit; } elsif ($form_data{'delete_item_button'} ne "") { &titles_1; &left_menu_bar; &output_delete_item_form; &footer; exit; } elsif ($form_data{'submit_deletion_button'} ne "") { &titles_1; &left_menu_bar; &delete_from_cart; &footer; exit; } elsif ($form_data{'order_form_button'} ne "") { &titles_1; &left_menu_bar; $site_url = $secure_url_link; &require_supporting_libraries (__FILE__, __LINE__, "$sc_order_lib_path"); &display_order_form; &footer; exit; } elsif ($form_data{'submit_order_form_button'} ne "") { &titles_1; &left_menu_bar; $site_url = $secure_url_link; &require_supporting_libraries (__FILE__, __LINE__, "$sc_order_lib_path"); if (((($form_data{'bill_state'} eq "FL") && ($form_data{'mail_state'} eq "")) || ($form_data{'mail_state'} eq "FL")) && ($form_data{'county'} eq "")) { &sales_tax_request; } else { &process_order_form; } &footer; exit; } elsif (($page ne "" || $form_data{'search_request_button'} ne "" || $form_data{'continue_shopping_button'} || $are_any_query_fields_filled_in =~ /yes/i) && ($form_data{'return_to_frontpage_button'} eq "")) { &titles_1; &left_menu_bar; &display_products_for_sale; &footer; exit; } else { &titles_2; print "$popup_window"; &left_menu_bar; &output_frontpage; &footer; exit; } exit; ####################################################################### # Require Supporting Libraries. # ####################################################################### sub require_supporting_libraries { local ($file, $line, @require_files) = @_; local ($require_file); foreach $require_file (@require_files) { if (-e "$require_file" && -r "$require_file") { require "$require_file"; } else { print "I am sorry but I was unable to require $require_file at line $line in $file. Would you please make sure that you have the path correct and that the permissions are set so that I have read access? Thank you."; &footer; exit; } } # End of foreach $require_file (@require_files) } # End of sub require_supporting_libraries ####################################################################### # Read and Parse Form Data. # ####################################################################### sub read_and_parse_form_data { &ReadParse(*form_data); } ####################################################################### # Error Check Form Data. # ####################################################################### sub error_check_form_data { foreach $file_extension (@acceptable_file_extensions_to_display) { if ($page =~ /$file_extension/ || $page eq "") { $valid_extension = "yes"; } } if ($valid_extension ne "yes") { print "$sc_page_load_security_warning"; &update_error_log("PAGE LOAD WARNING", __FILE__, __LINE__); &footer; exit; } } ####################################################################### # Delete Old Carts. # ####################################################################### sub delete_old_carts { opendir (USER_CARTS, "$sc_user_carts_directory_path") || &file_open_error("$sc_user_carts_directory_path", "Delete Old Carts", __FILE__, __LINE__); @carts = grep(/\.cart/,readdir(USER_CARTS)); closedir (USER_CARTS); foreach $cart (@carts) { if ($cart =~ /^(\w+\.cart)$/) { $cart = $1; if (-M "$sc_user_carts_directory_path/$cart" > $sc_number_days_keep_old_carts) { unlink("$sc_user_carts_directory_path/$cart"); } } } # end of foreach } # End of sub delete_old_carts ####################################################################### # Assign a Shopping Cart. # ####################################################################### sub assign_a_unique_shopping_cart_id { if ($sc_shall_i_log_accesses eq "yes") { $date = &get_date; &get_file_lock("$sc_access_log_path.lockfile"); open (ACCESS_LOG, ">>$sc_access_log_path"); @env_keys = keys(%ENV); $new_access = "$date\|"; foreach $env_key (@env_keys) { $new_access .= "$ENV{$env_key}\|"; } chop $new_access; print ACCESS_LOG "$new_access\n"; close (ACCESS_LOG); &release_file_lock("$sc_access_log_path.lockfile"); } srand (time|$$); $cart_id = int(rand(10000000)); $cart_id .= "_$$"; $cart_id =~ s/-//g; $sc_cart_path = "$sc_user_carts_directory_path/${cart_id}.cart"; $cart_count = 0; while (-e "$sc_cart_path") { if ($cart_count == 3) { print "$sc_randomizer_error_message"; &update_error_log("COULD NOT CREATE UNIQUE CART ID", __FILE__, __LINE__); &footer; exit; } $cart_id = int(rand(10000000)); $cart_id .= "_$$"; $cart_id =~ s/-//g; $sc_cart_path = "$sc_user_carts_directory_path/${cart_id}.cart"; $cart_count++; } # End of while (-e $sc_cart_path) open (CART, ">$sc_cart_path") || &file_open_error("$sc_cart_path", "Assign a Shopping Cart", __FILE__, __LINE__); } ####################################################################### # Output Frontpage. # ####################################################################### sub output_frontpage { &display_page("$sc_store_front_path", "Output Frontpage", __FILE__, __LINE__); } ####################################################################### # Add to Shopping Cart # ####################################################################### sub add_to_the_cart { open (CART, "+>>$sc_cart_path") || &file_open_error("$sc_cart_path", "Add to Shopping Cart", __FILE__, __LINE__); $highest_item_number = 100; # init highest item number (start at 100) seek (CART, 0, 0); # make sure we're positioned at top of file while () # loop on cart contents, if any { chomp $_; # get rid of terminating newline my @row = split (/\|/, $_); # split cart row into fields my $item_number = pop (@row); # get item number of row (last field) $highest_item_number = $item_number if ($item_number > $highest_item_number); } seek (CART, 0, 2); # position to end of file @items_ordered = keys (%form_data); foreach $item (@items_ordered) { if (($item =~ /^item-/i || $item =~ /^option/i) && $form_data{$item} ne "") { $item =~ s/^item-//i; if ($item =~ /^option/i) { push (@options, $item); } else { if (($form_data{"item-$item"} =~ /\D/) || ($form_data{"item-$item"} == 0)) { &bad_order_note; } else { $quantity = $form_data{"item-$item"}; push (@items_ordered_with_options, "$quantity\|$item\|"); } } } # End of if ($item ne "$variable" && $form_data{$item} ne "") } #End of foreach $item (@items_ordered) foreach $item_ordered_with_options (@items_ordered_with_options) { $options = ""; $option_subtotal = ""; $option_grand_total = ""; $item_grand_total = ""; $item_ordered_with_options =~ s/~qq~/\"/g; $item_ordered_with_options =~ s/~gt~/\>/g; $item_ordered_with_options =~ s/~lt~/\) { @database_row = split (/\|/, $_); $cart_row_number = pop (@database_row); push (@database_row, $cart_row_number); $old_quantity = shift (@database_row); chop $cart_row_number; foreach $item (@modify_items) { if ($item eq $cart_row_number) { $shopper_row .= "$form_data{$item}\|"; foreach $field (@database_row) { $shopper_row .= "$field\|"; } $quantity_modified = "yes"; chop $shopper_row; # Get rid of last pipe symbol but not the # newline character } # End of if ($item eq $cart_row_number) } # End of foreach $item (@modify_items) if ($quantity_modified ne "yes") { $shopper_row .= $_; } $quantity_modified = ""; } # End of while () close (CART); open (CART, ">$sc_cart_path") || &file_open_error("$sc_cart_path", "Modify Quantity of Items in the Cart", __FILE__, __LINE__); print CART "$shopper_row"; close (CART); &display_cart_contents; } # End of if ($form_data{'submit_change_quantity'} ne "") ####################################################################### # Output Delete Item Form # ####################################################################### sub output_delete_item_form { &standard_page_header("Delete Item"); &display_cart_table("delete"); &delete_form_footer; } # End of if ($form_data{'delete_item'} ne "") ####################################################################### # Delete Item From Cart # ####################################################################### sub delete_from_cart { @incoming_data = keys (%form_data); foreach $key (@incoming_data) { unless ($key =~ /[\D]/) { if ($form_data{$key} ne "") { push (@delete_items, $key); } } # End of unless ($key =~ /[\D]/... } # End of foreach $key (@incoming_data) open (CART, "<$sc_cart_path") || &file_open_error("$sc_cart_path", "Delete Item From Cart", __FILE__, __LINE__); while () { @database_row = split (/\|/, $_); $cart_row_number = pop (@database_row); $db_id_number = pop (@database_row); push (@database_row, $db_id_number); push (@database_row, $cart_row_number); chop $cart_row_number; $old_quantity = shift (@database_row); $delete_item = ""; foreach $item (@delete_items) { if ($item eq $cart_row_number) { $delete_item = "yes"; } } # End of foreach $item (@add_items) if ($delete_item ne "yes") { $shopper_row .= $_; } } # End of while () close (CART); open (CART, ">$sc_cart_path") || &file_open_error("$sc_cart_path", "Delete Item From Cart", __FILE__, __LINE__); print CART "$shopper_row"; close (CART); &display_cart_contents; } # End of if ($form_data{'submit_deletion'} ne "") ####################################################################### # Product Search Form # ####################################################################### sub search_database { if ($form_data{'sort_by'} ne "") { $index_of_field_to_be_sorted_by = $form_data{'sort_by'}; } &search_results_header; ($total_row_count) = &submit_query(*database_rows); foreach $row (@database_rows) { @row = split (/\|/, $row); $sortable_field = $row[$index_of_field_to_be_sorted_by]; unshift (@row, $sortable_field); $new_row = join ("\|", @row); push (@new_rows, $new_row); } @database_rows = (); @sorted_rows = sort (@new_rows); foreach $sorted_row (@sorted_rows) { @row = split (/\|/, $sorted_row); $sorted_field = shift (@row); $old_but_sorted_row = join ("\|", @row); push (@database_rows, $old_but_sorted_row); } if ($total_row_count < 1) { &no_hits_message; &footer; exit; } $hits_seen = $form_data{'new_hits_seen'}; for ($i = 1;$i <= $hits_seen;$i++) { $seen_row = shift (@database_rows); } $length_of_database_rows = @database_rows; for ($i = $length_of_database_rows-1;$i >= $max_rows_returned;$i--) { $extra_row = pop (@database_rows); } $new_hits_seen = $hits_seen + @database_rows; &search_results_body; } ####################################################################### # Display Products for Sale # ####################################################################### sub display_products_for_sale { if ($sc_use_html_product_pages eq "yes") { if ($form_data{'search_request_button'} ne "") { &standard_page_header("Search Results"); require "$sc_html_search_routines_library_path"; &html_search; &html_search_page_footer; &footer; exit; } &display_page("$sc_html_product_directory_path/$page", "Display Products for Sale", __FILE__, __LINE__); } else { &create_html_page_from_db; } } ####################################################################### # create_html_page_from_db Subroutine # ####################################################################### sub create_html_page_from_db { local (@database_rows, @database_fields, @item_ids, @display_fields); local ($total_row_count, $id_index, $display_index); local ($row, $field, $empty, $option_tag, $option_location, $output); if ($page ne "" && $form_data{'search_request_button'} eq "" && $form_data{'continue_shopping_button'} eq "") { &display_page("$sc_html_product_directory_path/$form_data{'page'}", "Display Products for Sale", __FILE__, __LINE__); &footer; exit; } &product_page_header($sc_product_display_title); if ($form_data{'add_to_cart_button'} ne "" && $sc_shall_i_let_client_know_item_added eq "yes") { print "$sc_item_ordered_message"; } if (!($sc_db_lib_was_loaded =~ /yes/i)) { &require_supporting_libraries (__FILE__, __LINE__, "$sc_db_lib_path"); } ($status,$total_row_count) = &submit_query(*database_rows); foreach $row (@database_rows) { @database_fields = split (/\|/, $row); foreach $field (@database_fields) { if ($field =~ /^%%OPTION%%/) { ($empty, $option_tag, $option_location) = split (/%%/, $field); $field = ""; open (OPTION_FILE, "<$sc_options_directory_path/$option_location") || &file_open_error ("$sc_options_directory_path/$option_location", "Display Products for Sale", __FILE__, __LINE__); while () { s/%%PRODUCT_ID%%/$database_fields[$sc_db_index_of_product_id]/g; $field .= $_; } close (OPTION_FILE); } # End of if ($field =~ /^%%OPTION%%/) } # End of foreach $field (@database_fields) @display_fields = (); @temp_fields = @database_fields; foreach $display_index (@sc_db_index_for_display) { if ($display_index == $sc_db_index_of_price) { $temp_fields[$sc_db_index_of_price] = &display_price($temp_fields[$sc_db_index_of_price]); } push(@display_fields, $temp_fields[$display_index]); } @item_ids = (); foreach $id_index (@sc_db_index_for_defining_item_id) { $database_fields[$id_index] =~ s/\"/~qq~/g; $database_fields[$id_index] =~ s/\>/~gt~/g; $database_fields[$id_index] =~ s/\ ~; local ($page, $routine, $file, $line) = @_; open (PAGE, "<$page") || &file_open_error("$page", "$routine", $file, $line); while () { s/cart_id=/cart_id=$cart_id/g; s/%%cart_id%%/$cart_id/g; s/%%page%%/$form_data{'page'}/g; s/%%my_form%%/$my_form/g; if ($form_data{'add_to_cart_button'} ne "" && $sc_shall_i_let_client_know_item_added eq "yes") { if ($_ =~ /
>$sc_error_log_path") || &CgiDie ("The Error Log could not be opened"); foreach $variable (@env_vars) { $log_entry .= "$ENV{$variable}\|"; } print ERROR_LOG "$log_entry\n"; close (ERROR_LOG); &release_file_lock("$sc_error_log_path.lockfile"); } # End of if ($sc_shall_i_log_errors eq "yes") if ($sc_shall_i_email_if_error eq "yes") { $email_body = "$type_of_error\n\n"; $email_body .= "FILE = $file_name\n"; $email_body .= "LINE = $line_number\n"; $email_body .= "DATE=$date\|"; foreach $variable (@env_vars) { $email_body .= "$variable = $ENV{$variable}\n"; } &send_mail("$sc_admin_email", "$sc_admin_email", "Web Store Error", "$email_body"); } # End of if ($sc_shall_i_email_if_error eq "yes") } ################################################################# # get_date Subroutine # ################################################################# sub get_date { local ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst,$date); local (@days, @months); @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday', 'Friday','Saturday'); @months = ('January','February','March','April','May','June','July', 'August','September','October','November','December'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } $year += 1900; $date = "$days[$wday], $months[$mon] $mday, $year at $hour\:$min\:$sec"; return $date; } ################################################################# # display_price Subroutine # ################################################################# sub display_price { local ($price) = @_; local ($format_price); if ($sc_money_symbol_placement eq "front") { $format_price = "$sc_money_symbol $price"; } else { $format_price = "$price $sc_money_symbol"; } return $format_price; } ####################################################################### # get_file_lock # ####################################################################### sub get_file_lock { local ($lock_file) = @_; local ($endtime); $endtime = 20; $endtime = time + $endtime; while (-e $lock_file && time < $endtime) { sleep(1); } open(LOCK_FILE, ">$lock_file") || &CgiDie ("I could not open the lock file"); # flock(LOCK_FILE, 2); # 2 exclusively locks the file } ####################################################################### # release_file_lock # ####################################################################### sub release_file_lock { local ($lock_file) = @_; # flock(LOCK_FILE, 8); # 8 unlocks the file close(LOCK_FILE); unlink($lock_file); } ####################################################################### # format_price # ####################################################################### sub format_price { local ($unformatted_price) = @_; local ($formatted_price); $formatted_price = sprintf ("%.2f", $unformatted_price); return $formatted_price; } ############################################################ # # subroutine: format_text_field # Usage: # $formatted_value = # &format_text_field($value, [$width]); # # Parameters: # $value = text value to format. # $width = optional field width. Defaults to 25. # # This routine takes the value and appends enough # spaces so that the field width is 25 spaces. # in order to justify the fields that are stored # eventually in the $text_of_cart. # # Output: # The formatted value # ############################################################ sub format_text_field { local($value, $width) = @_; $width = 25 if (!$width); return ($value . (" " x ($width - length($value)))); } # End of format_text_field