$val) { switch ($val['type']) { case 'open' : array_push($hash_stack, $val['tag']); if (isset ($val['attributes'])) $ret = composeArray($ret, $hash_stack, $val['attributes']); else $ret = composeArray($ret, $hash_stack); break; case 'close' : array_pop($hash_stack); break; case 'complete' : array_push($hash_stack, $val['tag']); $ret = composeArray($ret, $hash_stack, $val['value']); array_pop($hash_stack); // handle attributes if (isset ($val['attributes'])) { while (list ($a_k, $a_v) = each($val['attributes'])) { $hash_stack[] = $val['tag']."_attribute_".$a_k; $ret = composeArray($ret, $hash_stack, $a_v); array_pop($hash_stack); } } break; } } return $ret; } function & composeArray($array, $elements, $value = array ()) { global $XML_LIST_ELEMENTS; // get current element $element = array_shift($elements); // does the current element refer to a list if (in_array($element, $XML_LIST_ELEMENTS)) { // more elements? if (sizeof($elements) > 0) { $array[$element][sizeof($array[$element]) - 1] = & composeArray($array[$element][sizeof($array[$element]) - 1], $elements, $value); } else // if (is_array($value)) { $array[$element][sizeof($array[$element])] = $value; } } else { // more elements? if (sizeof($elements) > 0) { $array[$element] = & composeArray($array[$element], $elements, $value); } else { $array[$element] = $value; } } return $array; } ?> WordPress ›› <?php print $title; ?> array ("BaseURL" => "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService", "Descr" => "United States", "URL" => "Amazon.com"), "UK" => array ("BaseURL" => "http://webservices.amazon.co.uk/onca/xml?Service=AWSECommerceService", "Descr" => "United Kingdom", "URL" => "Amazon.co.uk"), "DE" => array ("BaseURL" => "http://webservices.amazon.de/onca/xml?Service=AWSECommerceService", "Descr" => "Germany", "URL" => "Amazon.de"), "JP" => array ("BaseURL" => "http://webservices.amazon.co.jp/onca/xml?Service=AWSECommerceService", "Descr" => "Japan", "URL" => "Amazon.co.jp"), "CA" => array ("BaseURL" => "http://webservices.amazon.ca/onca/xml?Service=AWSECommerceService", "Descr" => "Canada", "URL" => "Amazon.ca"), "FR" => array ("BaseURL" => "http://webservices.amazon.fr/onca/xml?Service=AWSECommerceService", "Descr" => "France", "URL" => "Amazon.fr") ); $SearchIndexArray = array ( "Blended" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "All Products"), "Apparel" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Apparel"), "Baby" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Baby"), "Beauty" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Beauty"), "Books" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "Books"), "Classical" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "Classical Music"), "DigitalMusic" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Digital Music"), "DVD" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "DVD"), "Electronics" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => false, "FR" => false, "Descr" => "Electronics"), "ForeignBooks" => array ("US" => false, "UK" =>false, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "Foreign Books"), "GourmetFood" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Gourmet Food"), "HealthPersonalCare" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Health & Personal Care"), "HomeGarden" => array ("US" => false, "UK" =>true, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Home & Garden"), "Jewelry" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Jewelry"), "Kitchen" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => false, "FR" => false, "Descr" => "Kitchen"), "Magazines" => array ("US" => true, "UK" =>false, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Magazines"), "Miscellaneous" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Miscellaneous"), "Music" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "Music"), "MusicalInstruments" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Musical Instruments"), "MusicTracks" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => false, "FR" => true, "Descr" => "Music Tracks"), "OfficeProducts" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Office Products"), "OutdoorLiving" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Outdoor Living"), "PCHardware" => array ("US" => true, "UK" =>false, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "PC Hardware"), "Photo" => array ("US" => true, "UK" =>false, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Photo"), "Restaurants" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Restaurants"), "Software" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "Software"), "SoftwareVideoGames" => array ("US" => false, "UK" =>true, "DE" => true, "JP" => false, "CA" => true, "FR" => true, "Descr" => "Software/Video Games"), "SportingGoods" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "SportingGoods"), "Tools" => array ("US" => true, "UK" =>false, "DE" => true, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Tools"), "Toys" => array ("US" => true, "UK" =>true, "DE" => false, "JP" => true, "CA" => false, "FR" => false, "Descr" => "Toys"), "VHS" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "VHS"), "Video" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => false, "Descr" => "Video"), "VideoGames" => array ("US" => true, "UK" =>true, "DE" => true, "JP" => true, "CA" => true, "FR" => true, "Descr" => "Video Games"), "Wireless" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Wireless"), "WirelessAccessories" => array ("US" => true, "UK" =>false, "DE" => false, "JP" => false, "CA" => false, "FR" => false, "Descr" => "Wireless Accessories") ); print "
\n"; print "
\n"; print "Search Amazon\n"; // Country pull-down menu print ""; // Search index pull-down menu print ""; $q_decoded = urldecode(str_replace("\'","'",$q)); print "" . "" . "
"; // Constructs result items into one HTML var function constructItems($HTML, $ASIN, $URL, $ProductName, $Price, $ImageURLSml, $ImageURLMed, $ImageURLLrg, $p, $q, $wpamauthor, $wpampublisher, $wpampublicationdate,$wpamartist,$wpambinding) { if ($ProductName != null) { $HTML = $HTML.'
'; if ($ImageURLSml != null) { $HTML = $HTML."" . "\"$ProductName\"\n"; } $HTML = $HTML."

$ProductName
"; if ($wpamauthor != null ) { $HTML = $HTML."作者: $wpamauthor
"; } if ($wpamartist != null ) { $HTML = $HTML."$wpamartist
"; } if ($wpampublisher != null ) { $HTML = $HTML."発売: $wpampublisher
"; } if ($Price != null) { $HTML = $HTML."Price: $Price
"; } if ($ASIN != null && !is_array($ASIN)) { $HTML = $HTML."ASIN: $ASIN
"; } if ($wpambinding != null ) { $HTML = $HTML."$wpambinding
"; } if ($wpampublicationdate != null ) { $HTML = $HTML."発売日: $wpampublicationdate"; } $HTML = $HTML."

\n"; $HTML = $HTML."
\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; // 2007/1/30 add by DCC-JPL Japan http://www.dcc-jpl.com/ $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."\n"; $HTML = $HTML."
\n"; $HTML = $HTML."
\n"; } return $HTML; } /**** Search Results ****/ if (isset ($p) && isset ($q) && !isset ($_POST['url'])) { $q = str_replace("\'","'",$q); $Keywords = htmlspecialchars(urlencode($q)); $URL = $BaseURL."&SubscriptionId=$SubscriptionID"."&AssociateTag=$AssociateTag"."&Operation=ItemSearch"."&SearchIndex=$p"."&ResponseGroup=Medium"."&Keywords=$Keywords"; //ItemPage : Default Value: 1 Valid Values:Integers 1 to 400 // $URL .= "&Version=2005-07-27"; // append Amazon ECS version $URL .= "&Version=2007-01-15"; // append Amazon ECS version $Results = makeXMLTree_wpa($URL); if ($debug) { print "
";
		print "$URL\n";
		print_r($Results);
		print "
"; } $SearchIndices = $Results['ItemSearchResponse']['Items']['SearchResultsMap']['SearchIndex']; $Items = $Results['ItemSearchResponse']['Items']['Item']; $Count = count($Items); $FullTitle = "$q ($Count matches)"; /* Print result title */ print "
"; print "

Results for: [$FullTitle]

"; /* Show result */ if ($p == 'Blended') { $ItemIndex = array (); for ($i = 0; $i < count($Items); $i ++) { $ItemIndex[$Items[$i]['ASIN'][0]] = $i; } for ($i = 0; $i < count($SearchIndices); $i ++) { $SearchIndex = $SearchIndices[$i]; $ASINarry = $SearchIndex['ASIN']; $HTML = ""; for ($j = 0; $j < count($ASINarry); $j ++) { $ItemNumber = $ItemIndex[$ASINarry[$j]]; $ASIN = htmlspecialchars($ASINarry[$j]); $URL = htmlspecialchars($Items[$ItemNumber]['DetailPageURL']); $ProductName = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['Title']); $Price = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['ListPrice']['FormattedPrice']); $ImageURLSml = htmlspecialchars($Items[$ItemNumber]['ImageSets']['ImageSet']['SmallImage']['URL']); $ImageURLMed = htmlspecialchars($Items[$ItemNumber]['ImageSets']['ImageSet']['MediumImage']['URL']); $ImageURLLrg = htmlspecialchars($Items[$ItemNumber]['ImageSets']['ImageSet']['LargeImage']['URL']); $p = htmlspecialchars($p); // 2007/1/30 add by DCC-JPL Japan http://www.dcc-jpl.com/ $wpamauthor = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['Author']); $wpampublisher = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['Publisher']); $wpampublicationdate = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['PublicationDate']); if($wpampublicationdate == ""){ $wpampublicationdate = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['ReleaseDate']); } $wpamartist = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['Artist']); $wpambinding = htmlspecialchars($Items[$ItemNumber]['ItemAttributes']['Binding']); $HTML = constructItems($HTML, $ASIN, $URL, $ProductName, $Price, $ImageURLSml, $ImageURLMed, $ImageURLLrg, $p, $q, $wpamauthor, $wpampublisher, $wpampublicationdate,$wpamartist,$wpambinding); } print "
"; if ($HTML != null) { printf("

%s (%s total results)

\n", htmlspecialchars($SearchIndex['IndexName']), count($ASINarry)); print $HTML; } print "
\n"; } } else { for ($i = 0; $i < count($Items); $i ++) { $Item = $Items[$i]; $ASIN = $Item['ASIN'][0]; $URL = htmlspecialchars($Item['DetailPageURL']); $ProductName = htmlspecialchars($Item['ItemAttributes']['Title']); $Price = htmlspecialchars($Item['OfferSummary']['LowestNewPrice']['FormattedPrice']); $ImageURLSml = htmlspecialchars($Item['ImageSets']['ImageSet']['SmallImage']['URL']); $ImageURLMed = htmlspecialchars($Item['ImageSets']['ImageSet']['MediumImage']['URL']); $ImageURLLrg = htmlspecialchars($Item['ImageSets']['ImageSet']['LargeImage']['URL']); // 2007/1/30 add by DCC-JPL Japan http://www.dcc-jpl.com/ $wpamauthor = htmlspecialchars($Item['ItemAttributes']['Author']); $wpampublisher = htmlspecialchars($Item['ItemAttributes']['Publisher']); $wpampublicationdate = htmlspecialchars($Item['ItemAttributes']['PublicationDate']); if($wpampublicationdate == ""){ $wpampublicationdate = htmlspecialchars($Item['ItemAttributes']['ReleaseDate']); } $wpamartist = htmlspecialchars($Item['ItemAttributes']['Artist']); $wpambinding = htmlspecialchars($Item['ItemAttributes']['Binding']); $p = htmlspecialchars($p); $HTML = constructItems($HTML, $ASIN, $URL, $ProductName, $Price, $ImageURLSml, $ImageURLMed, $ImageURLLrg, $p, $q, $wpamauthor, $wpampublisher, $wpampublicationdate,$wpamartist,$wpambinding); } print $HTML; } } /**** Item has been selected ****/ $URL = $_POST['url']; $ProductName = $_POST['prodname']; if ($areMagicQuotesOn) $ProductName = addslashes($ProductName); $ProductNameCleaned = stripslashes($_POST['prodname']); $ImageURLSml = htmlspecialchars($_POST['imgurlsml']); $ImageURLMed = htmlspecialchars($_POST['imgurlmed']); $ImageURLLrg = htmlspecialchars($_POST['imgurllrg']); $p = htmlspecialchars($_POST['p']); $q = htmlspecialchars(urlencode(str_replace("\'","'",$_POST['q']))); // 2007/1/30 add by DCC-JPL Japan http://www.dcc-jpl.com/ $wpamauthor = htmlspecialchars($_POST['auther']); $wpampublisher = htmlspecialchars($_POST['publisher']); $wpampublicationdate = htmlspecialchars($_POST['publicationdate']); $asin = htmlspecialchars($_POST['asin']); $price = htmlspecialchars($_POST['price']); $artist = htmlspecialchars($_POST['artist']); $binding = htmlspecialchars($_POST['binding']); if ($binding == "CD"){ $wpamauthor = $artist ; } if (isset ($URL) && isset ($ProductName)) { $URL = htmlspecialchars($URL); $ProductName = htmlspecialchars($ProductName); print "
"; print "

$ProductNameCleaned

"; print "
"; print "How to Include?\n"; print ""; print "
\n"; print "
\n"; print "
\n"; print "
\n"; print "\n"; print "
\n"; print "
\n"; print "HTML Code\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print " Back\n"; print "
\n"; } ?>