function amazon_fetch($asin, $mode)
 {
     global $serendipity;
     if (!class_exists('serendipity_event_amazonchooser')) {
         return;
     }
     $country = trim($this->get_config('server'));
     list($country_url, $mode_list) = Amazon_country_code($country);
     $mode_names = Amazon_return_mode_array();
     if (!is_dir($serendipity['serendipityPath'] . 'templates_c/amazonget/')) {
         mkdir($serendipity['serendipityPath'] . 'templates_c/amazonget/');
     }
     if (!in_array($mode, $mode_list)) {
         $mode = "All";
     }
     $data = array();
     serendipity_plugin_api::hook_event('serendipity_event_amazonchooser_devinfo', $data);
     $AWSAccessKey = $data['dtoken'];
     $secretKey = $data['secretKey'];
     $AssociateTag = $data['aaid'];
     if (@(include_once "Cache/Lite.php")) {
         $cache_obj = new Cache_Lite(array('cacheDir' => $serendipity['serendipityPath'] . 'templates_c/amazonget/', 'automaticSerialization' => true, 'lifeTime' => 43200));
         $results = $cache_obj->get('amazonlookup' . $asin);
     }
     if (!$results['return_date']) {
         $results = Amazon_ItemLookup($AWSAccessKey, $AssociateTag, $secretKey, $mode, $asin, $country_url);
         if ($results['return_date'] && class_exists('Cache_Lite') && is_object($cache_obj)) {
             $cache_obj->save($results, 'amazonlookup' . $asin);
         }
     }
     if ($results['count'] == 0 || $results['return_count'] == 0) {
         $results['items'] = "";
     }
     return $results;
 }
 function Amazon_Call($method, $mode, $searchstring, $country_url, $page)
 {
     global $serendipity;
     if (!is_dir($serendipity['serendipityPath'] . 'templates_c/amazonget/')) {
         mkdir($serendipity['serendipityPath'] . 'templates_c/amazonget/');
     }
     $AWSAccessKey = trim($this->get_config('dtoken'));
     $AssociateTag = trim($this->get_config('aaid'));
     $secretKey = trim($this->get_config('secretKey'));
     if ($method == "search") {
         $results = Amazon_SearchItems($AWSAccessKey, $AssociateTag, $secretKey, $mode, $searchstring, $country_url, $page);
     } else {
         if (@(include_once "Cache/Lite.php")) {
             $cache_obj = new Cache_Lite(array('cacheDir' => $serendipity['serendipityPath'] . 'templates_c/amazonget/', 'automaticSerialization' => true, 'lifeTime' => 43200));
             $results = $cache_obj->get('amazonlookup' . $searchstring);
         }
         if (!$results['return_date']) {
             $results = Amazon_ItemLookup($AWSAccessKey, $AssociateTag, $secretKey, $mode, $searchstring, $country_url);
             if ($results['return_date'] && class_exists('Cache_Lite') && is_object($cache_obj)) {
                 $cache_obj->save($results, 'amazonlookup' . $searchstring);
             }
         }
     }
     if ($results['count'] == 0 || $results['return_count'] == 0) {
         $results['items'] = "";
     }
     return $results;
 }