| Server IP : 216.92.14.13 / Your IP : 216.73.216.171 Web Server : Apache System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : rmlac2fmr ( 1040637) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/home/rmlac2fmr/public_html/cgi-bin/ |
Upload File : |
#!/usr/bin/perl -wT
# version 2.030316, 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 = ("rickymartinon-20");
# basic options:
# show search options link?
$show_search_options = "no";
# set the default search type
$sort_type = "+salesrank";
# set the locale: "us" or "uk"
$locale = "us";
@uk_associate_ids = ("");
# maximum results per page to display - Amazon usually only sends back 10 results per page
$max_results = 30;
# the normal grey button style is "background-color:#EDD5BF;color:#000000"
$submit_button_style = "background-color: #EDD5BF;
border-color: #000000;
border-style: solid;
border-width: 1px;
color: #000000;
font-size: 11px;
margin: 2px;cursor:hand";
# 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 = "apf_xml_cache";
$cache_max_size = "78";
# 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", "", "looney-products.template");
@item_templates = ("item_1.template", "../directory/aws/sample_item.template", "", "", "item_5.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");
# location of optional language files - comma separated, if blank or non-existent will use embedded English
@language_templates = ("apf_missing.language", "apf_dutch.language");
# deprecated options
# if you use these options let me know because I'm thinking of removing them from future versions
# 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";
# categories to exclude from browsing
# @exclusions = ( "Category to exclude here", "and another here. etc." );
# which set of templates and associate_id to use
#$templates_number = 1;
# which language file to use
#$language_number = 1;
# END OF OPTIONS
# don't monkey with anything below here unless you know PERL
# setup initial variables
if ($ENV{SCRIPT_NAME} =~ /test.cgi/) { $debug_state = "on"; $cache_file = "apf_xml_cache.test"; }
$page_num = 1;
get_url_input();
if ($search_type eq "FeaturedProducts") { $item_id = join(",", @featured_products); }
load_language();
intialize_hashes();
calculate_initial_variables();
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&locale=$locale";
$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&locale=$locale";
$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&locale=$locale";
$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&locale=$locale";
$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&locale=$locale";
$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&locale=$locale";
$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&locale=$locale";
$exchange_xml_result = get_url($this_xml_url);
$exchange_xml_result =~ s/<ExchangeSellerId>([^<]+)<\/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&locale=$locale";
$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[<A Href="$ENV{SCRIPT_NAME}?input_mode=none$url_options">$header_text1</A> > $store<BR>];
$products_html = load_browse_table(\%{$mode}, "input_mode=$mode&input_id=");
if (exists($chat_modes{$mode})) {
$chat_link = qq[<A Href="#" onClick="childwin = window.open('http://www.amazon.com/exec/obidos/redirect?tag=$associate_id&path=dt/assoc/tg/chat/age-verification/-/$chat_modes{$mode}/true/].${$mode}{"Top Selling"}.qq[/ref=br_chat_cc_av_e/', '', 'width=392,height=490'); childwin.opener = window;">Chat about $lookup_store{$mode}</a><BR>];
}
} 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]; }
if ($error_msg) { $products_html .= qq[<FONT Color="red" Size="+1">$error_msg</FONT><BR>]; }
if ($debug_state eq "on") { $debug_html = "xml_url = $this_xml_url\n$debug"; }
build_search_box();
$html .= set_html("page");
$html .= qq[<CENTER><FONT style="font-size: 10px; font-family: verdana;"><A Href="http://www.mrrat.com/scripts.html" Target="_new">script by MrRat</A></FONT><BR></CENTER>];
# 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;
$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}) { $new_input{templates_number} = "yes"; $templates_number = $FORM{input_templates}; }
if ($FORM{input_link_templates}) { $new_input{link_templates_number} = "yes"; $link_templates_number = $FORM{input_link_templates}; }
if ($FORM{input_language}) { $new_input{language_number} = "yes"; $language_number = $FORM{input_language}; }
if ($FORM{input_sort}) { $new_input{sort_type} = "yes"; ($sort_type = $FORM{input_sort}) =~ s/\s/+/g; }
if ($FORM{input_max}) { $new_input{max_results} = "yes"; $max_results = $FORM{input_max}; }
if ($FORM{input_link_max}) { $new_input{link_max_results} = "yes"; $link_max_results = $FORM{input_link_max}; }
if ($FORM{input_locale}) { $new_input{locale} = "yes"; $locale = $FORM{input_locale}; }
if ($FORM{input_id}) { $browse_id = $FORM{input_id}; }
if ($FORM{input_item}) { $item_id = $FORM{input_item}; }
if ($FORM{input_page}) { $page_num = $FORM{input_page}; }
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";
$button_text5 = "Add to Amazon.com Baby Registry";
$button_text6 = "Sort";
$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 = "<IMG Src=\"http://g-images.amazon.com/images/G/01/search-browse/button-more-results.gif\" Width=\"101\" Height=\"20\" Border=\"0\" Alt=\"More\">";
$see_text2 = "<IMG Src=\"http://g-images.amazon.com/images/G/01/search-browse/button-previous.gif\" Width=\"101\" Height=\"20\" Border=\"0\" Alt=\"Previous\">";
$see_text3 = "Back";
$see_text4 = "page";
$see_text5 = "of";
$see_text6 = "see more";
$association_text1 = "In association with Amazon";
$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 {
if ($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, "Kitchen & Home" => 3109091, "Phones" => 560820, "Photography" => 560834, "Portable Audio" => 560884 );
%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 = ( "Books" => "books_uk", "Popular Music" => "music", "Classical Music" => "classical", "DVD" => "dvd_uk", "Video" => "vhs_uk", "Electronics" => "electronics_uk", "Software" => "software_uk", "Computer & Video Games" => "video_games_uk", "Toys & Games" => "toys_uk" );
%catalog_to_mode = ( "Book" => "books_uk", "Music" => "music", "DVD" => "dvd_uk", "Video" => "vhs_uk", "Electronics" => "electronics_uk", "Software" => "software_uk", "Video Games" => "video_games_uk", "Toy" => "toys_uk" );
} else {
%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, "Toys: Birth - 12 months" => 731816, "Toys: 12 - 24 months" => 731876, "Toys: 2 years" => 731924 );
%books = ( "Top Selling" => 1000, 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, "New & Future Releases" => 404332 );
%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, "Leisure & Fitness" => 1063918, "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 );
%magazines = ( "Top Selling" => 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 = ( "Top Selling" => 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, "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 );
%photo = ( "Top Selling" => 508048, Outlet => 733952, "Accessories" => 172435, "Binoculars" => 499320, "Camcorders" => 172421, "Film Cameras" => 499106, "Frames & Albums" => 499176, "Printers & Scanners" => 499328, "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, "New & Future Releases" => 286747 );
%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 );
%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)", "+price" => "Price (Low to High)", "-price" => "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","+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" );
%marketplace_text_hash = ( Used => $my_marketplace2, Collectible => $my_marketplace3, ThirdPartyNew => $my_marketplace4, Refurbished => $my_marketplace5 );
%chat_modes = ( photo => 502394, electronics => 172282, videogames => 468642, books => 283155, music => 5174, dvd => 130, toys => 171280 );
}
sub calculate_initial_variables {
if ($locale eq "uk") { @associate_ids = @uk_associate_ids; }
if (@associate_ids[$templates_number-1]) { $associate_id = @associate_ids[$templates_number-1]; }
else { $associate_id = @associate_ids[0]; }
if ($locale eq "uk") {
$in_association = qq[<A Href="http://www.amazon.co.uk/exec/obidos/redirect-home?site=amazon&tag=$associate_id"><FONT Size="2">$association_text1.co.uk</FONT></A><BR>];
} else {
$in_association = qq[<A Href="http://www.amazon.com/exec/obidos/redirect-home/$associate_id"><FONT Size="2">$association_text1.com</FONT></A><BR>];
}
if ($mode eq "none") { $mode = ""; }
if ($search eq "none") { $search = ""; }
if (!$link_templates_number) { $link_templates_number = $templates_number; }
if (!$link_max_results) { $link_max_results = $max_results; }
%lookup_store = reverse %store_to_browse;
%reverse_sort_hash = reverse %sort_hash;
$store = $lookup_store{$mode};
($url_mode = $mode) =~ s/_/-/g;
$see_back = qq[<A Href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true">$see_text3</A>];
if ($new_input{link_templates_number} or $new_input{templates_number}) { $url_options .= "&input_templates=$link_templates_number"; }
if ($new_input{language_number}) { $url_options .= "&input_language=$language_number"; }
if ($new_input{sort_type}) { $url_options .= "&input_sort=$sort_type"; }
if ($new_input{locale}) { $url_options .= "&input_locale=$locale"; }
if ($new_input{max_results} or $new_input{link_max_results}) { $url_options .= "&input_max=$link_max_results"; }
if ($browse_id) {
$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[<A Href="$ENV{SCRIPT_NAME}?input_mode=none$url_options">$header_text1</A> > <A Href="$ENV{SCRIPT_NAME}?input_mode=$mode$url_options">$store</A> > $subject<BR>];
} elsif ($search) {
if ($search_type =~ /(?:SimilaritySearch|ListManiaSearch|SellerProfile|SellerSearch|WishlistSearch|ExchangeSearch)/) {
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)/) {
$query = "$search_type=";
} else {
$query = "KeywordSearch=";
}
$search =~ s/\s/\+/g;
(my $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 {
my $search_box_allsearches;
if ($show_search_options eq "yes") { $search_box_allsearches = qq[<BR><A Href="$ENV{'SCRIPT_NAME'}?input_search_type=AllSearches$url_options"><FONT Size="-1">Search Options</FONT></A>]; }
$search_box = qq[<FORM Method="get" Action="$ENV{'SCRIPT_NAME'}">];
if ($new_input{link_templates_number} or $new_input{templates_number}) { $search_box .= qq[<INPUT Type="hidden" Name="input_templates" Value="$link_templates_number">]; }
if ($new_input{language_number}) { $search_box .= qq[<INPUT Type="hidden" Name="input_language" Value="$language_number">]; }
if ($new_input{sort_type}) { $search_box .= qq[<INPUT Type="hidden" Name="input_sort" Value="$sort_type">]; }
if ($new_input{locale}) { $search_box .= qq[<INPUT Type="hidden" Name="input_locale" Value="$locale">]; }
if ($new_input{max_results} or $new_input{link_max_results}) { $search_box .= qq[<INPUT Type="hidden" Name="input_max" Value="$link_max_results">]; }
$search_box .= qq[<INPUT Type="text" Name="input_string" Size="20"];
if ($search) { $search_box .= qq[ Value="$subject" ]; }
$search_box .= qq[><SELECT Name="input_mode">];
foreach $key (sort keys %store_to_browse) {
my $value = $store_to_browse{$key};
$search_box .= qq[<OPTION Value="$value"];
if ( ($value eq $mode) or (!$mode and $value eq "books") ) { $search_box .= qq[ Selected]; }
$search_box .= qq[>$key];
}
$search_box .= qq[</SELECT><INPUT Style="$submit_button_style" Type="submit" Value="$button_text4">$search_box_allsearches</FORM>];
}
sub load_templates {
my $temp_num = $templates_number - 1; if ($temp_num < 0) { $temp_num = 0; }
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 (<FILEHANDLE>) { ${$variable} = ${$variable} . $_; }
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; }
$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.<BR>Please try again later.\n"; exit; }
if (!$xml_result and $skip ne "skip_ok") { $error_msg = "Sorry, we are currently unable to process your request in a timely manner.<BR>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>([^<]+)<\/ErrorMsg>/if ($skip ne "skip_ok") { $error_msg .= $1; }/esi;
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 my $key (keys %entry_hash) {
if (!${$entry_hash{$key}}[1]) { ${$key} = ${$entry_hash{$key}}[0]; }
foreach my $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 my $item (@{$level_1{Details}}) {
my %temp_hash; $ListPrice = "";
push @{$temp_hash{Details}}, $item;
my %level_2 = process_hashes_of_arrays(%temp_hash);
my %level_3 = process_hashes_of_arrays(%level_2);
$our_price = ""; $list_price = ""; $discount = ""; $our_value = ""; $list_value = "";
if ($browse_id) {
if (exists($chat_modes{$mode})) {
$chat_link = qq[<A Href="#" onClick="childwin = window.open('http://www.amazon.com/exec/obidos/redirect?tag=$associate_id&path=dt/assoc/tg/chat/age-verification/-/$chat_modes{$mode}/true/$browse_id/ref=br_chat_cc_av_e/', '', 'width=392,height=490'); childwin.opener = window;">Chat about $lookup_browse_id{$browse_id}</a><BR>];
}
}
if ($catalog_to_mode{$Catalog} and !$FORM{input_mode}) { $mode = $catalog_to_mode{$Catalog}; }
# start my_artists
$my_artists = "";
if ($mode =~ /^(books|books_uk)$/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|dvd_uk|vhs_uk)$/i) {
$my_artists = comma_separate_list($level_3{Actor},$my_artists_text2,"ActorSearch");
if ($level_3{Director}) { $my_artists .= "<BR>" . comma_separate_list($level_3{Director},$my_artists_text4,"DirectorSearch"); }
}
if ( (!$my_artists) and ($Manufacturer) ) {
if ($mode =~ /^(electronics|kitchen|videogames|software|photo|pc_hardware|electronics_uk|video_games_uk|software_uk)$/) {
(my $search_manufacturer_string = $Manufacturer) =~ s/ /+/g;
$my_artists = qq[$my_artists_text3 <A Href="$ENV{SCRIPT_NAME}?input_mode=$mode&input_search_type=ManufacturerSearch&input_string=$search_manufacturer_string$url_options">$Manufacturer</A>];
} else {
$my_artists = qq[$my_artists_text3 $Manufacturer];
}
}
# end my_artists
# start my_comments
foreach my $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/</</g;
($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[<IMG Alt="$temp_hash1{Rating}[0] out of 5 stars" Src="http://g-images.amazon.com/images/G/01/x-locale/common/customer-reviews/stars-$temp_rounded_rating.gif">];
if ($mode eq "toys") { $temp_rating_display = $temp_hash1{Rating}[0]};
if (!$temp_hash1{Rating}[0]) { $temp_rating_display = $average_rating_text2; }
if ($my_comments) { $my_comments .= qq[<BR><HR Width="75%"><BR>\n]; }
$my_comments .= qq[$my_comments_text1 $temp_rating_display - <B>$temp_hash1{Summary}[0]</B><BR>\n$temp_hash1{Comment}[0]<BR>\n];
}
# end my_comments
# start my_features
if ($level_3{Feature}) {
$my_features = qq[<B>$my_features_text1</B><BR>\n<LI>];
$my_features .= join("<BR>\n<LI>", @{$level_3{Feature}});
$my_features .= qq[<BR><BR>\n];
}
# end my_features
# start my_browse_list
if ($level_3{BrowseNode}) {
my $my_temp_browse_list;
foreach my $key1 (keys %store_to_browse) {
foreach my $key2 (keys %{$store_to_browse{$key1}}) {
foreach my $item (@{$level_3{BrowseNode}}) {
my (%temp_hash,%temp_hash1,%temp_hash2,$lc_browse_name);
push @{$temp_hash{BrowseNode}}, $item;
%temp_hash1 = process_hashes_of_arrays(%temp_hash);
$lc_browse_name = lc $temp_hash1{BrowseName}[0];
next if $lc_browse_name eq "top selling";
if ($lc_browse_name eq lc $key2) {
if ($my_temp_browse_list) {
$my_temp_browse_list .= qq[, <A Href="$ENV{SCRIPT_NAME}?input_mode=$store_to_browse{$key1}&input_id=${$store_to_browse{$key1}}{$key2}$url_options">$key1:$temp_hash1{BrowseName}[0]</A>];
} else {
$my_temp_browse_list = qq[<B>$my_browse_list_text1</B> <A Href="$ENV{SCRIPT_NAME}?input_mode=$store_to_browse{$key1}&input_id=${$store_to_browse{$key1}}{$key2}$url_options">$key1:$temp_hash1{BrowseName}[0]</A>];
}
}
}
}
}
if ($my_temp_browse_list) { $my_browse_list = $my_temp_browse_list . qq[<BR><BR>]; }
}
# end my_browse_list
# start my_prices
my $money_symbol;
if ($locale eq "us") {
if ($UsedPrice and $UsedPrice ne "\$0.") { $my_used = qq[<A Href="$ENV{SCRIPT_NAME}?input_item=$Asin&input_search_type=Used$url_options">$my_marketplace2 $my_marketplace1 $UsedPrice</A><BR>]; }
if ($CollectiblePrice and $CollectiblePrice ne "\$0.") { $my_collectible = qq[<A Href="$ENV{SCRIPT_NAME}?input_item=$Asin&input_search_type=Collectible$url_options">$my_marketplace3 $my_marketplace1 $CollectiblePrice</A><BR>]; }
if ($ThirdPartyNewPrice and $ThirdPartyNewPrice ne "\$0.") { $my_thirdpartynew = qq[<A Href="$ENV{SCRIPT_NAME}?input_item=$Asin&input_search_type=ThirdPartyNew$url_options">$my_marketplace4 $my_marketplace1 $ThirdPartyNewPrice</A><BR>]; }
if ($RefurbishedPrice and $RefurbishedPrice ne "\$0.") { $my_refurbished = qq[<A Href="$ENV{SCRIPT_NAME}?input_item=$Asin&input_search_type=Refurbished$url_options">$my_marketplace5 $my_marketplace1 $RefurbishedPrice</A><BR>]; }
}
if ($OurPrice) {
($our_value = $OurPrice) =~ s/,//g;
$our_value =~ s/^(?:(?:\$|£)(\d+(?:\.\d*)?|\.\d+))?.*$/$1/;
$our_price = qq[<B>$my_prices_text2 <FONT Color="#990000">$OurPrice</FONT></B><BR>];
} else {
$our_price = qq[<B>$my_prices_text2 <I>$my_prices_text5</I></B><BR>];
}
if ($ListPrice and ($OurPrice ne $ListPrice) ) {
($list_value = $ListPrice) =~ s/(?:\$|£|,)//g;
$list_price = qq[<B>$my_prices_text1 </B><STRIKE>$ListPrice</STRIKE><BR>];
}
if ( ($our_value and $list_value) and ($our_value < $list_value) ) {
if ($locale eq "uk") {
$money_symbol = "£";
} else {
$money_symbol = "$";
}
$discount_amount = $money_symbol . (sprintf "%.2f", ($list_value - $our_value));
$discount_percent = (sprintf "%2.f", (100 - ($our_value / $list_value)*100)) . "%";
$discount = qq[<B>$my_prices_text3</B> <FONT Color="#990000">$discount_amount ($discount_percent)</FONT><BR>];
}
$my_prices = $list_price . $our_price . $discount . qq[<FONT Size="1">$my_prices_text4</FONT><BR>];
# end my_prices
# start my_descriptors
if ($SalesRank) { push (@descriptors, qq[<B>$my_descriptors_text9</B> $SalesRank]); }
if ($ReleaseDate) { push (@descriptors, qq[<B>$my_descriptors_text1</B> $ReleaseDate]); }
if ($Media and $Media ne $Catalog) { push (@descriptors, qq[<B>$my_descriptors_text3</B> $Media]); }
if ($NumMedia and $NumMedia > 1) { push (@descriptors, qq[<B>$my_descriptors_text4</B> $NumMedia]); }
if ($Encoding) { push (@descriptors, qq[<B>$my_descriptors_text10</B> $Encoding]); }
if ($TheatricalReleaseDate) { push (@descriptors, qq[<B>$my_descriptors_text2</B> $TheatricalReleaseDate]); }
if ($MpaaRating) { push (@descriptors, qq[<B>$my_descriptors_text5</B> $MpaaRating]); }
if ($EsrbRating) { push (@descriptors, qq[<B>$my_descriptors_text7</B> $EsrbRating]); }
if ($ReadingLevel) { push (@descriptors, qq[<B>$my_descriptors_text12</B> $ReadingLevel]); }
if ($AgeGroup) { push (@descriptors, qq[<B>$my_descriptors_text8</B> $AgeGroup]); }
$my_platforms = join(", ", @{$level_3{Platform}});
if ($my_platforms) { push (@descriptors, qq[<B>$my_descriptors_text6</B> $my_platforms]); }
$my_descriptors = join("; ", @descriptors);
if ($my_descriptors) { $my_descriptors .= "<BR><BR>"; }
# end my_descriptors
# 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);
$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[<INPUT Type="hidden" Name="exchange.$ExchangeId.$Asin.$SellerId" Value="1">];
$buy_button = initialize_buttons("buy");
$my_ThirdPartyProductDetails .= set_html("thirdparty_products",$ii);
$ii++
}
$store = $my_marketplace_text; $subject = $ProductName;
}
# end my_ThirdPartyProductDetails
#start sort_box
if ($search or $browse_id or $search_type =~ /AuthorSearch|ArtistSearch|ActorSearch|DirectorSearch|ManufacturerSearch|PowerSearch/) {
my (@temp_sort_array,$sort_box_options,$sort_url_options);
if ( @{$sort_hash_by_mode{$mode}} ) {
@temp_sort_array = @{$sort_hash_by_mode{$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[<OPTION Value="$key1"];
if ($key1 eq $sort_type) { $sort_box_options .= " Selected"; }
$sort_box_options .= qq[>$sort_hash{$key1}];
}
}
$sort_url_options .= qq[<INPUT Type="hidden" Name="input_mode" Value="$mode">];
if ($search_type) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_search_type" Value="$search_type">]; }
if ($search) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_string" Value="$search">]; }
if ($browse_id) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_id" Value="$browse_id">]; }
if ($item_id) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_item" Value="$item_id">]; }
if ($new_input{link_templates_number} or $new_input{templates_number}) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_templates" Value="$link_templates_number">]; }
if ($new_input{language_number}) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_language" Value="$language_number">]; }
if ($new_input{locale}) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_locale" Value="$locale">]; }
if ($new_input{max_results} or $new_input{link_max_results}) { $sort_url_options .= qq[<INPUT Type="hidden" Name="input_max" Value="$link_max_results">]; }
$sort_box = qq[<FORM Method="get" Action="$ENV{SCRIPT_NAME}"><SELECT Name="input_sort">$sort_box_options</SELECT>$sort_url_options<INPUT Style="$submit_button_style" Type="submit" Value=" $button_text6 "></FORM>];
}
#end sort_box
if ($level_3{AvgCustomerRating} and $level_3{AvgCustomerRating}[0] != 0) {
$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[<IMG Alt="$AvgCustomerRating out of 5 stars" Src="http://g-images.amazon.com/images/G/01/x-locale/common/customer-reviews/stars-$temp_rounded_rating.gif">];
} else {
$my_avg_rating_display = $AvgCustomerRating = $average_rating_text2;
}
if ($Tracks) {
foreach $item (@{$level_3{Track}}) {
$my_tracks .= qq[<LI>$item<BR>];
}
$my_tracks = qq[<B>$my_descriptors_text11</B><BR>$my_tracks<BR>];
}
if ($level_3{Product}) {
if ($level_3{ListId}) { $my_listmania = qq[<LI><A Href="$ENV{SCRIPT_NAME}?input_search_type=ListManiaSearch&input_string=${$level_3{ListId}}[rand @{$level_3{ListId}}]$url_options">$similar_text1</A>]; }
my $temp_similar_products = get_extra_product_links($level_3{Product});
if ($temp_similar_products) { $my_similar_products = qq[<B>$my_similar_products_text1</A></B><BR>$my_listmania$temp_similar_products<LI><A Href="$ENV{SCRIPT_NAME}?input_search_type=SimilaritySearch&input_string=$Asin$url_options">$see_text6</A><BR>]; }
}
if ($level_3{Accessory}) {
my $temp_accessories = get_extra_product_links($level_3{Accessory});
if ($temp_accessories) { $my_accessories = qq[<B>$my_accessories_text1</B><BR>$temp_accessories<BR>]; }
}
if (!$Availability) { $Availability = "unknown"; }
if ($locale eq "us") { $my_availability = qq[<B>$availability_text1</B> $Availability<BR>]; }
$old_product_url = "http://www.amazon.com/exec/obidos/ASIN/$Asin/$associate_id/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");
$oneclick_button = initialize_buttons("oneclick");
}
$wishlist_button = initialize_buttons("wishlist");
$wedding_button = initialize_buttons("wedding");
$baby_button = initialize_buttons("baby");
$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; }
my $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 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);
$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 = "<CENTER><B>$my_comments_text1 $ExchangeSellerRating</B></CENTER>";
$ThirdPartyProduct_buy_button = qq[<INPUT Type="hidden" Name="exchange.$ExchangeId.$ExchangeAsin.$ExchangeSellerId" Value="1">];
$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);
}
# 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];
my $see_url_options;
if ($search_type) { $see_url_options .= "&input_search_type=$search_type"; }
if ($search) { $see_url_options .= "&input_string=$search"; }
if ($browse_id) { $see_url_options .= "&input_id=$browse_id"; }
if ($item_id) { $see_url_options .= "&input_item=$item_id"; }
if ($page_num < $total_pages) {
my $next_page = $page_num + 1;
$see_next = qq[<A Href="$ENV{SCRIPT_NAME}?input_mode=$mode&input_page=$next_page$see_url_options$url_options">$see_text1</A>];
}
if ($page_num > 1) {
my $prev_page = $page_num - 1;
$see_prev = qq[<A Href="$ENV{SCRIPT_NAME}?input_mode=$mode&input_page=$prev_page$see_url_options$url_options">$see_text2</A>];
}
my ($page_num_low,$page_num_high);
$see_index = "";
if ($total_pages != "1") {
if ($page_num - 5 > 0) { $page_num_low = $page_num - 5; } else { $page_num_low = "1"; }
if ($page_num_low + 10 <= $total_pages) { $page_num_high = $page_num_low + 10; } else { $page_num_high = $total_pages; }
for (my $loop_index = $page_num_low; $loop_index <= $page_num_high; $loop_index++) {
if ($loop_index == $page_num) {
$see_index .= qq[ $loop_index ];
} else {
$see_index .= qq[ <A Href="$ENV{SCRIPT_NAME}?input_mode=$mode&input_page=$loop_index$see_url_options$url_options">$loop_index</A> ];
}
}
}
}
#end see_more
}
sub initialize_all_search_boxes {
$store = "All"; $subject = "Searches";
my ($searchbox_start,$searchbox_options,$searchbox_end,$searchbox_modes,$searchbox_string,$searchbox_item,$searchbox_id,$searchbox_offering_types,%searchbox_types,$searchbox_sort,$searchbox_name);
$searchbox_start = qq[<FORM Method="get" Action="$ENV{SCRIPT_NAME}"><TABLE Width="100%">];
$searchbox_options = qq[<INPUT Type="hidden" Name="input_templates" Value="$link_templates_number"><INPUT Type="hidden" Name="input_language" Value="$language_number"><INPUT Type="hidden" Name="input_max" Value="$link_max_results">];
$searchbox_end = qq[<TR><TD Align="right" Colspan="2"><INPUT Style="$submit_button_style" Type="submit" Value="$button_text4"></TD></TR>\n</TABLE></FORM>];
foreach $key (sort keys %store_to_browse) { $searchbox_modes .= qq[<OPTION Value="$store_to_browse{$key}"]; if ($key eq "Books") { $searchbox_modes .= " Selected"; } $searchbox_modes .= qq[>$key]; }
$searchbox_modes = qq[<TR><TD>Product Mode: </TD><TD Align="right"><SELECT Name="input_mode">$searchbox_modes</SELECT></TD></TR>];
$searchbox_string = qq[<TR><TD>Search String: </TD><TD Align="right"><INPUT Type="text" Name="input_string" Size="20"></TD></TR>];
$searchbox_item = qq[<TR><TD>Item: </TD><TD Align="right"><INPUT Type="text" Name="input_item" Size="20"></TD></TR>];
$searchbox_id = qq[<TR><TD>Browse Id Number: </TD><TD Align="right"><INPUT Type="text" Name="input_id" Size="20"></TD></TR>];
foreach $key (sort keys %offering_type) { $searchbox_offering_types .= qq[<OPTION Value="$offering_type{$key}"]; if ($offering_type{$key} eq "Used") { $searchbox_offering_types .= " Selected"; } $searchbox_offering_types .= qq[>$offering_type{$key}]; }
$searchbox_offering_types = qq[<TR><TD>Offering Type: </TD><TD Align="right"><SELECT Name="input_search_type">$searchbox_offering_types</SELECT></TD></TR>];
%searchbox_types = (
"ASIN/ISBN Amazon" => ["ASIN/ISBN","$searchbox_item"],
"Actor/Actress" => ["actor/actress","$searchbox_string","ActorSearch","dvd","sort"],
"Artist/Musician" => ["artist or musician","$searchbox_string","ArtistSearch","music","sort"],
"Author" => ["author","$searchbox_string","AuthorSearch","books","sort"],
"BrowseNode" => ["browse node","$searchbox_id\n$searchbox_modes","","","sort"],
"Director" => ["director","$searchbox_string","DirectorSearch","dvd","sort"],
"Listmania" => ["listmania list id","$searchbox_string","ListManiaSearch"],
"Manufacturer" => ["manufacturer","$searchbox_string\n$searchbox_modes","ManufacturerSearch","","sort"],
"Power" => ["<A Href=$ENV{'SCRIPT_NAME'}?input_search_type=power_search_info$url_options>power search</A> for Books","$searchbox_string","PowerSearch","books","sort"],
"Similar Products" => ["products similar to ASIN","$searchbox_string","SimilaritySearch"],
"Third-party ASIN" => ["third-party ASIN","$searchbox_item\n$searchbox_offering_types"],
"Third-party Exchange" => ["exchange id","$searchbox_string","ExchangeSearch"],
"Third-party Seller" => ["seller id","$searchbox_string","SellerSearch"],
"UPC" => ["universal price code for Music","$searchbox_item","UpcSearch","music"],
"WishList" => ["wish list id","$searchbox_string","WishlistSearch"],
);
my $lap="0"; $all_searchboxes = qq[<TABLE border="0" Cellpadding="10" Width="100%">\n];
foreach my $key (sort keys %searchbox_types) {
$lap++;
if (${$searchbox_types{$key}}[2]) { ${$searchbox_types{$key}}[1] .= qq[\n<INPUT Type="hidden" Name="input_search_type" Value="${$searchbox_types{$key}}[2]">]; }
if (${$searchbox_types{$key}}[3]) { ${$searchbox_types{$key}}[1] .= qq[\n<INPUT Type="hidden" Name="input_mode" Value="${$searchbox_types{$key}}[3]">]; }
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[<OPTION Value="$key1"];
if ($key1 eq $sort_type) { $searchbox_sort .= " Selected"; }
$searchbox_sort .= qq[>$sort_hash{$key1}];
}
}
${$searchbox_types{$key}}[1] .= qq[<TR><TD>Sort by: </TD><TD Align="right"><SELECT Name="input_sort">$searchbox_sort</SELECT></TD></TR>];
}
$searchbox_name = $key . "_searchbox";
${$searchbox_name} = qq|$searchbox_start\n<TR><TD Align="center" Colspan="2"><B>$key:</B> Search by ${$searchbox_types{$key}}[0].</TD></TR>\n$searchbox_options\n${$searchbox_types{$key}}[1]\n$searchbox_end\n|;
if ($lap == 1) { $all_searchboxes .= "<TR>\n"; }
$all_searchboxes .= qq[<TD Align="center" Width="50%">\n${$searchbox_name}</TD>];
if ($lap == 2) {
$all_searchboxes .= "</TR>\n\n";
$lap = 0;
}
}
if ($lap > 0) { $all_searchboxes .= "</TR>\n\n"; }
$all_searchboxes .= "</TABLE>\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[<A Href="$ENV{SCRIPT_NAME}?input_mode=$mode&input_search_type=$temp_search_type&input_string=$temp_search_string$url_options">$item</A>];
}
return $temp_list;
}
sub initialize_buttons {
my $value = $_[0];
my (%button_hash,$asin_buy_button,$temp_button);
if ($locale eq "uk") { $value = "uk"; }
%button_hash = ( buy => ['Name="submit.add-to-cart" Value="'.$button_text1.'" Alt="'.$button_text1.'"','http://g-images.amazon.com/images/G/01/associates/add-to-cart.gif'], oneclick => ['Name="submit.add-to-cart" Value="'.$button_text1.'" Alt="'.$button_text1.'"','http://g-images.amazon.com/images/G/01/associates/add-to-cart.gif'], wishlist => ['Name="submit.add-to-registry.wishlist" Value="'.$button_text2.'" Alt="'.$button_text2.'"','http://g-images.amazon.com/images/G/01/associates/add-to-wishlist.gif'], wedding => ['Name="submit.add-to-registry.wedding" Value="'.$button_text3.'" Alt="'.$button_text3.'"','http://g-images.amazon.com/images/G/01/associates/add-to-wedding.gif'], baby => ['Name="submit.add-to-registry.babyreg" Value="'.$button_text5.'" Alt="'.$button_text5.'"','http://g-images.amazon.com/images/G/01/associates/add-to-baby.gif'], uk => ['Name="submit.add-to-cart" Value="'.$button_text1.'" Alt="Buy from Amazon.co.uk"','/images/add-to-cart-uk.gif'] );
if ($ThirdPartyProduct_buy_button) { $asin_buy_button = $ThirdPartyProduct_buy_button; } else { $asin_buy_button = qq[<INPUT Type="hidden" Name="asin.$Asin" Value="1">]; }
$temp_button = qq[<FORM Method="POST" Action="http://www.amazon.com/o/dt/assoc/handle-buy-box=$Asin" Target="amazon">$asin_buy_button<INPUT Type="hidden" Name="tag-value" Value="$associate_id"><INPUT Type="hidden" Name="tag_value" Value="$associate_id"><INPUT Type="hidden" Name="dev-tag-value" Value="D1KQJBNTALRLQH"><INPUT Type="image" ${$button_hash{$value}}[0] Src="${$button_hash{$value}}[1]"></FORM>];
if ($value eq "oneclick") {
$temp_button = qq[<script language="JavaScript">function popUp(URL,NAME) { amznwin=window.open(URL,NAME,'location=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=380,height=450,screenX=10,screenY=10,top=10,left=10'); amznwin.focus(); } document.open(); document.write("<a href=javascript:popUp('http://buybox.amazon.com/exec/obidos/redirect?tag=$associate_id&link_code=xsc&creative=23424&camp=2025&path=/dt/assoc/tg/aa/xml/assoc/-/$Asin/$associate_id/ref=ac_bb1_,_amazon')><img src=http://rcm-images.amazon.com/images/G/01/associates/remote-buy-box/buy1.gif border=0 alt='Buy from Amazon.com' ></a>"); document.close();</script><noscript>$temp_button</noscript>];
}
if ($locale eq "uk") { $temp_button =~ s/www\.amazon\.com/www.amazon.co.uk/gi; }
return $temp_button;
}
sub get_extra_product_links {
my $value = $_[0]; my ($temp_asins,$temp_xml_result,@temp_xml_feed,$my_temp);
$temp_asins = join(",", @{$value});
$temp_xml_result = get_url("http://xml.amazon.com/onca/xml2?t=$associate_id&dev-t=D1KQJBNTALRLQH&AsinSearch=$temp_asins&type=lite&f=xml&locale=$locale","skip_ok");
push @temp_xml_feed, ($temp_xml_result =~ /<Details(?:\s[^>]+)?>(.*?)<\/Details>/gsi);
for my $ii (0 .. $#temp_xml_feed) {
@temp_xml_feed[$ii] =~ s/<Asin>([^<]+)<\/Asin>/$temp_asin = $1/sie;
@temp_xml_feed[$ii] =~ s/<ProductName>([^<]+)<\/ProductName>/$temp_product_name = $1/sie;
$my_temp .= qq[<LI><A Href="$ENV{SCRIPT_NAME}?input_item=$temp_asin&input_search_type=AsinSearch$url_options">$temp_product_name</A><BR>\n];
}
return $my_temp;
}
sub build_featured_product {
my $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&locale=$locale";
$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&locale=$locale";
$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 =~ /<!--apf([^!]+?)!([^!]*?)!-->/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}) {
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 ($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 (<FILEHANDLE>) { $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[
<HTML><HEAD>
<META NAME="description" content="Buy %%subject%% %%store%% cheap.">
<META NAME="keywords" content="Buy %%subject%% %%store%% cheap.">
<TITLE>%%store%% : %%subject%%</TITLE>
<style type="text/css">
TD {
font-family: verdana, arial,helv;
font-size: 10px;
}
a:link{
background-color: transparent;
color: #7B4A1F;
font-size: 11px;
text-decoration: none;
}
a:visited {
background-color: transparent;
color: #7B4A1F;
font-size: 11px;
text-decoration: none;
}
a:hover {
background-color: transparent;
color: #000000;
font-size: 11px;
text-decoration: none;
}
a:active {
background-color: transparent;
color: #7B4A1F;
font-size: 11px;
text-decoration: none;
}
select {
background-color: #ffffff;
color: #000000;
}
INPUT {
background-color: #ffffff;
border-color: #000000;
border-style: solid;
border-width: 1px;
color: #000000;
font-size: 11px;
margin: 2px;
}
</style>
</HEAD><BODY>
\n\n<!--\n%%debug_html%%\n%%subject%% %%store%%\n-->\n\n
<SCRIPT>function noImageCheck(objImg) { if (objImg.width == 1) { objImg.src = "http://g-images.amazon.com/images/G/01/books/icons/books-no-image.gif"; } } </SCRIPT>
<TABLE Valign="middle" Width="100%"><TR><TD Align="center">
%%header%%
%%in_association%%
%%search_box%%
</TD>
</TR></TABLE>
<TABLE Bgcolor="#E7E0D9" Cellpadding="0" Cellspacing="0" Width="100%"><TR><TD><DIV Style="font-size: 6pt"> </DIV></TD></TR></TABLE>
<BR>
<CENTER>%%sort_box%%</CENTER>
%%products_html%%
<TABLE Width="100%"><TR>
<TD Align="left" Width="33%">%%see_prev%%</TD>
<TD Align="center" Width="34%"><FONT Size="-1">%%see_total%%<BR>%%see_index%%</FONT></TD>
<TD Align="right" Width="33%">%%see_next%%</TD>
</TR></TABLE>
<BR>
<TABLE Bgcolor="#E7E0D9" Cellpadding="0" Cellspacing="0" Width="100%"><TR><TD Align="center"><DIV Style="font-size: 6pt"> </DIV></TD></TR></TABLE>
</BODY></HTML>
];
} elsif (@_[0] eq "products") {
$temp_result = qq[
<!--apf &apf_repeat=2!
<TABLE Bgcolor="#E7E0D9" border="0" Cellpadding="10" Width="100%"><TR>
!-->
<!--apf &apf_start=2&apf_repeat=2!
<TABLE Bgcolor="#FFFFFF" border="0" Cellpadding="10" Width="100%"><TR>
!-->
<TR>
<TD Valign="middle">
<A Href="%%item_url%%"><IMG Align="left" Alt="%%store%% : %%ProductName%%" Border="0" Src="%%ImageUrlSmall%%" onLoad="noImageCheck(this);"></A>
<A Href="%%item_url%%"><B>%%ProductName%%</B></A><BR>
%%my_artists%%<BR>
%%ReleaseDate%%<BR>
</TD>
<TD Align="center" Valign="middle" Width="195">%%my_prices%%</TD>
</TR>
</TABLE><BR>
];
} elsif (@_[0] eq "item") {
$temp_result = qq[
<CENTER><TABLE Width="100%">
<TR><TD Align="center" Colspan="3">%%my_artists%%</TD></TR>
<TR><TD><BR></TD></TR>
<TR>
<TD Align="center" Valign="top"><A Href="%%my_large_image_url%%"><IMG Alt="%%store%% : %%ProductName%%" Border="0" Src="%%ImageUrlMedium%%" onLoad="noImageCheck(this);"><BR><FONT Size="2">%%see_larger_image_text1%%</FONT></A></TD>
<TD Valign="top">
%%my_prices%%<BR>
<FONT Size="-1">%%my_used%% %%my_collectible%% %%my_thirdpartynew%% %%my_refurbished%%</FONT><BR>
%%my_availability%%
</TD>
<TD Align="center" Valign="middle">%%oneclick_button%%</TD>
</TR>
<TR><TD><BR></TD></TR>
<TR><TD Colspan="3">
%%my_descriptors%%
%%my_features%%
</TD></TR>
<TR><TD Colspan="2">
%%my_accessories%%
%%my_browse_list%%
%%my_similar_products%%
</TD><TD>
%%my_tracks%%
</TD></TR>
<TR><TD><BR></TD></TR>
<TR Bgcolor="#E7E0D9"><TD Align="center" Colspan="3"><B><FONT Color="#FFFFFF" Face="Arial, Helvetica, sans-serif">%%customer_reviews_text1%%</FONT></B></TD></TR>
<TR><TD Colspan="3">
<CENTER>%%average_rating_text1%% %%my_avg_rating_display%%</CENTER><BR>
%%my_comments%%
</TD></TR>
</TABLE></CENTER>
];
} elsif (@_[0] eq "larger_image") {
$temp_result = qq[
<CENTER>
<IMG Src="%%ImageUrlLarge%%" onLoad="noImageCheck(this);"><BR>
%%see_back%%<BR>
</CENTER>
];
} elsif (@_[0] eq "sellersearch") {
$temp_result = qq[
<!--apf &apf_repeat=2!
<TABLE Bgcolor="#FFFFFF" Border="2" Cellpadding="10" Width="100%"><TR>
!-->
<!--apf &apf_start=2&apf_repeat=2!
<TABLE Bgcolor="#E7E0D9" Border="2" Cellpadding="10" Width="100%"><TR>
!-->
<TD Valign="middle">
<A Href="%%item_url%%">%%ExchangeTitle%%</A><BR>
%%ExchangeCondition%%<BR>
<B>%%thirdparty_text6%%</B> %%ExchangeQuantity%%; <B>%%thirdparty_text7%%</B> %%ExchangeOfferingType%%; <B>%%thirdparty_text3%%</B> %%ExchangeConditionType%%<BR>
<B>%%availability_text1%%</B> %%ExchangeAvailability%%; <B>%%thirdparty_text4%%</B> %%ExchangeSellerState%%, %%ExchangeSellerCountry%%<BR>
<B>%%thirdparty_text8%%</B> %%ExchangeEndDate%%<BR>
</TD>
<TD Align="center" Valign="middle" Width="195">
<B>%%my_marketplace1%% <FONT Color="#990000">%%ExchangePrice%%</FONT></B><BR>
%%buy_button%%
</TD>
</TR></TABLE><BR>
];
} elsif (@_[0] eq "sellerprofile") {
$temp_result = qq[
<!--apf &apf_start=1!
<TABLE Bgcolor="#E7E0D9" border="0" Cellpadding="10" Width="100%">
<TR><TD Colspan="5">
<B>%%thirdparty_text1%%</B> %%SellerNickname%%; <B>%%my_comments_text1%%</B> %%OverallFeedbackRating%%; <B>%%thirdparty_text9%%</B> %%NumberOfFeedback%%; <B>%%thirdparty_text10%%</B> %%NumberOfCanceledAuctions%%<BR>
</TD></TR><TR>
!-->
<TD Width="20%"><FONT Size="-1">
%%my_comments_text1%% %%FeedbackRating%%<BR>
%%thirdparty_text11%% %%FeedbackDate%%<BR>
%%thirdparty_text5%% %%FeedbackComments%%<BR>
</FONT></TD>
<!--apf &apf_start=last!
</TR></TABLE><BR>
!-->
];
} elsif (@_[0] eq "thirdparty_products") {
$temp_result = qq[
<!--apf &apf_repeat=2!
<TABLE Bgcolor="#FFFFFF" Border="2" Cellpadding="10" Width="100%"><TR>
!-->
<!--apf &apf_start=2&apf_repeat=2!
<TABLE Bgcolor="#E7E0D9" Border="2" Cellpadding="10" Width="100%"><TR>
!-->
<TD Valign="middle">
<B>%%thirdparty_text1%%</B> <A Href="%%sellersearch_url%%">%%SellerNickname%%</A>, <B>%%my_comments_text1%%</B> %%SellerRating%%<BR>
<B>%%thirdparty_text2%%</B> %%Condition%%; <B>%%thirdparty_text3%%</B> %%ConditionType%%<BR>
<B>%%availability_text1%%</B> %%ExchangeAvailability%%; <B>%%thirdparty_text4%%</B> %%SellerState%%, %%SellerCountry%%<BR>
<B>%%thirdparty_text5%%</B> %%ShipComments%%<BR>
</TD>
<TD Align="center" Valign="middle" Width="195">
<B>%%my_marketplace1%% <FONT Color="#990000">%%OfferingPrice%%</FONT></B><BR>
%%buy_button%%
</TD>
</TR></TABLE><BR>
];
} elsif (@_[0] eq "browse_menu") {
$temp_result = qq[
<!--apf &apf_start=1! <TABLE Bgcolor="#E7E0D9" Cellpadding="5" Width="100%"> !-->
<!--apf &apf_start=1&apf_repeat=3! <TR> !-->
<TD Align="center" Width="33%"><B><A Href="%%browse_menu_url%%">%%browse_menu_name%%</A></B></TD>
<!--apf &apf_start=3&apf_end=last&apf_repeat=3! </TR> !-->
<!--apf &apf_start=last! </TABLE> !-->
];
} elsif (@_[0] eq "nav_menu") {
$temp_result = qq[
<TR><TD><B><A Href="%%browse_menu_url%%">%%browse_menu_name%%</A></B></TD></TR>
];
} elsif (@_[0] eq "featured_product") {
$temp_result = qq[
<TABLE Bgcolor="#E8DCD2" Border="1" Width="120"><TR><TD Align="center">
<FONT Size="2"><B>Featured Product</B></FONT><BR>
<A Href="%%my_featured_item_url%%"><IMG Alt="%%featured_ProductName%%" Border="0" Src="%%featured_ImageUrlSmall%%" onLoad="noImageCheck(this);"><BR>
<FONT Size="1">%%featured_ProductName%%</FONT></A><BR>
<FONT Color="#990000" Size="1">%%featured_OurPrice%%</FONT><BR>
</TD></TR></TABLE>
];
} 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.<BR><BR>The syntax for a power search is shown below:<BR><UL>
<LI>author: ambrose<BR><BR>
<LI>author: ambrose and binding: (abridged or large print) and pubdate: after 11-1996<BR><BR>
<LI>subject: history and (<st1:country-region><st1:place>spain</st1:place></st1:country-region> or <st1:country-region><st1:place>mexico</st1:place></st1:country-region>) and not military and language: spanish<BR><BR>
<LI>(subject: marketing and author: kotler) or (publisher: harper and subject: "high technology")<BR><BR>
<LI>keywords: "high tech*" and not fiction and pubdate: during 1999<BR><BR>
<LI>isbn: 0446394319 or 0306806819 or 1567993850<BR><BR>
</UL><BR>You can use the following properties of a book in your search:<BR>
<UL><LI>Title<BR><BR><LI>Subject<BR><BR><LI>Author<BR><BR><LI>Keyword<BR><BR><LI>ISBN<BR><BR><LI>Publisher<BR><BR><LI>Language<BR><BR><LI>Publication date (pubdate)<BR><BR></UL><BR>
You can use the words <I>and</I>, <I>or</I>, and <I>not</I> 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.<BR>
];
}
}
$temp_result =~ s/(<!--apf[^!]+?![^!]*?!-->)/apf_commands($1,$lap);/egs;
$temp_result =~ s/%%(\w+)%%/${$1}/g;
return $temp_result;
}