<?
#index.php
	include "config.inc.php";
	//trace($site_conf);
	include "class/article.class.php";
	include "include/template_func.php";
	include "include/smarty.php";
	include "menu/main_menu.php";
	include "class/member.class.php";
	include "class/conf.class.php";
	$page_title = $site_conf["system"]["site_name"];
	$module=$_REQUEST["module"];
	$action=$_REQUEST["action"];
	$cid =$_REQUEST["cid"];
	$page_title .= ($catetree[$cid]["name"])?"---".$catetree[$cid]["name"]:"";
	$member=new member();
	$user_info = $member->member_auth();
	$art=new Article();
	$conf = new conf();
	$cid=$_REQUEST["cid"]?$_REQUEST["cid"]:0;
	if(!checkCateAccess($cid)){
	if($ulevel=="Guest"){
	        echo $member->member_block();
	}else{
                redirect(PLUS_URL."/index.php?module=error");
	}
	}else{
	$aid = $_REQUEST["aid"];
	$title=$catetree[$cid]["name"];
	$template= $catetree[$cid]["cate_template"];
	$ctype = $catetree[$cid]["ctype"];
	$title = $site_conf[system]["site_name"];
	$position=getPosition($cid);
	if($site_conf[system][is_open]=='no'){
			echo $site_conf[system]["site_close_reason"];
			exit;
	}
	if($ctype == "page"){
		$showFullTemplate=1;
		ob_start();
		echo format_text($catetree[$cid]["intro"],1);
		$content=ob_get_contents();
		ob_end_clean();		
	}elseif($ctype=="topic"){
		$action="topic";
		$tid=$catetree[$cid]["topicid"];
		ob_start();
		include "modules/article/index.php";
		$content = ob_get_contents();
		ob_get_clean();
	}elseif($ctype=="url"){
	    	    $content =  "<script language='javascript'>";
	            $content.= "      location='".$catetree[$cid]["url"]."';";
    	    	$content.= "</script>";  	
	}else{
	if($cid==0 && empty($_REQUEST["module"]) && empty($_REQUEST["action"]) ) {
		$template="home.tpl";
		$position = "<a href=index.php class='plink'>"._LANG_0950."</a>";
		}
	if(($module=="" || empty($module)) && $ctype=="bbs" ) $module=$ctype;
	$dtemplate = $catetree[$cid]["detail_template"];
	ob_start();
	if($user_info["user_level"]=="guest"){
		include "modules/member/index.php";
	}else{
	switch($module){
		case "cart":
			include "modules/cart/index.php";
			break;
		case "member":
			include "modules/member/index.php";
			break;
		case "hotel":
			include "modules/hotel/index.php";
			break;
		case "travel":
			include "modules/travel/index.php";
			break;
		case "form":
			include "modules/form/index.php";
			break;
		case "bbs":
			include "modules/bbs/index.php";
			break;
		case "error":
			include "modules/errorhandle/index.php";
			break;
		case "human":
			include "modules/human/index.php";
			break;
		case "article":
		default:
			include "modules/article/index.php";
			break;
		}	
	}
	$content=ob_get_contents();
	ob_end_clean();
	}
	}
	if($showFullTemplate==0){
		echo $content;	
	}else{
	$template_path="template/".$site_conf["template"]["site_template"]."/category/$template";
	if(!file_exists($template_path) || is_dir($template_path)) $template_path = "template/".$site_conf[template][site_template]."/category/index.tpl";
	$smarty->assign("page_title",$page_title);
	$smarty->assign("cateinfo",$catetree[$cid]);
	$smarty->assign("system",$site_conf["system"]);
	$smarty->assign("root",PLUS_URL);
	$smarty->assign("position",$position);
	$smarty->assign("cid",$cid);
	if(!$_REQUEST[module] && !$_REQUEST["action"]) 	$smarty->assign("intro",$catetree[$cid]["intro"]);
	$smarty->assign("page_content",$content);
	//trace($template_path);
	$smarty->display($template_path);
}
?>
