<?php

	defined('IN_TS') or die('Access Denied.');
	
	$huabaoid = intval(_get('id'));
	
	if($huabaoid == 0)
	{
		@header("http/1.1 404 not found"); 
		@header("status: 404 not found");
		include template("404");
		exit(); 
	}
	
	$huabao_arr = $db->once_fetch_assoc("select * from ".dbprefix."p_str where pictorialId =".$huabaoid);
	
	$huabao_arr_next  = $db->once_fetch_assoc("select * from ".dbprefix."p_str where pictorialId<".$huabaoid."  order by pictorialId desc limit 0,1");
	
	 $huabao_arr_prev = $db->once_fetch_assoc("select * from ".dbprefix."p_str where pictorialId>".$huabaoid."  order by pictorialId desc limit 0,1");

	
	
	if($huabaoid == 0|| !is_array($huabao_arr))
	{
		@header("http/1.1 404 not found"); 
		@header("status: 404 not found");
		include template("404");
		exit(); 
	}
	
	
	//相关商品
	$gi=1;
	
	
	foreach($strShare['tags'] as $gtkey=>$gtitem){
		if($gi<=5){
		 $xggoodsarray=$db->fetch_all_assoc("select huabaoid from ".dbprefix."tag_share_goods where tagid=".$gtitem['tag_id']." and huabaoid <>".$huabaoid." limit 0,3");


		 foreach($xggoodsarray as $xggkey=>$xggitem){
			if(aac("baobei")->getOneShare($xggitem['huabaoid']))
		  $strShare['tags'][$gtkey]['good'][$xggkey]=aac("baobei")->getOneShare($xggitem['huabaoid']);
		 }
		 
		}
	 }
	 
	 
	

	

	//分享者开始
	$shareuserid = $huabao_arr['uid'];
	
	$strshareUser = $db->once_fetch_assoc("select * from ".dbprefix."user_info where userid='$shareuserid'");
	
	//头像
		if($strshareUser['face'] != ''){
			$strshareUser['face'] = SITE_URL.miniimg($strshareUser['face'],'user',48,48,$strshareUser['path'],1);
			
		}else{
			$strshareUser['face']	= SITE_URL.'public/images/noavatar.gif';
		}
	
	//分享者结束

	//画报
	
	
	$p_id_arr = explode('_',$huabao_arr['p_str']);
	
	$f_pictorial = $db->once_fetch_assoc("select * from ".dbprefix."pictorial where id =".$p_id_arr[0]);
	$goods_id_arr = explode(',',$f_pictorial['goodslink']);

	foreach($goods_id_arr  as $key=>$item){
		if($item){
		$f_goods[] = $db->once_fetch_assoc("select * from ".dbprefix."share_goods where goods_id='$item'");
		}
	}
	
	
	foreach($p_id_arr as $key=>$item){
		$pictorial = $db->once_fetch_assoc("select * from ".dbprefix."pictorial where id =".$item);
		$productIds=array();
		$productList=array();
		$productImgList=array();
		$productTitle=array();
		$productImg=array();
		$productPrice=array();
		
		$goods_id_arr = explode(',',$pictorial['goodslink']);
		
		foreach($goods_id_arr  as $kkey=>$iitem){
			if($iitem){
				$f_goods_arr = $db->once_fetch_assoc("select * from ".dbprefix."share_goods where goods_id='$iitem'");
				$productIds[] =$f_goods_arr['goods_id'];
				$productList[] =SITE_URL.tsurl('baobei',$f_goods_arr['goods_id']);
				$productImgList[] =$f_goods_arr['img'];
				$productTitle[] =$f_goods_arr['name'];
				$productImg[] =$f_goods_arr['img'];
				$productPrice[] =$f_goods_arr['price'];
			}
		}

		$huaban_arrs[$item] = array(
			'id'          => $pictorial['id'],
			'pictorialId' => $item,
			'description' => $pictorial['description'],
			'randStr'     => $item,
			'photo'=>SITE_URL.$pictorial['photo'],
			'width'=>$pictorial['width'],
			'height'=>$pictorial['height'],
			
			
			'productIds' => $productIds,
			'productList' => $productList,
			'productImgList'=>$productImgList,
			'productTitle'=>$productTitle,
			'productImg'=>$productImg,
			'productPrice'=>$productPrice,
		);
	}

		$p_json = outputJson($huaban_arrs,1);
	
	//更多精彩画报
	$move_huabao = $db->fetch_all_assoc("select * from ".dbprefix."p_str where pictorialId <>".$huabaoid."  limit 6");
	
	foreach($move_huabao as $key=>$item){
		
			$p_id_arr = explode('_',$item['p_str']);
	
			$move_f_pictorial = $db->once_fetch_assoc("select * from ".dbprefix."pictorial where id =".$p_id_arr[0]);
			
			$move_huabao[$key]['f_pictorial']=$move_f_pictorial;
			
			}
	
	$TS_SITE['base']['site_desc']  = $f_pictorial['description'];
	
	$title = $huabao_arr['title'].' - '.$TS_SITE['base']['site_title'];
	
	
	
	
	include template("show");
	