<?php
   //
     defined('IN_TS') or die('Access Denied.');
	 
	 $caitem=$_GET['ac'];

	
	
	 
	 //热榜
	 $zhutitoparray = $db->fetch_all_assoc("select * from ".dbprefix."theme where cate = '".$caitem."' order by likenum desc,istop desc,uptime desc limit 0,6 ");
	 foreach($zhutitoparray as $zhutitoparraykey=>$zhutitoparrayitem){
		 	if($zhutitoparrayitem['strgoodid']!=NULL){
				$goodsidarray=explode(",",$zhutitoparrayitem['strgoodid']);
		        $zhutitoparray[$zhutitoparraykey]['goodsnum']=count($goodsidarray);
			}
	 }
	 
	
	 $page = isset($_GET['p']) ? intval($_GET['p']) : '1';
	 
	 $url = SITE_URL.tsurl('zhuti','',array('ac'=>$caitem,'per'=>'perzhuti','p'=>''));
	 
	
	 
	$lstart = $page*36-36;
	
	 $zhutiarraynum = $db->fetch_all_assoc("select count(*) as num from ".dbprefix."theme where cate = '".$caitem."'  ");
	 
	 $allpage=ceil($zhutiarraynum[0]['num']/36);
	 
	  
	   
	 if($allpage>$page)
	 {
	    $nexturl =SITE_URL.tsurl('zhuti','',array('ac'=>$caitem,'per'=>'perzhuti','p'=>$page+1));
	 }
	 
	
	  
	 if($page>1)
	 {
	   $perurl =SITE_URL.tsurl('zhuti','',array('ac'=>$caitem,'per'=>'perzhuti','p'=>$page-1));
	 }
	
	$pageUrl = nopin_pagination($zhutiarraynum['num'], 4, $page, $url);
	  
	
	 
    $zhutiarray = $db->fetch_all_assoc("select * from ".dbprefix."theme where cate = '".$caitem."' order by istop desc,recom desc,uptime desc  limit $lstart,36 ");
	
	$mmlp='';
	
				foreach($zhutiarray as $ztakey=>$ztaitem){
				$mmlp[$ztakey]=$ztaitem;
				if($ztaitem['strgoodid']!=NULL){
				$goodsidarray=explode(",",$ztaitem['strgoodid']);
			
		        $mmlp[$ztakey]['goodsnum']=count($goodsidarray);
				
				$goodsidarray=array_slice($goodsidarray,-9,9);
					foreach($goodsidarray as $gikey=>$giitem){
			 
				    $goodsmessage=$db->once_fetch_assoc("select goods_id,name,img from ".dbprefix."share_goods where goods_id = ".$giitem);
	  
				$mmlp[$ztakey]['goods'][$gikey]['goods_id']=$goodsmessage['goods_id'];
				$mmlp[$ztakey]['goods'][$gikey]['name']=$goodsmessage['name'];
				$mmlp[$ztakey]['goods'][$gikey]['simg']=$goodsmessage['img'];
				
				   }
				}else{
				$mmlp[$ztakey]['goodsnum']=0;	
				}
				
				$mmlp[$ztakey]['user']=aac('user')->getOneUserByUserid($ztaitem['userid']);
			}
           
     
   
	$title = $caitem.' - 主题街';
	$LE_APPone['qit']="其他";
   	include template("pertheme");
?>
