<?php
	include substr(dirname(__FILE__),0,-4).'/include/common.inc.php';
	
	$page=isset($page)?max(intval($page),1):1;

	$r=$yp->ypinfobyu($u);
	$id=$ypid=intval($r['id']);

	$typeid=isset($typeid)?intval($typeid):0;

	if($ypid<=0) 
	{
		show404($yplang['msg-yp-noexists']);
	}

	/*
		优先读取缓存
	*/
	$data=$cache->get(md5(CURURL));

	if(!$data)
	{
		/*
			获取黄页数据
		*/
		$data=$yp->allinfo($ypid);
		if(!$data) 
		{
			show404($yplang['msg-yp-noexists']);
		}
		$YP=array();

		if($data['status']==2)
		{
			show404($yplang['msg-yp-closed-admin']);
		}

		if($data['status']==0)
		{
			show404($yplang['msg-yp-closed-owner']);
		}
		unset($data['password'],$data['typeid']);
		$cache->set(md5(CURURL),$data);
	}
	$YP['domain']=$data['domain'];
	$areaid=$data['areaid'];
	extract($data,EXTR_SKIP);

	/*
		SEO数据
	*/

	if(!$data['menu'])
	{
		$data['menu']=array(
						'店铺首页'=>'yp/web/index.php?u='.$data['dir'].'&siteid='.SITEID,
						'新闻动态'=>'yp/web/news.php?u='.$data['dir'].'&siteid='.SITEID,
						'产品展示'=>'yp/web/product.php?u='.$data['dir'].'&siteid='.SITEID,
						'优惠促销'=>'yp/web/discount.php?u='.$data['dir'].'&siteid='.SITEID,
						'联系我们'=>'yp/web/contact.php?u='.$data['dir'].'&siteid='.SITEID,
						'在线留言'=>'yp/web/guestbook.php?u='.$data['dir'].'&siteid='.SITEID
					);
	}
	else
	{
		$data['menu']=string2array($data['menu']);
	}
	$menu=array_keys($data['menu']);
	$YP['menu']['index']=$menu[0];
	$YP['menu']['news']=$menu[1];
	$YP['menu']['product']=$menu[2];
	$YP['menu']['discount']=$menu[3];
	$YP['menu']['contact']=$menu[4];
	$YP['menu']['guestbook']=$menu[5];
	
	$YP['url']['index']=$data['menu'][$menu[0]];
	$YP['url']['news']=$data['menu'][$menu[1]];
	$YP['url']['product']=$data['menu'][$menu[2]];
	$YP['url']['discount']=$data['menu'][$menu[3]];
	$YP['url']['contact']=$data['menu'][$menu[4]];
	$YP['url']['guestbook']=$data['menu'][$menu[5]];

	$head['title'] =$YP['menu']['product'].'-'.$name;

	$head['keywords'] =$meta_keywords;
	$head['description'] =$meta_description;

	/*
		会员等级
	*/
	$r=cache_read('membergrade'.$gradeid.'.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$gradename=$r['name'];
	include template('list_product','yp',$template);
?>