<?php
require_once WEBROOT.'include/function.php';

$indexs = application("index",ROOT."indexdata.php");



$indextaobaokeItemArray = array ();


for($i=0;$i<count($indexs);$i++){
	//自动提交更新JS
	//检测单页商品调用
	if(!empty($indexs[$i]["indexsort"])) $indexsort = $indexs[$i]["indexsort"];
	if($i==0 && $singerpagesite==1){
		
		if(empty($indexs[$i]["nick"])) {
			$_GET["catid"] = $indexs[$i]["catid"];
			$_GET["q"] = $indexs[$i]["keyword"];
			$is_indexs = "ok";
			require_once WEBROOT.'source/source_list.php';
		} else {
			
			$_GET["nick"] = $indexs[$i]["nick"];
			switch($indexsort){
				case "commissionNum_desc":
					$_GET["sort"] = "volume:desc";
					break;
				case "commissionNum_asc":
					$_GET["sort"] = "volume:asc";
					break;
				case "price_desc":
					$_GET["sort"] = "price:desc";
					break;
				case "price_asc":
					$_GET["sort"] = "price:asc";
					break;
				case "delistTime_desc":
					$_GET["sort"] = "delist_time:desc";
					break;
				case "delistTime_asc":
					$_GET["sort"] = "delist_time:asc";
					break;
				default:
					$_GET["sort"] = "volume:desc";
					break;
			}
			
			$is_indexs = "ok";
			require_once WEBROOT.'source/source_shop.php';
		}
		
		
		exit;
	}
	
	$Taoapi->method = 'taobao.taobaoke.items.get';
	$Taoapi->fields = 'iid,num_iid,title,nick,pic_url,price,click_url,shop_click_url,seller_credit_score,commission,commission_rate,commission_num,commission_volume';
	$Taoapi->pid = $userpiddp;
	if($indexs[$i]["catid"]!="0") $Taoapi->cid = $indexs[$i]["catid"];
	
			switch($indexpagernd){
				case "page":
					$indexpage = intval(date("s"));
					break;
				case "hour":
					$indexpage = intval(date("H"));
					break;
				case "minute":
					$indexpage = intval(date("i"));
					break;
				case "day":
					$indexpage = intval(date("d"));
					break;
				default:
					break;
			}
	$Taoapi->page_no = $indexpage;
	$Taoapi->page_size = 40;
	
	
	$Taoapi->sort = $indexsort;
	$Taoapi->start_price = '25';
	$Taoapi->end_price = '5000';
	
	if(!empty($defaultarea)){
		$Taoapi->area = $defaultarea;
	}
	if(isset($indexs[$i]["keyword"])){
	$Taoapi->keyword = Newiconv("GBK","UTF-8",$indexs[$i]["keyword"]);
	}
	
	$Taoapi->start_credit = $shoplevelstart;
	$Taoapi->end_credit  = $shoplevelend;
	$Taoapi->start_commissionRate  = $stratmoneyKeys;
	$Taoapi->end_commissionRate  = $endmoneyKeys;
	if($ismall=="1")$Taoapi->mall_item = "true";
	
	$indexcache = $Taoapi->Send('get','xml')->getArrayData();
	
	$temparr = $indexcache["taobaoke_items"]["taobaoke_item"];
	for($x = 0; $x < count($temparr); $x++) { 
	
		if(!isset($indexcache["taobaoke_items"]["taobaoke_item"][$x]["title"])) break;
		
		$indexcache["taobaoke_items"]["taobaoke_item"][$x]["title"] =strtr(strip_tags($indexcache["taobaoke_items"]["taobaoke_item"][$x]["title"]),"'","*");
		
		$indexcache["taobaoke_items"]["taobaoke_item"][$x]["taodiurl"] = getproducturl($indexcache["taobaoke_items"]["taobaoke_item"][$x]["num_iid"]);
		
	}
	
	
	for($x=1;$x<=count($indexs[$i]["shoplist"]);$x++){
		$indexs[$i]["shoplist"][$x]["shopurl"] = strtr($indexs[$i]["shoplist"][$x]["shopurl"],$pidsplit);
	}
	$indexs[$i]["lpiclink"] = strtr($indexs[$i]["lpiclink"],$pidsplit);
	$indexs[$i]["rpiclink"] = strtr($indexs[$i]["rpiclink"],$pidsplit);
	
	$indextaobaokeItemArray[$i] = $indexcache;
	$indextaobaokeItemArray[$i]["catid"] = $indexs[$i]["catid"];
	$indexcache = "";
	
	
}

require_once WEBROOT.'include/functiondaohang.php';


//加载模板
require_once WEBROOT.'template/'.$templatefolder.'/index.php';
showend();

?>
