<?php
	define('T_ROOT', str_replace("\\", '/',substr(dirname(__FILE__),0,-3)));
	include T_ROOT.'include/common.inc.php';
	$action=$action?$action:'index';
	if(!in_array($action,array('index','list','flist','show')))exit('错误的请求!');
	switch($action)
	{
		case 'index':
			$tlp='wap';
			break;
		case 'list':
			$dir_catid=$id=intval($id); //2010-11-26
			$r=cache_read('category'.$id.'.cache.php',DIRCMS_ROOT.'data/cache_category/');
			$html=$r['listpage'];
			$final_catid=cache_read('finalcatid.cache.php',DIRCMS_ROOT.'data/cache_category/');
			if(!$r)showmsg('访问的栏目不存在!',$DIRCMS['site_url']);
			if(!$r['isshow'])showmsg('访问的栏目已被禁止访问!',$DIRCMS['site_url']);
			$dir_postion=$position=get_pos($id);
			@extract($r);
			$dir_url=$DIRCMS['site_url'].$r['url'];
			$dir_catname=$categoryname;
			$template=in_array($id,$final_catid)?$listtlp:$categorytlp;
			$page=isset($page)?intval($page):1;
			$page=(in_array($id,$final_catid) || $html)?max(1,intval($page)):0;
			$dir_catid=$catid=$id;
			$dir_search=$searchoption=searchoption($catid);
			$tlp='wap_list';
			break;
		case 'flist':
			$dir_catid=$id=intval($id); //2010-11-26
			$r=cache_read('category'.$id.'.cache.php',DIRCMS_ROOT.'data/cache_category/');
			$html=$r['listpage'];
			$final_catid=cache_read('finalcatid.cache.php',DIRCMS_ROOT.'data/cache_category/');
			if(!$r)showmsg('访问的栏目不存在!',$DIRCMS['site_url']);
			if(!$r['isshow'])showmsg('访问的栏目已被禁止访问!',$DIRCMS['site_url']);
			$dir_postion=$position=get_pos($id);
			@extract($r);
			$dir_url=$DIRCMS['site_url'].$r['url'];
			$dir_catname=$categoryname;
			$template=in_array($id,$final_catid)?$listtlp:$categorytlp;
			$page=isset($page)?intval($page):1;
			$page=(in_array($id,$final_catid) || $html)?max(1,intval($page)):0;
			$dir_catid=$catid=$id;
			$dir_search=$searchoption=searchoption($catid);
			$tlp='wap_flist';
			break;
		case 'show':
			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;
			$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);
			$tlp='wap_show';
			break;
	}
	include template($tlp);
?>