- <?php
- /**
- * This file contains some methods that are used throughout the entire script.
- *
- * All methods in this file are private since they are only meant to
- * be used internally by the script. (Not that this means anything in PHP ;)
- *
- * @author Mauricio Diaz <madd0@users.sourceforge.net>
- * @copyright 2004 (c) Mauricio Diaz Orlich
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
- * @version 0.3
- *
- * @package amazOOP
- */
-
- /**
- * For security, only {@link aq.php} should be included in your pages
- */
- defined('_AMAZOOP') or die( 'Direct Access to this location is not allowed.' );
-
- /**
- * If activated, this indicates that the image URL returned by Amazon should be
- * used even if it is only a 1x1 GIF.
- * This value is to be used in function {@link getImage getImage}() together
- * with one of the {@link IMAGE_ALTERNATIVES_0 IMAGE_ALTERNATIVES_X} values.
- */
- define('IMAGE_AS_IS', 16);
-
- /**
- * If activated, this indicates that function {@link }
- * http://www.php.net/getimagesize getimagesize}() should not be used.
- *
- * Not using this function implies that any generated image tags will not have
- * the width and height attributes, nor will these values be returned in the
- * array returned by {@link getImage getImage}().
- *
- * In some server configurations, however, this may reduce execution time
- * substantially.
- *
- * This value is to be used in function {@link getImage getImage}() together
- * with one of the {@link IMAGE_ALERNATIVES_0 IMAGE_ALTERNATIVES_X} values.
- * @var integer
- */
- define('IMAGE_NO_SIZE', 32);
-
- /**
- * If activated, the script will NOT look for any alternative images even if it
- * is determined that the URL returned by Amazon points to a 1x1 pixel GIF.
- *
- * The difference between using IMAGE_ALTERNATIVES_0 and {@link IMAGE_AS_IS} is
- * that {@link IMAGE_AS_IS} will display the 1x1 pixel GIF returned by Amazon,
- * while IMAGE_ALTERNATIVES_0 will display the "No image available" replacement.
- */
- define('IMAGE_ALTERNATIVES_0', 0);
-
- /**
- * If activated, the script will try to look for an alternative image ONLY if
- * the merchant name returned by Amazon (if a name was returned) is associated
- * to a merchant code is the user's {@link config/stores.inc.php personal}
- * stores}.
- */
- define('IMAGE_ALTERNATIVES_1', 1);
-
- /**
- * If activated, the script will try to look for an alternative image both at
- * {@link IMAGE_ALTERNATIVES_1 level 1} and by looking in all Amazon sites for
- * an alternative.
- */
- define('IMAGE_ALTERNATIVES_2', 2);
-
- /**
- * If activated, the script will try to look for an alternative image only
- * if you have associated the product's manufactuerer with a Merchant ID
- * in the {@link stores.inc.php} file.
- */
- define('IMAGE_ALTERNATIVES_3', 4);
-
- /**
- * If activated, the script will try to look for an alternative image using
- * ALL the store codes you have defined in file {@link stores.inc.php}. It
- * goes without saying that this is the option that takes more time to execute.
- */
- define('IMAGE_ALTERNATIVES_4', 8);
-
- /**
- * This document contains the classes where product details are stored.
- * @access private
- */
- require_once(CORE_PATH . "item.class.php");
- /**
- * This document contains the LiteDetails class
- * @access private
- */
- require_once(CORE_PATH . "liteDetails.class.php");
- /**
- * This document contains the HeavyDetails
- * @access private
- */
- require_once(CORE_PATH . "heavyDetails.class.php");
- /**
- * This document contains other classes used in amazOOP.
- * @access private
- */
- require_once(CORE_PATH . "other.class.php");
- /**
- * This document contains the scripts configuration variables.
- * @access private
- */
- require_once(CORE_PATH . "config/config.inc.php");
- /**
- * This document contains the XML parser used by the script.
- * @access private
- */
- require_once(CORE_PATH . "parser.class.php");
- /**
- * This document contains the classes needed for the Remote Shopping Cart
- * @access private
- */
- require_once(CORE_PATH . "cart.inc.php");
-
- /**
- * Sets function logError() as the error handler if error logging is active
- */
- set_error_handler('logError');
-
- /**
- * Gets the value of a variable from amazOOP's general configuration.
- *
- * The general configuration variables are the ones defined in section
- * 'General' of the {@tutorial amazoop.configure.pkg Configurator}, under the title
- * that reads 'General Configuration'.
- *
- * This function is mainly for internal use, however I have not declared it
- * private because it might be of interest for some developers.
- *
- * @param string $var The variable you wish to fetch. Valid values are:
- * - 'address': the URL of the site's home (e.g. 'www.server.com', or 'www.shared.com/mysite')
- * - 'path_to_script': absolute path to the script (e.g. 'c:\\path\\to\\site\\include\\amazoop\\', or '/var/www/html/amazoop/')
- * - 'close_tag_character': returns ' />' or ' >' if configured to use XHTML or HTML respectively
- * - 'file_separator': returns '\\' or '/' if configured to use Windows or *nix respectively
- * - 'UTF-8_encode': determines whether data from Amazon should be UTF-8 encoded
- * - 'open_links_in': 'new' or 'same' window
- * - 'log_errors': true or false
- * - 'log_requests': true or false
- * - 'temporary_directory': absolute path to temporary directory
- * - 'cache_directory': absolute path to cache directory
- * - 'max_request_log_size': maximum size in lines of request log
- * - 'max_error_log_size': maximum size in lines of error log
- * - 'request_log_file': absolute path to request log
- * - 'error_log_file': absolute path to error log
- * - 'timestamp_file': absolute path to file containing timestamp
- * - 'XML_template': absolute path to XML template
- * - 'check_alternative_images': level of image checking (0-4)
- *
- * @param string $server The server you want the variable for. Valid values
- * are:
- * - "auto": amazOOP determines which server it is running on and returns
- * the value for that server.
- * - "test": the value for the test server is returned.
- * - "def": the value for the definitive server is returned.
- *
- * @return string|booleanThe value of the requested variable.
- */
- function getAmazoopConfig($var, $server = "auto"){
- global $_AMAZOOP_CONFIG;
-
- $get = $server;
-
- if($server == "auto"){
- if($_SERVER['SERVER_NAME'] == $_AMAZOOP_CONFIG['address']['test'])
- $get = 'test';
- else
- $get = 'def';
- }
-
- $res = $_AMAZOOP_CONFIG[$var][$get];
-
- switch($var){
- case 'close_tag_character':
- if($res == 'xhtml')
- $res = ' />';
- else
- $res = ' >';
- break;
- case 'file_separator':
- if($res == 'windows')
- $res = '\\';
- else
- $res = '/';
- break;
- case 'temporary_directory':
- case 'cache_directory':
- case 'request_log_file':
- case 'error_log_file':
- case 'timestamp_file':
- case 'XML_template':
- if(substr($res, 0, 1) != '/' && substr($res, 1, 1) != ':'){
- $path = getAmazoopConfig('path_to_script', $server);
-
- if(substr($path, -1) != '/' && substr($path, -1) != '\\')
- $path = $path . getAmazoopConfig('file_separator', $server);
-
- $res = $path . $res;
- }
- default:
- break;
- }
-
- if(is_numeric($res))
- return $res;
- elseif($res == 'true')
- return true;
- elseif($res == 'false')
- return false;
- else
- return $res;
- }
-
- /**
- * Sets the value of a variable from amazOOP's general configuration.
- *
- * The general configuration variables are the ones defined in section
- * 'General' of the {@tutorial amazoop.configure.pkg Configurator}, under the title
- * that reads 'General Configuration'.
- *
- * Although I can't see an immediate use for this function, you can override the default
- * configuration of the script, using this function. These changes, however, are only
- * available to each instance of the script, and are lost once the script ends.
- *
- * @param string $var The variable you wish to set. Valid values are:
- * - 'address': the URL of the site's home (e.g. 'www.server.com', or 'www.shared.com/mysite')
- * - 'path_to_script': absolute path to the script (e.g. 'c:\\path\\to\\site\\include\\amazoop\\', or '/var/www/html/amazoop/')
- * - 'close_tag_character': 'xhtml' and 'html', will return ' />' or ' >' respectively
- * - 'file_separator': 'windows' or 'unix' will return '\\' or '/' respectively
- * - 'UTF-8_encode': 'true' or 'false'
- * - 'open_links_in': 'new' or 'same' window
- * - 'log_errors': 'true' or 'false'
- * - 'log_requests': 'true' or 'false'
- * - 'temporary_directory': path to temporary directory, either relative from 'path_to_script' or absolute
- * - 'cache_directory': path to cache directory, either relative from 'path_to_script' or absolute
- * - 'max_request_log_size': maximum size in lines of request log
- * - 'max_error_log_size': maximum size in lines of error log
- * - 'request_log_file': path to request log, either relative from 'path_to_script' or absolute
- * - 'error_log_file': path to error log, either relative from 'path_to_script' or absolute
- * - 'timestamp_file': path to file containing timestamp, either relative from 'path_to_script' or absolute
- * - 'XML_template': path to XML template, either relative from 'path_to_script' or absolute
- * - 'check_alternative_images': level of image checking (0-4)
- *
- * @param string $value The value you wish to set to $var. See the description of the $var parameter
- * for a list of valid values.
- *
- * @param string $server The server you want the variable for. Valid values
- * are:
- * - "test": the value for the test server is returned.
- * - "def": the value for the definitive server is returned.
- *
- * @return void
- */
- function setAmazoopConfig($var, $value, $server){
- global $_AMAZOOP_CONFIG;
-
-
- $_AMAZOOP_CONFIG[$var][$server] = $value;
- }
-
- /**
- * Gets the {@tutorial advanced.browsenodes.pkg browse node} corresponding to
- * an {@tutorial advanced.categories.pkg amazOOP category}.
- *
- * This function is mainly for internal use, however I have not declared it
- * private because it might be of interest for some developers.
- *
- * @param string $locale the country for which the category is defined.
- * @param string $category the amazOOP category for which you want to retrieve
- * the browse node.
- *
- * @return string|booleanthe browse node for the requested category, or false
- * if the category doesn't exist.
- */
- function getBrowseNode($locale, $category){
- global $_AMAZOOP_CATEGORIES;
-
- if(isset($_AMAZOOP_CATEGORIES[$locale][$category]['browsenode']))
- return $_AMAZOOP_CATEGORIES[$locale][$category]['browsenode'];
- else return false;
- }
-
- /**
- * Gets the associate ID for a specified locale.
- *
- * @param string $locale the locale for which you would like the associate ID.
- *
- * @return string|booleanthe requested ID or false if the requested locale is not valid.
- * If the locale is valid, but no ID has been set, the ID of the developer is returned (think of
- * it as a contribution).
- */
- function getAssociateID($locale){
- global $_AMAZOOP_ASSOC_IDS, $_AMAZOOP_MADD0S_IDS;
-
- if(isset($_AMAZOOP_ASSOC_IDS[$locale]))
- if($_AMAZOOP_ASSOC_IDS[$locale] == "")
- return $_AMAZOOP_MADD0S_IDS[$locale];
- else
- return $_AMAZOOP_ASSOC_IDS[$locale];
- else return false;
- }
-
- /**
- * Gets the path to the image representing a certain medium (i.e. DVD, CD, VHS, Software platform, etc).
- * Paths are stored in file {@link config.inc.php}
- *
- * @param string $medium the required medium.
- *
- * @return array If an image was configured, an array with the following information:
- * - 0: the URL to the image,
- * - 1: the width of the image,
- * - 2: the height of the image,
- * - 3: a string to be used in HTML IMG tags that reads ' width="*" height="*" '
- *
- * @since version 0.3RC2 this function returns an array instead of a string.
- *
- * @access private
- */
- function getMediaImage($medium){
- global $_AMAZOOP_MEDIA_IMAGES;
-
- if(isset($_AMAZOOP_MEDIA_IMAGES[$medium]))
- return array("http://" . getAmazoopConfig('address') . $_AMAZOOP_MEDIA_IMAGES[$medium]['url'],
- $_AMAZOOP_MEDIA_IMAGES[$medium]['width'],
- $_AMAZOOP_MEDIA_IMAGES[$medium]['height'],
- "width=\"" . $_AMAZOOP_MEDIA_IMAGES[$medium]['width'] . "\" height=\"" . $_AMAZOOP_MEDIA_IMAGES[$medium]['height'] . "\"");
- else
- return false;
- }
-
- /**
- * Receives an AWS mode and gets its name in a human readable form, e.g. "classic-uk" => "Classical Music",
- * or an amazOOP category ("classic-uk" => "classic").
- *
- * These associations are stored in {@link $_AMAZOOP_CATEGORIES}, but you should use the
- * {@tutorial amazoop.configure.pkg Configurator} to set them up.
- *
- * @param string $locale the locale used, important since modes are different in each locale
- * @param string $mode the mode searched
- * @param boolean $human if true the name is returned, otherwise, the mode is returned
- *
- * @return string The name of a mode in the requested presentation.
- *
- * @access private
- */
- function getCategory($locale, $mode, $human = true){
- global $_AMAZOOP_CATEGORIES;
-
- foreach($_AMAZOOP_CATEGORIES[$locale] as $catName => $cat){
- if($cat['mode'] == $mode){
- $key = $catName;
- $name = $cat['name'];
- break;
- }
- }
- if($human)
- return $name;
- else
- return $key;
- }
-
- /**
- * Receives a locale and an amazOOP category, and looks for the corresponding AWS mode.
- *
- * Tha associations are stored in {@link $_AMAZOOP_CATEGORIES}, which is in {@link categories.inc.php}.
- *
- * @param string $locale the locale used, important since modes are different in each locale
- * @param string $category the amazOOP category you want the mode for
- *
- * @return string The AWS mode corresponding to the provided amazOOP mode
- *
- * @access private
- */
- function getMode($locale, $category){
- global $_AMAZOOP_CATEGORIES;
-
- if(isset($_AMAZOOP_CATEGORIES[$locale][$category]))
- return $_AMAZOOP_CATEGORIES[$locale][$category]['mode'];
- else
- return false;
- }
-
- /**
- * Logs an error, either at the request of the user or a PHP generated error, to the error
- * log file.
- *
- * This function uses values specified in amazOOP's main configuration file which should be
- * configured using the {@tutorial amazoop.configure.pkg Configurator}
- *
- * @param integer $errno the error number
- * @param string $errstr the error string
- * @param string $errfile the name of the file where the error was generated
- * @param string $errline the line in which the error was generated
- *
- * @access private
- */
- function logError($errno, $errstr, $errfile, $errline){
- if (error_reporting() == 0) return;
-
- switch($errno){
- case E_ERROR:
- case E_USER_ERROR:
- $errormsg = "<b>Fatal Error</b>: " . $errstr;
- break;
-
- case E_WARNING:
- case E_USER_WARNING:
- $errormsg = "<b>Warning</b>: " . $errstr;
- break;
-
- case E_NOTICE:
- case E_USER_NOTICE:
- $errormsg = "<b>Notice</b>: " . $errstr;
- break;
-
- default:
- $errormsg = "<b>Unknown Error</b>: " . $errstr;
- break;
- }
-
- if(getAmazoopConfig('log_errors')){
- $err = array();
- $err[] = date('r') . "\n";
- $err[] = chunk_split(strip_tags($errormsg));
- $err[] = chunk_split("File: " . $errfile);
- $err[] = "Line: " . $errline . "\n";
- $err[] = chunk_split("URI: " . $_SERVER["REQUEST_URI"]);
- if(isset($_SERVER['HTTP_REFERER']))
- $err[] = chunk_split("Referer: " . $_SERVER['HTTP_REFERER']);
- else
- $err[] = chunk_split("Referer: Direct Hit or Hidden");
- $err[] = chunk_split("Remote IP: " . $_SERVER["REMOTE_ADDR"]);
- if(isset($_SERVER["HTTP_USER_AGENT"]))
- $err[] = chunk_split("User Agent: " . $_SERVER["HTTP_USER_AGENT"]);
- $err[] = "----------------------------------------------------------------------------\n";
-
- $err = array_merge($err, file(getAmazoopConfig('error_log_file')));
-
- if($fp = fopen(getAmazoopConfig('error_log_file'), 'wb+')){
- for($i = 0; $i < min(sizeof($err), getAmazoopConfig('max_error_log_size')); $i++)
- fwrite($fp, $err[$i]);
- fclose($fp);
- }
- else
- trigger_error("Could not write to the error log file (" . getAmazoopConfig('error_log_file') . ")", E_USER_WARNING);
- }
-
- if(!getAmazoopConfig('log_errors') || $errno == E_ERROR || $errno == E_USER_ERROR){
-
- $errormsg = "<br />" . $errormsg . " in <b>" . $errfile . "</b> on line <b>" . $errline . "</b><br />";
- echo $errormsg;
- flush();
- if($errno == E_ERROR || $errno == E_USER_ERROR)
- die();
- }
- }
-
- /**
- * Logs requests made to Amazon to the request log file.
- *
- * Typically, logged information includes: date, URL of AWS request, request ID return by AWS,
- * IP of client, duration of request.
- *
- * This function uses values specified in amazOOP's main configuration file which should be
- * configured using the {@tutorial amazoop.configure.pkg Configurator}
- *
- * @param array $req a description of the request to Amazon
- *
- * @see config.inc.php
- * @see $logFile
- * @see $logRequests
- * @see $requestLogSize
- *
- * @access private
- */
- function logRequest($req){
- if(getAmazoopConfig('log_requests')){
- $res = array();
- $res[] = date('r') . "\n";
- foreach($req as $n => $line)
- $req[$n] = chunk_split($line);
- $res = array_merge($res, $req);
- $res[] = "----------------------------------------------------------------------------\n";
- $res = array_merge($res, file(getAmazoopConfig('request_log_file')));
-
- if($fp = fopen(getAmazoopConfig('request_log_file'), 'wb+')){
- $max_request_log_size = getAmazoopConfig('max_request_log_size');
- for($i = 0; $i < min(sizeof($res), $max_request_log_size); $i++)
- fwrite($fp, $res[$i]);
- fclose($fp);
- }
- else
- trigger_error("Could not write to the request log file (" . getAmazoopConfig('request_log_file') . ")", E_USER_WARNING);
- }
- }
-
- /**
- * Used to parse the templates for the RSS feed.
- *
- * This function uses values specified in amazOOP's main configuration file which should be
- * configured using the {@tutorial amazoop.configure.pkg Configurator}
- *
- * WARNING!!! This function is experimental. Use and tweak if you wish, and send feedback!!!
- *
- * @param string $tag the string extracted from the RSS template that should be replaced
- * @param string $locale the locale from which the Amazon data is being gathered,
- * this can be "us", "uk", "de" or "jp"
- * @param LiteDetails|HeavyDetails$details the object containing the information to be
- * included in the RSS feed.
- *
- * @see config.inc.php
- * @see $rss
- *
- * @access private
- */
- function handleTag($tag, $locale, $details = NULL){
- global $_AMAZOOP_RSS;
-
- $tag = trim($tag);
- $res = "";
- switch($tag){
- case "startItem":
- $res = "stop";
- case "endItem":
- $res = "resume";
- break;
- case "language":
- if($locale == "us" || $locale == "uk")
- $res = "en-" . $locale;
- else
- $res = $locale;
- break;
- case "itemTitle":
- if(isset($details))
- $res = str_replace("&", "&", $details->getProductName());
- break;
- case "itemLink":
- if(isset($details))
- $res = "http://www.madd0.com/" . $locale . "/details/" . $details->getASIN();
- break;
- case "itemDescription":
- if(isset($details)){
- $res = "<![CDATA[ ";
- if($description = $details->getProductDescription(70)){
- $res .= "<p>" . $description;
- $res .= " <a href=\"http://www.madd0.com/" . $locale . "/details/" . $details->getASIN() . "\" target=\"_blank\"><i>(read more)</i></a></p>\n";
- }
- $res .= "<p>Get it now for only: " . $details->getOurPrice() . "</p>\n";
- $res .= "<p><i>Price is accurate as of " . date('r') . ". Prices and product availability are subject to change. Any price displayed on the Amazon website at the time of purchase will govern the sale of this product.</i></p> ]]>";
- }
- break;
- //<category>%category%</category>
- //<comments>%comments%</comments>
- case "guid":
- if(isset($details))
- $res = $details->getURL();
- break;
- case "lastBuildDate":
- case "itemPubDate":
- $res = gmdate('D, d M Y H:i:s \G\M\T');
- break;
- default:
- //$tag = substr($tag, -1);
- //$stripped = substr($stripped, 1);
- if(isset($_AMAZOOP_RSS[$tag]))
- $res = $_AMAZOOP_RSS[$tag];
- else
- $res = $tag;
- }
- return $res;
- }
-
- /**
- * Checks if more than 1 second has passed since the last query.
- * If so, the current time is stored as the time of the last query.
- *
- * This function uses values specified in amazOOP's main configuration file which should be
- * configured using the {@tutorial amazoop.configure.pkg Configurator}
- *
- * @return boolean true if more than 1 second has passed since the
- * last query to Amazon. False otherwise.
- *
- * @access private
- *
- */
- function inTime(){
- if(file_exists(getAmazoopConfig('timestamp_file'))){
- $lastRun = trim(file_get_contents(getAmazoopConfig('timestamp_file')));
- $currTime = time();
-
- if($currTime - $lastRun <= 0)
- return false;
- }
- if($fp = fopen(getAmazoopConfig('timestamp_file'), "w")){
- fwrite($fp, time());
- fclose($fp);
- }
- else
- trigger_error("Could not write to the timestamp file (" . getAmazoopConfig('timestamp_file') . ")", E_USER_ERROR);
-
- return true;
- }
-
- /**
- * Checks if an image provided by Amazon exists.
- * To do this the function checks the headers returned by the server
- * to determine if the URL is valid and if it is a valid image
- * and not a 1x1 GIF image. Does this assuming all 1x1 GIF images are
- * 807 bytes in length.
- *
- * @param string $img the URL of the image you want to verify.
- * @return boolean true if the image exists. False otherwise.
- *
- * @access private
- */
- function imageExists($img){
- global $allowsettimelimit;
-
- if($allowsettimelimit) set_time_limit(60);
-
- /*$start_time = explode(" ", microtime());
- $start_time = $start_time[1] + $start_time[0];*/
-
-
- $wait = 1;
- $result = true;
-
- $address = array();
- preg_match("/^(http:\/\/)?([^\/]+)(.*)/i", $img, $address);
-
- for($i = 0; $i < 3; $i++){
- if($fp = @fsockopen($address[2], 80, $errno, $errstr, 30))
- break;
- sleep($wait);
- $wait *= 2;
- }
-
- if(!$fp){
- trigger_error($errstr, $errno);
- $result = false;
- }
- else{
- $request = "HEAD ". $address[3] . " HTTP/1.1\r\n"
- . "Host: $address[2]\r\n"
- . "User-Agent: amazOOP/0.3\r\n"
- . "\r\n";
- fwrite($fp, $request);
-
- while(!feof($fp)){
- $text = strtolower(fgets($fp,1024));
- $line = explode(" ", $text);
- //$line = explode(" ", strtolower(fgets($fp,1024)));
- //echo $text . "<br>";
- if(strpos($line[0], "http/1.") === false){
- /*if($line[0] == "content-type:"){
- fclose($fp);
- return !(strpos($line[1], "image/jpeg") === false);
- }*/
- if($line[0] == "content-length:"){
- fclose($fp);
- $result = (int)$line[1] > 807;
- break;
- }
- }
- else{
- if($line[1] != "200"){
- fclose($fp);
- $result = false;
- //trigger_error("Invalid response: $line[1]", E_USER_NOTICE);
- break;
- }
- }
- }
- }
-
- /*$end_time = explode (" ", microtime());
- $end_time = $end_time[1] + $end_time[0];
-
- $log = array();
- $log[] = "After " . number_format(1000*($end_time - $start_time), 2) . " milliseconds,";
- $log[] = "I concluded that image: " . $img;
- if($result)
- $log[] = "EXISTED";
- else
- $log[] = "did NOT EXIST";
- logRequest($log);*/
-
- if($allowsettimelimit) set_time_limit(30);
-
- return $result;
- }
-
- /**
- * Advances the array's internal pointer to the last element.
- *
- * @param array $array the array whose last element should be returned.
- *
- * @return reference a reference to the last element in the array.
- *
- * @access private
- */
- function &array_last(&$array) {
- if (!is_array($array))
- return $array;
- if (!count($array))
- return null;
-
- end($array);
- return $array[key($array)];
- }
-
- /**
- * Tries to guess the AWS mode corresponding to a catalog returned in a feed.
- *
- * Used to guess the mode of a browse node obtained from a product's {@link HeavyDetails::browseList browseList}.
- *
- * WARNING!!! This is an experimental feature. Use it, tweak it, and send feedback!!!
- *
- * @param string $catalog the catalog that should be converted
- * @param string $locale the locale for which you want the AWS mode. Important because
- * modes are different in each locale.
- *
- * @return string the AWS mode corresponding to a catalog
- */
- function getModeFromCatalog($catalog, $locale){
-
- $catalog = $new_str = ereg_replace(" +", "", strtolower($catalog));
-
- if($catalog == "book" || $catalog == "ebook")
- return getMode($locale, "books");
- elseif($catalog == "magazine")
- return getMode($locale, "magazines");
- elseif($catalog == "homeimprovement")
- return getMode($locale, "tools");
- elseif($catalog == "toy")
- return getMode($locale, "toys");
- elseif($catalog == "video")
- return getMode($locale, "vhs");
- elseif(strstr($catalog, "lawn"))
- return getMode($locale, "garden");
- elseif(getMode($locale, $catalog))
- return getMode($locale, $catalog);
- else{
- logError(1024, $catalog . " could not be converted to AWS mode", "aq.lib.php", "389");
- return "misc";
- }
- }
-
- /**
- * Devloper's token. DO NOT TOUCH. Used by AWS for tracking.
- * @access private
- */
- define("_AMAZOOP_DEV_TOKEN", "D3R39P4FOXC4MW");
-
- ?>