#note $searchdo not use any format, becaus it is formated in aws_signed_request.php    (2009/8/18)        add associatetag: remember that in php ref to variable has to be in order in function def and as well as in the application 12/17/2011 for instance in mani_serch (put in order) and in uing it the order of variables have to be observed
error_reporting(0);
#$script_name = "amazon_search.php";
include("aws_signed_request.php");
$public_key = "1TTKKNERJRD3931Q22R2"; //your public AWS key
$private_key = "MNY8DqSdShXi2CDltGvwuj2WMMeavCVRZLbGt9j6"; //your private AWS key
$PartnerId = "categoricalgeome";
                  # print "dddddddddddddddddddddddddddddd $PartnerId";
$search = $_GET['search'];
$mode = $_GET['mode'];
$image_size = $_GET['image_size'];
$review = $_GET['review'];
$total_page = $_GET['total_page'];
$simple_list = $_GET['simple_list'];
$page_count = $_GET['page_count'];
$total_item = $_GET['total_item'];
$sort = $_GET['sort'];
$node = $_GET['node'];
$node_name = $_GET['node_name'];
$searchtype = $_GET['searchtype'];$productname = $_GET['productname'];
if ($searchtype == "asinxml"  or $mode == "asinxml")
	{
		$url =  "http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=15RJV3GX2B2Y33Y9BMR2&Operation=ItemLookup&ItemId=$search&ResponseGroup=Large";
		print "xml-view";
		$arr_file = file($url);
		$Parse_e1 = "<(.+)>";
		$Parse_e2 = "<(.+)/>";
		$result = join("",$arr_file);
		$result = ereg_replace("","-TTT-",$result);
		$result = ereg_replace(">","-SSS-",$result);
		$result = ereg_replace("<","-VVV-",$result);
		$result = ereg_replace("-SSS-",">",$result);
		$result = ereg_replace("-TTT-","
</",$result);
		$result = ereg_replace("-VVV-","
<",$result);
		echo $result;
		#for ($i=0; $i < count($arr_file); $i++)
		#{
			#print $arr_file[$i]."
";
		#}
		exit;
	}
$font_face_1 = "";
$file_mode = "books";
$file_node = "1";
#print $review."ssssssss";
$count = 0;
###############################change to gggg.com because category.org is too slow; note that prine_next_list has also changed
$search_cgi_name = "$SCRIPT_NAME";
#print "$SCRIPT_NAME mmmmmmmmmm";
#$search_cgi_name = "http://www.gggg.com".$SCRIPT_NAME;
$search_cgi_name = "/search.php";
#print "fffffffffffffffffffffffffffffff $SCRIPT_NAME";
$locale = "us";
$starters_us = array ("books|Books|1000|books",
 "photo|Photo|502394|photo",
 "wireless-phones|Wireless|301185|wireless",
 "pc-hardware|PCHardware|541966|pc",
 "videogames|VideoGames|468642|games",
 "dvd|DVD|130|video",
 "electronics|Electronics|172282|electronics",
 "kitchen|Kitchen|284507|kitchen",
 "magazines|Magazines|599872|magzines",
 "music|Music|301668|music",
 "classical|Classical|85|music|",
 "garden|OutdoorLiving|286168|garden|Garden",
 "software|Software|491286|software",
 "universal|Tools|228013|tools",
 "toys|Toys|171280|toys",
 "video|VHS|404272|video",
"apparel|Apparel|1036592|apparel|0|",
 "jewelry|Jewelry|3367581|jewelry|0|",
 "musicalinstruments|MusicalInstruments|11091801|musicalinstruments|0|",
 "health|HealthPersonalCare|3760901|health|0|",
 "beauty|Beauty|3760911|beauty|0|",
 "sports|SportingGoods|3375251|sports|0|",
 "office|OfficeProducts|1064954|office|0|");
#"asin|asin|0|asin|0|",
#"asinxml|asinxml|0|asinxml|0|");
#print "$search_cgi_name ttttttttt";
#print $image_size."aaaaa";
#$search = "algebra";
if ($review == "" and $total_page == "")
{
$review = "on";
}
if ($page_count == "")
{
$page_count = 1;
}
if ($total_page == "")
{
$total_page = 1;
}
if ($image_size == "")
{
$image_size = "medium";
#$image_size = "small";
}
if ($max_item == "")
{
$max_item = 0;
}
if ($sort == "")
{
	$sort = "pmrank";
}
if ($simple_list)
{
	$type = "lite";
}
if ($searchtype == "")
{
	$searchtype = "Keywords";
}
#print $photo_asin;
$search_d = rawurldecode($search);
#print "$search and $search_d = 1\n";
#$search = format($search_d);
#$search = rawurlencode($search);
$sort = urlencode($sort);
#print "sort = $sort\n";
$total_page_n = $page_count * $total_page;
$total_page_p = ($page_count - 1) * $total_page;
$productname = rawurldecode($productname);
$nn_node = $node;
if ($locale == "us")
{
	$starters = $starters_us;
}
if ($locale == "uk")
{
	$starters = $starters_uk;
}
if ($locale == "de")
{
	$starters = $starters_de;
}
if ($mode == "")
{
$mode = "books";
}
$count_line = count($starters);
for($x_au=0;$x_au<$count_line;$x_au++)
{
 $search_line =split("\|", $starters[$x_au]);
#print "\n nnnn $node \n";
if ($mode == $search_line[0])
{
$subject = $search_line[1];
if (!$node)
{
$node =$search_line[2];
}
#$search_mode = $search_line[3];
$next_node = $search_line[4];
#print "
ddddddddddddddd $next_node";
if ($next_node != "0")
{
$next_node = $node;
}
}
}
if ($nn_node)
{
	$node = $nn_node;
	$next_node = $nn_node;
}
#$search = ereg_replace("  "," ",$search);
#$search = ereg_replace("   "," ",$search);
#$search = ereg_replace(" ","%20",$search);
#type = "complete" for header";
#$browse_subject = "Browse:  $subject (Main Menu)";
html_head($mode, $search_d, $page, $image_size, $review, $total_page, $subject, $search_cgi_name, $simple_list, $photo_asin, $searchtype, $productname, $node_name);
#if($simple_list || $total_page > 1 || !$review || $image_size != "medium")
#{
	#$advanced = "advanced";
#}
#else
#{
	#$advanced = "";
#}
print_form("", $mode, $search_d, $page, $image_size, $review, $total_page, $subject, $search_cgi_name, $simple_list, $sort, $searchtype);
#print "$total_item && $page_count != 1";
#print " mode = $file_mode, search = $search; page = $page\n";
#print "$total_page_p - $total_page_n sssssssss\n";
#print $page."aaaaa\n";
#$TotalResults = 0;
if ($nn_node)
{
#$file_next_old = "/www/browse/$mode/$node/next.txt"; #comment out 4/24/2004
$file_next_old = "/us_1/csv/next/$mode/$next_node";
}
else
{
#$file_next_old = "/www/browse/$mode/next.txt";
$file_next_old = "/us_1/csv/next/$mode/$next_node";
}
#print "
 aaaaaaaaaaaaaa $file_next_old";
$file_url_dir = "http://www.category.org/browse/$mode/";
$page = $total_page_p;
if ($page_count < 2)
{
print_next_list($file_next_old, $file_url_dir, $mode);
}
	if($total_item && $page_count != 1)
{
write_page_line($page_count, $mode, $search, $image_size, $review, $total_page, $total_item, $search_cgi_name, $simple_list, $sort, $node, $node_name);
#print "$font_face_1 Click image to see lager photo
";
#print "
 page  and page_count = $page_count 
";
}
#print "$page_count == 1 and $mode";
	while ($total_page_p <= $page && $page < $total_page_n)
	{
		$page++;
		#print " stage =$search_step: $file_mode, $file_node; search nodes: page = $page\n";
		#if ($page == 1) change for search review 10/20/2004
		if (!$total_item)
		{
			$total_item = Main_Search($page_count, $mode, $search, $page, $image_size, $review, $total_page, $simple_list, $search_cgi_name, $photo_asin, $node, $sort, $searchtype, $node_name, $subject, $public_key, $private_key);
		}
		else
		{
			Main_Search($page_count, $mode, $search, $page, $image_size, $review, $total_page, $simple_list, $search_cgi_name, $photo_asin, $node, $sort, $searchtype, $node_name, $subject, $public_key, $private_key);
		}
		#Main_Search($file_mode, $file_node, $page);
	}
	$contact = '
contact: info@n2000.com'; $copyright = '
Copyright © 1998-2007 geometry.net';
	if ($total_item == 0 and $searchtype != "asin" and $searchtype != "ListManiaSearch" and $mode != "review")
	{
		#print "aaa $mode";
		if ($search && $mode !="office-products")
		{
		Print "Your search - $subject : $search_d - did not match any items.
 You may try a new search, or browse the subcategories for $subject:
"; $search = ""; print $browse_subject; print_next_list($file_next_old, $file_url_dir, $mode); Main_Search($page_count, $mode, $search, $page, $image_size, $review, $total_page, $simple_list, $search_cgi_name, $photo_asin, $node, $sort, $searchtype, $node_name, $subject, $public_key, $private_key); } elseif ($search) { Print "Your search - $subject : $search_d - did not match any items.
"; } } if ($total_item) { write_page_line($page_count, $mode, $search, $image_size, $review, $total_page, $total_item, $search_cgi_name, $simple_list, $sort, $node, $node_name); } #print_form("advanced", $mode, $search_d, $page, $image_size, $review, $total_page, $subject, $search_cgi_name, $simple_list, $sort, $searchtype); #if($page_count == 1 and $mode) if($mode && $search && $mode !="office-products") { #print $browse_subject; print_next_list($file_next_old, $file_url_dir, $mode); #print "$file_next_old, $file_url_dir"; } if ($total_item) { print "
Questions on ordering or shipping? click here for help."; } #if ($mode != "office-products") #{ print $copyright; print $contact; #} print ""; print ' '; print "