#!/usr/bin/perl # version 3.030822a beta, coded by MrRat - http://www.mrrat.com, GPL licensed - http://www.opensource.org/licenses/gpl-license.html # you can make a donation at http://s1.amazon.com/exec/varzea/pay/T3M26803DZOCMK # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. #use strict; my (%FORM, %MY_variables, %associate_ids); # # required changes: # Check the perl line at the top and make sure it points to the proper location. # Place this cgi in your cgi-bin directory and make it executable (chmod 755). # Put your Amazon.com affiliate id below. $associate_ids{us} = [ "theunofficiall0f" ]; # # basic options: # set the locale: "us", "uk", "de" $FORM{locale} = "us"; # If you are going to use locales othen than "us" you need to put those associate ids below. $associate_ids{uk} = [ "theunofficiall0f" ]; $associate_ids{de} = [ "theunofficiall0f" ]; # show search options link? my $show_search_options = "yes"; # # advanced options: # before messing with these you'll want to read the FAQ at http://www.mrrat.com/aws/amazon-products-feed-faq.html # list of featured products for random selection with apf_featured_product my @featured_products = ("055358135X","0764112082","076361873X","B00005R24I","B0000009S3","B00001WRLX","B00001ZUMD"); # cache settings - file location and number of requests to cache my $use_cache = "yes"; my $cache_file = "apf_xml_cache"; my $cache_max_size = "1000"; # length of reviews in %%my_shortened_comments%% and %%first_review_shortened_comment%% my $review_length = 500; # templates are comma separated lists, and if blank or non-existent will use embedded HTML my @page_templates = ("page_1.template", "page_1.template", "page_1.template", "page_1.template", "page_1.template"); my @products_templates = ("products.template", "products.template", "products.template", "products.template", "", ""); my @item_templates = ("item.template", "item.template", "item.template", "item.template", "item.template"); my @larger_image_templates = (); my @sellersearch_templates = (); my @sellerprofile_templates = (); my @thirdparty_products_templates = (); my @browse_menu_templates = (); my @nav_menu_templates = (); my @blended_templates = (); my @featured_product_templates = (); my @shopping_cart_templates = (); my @customer_reviews_templates = (); # location of optional language files - comma separated, if blank or non-existent will use embedded English my @language_templates = ("apf_de.language"); # END OF OPTIONS # don't monkey with anything below here unless you know PERL # setup initial variables my (%chat_modes, %lookup_store, %store_to_browse, %all_store_to_browse, %all_catalog_to_mode, %catalog_to_mode, %sort_hash, %sort_hash_by_mode, %offering_type ); my ($debug, $debug_state, %AWS_variables, $session, %template_html, $nav_menu_type, $html); my ($url_mode, $url_options, $see_url_options, %lookup_browse_id, $query, $my_marketplace_text, $sellerprofile_max, $amazon_server, $money_symbol, $details_max, $menu_length, $sort_mode ); $MY_variables{script_name} = $ENV{SCRIPT_NAME}; if ($MY_variables{script_name} =~ /test.cgi/) { $debug_state = "on"; $cache_file = "apf_xml_cache.test"; } elsif (-e "ratlog.cgi") { require "ratlog.cgi"; } $FORM{page_num} = 1; $FORM{sort_type} = "+salesrank"; $FORM{max_results} = 50; get_url_input(); if ($FORM{search_type} eq "FeaturedProducts") { $FORM{item_id} = join(",", @featured_products); } if ($FORM{mode} =~ /node:/) { $FORM{mode} =~ s/node:([^:]+):(.*)/$1/; $FORM{node} = $2; } if (!$FORM{link_templates}) { $FORM{link_templates} = $FORM{templates}; } $debug .= qq[mode = $FORM{mode} | id = $FORM{node} | search = $FORM{input_string}\n]; load_language(\@language_templates); initialize_hashes(); load_templates(); START_PROCESSING_LABEL: calculate_initial_variables(); # build the products_html if ($FORM{cart_action}) { shopping_cart(); } elsif ( ( $FORM{mode} and ($FORM{input_string} or $FORM{node}) and ($FORM{mode} ne "blended") ) or $FORM{item_id} =~ /,/ or $FORM{search_type} =~ /(?:ThirdPartyNew|Used|Collectible|Refurbished|ListManiaSearch|SimilaritySearch|WishlistSearch)/ ) { # get products my $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$FORM{sort_type}&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; if ($FORM{search_type} =~ /(?:ThirdPartyNew|Used|Collectible|Refurbished|ListManiaSearch|SimilaritySearch|WishlistSearch)/) { $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&$query&f=xml&locale=$FORM{locale}"; } my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); if ($AWS_variables{TotalResults} eq 1) { ${${$level_1}{Details}}[0] =~ /([^<]+)<\/Asin>/; delete $MY_variables{header}; delete $FORM{mode}; delete $FORM{input_mode}; delete $FORM{node}; $FORM{search_type} = "AsinSearch"; $FORM{item_id} = "$1"; goto START_PROCESSING_LABEL; # yes i know goto is lame, bite me } else { assign_variables("products",$level_1); } } elsif ($FORM{search_type} =~ /(?:AsinSearch|CustomerReviews)/) { # get item by ASIN/ISBN my $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&AsinSearch=$FORM{item_id}&type=heavy&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); if ($FORM{search_type} eq "CustomerReviews") { assign_variables("customer_reviews",$level_1); } else { assign_variables("item",$level_1); } $MY_variables{store} = $lookup_store{$catalog_to_mode{$AWS_variables{Catalog}}}; $MY_variables{subject} = $AWS_variables{ProductName}; } elsif ($FORM{search_type} eq "UpcSearch") { # get item by UPC my $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&UpcSearch=$FORM{item_id}&mode=$FORM{mode}&type=heavy&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); assign_variables("item",$level_1); $MY_variables{store} = $AWS_variables{Catalog}; $MY_variables{subject} = $AWS_variables{ProductName}; } elsif ($FORM{mode} eq "blended") { # blended search my $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&BlendedSearch=$FORM{input_string}&type=lite&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); blended_search($level_1); } elsif ($FORM{search_type} eq "image") { # get large image my $this_xml_url="http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&AsinSearch=$FORM{item_id}&type=lite&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); $xml_result =~ s/<([^>]+)>([^<]+)<\/\1>/$AWS_variables{$1} = $2;/gsie; $MY_variables{store} = $AWS_variables{Catalog}; $MY_variables{subject} = $AWS_variables{ProductName}; $MY_variables{products_html} .= set_html("larger_image"); } elsif ($FORM{search_type} eq "SellerSearch") { # get SellerProfile my $this_xml_url="http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&SellerProfile=$FORM{input_string}&type=lite&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); assign_variables("sellerprofile",$level_1); $MY_variables{store} = $AWS_variables{Catalog}; $MY_variables{subject} = $AWS_variables{ProductName}; # get SellerSearch my $this_xml_url="http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$FORM{sort_type}&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); assign_variables("sellersearch",$level_1); } elsif ($FORM{search_type} eq "ExchangeSearch") { # get ExchangeSearch my $this_xml_url="http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$FORM{sort_type}&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $exchange_xml_result = get_url($this_xml_url); $exchange_xml_result =~ s/([^<]+)<\/ExchangeSellerId>/$AWS_variables{ExchangeSellerId} = $1/e; # get SellerProfile my $this_xml_url="http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&SellerProfile=$AWS_variables{ExchangeSellerId}&type=lite&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); assign_variables("sellerprofile",$level_1); # get ExchangeSearch my $xml_result = $exchange_xml_result; my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); assign_variables("sellersearch",$level_1); } elsif ($FORM{search_type} eq "AllSearches") { assign_variables("AllSearches"); } elsif ($FORM{search_type} eq "power_search_info") { $MY_variables{store} = "PowerSearch"; $MY_variables{subject} = "Details"; $MY_variables{products_html} .= set_html("power_search_info"); } elsif ($FORM{mode}) { # display the categories for the mode $nav_menu_type = "modes"; $MY_variables{subject} = $language_text{header_text5}; $MY_variables{header} = qq[$language_text{header_text1} > $MY_variables{store}
]; $MY_variables{products_html} = load_browse_table(\%{$FORM{mode}}, "mode=$FORM{mode}&node="); if (exists($chat_modes{$FORM{mode}})) { $MY_variables{chat_link} = qq[Chat about $lookup_store{$FORM{mode}}
]; } } else { # display the modes $nav_menu_type = "none"; $MY_variables{subject} = $language_text{header_text1}; $MY_variables{store} = $language_text{header_text4}; $MY_variables{products_html} = load_browse_table(\%store_to_browse, "mode="); } # build the page if ($FORM{search_type} eq "SimilaritySearch") { $MY_variables{header} = qq[$language_text{my_similar_products_text1} $language_text{button_text4}]; } elsif ($FORM{search_type} eq "ListManiaSearch") { $MY_variables{header} = "$AWS_variables{ListName}"; } elsif (!$MY_variables{header}) { $MY_variables{header} = qq[$MY_variables{store} : $MY_variables{subject}]; } if ($MY_variables{error_msg}) { $MY_variables{products_html} .= qq[
$MY_variables{error_msg}
]; } if ($debug_state eq "on") { $MY_variables{debug_html} = $debug; } build_search_box(); if (!$AWS_variables{HMAC}) { build_international_links(); } $html .= set_html("page"); $apf_footer = "
"; #qq[
script by MrRat]; #if ($MY_variables{associate_id} =~ /(freewarfrommrrat|mrratcom-21)/) { $apf_footer .= qq[
A portion of each sale goes to benefit MrRat.com, thank you.]; } $apf_footer .= qq[ ]; $apf_footer .= qq[
]; $html =~ s/<\/body>/$apf_footer/i; # send the page to the browser print "Content-type: text/html; charset=utf-8\n\n"; print $html; exit; # the end - subs below sub get_url_input { my ($form_pair,$form_name,$form_value,$item); for $form_pair (split(/&/, $ENV{QUERY_STRING})) { $form_pair =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # remove all dangerous characters listed in WWW Security FAQ - http://www.w3.org/Security/Faq/ # except characters ( ) * which are required for power searches # i know this doesn't untaint but can't figure out how to untaint accented characters without the overhead of locale $form_pair =~ s/[\&|\;|\`|\\|\"|\||\?|\~|\<|\>|\^|\[|\]|\{|\}|\$]/ /g; ($form_name, $form_value) = split(/=/, $form_pair); if ($form_name eq $form_value) { $form_value = ""; } $FORM{$form_name} = $form_value; } if (%FORM) { if ($FORM{input_mode}) { $FORM{mode} = $FORM{input_mode}; } if ($FORM{input_templates}) { $FORM{templates} = $FORM{input_templates}; } if ($FORM{input_link_templates}) { $FORM{link_templates} = $FORM{input_link_templates}; } if ($FORM{input_language}) { $FORM{language} = $FORM{input_language}; } if ($FORM{input_sort}) { $FORM{sort_type} = $FORM{input_sort}; } if ($FORM{sort_type}) { $FORM{sort_type} =~ s/\s/+/g; } if ($FORM{input_max}) { $FORM{max_results} = $FORM{input_max}; } if ($FORM{input_link_max}) { $FORM{link_max_results} = $FORM{input_link_max}; } if ($FORM{input_locale}) { $FORM{locale} = $FORM{input_locale}; } if ($FORM{input_id}) { $FORM{node} = $FORM{input_id}; } if ($FORM{input_item}) { $FORM{item_id} = $FORM{input_item}; } if ($FORM{input_page}) { $FORM{page_num} = $FORM{input_page}; } if ($FORM{input_search_type}) { $FORM{search_type} = $FORM{input_search_type}; } if ($FORM{input_pricerange}) { $FORM{pricerange} = $FORM{input_pricerange}; } if ($FORM{input_keywords}) { $FORM{keywords} = $FORM{input_keywords}; } if ($FORM{input_cart_action}) { $FORM{cart_action} = $FORM{input_cart_action}; } if ($FORM{input_cart_item}) { $FORM{cart_item} = $FORM{input_cart_item}; } if ($FORM{input_string}) { $FORM{input_string} =~ s/ö|Ã[¶–]/oe/gi; $FORM{input_string} =~ s/ä|Ã[¤„]/ae/gi; $FORM{input_string} =~ s/ü|Ã[¼œ]/ue/gi; $FORM{input_string} =~ s/ß|ß/ss/gi; } } } sub load_language { my $temp_input = shift; my @temp_array = @$temp_input; # start default language if ($FORM{locale} eq "uk") { $amazon_site = "Amazon.co.uk"; } elsif ($FORM{locale} eq "de") { $amazon_site = "Amazon.de"; } else { $amazon_site = "Amazon.com"; } $language_text{header_text1} = "Bestsellers"; $language_text{header_text2} = "Items"; $language_text{header_text3} = "List"; $language_text{header_text4} = "All Products"; $language_text{header_text5} = "Categories"; $language_text{my_artists_text1} = "by:"; $language_text{my_artists_text2} = "starring:"; $language_text{my_artists_text3} = "from:"; $language_text{my_artists_text4} = "directed by:"; $language_text{my_prices_text1} = "List Price:"; $language_text{my_prices_text2} = $amazon_site . "'s Price:"; $language_text{my_prices_text3} = "You Save:"; $language_text{my_prices_text4} = "Prices subject to change."; $language_text{my_prices_text5} = "price not available"; $language_text{button_text1} = "Buy from " . $amazon_site; $language_text{button_text2} = "Add to " . $amazon_site . " Wishlist"; $language_text{button_text3} = "Add to " . $amazon_site . " Wedding Registry"; $language_text{button_text4} = "Search"; $language_text{button_text5} = "Add to " . $amazon_site . " Baby Registry"; $language_text{button_text6} = "Sort"; $language_text{button_text7} = "Change Quantities"; $language_text{button_text8} = "Delete"; $language_text{button_text9} = "Empty Shopping Cart"; $language_text{button_text10} = "Add to Shopping Cart"; $language_text{button_text11} = "See More Details"; $language_text{my_marketplace1} = "Price:"; $language_text{my_marketplace2} = "Used"; $language_text{my_marketplace3} = "Collectible"; $language_text{my_marketplace4} = "Third Party New"; $language_text{my_marketplace5} = "Refurbished"; $language_text{my_features_text1} = "Features:"; $language_text{my_similar_products_text1} = "Related Items:"; $language_text{my_accessories_text1} = "Accessories:"; $language_text{my_product_description} = "Product Description:"; $language_text{my_comments_text1} = "Rating:"; $language_text{my_comments_text2} = "Read More"; $language_text{my_descriptors_text1} = "Release Date:"; $language_text{my_descriptors_text2} = "Theatrical Date:"; $language_text{my_descriptors_text3} = "Media:"; $language_text{my_descriptors_text4} = "Number of Media:"; $language_text{my_descriptors_text5} = "MPAA Rating:"; $language_text{my_descriptors_text6} = "Platform:"; $language_text{my_descriptors_text7} = "ESRB Rating:"; $language_text{my_descriptors_text8} = "Age Group:"; $language_text{my_descriptors_text9} = "Sales Rank:"; $language_text{my_descriptors_text10} = "Encoding:"; $language_text{my_descriptors_text11} = "Tracks:"; $language_text{my_descriptors_text12} = "Reading Level:"; $language_text{my_descriptors_text13} = "Manufacturer:"; $language_text{my_browse_list_text1} = "Browse:"; $language_text{see_text1} = "Next >"; $language_text{see_text2} = "< Previous"; $language_text{see_text3} = "Back"; $language_text{see_text4} = "page"; $language_text{see_text5} = "of"; $language_text{see_text6} = "see more"; $language_text{association_text1} = "In association with " . $amazon_site; $language_text{availability_text1} = "Availability:"; $language_text{availability_text2} = "Not currently available for purchase."; $language_text{see_larger_image_text1} = "See Larger Image"; $language_text{customer_reviews_text1} = "Customer Reviews"; $language_text{average_rating_text1} = "Average Rating: "; $language_text{average_rating_text2} = "none"; $language_text{similar_text1} = "Featured Listmania! List"; $language_text{thirdparty_text1} = "Seller:"; $language_text{thirdparty_text2} = "Condition:"; $language_text{thirdparty_text3} = "Condition Type:"; $language_text{thirdparty_text4} = "From:"; $language_text{thirdparty_text5} = "Comments:"; $language_text{thirdparty_text6} = "Quantity:"; $language_text{thirdparty_text7} = "Offering Type:"; $language_text{thirdparty_text8} = "End Date:"; $language_text{thirdparty_text9} = "Total Feedback:"; $language_text{thirdparty_text10} = "Cancelled Auctions:"; $language_text{thirdparty_text11} = "Date:"; $language_text{cart_text1} = "Shopping Cart"; $language_text{cart_text2} = "There is nothing in your shopping cart."; $language_text{cart_text3} = "View Shopping Cart or Checkout"; $language_text{cart_text4} = "Include in shopping cart:"; $language_text{locale_text1} = "International Store:"; $language_text{locale_text2} = "USA"; $language_text{locale_text3} = "United Kingdom"; $language_text{locale_text4} = "Germany"; $language_text{locale_text5} = "Japan"; $language_text{sort_text1} = "Featured Items"; $language_text{sort_text2} = "Bestselling"; $language_text{sort_text3} = "Average Customer Review"; $language_text{sort_text4} = "Price (Low to High)"; $language_text{sort_text5} = "Price (High to Low)"; $language_text{sort_text6} = "Publication Date"; $language_text{sort_text7} = "Alphabetical (A-Z)"; $language_text{sort_text8} = "Alphabetical (Z-A)"; $language_text{sort_text9} = "Manufacturer (A-Z)"; $language_text{sort_text10} = "Manufacturer (Z-A)"; $language_text{sort_text11} = "Artist Name"; $language_text{sort_text12} = "Original Release Date"; $language_text{searchbox_text1} = "All Products"; $language_text{searchbox_text2} = "Only within this Category"; $language_text{searchbox_text3} = "Search Options"; $language_text{searchbox_text4} = "Search by"; $language_text{searchbox_text5} = "Item"; $language_text{searchbox_text6} = "Actor/Actress"; $language_text{searchbox_text7} = "Search String"; $language_text{searchbox_text8} = "Sort by"; $language_text{searchbox_text9} = "Artist/Musician"; $language_text{searchbox_text10} = "Author"; $language_text{searchbox_text11} = "BrowseNode"; $language_text{searchbox_text12} = "Browse Id Number"; $language_text{searchbox_text13} = "Product Mode"; $language_text{searchbox_text14} = "Price Range"; $language_text{searchbox_text15} = "Director"; $language_text{searchbox_text16} = "Listmania"; $language_text{searchbox_text17} = "Manufacturer"; $language_text{searchbox_text18} = "Power Search"; $language_text{searchbox_text19} = "Similar Products"; $language_text{searchbox_text20} = "third-party ASIN"; $language_text{searchbox_text21} = "Third-party exchange ID"; $language_text{searchbox_text22} = "Third-party Seller ID"; $language_text{searchbox_text23} = "UPC"; $language_text{searchbox_text24} = "WishList id"; # end default language my $temp_num = $FORM{language} - 1; if ($FORM{language} and -e $temp_array[$temp_num]) { require $temp_array[$temp_num]; } elsif ($FORM{locale} eq "de" and -e "apf_de.language") { require "apf_de.language"; } } sub initialize_hashes { my %us_store_to_browse = ( "Baby" => "baby", "Books" => "books", "Classical Music" => "classical", "DVD" => "dvd", "Electronics" => "electronics", "Kitchen & Housewares" => "kitchen", "Magazines" => "magazines", "Outdoor Living" => "garden", "Popular Music" => "music", "Computers" => "pc_hardware", "Camera & Photo" => "photo", "Software" => "software", "Tools & Hardware" => "universal", "Toys & Games" => "toys", "Video" => "vhs", "Computer & Video Games" => "videogames" ); my %uk_store_to_browse = ( "Books" => "books_uk", "Popular Music" => "music", "Classical Music" => "classical", "DVD" => "dvd_uk", "Video" => "vhs_uk", "Electronics" => "electronics_uk", "Kitchen & Housewares" => "kitchen_uk", "Software" => "software_uk", "Computer & Video Games" => "video_games_uk", "Toys & Games" => "toys_uk" ); my %de_store_to_browse = ( "Bücher" => "books_de", "Musik" => "pop_music_de", "Musik (Klassische)" => "classical_de", "DVD" => "dvd_de", "Video" => "vhs_de", "Elektronik & Foto" => "ce_de", "Küche & Haushalt" => "kitchen_de", "Software" => "software_de", "Computer & Video-Spiele" => "video_games_de", "Zeitschriften" => "magazines_de", "Englische Bücher" => "books_de_intl_us"); %all_store_to_browse = ( "us" => \%us_store_to_browse, "uk" => \%uk_store_to_browse, "de" => \%de_store_to_browse ); my %us_catalog_to_mode = ( "Apparel" => "apparel", "Baby Product" => "baby", "Book" => "books", "DVD" => "dvd", "Electronics" => "electronics", "Home Improvement" => "universal", "Kitchen" => "kitchen", "Lawn & Patio" => "garden", "Magazine" => "magazines", "Magazines" => "magazines", "Music" => "music", "Personal Computer" => "pc_hardware", "Software" => "software", "Toy" => "toys", "Video" => "vhs", "Video Games" => "videogames", "Sporting Goods" => "sporting", "Sports" => "sporting" ); my %uk_catalog_to_mode = ( "Book" => "books_uk", "Music" => "music", "DVD" => "dvd_uk", "Video" => "vhs_uk", "Electronics" => "electronics_uk", "Kitchen" => "kitchen_uk", "Software" => "software_uk", "Video Games" => "video_games_uk", "Toy" => "toys_uk" ); my %de_catalog_to_mode = ( "Book" => "books_de", "Music" => "pop_music_de", "DVD" => "dvd_de", "Video" => "vhs_de", "Electronics" => "ce_de", "Kitchen" => "kitchen_de", "Software" => "software_de", "Video Games" => "video_games_de", "Magazine" => "magazines_de" ); %all_catalog_to_mode = ( "us" => \%us_catalog_to_mode, "uk" => \%uk_catalog_to_mode, "de" => \%de_catalog_to_mode ); if ($FORM{locale} eq "uk") { %books_uk = ( "Top Selling" => 1025612, "Address Books, Journals & More" => 507848, "Art, Architecture & Photography" => 91, "Audio Cassettes" => 51, "Audio CDs" => 267859, "Biography" => 67, "Business, Finance & Law" => 68, "Children's Books" => 69, "Comics & Graphic Novels" => 274081, "Computers & Internet" => 71, "Crime, Thrillers & Mystery" => 72, "e-Books" => 637262, "Fiction" => 62, "Food & Drink" => 66, "Gay & Lesbian" => 275835, "Health, Family & Lifestyle" => 74, "History" => 65, "Home & Garden" => 64, "Horror" => 63, "Mind, Body & Spirit" => 61, "Music, Stage & Screen" => 73, "Poetry, Drama & Criticism" => 275389, "Reference & Languages" => 59, "Religion & Spirituality" => 58, "Romance" => 88, "Science Fiction & Fantasy" => 56, "Science & Nature" => 57, "Scientific, Technical & Medical" => 564334, "Society, Politics & Philosophy" => 60, "Sports, Hobbies & Games" => 55, "Travel & Holiday" => 83, "Young Adult" => 52 ); %classical = ( "Top Selling" => 229817, "Classical for Beginners" => 508574, "Composers" => 506476, "Compilations" => 720862, "Occasions" => 508572, "Solo Instrumental" => 505660, "Chamber Music" => 505630, "Orchestral" => 505586, "Ballet & Dance" => 505622 ); %dvd_uk = ( "Top Selling" => 573406, "Action & Adventure" => 501778, "Art House & International" => 501796, "Children's DVD" => 501858, "Classics" => 501976, "Comedy" => 501866, "Drama" => 501872, "DVD Special Offers" => 655852, "Horror & Suspense" => 501880, "Music" => 501888, "Musicals & Classical" => 1108824, "Science Fiction & Fantasy" => 501912, "Sports & Fitness" => 501940, "Television & Documentary" => 501958 ); %electronics_uk = ( "Top Selling" => 560800, "Computer Peripherals" => 561904, "Gadgets" => 3108311, "Handhelds & PDAs" => 560802, "Home Entertainment" => 560858, "Phones" => 560820, "Photography" => 560834, "Portable Audio" => 560884 ); %kitchen_uk = ( "Top Selling" => 3147411, "Cookware" => 3147471, "Cutlery & Knives" => 3147481, "Home Appliances" => 3147451, "Kitchen Accessories & Gadgets" => 3147491, "Kitchen Appliances" => 3147441, "Personal Care" => 3147461 ); %music = ( "Top Selling" => 694208, "The PopShop" => 694266, "Adult Contemporary" => 694228, "Dance Pop" => 694296, "Greatest Hits" => 694212, "Live Albums" => 694214, "Disco" => 694308, "Pop R&B" => 694216 ); %software_uk = ( "Top Selling" => 1025614, "Business" => 600014, "Children's Fun & Learning" => 300473, "Education & Reference" => 300436, "Graphics" => 600136, "Home Computing" => 599892, "Lifestyle & Hobbies" => 300479, "Linux" => 300543, "Macintosh" => 300530, "Programming & Web Development" => 600188, "Video & Music" => 600236 ); %toys_uk = ( "Top Selling" => 595314, "Arts & Crafts" => 595346, "Baby & Pre-school Toys" => 595446, "Cars" => 1161582, "Collectables" => 1095918, "Development & Learning" => 595334, "Dolls & Accessories" => 595376, "Dressing Up & Make-believe" => 595398, "Electronic Toys" => 1193380, "Experiences" => 3052531, "Games & Puzzles" => 595426, "Outdoor Kit" => 1025554, "Playhouses & Tents" => 595406, "Playsets" => 1095914, "Ride-ons" => 1095910, "Skateboards" => 3059981, "Trains" => 595826, "Vehicles" => 1095916, "Wooden Toys" => 1025552 ); %vhs_uk = ( "Top Selling" => 573400, "Action & Adventure" => 283921, "Art House & International" => 283922, "Children's Videos" => 283928, "Classic Films" => 283923, "Comedy" => 283924, "Drama" => 283925, "Fitness Corner" => 283995, "Horror & Suspense" => 283927, "Music & Performing Arts" => 283929, "Science Fiction & Fantasy" => 283930, "Special Interest" => 283931, "Sports" => 283932, "Television & Documentary" => 283933, "Video Special Offers" => 655858 ); %video_games_uk = ( "Top Selling" => 1025616, "Children's PC & Video Games" => 501128, "Game Boy Advance" => 573612, "GameCube" => 660286, "Game Hardware" => 506846, "PC Games" => 300729, "PlayStation 2" => 526776, "PSone" => 300839, "Xbox" => 660202, "Other Platforms" => 725726 ); %store_to_browse = %{$all_store_to_browse{uk}}; %catalog_to_mode = %{$all_catalog_to_mode{uk}}; } elsif ($FORM{locale} eq "de") { %books_de = ( "Belletristik" => 117, "Börse & Geld" => 120, "Business & Karriere" => 403434, "Computer & Internet" => 124, "Fachbücher" => 288100, "Film, Kultur & Comics" => 548400, "Geist & Wissen" => 119, "Kinder & Jugend Bücher" => 280652, "Kochen & Lifestyle" => 122, "Krimi & Thriller" => 287480, "Lernen & Nachschlagen" => 403432, "Musiknoten" => 1199902, "Naturwissenschaften & Technik" => 121, "Politik, Biografien & Geschichte" => 143, "Ratgeber" => 536302, "Reise & Sport" => 298002, "Science Fiction, Horror & Fantasy" => 142, "Hörbücher" => 300259 ); %books_de_intl_us = ( "Arts & Photography" => 1, "Biographies & Memoirs" => 2, "Business & Investing" => 3, "Children's Books" => 4, "Computers & Internet" => 5, "Cooking, Food & Wine" => 6, "Engineering" => 13643, "Entertainment" => 86, "Gay & Lesbian" => 301889, "Health, Mind & Body" => 10, "History" => 9, "Home & Garden" => 48, "Horror" => 49, "Law" => 10777, "Literature & Fiction" => 17, "Medicine" => 13996, "Mystery & Thrillers" => 18, "Nonfiction" => 53, "Outdoors & Nature" => 290060, "Parenting & Families" => 20, "Professional & Technical" => 173507, "Reference" => 21, "Religion & Spirituality" => 22, "Romance" => 23, "Science" => 75, "Science Fiction & Fantasy" => 25, "Sports" => 26, "Teens" => 28, "Travel" => 27 ); %classical_de = ( "Klassik" => 255966, "Populäre Klassik" => 518124, "Komponisten" => 256029, "Interpreten" => 513528, "Gattungen" => 550142, "Preiswerte Klassik" => 518342 ); %dvd_de = ( "Action, Thriller & Horror" => 289093, "Kinder & Familie" => 290505, "Komödie & Drama" => 290800, "Musik-DVDs" => 289312, "Originalfassungen" => 526774, "Science Fiction & Fantasy" => 548404, "TV & Dokumentationen" => 1027630 ); %ce_de = ( "Computerzubehör" => 700962, "Heimkino & Video" => 761254, "HiFi & Audio" => 571760, "Kamera & Foto" => 571860, "PC & Notebook" => 3034831, "PDA & Organizer" => 569606, "Handy & Telefon" => 571954, "Tragbare Geräte" => 571712, "Zubehör" => 569866 ); %kitchen_de = ( "Elektrische Küchengeräte" => 3169321, "Elektrowerkzeug" => 3527241, "Geschirr, Besteck & Gläser" => 3310821, "Haushaltsgeräte" => 3169211, "Körperpflege & Bad" => 3169021, "Küchengeräte & Kochgeschirr" => 3311201, "Tisch- & Wohnaccessoires" => 3312031, "Wohnen, Garten & Freizeit" => 3312261 ); %pop_music_de = ( "Alternative" => 400118, "Comedy & Kabarett" => 255953, "Dance & Electronic" => 255883, "Diverses" => 255952, "Hard & Heavy" => 264898, "Jazz & Blues" => 255917, "Kindermusik & Hörspiele" => 255956, "Pop" => 264875, "Rap & HipHop" => 255902, "R&B & Soul" => 255895, "Reggae & Ska" => 464356, "Rock" => 264886, "Schlager & Oldies" => 264910, "Songwriter, Folk & Country" => 573044, "Soundtrack & Musical" => 264918, "Weltmusik" => 265502, "Box-Sets" => 1038400, "DVD-Audio" => 772670, "Limited Editions" => 914906, "Maxi-CDs" => 915202, "Super-Audio-CDs" => 914900, "TV-Werbung & Compilations" => 510728 ); %software_de = ( "Betriebssysteme & Tools" => 1064170, "Bildung & Wissenschaft" => 408270, "Büro & Geschäft" => 408288, "Interessen & Unterhaltung" => 408308, "Kinder & Familie" => 408290, "Multimedia & Internet" => 408292, "PDAs & Handhelds" => 505578, "Programmierung & Webdesign" => 408306, "Macintosh" => 910084 ); %magazines_de = ( "Auto & Motorrad" => 1196118, "Computer, Internet & Technik" => 1198616, "Erotik" => 1198618, "Familie, Hobby & Wohnen" => 1198620, "Jugend & Comics" => 1198622, "Mode, Lifestyle & Leute" => 1198628, "Musikzeitschriften" => 1199630, "Reise, Sport & Kultur" => 1198626, "TV & Kino" => 1198630, "Wirtschaft & Politik" => 1198624, "Internationale Presse" => 1198632, "Fachzeitschriften" => 1198634 ); %vhs_de = ( "Action, Thriller & Science Fiction" => 284262, "Kinder & Familie" => 284264, "Komödie & Drama" => 284263, "Musik, TV & Dokumentation" => 284265, "Originalfassungen" => 284267 ); %video_games_de = ( "Computerspiele" => 301129, "Game Boy" => 301014, "Game Boy Advance" => 569128, "GameCube" => 639320, "Nintendo 64" => 301037, "PlayStation" => 300993, "PlayStation 2" => 516838, "Sega Dreamcast" => 301027, "Sega Saturn" => 1198490, "Xbox" => 575708, "Zubehör & Hardware für PC-Spiele" => 643172, "Zubehör & Hardware für Game Boy" => 301026, "Zubehör & Hardware für Game Boy advanced" => 600590, "Zubehör & Hardware für GameCube" => 901948, "Zubehör & Hardware für Nintendo 64" => 408342, "Zubehör & Hardware für PlayStation" => 403624, "Zubehör & Hardware für PlayStation 2" => 516856, "Zubehör & Hardware für Sega Dreamcast" => 301036, "Zubehör & Hardware für Xbox" => 749286 ); %store_to_browse = %{$all_store_to_browse{de}}; %catalog_to_mode = %{$all_catalog_to_mode{de}}; } else { %apparel = ( "Girls" => 1040664, "Boys" => 1040666, "Infants & Toddlers" => 1044500, "Women - Sleepware" => 1044462 ); %sporting = ( "Airsoft" => 3395111, "Archery" => 3395321, "Badminton" => 3528171, "Baseball & Softball" => 3395731, "Basketball" => 3396541, "Billiards" => 3397051, "Boating" => 3397331, "Bowling" => 3399691, "Boxing" => 3400051, "Camping & Hiking" => 3400371, "Cheerleading" => 3402161, "Climbing" => 3402401, "Cricket" => 3402931, "Cycling & Wheel Sports" => 3403201, "Darts" => 3405651, "Disc Sports" => 3406041, "Diving" => 3406281, "Equestrian Sports" => 3407321, "Exercise & Fitness" => 3407731, "Field Hockey" => 3408621, "Fishing" => 3408951, "Football" => 3410221, "Golf" => 3410851, "Gymnastics" => 3412011, "Hockey" => 3412421, "Hunting" => 3412851, "Kayaking" => 3413781, "Lacrosse" => 3414361, "Lawn Games" => 3414921, "Martial Arts" => 3415011, "Paintball" => 3415511, "Racquetball & Squash" => 3528161, "Rugby" => 3415701, "Running" => 3416071 ); %baby = ( "Top Selling" => 540988, Outlet => 735502, "Activity" => 542460, "Bath & Potty" => 541586, "Feeding" => 541564, "Gear" => 541558, "Health & Safety" => 541580, "Layette" => 738468, "Nursery" => 541572, "Backpacks & Carriers" => 542456, "Car Seats" => 541560, "Strollers" => 541562, "Travel Systems" => 542442, "Playards" => 542468, "Bedding" => 541574, "Furniture" => 541576, "Breast-feeding" => 541568, "Bottle Feeding" => 541566, "Solid Feeding" => 541570, "Highchairs" => 542302, "Play Centers" => 548050, "Swings & Bouncers" => 542470 ); %books = ( Outlet => 733804, "Arts & Photography" => 1, "Biographies & Memoirs" => 2, "Business & Investing" => 3, "Children's Books" => 4, "Computers & Internet" => 5, "Cooking, Food & Wine" => 6, "Engineering" => 13643, "Entertainment" => 86, "Gay & Lesbian" => 301889, "Health, Mind & Body" => 10, "History" => 9, "Home & Garden" => 48, "Horror" => 49, "Law" => 10777, "Literature & Fiction" => 17, "Medicine" => 13996, "Mystery & Thrillers" => 18, "Nonfiction" => 53, "Outdoors & Nature" => 290060, "Parenting & Families" => 20, "Professional & Technical" => 173507, "Reference" => 21, "Religion & Spirituality" => 22, "Romance" => 23, "Science" => 75, "Science Fiction & Fantasy" => 25, "Sports" => 26, "Teens" => 28, "Travel" => 27 ); %classical = ( "Top Selling" => 85, "Ballets & Dances" => 5260, "Chamber Music" => 5318, "Featured Composers, A-Z" => 5338, "Featured Performers, A-Z" => 38472, "Forms & Genres" => 36632, "Historical Periods" => 36712, "Instruments" => 38374, "Sacred & Religious" => 63654, "Symphonies" => 63681 ); %dvd = ( "Top Selling" => 404276, Outlet => 734006, "Action & Adventure" => 163296, "African American Cinema" => 538708, "Animation" => 712256, "Anime & Manga" => 517956, "Art House & International" => 163313, "Classics" => 163345, "Comedy" => 163357, "Cult Movies" => 466674, "Documentary" => 508532, "Drama" => 163379, "Gay & Lesbian" => 301667, "Horror" => 163396, "Kids & Family" => 163414, "Military & War" => 586156, "Musicals & Performing Arts" => 508528, "Music Video & Concerts" => 163420, "Mystery & Suspense" => 512030, "Science Fiction & Fantasy" => 163431, "Special Interests" => 163448, "Television" => 163450, "Westerns" => 163312, "Boxed Sets" => 501230 ); %electronics = ( "Top Selling" => 493964, Outlet => 734050, "Accessories & Supplies" => 281407, "Audio & Video" => 1065836, "Computer Add-Ons" => 172455, "Gadgets" => 172517, "GPS & Navigation" => 172526, "Handhelds & PDAs" => 172594, "Office Electronics" => 172574, "Printers" => 172635, "Telephones" => 172606, "DVD Players" => 172514, "VCRs & DVRs" => 172669, "TV & HDTV" => 172659, "MP3 & Digital Audio" => 172630, "Car Accessories" => 226184, "Clocks & Clock Radios" => 509280, "Home Audio" => 172531, "Home Office" => 172574, "Home Video" => 172592, "Portable Audio & Video" => 172623 ); %garden = ( "Top Selling" => 468250, Outlet => 734346, "Backyard Birding" => 553632, "Gifts" => 553648, "Grills & Fryers" => 553760, "Heating & Lighting" => 553778, "Sports & Lawn Games" => 892984, "Outdoor Décor" => 553788, "Patio Furniture" => 553824, "Pest Control" => 553844, "Lawn/Garden Tools" => 915484, "Camping" => 892986 ); %kitchen = ( "Top Selling" => 491864, Outlet => 734070, "Baking" => 289668, "Bar Tools & Glasses" => 289728, "Coffee, Tea & Espresso" => 289742, "Cookware" => 289814, "Cutlery" => 289851, "Housewares" => 510080, "Small Appliances" => 289913, "Tableware" => 289891, "Gadgets" => 289754, "Grills & Fryers" => 553760 ); %magazines = ( "Top Selling" => 599872, "Arts & Crafts" => 602314, "Automotive" => 602316, "Business & Finance" => 602320, "Computer & Internet" => 602324, "Electronics & Audio" => 602326, "Family & Parenting" => 602330, "Fashion & Style" => 602332, "Food & Gourmet" => 602334, "Games & Hobbies" => 602336, "Health & Fitness" => 602340, "Home & Garden" => 602344, "Men's Interest" => 602352, "Music" => 602354, "News & Politics" => 602358, "Science & Nature" => 602364, "Travel & Regional" => 602370, "Women's Interest" => 602372, "Pets" => 602360, "Children's" => 602322, "Entertainment" => 602328 ); %music = ( "Top Selling" => 301668, Outlet => 734368, "Alternative Rock" => 30, "Blues" => 31, "Broadway & Vocalists" => 265640, "Children's" => 173425, "Christian & Gospel" => 173429, "Classic Rock" => 67204, "Country" => 16, "Dance & DJ" => 7, "Folk" => 32, "Hard Rock & Metal" => 67207, "International" => 33, "Latin" => 289122, "Miscellaneous" => 35, "New Age" => 36, "Opera & Vocal" => 84, "Pop" => 37, "Rap & Hip-Hop" => 38, "R&B" => 39, "Rock" => 40, "Soundtracks" => 42, "Indie" => 266023, "Jazz" => 34 ); %pc_hardware = ( "Top Selling" => 565118, "Desktops" => 565098, "Notebooks" => 565108, "AMD" => 602286, "Apple" => 565124, "HP" => 565120, "IBM" => 603128, "Intel" => 565122, "Sony" => 565126, "Toshiba" => 598398, "Desktops" => 565098, "Accessories & Supplies" => 281407, "Refurbished" => 896918, "Handhelds & PDAs" => 172594, "Monitors" => 172509, "Printers" => 172635 ); %photo = ( "Top Selling" => 508048, Outlet => 733952, "Accessories" => 172435, "Binoculars" => 499320, "Camcorders" => 172421, "Film Cameras" => 499106, "Projectors" => 525462, "Surveillance Systems" => 524136, "Digital Cameras" => 281052 ); %software = ( "Top Selling" => 491286, Outlet => 735326, "Business & Office" => 229535, "Children's Software" => 229548, "Graphics" => 229614, "Home & Hobbies" => 229624, "Language & Travel" => 497026, "Linux" => 290562, "Networking" => 229637, "Operating Systems" => 229653, "Personal Finance" => 229540, "Programming" => 229667, "Software for Handhelds" => 229663, "Utilities" => 229672, "Video & Music" => 497022 ); %toys = ( "Top Selling" => 491290, Outlet => 735410, "Action Figures" => 171662, "Arts & Crafts" => 171859, "Building Sets, Blocks & Models" => 171814, "Dolls" => 171569, "Electronics" => 720366, "Games" => 171689, "Sports & Outdoor Play" => 171960, "Stuffed Animals" => 171992, "Learning Toys" => 585496, "Bikes" => 569472, "Furniture" => 172790, "Puzzles" => 171744, "Vehicles" => 171600 ); %universal = ( "Top Selling" => 468240, Outlet => 735342, "Automotive Supplies" => 553294, "Electrical" => 495266, "Hand Tools" => 551238, "Hardware" => 511228, "Heating & Cooling" => 495346, "Job Site Equipment" => 551240, "Lawn & Garden Tools" => 551242, "Lighting" => 495224, "Power Tools" => 551236, "Accessories" => 552262, "Air Tools" => 552684, "Cordless Tools" => 552738, "Sanders" => 552876, "Saws"=> 552894, "Painting" => 228899 ); %vhs = ( "Top Selling" => 404274, Outlet => 735448, "Action & Adventure" => 141, "African American Cinema" => 301597, "Animation" => 712260, "Anime & Manga" => 281300, "Art House & International" => 126, "Classics" => 127, "Comedy" => 128, "Cult Movies" => 162482, "Drama" => 129, "Gay & Lesbian" => 301665, "Horror" => 131, "Kids & Family" => 132, "Military & War" => 586154, "Musicals & Performing Arts" => 508526, "Music Video & Concerts" => 133, "Mystery & Suspense" => 512026, "Science Fiction & Fantasy" => 144, "Special Interests" => 135, "Sports" => 169798, "Television" => 136, "Westerns" => 139725, "Boxed Sets" => 501232 ); %videogames = ( "Top Selling" => 471280, Outlet => 733954, "Game Boy" => 229783, "Game Boy Advance" => 541020, "GameCube" => 541022, "Mac Games" => 229647, "More Systems" => 294940, "Nintendo 64" => 229763, "PC Games" => 229575, "PlayStation" => 229773, "PlayStation2" => 301712, "Sega Dreamcast" => 229793, "Xbox" => 537504, "Linux" => 290573, "NEOGEO" => 541018, "NES" => 566458, "Palm" => 498176, "Sega Game Gear" => 294942, "Sega Genesis" => 294943, "Sega Saturn" => 294944, "Super NES" => 294945 ); %store_to_browse = %{$all_store_to_browse{us}}; %catalog_to_mode = %{$all_catalog_to_mode{us}}; } %sort_hash = ( "+pmrank" => $language_text{sort_text1}, "+salesrank" => $language_text{sort_text2}, "+reviewrank" => $language_text{sort_text3}, "+pricerank" => $language_text{sort_text4}, "+inverse-pricerank" => $language_text{sort_text5}, "+price" => $language_text{sort_text4}, "-price" => $language_text{sort_text5}, "+daterank" => $language_text{sort_text6}, "+titlerank" => $language_text{sort_text7}, "-titlerank" => $language_text{sort_text8}, "+manufactrank" => $language_text{sort_text9}, "-manufactrank" => $language_text{sort_text10}, "+artistrank" => $language_text{sort_text11}, "+orig-rel-date" => $language_text{sort_text12} ); %sort_hash_by_mode = ( "all" => ["+titlerank","+salesrank","+pmrank"], "books" => ["+pmrank","+salesrank","+reviewrank","+pricerank","+inverse-pricerank","+daterank","+titlerank","-titlerank"], "software" => ["+pmrank","+salesrank","+titlerank","-price","+price"], "garden" => ["+pmrank","+salesrank","+titlerank","-titlerank","+manufactrank","-manufactrank","+price","-price"], "universal" => ["+pmrank","+salesrank","+titlerank","-titlerank","+manufactrank","-manufactrank","+price","-price"], "photo" => ["+pmrank","+salesrank","+titlerank","-titlerank"], "pc_hardware" => ["+pmrank","+salesrank","+titlerank","-titlerank"], "videogames" => ["+pmrank","+salesrank","+price","-price","+titlerank"], "music" => ["+pmrank","+salesrank","+artistrank","+orig-rel-date","+titlerank"], "classical" => ["+pmrank","+salesrank","+artistrank","+orig-rel-date","+titlerank"], "office_products" => ["+pmrank","+salesrank","+reviewrank","+price","-price","+titlerank","-titlerank"], "electronics" => ["+pmrank","+salesrank","+reviewrank","+titlerank"], "kitchen" => ["+pmrank","+salesrank","+titlerank","-titlerank","+manufactrank","-manufactrank","+price","-price"], ); %offering_type = ( new => "ThirdPartyNew", used => "Used", collectible => "Collectible", refurbished => "Refurbished" ); %chat_modes = ( photo => 502394, electronics => 172282, videogames => 468642, books => 283155, music => 5174, dvd => 130, toys => 171280 ); } sub calculate_initial_variables { my @associate_ids = @{$associate_ids{$FORM{locale}}}; if ($FORM{templates} and @associate_ids[$FORM{templates}-1]) { $MY_variables{associate_id} = @associate_ids[$FORM{templates}-1]; } else { $MY_variables{associate_id} = @associate_ids[0]; } if ($FORM{locale} eq "uk") { $MY_variables{in_association} = qq[$language_text{association_text1}
]; # $sort_mode = substr($FORM{mode},0,length($FORM{mode})-3); $money_symbol = "£"; $amazon_server = "xml-eu"; } elsif ($FORM{locale} eq "de") { $MY_variables{in_association} = qq[$language_text{association_text1}
]; # $sort_mode = substr($FORM{mode},0,length($FORM{mode})-3); $money_symbol = "EUR "; $amazon_server = "xml-eu"; } else { $MY_variables{in_association} = qq[$language_text{association_text1}
]; $money_symbol = "$"; $amazon_server = "xml"; } $sort_mode = $FORM{mode}; if ($FORM{mode} eq "none") { $FORM{mode} = ""; } if ($FORM{input_string} eq "none") { $FORM{input_string} = ""; } if (!$FORM{link_max_results} and $FORM{max_results} != 50) { $FORM{link_max_results} = $FORM{max_results}; } $ENV{'HTTP_COOKIE'} =~ s/apfcart=([^,]+),([^;]+)/$AWS_variables{CartId} = $1; $AWS_variables{HMAC} = $2;/e; $AWS_variables{HMAC} =~ s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg; if ($AWS_variables{CartId} and $AWS_variables{HMAC}) { $session = qq[&CartId=$AWS_variables{CartId}&Hmac=$AWS_variables{HMAC}]; } %lookup_store = reverse %store_to_browse; $MY_variables{store} = $lookup_store{$FORM{mode}}; ($url_mode = $FORM{mode}) =~ s/_/-/g; $FORM{input_string} =~ s/\s/\+/g; $MY_variables{see_back} = qq[$language_text{see_text3}]; # url, form, & see options $url_options = ""; $MY_variables{form_options} = ""; $see_url_options = ""; if ($FORM{link_templates} or $FORM{templates}) { $url_options .= "&templates=$FORM{link_templates}"; $MY_variables{form_options} .= qq[]; } if ($FORM{language}) { $url_options .= "&language=$FORM{language}"; $MY_variables{form_options} .= qq[]; } if ($FORM{locale}) { $url_options .= "&locale=$FORM{locale}"; $MY_variables{form_options} .= qq[]; } if ($FORM{link_max_results}) { $url_options .= "&max_results=$FORM{link_max_results}"; $MY_variables{form_options} .= qq[]; } if ($FORM{search_type}) { $see_url_options .= "&search_type=$FORM{search_type}"; } if ($FORM{input_string}) { $see_url_options .= "&input_string=$FORM{input_string}"; } if ($FORM{node}) { $see_url_options .= "&node=$FORM{node}"; } if ($FORM{item_id}) { $see_url_options .= "&item_id=$FORM{item_id}"; } if ($FORM{sort_type} ne "+salesrank") { $see_url_options .= "&sort_type=$FORM{sort_type}"; } if ($FORM{pricerange}) { $see_url_options .= "&pricerange=$FORM{pricerange}"; } if ($FORM{keywords}) { $see_url_options .= "&keywords=$FORM{keywords}"; } if ($session and !$FORM{cart_action} and $FORM{locale} eq "us") { $MY_variables{shopping_cart_link} = qq[$language_text{cart_text3}]; } if ($FORM{node}) { %lookup_browse_id = reverse %{$FORM{mode}}; $query = "BrowseNodeSearch=" . $FORM{node} . "&mode=$url_mode&type=lite&page=$FORM{page_num}"; if ($FORM{input_string} and !$FORM{keywords}) { $FORM{keywords} = $FORM{input_string}; } $MY_variables{subject} = $lookup_browse_id{$FORM{node}}; $MY_variables{header} = qq[$language_text{header_text1} > $MY_variables{store} > $MY_variables{subject}
]; } elsif ($FORM{input_string}) { if ($FORM{search_type} =~ /(?:SimilaritySearch|ListManiaSearch|SellerProfile|SellerSearch|WishlistSearch|ExchangeSearch)/) { if ($FORM{search_type} eq "SellerSearch") { $query = "SellerSearch=$FORM{input_string}&type=heavy&offerstatus=open&page=$FORM{page_num}"; } else { $query = "$FORM{search_type}=$FORM{input_string}&type=lite&page=$FORM{page_num}"; } } else { if ($FORM{search_type} =~ /(AuthorSearch|ArtistSearch|ActorSearch|ManufacturerSearch|DirectorSearch|PowerSearch)/) { $query = "$FORM{search_type}="; } else { $query = "KeywordSearch="; } (my $search_url = $FORM{input_string}) =~ s/\+/%20/g; ($MY_variables{subject} = $FORM{input_string}) =~ s/\+/ /g; $query .= $search_url . "&mode=$url_mode&type=lite&page=$FORM{page_num}"; } } elsif ($FORM{search_type} =~ /(ThirdPartyNew|Used|Collectible|Refurbished)/) { $query = "AsinSearch=$FORM{item_id}&type=heavy&offer=$FORM{search_type}&offerpage=$FORM{page_num}"; my %marketplace_text_hash = ( Used => $language_text{my_marketplace2}, Collectible => $language_text{my_marketplace3}, ThirdPartyNew => $language_text{my_marketplace4}, Refurbished => $language_text{my_marketplace5} ); $my_marketplace_text = $marketplace_text_hash{$FORM{search_type}}; } elsif ($FORM{item_id} =~ /,/) { $MY_variables{store} = $language_text{header_text2}; $MY_variables{subject} = $language_text{header_text3}; $query = "AsinSearch=" . $FORM{item_id} . "&type=lite&page=$FORM{page_num}"; } if ($FORM{pricerange}) { $query .= qq[&price=$FORM{pricerange}]; } if ($FORM{keywords}) { $query .= qq[&keywords=$FORM{keywords}]; } } sub build_search_box { my ($search_box_allsearches, $search_subject); if ($show_search_options eq "yes") { $search_box_allsearches = qq[
$language_text{searchbox_text3}]; } $MY_variables{search_box} = qq[
]; $MY_variables{search_box} .= $MY_variables{form_options}; $MY_variables{search_box} .= qq[$search_box_allsearches
]; } sub load_templates { my $temp_num = $FORM{templates} - 1; if ($temp_num < 0) { $temp_num = 0; } my %template_name_refs = ( page => \@page_templates, products => \@products_templates, item => \@item_templates, larger_image => \@larger_image_templates, sellersearch => \@sellersearch_templates, sellerprofile => \@sellerprofile_templates, thirdparty_products => \@thirdparty_products_templates, browse_menu => \@browse_menu_templates, nav_menu => \@nav_menu_templates, featured_product => \@featured_product_templates, blended => \@blended_templates, shopping_cart => \@shopping_cart_templates, customer_reviews => \@customer_reviews_templates); for my $key (keys %template_name_refs) { my $template_file_name = ${$template_name_refs{$key}}[$temp_num]; if ( -e $template_file_name ) { open(FILEHANDLE,"<$template_file_name"); while () { $template_html{$key} = $template_html{$key} . $_; } close (FILEHANDLE); } } } sub get_url { my $value = $_[0]; my $skip = $_[1]; my (%xml_cache,$xml_result,$dbm_error); my $cache_expire = time() - 3600; my $cache_time = $value . "_time"; if ($use_cache eq "yes") { eval 'use Fcntl'; $dbm_error = $@; eval 'use DB_File'; $dbm_error .= $@; if (!$dbm_error) { if (-s $cache_file > (7000 * $cache_max_size)) { unlink $cache_file; } eval 'tie(%xml_cache,"DB_File",$cache_file,O_RDONLY)'; $dbm_error = $@; } } if ($xml_cache{$value} and $xml_cache{$cache_time} > $cache_expire) { $xml_result = $xml_cache{$value}; $debug .= "cache status = cached request size " . length($xml_result) . ", total requests cached " . keys(%xml_cache) . "\n"; untie %xml_cache; } else { untie %xml_cache; eval 'use LWP::Simple qw($ua get)'; if ($@) { print "Content-type: text/html\n\n"; print "Unable to use LWP::Simple and this script cannot function without it.\n"; exit; } my $ua = new LWP::UserAgent; $ua->timeout(30); $xml_result = get($value); $xml_result =~ s/\<//<$1em>/gi; $xml_result =~ s/<(\/?)b>/<$1strong>/gi; $xml_result =~ s/
/
/gi; $xml_result =~ s/<\/?p>/

/gi; if (!$xml_result and $skip ne "skip_ok") { $MY_variables{error_msg} = "Sorry, we are currently unable to process your request in a timely manner.
Please try again later.\n"; } if ($use_cache eq "yes" and !$dbm_error) { my $count=0; open(LOCK, ">$cache_file.lock"); until (flock(LOCK,2) or $count > 50) { sleep .10; ++$count; } if ($count > 50) { $dbm_error = "lock failed"; } if (!$dbm_error) { eval 'tie(%xml_cache,"DB_File",$cache_file,O_CREAT|O_RDWR)'; $dbm_error = $@; if (keys(%xml_cache) > $cache_max_size) { undef %xml_cache; $debug .= "cleared cache\n"; } } } $xml_cache{$value} = $xml_result; $xml_cache{$cache_time} = time; untie %xml_cache; close(LOCK); $debug .= "cache status = not cached request size " . length($xml_result) . "\n"; } $xml_result =~ s/([^<]+)<\/ErrorMsg>/if ($skip ne "skip_ok") { $MY_variables{error_msg} .= $1; }/esi; return $xml_result; } sub parse_xml_into_hashes_of_arrays { my $xml_result = shift; my (%temp_level_0, $temp_level_1); $xml_result =~ s/<([^>]+?)(?:\s[^>]+)?>(.*?)<\/\1>/push @{$temp_level_0{$1}}, $2;/gsie; $temp_level_1 = process_hashes_of_arrays(\%temp_level_0); delete $AWS_variables{ProductInfo}; $AWS_variables{TotalResults} = ${${$temp_level_1}{TotalResults}}[0]; $AWS_variables{TotalPages} = ${${$temp_level_1}{TotalPages}}[0]; return $temp_level_1; } sub process_hashes_of_arrays { my ($entry_hash, %exit_hash) = @_; for my $key (keys %$entry_hash) { if (!${${$entry_hash}{$key}}[1]) { $AWS_variables{$key} = ${${$entry_hash}{$key}}[0]; $AWS_variables{$key} =~ s/"/'/g; } foreach my $item (@{${$entry_hash}{$key}}) { $item =~ s/<([^>]+?)(\s[^>]+)?>(.*?)<\/\1>/my $temp3; if ($2 and $1 eq "Details") { $temp3 = $3 . "$2<\/DetailsURL>"; } else { $temp3 = $3; } push @{$exit_hash{$1}}, $temp3;/gsie; } } return \%exit_hash; } sub blended_search { my $level_1 = shift; my $i_blended = 0; foreach my $item_blended (@{${$level_1}{ProductLine}}) { my %temp_hash_blended; push @{$temp_hash_blended{ProductLine}}, $item_blended; my $level_2_blended = process_hashes_of_arrays(\%temp_hash_blended); if (${$level_2_blended}{Mode}[0] eq "apparel") { next; } my $level_3_blended = process_hashes_of_arrays($level_2_blended); ${$level_2_blended}{Mode}[0] =~ s/-/_/g; $MY_variables{blended_mode} = $lookup_store{${$level_2_blended}{Mode}[0]}; $MY_variables{blended_mode_totalresults} = ${$level_3_blended}{TotalResults}[0]; $MY_variables{blended_mode_pages} = ${$level_3_blended}{TotalPages}[0]; $MY_variables{blended_see_more_url} = qq[$MY_variables{script_name}?mode=${$level_2_blended}{Mode}[0]&input_string=$FORM{input_string}$url_options]; $MY_variables{products_html} .= set_html("blended"); assign_variables("products",$level_3_blended); } $MY_variables{store} = "$language_text{searchbox_text1}"; } sub assign_variables { my ($whose_variables, $temp_input) = @_; my @Details; if (@{${$temp_input}{Details}}) { @Details = @{${$temp_input}{Details}}; } my $i = 0; my ($more_form_options); Details_loop: foreach my $item (@Details) { my (%temp_hash, @descriptors); my @AWS_deletekeys = (DetailsURL,Catalog,ReleaseDate,Manufacturer,Availability,ListPrice,OurPrice,UsedPrice); delete @AWS_variables{@AWS_deletekeys}; my @MY_deletekeys = (our_price,list_price,discount,our_value,list_value,my_artists); delete @MY_variables{@MY_deletekeys}; $details_max = $#Details + 1; push @{$temp_hash{Details}}, $item; my $level_2 = process_hashes_of_arrays(\%temp_hash); my $level_3 = process_hashes_of_arrays($level_2); if ($AWS_variables{DetailsURL}) { $AWS_variables{DetailsURL} =~ s/(?:\surl=|\')//g; $MY_variables{in_association} = qq[$language_text{association_text1}
]; } if ($FORM{node}) { if (exists($chat_modes{$FORM{mode}})) { $MY_variables{chat_link} = qq[Chat about $lookup_browse_id{$FORM{node}}
]; } } if ($catalog_to_mode{$AWS_variables{Catalog}} and !$FORM{mode}) { $FORM{mode} = $catalog_to_mode{$AWS_variables{Catalog}}; } $more_form_options = qq[]; if ($FORM{search_type}) { $more_form_options .= qq[]; } if ($FORM{input_string}) { $more_form_options .= qq[]; } if ($FORM{node}) { $more_form_options .= qq[]; } if ($FORM{item_id}) { $more_form_options .= qq[]; } if ($FORM{pricerange}) { $more_form_options .= qq[]; } if ($FORM{keywords}) { $more_form_options .= qq[]; } # start my_artists if ($FORM{mode} =~ /^(books|books_uk|books_de|books_de_intl_us)$/i) { $MY_variables{my_artists} = comma_separate_list(${$level_3}{Author},$language_text{my_artists_text1},"AuthorSearch"); } elsif ($FORM{mode} =~ /^(music|classical|pop_music_de|classical_de)$/i) { $MY_variables{my_artists} = comma_separate_list(${$level_3}{Artist},$language_text{my_artists_text1},"ArtistSearch"); } elsif ($FORM{mode} =~ /^(dvd|vhs|video|dvd_uk|vhs_uk|dvd_de|vhs_de)$/i) { $MY_variables{my_artists} = comma_separate_list(${$level_3}{Actor},$language_text{my_artists_text2},"ActorSearch"); if (${$level_3}{Director}) { $MY_variables{my_artists} .= "
" . comma_separate_list(${$level_3}{Director},$language_text{my_artists_text4},"DirectorSearch"); } } if ( (!$MY_variables{my_artists}) and ($AWS_variables{Manufacturer}) ) { if ($FORM{mode} =~ /^(electronics|kitchen|videogames|software|photo|pc_hardware|electronics_uk|video_games_uk|software_uk|ce_de|kitchen_de|video_games_de|software_de)$/) { (my $search_manufacturer_string = $AWS_variables{Manufacturer}) =~ s/ /+/g; $MY_variables{my_artists} = qq[$language_text{my_artists_text3} $AWS_variables{Manufacturer}]; } else { $MY_variables{my_artists} = qq[$language_text{my_artists_text3} $AWS_variables{Manufacturer}]; } } # end my_artists # start my_comments my $temp_loop = 1; foreach my $item (@{${$level_3}{CustomerReview}}) { my (%temp_hash,$temp_hash1,$temp_rounded_rating,$temp_rating_display,$shortened_comment); push @{$temp_hash{CustomerReview}}, $item; $temp_hash1 = process_hashes_of_arrays(\%temp_hash); ($temp_rounded_rating = ${$temp_hash1}{Rating}[0]) =~ s/(\.\d+)//; if ($1 >= .25 and $1 < .75) { $temp_rounded_rating .= "-5"; } elsif ($1 >= .75) { $temp_rounded_rating++; $temp_rounded_rating .= "-0"; } else { $temp_rounded_rating .= "-0"; } $temp_rating_display = qq[${$temp_hash1}{Rating}[0] out of 5 stars]; if ($FORM{mode} eq "toys") { $temp_rating_display = ${$temp_hash1}{Rating}[0]}; if (!${$temp_hash1}{Rating}[0]) { $temp_rating_display = $language_text{average_rating_text2}; } if ($MY_variables{my_comments}) { $MY_variables{my_comments} .= qq[


\n]; } $MY_variables{my_comments} .= qq[$language_text{my_comments_text1} $temp_rating_display - ${$temp_hash1}{Summary}[0]
\n${$temp_hash1}{Comment}[0]
\n]; $shortened_comment = ${$temp_hash1}{Comment}[0]; $shortened_comment =~ s/<([^\s|>]+)\s[^>]+>(.*?)<\/\1>/$2/gis; if ($review_length) { while (substr($shortened_comment,$review_length,1) !~ /[\s|-]/ and $review_length < length($shortened_comment)) { $review_length++ } $shortened_comment = substr($shortened_comment,0,$review_length); if ($review_length < length(${$temp_hash1}{Comment}[0])) { $shortened_comment .= qq[ ... $language_text{my_comments_text2}]; } } if ($MY_variables{my_shortened_comments}) { $MY_variables{my_shortened_comments} .= qq[


\n]; } $MY_variables{my_shortened_comments} .= qq[$language_text{my_comments_text1} $temp_rating_display - ${$temp_hash1}{Summary}[0]
\n$shortened_comment
\n]; if ($temp_loop eq 1) { $MY_variables{first_review_rating_display} = $temp_rating_display; $MY_variables{first_review_summary} = ${$temp_hash1}{Summary}[0]; $MY_variables{first_review_comment} = ${$temp_hash1}{Comment}[0]; $MY_variables{first_review_shortened_comment} = $shortened_comment; } $temp_loop++; } # end my_comments # start my_features if (${$level_3}{Feature}) { $MY_variables{my_features} = qq[$language_text{my_features_text1}\n
    \n
  • ]; $MY_variables{my_features} .= join("
  • \n
  • ", @{${$level_3}{Feature}}); $MY_variables{my_features} .= qq[
  • \n
\n]; } # end my_features # start my_prices if ($FORM{locale} eq "us") { if ($AWS_variables{UsedPrice} and $AWS_variables{UsedPrice} ne "\$0.") { $MY_variables{my_used} = qq[$language_text{my_marketplace2} $language_text{my_marketplace1} $AWS_variables{UsedPrice}
]; } if ($AWS_variables{CollectiblePrice} and $AWS_variables{CollectiblePrice} ne "\$0.") { $MY_variables{my_collectible} = qq[$language_text{my_marketplace3} $language_text{my_marketplace1} $AWS_variables{CollectiblePrice}
]; } if ($AWS_variables{ThirdPartyNewPrice} and $AWS_variables{ThirdPartyNewPrice} ne "\$0.") { $MY_variables{my_thirdpartynew} = qq[$language_text{my_marketplace4} $language_text{my_marketplace1} $AWS_variables{ThirdPartyNewPrice}
]; } if ($AWS_variables{RefurbishedPrice} and $AWS_variables{RefurbishedPrice} ne "\$0.") { $MY_variables{my_refurbished} = qq[$language_text{my_marketplace5} $language_text{my_marketplace1} $AWS_variables{RefurbishedPrice}
]; } } if ($AWS_variables{OurPrice}) { $MY_variables{our_value} = $AWS_variables{OurPrice}; if ($FORM{locale} eq "de") { $MY_variables{our_value} =~ s/\.//g; $MY_variables{our_value} =~ s/,/./; } else { $MY_variables{our_value} =~ s/,//g; } $MY_variables{our_value} =~ s/^(?:(?:\$|£|EUR )(\d+(?:\.\d*)?|\.\d+))?.*$/$1/; $MY_variables{our_price} = qq[$language_text{my_prices_text2} $AWS_variables{OurPrice}
]; } else { $MY_variables{our_price} = qq[$language_text{my_prices_text2} $language_text{my_prices_text5}
]; } if ($AWS_variables{ListPrice} and ($AWS_variables{OurPrice} ne $AWS_variables{ListPrice}) ) { $MY_variables{list_value} = $AWS_variables{ListPrice}; if ($FORM{locale} eq "de") { $MY_variables{list_value} =~ s/\.//g; $MY_variables{list_value} =~ s/,/./; } else { $MY_variables{list_value} =~ s/,//g; } $MY_variables{list_value} =~ s/^(?:(?:\$|£|EUR )(\d+(?:\.\d*)?|\.\d+))?.*$/$1/; if ($MY_variables{our_value} < $MY_variables{list_value}) { $MY_variables{list_price} = qq[$language_text{my_prices_text1} $AWS_variables{ListPrice}
]; } } if ( ($MY_variables{our_value} and $MY_variables{list_value}) and ($MY_variables{our_value} < $MY_variables{list_value}) ) { my $discount_amount = $money_symbol . (sprintf "%.2f", ($MY_variables{list_value} - $MY_variables{our_value})); if ($FORM{locale} eq "de") { $discount_amount =~ s/\./,/g; } my $discount_percent = (sprintf "%2.f", (100 - ($MY_variables{our_value} / $MY_variables{list_value})*100)) . "%"; $MY_variables{discount} = qq[$language_text{my_prices_text3} $discount_amount ($discount_percent)
]; } $MY_variables{my_prices} = qq[
] . $MY_variables{list_price} . $MY_variables{our_price} . $MY_variables{discount} . qq[$language_text{my_prices_text4}
]; # end my_prices # start my_descriptors if ($AWS_variables{SalesRank}) { push (@descriptors, qq[$language_text{my_descriptors_text9} $AWS_variables{SalesRank}]); } if ($AWS_variables{ReleaseDate}) { push (@descriptors, qq[$language_text{my_descriptors_text1} $AWS_variables{ReleaseDate}]); } if ($AWS_variables{Media} and $AWS_variables{Media} ne $AWS_variables{Catalog}) { push (@descriptors, qq[$language_text{my_descriptors_text3} $AWS_variables{Media}]); } if ($AWS_variables{NumMedia} and $AWS_variables{NumMedia} > 1) { push (@descriptors, qq[$language_text{my_descriptors_text4} $AWS_variables{NumMedia}]); } if ($AWS_variables{Encoding}) { push (@descriptors, qq[$language_text{my_descriptors_text10} $AWS_variables{Encoding}]); } if ($AWS_variables{TheatricalReleaseDate}) { push (@descriptors, qq[$language_text{my_descriptors_text2} $AWS_variables{TheatricalReleaseDate}]); } if ($AWS_variables{MpaaRating}) { push (@descriptors, qq[$language_text{my_descriptors_text5} $AWS_variables{MpaaRating}]); } if ($AWS_variables{EsrbRating}) { push (@descriptors, qq[$language_text{my_descriptors_text7} $AWS_variables{EsrbRating}]); } if ($AWS_variables{ReadingLevel}) { push (@descriptors, qq[$language_text{my_descriptors_text12} $AWS_variables{ReadingLevel}]); } if ($AWS_variables{AgeGroup}) { push (@descriptors, qq[$language_text{my_descriptors_text8} $AWS_variables{AgeGroup}]); } if ($AWS_variables{Manufacturer} and $MY_variables{my_artists} !~ /\Q$AWS_variables{Manufacturer}\E/) { push (@descriptors, qq[$language_text{my_descriptors_text13} $AWS_variables{Manufacturer}]); } $MY_variables{my_platforms} = join(", ", @{${$level_3}{Platform}}); if ($MY_variables{my_platforms}) { push (@descriptors, qq[$language_text{my_descriptors_text6} $MY_variables{my_platforms}]); } $MY_variables{my_descriptors} = join("
\n", @descriptors); if ($MY_variables{my_descriptors}) { $MY_variables{my_descriptors} .= "
\n"; } # end my_descriptors if ($AWS_variables{ProductDescription}) { $MY_variables{product_description} = qq[$language_text{my_product_description}

$AWS_variables{ProductDescription}
\n]; } # start my_ThirdPartyProductDetails if ($my_marketplace_text) { my $ii; foreach my $item (@{${$level_3}{ThirdPartyProductDetails}}) { my (%temp_hash,$temp_hash1,$temp_hash2); push @{$temp_hash{ThirdPartyProductDetails}}, $item; $temp_hash1 = process_hashes_of_arrays(\%temp_hash); $temp_hash2 = process_hashes_of_arrays($temp_hash1); if (!$AWS_variables{OfferingPrice}) { next; } if (!$AWS_variables{SellerRating}) { $AWS_variables{SellerRating} = "$language_text{average_rating_text2}"; } $MY_variables{sellersearch_url} = "$MY_variables{script_name}?search_type=SellerSearch&input_string=$AWS_variables{SellerId}$url_options"; $MY_variables{ThirdPartyProduct_buy_button} = qq[]; $MY_variables{buy_button} = initialize_buttons("buy"); $MY_variables{my_ThirdPartyProductDetails} .= set_html("thirdparty_products",$ii); $ii++ } $MY_variables{store} = $my_marketplace_text; $MY_variables{subject} = $AWS_variables{ProductName}; } # end my_ThirdPartyProductDetails #start sort_box if (($FORM{input_string} or $FORM{node} or $FORM{search_type} =~ /AuthorSearch|ArtistSearch|ActorSearch|DirectorSearch|ManufacturerSearch|PowerSearch/) and $AWS_variables{TotalResults} > 1) { my (@temp_sort_array,$sort_box_options); if ( @{$sort_hash_by_mode{$sort_mode}} ) { @temp_sort_array = @{$sort_hash_by_mode{$sort_mode}}; } else { @temp_sort_array = @{$sort_hash_by_mode{"all"}}; } foreach my $key1 (keys %sort_hash) { if (grep { $_ eq $key1 } @temp_sort_array) { $sort_box_options .= qq[]; } } my $sort_form_options = $MY_variables{form_options} . $more_form_options; $MY_variables{sort_box} = qq[
$sort_form_options
]; } #end sort_box if (${$level_3}{AvgCustomerRating} and ${$level_3}{AvgCustomerRating}[0] != 0) { $AWS_variables{AvgCustomerRating} = sprintf "%.2f", ${$level_3}{AvgCustomerRating}[0]; (my $temp_rounded_rating = $AWS_variables{AvgCustomerRating}) =~ s/(\.\d+)//; if ($1 >= .25 and $1 < .75) { $temp_rounded_rating .= "-5"; } elsif ($1 >= .75) { $temp_rounded_rating++; $temp_rounded_rating .= "-0"; } else { $temp_rounded_rating .= "-0"; } $MY_variables{my_avg_rating_display} = qq[$AWS_variables{AvgCustomerRating} out of 5 stars]; } else { $MY_variables{my_avg_rating_display} = $AWS_variables{AvgCustomerRating} = $language_text{average_rating_text2}; } if ($AWS_variables{Tracks}) { foreach my $item (@{${$level_3}{Track}}) { $MY_variables{my_tracks} .= qq[
  • $item
  • ]; } $MY_variables{my_tracks} = qq[$language_text{my_descriptors_text11}
      $MY_variables{my_tracks}
    ]; } if (${$level_3}{Product}) { if (${$level_3}{ListId}) { $MY_variables{my_listmania} = qq[
  • $language_text{similar_text1}
  • ]; } my ($temp_similar_products, $temp_similar_products_cart) = get_extra_product_links(${$level_3}{Product}); if ($temp_similar_products) { my $temp_similar_products_images; $MY_variables{my_similar_products} = qq[$language_text{my_similar_products_text1}]; foreach my $item (@{${$level_3}{Product}}) { $temp_similar_products_images .= qq[ ]; } $MY_variables{my_similar_products_images} = qq[$language_text{my_similar_products_text1}
    $temp_similar_products_images$language_text{see_text6}
    ]; } if ($temp_similar_products_cart) { $MY_variables{similar_products_cartadd} = qq[
    $language_text{cart_text4}
    $language_text{my_similar_products_text1}
    ] . $temp_similar_products_cart . qq[

    \n]; } elsif ($MY_variables{my_similar_products}) { $MY_variables{similar_products_cartadd} = $MY_variables{my_similar_products}; } } if (${$level_3}{Accessory}) { my ($temp_accessories, $temp_accessories_cart) = get_extra_product_links(${$level_3}{Accessory}); if ($temp_accessories) { my $temp_accessories_images; $MY_variables{my_accessories} = qq[$language_text{my_accessories_text1}
      $temp_accessories
    ]; foreach my $item (@{${$level_3}{Accessory}}) { $temp_accessories_images .= qq[ ]; } $MY_variables{my_accessories_images} = qq[$language_text{my_accessories_text1}
    $temp_accessories_images
    ]; } if ($temp_accessories_cart) { $MY_variables{accessories_cartadd} = qq[
    $language_text{cart_text4}
    $language_text{my_accessories_text1}
    ] . $temp_accessories_cart . qq[

    \n]; } elsif ($MY_variables{my_accessories}) { $MY_variables{accessories_cartadd} = $MY_variables{my_accessories}; } } if (!$AWS_variables{Availability}) { $AWS_variables{Availability} = "unknown"; } $MY_variables{my_availability} = qq[$language_text{availability_text1} $AWS_variables{Availability}
    \n]; $MY_variables{old_product_url} = "http://www.$amazon_site/exec/obidos/ASIN/$AWS_variables{Asin}/ref=nosim/$MY_variables{associate_id}?dev-t=D1KQJBNTALRLQH"; $MY_variables{pda_item_url} = "http://www.amazon.com/exec/obidos/redirect?tag=$MY_variables{associate_id}&creative=D1KQJBNTALRLQH&camp=2025&link_code=xm2&path=dt/upda-1.0-anywhere/tg/aa/upda/item/-/$AWS_variables{Asin}"; $MY_variables{rim_item_url} = "http://www.amazon.com/exec/obidos/redirect?tag=$MY_variables{associate_id}&creative=D1KQJBNTALRLQH&camp=2025&link_code=xm2&path=dt/upda-1.0-i/tg/aa/upda/item/-/$AWS_variables{Asin}"; $MY_variables{my_large_image_url} = "$MY_variables{script_name}?item_id=$AWS_variables{Asin}&search_type=image$url_options"; $MY_variables{item_url} = "$MY_variables{script_name}?item_id=$AWS_variables{Asin}&search_type=AsinSearch$url_options"; $MY_variables{buy_button} = initialize_buttons("buy"); $MY_variables{oneclick_button} = initialize_buttons("oneclick"); $MY_variables{shopping_cart_button} = initialize_buttons("cart"); $MY_variables{wishlist_button} = initialize_buttons("wishlist"); $MY_variables{wedding_button} = initialize_buttons("wedding"); $MY_variables{baby_button} = initialize_buttons("baby"); $MY_variables{products_html} .= set_html($whose_variables,$i) . $MY_variables{my_ThirdPartyProductDetails}; if ($i >= $FORM{max_results} -1) { last Details_loop; } $i++; } if ($whose_variables eq "sellerprofile") { my $level_2 = process_hashes_of_arrays($temp_input); my $level_3 = process_hashes_of_arrays($level_2); my $ii ="0"; if (!$AWS_variables{NumberOfCanceledAuctions}) { $AWS_variables{NumberOfCanceledAuctions} = $language_text{average_rating_text2}; } $sellerprofile_max = $#{${$level_3}{Feedback}} + 1; foreach my $item (@{${$level_3}{Feedback}}) { my (%temp_hash,$temp_hash1,$temp_hash2); push @{$temp_hash{ListingProductDetails}}, $item; $temp_hash1 = process_hashes_of_arrays(\%temp_hash); $temp_hash2 = process_hashes_of_arrays($temp_hash1); $MY_variables{sellerprofile_html} .= set_html("sellerprofile",$ii); $ii++ } } elsif ($whose_variables eq "sellersearch") { my $level_2 = process_hashes_of_arrays($temp_input); my $level_3 = process_hashes_of_arrays($level_2); $MY_variables{store} = $AWS_variables{SellerNickname}; $MY_variables{subject} = $language_text{button_text4}; $MY_variables{products_html} .= $MY_variables{sellerprofile_html}; if ($search_type eq "ExchangeSearch") { ${$level_3}{ListingProductDetails} = ${$temp_input}{ListingProductDetails}; } foreach my $item (@{${$level_3}{ListingProductDetails}}) { my (%temp_hash,$temp_hash1,$temp_hash2); push @{$temp_hash{ListingProductDetails}}, $item; $temp_hash1 = process_hashes_of_arrays(\%temp_hash); $temp_hash2 = process_hashes_of_arrays($temp_hash1); if (!$AWS_variables{ExchangeSellerRating}) { $AWS_variables{ExchangeSellerRating} = "$language_text{average_rating_text2}"; } $AWS_variables{ImageUrlSmall} = "http://images.amazon.com/images/P/$AWS_variables{ExchangeAsin}.01.THUMBZZZ.jpg"; $MY_variables{item_url} = "$MY_variables{script_name}?search_type=$offering_type{$AWS_variables{ExchangeOfferingType}}&item_id=$AWS_variables{ExchangeAsin}$url_options"; $MY_variables{my_exchangesellerrating} = qq[$language_text{my_comments_text1} $AWS_variables{ExchangeSellerRating}]; $MY_variables{ThirdPartyProduct_buy_button} = qq[]; $MY_variables{buy_button} = initialize_buttons("buy"); $MY_variables{products_html} .= set_html("sellersearch",$i); if ($i >= $FORM{max_results} -1) { return; } $i++; } } elsif ($whose_variables eq "AllSearches") { initialize_all_search_boxes(); $MY_variables{products_html} .= set_html("AllSearches",$i); } # start see_more if ($AWS_variables{TotalResults} or $AWS_variables{NumberOfOfferings}) { $AWS_variables{TotalResults} = $AWS_variables{TotalResults} + $AWS_variables{NumberOfOfferings}; if (!$AWS_variables{TotalPages}) { $AWS_variables{TotalPages} = int(($AWS_variables{TotalResults} + 9)/10); if ($AWS_variables{TotalPages} == 0) { $AWS_variables{TotalPages} = 1; } } $MY_variables{see_total} = qq[$language_text{see_text4} $FORM{page_num} $language_text{see_text5}  $AWS_variables{TotalPages}]; my $see_form_options = $MY_variables{form_options} . $more_form_options; $see_form_options .= qq[]; if ($FORM{page_num} < $AWS_variables{TotalPages}) { my $next_page = $FORM{page_num} + 1; $see_form_options .= qq[]; $MY_variables{see_next} = qq[
    $see_form_options
    ]; } if ($FORM{page_num} > 1) { my $prev_page = $FORM{page_num} - 1; $see_form_options .= qq[]; $MY_variables{see_prev} = qq[
    $see_form_options
    ]; } my ($page_num_low,$page_num_high); $MY_variables{see_index} = ""; if ($AWS_variables{TotalPages} != "1") { if ($FORM{page_num} - 5 > 0) { $page_num_low = $FORM{page_num} - 5; } else { $page_num_low = "1"; } if ($page_num_low + 10 <= $AWS_variables{TotalPages}) { $page_num_high = $page_num_low + 10; } else { $page_num_high = $AWS_variables{TotalPages}; } for (my $loop_index = $page_num_low; $loop_index <= $page_num_high; $loop_index++) { if ($loop_index == $FORM{page_num}) { $MY_variables{see_index} .= qq[ $loop_index ]; } else { $MY_variables{see_index} .= qq[ $loop_index ]; } } } } #end see_more } sub shopping_cart { my ($this_xml_url, $xml_result); if (!$MY_variables{associate_id}) { $html = "

    No associate_id found!

    "; } $use_cache = "no"; $debug .= "cook=$ENV{'HTTP_COOKIE'}\n"; $MY_variables{store} = "Shopping"; $MY_variables{subject} = "Cart"; $MY_variables{header} = $language_text{cart_text1}; if ($FORM{cart_action} eq "get") { if (!$session) { $MY_variables{products_html} = $language_text{cart_text2}; return; } $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?ShoppingCart=get&f=xml&t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH$session&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; } elsif ($FORM{cart_action} eq "clear") { if (!$session) { $MY_variables{products_html} = $language_text{cart_text2}; return; } print "Set-Cookie: apfcart=empty; expires=Sun 01-Jan-01 01:01:01 GMT;\n"; my $temp_result = get_url("http://$amazon_server.amazon.com/onca/xml3?ShoppingCart=clear&f=xml&t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH$session&locale=$FORM{locale}"); $MY_variables{products_html} = $language_text{cart_text2}; return; } elsif ($FORM{cart_action} eq "modify") { my $cart_delete_item; $ENV{QUERY_STRING} =~ s/cart_delete_item=([^&]+)/$cart_delete_item = $1;/e; $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?ShoppingCart=modify&f=xml&t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&Item.$cart_delete_item=0$session&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; } elsif ($FORM{cart_action} eq "add") { my ( %item_hash, $item_key, $items_quantities ); $ENV{QUERY_STRING} =~ s/cart_item_([^=]+)=([^&]+)/if ($2 > 0) { $item_hash{$1} = $item_hash{$1} + $2; }/ge; foreach $item_key (keys %item_hash) { $items_quantities .= "&Asin.$item_key=$item_hash{$item_key}"; } $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?ShoppingCart=add&f=xml&t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH$items_quantities$session&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; } elsif ($FORM{cart_action} eq "replace") { if (!$session) { $MY_variables{products_html} = $language_text{cart_text2}; return; } my ( $temp_result, %item_hash, $item_key, $items_quantities, $i ); for (my $temp_i = 1; $temp_i <= 3; $temp_i++) { delete $MY_variables{error_msg}; $temp_result = get_url("http://$amazon_server.amazon.com/onca/xml3?ShoppingCart=clear&f=xml&t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH$session&locale=$FORM{locale}"); $xml_result = get_url($this_xml_url); $debug .= "xml_url=$this_xml_url\n"; if ($xml_result =~ /ShoppingCart/) { $MY_variables{error_msg} = ""; last; } } sleep 1; $ENV{QUERY_STRING} =~ s/cart_item_([^=]+)=([^&]+)/if ($2 > 0) { $item_hash{$1} = $item_hash{$1} + $2; }/ge; foreach $item_key (keys %item_hash) { $items_quantities .= "&Asin.$item_key=$item_hash{$item_key}"; } $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?ShoppingCart=add&f=xml&t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH$items_quantities$session&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n $items_quantities - $MY_variables{error_msg} - $AWS_variables{ErrorMsg}\n\n"; if (!$items_quantities) { delete $MY_variables{error_msg}; $FORM{cart_action} = "clear"; shopping_cart(); return; } } if ($this_xml_url) { for (my $temp_i = 1; $temp_i <= 3; $temp_i++) { $MY_variables{error_msg} = ""; $xml_result = get_url($this_xml_url); if ($xml_result =~ /ShoppingCart/) { $MY_variables{error_msg} = ""; last; } } } my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); my $level_2 = process_hashes_of_arrays($level_1); my $level_3 = process_hashes_of_arrays($level_2); my $i = 0; if (!$session and $FORM{cart_action} eq "add") { print "Set-Cookie: apfcart=$AWS_variables{CartId},$AWS_variables{HMAC};\n"; } $MY_variables{total_cart_items} = $#{${$level_3}{Item}} + 1; my $whose_variables = "shopping_cart"; $MY_variables{continue_shopping} = qq[Continue Shopping]; $MY_variables{checkout} = qq[Buy from Amazon.com]; foreach my $single_item (@{${$level_3}{Item}}) { my (%temp_hash,$temp_hash1,$temp_hash2); push @{$temp_hash{Item}}, $single_item; $temp_hash1 = process_hashes_of_arrays(\%temp_hash); $temp_hash2 = process_hashes_of_arrays($temp_hash1); ($MY_variables{our_value} = $AWS_variables{OurPrice}) =~ s/(?:\$|£|,|USD )//g; $MY_variables{our_value_item_total} = $MY_variables{our_value} * $AWS_variables{Quantity}; $MY_variables{my_cart_item_price} = $money_symbol . (sprintf "%.2f", $MY_variables{our_value_item_total}); $MY_variables{cart_value_total} += $MY_variables{our_value_item_total}; $MY_variables{cart_price_total} = $money_symbol . (sprintf "%.2f", $MY_variables{cart_value_total}); $MY_variables{cart_qty_total} += $AWS_variables{Quantity}; $MY_variables{products_html} .= set_html($whose_variables,$i); $i++ } if (!$MY_variables{cart_qty_total} and !$MY_variables{error_msg} and !$AWS_variables{ErrorMsg}) { $MY_variables{products_html} = $language_text{cart_text2}; } } sub initialize_all_search_boxes { $MY_variables{header} = $language_text{searchbox_text3}; my ($searchbox_start,$searchbox_end,$searchbox_modes,$searchbox_string,$searchbox_item,$searchbox_id,$searchbox_offering_types,%searchbox_types,$searchbox_sort,$searchbox_name,$searchbox_pricerange); $searchbox_start = qq[
    ]; $searchbox_end = qq[\n
    ]; foreach my $key (sort keys %store_to_browse) { $searchbox_modes .= qq[]; } $searchbox_modes = qq[$language_text{searchbox_text13}: ]; $searchbox_string = qq[$language_text{searchbox_text7}: ]; $searchbox_item = qq[$language_text{searchbox_text5}: ]; $searchbox_id = qq[$language_text{searchbox_text12}: ]; $searchbox_pricerange = qq[$language_text{searchbox_text14}: ]; foreach my $key (sort keys %offering_type) { $searchbox_offering_types .= qq[]; } $searchbox_offering_types = qq[$language_text{thirdparty_text7} ]; %searchbox_types = ( "ASIN/ISBN" => ["","$searchbox_item"], $language_text{searchbox_text6} => ["","$searchbox_string","ActorSearch","dvd","sort"], $language_text{searchbox_text9} => ["","$searchbox_string","ArtistSearch","music","sort"], $language_text{searchbox_text10} => ["","$searchbox_string","AuthorSearch","books","sort"], $language_text{searchbox_text11} => ["","$searchbox_string\n$searchbox_id\n$searchbox_modes\n$searchbox_pricerange","","","sort"], $language_text{searchbox_text15} => ["","$searchbox_string","DirectorSearch","dvd","sort"], $language_text{searchbox_text16} => ["","$searchbox_string","ListManiaSearch"], $language_text{searchbox_text17} => ["","$searchbox_string\n$searchbox_modes","ManufacturerSearch","","sort"], $language_text{searchbox_text18} => ["
    Details","$searchbox_string","PowerSearch","books","sort"], $language_text{searchbox_text19} => ["","$searchbox_string","SimilaritySearch"], $language_text{searchbox_text20} => ["","$searchbox_item\n$searchbox_offering_types"], $language_text{searchbox_text21} => ["","$searchbox_string","ExchangeSearch"], $language_text{searchbox_text22} => ["","$searchbox_string","SellerSearch"], $language_text{searchbox_text23} => ["","$searchbox_item\n$searchbox_modes","UpcSearch"], $language_text{searchbox_text24} => ["","$searchbox_string","WishlistSearch"], ); my $lap="0"; $MY_variables{all_searchboxes} = qq[\n]; foreach my $key (sort keys %searchbox_types) { $lap++; if (${$searchbox_types{$key}}[2]) { ${$searchbox_types{$key}}[1] .= qq[\n]; } if (${$searchbox_types{$key}}[3]) { ${$searchbox_types{$key}}[1] .= qq[\n]; } if (${$searchbox_types{$key}}[4]) { my (@temp_sort_array,$searchbox_sort); if ( ${$searchbox_types{$key}}[3] and @{$sort_hash_by_mode{${$searchbox_types{$key}}[3]}} ) { @temp_sort_array = @{$sort_hash_by_mode{${$searchbox_types{$key}}[3]}}; } else { @temp_sort_array = @{$sort_hash_by_mode{"all"}}; } foreach my $key1 (keys %sort_hash) { if (grep { $_ eq $key1 } @temp_sort_array) { $searchbox_sort .= qq[]; } } ${$searchbox_types{$key}}[1] .= qq[]; } $searchbox_name = $key . "_searchbox"; ${$searchbox_name} = qq|$searchbox_start\n\n$MY_variables{form_options}\n${$searchbox_types{$key}}[1]\n$searchbox_end\n|; if ($lap == 1) { $MY_variables{all_searchboxes} .= "\n"; } $MY_variables{all_searchboxes} .= qq[]; if ($lap == 2) { $MY_variables{all_searchboxes} .= "\n\n"; $lap = 0; } } if ($lap > 0) { $MY_variables{all_searchboxes} .= "\n\n"; } $MY_variables{all_searchboxes} .= "
    $language_text{searchbox_text8}:
    $key${$searchbox_types{$key}}[0]
    \n${$searchbox_name}
    \n"; } sub comma_separate_list { my($temp_array_ref,$temp_list_start,$temp_search_type,$temp_list,$temp_search_string,$item) = @_; foreach $item (@{$temp_array_ref}) { if ($temp_list) { $temp_list .= ", "; } else { $temp_list = "$temp_list_start "; } ($temp_search_string = $item) =~ s/ /+/g; $temp_list .= qq[$item]; } return $temp_list; } sub initialize_buttons { my $value = $_[0]; my ($asin_buy_button,$temp_button); if (!$MY_variables{associate_id}) { $html = "

    No associate_id found!

    "; } if ($MY_variables{ThirdPartyProduct_buy_button}) { $asin_buy_button = $MY_variables{ThirdPartyProduct_buy_button}; if ($value eq "oneclick" or $value eq "cart") { $value = "buy"; } } else { $asin_buy_button = qq[]; } if ($value eq "wishlist") { $temp_button = qq[
    $asin_buy_button
    ]; } elsif ($value eq "wedding") { $temp_button = qq[
    $asin_buy_button
    ]; } elsif ($value eq "baby") { $temp_button = qq[
    $asin_buy_button
    ]; } elsif (!$MY_variables{ThirdPartyProduct_buy_button} and ($AWS_variables{Availability} =~ /(?:not available|discontinued|out of print|unable|jetzt gebraucht vorbestellen)/i or ($FORM{locale} eq "us" and $value eq "cart" and $AWS_variables{Availability} !~ /Usually ships|Not yet/))) { $MY_variables{my_availability} = qq[$language_text{availability_text2}
    ]; $temp_button = qq[
    ]; } else { if ($value eq "buy") { $temp_button = qq[
    $asin_buy_button
    ]; } if ($value eq "oneclick") { $temp_button = qq[ ]; } if ($value eq "cart") { $temp_button = qq[
    $MY_variables{form_options}
    ]; } if ($FORM{locale} eq "uk") { $temp_button = qq[form method="post" action="http://www.amazon.co.uk/exec/obidos/dt/assoc/handle-buy-box=$AWS_variables{Asin}" target="amazon">$asin_buy_button]; } if ($FORM{locale} eq "de") { $temp_button = qq[
    $asin_buy_button
    ]; } } return $temp_button; } sub get_extra_product_links { my $value = shift; my ($temp_asins,$temp_xml_result,@temp_xml_feed,$my_temp,$temp_cart,$cart_counter); $temp_asins = join(",", @{$value}); $temp_xml_result = get_url("http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&AsinSearch=$temp_asins&type=lite&f=xml&locale=$FORM{locale}","skip_ok"); push @temp_xml_feed, ($temp_xml_result =~ /]+)?>(.*?)<\/Details>/gsi); for my $ii (0 .. $#temp_xml_feed) { my ($temp_asin,$temp_product_name,$temp_our_price,$temp_availability,$row_color); @temp_xml_feed[$ii] =~ s/([^<]+)<\/Asin>/$temp_asin = $1/sie; @temp_xml_feed[$ii] =~ s/([^<]+)<\/ProductName>/$temp_product_name = $1/sie; @temp_xml_feed[$ii] =~ s/([^<]+)<\/OurPrice>/$temp_our_price = $1/sie; @temp_xml_feed[$ii] =~ s/([^<]+)<\/Availability>/$temp_availability = $1/sie; $my_temp .= qq[
  • $temp_product_name
  • \n]; if ($AWS_variables{Availability} =~ /Usually ships|Not yet/i) { if ($ii/2 == int($ii/2)) { $row_color = "apf_even_row"; } else { $row_color = "apf_odd_row"; } $temp_cart .= qq[
    $temp_our_price
    ]; } } return $my_temp, $temp_cart; } sub build_international_links { my $int_options = $see_url_options . $url_options; my %international_sites = ( "us" => $language_text{locale_text2}, "uk" => $language_text{locale_text3}, "de" => $language_text{locale_text4} ); if ($int_options =~ /search_type=(?:ListManiaSearch|SimilaritySearch|WishlistSearch|SellerSearch)/) { $FORM{mode} = ""; $int_options = $url_options; } $int_options =~ s/search_type=(?:ThirdPartyNew|Used|Collectible|Refurbished)/search_type=AsinSearch/; $int_options =~ s/search_type=AsinSearch/input_string=$AWS_variables{ProductName}/; delete($international_sites{$FORM{locale}}); foreach my $int_key (keys %international_sites) { my $int_mode = ${$all_store_to_browse{$int_key}}{$lookup_store{$FORM{mode}}}; # i dare you to figure that out :P if ($FORM{mode} eq "blended") { $int_mode = $FORM{mode}; } if (!$int_mode and $FORM{mode}) { my $temp_mode = $FORM{mode}; $FORM{mode} = ""; $int_options = $url_options; $FORM{mode} = $temp_mode; } if ($MY_variables{international_links}) { $MY_variables{international_links} .= ", "; } else { $MY_variables{international_links} = "$language_text{locale_text1} "; } $int_options =~ s/(?:&locale=[^&]+|&node=[^&]+)//g; $MY_variables{international_links} .= qq[$international_sites{$int_key}]; } } sub build_featured_product { my $featured_input = shift; my ($featured_asin); if ($featured_input =~ ",") { @featured_products = split(/,/,$featured_input); $featured_input = "random"; } if ($featured_input =~ /browse\+(\d+)\+mode\+(.+)/) { my $query = "BrowseNodeSearch=$1&mode=$2&type=lite&page=$FORM{page_num}"; my $this_xml_url="http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$FORM{sort_type}&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url); my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); my $featured_asin_xml = ${${$level_1}{Details}}[rand @{${$level_1}{Details}}]; # now this next line is an impressive piece of poo ${${$level_1}{Details}}[rand @{${$level_1}{Details}}] =~ s/([^<]+)<\/Asin>/$featured_asin = $1/e; } elsif ($featured_input eq "random") { if (@featured_products) { $featured_asin = $featured_products[rand @featured_products]; } else { return; } } else { $featured_asin = $featured_input; } my $this_xml_url = "http://$amazon_server.amazon.com/onca/xml3?t=$MY_variables{associate_id}&dev-t=D1KQJBNTALRLQH&AsinSearch=$featured_asin&type=lite&f=xml&locale=$FORM{locale}"; $debug .= "xml_url=$this_xml_url\n"; my $xml_result = get_url($this_xml_url,"skip_ok"); if (!$xml_result) { return; } my $level_1 = parse_xml_into_hashes_of_arrays($xml_result); my $level_2 = process_hashes_of_arrays($level_1); $MY_variables{featured_ProductName} = ${$level_2}{ProductName}[0]; $MY_variables{my_featured_item_url} = "$MY_variables{script_name}?item_id=${$level_2}{Asin}[0]&search_type=AsinSearch$url_options"; $MY_variables{featured_ImageUrlSmall} = ${$level_2}{ImageUrlSmall}[0]; $MY_variables{featured_OurPrice} = ${$level_2}{OurPrice}[0]; return set_html("featured_product"); } sub load_browse_table { my ($input1, $input2, $input3) = @_; my ($page_listing); my $i = 0; $menu_length = keys(%{$input1}); foreach my $key (sort keys %{$input1}) { $MY_variables{browse_menu_url} = qq[$MY_variables{script_name}?$input2${$input1}{$key}$url_options]; $MY_variables{browse_menu_name} = $key; if ($input3 eq "nav_menu") { $page_listing .= set_html("nav_menu",$i); } else { $page_listing .= set_html("browse_menu",$i); } $i++; } return $page_listing; } sub apf_commands { my ($command_string, $lap, $whose_variables) = @_; $lap = $lap + 1; my (%COMMAND, $command_name, $command_value); $command_string =~ //s; my $command_commands = $1; my $command_html = $2; for my $command_pair (split(/&/, $command_commands)) { ($command_name, $command_value) = split(/=/, $command_pair); if ($command_value eq "last") { if ($whose_variables eq "sellerprofile") { $command_value = $sellerprofile_max; } elsif ($whose_variables eq "shopping_cart") { $command_value = $MY_variables{total_cart_items}; } elsif ($whose_variables eq "products") { $command_value = $details_max; } elsif ($whose_variables =~ "_menu") { $command_value = $menu_length; } else { $command_value = $FORM{max_results}; } } $COMMAND{$command_name} = $command_value; } if ($COMMAND{apf_repeat} and !$COMMAND{apf_start}) { $COMMAND{apf_start} = 1; } if ($COMMAND{apf_start}) { if ($COMMAND{apf_start} == $lap) { return $command_html; } if ($COMMAND{apf_repeat}) { my $test_lap = ($lap - $COMMAND{apf_start})/$COMMAND{apf_repeat}; if ($test_lap == int $test_lap) { return $command_html; } } } if ($COMMAND{apf_end} == $lap) { return $command_html; } elsif ($COMMAND{apf_include}) { if ($COMMAND{apf_include} eq "nav_menu") { if ($FORM{mode} and !$nav_menu_type) { $MY_variables{nav_menu_html} = load_browse_table(\%{$FORM{mode}}, "mode=$FORM{mode}&node=", "nav_menu"); } elsif ($nav_menu_type ne "none") { $MY_variables{nav_menu_html} = load_browse_table(\%store_to_browse, "mode=", "nav_menu"); } if ($MY_variables{nav_menu_html}) { return $command_html; } } else { my $include_variable; open(FILEHANDLE,"<$COMMAND{apf_include}"); while () { $include_variable = $include_variable . $_; } close (FILEHANDLE); return $include_variable; } } elsif ($COMMAND{apf_featured_product}) { my $my_featured_product = build_featured_product($COMMAND{apf_featured_product}); if ($my_featured_product) { return $my_featured_product; } } elsif ($COMMAND{apf_show_vars}) { my $temp_html; if ($COMMAND{apf_show_vars} ne "AWS") { $temp_html = "
    MY_variables:

    "; foreach my $key (sort keys %MY_variables) { (my $encoded = $MY_variables{$key}) =~ s/%%$key%% => $encoded

    "; } $temp_html .= "

    "; } if ($COMMAND{apf_show_vars} ne "MY") { $temp_html .= "
    AWS_variables:

    "; foreach my $key (sort keys %AWS_variables) { (my $encoded = $AWS_variables{$key}) =~ s/%%$key%% => $encoded

    "; } $temp_html .= "

    "; } $MY_variables{products_html} .= $temp_html . "

    "; } return; } sub set_html { my ($which, $lap) = @_; my $temp_result; if ($template_html{$which}) { $temp_result = $template_html{$which}; } else { if ($which eq "page") { $temp_result = qq[ %%store%% : %%subject%%

    %%header%%

    %%in_association%% %%search_box%%
     %%shopping_cart_link%% 

    %%sort_box%%
    %%products_html%%
    %%see_prev%%
    %%see_next%%
    %%see_total%%
    %%see_index%%
     

    ]; } elsif ($which eq "products") { $temp_result = qq[
    %%result_number%%.
    %%store%% : %%ProductName%%
    %%my_prices%%
    %%ProductName%%
    %%my_artists%%
    %%ReleaseDate%%

    ]; } elsif ($which eq "item") { $temp_result = qq[
    %%my_artists%%

    %%store%% : %%ProductName%%
    %%see_larger_image_text1%%

    %%my_prices%%
    %%my_used%% %%my_collectible%% %%my_thirdpartynew%% %%my_refurbished%%

    %%my_availability%%

    %%shopping_cart_button%%

    %%my_descriptors%%
    %%my_features%%


    %%accessories_cartadd%% %%similar_products_cartadd%% %%my_tracks%%

    $MY_variables{product_description}

    %%customer_reviews_text1%%
    %%average_rating_text1%% %%my_avg_rating_display%%

    %%my_shortened_comments%% ]; } elsif ($which eq "larger_image") { $temp_result = qq[
    large image
    %%see_back%%
    ]; } elsif ($which eq "sellersearch") { $temp_result = qq[
    %%my_marketplace1%% %%ExchangePrice%%
    %%buy_button%%
    %%ExchangeTitle%%
    %%ExchangeCondition%%
    %%thirdparty_text6%% %%ExchangeQuantity%%; %%thirdparty_text7%% %%ExchangeOfferingType%%; %%thirdparty_text3%% %%ExchangeConditionType%%
    %%availability_text1%% %%ExchangeAvailability%%; %%thirdparty_text4%% %%ExchangeSellerState%%, %%ExchangeSellerCountry%%
    %%thirdparty_text8%% %%ExchangeEndDate%%

    ]; } elsif ($which eq "sellerprofile") { $temp_result = qq[
    %%my_comments_text1%% %%FeedbackRating%%
    %%thirdparty_text11%% %%FeedbackDate%%
    %%thirdparty_text5%% %%FeedbackComments%%
    ]; } elsif ($which eq "thirdparty_products") { $temp_result = qq[
    %%my_marketplace1%% %%OfferingPrice%%
    %%buy_button%%
    %%thirdparty_text1%% %%SellerNickname%%, %%my_comments_text1%% %%SellerRating%%
    %%thirdparty_text2%% %%Condition%%; %%thirdparty_text3%% %%ConditionType%%
    %%availability_text1%% %%ExchangeAvailability%%; %%thirdparty_text4%% %%SellerState%%, %%SellerCountry%%
    %%thirdparty_text5%% %%ShipComments%%

    ]; } elsif ($which eq "browse_menu") { $temp_result = qq[ %%browse_menu_name%% ]; } elsif ($which eq "nav_menu") { $temp_result = qq[ %%browse_menu_name%% ]; } elsif ($which eq "featured_product") { $temp_result = qq[
    Featured Product
    %%featured_ProductName%%
    %%featured_ProductName%%

    %%featured_OurPrice%%
    ]; } elsif ($which eq "AllSearches") { $temp_result = qq[ %%all_searchboxes%% ]; } elsif ($which eq "power_search_info") { $temp_result = qq[ A power search is used to retrieve book information using a complex query.

    The syntax for a power search is shown below: You can use the following properties of a book in your search: You can use the words and, or, and not to link different parts of a book description. You can also group properties together using parentheses if that seems necessary to convey the precise meaning of your description.

    Power Search allows searching against a variety of fields. You can use any combination of the following keywords to match against specific product fields: You can combine them with and, or, and not, and you can group them with parentheses.
    ]; } elsif ($which eq "shopping_cart") { $temp_result = qq[
    %%my_cart_item_price%%

    %%ProductName%%

    ]; } elsif ($which eq "blended") { $temp_result = qq[
    %%blended_mode%%: See all %%blended_mode_totalresults%% results...
    ]; } elsif ($which eq "customer_reviews") { $temp_result = qq[ %%my_comments%%

    %%see_back%%
    ]; } } $MY_variables{result_number} = $lap + 1 + (($FORM{page_num} - 1) * 10); $temp_result =~ s/()/apf_commands($1,$lap,$which);/egs; $temp_result =~ s/%%(\w+)%%/if ($AWS_variables{$1}) { $AWS_variables{$1}; } elsif ($MY_variables{$1}) { $MY_variables{$1}; } else { $language_text{$1}; }/ge; if ($which eq "item" and $temp_result =~ /$language_text{button_text10}/ and $temp_result =~ /$language_text{cart_text4}/) { $temp_result =~ s/"$language_text{button_text10}"\s\/><\/form>/"$language_text{button_text10}" \/>/; $temp_result =~ s/(]+>)//; $temp_result = $1 . $temp_result . qq[\n]; } return $temp_result; }