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


$sr	= htmlspecialchars(var_request('sr','volume:desc'),ENT_QUOTES);
$page = intval(var_request("page","0"));
$sort = htmlspecialchars(var_request("sort","volume:desc"),ENT_QUOTES);
$sortnum = intval(var_request("sortnum",Show_shop_sort));

if($sortnum=="0")$sort="volume:desc";
if($sortnum=="1")$sort="delist_time:desc";
if($sortnum=="2")$sort="price:desc";
if($sortnum=="3")$sort="price:asc";
if($sortnum=="4")$sort="delistTime_desc";

$sp = intval(var_request("sp","1"));
$ep = intval(var_request("ep","1000000"));
$nick = getcnstr(var_request("nick_jt",""));


if(empty($nick)) $nick = urldecode(var_request('nick',"柠檬绿茶")); //默认昵称

	$nickstr = ($nick);

	$nick = htmlspecialchars(iconv("GBK","UTF-8",$nick),ENT_QUOTES);


$page	=	intval(var_request('page',1));
$page = $page>100?100:$page;


$results = null;

	$Taoapi->method = 'taobao.user.get';
	//$Taoapi->fields = 'sid,cid,nick,title,desc,bulletin,pic_path,created,modified';
	$Taoapi->fields = 'user_id,nick,seller_credit,type,has_shop';
	$Taoapi->nick = $nick;
	$resultuser = $Taoapi->Send('get','xml')->getArrayData();
	$resultuser = $resultuser['user'];

if($resultuser["has_shop"]=="true"){
	$Taoapi->method = 'taobao.shop.get';
	//$Taoapi->fields = 'sid,cid,nick,title,desc,bulletin,pic_path,created,modified';
	$Taoapi->fields = 'sid,cid,nick,title,pic_path,desc,created,modified';
	$Taoapi->nick = $nick;
	$results = $Taoapi->Send('get','xml')->getArrayData();
}


$title = "";
if( isset($results['shop']) ) {
	$item = $results['shop'];
	if( isset( $item['title'] ) ) {
		$title = iconv("UTF-8", "GBK",$item['title']);
	}
}



if($resultuser["has_shop"]=="true"){
	$Taoapi->method = 'taobao.items.get';
	$Taoapi->fields = 'pic_url,iid,num_iid,title,nick,cid,price,type,delist_time,post_fee,volume';
	$Taoapi->nicks = $nick;
	$Taoapi->page_no = $page;
	$Taoapi->page_size = $pagenumKeys;

	$Taoapi->order_by = $sort;
	$Taoapi->start_price = $sp;
	$Taoapi->end_price = $ep;

	$results = $Taoapi->Send('get','xml')->getArrayData();
}

	

$taobaokeItem = $results['items']['item'];
$totalResults = $results['total_results'];

$mingcheng = iconv("UTF-8","GBK",$nick);


function good( $good=0, $total=0){
	return round(($good/$total)*100,2)."%";
}

function clearhtml($str){
	return strip_tags($str);
}

//过滤标题

for($i = 0; $i < count($taobaokeItem); $i++) {
	
	if(!isset($taobaokeItem[$i]["title"])) break;
	$taobaokeItem[$i]["title"] =Newiconv("GBK","UTF-8", setsplitkeyword($searchkeypb,Newiconv("UTF-8","GBK",$taobaokeItem[$i]["title"]),"***"));
	$taobaokeItem[$i]["title"] =str_replace("'","'",Newiconv("GBK","UTF-8", Newiconv("UTF-8","GBK",(strip_tags($taobaokeItem[$i]["title"])))));

}

if($shop_title=="")$shop_title = "{店铺名},掌柜{卖家昵称}的淘宝店铺商品列表|淘宝主题店推荐_{网站名}";
if($shop_keyword=="")$shop_keyword = "{店铺名},淘宝网店铺";
if($shop_discription=="")$shop_discription = "您查看的是淘宝网主题店【{店铺名}】的所有商品列表和掌柜{卖家昵称}的店铺资料。该主题店是淘宝网正规主题店铺，您可根据卖家的信誉度选择信誉较高的卖家。";

$tihuanarr = array();
$tihuanarr["{店铺名}"] = $title;
$tihuanarr["{卖家昵称}"] = $mingcheng;
$tihuanarr["{网站名}"] = $sitetitle;


$page_title = strtr($shop_title,$tihuanarr); 
$page_keyword = strtr($shop_keyword,$tihuanarr); 
$page_discription = strtr($shop_discription,$tihuanarr); 

if($is_indexs=="ok"){
	$page_title = $sitetitle;
	$page_keyword = $sitekey; 
	$page_discription = $sitedesc; 
}


require_once WEBROOT.'include/functiondaohang.php';


require_once(WEBROOT."include/pages.php");

//加载模板
require_once WEBROOT.'template/'.$templatefolder.'/shop.php';

showend();
?>
