<?php
	require dirname(__FILE__).'/include/common.inc.php';
	require DIRCMS_ROOT.'include/version.inc.php';
	require DIRCMS_ROOT.'include/admin/content.class.php';
	$c=new content();
	$dir_contentid=$id=intval($id);
	$r=$c->get($id);
	if(!$r)showmsg('访问的内容不存在!',$DIRCMS['site_url']);
	if(!$r['status'] && $_groupid!=1)showmsg('访问的内容待审核!',$DIRCMS['site_url']);
	$groupid=explode(',',$r['groupid']);
	$_isvip=intval($_isvip)?intval($_isvip):0;
	if($r['groupid'] && !in_array($_isvip,$groupid) && $_groupid!=1)$r['content']='您的会员级别没有查看该内容的权限!';
	@extract($r);	
	if(!$r['status'])$title=$title.'<font color="#ff0000">[待审内容]</font>';
	unset($r,$c);
	$dir_url=$DIRCMS['site_url'].$url;
	$c=preg_split('/<div style=\"page-break-after: always\"><span style=\"display: none\">&nbsp;<\/span><\/div>/i',$content);
	$pages=count($c)>1?count($c):0;

	if($pages)
	{
		$page=intval($page)?max(1,intval($page)):1;
		$page=min(($pages+1),intval($page));
		$cururl=preg_replace('/([&\?]?)(page=[0-9]+)([&\?]?)/i','\\1',getcururl());
		$cururl=substr($cururl,-1)=='&'?$cururl:$cururl.'&';
		for($i=1;$i<=$pages;$i++)
		{
			$pagestring.='<a href="'.$cururl.'page='.$i.'">'.$i.'</a>';
		}
		$t=$page-1;
		$content=$c[$t];
	}
	$dir_page=$pagestring;
	$r=cache_read('category'.$catid.'.cache.php',DIRCMS_ROOT.'data/cache_category/');
	$dir_catid=$catid=$r['id'];
	$dir_catname=$catname=$r['categoryname'];
	if($_groupid!=1 && (!$_userid || $r['viewpoint']<$point) && $point) //扣除积分
	{
		$content='<font style="color:#ff0000;font-size:12px">浏览该内容需要'.$point.'积分,您没有足够的积分查看该内容!</font>';
	}
	else
	{
		$db->update(DB_PRE."member",array('point'=>intval($point-$r['viewpoint'])),'id='.$_userid);
	}
	$dir_postion=$position=get_pos($catid);
	$dir_search=$searchoption=searchoption($catid);
	include template($template);
?>