#!/usr/bin/perl # version 2.021120a, coded by MrRat - http://www.mrrat.com, GPL licensed - http://www.opensource.org/licenses/gpl-license.html # 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 775). # Put your Amazon affiliate id in the next line if you have one @associate_ids = ("ref=nosim/ASSOCIATEID"); # basic options: # set the default mode # modes are: books, magazines, music, classical, vhs, dvd, toys, baby, videogames, electronics, software, universal, garden, kitchen, photo, pc_hardware # if $mode = "none" then links to the Bestsellers for all modes will be displayed $mode = "none"; # set the default search subject # if $search = "none" then the Bestsellers will be displayed $search = "none"; # set the default search type $sort_type = "+salesrank"; # advanced options: # before messing with these you'll want to read the FAQ at http://www.mrrat.com/amazon-products-feed-faq.html # list of featured products for random selection with apf_featured_product @featured_products = ("055358135X","0764112082","076361873X","B00005R24I","B0000009S3","B00001WRLX","B00001ZUMD"); # cache settings - file location and number of requests to cache $use_cache = "yes"; $cache_file = "/home/virtual/site1/fst/var/www/cgi-bin/bookCache/apf_xml_cache"; $cache_max_size = "500"; # templates are comma separated lists, and if blank or non-existent will use embedded HTML @page_templates = ("page_1.template", "../directory/aws/sample_page_apf.template", "page_3.template", "page_4.template", "../directory/aws/sample_page_5.template"); @products_templates = ("products_1.template", "../directory/aws/sample_products.template", "products_3.template", "products_4.template"); @item_templates = ("item_1.template", "../directory/aws/sample_item.template"); @larger_image_templates = ("image_1.template", "../directory/aws/sample_image.template"); @sellersearch_templates = ("sellersearch_1.template", "../directory/aws/sample_sellersearch.template"); @sellerprofile_templates = ("sellerprofile_1.template", "../directory/aws/sample_sellerprofile.template"); @thirdparty_products_templates = ("thirdpartyproducts_1.template", "../directory/aws/sample_thirdpartyproducts.template"); @browse_menu_templates = ("browse_menu_1.template", "../directory/aws/sample_browsemenu.template"); @nav_menu_templates = ("nav_menu_1.template", "../directory/aws/sample_navmenu.template"); @featured_product_templates = ("featured_product_1.template", "../directory/aws/sample_featuredproduct.template","","","../directory/aws/sample_featuredproduct_5.template"); # which set of templates and associate_id to use $templates_number = 1; # location of optional language files - comma separated, if blank or non-existent will use embedded English @language_templates = ("apf_missing.language", "apf_dutch.language"); # which language file to use $language_number = 1; # categories to exclude from browsing # @exclusions = ( "Category to exclude here", "and another here. etc." ); # maximum results per page to display - Amazon usually only sends back 10 results per page $max_results = 30; # END OF OPTIONS # don't monkey with anything below here unless you know PERL if ($ENV{SCRIPT_NAME} =~ /test.cgi/) { $debug_state = "on"; $cache_file = "apf_xml_cache.test"; } # setup initial variables $page_num = 1; get_url_input(); if ($search_type eq "FeaturedProducts") { $item_id = join(",", @featured_products); } load_language(); intialize_hashes(); calculate_initial_variables(); build_search_box(); load_templates(); # build the products_html if ( ($mode and ($search or $browse_id)) or $item_id =~ /,/ or $search_type =~ /(?:ThirdPartyNew|Used|Collectible|Refurbished|ListManiaSearch|SimilaritySearch|WishlistSearch)/) { # get products $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$sort_type"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); assign_variables("products"); } elsif ($search_type eq "AsinSearch") { # get item by ASIN/ISBN $this_xml_url = "http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&AsinSearch=$item_id&type=heavy&f=xml"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); assign_variables("item"); $store = $Catalog; $subject = $ProductName; } elsif ($search_type eq "UpcSearch") { # get item by UPC $this_xml_url = "http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&UpcSearch=$item_id&mode=music&type=heavy&f=xml"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); assign_variables("item"); $store = $Catalog; $subject = $ProductName; } elsif ($search_type eq "image") { # get large image $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&AsinSearch=$item_id&type=lite&f=xml"; $xml_result = get_url($this_xml_url); $xml_result =~ s/<([^>]+)>([^<]+)<\/\1>/${$1} = $2;/gsie; $store = $Catalog; $subject = $ProductName; $products_html .= set_html("larger_image"); } elsif ($search_type eq "SellerSearch") { # get SellerProfile $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&SellerProfile=$search&type=lite&f=xml"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); assign_variables("sellerprofile"); # get SellerSearch $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$sort_type"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); assign_variables("sellersearch"); } elsif ($search_type eq "ExchangeSearch") { # get ExchangeSearch $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$sort_type"; $exchange_xml_result = get_url($this_xml_url); $exchange_xml_result =~ s/([^<]+)<\/ExchangeSellerId>/$ExchangeSellerId = $1/e; # get SellerProfile $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&SellerProfile=$ExchangeSellerId&type=lite&f=xml"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); assign_variables("sellerprofile"); # get ExchangeSearch $xml_result = $exchange_xml_result; parse_xml_into_hashes_of_arrays(); assign_variables("sellersearch"); } elsif ($search_type eq "AllSearches") { assign_variables("AllSearches"); } elsif ($search_type eq "power_search_info") { $store = "PowerSearch"; $subject = "Details"; $products_html .= set_html("power_search_info"); } elsif ($mode) { # display the categories for the mode $nav_menu_type = "mode"; $subject = $header_text5; $header = qq[$header_text1 > $store
]; $products_html = load_browse_table(\%{$mode}, "input_mode=$mode&input_id="); } else { # display the modes $nav_menu_type = "none"; $subject = $header_text1; $store = $header_text4; $products_html = load_browse_table(\%store_to_browse, "input_mode="); } # build the page if ($search_type eq "SimilaritySearch") { $header = qq[$my_similar_products_text1 $button_text4]; } elsif ($search_type eq "ListManiaSearch") { $header = "$level_1{ListName}[0]"; } elsif (!$header) { $header = qq[$store : $subject]; } $xml_result =~ /([^<]+)<\/ErrorMsg>/si; if ($1) { $products_html .= qq[$1

]; } if ($debug_state eq "on") { $debug_html = "xml_url = $this_xml_url\n$debug"; } $html .= set_html("page"); $html .= qq[ Footer Script By Mr. Rat ]; # 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 { for $form_pair (split(/&/, $ENV{QUERY_STRING})) { $form_pair =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $form_pair =~ s/[^\w|\d|\=|\,|\(|\)|\-|\:]/ /g; ($form_name, $form_value) = split(/=/, $form_pair); if ($form_name eq $form_value) { $form_value = ""; } $FORM{$form_name} = $form_value; } foreach $item (@ARGV) { ($form_name, $form_value) = split(/=/, $item); $FORM{$form_name} = $form_value; } if (%FORM) { $search = $FORM{input_string}; if ($FORM{input_mode} or $FORM{input_id}) { $mode = $FORM{input_mode}; } if ($FORM{input_templates}) { $templates_number = $FORM{input_templates}; } if ($FORM{input_link_templates}) { $link_templates_number = $FORM{input_link_templates}; } if ($FORM{input_sort}) { ($sort_type = $FORM{input_sort}) =~ s/\s/+/g; } if ($FORM{input_id}) { $browse_id = $FORM{input_id}; } if ($FORM{input_max}) { $max_results = $FORM{input_max}; } if ($FORM{input_item}) { $item_id = $FORM{input_item}; } if ($FORM{input_page}) { $page_num = $FORM{input_page}; } if ($FORM{input_language}) { $language_number = $FORM{input_language}; } if ($FORM{input_search_type}) { $search_type = $FORM{input_search_type}; } } } sub load_language { # start default language $header_text1 = "Bestsellers"; $header_text2 = "Items"; $header_text3 = "List"; $header_text4 = "All Products"; $header_text5 = "Categories"; $my_artists_text1 = "by:"; $my_artists_text2 = "starring:"; $my_artists_text3 = "from:"; $my_artists_text4 = "directed by:"; $my_prices_text1 = "List Price:"; $my_prices_text2 = "Amazon.com's Price:"; $my_prices_text3 = "You Save:"; $my_prices_text4 = "Amazon.com prices subject to change."; $my_prices_text5 = "price not available"; $button_text1 = "Buy from Amazon.com"; $button_text2 = "Add to Amazon.com Wishlist"; $button_text3 = "Add to Amazon.com Wedding Registry"; $button_text4 = "Search"; $my_marketplace1 = "Price:"; $my_marketplace2 = "Used"; $my_marketplace3 = "Collectible"; $my_marketplace4 = "Third Party New"; $my_marketplace5 = "Refurbished"; $my_features_text1 = "Features:"; $my_similar_products_text1 = "Similar Items:"; $my_accessories_text1 = "Accessories:"; $my_comments_text1 = "Rating:"; $my_descriptors_text1 = "Release Date:"; $my_descriptors_text2 = "Theatrical Date:"; $my_descriptors_text3 = "Media:"; $my_descriptors_text4 = "Number of Media:"; $my_descriptors_text5 = "MPAA Rating:"; $my_descriptors_text6 = "Platform:"; $my_descriptors_text7 = "ESRB Rating:"; $my_descriptors_text8 = "Age Group:"; $my_descriptors_text9 = "Sales Rank:"; $my_descriptors_text10 = "Encoding:"; $my_descriptors_text11 = "Tracks:"; $my_descriptors_text12 = "Reading Level:"; $my_browse_list_text1 = "Browse:"; $see_text1 = "\"More"; $see_text2 = "\"Previous\""; $see_text3 = "\"Previous\""; $see_text4 = "page"; $see_text5 = "of"; $see_text6 = "see more"; $association_text1 = "In association with Amazon.com"; $availability_text1 = "Availability:"; $see_larger_image_text1 = "See Larger Image"; $customer_reviews_text1 = "Customer Reviews"; $average_rating_text1 = "Average Rating: "; $average_rating_text2 = "none"; $similar_text1 = "Featured Listmania! List"; $thirdparty_text1 = "Seller:"; $thirdparty_text2 = "Condition:"; $thirdparty_text3 = "Condition Type:"; $thirdparty_text4 = "From:"; $thirdparty_text5 = "Comments:"; $thirdparty_text6 = "Quantity:"; $thirdparty_text7 = "Offering Type:"; $thirdparty_text8 = "End Date:"; $thirdparty_text9 = "Total Feedback:"; $thirdparty_text10 = "Cancelled Auctions:"; $thirdparty_text11 = "Date:"; # end default language my $temp_num = $language_number - 1; if ( -e $language_templates[$temp_num] and -s $language_templates[$temp_num] ) { require $language_templates[$temp_num]; } } sub intialize_hashes { %baby = ( "General" => 540988, Outlet => 735502, "Activity" => 542460, "Bath & Potty" => 541586, "Feeding" => 541564, "Gear" => 541558, "Health & Safety" => 541580, "Layette" => 738468, "Nursery" => 541572 ); %books = ( "General" => 1000, Outlet => 733804, "Arts & Photography" => 1, "Biographies & Memoirs" => 2, "Business & Investing" => 3, "Children's Books" => 4, "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 = ( "General" => 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 = ( "General" => 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 ); %electronics = ( "General" => 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 ); %garden = ( "General" => 468250, Outlet => 734346, "Backyard Birding" => 553632, "Gifts" => 553648, "Grills & Fryers" => 553760, "Heating & Lighting" => 553778, "Leisure & Fitness" => 1063918, "Outdoor Décor" => 553788, "Patio Furniture" => 553824, "Pest Control" => 553844 ); %kitchen = ( "General" => 491864, Outlet => 734070, "Baking" => 289668, "Bar Tools & Glasses" => 289728, "Coffee, Tea & Espresso" => 289742, "Cookware" => 289814, "Cutlery" => 289851, "Housewares" => 510080, "Small Appliances" => 289913, "Tableware" => 289891 ); %magazines = ( "General" => 599872, Outlet => 700580, "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 ); %music = ( "General" => 301668, Outlet => 734368, "Alternative Rock" => 30, "Blues" => 31, "Broadway & Vocalists" => 265640, "Children's Music" => 173425, "Christian & Gospel" => 173429, "Classical" => 85, "Classic Rock" => 67204, "Country" => 16, "Dance & DJ" => 7, "Folk" => 32, "Hard Rock & Metal" => 67207, "International" => 33, "Latin Music" => 289122, "Miscellaneous" => 35, "New Age" => 36, "Opera & Vocal" => 84, "Pop" => 37, "Rap & Hip-Hop" => 38, "R&B" => 39, "Rock" => 40, "Soundtracks" => 42 ); %pc_hardware = ( "General" => 542030, "Desktops" => 565098, "Notebooks" => 565108 ); %photo = ( "General" => 508048, Outlet => 733952, "Accessories" => 172435, "Binoculars" => 499320, "Camcorders" => 172421, "Film Cameras" => 499106, "Frames & Albums" => 499176, "Printers & Scanners" => 499328, "Projectors" => 525462, "Surveillance Systems" => 524136 ); %software = ( "General" => 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 = ( "General" => 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 ); %universal = ( "General" => 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 ); %vhs = ( "General" => 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 ); %videogames = ( "General" => 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 ); # %target = ( "Boys' (Sizes 4-16)" => 712636, "Fleece" => 1192178, "Girls' (Sizes 4-16)" => 712638, "Infant Boys'" => 1084382, "Infant Girls'" => 1084250, "Maternity" => 1084252, "Men's" => 712640, "Outerwear" => 1192180, "School Uniforms" => 1084254, "Toddler Boys'" => 1084256, "Toddler Girls'" => 1084258, "Women's" => 712642, "Women's Fitness + Yoga" => 1192120, "Women's Leather, Suede + Shearling" => 1192206, "Women's Plus Sizes" => 1084260, "Diamond Jewelry" => 712736, "Gold Jewelry" => 712738, "Pearl Jewelry" => 712740, "Precious Stones" => 720378, "Silver Jewelry" => 712742, "Jewelry Cleaning + Storage" => 712746, "Handbags" => 712750, "Hats + Gloves" => 725820, "Shoes + Belts" => 712754, "Watches" => 712756 ); # %wireless_phones = ( "General" => 301185, "All Phones" => 1067706, "Flip" => 465604, "PDA Cell Phones" => 864136, "Prepaid" => 1067700, "Ultra Compact" => 408238, "Value" => 408236, "Web-Enabled" => 408242 ); %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" ); %catalog_to_mode = ( "Baby Product" => "baby", "Book" => "books", "DVD" => "dvd", "Electronics" => "electronics", "Home Improvement" => "universal", "Kitchen" => "kitchen", "Lawn & Patio" => "garden", "Magazine" => "magazines", "Music" => "music", "Personal Computer" => "pc_hardware", "Software" => "software", "Toy" => "toys", "Video" => "vhs", "Video Games" => "videogames" ); %sort_hash = ( "+pmrank" => "Featured Items", "+salesrank" => "Bestselling", "+reviewrank" => "Average Customer Review", "+pricerank" => "Price (Low to High)", "+inverse-pricerank" => "Price (High to Low)", "+daterank" => "Publication Date", "+titlerank" => "Alphabetical (A-Z)", "-titlerank" => "Alphabetical (Z-A)", "+manufactrank" => "Manufacturer (A-Z)", "-manufactrank" => "Manufacturer (Z-A)", "+artistrank" => "Artist Name", "+orig-rel-date" => "Original Release Date" ); %sort_hash_by_mode = ( "all" => ["+titlerank","+salesrank","+pmrank"], "books" => ["+pmrank","+salesrank","+reviewrank","+pricerank","+inverse-pricerank","+daterank","+titlerank","-titlerank"], "software" => ["+pmrank","+salesrank","Alphabetical","+inverse-pricerank","+pricerank"], "garden" => ["+pmrank","+salesrank","+titlerank","-titlerank","+manufactrank","-manufactrank","+pricerank","+inverse-pricerank"], "universal" => ["+pmrank","+salesrank","+titlerank","-titlerank","+manufactrank","-manufactrank","+pricerank","+inverse-pricerank"], "photo" => ["+pmrank","+salesrank","+titlerank","-titlerank"], "pc_hardware" => ["+pmrank","+salesrank","+titlerank","-titlerank"], "videogames" => ["+pmrank","+salesrank","+pricerank","+inverse-pricerank","+titlerank"], "music" => ["+pmrank","+salesrank","+artistrank","+orig-rel-date","+titlerank"], "classical" => ["+pmrank","+salesrank","+artistrank","+orig-rel-date","+titlerank"], "office_products" => ["+pmrank","+salesrank","+reviewrank","+pricerank","+inverse-pricerank","+titlerank","-titlerank"], "electronics" => ["+pmrank","+salesrank","+reviewrank","+titlerank"], "kitchen" => ["+pmrank","+salesrank","+titlerank","-titlerank","+manufactrank","-manufactrank","+pricerank","+inverse-pricerank"], ); %offering_type = ( new => "ThirdPartyNew", used => "Used", collectible => "Collectible", refurbished => "Refurbished" ); %marketplace_text_hash = ( Used => $my_marketplace2, Collectible => $my_marketplace3, ThirdPartyNew => $my_marketplace4, Refurbished => $my_marketplace5 ); } sub calculate_initial_variables { if (@associate_ids[$templates_number-1]) { $associate_id = @associate_ids[$templates_number-1]; } else { $associate_id = @associate_ids[0]; } if ($mode eq "none") { $mode = ""; } if ($search eq "none") { $search = ""; } if (!$link_templates_number) { $link_templates_number = $templates_number; } $show_variables = qq[Amazon variables:
\n]; %lookup_store = reverse %store_to_browse; $store = $lookup_store{$mode}; ($url_mode = $mode) =~ s/_/-/; $see_back = qq[$see_text3]; $url_options = qq[input_templates=$link_templates_number&input_language=$language_number&input_sort=$sort_type&input_max=$max_results]; if ($browse_id) { # $nav_menu_type = "browse"; $query = "BrowseNodeSearch=" . $browse_id . "&mode=$url_mode&type=lite&page=$page_num"; %lookup_browse_id = reverse %{$mode}; $subject = $lookup_browse_id{$browse_id}; $header = qq[$header_text1 > $store > $subject
]; } elsif ($search) { if ($search_type =~ /(?:SimilaritySearch|ListManiaSearch|SellerProfile|SellerSearch|WishlistSearch|ExchangeSearch)/) { $find_string = "input_search_type=" . ($store = $search_type); $subject = $search; if ($search_type eq SellerSearch) { $query = "SellerSearch=$search&type=heavy&offerstatus=open&page=$page_num"; } else { $query = "$search_type=$search&type=lite&page=$page_num"; } } else { if ($search_type =~ /(AuthorSearch|ArtistSearch|ActorSearch|ManufacturerSearch|DirectorSearch|PowerSearch)/) { $find_string = "input_search_type=" . $search_type; $query = "$search_type="; } else { $query = "KeywordSearch="; } $search =~ s/\s/\+/g; ($search_url = $search) =~ s/\+/%20/; ($subject = $search) =~ s/\+/ /g; $query .= $search_url . "&mode=$url_mode&type=lite&page=$page_num"; } } elsif ($search_type =~ /(ThirdPartyNew|Used|Collectible|Refurbished)/) { $query = "AsinSearch=$item_id&type=heavy&offer=$search_type&offerpage=$page_num"; $my_marketplace_text = $marketplace_text_hash{$search_type}; } elsif ($item_id =~ /,/) { $store = $header_text2; $subject = $header_text3; $query = "AsinSearch=" . $item_id . "&type=lite"; } } sub build_search_box { $search_box_allsearches = qq[
]; $search_box = qq[
$search_box_allsearches
]; } sub load_templates { my $temp_num = $templates_number - 1; my @temp_array = (page, products, item, larger_image, sellersearch, sellerprofile, thirdparty_products, browse_menu, nav_menu, featured_product); foreach $value (@temp_array) { my $file = $value . "_templates"; if ( -e ${$file}[$temp_num] and -s ${$file}[$temp_num] ) { my $variable = $value . "_template_html"; open(FILEHANDLE,"<${$file}[$temp_num]"); while () { ${$variable} = ${$variable} . $_; } close (FILEHANDLE); } } } sub get_url { my $value = $_[0]; my $skip = $_[1]; my $xml_result; my $cache_expire = time() - 3600; my $cache_time = $value . "_time"; if ($use_cache eq "yes") { 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)'; $dbm_error = $@; if ( keys(%xml_cache) > $cache_max_size) { %xml_cache = (); } } } if ($xml_cache{$value} and $xml_cache{$cache_time} > $cache_expire) { $xml_result = $xml_cache{$value}; $db_size = keys(%xml_cache); if ($use_cache eq "yes" and !$dbm_error) { untie %xml_cache; } $debug .= "cache status = cached request size " . length($xml_result) . ", total requests cached " . $db_size . "\n"; } else { if ($use_cache eq "yes" and !$dbm_error) { 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; } $ua->timeout(30); $xml_result = get($value); if (!$xml_result and $skip ne "skip_ok") { print "Content-type: text/html\n\n"; print "Sorry, we are currently unable to process your request in a timely manner.
Please try again later.\n"; exit; } if ($use_cache eq "yes" and !$dbm_error) { eval 'tie(%xml_cache,"DB_File",$cache_file)'; $dbm_error = $@; } $xml_cache{$value} = $xml_result; $xml_cache{$cache_time} = time; if ($use_cache eq "yes" and !$dbm_error) { untie %xml_cache; } $debug .= "cache status = not cached request size " . length($xml_result) . "\n"; } return $xml_result; } sub parse_xml_into_hashes_of_arrays { $xml_result =~ s/<([^>]+?)(?:\s[^>]+)?>(.*?)<\/\1>/push @{$level_0{$1}}, $2;/gsie; %level_1 = process_hashes_of_arrays(%level_0); } sub process_hashes_of_arrays { my (%entry_hash,%exit_hash) = @_; for $key (keys %entry_hash) { if (!${$entry_hash{$key}}[1]) { ${$key} = ${$entry_hash{$key}}[0]; } #$show_variables .= "%%$key%% = ${$entry_hash{$key}}[0]
\n"; foreach $item (@{$entry_hash{$key}}) { $item =~ s/<([^>]+?)(?:\s[^>]+)?>(.*?)<\/\1>/push @{$exit_hash{$1}}, $2;/gsie; } } return %exit_hash; } sub assign_variables { $whose_variables = $_[0]; my $i = 0; foreach $item (@{$level_1{Details}}) { my %temp_hash; $ListPrice = ""; push @{$temp_hash{Details}}, $item; my %level_2 = process_hashes_of_arrays(%temp_hash); %level_3 = process_hashes_of_arrays(%level_2); $our_price = ""; $list_price = ""; $discount = ""; $our_value = ""; $list_value = ""; if ($catalog_to_mode{$Catalog}) { $mode = $catalog_to_mode{$Catalog}; } # start my_artists $my_artists = ""; if ($mode =~ /^(books)$/i) { $my_artists = comma_separate_list($level_3{Author},$my_artists_text1,"AuthorSearch"); } elsif ($mode =~ /^(music|classical)$/i) { $my_artists = comma_separate_list($level_3{Artist},$my_artists_text1,"ArtistSearch"); } elsif ($mode =~ /^(dvd|vhs|video)$/i) { $my_artists = comma_separate_list($level_3{Actor},$my_artists_text2,"ActorSearch"); if ($level_3{Director}) { $my_artists .= "
" . comma_separate_list($level_3{Director},$my_artists_text4,"DirectorSearch"); } } if ( (!$my_artists) and ($Manufacturer) ) { if ($mode =~ /^(electronics|kitchen|videogames|software|photo|pc_hardware)$/) { ($search_manufacturer_string = $Manufacturer) =~ s/ /+/g; $my_artists = qq[$my_artists_text3 $Manufacturer]; } else { $my_artists = qq[$my_artists_text3 $Manufacturer]; } } # end my_artists # start my_comments foreach $item (@{$level_3{CustomerReview}}) { my (%temp_hash,%temp_hash1,$temp_rounded_rating,$temp_rating_display); push @{$temp_hash{CustomerReview}}, $item; %temp_hash1 = process_hashes_of_arrays(%temp_hash); $temp_hash1{Comment}[0] =~ s/</= .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 (!$temp_hash1{Rating}[0]) { $temp_rating_display = "none"; } if ($my_comments) { $my_comments .= qq[


\n]; } $my_comments .= qq[$my_comments_text1 $temp_rating_display - $temp_hash1{Summary}[0]
\n$temp_hash1{Comment}[0]
\n]; } # end my_comments # start my_features if ($level_3{Feature}) { $my_features = qq[$my_features_text1
\n
  • ]; $my_features .= join("
    \n
  • ", @{$level_3{Feature}}); $my_features .= qq[

    \n]; } # end my_features # start my_browse_list if ($level_3{BrowseNode}) { foreach $key1 (keys %store_to_browse) { foreach $key2 (keys %{$store_to_browse{$key1}}) { foreach $item (@{$level_3{BrowseNode}}) { my (%temp_hash,%temp_hash1,%temp_hash2); push @{$temp_hash{BrowseNode}}, $item; %temp_hash1 = process_hashes_of_arrays(%temp_hash); $lc_browse_name = lc $temp_hash1{BrowseName}[0]; $lc_key2 = lc $key2; next if $lc_browse_name eq "general"; if ($lc_browse_name eq lc $key2) { if ($my_temp_browse_list) { $my_temp_browse_list .= qq[, $key1:$temp_hash1{BrowseName}[0]]; } else { $my_temp_browse_list = qq[$my_browse_list_text1 $key1:$temp_hash1{BrowseName}[0]]; } } } } } if ($my_temp_browse_list) { $my_browse_list = $my_temp_browse_list . qq[

    ]; } } # end my_browse_list # start my_prices if ($UsedPrice and $UsedPrice ne "\$0.") { $my_used = qq[$my_marketplace2 $my_marketplace1 $UsedPrice
    ]; } if ($CollectiblePrice and $CollectiblePrice ne "\$0.") { $my_collectible = qq[$my_marketplace3 $my_marketplace1 $CollectiblePrice
    ]; } if ($ThirdPartyNewPrice and $ThirdPartyNewPrice ne "\$0.") { $my_thirdpartynew = qq[$my_marketplace4 $my_marketplace1 $ThirdPartyNewPrice
    ]; } if ($RefurbishedPrice and $RefurbishedPrice ne "\$0.") { $my_refurbished = qq[$my_marketplace5 $my_marketplace1 $RefurbishedPrice
    ]; } if ($OurPrice) { ($our_value = $OurPrice) =~ s/,//g; $our_value =~ s/^(?:\$(\d+(?:\.\d*)?|\.\d+))?.*$/$1/; $our_price = qq[$my_prices_text2 $OurPrice
    ]; } else { $our_price = qq[$my_prices_text2 $my_prices_text5
    ]; } if ($ListPrice and ($OurPrice ne $ListPrice) ) { ($list_value = $ListPrice) =~ s/[\$,]//g; $list_price = qq[$my_prices_text1 $ListPrice
    ]; } if ( ($our_value and $list_value) and ($our_value < $list_value) ) { $discount_amount = "$" . (sprintf "%.2f", ($list_value - $our_value)); $discount_percent = (sprintf "%2.f", (100 - ($our_value / $list_value)*100)) . "%"; $discount = qq[$my_prices_text3 $discount_amount ($discount_percent)
    ]; } $my_prices = $list_price . $our_price . $discount . qq[$my_prices_text4
    ]; # end my_prices # start my_descriptors if ($SalesRank) { push (@descriptors, qq[$my_descriptors_text9 $SalesRank]); } if ($ReleaseDate) { push (@descriptors, qq[$my_descriptors_text1 $ReleaseDate]); } if ($Media and $Media ne $Catalog) { push (@descriptors, qq[$my_descriptors_text3 $Media]); } if ($NumMedia and $NumMedia > 1) { push (@descriptors, qq[$my_descriptors_text4 $NumMedia]); } if ($Encoding) { push (@descriptors, qq[$my_descriptors_text10 $Encoding]); } if ($Tracks) { push (@descriptors, qq[$my_descriptors_text11 $Tracks]); } if ($TheatricalReleaseDate) { push (@descriptors, qq[$my_descriptors_text2 $TheatricalReleaseDate]); } if ($MpaaRating) { push (@descriptors, qq[$my_descriptors_text5 $MpaaRating]); } if ($EsrbRating) { push (@descriptors, qq[$my_descriptors_text7 $EsrbRating]); } if ($ReadingLevel) { push (@descriptors, qq[$my_descriptors_text12 $ReadingLevel]); } if ($AgeGroup) { push (@descriptors, qq[$my_descriptors_text8 $AgeGroup]); } $my_platforms = join(", ", @{$level_3{Platform}}); if ($my_platforms) { push (@descriptors, qq[$my_descriptors_text6 $my_platforms]); } $my_descriptors = join("; ", @descriptors); if ($my_descriptors) { $my_descriptors .= "

    "; } # end my_descriptors # start my_ThirdPartyProductDetails if ($my_marketplace_text) { my $ii; foreach $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); $ConditionType =~ s/<[^>]+>/ /g; if (!$OfferingPrice) { next; } else { $OfferingPrice = "\$" . $OfferingPrice; } if (!$SellerRating) { $SellerRating = "$average_rating_text2"; } $sellersearch_url = "$ENV{SCRIPT_NAME}?input_search_type=SellerSearch&input_string=$SellerId&$url_options"; $ThirdPartyProduct_buy_button = qq[]; $buy_button = initialize_buttons("buy"); $my_ThirdPartyProductDetails .= set_html("thirdparty_products",$ii); $ii++ } $store = $my_marketplace_text; $subject = $ProductName; } # end my_ThirdPartyProductDetails # start see_more if ($level_1{TotalResults}[0]) { $total_pages = int(($level_1{TotalResults}[0] + 9)/10); if ($total_pages == 0) { $total_pages = 1; } $see_total = qq[$see_text4 $page_num $see_text5  $total_pages]; if ($page_num < $total_pages) { $next_page = $page_num + 1; $see_next = qq[$see_text1]; } if ($page_num > 1) { $prev_page = $page_num - 1; $see_prev = qq[$see_text2]; } } #end see_more if ($level_3{AvgCustomerRating}) { $AvgCustomerRating = sprintf "%.2f", $level_3{AvgCustomerRating}[0]; (my $temp_rounded_rating = $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_avg_rating_display = qq[$AvgCustomerRating out of 5 stars]; } else { $my_avg_rating_display = $AvgCustomerRating = $average_rating_text2; } if ($level_3{Product}) { if ($level_3{ListId}) { $my_listmania = qq[
  • $similar_text1]; } $temp_similar_products = get_extra_product_links($level_3{Product}); if ($temp_similar_products) { $my_similar_products = qq[$my_similar_products_text1
    $my_listmania$temp_similar_products
  • $see_text6
    ]; } } if ($level_3{Accessory}) { $temp_accessories = get_extra_product_links($level_3{Accessory}); if ($temp_accessories) { $my_accessories = qq[$my_accessories_text1
    $temp_accessories
    ]; } } $old_product_url = "http://www.amazon.com/exec/obidos/ASIN/$Asin/$associate_id/ref=nosim"; $pda_item_url = "http://www.amazon.com/exec/obidos/redirect?tag=$associate_id&creative=D1KQJBNTALRLQH&camp=2025&link_code=xm2&path=dt/upda-1.0-anywhere/tg/aa/upda/item/-/$Asin"; $rim_item_url = "http://www.amazon.com/exec/obidos/redirect?tag=$associate_id&creative=D1KQJBNTALRLQH&camp=2025&link_code=xm2&path=dt/upda-1.0-i/tg/aa/upda/item/-/$Asin"; $my_large_image_url = "$ENV{SCRIPT_NAME}?input_item=$Asin&input_search_type=image&$url_options"; $item_url = "$ENV{SCRIPT_NAME}?input_item=$Asin&input_search_type=AsinSearch&$url_options"; if ($Availability !~ /(?:not available|discontinued|out of print)/i) { $buy_button = initialize_buttons("buy"); } $wishlist_button = initialize_buttons("wishlist"); $registry_button = initialize_buttons("registry"); $products_html .= set_html($whose_variables,$i) . $my_ThirdPartyProductDetails; if ($i >= $max_results -1) { return; } $i++; } if ($whose_variables eq "sellerprofile") { my %level_2 = process_hashes_of_arrays(%level_1); my %level_3 = process_hashes_of_arrays(%level_2); if (!$NumberOfCanceledAuctions) { $NumberOfCanceledAuctions = $average_rating_text2; } $ii ="0"; $sellerprofile_max = $#{$level_3{Feedback}} + 1; foreach $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); $sellerprofile_html .= set_html("sellerprofile",$ii); $ii++ } } elsif ($whose_variables eq "sellersearch") { my %level_2 = process_hashes_of_arrays(%level_1); my %level_3 = process_hashes_of_arrays(%level_2); $header = "$SellerNickname : $button_text4"; $products_html .= $sellerprofile_html; if ($search_type eq "ExchangeSearch") { $level_3{ListingProductDetails} = $level_1{ListingProductDetails}; } foreach $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); $ExchangeCondition =~ s/<[^>]+>/ /g; if (!$ExchangeSellerRating) { $ExchangeSellerRating = "$average_rating_text2"; } $ImageUrlSmall = "http://images.amazon.com/images/P/$ExchangeAsin.01.THUMBZZZ.jpg"; $item_url = "$ENV{SCRIPT_NAME}?input_search_type=$offering_type{$ExchangeOfferingType}&input_item=$ExchangeAsin&$url_options"; $my_exchangesellerrating = "
    $my_comments_text1 $ExchangeSellerRating
    "; $ThirdPartyProduct_buy_button = qq[]; $buy_button = initialize_buttons("buy"); $products_html .= set_html("sellersearch",$i); if ($i >= $max_results -1) { return; } $i++; } } elsif ($whose_variables eq "AllSearches") { initialize_all_search_boxes(); $products_html .= set_html("AllSearches",$i); } } sub initialize_all_search_boxes { $store = "All"; $subject = "Searches"; $searchbox_start = qq[
    ]; $searchbox_options = qq[]; $searchbox_end = qq[\n
    ]; foreach $key (sort keys %store_to_browse) { $searchbox_modes .= qq[
  • $temp_product_name
    \n]; } return $my_temp; } sub build_featured_product { $featured_input = $_[0]; if ($featured_input =~ /browse\+(\d+)\+mode\+(.+)/) { my $query = "BrowseNodeSearch=$1&mode=$2&type=lite&page=$page_num"; $this_xml_url="http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&$query&f=xml&sort=$sort_type"; $xml_result = get_url($this_xml_url); parse_xml_into_hashes_of_arrays(); my $save_products_html = $products_html; $products_html = ""; assign_variables("featured_product"); my $featured_products_html = $products_html; $products_html = $save_products_html; return $featured_products_html; } else { if ($featured_input eq "random") { if (@featured_products) { $featured_asin = $featured_products[rand @featured_products]; } else { return; } } else { $featured_asin = $featured_input; } $this_xml_url = "http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&AsinSearch=$featured_asin&type=lite&f=xml"; $xml_result = get_url($this_xml_url,"skip_ok"); if (!$xml_result) { return; } parse_xml_into_hashes_of_arrays(); my %level_2 = process_hashes_of_arrays(%level_1); $featured_ProductName = $level_2{ProductName}[0]; $my_featured_item_url = "$ENV{SCRIPT_NAME}?input_item=$level_2{Asin}[0]&input_search_type=AsinSearch&$url_options"; $featured_ImageUrlSmall = $level_2{ImageUrlSmall}[0]; $featured_OurPrice = $level_2{OurPrice}[0]; return set_html(featured_product); } } sub load_browse_table { my %input1 = %{$_[0]}; my $input2 = $_[1]; my $input3 = $_[2]; my ($key, $value, $page_listing); $i = 0; my $temp_name = $input3 . "max_results"; ${$temp_name} = keys %input1; foreach $key (sort keys %input1) { $value = $input1{$key}; next if grep { $_ eq $key } @exclusions; $browse_menu_url = qq[$ENV{'SCRIPT_NAME'}?$input2$value&$url_options]; $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 = $_[0]; my $lap = $_[1] + 1; my %COMMAND; $command_string =~ //s; my $command_commands = $1; my $command_html = $2; for my $command_pair (split(/&/, $command_commands)) { (my $command_name, local $command_value) = split(/=/, $command_pair); if ($command_value eq "last") { if ($whose_variables eq "sellerprofile") { $command_value = $sellerprofile_max; } else { $command_value = $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}) { $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 ($mode and !$nav_menu_type){ $nav_menu_html = load_browse_table(\%{$mode}, "input_mode=$mode&input_id=", "nav_menu"); } elsif ($catalog_to_mode{$Catalog} and !$nav_menu_type) { $nav_menu_html = load_browse_table(\%{$mode}, "input_mode=$mode&input_id=", "nav_menu"); } elsif ($nav_menu_type ne "none") { $nav_menu_html = load_browse_table(\%store_to_browse, "input_mode=", "nav_menu"); } if ($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_featured_product = build_featured_product($COMMAND{apf_featured_product}); if ($my_featured_product) { return $command_html; } } return; } sub set_html { my $temp_result; my $lap = $_[1]; $which_template = $_[0] . "_template_html"; if (${$which_template}) { $temp_result = ${$which_template}; } else { if (@_[0] eq "page") { $temp_result = qq[ Header \n\n\n\n
    %%header%% %%search_box%%
     

    %%products_html%%
    %%see_prev%% %%see_total%% %%see_next%%

     
    ]; } elsif (@_[0] eq "products") { $temp_result = qq[ %%ProductName%%
    %%my_artists%%
    %%ReleaseDate%%
    %%my_prices%%
    ]; } elsif (@_[0] eq "item") { $temp_result = qq[
    %%my_artists%%


    %%see_larger_image_text1%%
    %%my_prices%%
    %%my_used%% %%my_collectible%% %%my_thirdpartynew%% %%my_refurbished%%
    %%availability_text1%% %%Availability%%
    %%buy_button%%

    %%my_descriptors%% %%my_features%% %%my_accessories%% %%my_browse_list%% %%my_similar_products%%

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

    %%my_comments%%
    ]; } elsif (@_[0] eq "larger_image") { $temp_result = qq[
    %%see_back%%
    ]; } elsif (@_[0] eq "sellersearch") { $temp_result = qq[ %%ExchangeTitle%%
    %%ExchangeCondition%%
    $thirdparty_text6 %%ExchangeQuantity%%; $thirdparty_text7 %%ExchangeOfferingType%%; $thirdparty_text3 %%ExchangeConditionType%%
    $availability_text1 %%ExchangeAvailability%%; $thirdparty_text4 %%ExchangeSellerState%%, %%ExchangeSellerCountry%%
    $thirdparty_text8 %%ExchangeEndDate%%
    $my_marketplace1 %%ExchangePrice%%
    %%buy_button%%
    ]; } elsif (@_[0] eq "sellerprofile") { $temp_result = qq[ %%my_comments_text1%% $FeedbackRating
    %%thirdparty_text11%% $FeedbackDate
    %%thirdparty_text5%% $FeedbackComments
    ]; } elsif (@_[0] eq "thirdparty_products") { $temp_result = qq[ $thirdparty_text1 %%SellerNickname%%, $my_comments_text1 %%SellerRating%%
    $thirdparty_text2 %%Condition%%; $thirdparty_text3 %%ConditionType%%
    $availability_text1 %%ExchangeAvailability%%; $thirdparty_text4 %%SellerState%%, %%SellerCountry%%
    $thirdparty_text5 %%ShipComments%%
    $my_marketplace1 %%OfferingPrice%%
    %%buy_button%%
    ]; } elsif (@_[0] eq "browse_menu") { $temp_result = qq[ %%browse_menu_name%% ]; } elsif (@_[0] eq "nav_menu") { $temp_result = qq[ %%browse_menu_name%% ]; } elsif (@_[0] eq "featured_product") { $temp_result = qq[
    Featured Product

    %%featured_ProductName%%

    %%featured_OurPrice%%
    ]; } elsif (@_[0] eq "AllSearches") { $temp_result = qq[ %%all_searchboxes%% ]; } elsif (@_[0] 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:
    • author: ambrose

    • author: ambrose and binding: (abridged or large print) and pubdate: after 11-1996

    • subject: history and (spain or mexico) and not military and language: spanish

    • (subject: marketing and author: kotler) or (publisher: harper and subject: "high technology")

    • keywords: "high tech*" and not fiction and pubdate: during 1999

    • isbn: 0446394319 or 0306806819 or 1567993850


    You can use the following properties of a book in your search:
    • Title

    • Subject

    • Author

    • Keyword

    • ISBN

    • Publisher

    • Language

    • Publication date (pubdate)


    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.
    ]; } } $temp_result =~ s/()/apf_commands($1,$lap);/egs; $temp_result =~ s/%%(\w+)%%/${$1}/g; return $temp_result; }