<?php
include_once("includes/global.php");
include_once("includes/smarty_config.php");
include_once("includes/point_inc.php");
include_once("includes/news_function.php");
//=========================================
$id=is_numeric($_GET["id"])?$_GET['id']:die('Error');
$pagecurrent=!empty($_GET['page'])&&is_numeric($_GET['page'])?$_GET['page']:1;
//-----------------------------------------
$db->query("update ".NEWSD." set onclick=onclick+1 where nid='$id'");
if($bcid)
{
	$sql="select ifpay from ".COMPANY." WHERE company_id='$bcid'";
	$db->query($sql);
	$ifpay=$db->fetchField('ifpay');
}
user_read_rec($buid,$id,4);//记当会员查看文章
//==============================
useCahe("news_detail/",true);
$flag=md5($dpid.$dcid.$config["temp"].$id.$pagecurrent);
if(!$tpl->is_cached($page,$flag))
{
	$sql="SELECT a.*,b.con FROM ".NEWSD." a left join ".NEWSDATA." b on a.nid=b.nid WHERE a.nid='$id'";
	$db->query($sql);
	$news=$db->fetchRow();
	
	$sql="SELECT cat,template,catid FROM ".NEWSCAT." WHERE catid='$news[classid]'";
	$db->query($sql);
	$ncat=$db->fetchRow();
	$news['cat']=$ncat['cat'];
	
	$newsc=str_replace('<hr class="ke-pagebreak" style="page-break-after:always;" />',"[#page#]",$news['con']);
	$newsc=str_replace('<hr style="page-break-after:always;" class="ke-pagebreak" />',"[#page#]",$newsc);
	$articletext=array();
	$articletext=explode('[#page#]',$newsc);
	$nums=count($articletext);//算出数组长度
	$cp=$pagecurrent-1;
	$phref='';
	if($nums>1)
	{
		 for($i=1;$i<=$nums;$i++)
		 {
				if($i!=$pagecurrent)
				  $phref=$phref.'<a href="'.$config['weburl'].'/?m=news&s=detail&id='.$id.'&page='.$i.'"><span style="border:#b6daeb 1px solid;background-color:#ffffff;display:moz-inline-box;display:inline-block;height:25px;width:25px;"><font size=4>'.$i.'</font></span></a>&nbsp;&nbsp;';
				else
				  $phref=$phref.'<span style="border:#ffd6b4 1px solid;background-color:#b6daeb;display:block;display:-moz-inline-box; display:inline-block; height:25px;width:25px;"><font size=4>'.$i.'</font></span>&nbsp;&nbsp;';
		 }
	}
	$tpl->assign("pages",$phref);
	$tpl->assign("ncontent",$articletext[$cp]);
	$tpl->assign("de",$news);
	//-------------------------------------------
	$ar1=array('[catname]','[title]','[keyword]','[des]');
	$ar2=array($news['cat'],$news['ftitle'],$news['keyboard'],strip_tags($prode['con']),$news['smalltext']);
	$config['title']=str_replace($ar1,$ar2,$config['title3']);
	$config['keyword']=str_replace($ar1,$ar2,$config['keyword3']);
	$config['description']=str_replace($ar1,$ar2,$config['description3']);
	//--------------------------------------------
}
if(!empty($ncat['template']))
	$tpl->assign("current",$ncat['id']);
else
	$tpl->assign("current","news");

$page='news_detail.htm';
//======================================
include_once("footer.php");
$out=tplfetch($page,$flag);
?>