Jump to content

Recommended Posts

Hi Guys I needed some help with this script http://apf.sourceforge.net/ I found on the web.

 

it has these instructions to install it

 

INSTALL:

 

1) Download the script archive and unpack the contents to a directory on your

    machine.

 

2) Make a new directory on your server, e.g. .../cgi-bin/aws.

 

3) Upload the APF files to the new .../cgi-bin-aws directory.

 

4). Ensure the CGI files 'apf.cgi', 'apf_test.cgi', and 'apf_config.cgi' have

    execute permissions set, e.g. chmod 755 *.cgi.

 

5). Use your browser to go directly to the 'apf_config.cgi' file on your server,

    e.g. http://www.MY-DOMAIN.com/public_html/cgi-bin/aws/apf_config.cgi.

 

6). Because this is you first usage, you will have to enter a password and save

    it -- write the password down for use later

 

7). Enter your Amazon IDs, AWS 'Access Key ID', and AWS 'Secret Access Key',

    and your default locale, you can leave most of the other fields unchanged,

    then enter your password and 'Save'.

 

8) Test your efforts by using your browser to go to

    http://www.MY-DOMAIN.com/cgi-bin/aws/apf4_test.cgi and you should see Amazon

    debug confirmation stuff with Labb's default template

 

9). Change the page, product, and item template in the

    .../cgi-bin/aws/templates/default directory to your defaults and you should

    see your webpages with the Amazon debug messages. You also should copy over

    the contents of any other template directories that you are currently using

    into the new '...cgi-bin/aws' directory.

 

10). Now try it with the web link going to the '...cgi-bin/aws/apf4.cgi' in lieu

    of the '...cgi-bin/aws/apf4_test.cgi' and everything should work without

    the Amazon test messages.

 

11) To go operational, just change your real links to use

    '...cgi-bin/aws/apf4.cgi' in lieu of your previous script.

 

12) Optionally you can remove the apf4_test.cgi, as it is only needed for

    debugging purposes and is exactly the same as apf4.cgi.

 

 

 

ok I'm up to this part here

 

5). Use your browser to go directly to the 'apf_config.cgi' file on your server,

    e.g. http://www.MY-DOMAIN.com/public_html/cgi-bin/aws/apf_config.cgi.

 

6). Because this is you first usage, you will have to enter a password and save

    it -- write the password down for use later

 

but when I go there http://mypcmates.com/aws/apf_config.cgi it's not asking for a password what am I doing wrong? I'm new at this so yeah....

Link to comment
https://forums.phpfreaks.com/topic/219134-apf4-amazon-script-help/
Share on other sites

ok any way done a bit more I started this from scratch and went through it all again. before I had it all in AWS folder on my server, now I did it all again and put it in cgi-bin folder, now I get to these steps

 

5). Use your browser to go directly to the 'apf_config.cgi' file on your server,

e.g. http://www.MY-DOMAIN.com/public_html...apf_config.cgi.

 

6). Because this is you first usage, you will have to enter a password and save

it -- write the password down for use later

 

Now I get this error "

Forbidden

 

You don't have permission to access /cgi-bin/ on this server." I set the permissions to allow read/write access on the ubuntu server by right clicking the folder and setting them but I still get the "

 

Forbidden

 

You don't have permission to access /cgi-bin/ on this server." error got any ideas

ok I found a better script and got it working I really need some help with this being fairly new at in and chucking myself in the deep end at the moment I'm trying to get this page http://mypcmates.com/aws/amazonv4.php which runs a scripts, this is the code from that page

 

<?php
//amazonv4.php
//stand-alone PHP example script to use the Amazon Web Services interface
//written by Jaap van Ganswijk (JvG) <ganswijk@xs4all.nl>
//you can use this version under any version of the GPL (GNU Public License)
//20020816/JvG, released under the GNU GPL
//...
//20090623/JvG, busy adding the signing that Amazon requires from 20090815
//20090804/JvG, refixed the do/du problem for used products (which had gone after going back to an old version) and added the (server) locale functionality to the signed version
//20090804/JvG, rewrote the scripts to make the new version (with signing) more like the old version so that the caching would work again but didn't test it yet, this also made show_url work again
//20090812/JvG, added the comments for 20090804 and 20090812 and tested the caching and I am going to try to put the script online
//20090816/JvG, always use signed request, started adding better time measurement
//20090826/JvG, script will now create cache directory itself
//20090826/JvG, got simplexml object printing working
//20090827/JvG, added printing a simple HTML-header to have utf8 rendered correctly
//20090827/JvG, added the $tab variable in all echo statements so all HTML is indented properly
//20090827/JvG, removed a lot of old outdated messages from this list
//20091105/JvG, separated the AWS requesting part to aws.php

//Thanks for all the questions, improvement tips and help!
//Feel free to send more feedback to me at ganswijk@xs4all.nl!
//Please mention AWS or Amazon in the subject line to avoid my spamfilters

error_reporting(error_reporting()&~E_NOTICE);  //this prevents a lot of warnings on a Windows server, but you can comment-out this line for debugging

$Amicrotime['total'][0]=getmicrotime();  //time at start of total process

//send html-header so utf8's are correctly shown
echo "<html>\n";
echo "  <head>\n";
echo "    <meta **********='content-Type' content='text/html; charset=utf-8' />\n";
echo "  </head>\n";
echo "  <body>\n";

$tab='    ';  //tab how much?

if (!defined($jaap)) $jaap=$false;  //($_SERVER['PHP_SELF']=='/jaap/php/amazon/amazonv4.php' or $_SERVER['PHP_SELF']=='/jaap/php_linux/amazon/amazonv4.php');  //I use this flag to develop new things for the script on my local PC.

$jb=false;  //this is a test for someone, please change it to false if it isn't already

//Set these to correspond with your site.
//This will determine the first results that the user will see.
//The user can overrule them using the search form.
$Adefault=array(
  'language'           =>'en',           //what language to render the page in
  'locale'             =>'us',           //which server's products? available: ca,de,fr,jp,uk,us
//'mode'               =>'books',        //what product category?
  'page'               =>1,              //first page to show (we are counting from 1 not 0)
//'search'             =>'Machiavelli',  //what to search for?
  'operation'          =>'ItemSearch',   //what to do?
  'searchindex'        =>'Books',        //what product category for search?
  'searchparameter'    =>'Author',       //what kind of search?
  'searchparameterdata'=>'Machiavelli',  //what to search for?
  //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true'
  'jaap'               =>false,          //my own debugflag to test new things
  'show_array'         =>false,          //debug: show complete incoming array? You can use this to see what other information Amazon is sending
  'show_url'           =>false,          //debug: show XML request url to be send to Amazon?
  'show_xml'           =>false,          //debug: show incoming XML code from Amazon?
);
//change the debug options to true if you want to activate them or call the script with '?show_array=true' to see what actual information you're getting from Amazon and how little my standard script is actually showing of it

require_once "data.php";      //static data about Amazon (servers, search fields) v3-
require_once "data_v4.php";   //static data about Amazon (servers, search fields) v4+
require_once "language.php";  //translate the output to the prefered language of the user
require_once "aws.php";       //see: http://mierendo.com/software/aws_signed_query/, please note that I'm using an slightly adapted version of the script: I do my own XML-interpreting

//20090624: the following isn't relevant anymore it seems, 20091122: yes it is!
$Aassociates_id=array(
  'de'=>'chipdir00' ,  // <-- replace with your amazon.de    associate ID, or leave it as it is
  'fr'=>'chipdir010',  // <-- replace with your amazon.fr    associate ID, or leave it as it is
  'jp'=>'INVALID'   ,  // <-- replace with your amazon.co.jp associate ID, or leave it as it is
  'uk'=>'chipdir03' ,  // <-- replace with your amazon.co.uk associate ID, or leave it as it is
  'us'=>'chipdir'   ,  // <-- replace with your amazon.com   associate ID
);
//If you haven't gotten your own associate ID yet, get it from:
//http://associates.amazon.com/exec/panama/associates/apply
//
//Normally you will want to start selling books via Amazon.com only,
//just to see if it works and pays well (which it normally doesn't).
//
//You can save yourself a lot of trouble by not applying for an associate ID
//at the other local Amazon sites yet, but leaving mine in for the time being
//and perhaps I'll make a few pounds, euro's and/or yen. As soon as I would
//receive a noticable amount of cash I'll track you down an will warn you
//to get your own ID's there.
//
//please note that all those local Amazons send out all of their communications
//in their local languages, so French, German and Japanese for example and
//that you first have to earn enough money per branch before you get paid.
//And the Japanese branch only seems to pay in gift-certificates, so you'd
//have to buy Japanese books for example.
//
//if you want to disable any of the foreign branches, please do so in the
//file data.php, but please consider that we're living in an ever better
//connected world and sometime later you might want to add them again
//if only as a service to your visitors.

//other flags:
//this doesn't seem to be relevant anymore:
//$f_rich=true;       //when set to true this will convert the URL so you'll get 7.5% on qualifying books instead of 5%. It doesn't work yet outside of the USA.
                      //change it to false when you prefer to get only 5% ;-)
                      //see http://forums.prospero.com/n/mb/message.asp?webtag=am-assosdev&msg=6.1&ctx=0, or search the forum for 'nosim'
                      //This is only helpful for certain books
                      //correction: keep this option set to true, to prevent the showing of Amazon's annoying distraction pages.
                      //20080530: i don't know if this is still relevant for version 4
$f_user_search=true;  //add a user search form and allow user searches?

//=============================================================================
//==You don't have to change anything below this line to start earning money.==
//=============================================================================

if ($jaap) {
  print_array($_GET,$tab);
}

//what are the user's prefered languages?
$Ahttp_lang=split(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);

if ($jaap) {
  print_array($Ahttp_lang,$tab);
}

//try to find the visitor's prefered language, this is still experimental
foreach ($Ahttp_lang as $i=>$d) {
  if ($Axl[$l=substr($d,0,2)]) {
    $pref_lang=$l;
    break;
  }
}

if (isset($pref_lang)) {
  $Adefault['language']=$pref_lang;
  if ($jaap) {
    echo $tab."prefered available language='$pref_lang'<br />\n";
  }
}

//for all parameters see if the user has overruled it or use the default
foreach ($Adefault as $i=>$d) {
  $$i=isset($_GET[$i])?$_GET[$i]:$d;
  if ($jaap) echo $tab."$i = '".$$i."'<br />\n";
}

//this is a test for someone:
if ($jb) {
  $operation ='SellerListingSearch';
  $show_array=1;
}

//use which servers?
//$norserver=$Aserver[$locale]['nor'];
//$xmlserver=$Aserver[$locale]['xml'];

//20090817: this is no longer used it seems:
//$dev_token='D2WMCOIPS9D14E';
//you can replace this with your own developer token after you have changed the script a lot
//get one from http://associates.amazon.com/exec/panama/associates/join/developer/application.html
//see:
//http://forums.prospero.com/n/mb/message.asp?webtag=am-assocdevxml&msg=378.1&ctx=0

//this is the data that is used to form the request for AWS
//this is the part that is search specific
if ($jb) {  //this is a test for someone
  $parameters=array(
    'Operation'       =>$operation              ,
    'SellerId'        =>'A23I0F0MWQH94Z'        ,
//  'Keywords'        =>urlencode($search)      ,
//  'SearchIndex'     =>$searchindex            ,  //Books for example.
//  "$searchparameter"=>$searchparameterdata    ,
    'ItemPage'        =>$page                   ,  //which page?
//  'Service'         =>'AWSECommerceService'   ,  //this makes it version 4
//  'SubscriptionId'  =>$subscriptionid         ,  //is this correct?
//  'AWSAccessKeyId'  =>$awsaccesskeyid         ,  //is this correct?
    'AssociateTag'    =>$Aassociates_id[$locale],
//  'ResponseGroup'   =>'Medium'                ,  //Small, Medium or Large
    'ResponseGroup'   =>'SellerListing'         ,  //Small, Medium, Large or SellerListing
  );
}
else {
  $parameters=array(
    'Operation'       =>$operation              ,
    'Keywords'        =>urlencode($search)      ,
    'SearchIndex'     =>$searchindex            ,  //Books for example.
    "$searchparameter"=>$searchparameterdata    ,
    'ItemPage'        =>$page                   ,  //which page?
//  'Service'         =>'AWSECommerceService'   ,  //this makes it version 4
//  'SubscriptionId'  =>$subscriptionid         ,  //is this correct?
//  'AWSAccessKeyId'  =>$awsaccesskeyid         ,  //is this correct?
    'AssociateTag'    =>$Aassociates_id[$locale],
    'ResponseGroup'   =>'Medium'                ,  //Small, Medium, Large or SellerListing
  );
}

$A=aws_request($parameters);  //do the AWS request via cache and decode the XML

//debug:
if ($jaap) {
  echo $tab."<hr />\n";
  echo $tab."<pre>\n";
  print_r    ($A);
  echo $tab."</pre>\n";
//echo $tab."<hr />\n";
//echo $tab."<pre>\n";
//var_dump   ($A);
//echo $tab."</pre>\n";
//echo $tab."<hr />\n";
//echo $tab."<pre>\n";
//var_export ($A);
//echo $tab."</pre>\n";
  echo $tab."<hr />\n";
  print_array($A);
  echo $tab."<hr />\n";
}

$Amicrotime['XML'][1]=getmicrotime();        //time after XML decoding

//debug: show the array or object
//you can easily use this debugging tool by adding '&show_array=1' to the URL of this script
if ($show_array) {       //show the array for debugging?
  print_array($A,$tab);  //show the complete array
}

//show the stuff

$Amicrotime['show'][0]=getmicrotime();         //time before showing stuff

echo $tab."<h2>".xu('searching for')." '$searchparameterdata'</h2>\n";  //you can change the h2's to h1's

//20090827/old code:
//if ($e=$error_msg) {
//  switch ($Aerror[$e]) {
//  case 'print':
//    echo $tab."$e<br />\n";
//    break;
//  default:
//    echo $tab.xu('Amazon returned the error').': '.$e."<br />\n";
//    echo $tab."<br />\n";
//    echo $tab.xu('please add this error message to the ').
//          "<a href='http://www.chipdir.nl/amazon/errorlist.php?do=add&da=".urlencode($e)."&ur=".$file."'>".
//          xl('database')."</a>.<br />\n";
//    break;
//  }
//}

//$jaap=true;
//actually show the products:

//echo $A->Items->Request->IsValid;

if (isset($A->Error)) {
  $c=$A->Error->Code;
  $e=$A->Error->Message;
  echo $tab."Amazon error: $c: $e<br />\n";
}
else if ($A->Items->Request->IsValid!='True') {
  $c=$A->Items->Request->Errors->Error->Code;
  $e=$A->Items->Request->Errors->Error->Message;
  echo $tab."Amazon error: $c: $e<br />\n";
}
else {
  print_products($A,$tab);
}

//print all the products
function print_products($A,$tab='') {
  global $jaap;
  global $language;
  global $locale;
  global $operation;
  global $page;
  global $search;
  global $searchparameter;
  global $searchparameterdata;

  switch ($operation) {
  case 'SellerListingSearch':
    die("sorry but SellerListingSearch doesn't work yet");
    $items  =$A['SellerListingSearchResponse']['SellerListings'];
    $subnode='SellerListing';
    break;
  default:
//  $items=$A['ItemSearchResponse']['Items'];  //old
//  $subnode='Item';
//  break;
    if ($jaap) {
      echo $tab."in print_products():<br />\n";
      echo $tab."A:<br />\n";
      print_array($A,$tab='');
    }
    $items    =$A    ->Items;
//  $items_sub=$items->Item;
    $aitems=(array)$items;       //it is very strange that this and the next line works and not the outcommented line before this one
    $items_sub=$aitems['Item'];
    if ($jaap) {
      echo $tab."items:<br />\n";
      echo $tab."<pre>\n";
      print_r($items);
      echo $tab."</pre>\n";
      echo $tab."items:<br />\n";
      print_array($items,$tab='');
      echo $tab."items->Item:<br />\n";
      echo $tab."<pre>\n";
      print_r($items->Item);
      echo $tab."</pre>\n";
      echo $tab."items->Item:<br />\n";
      print_array($items->Item,$tab='');
      echo $tab."items_sub:<br />\n";
      echo $tab."<pre>\n";
      print_r($items_sub);
      echo $tab."</pre>\n";
      echo $tab."items_sub:<br />\n";
      print_array($items_sub,$tab='');
    }
    break;
  }
  $npro=$items->TotalResults;
  $npag=$items->TotalPages;
  echo $tab."<b>".xu('number of products').": $npro</b><br />\n";
  echo $tab."<b>".xu('page').' '.($page).' '.xl('of').' '.((int)$npag)."</b><br />\n";
  echo $tab."<p />\n";
  echo $tab."<table border='1'>\n";
  echo $tab."  <tbody>\n";
  if (is_array($items_sub) and $items_sub[0]) {
    foreach ($items_sub as $i=>$E) {
      print_product($E,$tab.'    ');
    }
  }
  else {
    print_product($D,$tab.'    ');
  }
  echo $tab."  </tbody>\n";
  echo $tab."</table>\n";
  //provide links to previous and next page
  if ($npag>1) {
    //echo $tab."<hr>\n";
    echo $tab.xu('page:')."\n";
    echo $tab.make_link_to_page(1,1)."\n";
    echo $tab.make_link_to_page(2,2)."\n";
    if ($page>=2) {
      echo $tab.make_link_to_page($page-1,'<')."\n";
    }
    if ($page<$npag) {
      echo $tab.make_link_to_page($page+1,'>')."\n";
    }
    echo $tab.make_link_to_page($npag,$npag)."\n";
  }
}

//print one Amazon product
//version 4
function print_product($E,$tab) {
//global $Aassociates_id;
//global $dev_token;
//global $f_rich;          //do you want 15% or 5%? (only for discounted books), 20090624: I don't know if this is still relevant
  global $jaap;
  global $locale;
//global $norserver;

  if ($E) {
    if ($jaap) echo $tab."print_product()<br />\n";
    $url=$E->DetailPageURL;
    if ($jaap) echo $tab."url=$url<br />\n";
    $E2A=(array)$E;
    $url=$E2A['DetailPageURL'];
    if ($jaap) echo $tab."url=$url<br />\n";
    if ($jaap) print_array($E2A);
    //print_array($E);
    //rebuild the URL if you want 15% instead of 5%:
//20090804/wjvg: changed this:
//  $url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/ref=nosim/'.$Aassociates_id[$locale].'?dev-t='.$dev_token:$E['url'];
    //$url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/'.$Aassociates_id[$locale]:$E['url'];
    echo $tab.    "<tr>\n";
    echo $tab.    "  <td align='center'>\n";
    if ($d=$E->MediumImage) {
      $iu=$d->URL;
      $ih=$d->Height;
      $iw=$d->Width;
      echo $tab.  "    <a href='$url'><img src='$iu' width='$iw' height='$ih' border='0'></a>\n";
    }
    echo $tab.    "  </td>\n";
    echo $tab.    "  <td align='center'>\n";
    if ($d=$E->ItemAttributes->Title) {
      echo $tab.  "    <a href='$url'>$d</a><br />\n";
    }
    if (is_array($dd=$E->ItemAttributes->Author)) {
      echo $tab.  "    ".xl('by').": ";
      foreach ($dd as $i=>$d) {
        if ($i) echo ', ';
        //echo $tab."<a href="<b>$d</b>";
        echo "<b>$d</b>";
      }
      echo "<br />\n";
    }
    else if ($d=$dd) {
      echo $tab.  "    ".xl('by').": <b>$d</b><br />\n";
    }
    $dm=$E->ItemAttributes->Publisher;
    $dr=$E->ItemAttributes->PublicationDate;
    if ($dm or $dr) {
      echo $tab.  "    ";
      if ($dm) {
        echo xl('publisher').": <b>$dm</b>";
      }
      if ($dm and $dr) echo ', ';
      if ($dr) {
        echo xl('published').": <b>$dr</b>";
      }
      echo "<br />\n";
    }
    if ($asin=$E->ASIN) {
      echo $tab.  "    ASIN: <b>$asin</b><br />\n";
    }
    if ($ean=$E->ItemAttributes->EAN) {
      echo   $tab."    EAN: <b>$ean</b><br />\n";
    }
    //$da=$E->Reviews->AvgCustomerRating;  //not in Medium Set?
    $da=false;  //don't show
    $ds=$E->SalesRank;
    if ($da or $ds) {
      echo $tab.  "    ";
      if ($ds) echo xl('sales rank').": <b>$ds</b>";
      if ($da and $ds) echo ", ";
      if ($da) echo $tab.xl('customer rating').": <b>".(($da-1)*25)."%</b>";
      echo "<br />\n";
    }
    $do=$E->OfferSummary->LowestNewPrice ->FormattedPrice;
    $du=$E->OfferSummary->LowestUsedPrice->FormattedPrice;
    if ($do or $du) {
      echo $tab.  "    ".xl('price').": ";
      if ($do) echo "<b>$do</b> (".xl('new').")";
      if ($do and $du) echo ", ";
      if ($du) echo "<b>$du</b> (".xl('used').")";
      echo "<br />\n";
    }
    echo $tab.    "  </td>\n";
    if ($EditorialReviews=$E->EditorialReviews and
        $EditorialReview=$EditorialReviews->EditorialReview and
        $Content=$EditorialReview->Content) {
      echo $tab.  "  <td align='center'>\n";
      echo $tab.  "    $Content\n";
      echo $tab.  "  </td>\n";
    }
    echo $tab.    "</tr>\n";
  }
}

//make link to other page (next, previous etc.)
function make_link_to_page($page,$s) {
  global $language;
  global $locale;
  global $search;
  global $searchindex;
  global $searchparameter;
  global $searchparameterdata;

  return "<a href='?".
         'language'           .'='.$language                      .'&'.
         'locale'             .'='.$locale                        .'&'.
         'page'               .'='.$page                          .'&'.
         'searchindex'        .'='.$searchindex                   .'&'.
         'searchparameter'    .'='.$searchparameter               .'&'.
         'searchparameterdata'.'='.urlencode($searchparameterdata).'&'.
         "'>".xu($s)."</a>";
}

//print an array or object
//(for debugging)
function print_array($A,$tab='') {
  if (is_object($A)) {
    echo   $tab."object:<br >\n";
    print_array((array)$A,$tab);
  }
  else if (is_array($A)) {
//  print_r($A);
    echo   $tab."<table border='1'>\n";
    echo   $tab."  <tbody>\n";
//  echo   $tab."    COUNT=".count($A)."\n";
//  if (is_object($A)) {
//    echo   $tab."    COUNT=".count($A)." - ".$A['0']."\n";
//  }
    foreach ($A as $i=>$d) {
      echo   $tab."    <tr>\n";
      echo   $tab."      <td valign='top'>$i</td>\n";
//    print_r($d);
      if (is_string($d)) {
//      echo $tab."      STRING\n";
//      print_r($d);
//      echo $tab."      <td><pre>".htmlentities($d)."</pre></td>\n";
        echo $tab."      <td>".htmlentities($d)."</td>\n";
      }
      else if (is_array($d)) {
//      echo $tab."      ARRAY or OBJECT\n";
        echo $tab."      <td>\n";
        print_array($d,$tab.'        ');
        echo $tab."      </td>\n";
      }
      else if (is_object($d)) {
//      echo $tab."      ARRAY or OBJECT\n";
        echo $tab."      <td>object:\n";
        print_array((array)$d,$tab.'        ');
        echo $tab."      </td>\n";
      }
      else {
//      echo $tab."      ELSE\n";
//      print_r($d);
//      echo $tab."      <td><pre>".htmlentities($d)."</pre></td>\n";
        echo $tab."      <td>".htmlentities($d)."</td>\n";
      }
      echo   $tab."    </tr>\n";
    }
    echo     $tab."  </tbody>\n";
    echo     $tab."</table>\n";
  }
  else {
    echo $tab."warning: not-an-array-or-object given to print_array()<br />\n";
  }
}

function getmicrotime() {
  list($us,$s)=explode(' ',microtime());
  return (float)$us+(float)$s;
}

if ($f_user_search) {
  //the next section adds a search box for the users
  echo $tab.  "<hr />\n";
  echo $tab.  "<form method='get' action='?'>\n";
  //echo $tab."  <input type='hidden' name='language' value='$language' />\n";
  //echo $tab."  <input type='hidden' name='locale'   value='$locale'   />\n";
  //echo $tab."  <input type='text'   name='ty'>Search type</input><br />\n";
  echo $tab.  "  <table>\n";
  echo $tab.  "    <tbody>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('language for page:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='language'>\n";
  foreach ($Alanguage as $i=>$d) {
    echo $tab."            <option value='$i'".($i==$language?" selected='true'":"").">".xu($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('which server:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='locale'>\n";
  foreach ($Alocale as $i=>$d) {
    echo $tab."            <option value='$i'".($i==$locale?" selected='true'":"").">".xl($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('operation:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='operation'>\n";
  foreach ($Aoperation as $i=>$d) {
    echo $tab."            <option value='$i'".($i==$operation?" selected='true'":"").">".xu($i)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('product category:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='searchindex'>\n";
  foreach ($Asearchindex as $i=>$d) {  //uk and jp not ready yet? 20080730: must be adjusted to the locale again
    echo $tab."            <option value='$d'".($d==$searchindex?" selected='true'":"").">".xl($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('search parameter:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='searchparameter'>\n";
  foreach ($Aoperation['ItemSearch']['RequiredParameters']['SearchIndex'] as $i=>$d) {
    echo $tab."            <option value='$d'".($d==$searchparameter?" selected='true'":"").">".xu($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('search string:')."</td>\n";
  echo $tab.  "        <td><input type='text' name='searchparameterdata' value='$searchparameterdata' /></td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "    </tbody>\n";
  echo $tab.  "  </table>\n";
  echo $tab.  "  <input type='submit' value='Search' />\n";
  echo $tab.  "</form>\n";
  //end of the search box section
}

//phpinfo();

$Amicrotime['show' ][1]=getmicrotime();  //time after showing
$Amicrotime['total'][1]=getmicrotime();  //time at end

//The next part is to show if the script isn't overburdoning your server. (The time waiting for Amazon isn't burdoning your server). You can remove the next part if you like:
echo $tab."<hr />\n";
//echo("Time used for time-consuming parts:<br />\n");
echo $tab."Time used:<br />\n";
foreach ($Amicrotime as $i=>$d) {
  //if ($d[1]>$d[0]) {
    printf($tab."- %.2f s %s<br />\n",$d[1]-$d[0],$i);
  //}
}
//20091129/wjvg: you may remove these lines or move them to an about section of your site:
echo $tab."<hr />\n";
echo $tab."This script is GPL'ed and can be downloaded from <a href='http://www.chipdir.nl/amazon/'>this page</a>.<br />\n";

echo "  </body>\n";
echo "</html>\n";

//end

what I'm trying to workout to do before I go messing around with this script is to get it working in this pagehttp://mypcmates.com/pcparts.php

if you look there you will see this text "Your text here test" to change this text you edit this page \styles\X_Silver\template\pcparts_body.html

 

<!-- INCLUDE overall_header.html -->

<!--
    Your page can be changed to what ever you want displayed in this location.  Now if you change the name
    of the file from something different then pcpart_body.html make sure you also make the chagne in
    php file as well.
    
-->

<div class="c-h-l"><div class="c-h-r"><div class="c-h-c"><div class="c-h-title"><h4>Your Page</h4> </div></div></div></div>
<div class="v-left"><div class="v-right">
    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>
<!--
    Then information you wish to add to this page will go between the <div class="content"> and its closing div
    </div>  you do not have to use the paragraphp codes if you do not wish.
-->

       <div class="content">
          <p>
             Your text here test
          </p>
       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>
</div></div>    
<div class="c-f-l"><div class="c-f-r"><div class="c-f-c"></div></div></div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->

it would be great if you could help me work this out

update I have added the code from amazonv4.php into pcparts_body.html code below

 

<!-- INCLUDE overall_header.html -->

<!--
    Your page can be changed to what ever you want displayed in this location.  Now if you change the name
    of the file from something different then yourpage_body.html make sure you also make the chagne in
    php file as well.
    
-->

<div class="c-h-l"><div class="c-h-r"><div class="c-h-c"><div class="c-h-title"><h4>My PC Mates aStore Powered By Amazon</h4> </div></div></div></div>
<div class="v-left"><div class="v-right">
    <div class="panel">
       <div class="inner"><span class="corners-top"><span></span></span>
<!--
    Then information you wish to add to this page will go between the <div class="content"> and its closing div
    </div>  you do not have to use the paragraphp codes if you do not wish.
-->

       <div class="content">
Your text here test
<?php
//amazonv4.php
//stand-alone PHP example script to use the Amazon Web Services interface
//written by Jaap van Ganswijk (JvG) <ganswijk@xs4all.nl>
//you can use this version under any version of the GPL (GNU Public License)
//20020816/JvG, released under the GNU GPL
//...
//20090623/JvG, busy adding the signing that Amazon requires from 20090815
//20090804/JvG, refixed the do/du problem for used products (which had gone after going back to an old version) and added the (server) locale functionality to the signed version
//20090804/JvG, rewrote the scripts to make the new version (with signing) more like the old version so that the caching would work again but didn't test it yet, this also made show_url work again
//20090812/JvG, added the comments for 20090804 and 20090812 and tested the caching and I am going to try to put the script online
//20090816/JvG, always use signed request, started adding better time measurement
//20090826/JvG, script will now create cache directory itself
//20090826/JvG, got simplexml object printing working
//20090827/JvG, added printing a simple HTML-header to have utf8 rendered correctly
//20090827/JvG, added the $tab variable in all echo statements so all HTML is indented properly
//20090827/JvG, removed a lot of old outdated messages from this list
//20091105/JvG, separated the AWS requesting part to aws.php

//Thanks for all the questions, improvement tips and help!
//Feel free to send more feedback to me at ganswijk@xs4all.nl!
//Please mention AWS or Amazon in the subject line to avoid my spamfilters

error_reporting(error_reporting()&~E_NOTICE);  //this prevents a lot of warnings on a Windows server, but you can comment-out this line for debugging

$Amicrotime['total'][0]=getmicrotime();  //time at start of total process

//send html-header so utf8's are correctly shown
echo "<html>\n";
echo "  <head>\n";
echo "    <meta **********='content-Type' content='text/html; charset=utf-8' />\n";
echo "  </head>\n";
echo "  <body>\n";

$tab='    ';  //tab how much?

if (!defined($jaap)) $jaap=$false;  //($_SERVER['PHP_SELF']=='/jaap/php/amazon/amazonv4.php' or $_SERVER['PHP_SELF']=='/jaap/php_linux/amazon/amazonv4.php');  //I use this flag to develop new things for the script on my local PC.

$jb=false;  //this is a test for someone, please change it to false if it isn't already

//Set these to correspond with your site.
//This will determine the first results that the user will see.
//The user can overrule them using the search form.
$Adefault=array(
  'language'           =>'en',           //what language to render the page in
  'locale'             =>'us',           //which server's products? available: ca,de,fr,jp,uk,us
//'mode'               =>'books',        //what product category?
  'page'               =>1,              //first page to show (we are counting from 1 not 0)
//'search'             =>'Machiavelli',  //what to search for?
  'operation'          =>'ItemSearch',   //what to do?
  'searchindex'        =>'Books',        //what product category for search?
  'searchparameter'    =>'Author',       //what kind of search?
  'searchparameterdata'=>'Machiavelli',  //what to search for?
  //here some debugging flags you can put at the end of the URL to call this script with, like: '?show_array=true'
  'jaap'               =>false,          //my own debugflag to test new things
  'show_array'         =>false,          //debug: show complete incoming array? You can use this to see what other information Amazon is sending
  'show_url'           =>false,          //debug: show XML request url to be send to Amazon?
  'show_xml'           =>false,          //debug: show incoming XML code from Amazon?
);
//change the debug options to true if you want to activate them or call the script with '?show_array=true' to see what actual information you're getting from Amazon and how little my standard script is actually showing of it

require_once "data.php";      //static data about Amazon (servers, search fields) v3-
require_once "data_v4.php";   //static data about Amazon (servers, search fields) v4+
require_once "language.php";  //translate the output to the prefered language of the user
require_once "aws.php";       //see: http://mierendo.com/software/aws_signed_query/, please note that I'm using an slightly adapted version of the script: I do my own XML-interpreting

//20090624: the following isn't relevant anymore it seems, 20091122: yes it is!
$Aassociates_id=array(
  'de'=>'chipdir00' ,  // <-- replace with your amazon.de    associate ID, or leave it as it is
  'fr'=>'chipdir010',  // <-- replace with your amazon.fr    associate ID, or leave it as it is
  'jp'=>'INVALID'   ,  // <-- replace with your amazon.co.jp associate ID, or leave it as it is
  'uk'=>'chipdir03' ,  // <-- replace with your amazon.co.uk associate ID, or leave it as it is
  'us'=>'chipdir'   ,  // <-- replace with your amazon.com   associate ID
);
//If you haven't gotten your own associate ID yet, get it from:
//http://associates.amazon.com/exec/panama/associates/apply
//
//Normally you will want to start selling books via Amazon.com only,
//just to see if it works and pays well (which it normally doesn't).
//
//You can save yourself a lot of trouble by not applying for an associate ID
//at the other local Amazon sites yet, but leaving mine in for the time being
//and perhaps I'll make a few pounds, euro's and/or yen. As soon as I would
//receive a noticable amount of cash I'll track you down an will warn you
//to get your own ID's there.
//
//please note that all those local Amazons send out all of their communications
//in their local languages, so French, German and Japanese for example and
//that you first have to earn enough money per branch before you get paid.
//And the Japanese branch only seems to pay in gift-certificates, so you'd
//have to buy Japanese books for example.
//
//if you want to disable any of the foreign branches, please do so in the
//file data.php, but please consider that we're living in an ever better
//connected world and sometime later you might want to add them again
//if only as a service to your visitors.

//other flags:
//this doesn't seem to be relevant anymore:
//$f_rich=true;       //when set to true this will convert the URL so you'll get 7.5% on qualifying books instead of 5%. It doesn't work yet outside of the USA.
                      //change it to false when you prefer to get only 5% ;-)
                      //see http://forums.prospero.com/n/mb/message.asp?webtag=am-assosdev&msg=6.1&ctx=0, or search the forum for 'nosim'
                      //This is only helpful for certain books
                      //correction: keep this option set to true, to prevent the showing of Amazon's annoying distraction pages.
                      //20080530: i don't know if this is still relevant for version 4
$f_user_search=true;  //add a user search form and allow user searches?

//=============================================================================
//==You don't have to change anything below this line to start earning money.==
//=============================================================================

if ($jaap) {
  print_array($_GET,$tab);
}

//what are the user's prefered languages?
$Ahttp_lang=split(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);

if ($jaap) {
  print_array($Ahttp_lang,$tab);
}

//try to find the visitor's prefered language, this is still experimental
foreach ($Ahttp_lang as $i=>$d) {
  if ($Axl[$l=substr($d,0,2)]) {
    $pref_lang=$l;
    break;
  }
}

if (isset($pref_lang)) {
  $Adefault['language']=$pref_lang;
  if ($jaap) {
    echo $tab."prefered available language='$pref_lang'<br />\n";
  }
}

//for all parameters see if the user has overruled it or use the default
foreach ($Adefault as $i=>$d) {
  $$i=isset($_GET[$i])?$_GET[$i]:$d;
  if ($jaap) echo $tab."$i = '".$$i."'<br />\n";
}

//this is a test for someone:
if ($jb) {
  $operation ='SellerListingSearch';
  $show_array=1;
}

//use which servers?
//$norserver=$Aserver[$locale]['nor'];
//$xmlserver=$Aserver[$locale]['xml'];

//20090817: this is no longer used it seems:
//$dev_token='D2WMCOIPS9D14E';
//you can replace this with your own developer token after you have changed the script a lot
//get one from http://associates.amazon.com/exec/panama/associates/join/developer/application.html
//see:
//http://forums.prospero.com/n/mb/message.asp?webtag=am-assocdevxml&msg=378.1&ctx=0

//this is the data that is used to form the request for AWS
//this is the part that is search specific
if ($jb) {  //this is a test for someone
  $parameters=array(
    'Operation'       =>$operation              ,
    'SellerId'        =>'A23I0F0MWQH94Z'        ,
//  'Keywords'        =>urlencode($search)      ,
//  'SearchIndex'     =>$searchindex            ,  //Books for example.
//  "$searchparameter"=>$searchparameterdata    ,
    'ItemPage'        =>$page                   ,  //which page?
//  'Service'         =>'AWSECommerceService'   ,  //this makes it version 4
//  'SubscriptionId'  =>$subscriptionid         ,  //is this correct?
//  'AWSAccessKeyId'  =>$awsaccesskeyid         ,  //is this correct?
    'AssociateTag'    =>$Aassociates_id[$locale],
//  'ResponseGroup'   =>'Medium'                ,  //Small, Medium or Large
    'ResponseGroup'   =>'SellerListing'         ,  //Small, Medium, Large or SellerListing
  );
}
else {
  $parameters=array(
    'Operation'       =>$operation              ,
    'Keywords'        =>urlencode($search)      ,
    'SearchIndex'     =>$searchindex            ,  //Books for example.
    "$searchparameter"=>$searchparameterdata    ,
    'ItemPage'        =>$page                   ,  //which page?
//  'Service'         =>'AWSECommerceService'   ,  //this makes it version 4
//  'SubscriptionId'  =>$subscriptionid         ,  //is this correct?
//  'AWSAccessKeyId'  =>$awsaccesskeyid         ,  //is this correct?
    'AssociateTag'    =>$Aassociates_id[$locale],
    'ResponseGroup'   =>'Medium'                ,  //Small, Medium, Large or SellerListing
  );
}

$A=aws_request($parameters);  //do the AWS request via cache and decode the XML

//debug:
if ($jaap) {
  echo $tab."<hr />\n";
  echo $tab."<pre>\n";
  print_r    ($A);
  echo $tab."</pre>\n";
//echo $tab."<hr />\n";
//echo $tab."<pre>\n";
//var_dump   ($A);
//echo $tab."</pre>\n";
//echo $tab."<hr />\n";
//echo $tab."<pre>\n";
//var_export ($A);
//echo $tab."</pre>\n";
  echo $tab."<hr />\n";
  print_array($A);
  echo $tab."<hr />\n";
}

$Amicrotime['XML'][1]=getmicrotime();        //time after XML decoding

//debug: show the array or object
//you can easily use this debugging tool by adding '&show_array=1' to the URL of this script
if ($show_array) {       //show the array for debugging?
  print_array($A,$tab);  //show the complete array
}

//show the stuff

$Amicrotime['show'][0]=getmicrotime();         //time before showing stuff

echo $tab."<h2>".xu('searching for')." '$searchparameterdata'</h2>\n";  //you can change the h2's to h1's

//20090827/old code:
//if ($e=$error_msg) {
//  switch ($Aerror[$e]) {
//  case 'print':
//    echo $tab."$e<br />\n";
//    break;
//  default:
//    echo $tab.xu('Amazon returned the error').': '.$e."<br />\n";
//    echo $tab."<br />\n";
//    echo $tab.xu('please add this error message to the ').
//          "<a href='http://www.chipdir.nl/amazon/errorlist.php?do=add&da=".urlencode($e)."&ur=".$file."'>".
//          xl('database')."</a>.<br />\n";
//    break;
//  }
//}

//$jaap=true;
//actually show the products:

//echo $A->Items->Request->IsValid;

if (isset($A->Error)) {
  $c=$A->Error->Code;
  $e=$A->Error->Message;
  echo $tab."Amazon error: $c: $e<br />\n";
}
else if ($A->Items->Request->IsValid!='True') {
  $c=$A->Items->Request->Errors->Error->Code;
  $e=$A->Items->Request->Errors->Error->Message;
  echo $tab."Amazon error: $c: $e<br />\n";
}
else {
  print_products($A,$tab);
}

//print all the products
function print_products($A,$tab='') {
  global $jaap;
  global $language;
  global $locale;
  global $operation;
  global $page;
  global $search;
  global $searchparameter;
  global $searchparameterdata;

  switch ($operation) {
  case 'SellerListingSearch':
    die("sorry but SellerListingSearch doesn't work yet");
    $items  =$A['SellerListingSearchResponse']['SellerListings'];
    $subnode='SellerListing';
    break;
  default:
//  $items=$A['ItemSearchResponse']['Items'];  //old
//  $subnode='Item';
//  break;
    if ($jaap) {
      echo $tab."in print_products():<br />\n";
      echo $tab."A:<br />\n";
      print_array($A,$tab='');
    }
    $items    =$A    ->Items;
//  $items_sub=$items->Item;
    $aitems=(array)$items;       //it is very strange that this and the next line works and not the outcommented line before this one
    $items_sub=$aitems['Item'];
    if ($jaap) {
      echo $tab."items:<br />\n";
      echo $tab."<pre>\n";
      print_r($items);
      echo $tab."</pre>\n";
      echo $tab."items:<br />\n";
      print_array($items,$tab='');
      echo $tab."items->Item:<br />\n";
      echo $tab."<pre>\n";
      print_r($items->Item);
      echo $tab."</pre>\n";
      echo $tab."items->Item:<br />\n";
      print_array($items->Item,$tab='');
      echo $tab."items_sub:<br />\n";
      echo $tab."<pre>\n";
      print_r($items_sub);
      echo $tab."</pre>\n";
      echo $tab."items_sub:<br />\n";
      print_array($items_sub,$tab='');
    }
    break;
  }
  $npro=$items->TotalResults;
  $npag=$items->TotalPages;
  echo $tab."<b>".xu('number of products').": $npro</b><br />\n";
  echo $tab."<b>".xu('page').' '.($page).' '.xl('of').' '.((int)$npag)."</b><br />\n";
  echo $tab."<p />\n";
  echo $tab."<table border='1'>\n";
  echo $tab."  <tbody>\n";
  if (is_array($items_sub) and $items_sub[0]) {
    foreach ($items_sub as $i=>$E) {
      print_product($E,$tab.'    ');
    }
  }
  else {
    print_product($D,$tab.'    ');
  }
  echo $tab."  </tbody>\n";
  echo $tab."</table>\n";
  //provide links to previous and next page
  if ($npag>1) {
    //echo $tab."<hr>\n";
    echo $tab.xu('page:')."\n";
    echo $tab.make_link_to_page(1,1)."\n";
    echo $tab.make_link_to_page(2,2)."\n";
    if ($page>=2) {
      echo $tab.make_link_to_page($page-1,'<')."\n";
    }
    if ($page<$npag) {
      echo $tab.make_link_to_page($page+1,'>')."\n";
    }
    echo $tab.make_link_to_page($npag,$npag)."\n";
  }
}

//print one Amazon product
//version 4
function print_product($E,$tab) {
//global $Aassociates_id;
//global $dev_token;
//global $f_rich;          //do you want 15% or 5%? (only for discounted books), 20090624: I don't know if this is still relevant
  global $jaap;
  global $locale;
//global $norserver;

  if ($E) {
    if ($jaap) echo $tab."print_product()<br />\n";
    $url=$E->DetailPageURL;
    if ($jaap) echo $tab."url=$url<br />\n";
    $E2A=(array)$E;
    $url=$E2A['DetailPageURL'];
    if ($jaap) echo $tab."url=$url<br />\n";
    if ($jaap) print_array($E2A);
    //print_array($E);
    //rebuild the URL if you want 15% instead of 5%:
//20090804/wjvg: changed this:
//  $url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/ref=nosim/'.$Aassociates_id[$locale].'?dev-t='.$dev_token:$E['url'];
    //$url=($f_rich /*and $mode=='books' and $locale=='us'*/)?"$norserver/exec/obidos/ASIN/".$E['ASIN'].'/'.$Aassociates_id[$locale]:$E['url'];
    echo $tab.    "<tr>\n";
    echo $tab.    "  <td align='center'>\n";
    if ($d=$E->MediumImage) {
      $iu=$d->URL;
      $ih=$d->Height;
      $iw=$d->Width;
      echo $tab.  "    <a href='$url'><img src='$iu' width='$iw' height='$ih' border='0'></a>\n";
    }
    echo $tab.    "  </td>\n";
    echo $tab.    "  <td align='center'>\n";
    if ($d=$E->ItemAttributes->Title) {
      echo $tab.  "    <a href='$url'>$d</a><br />\n";
    }
    if (is_array($dd=$E->ItemAttributes->Author)) {
      echo $tab.  "    ".xl('by').": ";
      foreach ($dd as $i=>$d) {
        if ($i) echo ', ';
        //echo $tab."<a href="<b>$d</b>";
        echo "<b>$d</b>";
      }
      echo "<br />\n";
    }
    else if ($d=$dd) {
      echo $tab.  "    ".xl('by').": <b>$d</b><br />\n";
    }
    $dm=$E->ItemAttributes->Publisher;
    $dr=$E->ItemAttributes->PublicationDate;
    if ($dm or $dr) {
      echo $tab.  "    ";
      if ($dm) {
        echo xl('publisher').": <b>$dm</b>";
      }
      if ($dm and $dr) echo ', ';
      if ($dr) {
        echo xl('published').": <b>$dr</b>";
      }
      echo "<br />\n";
    }
    if ($asin=$E->ASIN) {
      echo $tab.  "    ASIN: <b>$asin</b><br />\n";
    }
    if ($ean=$E->ItemAttributes->EAN) {
      echo   $tab."    EAN: <b>$ean</b><br />\n";
    }
    //$da=$E->Reviews->AvgCustomerRating;  //not in Medium Set?
    $da=false;  //don't show
    $ds=$E->SalesRank;
    if ($da or $ds) {
      echo $tab.  "    ";
      if ($ds) echo xl('sales rank').": <b>$ds</b>";
      if ($da and $ds) echo ", ";
      if ($da) echo $tab.xl('customer rating').": <b>".(($da-1)*25)."%</b>";
      echo "<br />\n";
    }
    $do=$E->OfferSummary->LowestNewPrice ->FormattedPrice;
    $du=$E->OfferSummary->LowestUsedPrice->FormattedPrice;
    if ($do or $du) {
      echo $tab.  "    ".xl('price').": ";
      if ($do) echo "<b>$do</b> (".xl('new').")";
      if ($do and $du) echo ", ";
      if ($du) echo "<b>$du</b> (".xl('used').")";
      echo "<br />\n";
    }
    echo $tab.    "  </td>\n";
    if ($EditorialReviews=$E->EditorialReviews and
        $EditorialReview=$EditorialReviews->EditorialReview and
        $Content=$EditorialReview->Content) {
      echo $tab.  "  <td align='center'>\n";
      echo $tab.  "    $Content\n";
      echo $tab.  "  </td>\n";
    }
    echo $tab.    "</tr>\n";
  }
}

//make link to other page (next, previous etc.)
function make_link_to_page($page,$s) {
  global $language;
  global $locale;
  global $search;
  global $searchindex;
  global $searchparameter;
  global $searchparameterdata;

  return "<a href='?".
         'language'           .'='.$language                      .'&'.
         'locale'             .'='.$locale                        .'&'.
         'page'               .'='.$page                          .'&'.
         'searchindex'        .'='.$searchindex                   .'&'.
         'searchparameter'    .'='.$searchparameter               .'&'.
         'searchparameterdata'.'='.urlencode($searchparameterdata).'&'.
         "'>".xu($s)."</a>";
}

//print an array or object
//(for debugging)
function print_array($A,$tab='') {
  if (is_object($A)) {
    echo   $tab."object:<br >\n";
    print_array((array)$A,$tab);
  }
  else if (is_array($A)) {
//  print_r($A);
    echo   $tab."<table border='1'>\n";
    echo   $tab."  <tbody>\n";
//  echo   $tab."    COUNT=".count($A)."\n";
//  if (is_object($A)) {
//    echo   $tab."    COUNT=".count($A)." - ".$A['0']."\n";
//  }
    foreach ($A as $i=>$d) {
      echo   $tab."    <tr>\n";
      echo   $tab."      <td valign='top'>$i</td>\n";
//    print_r($d);
      if (is_string($d)) {
//      echo $tab."      STRING\n";
//      print_r($d);
//      echo $tab."      <td><pre>".htmlentities($d)."</pre></td>\n";
        echo $tab."      <td>".htmlentities($d)."</td>\n";
      }
      else if (is_array($d)) {
//      echo $tab."      ARRAY or OBJECT\n";
        echo $tab."      <td>\n";
        print_array($d,$tab.'        ');
        echo $tab."      </td>\n";
      }
      else if (is_object($d)) {
//      echo $tab."      ARRAY or OBJECT\n";
        echo $tab."      <td>object:\n";
        print_array((array)$d,$tab.'        ');
        echo $tab."      </td>\n";
      }
      else {
//      echo $tab."      ELSE\n";
//      print_r($d);
//      echo $tab."      <td><pre>".htmlentities($d)."</pre></td>\n";
        echo $tab."      <td>".htmlentities($d)."</td>\n";
      }
      echo   $tab."    </tr>\n";
    }
    echo     $tab."  </tbody>\n";
    echo     $tab."</table>\n";
  }
  else {
    echo $tab."warning: not-an-array-or-object given to print_array()<br />\n";
  }
}

function getmicrotime() {
  list($us,$s)=explode(' ',microtime());
  return (float)$us+(float)$s;
}

if ($f_user_search) {
  //the next section adds a search box for the users
  echo $tab.  "<hr />\n";
  echo $tab.  "<form method='get' action='?'>\n";
  //echo $tab."  <input type='hidden' name='language' value='$language' />\n";
  //echo $tab."  <input type='hidden' name='locale'   value='$locale'   />\n";
  //echo $tab."  <input type='text'   name='ty'>Search type</input><br />\n";
  echo $tab.  "  <table>\n";
  echo $tab.  "    <tbody>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('language for page:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='language'>\n";
  foreach ($Alanguage as $i=>$d) {
    echo $tab."            <option value='$i'".($i==$language?" selected='true'":"").">".xu($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('which server:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='locale'>\n";
  foreach ($Alocale as $i=>$d) {
    echo $tab."            <option value='$i'".($i==$locale?" selected='true'":"").">".xl($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('operation:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='operation'>\n";
  foreach ($Aoperation as $i=>$d) {
    echo $tab."            <option value='$i'".($i==$operation?" selected='true'":"").">".xu($i)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('product category:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='searchindex'>\n";
  foreach ($Asearchindex as $i=>$d) {  //uk and jp not ready yet? 20080730: must be adjusted to the locale again
    echo $tab."            <option value='$d'".($d==$searchindex?" selected='true'":"").">".xl($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('search parameter:')."</td>\n";
  echo $tab.  "        <td>\n";
  echo $tab.  "          <select name='searchparameter'>\n";
  foreach ($Aoperation['ItemSearch']['RequiredParameters']['SearchIndex'] as $i=>$d) {
    echo $tab."            <option value='$d'".($d==$searchparameter?" selected='true'":"").">".xu($d)."</option>\n";
  }
  echo $tab.  "          </select>\n";
  echo $tab.  "        </td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "      <tr>\n";
  echo $tab.  "        <td>".xu('search string:')."</td>\n";
  echo $tab.  "        <td><input type='text' name='searchparameterdata' value='$searchparameterdata' /></td>\n";
  echo $tab.  "      </tr>\n";
  echo $tab.  "    </tbody>\n";
  echo $tab.  "  </table>\n";
  echo $tab.  "  <input type='submit' value='Search' />\n";
  echo $tab.  "</form>\n";
  //end of the search box section
}

//phpinfo();

$Amicrotime['show' ][1]=getmicrotime();  //time after showing
$Amicrotime['total'][1]=getmicrotime();  //time at end

//The next part is to show if the script isn't overburdoning your server. (The time waiting for Amazon isn't burdoning your server). You can remove the next part if you like:
echo $tab."<hr />\n";
//echo("Time used for time-consuming parts:<br />\n");
echo $tab."Time used:<br />\n";
foreach ($Amicrotime as $i=>$d) {
  //if ($d[1]>$d[0]) {
    printf($tab."- %.2f s %s<br />\n",$d[1]-$d[0],$i);
  //}
}
//20091129/wjvg: you may remove these lines or move them to an about section of your site:
echo $tab."<hr />\n";
echo $tab."This script is GPL'ed and can be downloaded from <a href='http://www.chipdir.nl/amazon/'>this page</a>.<br />\n";

echo "  </body>\n";
echo "</html>\n";


?>

       </div>

       <span class="corners-bottom"><span></span></span></div>
    </div>
</div></div>    
<div class="c-f-l"><div class="c-f-r"><div class="c-f-c"></div></div></div>
<!-- INCLUDE jumpbox.html -->
<!-- INCLUDE overall_footer.html -->

the page loads but none of the amazonv4.php stuff is showing, so I had a bit of a look around the net and came across this Run PHP from HTML - .html as .php - Execute PHP in .html do you think this is why it might not be showing?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.